Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

file/src/apprentice.c File Reference

#include "system.h"
#include "file.h"
#include "debug.h"

Go to the source code of this file.

Defines

#define EATAB
#define LOWCASE(l)
#define MAP_FAILED   (void *) -1
#define MAP_FILE   0
#define MAGIC   "/etc/magic"
#define ALLOC_INCR   200
#define NBYTE   4
#define NSHORT   5
#define NLONG   4
#define NSTRING   6
#define NDATE   4
#define NBESHORT   7
#define NBELONG   6
#define NBEDATE   6
#define NLESHORT   7
#define NLELONG   6
#define NLEDATE   6
#define NPSTRING   7
#define NLDATE   5
#define NBELDATE   7
#define NLELDATE   7
#define NREGEX   5

Functions

const char * rcsid (const char *p)
uint32_t file_signextend (struct magic *m, uint32_t v)
void eatsize (char **p)
int hextoint (int c)
char * getstr (char *s, char *p, int plen, int *slen)
int getvalue (struct magic *m, char **p)
int parse (struct magic **magicp, uint32_t *nmagicp, char *l, int action)
void file_showstr (FILE *fp, const char *s, size_t len)
uint16_t swap2 (uint16_t sv)
uint32_t swap4 (uint32_t sv)
void bs1 (struct magic *m)
void byteswap (struct magic *m, uint32_t nmagic)
char * mkdbname (const char *fn)
int apprentice_file (fmagic fm, struct magic **magicp, uint32_t *nmagicp, const char *fn, int action)
int apprentice_compile (const fmagic fm, struct magic **magicp, uint32_t *nmagicp, const char *fn, int action)
int apprentice_map (const fmagic fm, struct magic **magicp, uint32_t *nmagicp, const char *fn, int action)
int apprentice_1 (fmagic fm, const char *fn, int action)
int fmagicSetup (fmagic fm, const char *fn, int action)

Variables

char PATHSEP = ':'
int maxmagic = 0
const char * default_magicfile = "/etc/magic"


Define Documentation

#define ALLOC_INCR   200
 

Referenced by parse().

#define EATAB
 

Value:

{while (isascii((unsigned char) *l) && \
                      isspace((unsigned char) *l))  ++l;}

Definition at line 45 of file apprentice.c.

Referenced by parse().

#define LOWCASE  ) 
 

Value:

(isupper((unsigned char) (l)) ? \
                        tolower((unsigned char) (l)) : (l))

Definition at line 47 of file apprentice.c.

Referenced by eatsize().

#define MAGIC   "/etc/magic"
 

Definition at line 78 of file apprentice.c.

#define MAP_FAILED   (void *) -1
 

Definition at line 60 of file apprentice.c.

Referenced by apprentice_map().

#define MAP_FILE   0
 

Definition at line 64 of file apprentice.c.

Referenced by apprentice_map().

#define NBEDATE   6
 

Referenced by parse().

#define NBELDATE   7
 

Referenced by parse().

#define NBELONG   6
 

Referenced by parse().

#define NBESHORT   7
 

Referenced by parse().

#define NBYTE   4
 

Referenced by parse().

#define NDATE   4
 

Referenced by parse().

#define NLDATE   5
 

Referenced by parse().

#define NLEDATE   6
 

Referenced by parse().

#define NLELDATE   7
 

Referenced by parse().

#define NLELONG   6
 

Referenced by parse().

#define NLESHORT   7
 

Referenced by parse().

#define NLONG   4
 

Referenced by parse().

#define NPSTRING   7
 

Referenced by parse().

#define NREGEX   5
 

Referenced by parse().

#define NSHORT   5
 

Referenced by parse().

#define NSTRING   6
 

Referenced by parse().


Function Documentation

int apprentice_1 fmagic  fm,
const char *  fn,
int  action
[static]
 

Definition at line 1022 of file apprentice.c.

References __progname, apprentice_compile(), apprentice_file(), apprentice_map(), FILE_COMPILE, fmagic, fmagic_s::mlist, mlist::next, mlist::prev, and xmalloc().

Referenced by fmagicSetup().

int apprentice_compile const fmagic  fm,
struct magic **  magicp,
uint32_t *  nmagicp,
const char *  fn,
int  action
[static]
 

Definition at line 865 of file apprentice.c.

References __progname, errno, fmagic, MAGICNO, mkdbname(), SEEK_SET, strerror(), and VERSIONNO.

Referenced by apprentice_1().

int apprentice_file fmagic  fm,
struct magic **  magicp,
uint32_t *  nmagicp,
const char *  fn,
int  action
[static]
 

Definition at line 812 of file apprentice.c.

References __progname, errno, FILE_CHECK, fmagic, fmagic_s::lineno, maxmagic, MAXMAGIS, parse(), strerror(), and xcalloc().

Referenced by apprentice_1().

int apprentice_map const fmagic  fm,
struct magic **  magicp,
uint32_t *  nmagicp,
const char *  fn,
int  action
[static]
 

Definition at line 921 of file apprentice.c.

References __progname, byteswap(), errno, fmagic, MAGICNO, MAP_FAILED, MAP_FILE, mkdbname(), strerror(), swap4(), VERSIONNO, and xmalloc().

Referenced by apprentice_1().

void bs1 struct magic m  )  [static]
 

Definition at line 767 of file apprentice.c.

References magic::cont_level, FILE_STRING, magic::in_offset, magic::VALUETYPE::l, magic::mask, magic::offset, swap2(), swap4(), magic::type, and magic::value.

Referenced by byteswap().

void byteswap struct magic m,
uint32_t  nmagic
[static]
 

Definition at line 783 of file apprentice.c.

References bs1().

Referenced by apprentice_map().

void eatsize char **  p  )  [static]
 

Definition at line 133 of file apprentice.c.

References LOWCASE.

Referenced by getvalue(), and parse().

void file_showstr FILE *  fp,
const char *  s,
size_t  len
 

Definition at line 675 of file apprentice.c.

Referenced by file_mdump(), and fmagicSDebug().

uint32_t file_signextend struct magic m,
uint32_t  v
 

Definition at line 88 of file apprentice.c.

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

Referenced by fmagicSCheck(), fmagicSPrint(), getvalue(), and parse().

int fmagicSetup fmagic  fm,
const char *  fn,
int  action
 

Definition at line 1075 of file apprentice.c.

References __progname, apprentice_1(), EXIT_FAILURE, FILE_CHECK, fmagic, fmagic_s::mlist, mlist::next, PATHSEP, mlist::prev, and xstrdup().

Referenced by main(), and rpmfcClassify().

char* getstr char *  s,
char *  p,
int  plen,
int *  slen
[static]
 

Definition at line 182 of file apprentice.c.

References hextoint().

Referenced by getvalue().

int getvalue struct magic m,
char **  p
[static]
 

Definition at line 290 of file apprentice.c.

References eatsize(), FILE_PSTRING, FILE_REGEX, file_signextend(), FILE_STRING, getstr(), magic::VALUETYPE::l, magic::reln, magic::VALUETYPE::s, magic::type, magic::vallen, and magic::value.

Referenced by parse().

int hextoint int  c  )  [static]
 

Definition at line 159 of file apprentice.c.

Referenced by getstr().

char* mkdbname const char *  fn  )  [static]
 

Definition at line 798 of file apprentice.c.

References stpcpy(), and xmalloc().

Referenced by apprentice_compile(), and apprentice_map().

int parse struct magic **  magicp,
uint32_t *  nmagicp,
char *  l,
int  action
[static]
 

Definition at line 313 of file apprentice.c.

References ALLOC_INCR, CHAR_COMPACT_BLANK, CHAR_COMPACT_OPTIONAL_BLANK, CHAR_IGNORE_LOWERCASE, EATAB, eatsize(), FILE_BEDATE, FILE_BELDATE, FILE_BELONG, FILE_BESHORT, FILE_BYTE, FILE_CHECK, FILE_DATE, FILE_LDATE, FILE_LEDATE, FILE_LELDATE, FILE_LELONG, FILE_LESHORT, FILE_LONG, file_magwarn(), file_mdump(), FILE_OPADD, FILE_OPAND, FILE_OPDIVIDE, FILE_OPINVERSE, FILE_OPMINUS, FILE_OPMODULO, FILE_OPMULTIPLY, FILE_OPOR, FILE_OPXOR, FILE_PSTRING, FILE_REGEX, FILE_SHORT, file_signextend(), FILE_STRING, getvalue(), INDIR, MAXDESC, maxmagic, NBEDATE, NBELDATE, NBELONG, NBESHORT, NBYTE, NDATE, NLDATE, NLEDATE, NLELDATE, NLELONG, NLESHORT, NLONG, NPSTRING, NREGEX, NSHORT, NSTRING, OFFADD, STRING_COMPACT_BLANK, STRING_COMPACT_OPTIONAL_BLANK, STRING_IGNORE_LOWERCASE, UNSIGNED, and xrealloc().

Referenced by apprentice_file().

const char* rcsid const char *  p  )  [inline, static]
 

Definition at line 41 of file apprentice.c.

uint16_t swap2 uint16_t  sv  )  [static]
 

Definition at line 732 of file apprentice.c.

Referenced by bs1().

uint32_t swap4 uint32_t  sv  )  [static]
 

Definition at line 749 of file apprentice.c.

Referenced by apprentice_map(), and bs1().


Variable Documentation

const char* default_magicfile = "/etc/magic"
 

Definition at line 82 of file apprentice.c.

Referenced by main(), and rpmfcClassify().

int maxmagic = 0 [static]
 

Definition at line 75 of file apprentice.c.

Referenced by apprentice_file(), and parse().

char PATHSEP = ':' [static]
 

Definition at line 71 of file apprentice.c.

Referenced by fmagicSetup().


Generated on Tue Apr 19 03:30:28 2005 for rpm by doxygen 1.3.5