2 * Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
3 * Copyright (c) 1992/3 John Brezak
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote
15 * products derived from this software without specific prior written
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * $FreeBSD: src/usr.sbin/yppoll/yppoll.c,v 1.5.2.2 2002/02/15 00:46:59 des Exp $
31 * $DragonFly: src/usr.sbin/yppoll/yppoll.c,v 1.3 2005/11/24 22:23:02 swildner Exp $
34 #include <sys/param.h>
35 #include <sys/types.h>
36 #include <sys/socket.h>
45 #include <rpcsvc/yp_prot.h>
46 #include <rpcsvc/ypclnt.h>
51 fprintf(stderr
, "usage: yppoll [-h host] [-d domainname] mapname\n");
56 main(int argc
, char **argv
)
59 char *hostname
= "localhost";
64 yp_get_default_domain(&domainname
);
66 while ((c
= getopt(argc
, argv
, "h:d:")) != -1)
79 if (optind
+ 1 != argc
)
84 r
= yp_order(domainname
, inmap
, &order
);
86 errx(1, "no such map %s. Reason: %s", inmap
, yperr_string(r
));
87 printf("Map %s has order number %d. %s", inmap
, order
,
88 ctime((time_t *)&order
));
89 r
= yp_master(domainname
, inmap
, &master
);
91 errx(1, "no such map %s. Reason: %s", inmap
, yperr_string(r
));
92 printf("The master server is %s.\n", master
);