1 /* $NetBSD: hesinfo.c,v 1.1 1999/01/25 22:45:55 lukem Exp $ */
3 /* Copyright 1988, 1996 by the Massachusetts Institute of Technology.
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for any purpose and without
7 * fee is hereby granted, provided that the above copyright
8 * notice appear in all copies and that both that copyright
9 * notice and this permission notice appear in supporting
10 * documentation, and that the name of M.I.T. not be used in
11 * advertising or publicity pertaining to distribution of the
12 * software without specific, written prior permission.
13 * M.I.T. makes no representations about the suitability of
14 * this software for any purpose. It is provided "as is"
15 * without express or implied warranty.
17 * $FreeBSD: src/usr.bin/hesinfo/hesinfo.c,v 1.7 2002/09/04 23:29:01 dwmalone Exp $
20 /* This file is a simple driver for the Hesiod library. */
31 main(int argc
, char **argv
)
33 char **list
, **p
, *bindname
, *name
, *type
;
34 int lflag
= 0, errflg
= 0, bflag
= 0, c
;
37 while ((c
= getopt(argc
, argv
, "lb")) != -1) {
50 if (argc
- optind
!= 2 || errflg
) {
51 fprintf(stderr
, "usage: hesinfo [-bl] name type\n");
52 fprintf(stderr
, "\t-l selects long format\n");
53 fprintf(stderr
, "\t-b also does hes_to_bind conversion\n");
57 type
= argv
[optind
+ 1];
59 if (hesiod_init(&context
) < 0) {
62 "hesiod_init: Invalid Hesiod configuration file.");
66 /* Display bind name if requested. */
69 printf("hes_to_bind(%s, %s) expands to\n", name
, type
);
70 bindname
= hesiod_to_bind(context
, name
, type
);
75 warnx("hesiod_to_bind: Unknown rhs-extension.");
77 warn("hesiod_to_bind");
80 printf("%s\n", bindname
);
86 printf("resolves to\n");
88 /* Do the hesiod resolve and check for errors. */
89 list
= hesiod_resolve(context
, name
, type
);
94 warnx("hesiod_resolve: Hesiod name not found.");
96 warn("hesiod_resolve");
99 /* Display the results. */
100 for (p
= list
; *p
; p
++)
103 hesiod_free_list(context
, list
);