1 /* Copyright 1988, 1996 by the Massachusetts Institute of Technology.
3 * Permission to use, copy, modify, and distribute this
4 * software and its documentation for any purpose and without
5 * fee is hereby granted, provided that the above copyright
6 * notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting
8 * documentation, and that the name of M.I.T. not be used in
9 * advertising or publicity pertaining to distribution of the
10 * software without specific, written prior permission.
11 * M.I.T. makes no representations about the suitability of
12 * this software for any purpose. It is provided "as is"
13 * without express or implied warranty.
16 /* This file is a simple driver for the Hesiod library. */
18 static char rcsid[] = "$Id: hesinfo.c,v 1.8 1996/12/08 21:29:54 ghudson Exp $";
28 int main(int argc, char **argv)
30 char **list, **p, *bindname, *name, *type;
31 int lflag = 0, errflg = 0, bflag = 0, c, status;
34 while ((c = getopt(argc, argv, "lb")) != EOF)
49 if (argc - optind != 2 || errflg)
51 fprintf(stderr,"Usage: %s [-bl] name type\n",argv[0]);
52 fprintf(stderr,"\t-l selects long format\n");
53 fprintf(stderr,"\t-b also does hes_to_bind conversion\n");
58 type = argv[optind + 1];
60 if (hesiod_init(&context) < 0)
63 fprintf(stderr, "hesiod_init: Invalid Hesiod configuration file.\n");
65 perror("hesiod_init");
68 /* Display bind name if requested. */
72 printf("hes_to_bind(%s, %s) expands to\n", name, type);
73 bindname = hesiod_to_bind(context, name, type);
79 fprintf(stderr, "hesiod_to_bind: Unknown rhs-extension.\n");
81 perror("hesiod_to_bind");
84 printf("%s\n", bindname);
91 printf("resolves to\n");
93 /* Do the hesiod resolve and check for errors. */
94 list = hesiod_resolve(context, name, type);
100 fprintf(stderr, "hesiod_resolve: Hesiod name not found.\n");
102 perror("hesiod_resolve");
106 /* Display the results. */
107 for (p = list; *p; p++)
110 hesiod_free_list(context, list);