[BACK]Return to file.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / file

Annotation of src/usr.bin/file/file.h, Revision 1.9

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