This commit was generated by cvs2svn to track changes on a CVS vendor
[unix-history] / usr.bin / file / file.h
CommitLineData
15637ed4
RG
1/*
2 * file.h - definitions for file(1) program
286a6f32 3 * @(#)file.h,v 1.2 1993/06/10 00:38:09 jtc Exp
15637ed4
RG
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#define HOWMANY 1024 /* how much of the file to look at */
286a6f32 30#define MAXMAGIS 1000 /* max entries in /etc/magic */
15637ed4
RG
31#define MAXDESC 50 /* max leng of text description */
32#define MAXstring 32 /* max leng of "string" types */
15637ed4
RG
33
34struct magic {
286a6f32
C
35 short flag;
36#define INDIR 1 /* if '>(...)' appears, */
37 short cont_level; /* level of ">" */
38 struct {
39 char type; /* byte short long */
40 long offset; /* offset from indirection */
41 } in;
15637ed4 42 long offset; /* offset to magic number */
286a6f32
C
43#define MASK 0200 /* this is a masked op, like & v1 = v2 */
44 unsigned char reln; /* relation (0=eq, '>'=gt, etc) */
15637ed4
RG
45 char type; /* int, short, long or string. */
46 char vallen; /* length of string value, if any */
47#define BYTE 1
48#define SHORT 2
49#define LONG 4
50#define STRING 5
286a6f32
C
51#define DATE 6
52#define BESHORT 7
53#define BELONG 8
54#define BEDATE 9
55#define LESHORT 10
56#define LELONG 11
57#define LEDATE 12
15637ed4
RG
58 union VALUETYPE {
59 char b;
60 short h;
61 long l;
62 char s[MAXstring];
286a6f32
C
63 unsigned char hs[2]; /* 2 bytes of a fixed-endian "short" */
64 unsigned char hl[4]; /* 2 bytes of a fixed-endian "long" */
15637ed4 65 } value; /* either number or string */
286a6f32
C
66 long mask; /* mask before comparison with value */
67 char nospflag; /* supress space character */
15637ed4
RG
68 char desc[MAXDESC]; /* description */
69};
70
286a6f32
C
71#include <stdio.h> /* Include that here, to make sure __P gets defined */
72
73#ifndef __P
74# if __STDC__ || __cplusplus
75# define __P(a) a
76# else
77# define __P(a) ()
78# define const
79# endif
80#endif
81
82extern int apprentice __P((char *, int));
83extern int ascmagic __P((unsigned char *, int));
84extern void error __P((const char *, ...));
85extern void ckfputs __P((const char *, FILE *));
86struct stat;
87extern int fsmagic __P((const char *, struct stat *));
88extern int is_compress __P((const unsigned char *, int *));
89extern int is_tar __P((unsigned char *));
90extern void magwarn __P((const char *, ...));
91extern void mdump __P((struct magic *));
92extern void process __P((const char *, int));
93extern void showstr __P((const char *));
94extern int softmagic __P((unsigned char *, int));
95extern void tryit __P((unsigned char *, int));
96extern int uncompress __P((const unsigned char *, unsigned char **, int));
97extern void ckfprintf __P((FILE *, const char *, ...));
98
99
100
101extern int errno; /* Some unixes don't define this.. */
102
103extern char *progname; /* the program name */
104extern char *magicfile; /* name of the magic file */
105extern int lineno; /* current line number in magic file */
106
107extern struct magic *magic; /* array of magic entries */
108extern int nmagic; /* number of valid magic[]s */
109
110
111extern int debug; /* enable debugging? */
112extern int zflag; /* process compressed files? */
113extern int lflag; /* follow symbolic links? */
114
115extern int optind; /* From getopt(3) */
116extern char *optarg;
117
118#if !defined(__STDC__) || defined(sun)
119extern int sys_nerr;
120extern char *sys_errlist[];
121#define strerror(e) \
122 (((e) >= 0 && (e) < sys_nerr) ? sys_errlist[(e)] : "Unknown error")
123#endif
124
125#ifndef MAXPATHLEN
126#define MAXPATHLEN 512
127#endif