[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.3

1.3     ! millert     1: /*     $OpenBSD: file.h,v 1.2 1996/06/26 05:32:57 deraadt Exp $        */
        !             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:
        !            33: typedef int32_t int32;
        !            34: typedef u_int32_t uint32;
        !            35:
1.1       deraadt    36: #ifndef HOWMANY
                     37: # define HOWMANY 8192          /* how much of the file to look at */
                     38: #endif
                     39: #define MAXMAGIS 1000          /* max entries in /etc/magic */
                     40: #define MAXDESC        50              /* max leng of text description */
                     41: #define MAXstring 32           /* max leng of "string" types */
                     42:
                     43: struct magic {
                     44:        short flag;
                     45: #define INDIR  1               /* if '>(...)' appears,  */
                     46: #define        UNSIGNED 2              /* comparison is unsigned */
1.3     ! millert    47: #define ADD    4               /* if '>&' appears,  */
1.1       deraadt    48:        short cont_level;       /* level of ">" */
                     49:        struct {
                     50:                char type;      /* byte short long */
1.3     ! millert    51:                int32 offset;   /* offset from indirection */
1.1       deraadt    52:        } in;
1.3     ! millert    53:        int32 offset;           /* offset to magic number */
1.1       deraadt    54:        unsigned char reln;     /* relation (0=eq, '>'=gt, etc) */
                     55:        char type;              /* int, short, long or string. */
                     56:        char vallen;            /* length of string value, if any */
                     57: #define                        BYTE    1
                     58: #define                                SHORT   2
                     59: #define                                LONG    4
                     60: #define                                STRING  5
                     61: #define                                DATE    6
                     62: #define                                BESHORT 7
                     63: #define                                BELONG  8
                     64: #define                                BEDATE  9
                     65: #define                                LESHORT 10
                     66: #define                                LELONG  11
                     67: #define                                LEDATE  12
                     68:        union VALUETYPE {
                     69:                unsigned char b;
                     70:                unsigned short h;
1.3     ! millert    71:                uint32 l;
1.1       deraadt    72:                char s[MAXstring];
                     73:                unsigned char hs[2];    /* 2 bytes of a fixed-endian "short" */
                     74:                unsigned char hl[4];    /* 2 bytes of a fixed-endian "long" */
                     75:        } value;                /* either number or string */
1.3     ! millert    76:        uint32 mask;    /* mask before comparison with value */
1.1       deraadt    77:        char nospflag;          /* supress space character */
                     78:        char desc[MAXDESC];     /* description */
                     79: };
                     80:
                     81: #include <stdio.h>     /* Include that here, to make sure __P gets defined */
                     82:
                     83: #ifndef __P
                     84: # if __STDC__ || __cplusplus
                     85: #  define __P(a) a
                     86: # else
                     87: #  define __P(a) ()
                     88: #  define const
                     89: # endif
                     90: #endif
                     91:
                     92: extern int   apprentice                __P((char *, int));
                     93: extern int   ascmagic          __P((unsigned char *, int));
                     94: extern void  error             __P((const char *, ...));
                     95: extern void  ckfputs           __P((const char *, FILE *));
                     96: struct stat;
                     97: extern int   fsmagic           __P((const char *, struct stat *));
                     98: extern int   is_compress       __P((const unsigned char *, int *));
                     99: extern int   is_tar            __P((unsigned char *, int));
                    100: extern void  magwarn           __P((const char *, ...));
                    101: extern void  mdump             __P((struct magic *));
                    102: extern void  process           __P((const char *, int));
                    103: extern void  showstr           __P((FILE *, const char *, int));
                    104: extern int   softmagic         __P((unsigned char *, int));
                    105: extern int   tryit             __P((unsigned char *, int, int));
                    106: extern int   zmagic            __P((unsigned char *, int));
                    107: extern void  ckfprintf         __P((FILE *, const char *, ...));
1.3     ! millert   108: extern uint32 signextend       __P((struct magic *, unsigned int32));
        !           109: extern int internatmagic       __P((unsigned char *, int));
        !           110: extern void tryelf             __P((int, char *, int));
1.1       deraadt   111:
                    112:
                    113: extern int errno;              /* Some unixes don't define this..      */
                    114:
                    115: extern char *progname;         /* the program name                     */
                    116: extern char *magicfile;                /* name of the magic file               */
                    117: extern int lineno;             /* current line number in magic file    */
                    118:
                    119: extern struct magic *magic;    /* array of magic entries               */
                    120: extern int nmagic;             /* number of valid magic[]s             */
                    121:
                    122:
                    123: extern int debug;              /* enable debugging?                    */
                    124: extern int zflag;              /* process compressed files?            */
                    125: extern int lflag;              /* follow symbolic links?               */
                    126:
                    127: extern int optind;             /* From getopt(3)                       */
                    128: extern char *optarg;
                    129:
1.3     ! millert   130: #if defined(sun) || defined(__sun__) || defined (__sun)
        !           131: # if defined(__svr4) || defined (__SVR4) || defined(__svr4__)
        !           132: #  define SOLARIS
        !           133: # else
        !           134: #  define SUNOS
        !           135: # endif
        !           136: #endif
        !           137:
        !           138:
        !           139: #if !defined(__STDC__) || defined(SUNOS) || defined(__convex__)
1.1       deraadt   140: extern int sys_nerr;
                    141: extern char *sys_errlist[];
                    142: #define strerror(e) \
                    143:        (((e) >= 0 && (e) < sys_nerr) ? sys_errlist[(e)] : "Unknown error")
                    144: #define strtoul(a, b, c)       strtol(a, b, c)
                    145: #endif
                    146:
                    147: #ifndef MAXPATHLEN
                    148: #define        MAXPATHLEN      512
                    149: #endif
1.3     ! millert   150:
        !           151: #endif /* __file_h__ */