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

file/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 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 showstr (FILE *fp, const char *s, int 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
 

#define EATAB
 

Value:

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

Definition at line 36 of file apprentice.c.

Referenced by parse().

#define LOWCASE  
 

Value:

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

Definition at line 38 of file apprentice.c.

Referenced by eatsize().

#define MAGIC   "/etc/magic"
 

Definition at line 69 of file apprentice.c.

#define MAP_FAILED   (void *) -1
 

Definition at line 51 of file apprentice.c.

Referenced by apprentice_map().

#define MAP_FILE   0
 

Definition at line 55 of file apprentice.c.

Referenced by apprentice_map().

#define NBEDATE   6
 

#define NBELDATE   7
 

#define NBELONG   6
 

#define NBESHORT   7
 

#define NBYTE   4
 

#define NDATE   4
 

#define NLDATE   5
 

#define NLEDATE   6
 

#define NLELDATE   7
 

#define NLELONG   6
 

#define NLESHORT   7
 

#define NLONG   4
 

#define NPSTRING   7
 

#define NREGEX   5
 

#define NSHORT   5
 

#define NSTRING   6
 


Function Documentation

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

Definition at line 1006 of file apprentice.c.

References __progname, apprentice_compile(), apprentice_file(), apprentice_map(), COMPILE, mlist::magic, fmagic_s::mlist, mlist::next, mlist::nmagic, 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 860 of file apprentice.c.

References __progname, errno, 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 807 of file apprentice.c.

References __progname, CHECK, errno, fmagic_s::lineno, maxmagic, MAXMAGIS, parse(), and strerror().

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 911 of file apprentice.c.

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

Referenced by apprentice_1().

void bs1 struct magic   m [static]
 

Definition at line 758 of file apprentice.c.

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

Referenced by byteswap().

void byteswap struct magic   m,
uint32_t    nmagic
[static]
 

Definition at line 774 of file apprentice.c.

References bs1().

Referenced by apprentice_map().

void eatsize char **    p [static]
 

Definition at line 124 of file apprentice.c.

References LOWCASE.

Referenced by getvalue(), and parse().

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

Definition at line 1059 of file apprentice.c.

References __progname, apprentice_1(), CHECK, EXIT_FAILURE, 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 173 of file apprentice.c.

References hextoint().

Referenced by getvalue().

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

Definition at line 281 of file apprentice.c.

References eatsize(), getstr(), magic::VALUETYPE::l, PSTRING, REGEX, magic::reln, magic::VALUETYPE::s, signextend(), STRING, magic::type, magic::vallen, and magic::value.

Referenced by parse().

int hextoint int    c [static]
 

Definition at line 150 of file apprentice.c.

Referenced by getstr().

char* mkdbname const char *    fn [static]
 

Definition at line 788 of file apprentice.c.

References xrealloc().

Referenced by apprentice_compile(), and apprentice_map().

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

Definition at line 304 of file apprentice.c.

References BEDATE, BELDATE, BELONG, BESHORT, BYTE, CHAR_COMPACT_BLANK, CHAR_COMPACT_OPTIONAL_BLANK, CHAR_IGNORE_LOWERCASE, CHECK, magic::cont_level, DATE, magic::desc, EATAB, eatsize(), magic::flag, getvalue(), magic::in_offset, magic::in_op, magic::in_type, INDIR, LDATE, LEDATE, LELDATE, LELONG, LESHORT, LONG, magwarn(), magic::mask, magic::mask_op, MAXDESC, maxmagic, mdump(), magic::nospflag, OFFADD, magic::offset, OPADD, OPAND, OPDIVIDE, OPINVERSE, OPMINUS, OPMODULO, OPMULTIPLY, OPOR, OPXOR, PSTRING, REGEX, magic::reln, SHORT, signextend(), STRING, STRING_COMPACT_BLANK, STRING_COMPACT_OPTIONAL_BLANK, STRING_IGNORE_LOWERCASE, magic::type, UNSIGNED, and xrealloc().

Referenced by apprentice_file().

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

Definition at line 32 of file apprentice.c.

void showstr FILE *    fp,
const char *    s,
int    len
 

Definition at line 666 of file apprentice.c.

Referenced by fmagicSDebug(), and mdump().

uint32_t signextend struct magic   m,
uint32_t    v
 

Definition at line 79 of file apprentice.c.

References BEDATE, BELDATE, BELONG, BESHORT, BYTE, DATE, magic::flag, LDATE, LEDATE, LELDATE, LELONG, LESHORT, LONG, magwarn(), PSTRING, REGEX, SHORT, STRING, magic::type, and UNSIGNED.

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

uint16_t swap2 uint16_t    sv [static]
 

Definition at line 723 of file apprentice.c.

Referenced by bs1().

uint32_t swap4 uint32_t    sv [static]
 

Definition at line 740 of file apprentice.c.

Referenced by apprentice_map(), and bs1().


Variable Documentation

const char* default_magicfile = "/etc/magic"
 

Definition at line 73 of file apprentice.c.

int maxmagic = 0 [static]
 

Definition at line 66 of file apprentice.c.

Referenced by apprentice_file(), and parse().

char PATHSEP = ':' [static]
 

Definition at line 62 of file apprentice.c.

Referenced by fmagicSetup().


Generated on Sun Oct 26 13:02:04 2003 for rpm by doxygen1.2.18