file/src/file.h File Reference

#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>

Go to the source code of this file.

Data Structures

struct  magic
union  magic::VALUETYPE
struct  mlist
struct  magic_set
struct  magic_set::cont
struct  magic_set::out

Defines

#define MAGIC   "/etc/magic"
#define PATHSEP   ':'
#define private   static
#define public
#define HOWMANY   (256 * 1024)
#define MAXMAGIS   8192
#define MAXDESC   64
#define MAXstring   32
#define MAGICNO   0xF11E041C
#define VERSIONNO   2
#define FILE_MAGICSIZE   (32 * 4)
#define FILE_LOAD   0
#define FILE_CHECK   1
#define FILE_COMPILE   2
#define INDIR   1
#define UNSIGNED   2
#define OFFADD   4
#define INDIROFFADD   8
#define FILE_BYTE   1
#define FILE_SHORT   2
#define FILE_LONG   4
#define FILE_STRING   5
#define FILE_DATE   6
#define FILE_BESHORT   7
#define FILE_BELONG   8
#define FILE_BEDATE   9
#define FILE_LESHORT   10
#define FILE_LELONG   11
#define FILE_LEDATE   12
#define FILE_PSTRING   13
#define FILE_LDATE   14
#define FILE_BELDATE   15
#define FILE_LELDATE   16
#define FILE_REGEX   17
#define FILE_BESTRING16   18
#define FILE_LESTRING16   19
#define FILE_SEARCH   20
#define FILE_FORMAT_NAME
#define FILE_FMT_NUM   "cduxXi"
#define FILE_FMT_STR   "s"
#define FILE_FORMAT_STRING
#define FILE_OPS   "&|^+-*/%"
#define FILE_OPAND   0
#define FILE_OPOR   1
#define FILE_OPXOR   2
#define FILE_OPADD   3
#define FILE_OPMINUS   4
#define FILE_OPMULTIPLY   5
#define FILE_OPDIVIDE   6
#define FILE_OPMODULO   7
#define FILE_OPINVERSE   0x40
#define FILE_OPINDIRECT   0x80
#define BIT(A)   (1 << (A))
#define STRING_IGNORE_LOWERCASE   BIT(0)
#define STRING_COMPACT_BLANK   BIT(1)
#define STRING_COMPACT_OPTIONAL_BLANK   BIT(2)
#define CHAR_IGNORE_LOWERCASE   'c'
#define CHAR_COMPACT_BLANK   'B'
#define CHAR_COMPACT_OPTIONAL_BLANK   'b'
#define strerror(e)   (((e) >= 0 && (e) < sys_nerr) ? sys_errlist[(e)] : "Unknown error")
#define strtoul(a, b, c)   strtol(a, b, c)
#define O_BINARY   0
#define FILE_RCSID(id)

Functions

const char * file_fmttime (uint32_t, int)
int file_buffer (struct magic_set *ms, int, const void *, size_t)
int file_fsmagic (struct magic_set *ms, const char *fn, struct stat *sb)
int file_pipe2file (struct magic_set *ms, int fd, const void *startbuf, size_t nbytes)
int file_printf (struct magic_set *ms, const char *,...)
int file_reset (struct magic_set *ms)
int file_tryelf (struct magic_set *ms, int, const unsigned char *, size_t)
int file_zmagic (struct magic_set *ms, int, const unsigned char *, size_t)
int file_ascmagic (struct magic_set *ms, const unsigned char *, size_t)
int file_is_tar (struct magic_set *ms, const unsigned char *, size_t)
int file_softmagic (struct magic_set *ms, const unsigned char *, size_t)
mlistfile_apprentice (struct magic_set *ms, const char *, int)
uint32_t file_signextend (struct magic_set *ms, struct magic *, uint32_t)
void file_delmagic (struct magic *p, int type, size_t entries)
void file_badread (struct magic_set *ms)
void file_badseek (struct magic_set *ms)
void file_oomem (struct magic_set *ms)
void file_error (struct magic_set *ms, int, const char *,...)
void file_magwarn (struct magic_set *ms, const char *,...)
void file_mdump (struct magic *m)
void file_showstr (FILE *fp, const char *, size_t)
size_t file_mbswidth (const char *)
const char * file_getbuffer (struct magic_set *ms)

Variables

int sys_nerr
char * sys_errlist []


Define Documentation

#define BIT (  )     (1 << (A))

Definition at line 210 of file file.h.

#define CHAR_COMPACT_BLANK   'B'

Definition at line 215 of file file.h.

Referenced by file_mdump(), and parse().

#define CHAR_COMPACT_OPTIONAL_BLANK   'b'

Definition at line 216 of file file.h.

Referenced by file_mdump(), and parse().

#define CHAR_IGNORE_LOWERCASE   'c'

Definition at line 214 of file file.h.

Referenced by file_mdump(), and parse().

#define FILE_BEDATE   9

Definition at line 104 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_BELDATE   15

Definition at line 110 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_BELONG   8

Definition at line 103 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_BESHORT   7

Definition at line 102 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_BESTRING16   18

Definition at line 113 of file file.h.

Referenced by file_signextend(), getvalue(), mconvert(), mcopy(), mprint(), mymcheck(), and parse().

#define FILE_BYTE   1

Definition at line 97 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_CHECK   1

Definition at line 80 of file file.h.

Referenced by apprentice_file(), main(), and parse().

#define FILE_COMPILE   2

Definition at line 81 of file file.h.

Referenced by apprentice_1(), and main().

#define FILE_DATE   6

Definition at line 101 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_FMT_NUM   "cduxXi"

Definition at line 140 of file file.h.

#define FILE_FMT_STR   "s"

Definition at line 141 of file file.h.

#define FILE_FORMAT_NAME

Value:

/* 0 */                         "invalid 0",            \
/* 1 */                         "byte",                 \
/* 2 */                         "short",                \
/* 3 */                         "invalid 3",            \
/* 4 */                         "long",                 \
/* 5 */                         "string",               \
/* 6 */                         "date",                 \
/* 7 */                         "beshort",              \
/* 8 */                         "belong",               \
/* 9 */                         "bedate",               \
/* 10 */                        "leshort",              \
/* 11 */                        "lelong",               \
/* 12 */                        "ledate",               \
/* 13 */                        "pstring",              \
/* 14 */                        "ldate",                \
/* 15 */                        "beldate",              \
/* 16 */                        "leldate",              \
/* 17 */                        "regex",                \
/* 18 */                        "bestring16",           \
/* 19 */                        "lestring16",           \
/* 20 */                        "search",

Definition at line 117 of file file.h.

Referenced by check_format().

#define FILE_FORMAT_STRING

Value:

/* 0 */                         NULL,                   \
/* 1 */                         FILE_FMT_NUM,           \
/* 2 */                         FILE_FMT_NUM,           \
/* 3 */                         NULL,                   \
/* 4 */                         FILE_FMT_NUM,           \
/* 5 */                         FILE_FMT_STR,           \
/* 6 */                         FILE_FMT_STR,           \
/* 7 */                         FILE_FMT_NUM,           \
/* 8 */                         FILE_FMT_NUM,           \
/* 9 */                         FILE_FMT_STR,           \
/* 10 */                        FILE_FMT_NUM,           \
/* 11 */                        FILE_FMT_NUM,           \
/* 12 */                        FILE_FMT_STR,           \
/* 13 */                        FILE_FMT_STR,           \
/* 14 */                        FILE_FMT_STR,           \
/* 15 */                        FILE_FMT_STR,           \
/* 16 */                        FILE_FMT_STR,           \
/* 17 */                        FILE_FMT_STR,           \
/* 18 */                        FILE_FMT_STR,           \
/* 19 */                        FILE_FMT_STR,           \
/* 20 */                        FILE_FMT_STR,

Definition at line 143 of file file.h.

Referenced by check_format().

#define FILE_LDATE   14

Definition at line 109 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_LEDATE   12

Definition at line 107 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_LELDATE   16

Definition at line 111 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_LELONG   11

Definition at line 106 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_LESHORT   10

Definition at line 105 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_LESTRING16   19

Definition at line 114 of file file.h.

Referenced by file_signextend(), getvalue(), mconvert(), mcopy(), mprint(), mymcheck(), and parse().

#define FILE_LOAD   0

Definition at line 79 of file file.h.

#define FILE_LONG   4

Definition at line 99 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_MAGICSIZE   (32 * 4)

Definition at line 77 of file file.h.

Referenced by apprentice_1().

#define FILE_OPADD   3

Definition at line 175 of file file.h.

Referenced by mconvert(), mget(), and parse().

#define FILE_OPAND   0

Definition at line 172 of file file.h.

Referenced by mconvert(), mget(), and parse().

#define FILE_OPDIVIDE   6

Definition at line 178 of file file.h.

Referenced by mconvert(), mget(), and parse().

#define FILE_OPINDIRECT   0x80

Definition at line 181 of file file.h.

Referenced by mget(), and parse().

#define FILE_OPINVERSE   0x40

Definition at line 180 of file file.h.

Referenced by file_mdump(), mconvert(), mget(), and parse().

#define FILE_OPMINUS   4

Definition at line 176 of file file.h.

Referenced by mconvert(), mget(), and parse().

#define FILE_OPMODULO   7

Definition at line 179 of file file.h.

Referenced by mconvert(), mget(), and parse().

#define FILE_OPMULTIPLY   5

Definition at line 177 of file file.h.

Referenced by mconvert(), mget(), and parse().

#define FILE_OPOR   1

Definition at line 173 of file file.h.

Referenced by mconvert(), mget(), and parse().

#define FILE_OPS   "&|^+-*/%"

Definition at line 171 of file file.h.

Referenced by parse().

#define FILE_OPXOR   2

Definition at line 174 of file file.h.

Referenced by mconvert(), mget(), and parse().

#define FILE_PSTRING   13

Definition at line 108 of file file.h.

Referenced by file_mdump(), file_signextend(), getvalue(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_RCSID ( id   ) 

Value:

static const char *rcsid(const char *p) { \
        return rcsid(p = id); \
}

Definition at line 343 of file file.h.

#define FILE_REGEX   17

Definition at line 112 of file file.h.

Referenced by file_mdump(), file_signextend(), getvalue(), mconvert(), mcopy(), mprint(), mymcheck(), and parse().

#define FILE_SEARCH   20

Definition at line 115 of file file.h.

Referenced by file_signextend(), getvalue(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_SHORT   2

Definition at line 98 of file file.h.

Referenced by file_mdump(), file_signextend(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define FILE_STRING   5

Definition at line 100 of file file.h.

Referenced by file_mdump(), file_signextend(), getvalue(), mconvert(), mget(), mprint(), mymcheck(), and parse().

#define HOWMANY   (256 * 1024)

Definition at line 69 of file file.h.

Referenced by uncompressbuf().

#define INDIR   1

Definition at line 88 of file file.h.

Referenced by file_mdump(), mget(), and parse().

#define INDIROFFADD   8

Definition at line 91 of file file.h.

Referenced by mget(), and parse().

#define MAGIC   "/etc/magic"

Definition at line 53 of file file.h.

Referenced by file_apprentice().

#define MAGICNO   0xF11E041C

Definition at line 75 of file file.h.

Referenced by apprentice_map().

#define MAXDESC   64

Definition at line 72 of file file.h.

Referenced by parse().

#define MAXMAGIS   8192

Definition at line 71 of file file.h.

Referenced by apprentice_file().

#define MAXstring   32

Definition at line 73 of file file.h.

#define O_BINARY   0

Definition at line 340 of file file.h.

#define OFFADD   4

Definition at line 90 of file file.h.

Referenced by match(), and parse().

#define PATHSEP   ':'

Definition at line 59 of file file.h.

Referenced by file_apprentice().

#define private   static

Definition at line 62 of file file.h.

#define public

Definition at line 66 of file file.h.

#define strerror (  )     (((e) >= 0 && (e) < sys_nerr) ? sys_errlist[(e)] : "Unknown error")

Definition at line 323 of file file.h.

Referenced by checkOwners(), checkPassPhrase(), cpioStrerror(), dbiOpen(), doScript(), fdFgets(), fdWritable(), file_fsmagic(), fsmStage(), Fstrerror(), getFdErrstr(), getFilesystemList(), getOutputFrom(), load(), main(), makeGPGSignature(), makePGPSignature(), packageBinaries(), processSourceFiles(), rpmdbRebuild(), rpmfcClassify(), rpmGetFilesystemUsage(), rpmProblemString(), rpmQueryVerify(), runScript(), ufdRead(), ufdWrite(), uncompressbuf(), unwrap(), urlStrerror(), and verifyHeader().

#define STRING_COMPACT_BLANK   BIT(1)

Definition at line 212 of file file.h.

Referenced by file_mdump(), mymcheck(), and parse().

#define STRING_COMPACT_OPTIONAL_BLANK   BIT(2)

Definition at line 213 of file file.h.

Referenced by file_mdump(), mymcheck(), and parse().

#define STRING_IGNORE_LOWERCASE   BIT(0)

Definition at line 211 of file file.h.

Referenced by file_mdump(), mymcheck(), and parse().

#define strtoul ( a,
b,
 )     strtol(a, b, c)

Definition at line 328 of file file.h.

Referenced by addCanon(), getvalue(), parse(), parseFormat(), parseNum(), rpmQueryVerify(), and strntoul().

#define UNSIGNED   2

Definition at line 89 of file file.h.

Referenced by file_mdump(), file_signextend(), mymcheck(), and parse().

#define VERSIONNO   2

Definition at line 76 of file file.h.

Referenced by apprentice_map().


Function Documentation

struct mlist* file_apprentice ( struct magic_set ms,
const char *  ,
int   
) [read]

Definition at line 254 of file apprentice.c.

References apprentice_1(), file_error(), file_oomem(), magic_set::flags, getenv(), MAGIC, and PATHSEP.

int file_ascmagic ( struct magic_set ms,
const unsigned char *  ,
size_t   
)

Definition at line 78 of file ascmagic.c.

References ascmatch(), from_ebcdic(), ISSPC, looks_ascii(), looks_extended(), looks_latin1(), looks_unicode(), looks_utf8(), names::name, NNAMES, names::type, and types.

void file_badread ( struct magic_set ms  ) 

Referenced by apprentice_map().

void file_badseek ( struct magic_set ms  ) 

Referenced by file_pipe2file().

int file_buffer ( struct magic_set ms,
int  ,
const void *  ,
size_t   
)

Referenced by file_zmagic().

void file_delmagic ( struct magic p,
int  type,
size_t  entries 
)

Definition at line 231 of file apprentice.c.

Referenced by apprentice_1().

void file_error ( struct magic_set ms,
int  ,
const char *  ,
  ... 
)

Referenced by apprentice_1(), apprentice_compile(), apprentice_file(), apprentice_map(), file_apprentice(), file_fsmagic(), file_pipe2file(), getstr(), mconvert(), mget(), mprint(), mymcheck(), and uncompressbuf().

const char* file_fmttime ( uint32_t  ,
int   
)

Definition at line 157 of file print.c.

Referenced by file_mdump(), and mprint().

int file_fsmagic ( struct magic_set ms,
const char *  fn,
struct stat *  sb 
)

Definition at line 64 of file fsmagic.c.

References errno, file_error(), file_printf(), magic_set::flags, magic_set::haderr, major, minor, S_IFSOCK, and strerror.

const char* file_getbuffer ( struct magic_set ms  ) 

int file_is_tar ( struct magic_set ms,
const unsigned char *  ,
size_t   
)

void file_magwarn ( struct magic_set ms,
const char *  ,
  ... 
)

Definition at line 141 of file print.c.

References magic_set::file, and magic_set::line.

Referenced by apprentice_1(), check_format(), file_signextend(), getvalue(), and parse().

size_t file_mbswidth ( const char *   ) 

Definition at line 480 of file file.c.

Referenced by main(), process(), and unwrap().

void file_mdump ( struct magic m  ) 

Definition at line 51 of file print.c.

References CHAR_COMPACT_BLANK, CHAR_COMPACT_OPTIONAL_BLANK, CHAR_IGNORE_LOWERCASE, magic::cont_level, magic::desc, FILE_BEDATE, FILE_BELDATE, FILE_BELONG, FILE_BESHORT, FILE_BYTE, FILE_DATE, file_fmttime(), FILE_LDATE, FILE_LEDATE, FILE_LELDATE, FILE_LELONG, FILE_LESHORT, FILE_LONG, FILE_OPINVERSE, FILE_PSTRING, FILE_REGEX, FILE_SHORT, file_showstr(), FILE_STRING, magic::flag, magic::in_offset, magic::in_op, magic::in_type, INDIR, magic::VALUETYPE::l, magic::mask, magic::mask_op, magic::offset, magic::reln, magic::VALUETYPE::s, STRING_COMPACT_BLANK, STRING_COMPACT_OPTIONAL_BLANK, STRING_IGNORE_LOWERCASE, SZOF, magic::type, UNSIGNED, and magic::value.

Referenced by mget(), and parse().

void file_oomem ( struct magic_set ms  ) 

Referenced by apprentice_1(), apprentice_file(), apprentice_map(), check_mem(), file_apprentice(), mcopy(), and parse().

int file_pipe2file ( struct magic_set ms,
int  fd,
const void *  startbuf,
size_t  nbytes 
)

Definition at line 190 of file compress.c.

References errno, file_badseek(), file_error(), SEEK_SET, sread(), and swrite().

int file_printf ( struct magic_set ms,
const char *  ,
  ... 
)

Referenced by file_fsmagic(), file_zmagic(), match(), and mprint().

int file_reset ( struct magic_set ms  ) 

void file_showstr ( FILE *  fp,
const char *  ,
size_t   
)

Definition at line 997 of file apprentice.c.

Referenced by file_mdump(), and mdebug().

uint32_t file_signextend ( struct magic_set ms,
struct magic ,
uint32_t   
)

Definition at line 374 of file apprentice.c.

References FILE_BEDATE, FILE_BELDATE, FILE_BELONG, FILE_BESHORT, FILE_BESTRING16, FILE_BYTE, FILE_DATE, FILE_LDATE, FILE_LEDATE, FILE_LELDATE, FILE_LELONG, FILE_LESHORT, FILE_LESTRING16, FILE_LONG, file_magwarn(), FILE_PSTRING, FILE_REGEX, FILE_SEARCH, FILE_SHORT, FILE_STRING, magic::flag, magic_set::flags, magic::type, and UNSIGNED.

Referenced by getvalue(), mprint(), mymcheck(), and parse().

int file_softmagic ( struct magic_set ms,
const unsigned char *  ,
size_t   
)

Definition at line 82 of file softmagic.c.

References mlist::magic, match(), magic_set::mlist, mlist::next, and mlist::nmagic.

int file_tryelf ( struct magic_set ms,
int  ,
const unsigned char *  ,
size_t   
)

int file_zmagic ( struct magic_set ms,
int  ,
const unsigned char *  ,
size_t   
)

Definition at line 101 of file compress.c.

References file_buffer(), file_printf(), magic_set::flags, maglen, and uncompressbuf().


Variable Documentation

char* sys_errlist[]

int sys_nerr


Generated on Fri Oct 12 08:44:55 2007 for rpm by  doxygen 1.5.2