Add usage(), use err(3), remove `progname'.

This commit is contained in:
Philippe Charnier 1997-09-02 06:35:27 +00:00
parent 68366fa6e8
commit d7d4c0e8c6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=29029
10 changed files with 158 additions and 183 deletions

View File

@ -37,7 +37,7 @@
*
* @(#)amd.c 8.1 (Berkeley) 6/6/93
*
* $Id$
* $Id: amd.c,v 1.5 1997/02/22 16:01:26 peter Exp $
*
*/
@ -59,7 +59,6 @@ static char copyright[] =
#include <setjmp.h>
char pid_fsname[16 + MAXHOSTNAMELEN]; /* "kiska.southseas.nz:(pid%d)" */
char *progname; /* "amd" */
#ifdef HAS_HOST
#ifdef HOST_EXEC
char *host_helper;
@ -208,20 +207,6 @@ char *argv[];
*/
amd_state = Start;
/*
* Determine program name
*/
if (argv[0]) {
progname = strrchr(argv[0], '/');
if (progname && progname[1])
progname++;
else
progname = argv[0];
}
if (!progname)
progname = "amd";
/*
* Initialise process id. This is kept
* cached since it is used for generating

View File

@ -34,26 +34,27 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)get_args.c 8.1 (Berkeley) 6/6/93
*
* $Id: get_args.c,v 1.3 1997/02/22 16:01:28 peter Exp $
*
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)get_args.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
#endif /* not lint */
/*
* Argument decode
*/
#include <unistd.h>
#include "am.h"
#ifdef HAS_SYSLOG
#include <syslog.h>
#endif /* HAS_SYSLOG */
#include <sys/stat.h>
extern int optind;
extern char *optarg;
#if defined(DEBUG) && defined(PARANOID)
char **gargv;
#endif /* defined(DEBUG) && defined(PARANOID) */
@ -104,23 +105,22 @@ char *opt;
}
#endif /* DEBUG */
static void usage __P((void));
void get_args(c, v)
int c;
char *v[];
{
int opt_ch;
int usage = 0;
int usageflg = 0;
char *logfile = 0;
char *sub_domain = 0;
while ((opt_ch = getopt(c, v, "mnprva:c:d:h:k:l:t:w:x:y:C:D:")) != -1)
switch (opt_ch) {
case 'a':
if (*optarg != '/') {
fprintf(stderr, "%s: -a option must begin with a '/'\n",
progname);
exit(1);
}
if (*optarg != '/')
errx(1, "-a option must begin with a '/'");
auto_dir = optarg;
break;
@ -199,7 +199,7 @@ char *v[];
break;
case 'x':
usage += switch_option(optarg);
usageflg += switch_option(optarg);
break;
case 'y':
@ -216,30 +216,30 @@ char *v[];
case 'D':
#ifdef DEBUG
usage += debug_option(optarg);
usageflg += debug_option(optarg);
#else
fprintf(stderr, "%s: not compiled with DEBUG option -- sorry.\n", progname);
warnx("not compiled with DEBUG option -- sorry");
#endif /* DEBUG */
break;
default:
usage = 1;
usageflg = 1;
break;
}
if (xlog_level_init == ~0) {
(void) switch_option("");
#ifdef DEBUG
usage += switch_option("debug");
usageflg += switch_option("debug");
#endif /* DEBUG */
} else {
#ifdef DEBUG
usage += switch_option("debug");
usageflg += switch_option("debug");
#endif /* DEBUG */
}
if (usage)
goto show_usage;
if (usageflg)
usage();
while (optind <= c-2) {
char *dir = v[optind++];
@ -310,15 +310,20 @@ char *v[];
afs_retrans = 3; /* XXX */
return;
}
usage();
}
show_usage:
fprintf(stderr,
"Usage: %s [-mnprv] [-a mnt_point] [-c cache_time] [-d domain]\n\
\t[-k kernel_arch] [-l logfile|\"syslog\"] [-t afs_timeout]\n\
\t[-w wait_timeout] [-C cluster_name]", progname);
static void
usage()
{
fprintf(stderr, "%s\n%s\n%s",
"usage: amd [-mnprv] [-a mnt_point] [-c cache_time] [-d domain]",
" [-k kernel_arch] [-l logfile|\"syslog\"] [-t afs_timeout]",
" [-w wait_timeout] [-C cluster_name]");
#if defined(HAS_HOST) && defined(HOST_EXEC)
fputs(" [-h host_helper]\n", stderr);
fputs(" [-h host_helper]", stderr);
#endif /* defined(HAS_HOST) && defined(HOST_EXEC) */
#ifdef HAS_NIS_MAPS
@ -331,6 +336,6 @@ char *v[];
#ifdef DEBUG
show_opts('D', dbg_opt);
#endif /* DEBUG */
fprintf(stderr, "\t{directory mapname [-map_options]} ...\n");
fprintf(stderr, " {directory mapname [-map_options]} ...\n");
exit(1);
}

View File

@ -34,13 +34,16 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)nfs_start.c 8.1 (Berkeley) 6/6/93
*
* $Id: nfs_start.c,v 1.4 1997/02/22 16:01:38 peter Exp $
*
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)nfs_start.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
#endif /* not lint */
#include "am.h"
#include "amq.h"
#include <sys/signal.h>
@ -264,7 +267,7 @@ static serv_state run_rpc(P_void)
#endif /* DEBUG */
continue;
}
perror("select");
warn("select");
break;
case 0:
@ -344,12 +347,12 @@ int ppid;
int nmount;
if (so < 0 || bindnfs_port(so) < 0) {
perror("Can't create privileged nfs port");
warn("can't create privileged nfs port");
return 1;
}
if (so2 < 0 || bind_resv_port(so2, NULL) < 0) {
perror("Can't create privileged port");
warn("can't create privileged port");
return 1;
}
if ((nfsxprt = svcudp_create(so)) == NULL) {

View File

@ -34,13 +34,16 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)xutil.c 8.1 (Berkeley) 6/6/93
*
* $Id$
*
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)xutil.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
#endif /* not lint */
#include "config.h"
#ifdef HAS_SYSLOG
#include <syslog.h>
@ -154,7 +157,7 @@ extern struct mallinfo __mallinfo;
if (orig_mem_bytes == 0)
mem_bytes = orig_mem_bytes = __mallinfo.uordbytes;
else {
fprintf(logfp, "%s[%d]: ", progname, mypid);
fprintf(logfp, "amd[%d]: ", mypid);
if (mem_bytes < __mallinfo.uordbytes) {
fprintf(logfp, "ALLOC: %d bytes",
__mallinfo.uordbytes - mem_bytes);
@ -245,7 +248,7 @@ extern char **gargv;
#if defined(DEBUG) && defined(PARANOID)
gargv[0],
#else
progname,
"amd",
#endif /* defined(DEBUG) && defined(PARANOID) */
mypid,
sev);
@ -322,7 +325,7 @@ struct opt_tab *opts;
*/
int i;
int s = '{';
fprintf(stderr, "\t[-%c {no}", ch);
fprintf(stderr, " [-%c {no}", ch);
for (i = 0; opts[i].opt; i++) {
fprintf(stderr, "%c%s", s, opts[i].opt);
s = ',';
@ -441,11 +444,11 @@ char *logfile;
syslogging = 1;
new_logfp = stderr;
#if defined(LOG_CONS) && defined(LOG_NOWAIT)
openlog(progname, LOG_PID|LOG_CONS|LOG_NOWAIT,
openlog("amd", LOG_PID|LOG_CONS|LOG_NOWAIT,
LOG_DAEMON);
#else
/* 4.2 compat mode - XXX */
openlog(progname, LOG_PID);
openlog("amd", LOG_PID);
#endif /* LOG_CONS && LOG_NOWAIT */
#else
plog(XLOG_WARNING, "syslog option not supported, logging unchanged");

View File

@ -34,11 +34,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)amq.c 8.1 (Berkeley) 6/7/93
*
* $Id: amq.c,v 1.5 1997/03/22 23:12:08 joerg Exp $
*
*/
/*
@ -54,19 +49,23 @@ char copyright[] = "\
#endif /* not lint */
#ifndef lint
static char rcsid[] = "$Id: amq.c,v 1.5 1997/03/22 23:12:08 joerg Exp $";
#if 0
static char sccsid[] = "@(#)amq.c 8.1 (Berkeley) 6/7/93";
#endif
static const char rcsid[] =
"$Id$";
#endif /* not lint */
#include "am.h"
#include "amq.h"
#include <stdio.h>
#include <fcntl.h>
#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
static int privsock();
static void usage __P((void));
char *progname;
static int flush_flag;
static int minfo_flag;
static int unmount_flag;
@ -79,9 +78,6 @@ static char *xlog_optstr;
static char localhost[] = "localhost";
static char *def_server = localhost;
extern int optind;
extern char *optarg;
static struct timeval tmo = { 10, 0 };
#define TIMEOUT tmo
@ -294,19 +290,6 @@ char *argv[];
struct hostent *hp;
int nodefault = 0;
/*
* Compute program name
*/
if (argv[0]) {
progname = strrchr(argv[0], '/');
if (progname && progname[1])
progname++;
else
progname = argv[0];
}
if (!progname)
progname = "amq";
/*
* Parse arguments
*/
@ -371,13 +354,8 @@ char *argv[];
errs = 1;
}
if (errs) {
show_usage:
fprintf(stderr, "\
Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
\t[-l logfile|\"syslog\"] [-x log_flags] [-D dbg_opts] [-M mapent]\n", progname);
exit(1);
}
if (errs)
usage();
#ifdef hpux
/*
@ -392,10 +370,8 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
/*
* Get address of server
*/
if ((hp = gethostbyname(server)) == 0 && strcmp(server, localhost) != 0) {
fprintf(stderr, "%s: Can't get address of %s\n", progname, server);
exit(1);
}
if ((hp = gethostbyname(server)) == 0 && strcmp(server, localhost) != 0)
errx(1, "can't get address of %s", server);
bzero(&server_addr, sizeof server_addr);
server_addr.sin_family = AF_INET;
if (hp) {
@ -416,11 +392,8 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
s = privsock(SOCK_DGRAM);
clnt = clntudp_create(&server_addr, AMQ_PROGRAM, AMQ_VERSION, TIMEOUT, &s);
}
if (clnt == 0) {
fprintf(stderr, "%s: ", progname);
clnt_pcreateerror(server);
exit(1);
}
if (clnt == 0)
errx(1, "%s", clnt_spcreateerror(server));
/*
* Control debugging
@ -432,10 +405,10 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
opt.as_str = debug_opts;
rc = amqproc_setopt_1(&opt, clnt);
if (rc && *rc < 0) {
fprintf(stderr, "%s: daemon not compiled for debug", progname);
warnx("daemon not compiled for debug");
errs = 1;
} else if (!rc || *rc > 0) {
fprintf(stderr, "%s: debug setting for \"%s\" failed\n", progname, debug_opts);
warnx("debug setting for \"%s\" failed", debug_opts);
errs = 1;
}
}
@ -450,7 +423,7 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
opt.as_str = xlog_optstr;
rc = amqproc_setopt_1(&opt, clnt);
if (!rc || *rc) {
fprintf(stderr, "%s: setting log level to \"%s\" failed\n", progname, xlog_optstr);
warnx("setting log level to \"%s\" failed", xlog_optstr);
errs = 1;
}
}
@ -465,7 +438,7 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
opt.as_str = logfile;
rc = amqproc_setopt_1(&opt, clnt);
if (!rc || *rc) {
fprintf(stderr, "%s: setting logfile to \"%s\" failed\n", progname, logfile);
warnx("setting logfile to \"%s\" failed", logfile);
errs = 1;
}
}
@ -480,7 +453,7 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
opt.as_str = "";
rc = amqproc_setopt_1(&opt, clnt);
if (!rc || *rc) {
fprintf(stderr, "%s: amd on %s cannot flush the map cache\n", progname, server);
warnx("amd on %s cannot flush the map cache", server);
errs = 1;
}
}
@ -498,7 +471,7 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
show_mi(ml, Full, &mwid, &dwid, &twid);
} else {
fprintf(stderr, "%s: amd on %s cannot provide mount info\n", progname, server);
warnx("amd on %s cannot provide mount info", server);
}
}
@ -515,8 +488,7 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
errno = *rc;
else
errno = ETIMEDOUT;
fprintf(stderr, "%s: could not start new ", progname);
perror("autmount point");
warn("could not start new autmount point");
}
}
@ -529,7 +501,7 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
printf("%s.\n", *spp);
free(*spp);
} else {
fprintf(stderr, "%s: failed to get version information\n", progname);
warnx("failed to get version information");
errs = 1;
}
}
@ -560,25 +532,23 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
dwid, dwid, "What");
show_mt(mt, Stats, &mwid, &dwid, &twid);
} else {
fprintf(stderr, "%s: %s not automounted\n", progname, fs);
warnx("%s not automounted", fs);
}
xdr_pri_free(xdr_amq_mount_tree_p, (caddr_t) mtp);
} else {
fprintf(stderr, "%s: ", progname);
clnt_perror(clnt, server);
warnx("%s", clnt_sperror(clnt, server));
errs = 1;
}
}
} while (optind < argc);
} else if (unmount_flag) {
goto show_usage;
usage();
} else if (stats_flag) {
amq_mount_stats *ms = amqproc_stats_1((voidp) 0, clnt);
if (ms) {
show_ms(ms);
} else {
fprintf(stderr, "%s: ", progname);
clnt_perror(clnt, server);
warnx("%s", clnt_sperror(clnt, server));
errs = 1;
}
} else if (!nodefault) {
@ -597,8 +567,7 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
else if (e == Short) e = ShowDone;
}
} else {
fprintf(stderr, "%s: ", progname);
clnt_perror(clnt, server);
warnx("%s", clnt_sperror(clnt, server));
errs = 1;
}
}
@ -606,6 +575,15 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
exit(errs);
}
static void
usage()
{
fprintf(stderr, "%s\n%s\n",
"usage: amq [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |",
" [-l logfile|\"syslog\"] [-x log_flags] [-D dbg_opts] [-M mapent]");
exit(1);
}
/*
* udpresport creates a datagram socket and attempts to bind it to a
* secure port.

View File

@ -31,13 +31,16 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)fsi_util.c 8.1 (Berkeley) 6/6/93
*
* $Id$
*
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)fsi_util.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
#endif
#include "../fsinfo/fsinfo.h"
/*
@ -47,7 +50,7 @@ void error(s, s1, s2, s3, s4)
char *s, *s1, *s2, *s3, *s4;
{
col_cleanup(0);
fprintf(stderr, "%s: Error, ", progname);
fprintf(stderr, "fsinfo: error, ");
fprintf(stderr, s, s1, s2, s3, s4);
fputc('\n', stderr);
errors++;
@ -79,7 +82,7 @@ void fatal(s, s1, s2, s3, s4)
char *s, *s1, *s2, *s3, *s4;
{
col_cleanup(1);
fprintf(stderr, "%s: Fatal, ", progname);
fprintf(stderr, "fsinfo: fatal, ");
fprintf(stderr, s, s1, s2, s3, s4);
fputc('\n', stderr);
exit(1);
@ -108,7 +111,7 @@ char *s, *s1, *s2, *s3, *s4;
{
if (verbose > 0) {
fputc('#', stdout);
fprintf(stdout, "%s: ", progname);
fprintf(stdout, "fsinfo: ");
fprintf(stdout, s, s1, s2, s3, s4);
putc('\n', stdout);
}
@ -137,10 +140,10 @@ FILE *fp;
fprintf(fp,
"\
# *** This file was automatically generated -- DO NOT EDIT HERE ***\n\
# \"%s\" run by %s@%s on %s\
# \"fsinfo\" run by %s@%s on %s\
#\n\
",
progname, username, hostname, cp);
username, hostname, cp);
}
static int show_range = 10;

View File

@ -34,26 +34,31 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)fsinfo.c 8.1 (Berkeley) 6/6/93
*
* $Id: fsinfo.c,v 1.3 1997/02/22 16:03:20 peter Exp $
*
*/
#ifndef lint
static char copyright[] =
static const char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)fsinfo.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
#endif /* not lint */
/*
* fsinfo
*/
#include "../fsinfo/fsinfo.h"
#include "fsi_gram.h"
#include <err.h>
#include <pwd.h>
#include <unistd.h>
qelem *list_of_hosts;
qelem *list_of_automounts;
@ -69,7 +74,8 @@ int verbose;
char idvbuf[1024];
char **g_argv;
char *progname;
static void usage __P((void));
/*
* Output file prefixes
@ -87,25 +93,10 @@ static void get_args(c, v)
int c;
char *v[];
{
extern char *optarg;
extern int optind;
int ch;
int usage = 0;
int usageflg = 0;
char *iptr = idvbuf;
/*
* Determine program name
*/
if (v[0]) {
progname = strrchr(v[0], '/');
if (progname && progname[1])
progname++;
else
progname = v[0];
}
if (!progname)
progname = "fsinfo";
while ((ch = getopt(c, v, "a:b:d:e:f:h:m:D:U:I:qv")) != -1)
switch (ch) {
case 'a':
@ -150,7 +141,7 @@ char *v[];
iptr += strlen(iptr);
break;
default:
usage++;
usageflg++;
break;
}
@ -159,18 +150,11 @@ char *v[];
if (yywrap())
fatal("Cannot read any input files");
} else {
usage++;
}
if (usage) {
fprintf(stderr,
"\
Usage: %s [-v] [-a autodir] [-h hostname] [-b bootparams] [-d dumpsets]\n\
\t[-e exports] [-f fstabs] [-m automounts]\n\
\t[-I dir] [-D|-U string[=string]] config ...\n", progname);
exit(1);
usageflg++;
}
if (usageflg)
usage();
if (g_argv[0])
log("g_argv[0] = %s", g_argv[0]);
@ -178,6 +162,16 @@ Usage: %s [-v] [-a autodir] [-h hostname] [-b bootparams] [-d dumpsets]\n\
log("g_argv[0] = (nil)");
}
static void
usage()
{
fprintf(stderr, "%s\n%s\n%s\n",
"usage: fsinfo [-v] [-a autodir] [-h hostname] [-b bootparams] [-d dumpsets]",
" [-e exports] [-f fstabs] [-m automounts]",
" [-I dir] [-D|-U string[=string]] config ...");
exit(1);
}
/*
* Determine username of caller
*/
@ -216,10 +210,8 @@ char *argv[];
/*
* If no hostname given then use the local name
*/
if (!*hostname && gethostname(hostname, sizeof(hostname)) < 0) {
perror("gethostname");
exit(1);
}
if (!*hostname && gethostname(hostname, sizeof(hostname)) < 0)
err(1, "gethostname");
/*
* Get the username

View File

@ -37,7 +37,7 @@
*
* @(#)fsinfo.h 8.1 (Berkeley) 6/6/93
*
* $Id$
* $Id: fsinfo.h,v 1.5 1997/02/22 16:03:21 peter Exp $
*
*/
@ -126,7 +126,6 @@ extern char *fsmount_strings[];
extern char *host_strings[];
extern char *ether_if_strings[];
extern char *autodir;
extern char *progname;
extern char hostname[];
extern char *username;
extern char **g_argv;

View File

@ -37,7 +37,7 @@
*
* @(#)config.h 8.1 (Berkeley) 6/6/93
*
* $Id$
* $Id: config.h,v 1.3 1997/02/22 16:03:52 peter Exp $
*
*/
@ -82,7 +82,6 @@ extern int errno;
extern time_t time P((time_t *));
extern time_t clock_valid; /* Clock needs recalculating */
extern char *progname; /* "amd"|"mmd" */
extern char hostname[]; /* "kiska" */
extern int mypid; /* Current process id */

View File

@ -34,10 +34,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)mk-amd-map.c 8.1 (Berkeley) 6/28/93
*
* $Id: mk-amd-map.c,v 1.3 1997/02/22 16:03:56 peter Exp $
*/
/*
@ -53,11 +49,15 @@ char copyright[] = "\
#endif /* not lint */
#ifndef lint
static char rcsid[] = "$Id: mk-amd-map.c,v 1.3 1997/02/22 16:03:56 peter Exp $";
#if 0
static char sccsid[] = "@(#)mk-amd-map.c 8.1 (Berkeley) 6/28/93";
#endif
static const char rcsid[] =
"$Id$";
#endif /* not lint */
#include "am.h"
#include <unistd.h>
#ifndef SIGINT
#include <signal.h>
@ -73,6 +73,8 @@ static char sccsid[] = "@(#)mk-amd-map.c 8.1 (Berkeley) 6/28/93";
#define create_database(name) dbm_open(name, O_RDWR|O_CREAT, 0644)
static void usage __P((void));
static int store_data(db, k, v)
voidp db;
char *k, *v;
@ -245,9 +247,8 @@ char *argv[];
int len;
char *sl;
int printit = 0;
int usage = 0;
int usageflg = 0;
int ch;
extern int optind;
while ((ch = getopt(argc, argv, "p")) != -1)
switch (ch) {
@ -255,13 +256,12 @@ char *argv[];
printit = 1;
break;
default:
usage++;
usageflg++;
break;
}
if (usage || optind != (argc - 1)) {
fputs("Usage: mk-amd-map [-p] file-map\n", stderr);
exit(1);
if (usageflg || optind != (argc - 1)) {
usage();
}
map = argv[optind];
@ -375,6 +375,14 @@ char *argv[];
}
exit(rc);
}
static void
usage()
{
fprintf(stderr, "usage: mk-amd-map [-p] file-map\n");
exit(1);
}
#else
main()
{