#endif
#ifndef lint
-FILE_RCSID("@(#)$Id: apprentice.c,v 1.76 2004/05/12 14:53:01 christos Exp $")
+FILE_RCSID("@(#)$Id: apprentice.c,v 1.77 2004/06/04 14:40:19 christos Exp $")
#endif /* lint */
#define EATAB {while (isascii((unsigned char) *l) && \
private size_t magicsize = sizeof(struct magic);
#ifdef COMPILE_ONLY
-const char *magicfile;
-char *progname;
-int lineno;
int main(int, char *[]);
main(int argc, char *argv[])
{
int ret;
+ struct magic_set *ms;
+ char *progname;
if ((progname = strrchr(argv[0], '/')) != NULL)
progname++;
progname = argv[0];
if (argc != 2) {
- (void)fprintf(stderr, "usage: %s file\n", progname);
- exit(1);
+ (void)fprintf(stderr, "Usage: %s file\n", progname);
+ return 1;
}
- magicfile = argv[1];
- exit(file_apprentice(magicfile, COMPILE, MAGIC_CHECK) == -1 ? 1 : 0);
+ if ((ms = magic_open(MAGIC_CHECK)) == NULL) {
+ (void)fprintf(stderr, "%s: %s\n", progname, strerror(errno));
+ return 1;
+ }
+ ret = magic_compile(ms, argv[1]) == -1 ? 1 : 0;
+ if (ret == 1)
+ (void)fprintf(stderr, "%s: %s\n", progname, magic_error(ms));
+ magic_close(ms);
+ return ret;
}
#endif /* COMPILE_ONLY */
#include <ctype.h>
#ifndef lint
-FILE_RCSID("@(#)$Id: funcs.c,v 1.11 2003/11/11 20:01:46 christos Exp $")
+FILE_RCSID("@(#)$Id: funcs.c,v 1.12 2004/06/04 14:40:20 christos Exp $")
#endif /* lint */
/*
* Like printf, only we print to a buffer and advance it.
file_error(ms, errno, "error reading");
}
+#ifndef COMPILE_ONLY
protected int
file_buffer(struct magic_set *ms, const void *buf, size_t nb)
{
}
return m;
}
+#endif
protected int
file_reset(struct magic_set *ms)
#include "patchlevel.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: magic.c,v 1.20 2004/03/23 15:33:43 christos Exp $")
+FILE_RCSID("@(#)$Id: magic.c,v 1.21 2004/06/04 14:40:20 christos Exp $")
#endif /* lint */
#ifdef __EMX__
}
}
+#ifndef COMPILE_ONLY
/*
* find type of named file
*/
}
return file_getbuffer(ms);
}
+#endif
public const char *
magic_error(struct magic_set *ms)