Use err(3).

This commit is contained in:
Philippe Charnier 1997-10-27 12:30:30 +00:00
parent e7f0e9ca56
commit 0069349cc5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=30778
2 changed files with 14 additions and 18 deletions

View file

@ -34,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $Id$
.\" $Id: yppoll.8,v 1.1 1997/09/21 11:49:10 wosch Exp $
.\"
.Dd October 25, 1994
.Dt YPPOLL 8
@ -79,4 +79,4 @@ instead of the default domain as returned by
.Xr ypbind 8 ,
.Xr ypset 8
.Sh AUTHORS
Theo De Raadt and John Brezak
.An Theo De Raadt and An John Brezak

View file

@ -29,24 +29,27 @@
*/
#ifndef lint
static char rcsid[] = "yppoll.c,v 1.2 1993/08/02 17:57:20 mycroft Exp";
static const char rcsid[] =
"$Id$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <err.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
static void
usage()
{
fprintf(stderr, "Usage:\n");
fprintf(stderr, "\typpoll [-h host] [-d domainname] mapname\n");
fprintf(stderr, "usage: yppoll [-h host] [-d domainname] mapname\n");
exit(1);
}
@ -58,8 +61,6 @@ char **argv;
char *hostname = "localhost";
char *inmap, *master;
int order;
extern char *optarg;
extern int optind;
int c, r;
yp_get_default_domain(&domainname);
@ -83,18 +84,13 @@ char **argv;
inmap = argv[optind];
r = yp_order(domainname, inmap, &order);
if (r != 0) {
fprintf(stderr, "No such map %s. Reason: %s\n",
inmap, yperr_string(r));
exit(1);
}
printf("Map %s has order number %d. %s", inmap, order, ctime((time_t *)&order));
if (r != 0)
errx(1, "no such map %s. Reason: %s", inmap, yperr_string(r));
printf("Map %s has order number %d. %s", inmap, order,
ctime((time_t *)&order));
r = yp_master(domainname, inmap, &master);
if (r != 0) {
fprintf(stderr, "No such map %s. Reason: %s\n",
inmap, yperr_string(r));
exit(1);
}
if (r != 0)
errx(1, "no such map %s. Reason: %s", inmap, yperr_string(r));
printf("The master server is %s.\n", master);
exit(0);