diff options
author | obrien <obrien@FreeBSD.org> | 2001-03-25 18:37:04 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2001-03-25 18:37:04 +0000 |
commit | fd87285c4e3e4e4fbf7112229c209a1c6ea64494 (patch) | |
tree | e67293d6663395ea7f7a72c51cd928cd80e3b960 /contrib/file/file.c | |
parent | 07b03dc31d7b8ca7a40599770596dc7106822a14 (diff) | |
download | FreeBSD-src-fd87285c4e3e4e4fbf7112229c209a1c6ea64494.zip FreeBSD-src-fd87285c4e3e4e4fbf7112229c209a1c6ea64494.tar.gz |
Virgin import of Christos Zoulas's FILE 3.34.
Diffstat (limited to 'contrib/file/file.c')
-rw-r--r-- | contrib/file/file.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/contrib/file/file.c b/contrib/file/file.c index ac770d1..429e53a 100644 --- a/contrib/file/file.c +++ b/contrib/file/file.c @@ -56,7 +56,7 @@ #include "patchlevel.h" #ifndef lint -FILE_RCSID("@(#)$Id: file.c,v 1.55 2000/08/05 19:00:12 christos Exp $") +FILE_RCSID("@(#)$Id: file.c,v 1.56 2001/03/11 20:29:16 christos Exp $") #endif /* lint */ @@ -97,6 +97,7 @@ int lineno; /* line number in the magic file */ static void unwrap __P((char *fn)); +static void usage __P((void)); #if 0 static int byteconv4 __P((int, int, int)); static short byteconv2 __P((int, int, int)); @@ -113,7 +114,7 @@ main(argc, argv) char *argv[]; { int c; - int check = 0, didsomefiles = 0, errflg = 0, ret = 0, app = 0; + int action = 0, didsomefiles = 0, errflg = 0, ret = 0, app = 0; char *mime; #ifdef LC_CTYPE @@ -128,21 +129,24 @@ main(argc, argv) if (!(magicfile = getenv("MAGIC"))) magicfile = default_magicfile; - while ((c = getopt(argc, argv, "bcdf:ikm:nsvzL")) != EOF) + while ((c = getopt(argc, argv, "bcdf:ikm:nsvzCL")) != EOF) switch (c) { case 'b': ++bflag; break; case 'c': - ++check; + action = CHECK; + break; + case 'C': + action = COMPILE; break; case 'd': ++debug; break; case 'f': if (!app) { - ret = apprentice(magicfile, check); - if (check) + ret = apprentice(magicfile, action); + if (action) exit(ret); app = 1; } @@ -190,21 +194,19 @@ main(argc, argv) } if (errflg) { - (void) fprintf(stderr, USAGE, progname); - exit(2); + usage(); } if (!app) { - ret = apprentice(magicfile, check); - if (check) + ret = apprentice(magicfile, action); + if (action) exit(ret); app = 1; } if (optind == argc) { if (!didsomefiles) { - (void)fprintf(stderr, USAGE, progname); - exit(2); + usage(); } } else { @@ -451,3 +453,13 @@ tryit(buf, nb, zflag) ckfputs("data", stdout); return '\0'; } + +static void +usage() +{ + (void)fprintf(stderr, USAGE, progname); +#ifdef QUICK + (void)fprintf(stderr, "Usage: %s -C [-m magic]\n", progname); +#endif + exit(1); +} |