diff options
author | charnier <charnier@FreeBSD.org> | 1997-10-13 11:13:33 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-10-13 11:13:33 +0000 |
commit | 8f640499e9439317b5c4c86c9e29cebdf7d2fcbd (patch) | |
tree | 8551f6336b076c1eac810d9b3c0620185755588a /usr.sbin/rpc.lockd/lockd.c | |
parent | 5b323e1a4836fcfb03b1e09ee91f62997da87f09 (diff) | |
download | FreeBSD-src-8f640499e9439317b5c4c86c9e29cebdf7d2fcbd.zip FreeBSD-src-8f640499e9439317b5c4c86c9e29cebdf7d2fcbd.tar.gz |
Use err(3). Add usage() and #includes.
Diffstat (limited to 'usr.sbin/rpc.lockd/lockd.c')
-rw-r--r-- | usr.sbin/rpc.lockd/lockd.c | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/usr.sbin/rpc.lockd/lockd.c b/usr.sbin/rpc.lockd/lockd.c index 092628a..44a5e21 100644 --- a/usr.sbin/rpc.lockd/lockd.c +++ b/usr.sbin/rpc.lockd/lockd.c @@ -31,19 +31,29 @@ * */ +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ /* main() function for NFS lock daemon. Most of the code in this */ /* file was generated by running rpcgen /usr/include/rpcsvc/nlm_prot.x */ /* The actual program logic is in the file procs.c */ +#include <err.h> +#include <stdlib.h> +#include <string.h> +#include <rpc/rpc.h> +#include <rpc/pmap_clnt.h> #include "lockd.h" void nlm_prog_1 __P((struct svc_req *, SVCXPRT *)); void nlm_prog_3 __P((struct svc_req *, SVCXPRT *)); +static void usage __P((void)); int debug_level = 0; /* Zero means no debugging syslog() calls */ - +int main(int argc, char **argv) { SVCXPRT *transp; @@ -51,10 +61,7 @@ main(int argc, char **argv) if (argc > 1) { if (strncmp(argv[1], "-d", 2)) - { - fprintf(stderr, "Usage: rpc.lockd [-d [<debuglevel>]]\n"); - exit(1); - } + usage(); if (argc > 2) debug_level = atoi(argv[2]); else debug_level = atoi(argv[1] + 2); /* Ensure at least some debug if -d with no specified level */ @@ -66,44 +73,24 @@ main(int argc, char **argv) transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) - { - (void)fprintf(stderr, "cannot create udp service.\n"); - exit(1); - } + errx(1, "cannot create udp service"); if (!svc_register(transp, NLM_PROG, NLM_VERS, nlm_prog_1, IPPROTO_UDP)) - { - (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERS, udp).\n"); - exit(1); - } + errx(1, "unable to register (NLM_PROG, NLM_VERS, udp)"); if (!svc_register(transp, NLM_PROG, NLM_VERSX, nlm_prog_3, IPPROTO_UDP)) - { - (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERSX, udp).\n"); - exit(1); - } + errx(1, "unable to register (NLM_PROG, NLM_VERSX, udp)"); transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) - { - (void)fprintf(stderr, "cannot create tcp service.\n"); - exit(1); - } + errx(1, "cannot create tcp service"); if (!svc_register(transp, NLM_PROG, NLM_VERS, nlm_prog_1, IPPROTO_TCP)) - { - (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERS, tcp).\n"); - exit(1); - } + errx(1, "unable to register (NLM_PROG, NLM_VERS, tcp)"); if (!svc_register(transp, NLM_PROG, NLM_VERSX, nlm_prog_3, IPPROTO_TCP)) - { - (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERSX, tcp).\n"); - exit(1); - } + errx(1, "unable to register (NLM_PROG, NLM_VERSX, tcp)"); /* Note that it is NOT sensible to run this program from inetd - the */ /* protocol assumes that it will run immediately at boot time. */ - if (daemon(0,0)) { - perror("cannot fork"); - exit(1); - } + if (daemon(0,0)) + err(1, "fork"); openlog("rpc.lockd", 0, LOG_DAEMON); if (debug_level) syslog(LOG_INFO, "Starting, debug level %d", debug_level); else syslog(LOG_INFO, "Starting"); @@ -111,3 +98,10 @@ main(int argc, char **argv) svc_run(); /* Should never return */ exit(1); } + +static void +usage() +{ + fprintf(stderr, "usage: rpc.lockd [-d [debuglevel]]\n"); + exit(1); +} |