Annotation of src/usr.bin/file/file.h, Revision 1.1
1.1 ! deraadt 1: /*
! 2: * file.h - definitions for file(1) program
! 3: * @(#)$Id: file.h,v 1.7 1995/05/21 00:13:30 christos Exp $
! 4: *
! 5: * Copyright (c) Ian F. Darwin, 1987.
! 6: * Written by Ian F. Darwin.
! 7: *
! 8: * This software is not subject to any license of the American Telephone
! 9: * and Telegraph Company or of the Regents of the University of California.
! 10: *
! 11: * Permission is granted to anyone to use this software for any purpose on
! 12: * any computer system, and to alter it and redistribute it freely, subject
! 13: * to the following restrictions:
! 14: *
! 15: * 1. The author is not responsible for the consequences of use of this
! 16: * software, no matter how awful, even if they arise from flaws in it.
! 17: *
! 18: * 2. The origin of this software must not be misrepresented, either by
! 19: * explicit claim or by omission. Since few users ever read sources,
! 20: * credits must appear in the documentation.
! 21: *
! 22: * 3. Altered versions must be plainly marked as such, and must not be
! 23: * misrepresented as being the original software. Since few users
! 24: * ever read sources, credits must appear in the documentation.
! 25: *
! 26: * 4. This notice may not be removed or altered.
! 27: */
! 28:
! 29: #ifndef HOWMANY
! 30: # define HOWMANY 8192 /* how much of the file to look at */
! 31: #endif
! 32: #define MAXMAGIS 1000 /* max entries in /etc/magic */
! 33: #define MAXDESC 50 /* max leng of text description */
! 34: #define MAXstring 32 /* max leng of "string" types */
! 35:
! 36: struct magic {
! 37: short flag;
! 38: #define INDIR 1 /* if '>(...)' appears, */
! 39: #define UNSIGNED 2 /* comparison is unsigned */
! 40: short cont_level; /* level of ">" */
! 41: struct {
! 42: char type; /* byte short long */
! 43: long offset; /* offset from indirection */
! 44: } in;
! 45: long offset; /* offset to magic number */
! 46: unsigned char reln; /* relation (0=eq, '>'=gt, etc) */
! 47: char type; /* int, short, long or string. */
! 48: char vallen; /* length of string value, if any */
! 49: #define BYTE 1
! 50: #define SHORT 2
! 51: #define LONG 4
! 52: #define STRING 5
! 53: #define DATE 6
! 54: #define BESHORT 7
! 55: #define BELONG 8
! 56: #define BEDATE 9
! 57: #define LESHORT 10
! 58: #define LELONG 11
! 59: #define LEDATE 12
! 60: union VALUETYPE {
! 61: unsigned char b;
! 62: unsigned short h;
! 63: unsigned long l;
! 64: char s[MAXstring];
! 65: unsigned char hs[2]; /* 2 bytes of a fixed-endian "short" */
! 66: unsigned char hl[4]; /* 2 bytes of a fixed-endian "long" */
! 67: } value; /* either number or string */
! 68: unsigned long mask; /* mask before comparison with value */
! 69: char nospflag; /* supress space character */
! 70: char desc[MAXDESC]; /* description */
! 71: };
! 72:
! 73: #include <stdio.h> /* Include that here, to make sure __P gets defined */
! 74:
! 75: #ifndef __P
! 76: # if __STDC__ || __cplusplus
! 77: # define __P(a) a
! 78: # else
! 79: # define __P(a) ()
! 80: # define const
! 81: # endif
! 82: #endif
! 83:
! 84: extern int apprentice __P((char *, int));
! 85: extern int ascmagic __P((unsigned char *, int));
! 86: extern void error __P((const char *, ...));
! 87: extern void ckfputs __P((const char *, FILE *));
! 88: struct stat;
! 89: extern int fsmagic __P((const char *, struct stat *));
! 90: extern int is_compress __P((const unsigned char *, int *));
! 91: extern int is_tar __P((unsigned char *, int));
! 92: extern void magwarn __P((const char *, ...));
! 93: extern void mdump __P((struct magic *));
! 94: extern void process __P((const char *, int));
! 95: extern void showstr __P((FILE *, const char *, int));
! 96: extern int softmagic __P((unsigned char *, int));
! 97: extern int tryit __P((unsigned char *, int, int));
! 98: extern int zmagic __P((unsigned char *, int));
! 99: extern void ckfprintf __P((FILE *, const char *, ...));
! 100: extern unsigned long signextend __P((struct magic *, unsigned long));
! 101:
! 102:
! 103:
! 104: extern int errno; /* Some unixes don't define this.. */
! 105:
! 106: extern char *progname; /* the program name */
! 107: extern char *magicfile; /* name of the magic file */
! 108: extern int lineno; /* current line number in magic file */
! 109:
! 110: extern struct magic *magic; /* array of magic entries */
! 111: extern int nmagic; /* number of valid magic[]s */
! 112:
! 113:
! 114: extern int debug; /* enable debugging? */
! 115: extern int zflag; /* process compressed files? */
! 116: extern int lflag; /* follow symbolic links? */
! 117:
! 118: extern int optind; /* From getopt(3) */
! 119: extern char *optarg;
! 120:
! 121: #if !defined(__STDC__) || defined(sun) || defined(__sun__) || defined(__convex__)
! 122: extern int sys_nerr;
! 123: extern char *sys_errlist[];
! 124: #define strerror(e) \
! 125: (((e) >= 0 && (e) < sys_nerr) ? sys_errlist[(e)] : "Unknown error")
! 126: #define strtoul(a, b, c) strtol(a, b, c)
! 127: #endif
! 128:
! 129: #ifndef MAXPATHLEN
! 130: #define MAXPATHLEN 512
! 131: #endif