summaryrefslogtreecommitdiff
path: root/contrib/file/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/file/file.c')
-rw-r--r--contrib/file/file.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/contrib/file/file.c b/contrib/file/file.c
index ac770d1de1724..429e53a69bdf3 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);
+}