file/src/apprentice.c File Reference

#include "file.h"
#include "magic.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/param.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 MAXPATHLEN   1024
#define IS_PLAINSTRING(t)
#define IS_STRING(t)
#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
#define NBESTRING16   10
#define NLESTRING16   10
#define NSEARCH   6
#define RET   1

Functions

static const char * rcsid (const char *p)
static int getvalue (struct magic_set *ms, struct magic *m, char **p)
static int hextoint (int)
static char * getstr (struct magic_set *ms, char *s, char *p, int plen, int *slen)
static int parse (struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, char *l, int action)
static void eatsize (char **p)
static int apprentice_1 (struct magic_set *ms, const char *fn, int action, struct mlist *mlist)
static int apprentice_file (struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, const char *fn, int action)
static void byteswap (struct magic *magic, uint32_t nmagic)
static void bs1 (struct magic *m)
static uint16_t swap2 (uint16_t sv)
static uint32_t swap4 (uint32_t sv)
static char * mkdbname (const char *fn, char *buf, size_t, int)
static int apprentice_map (struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, const char *fn)
static int apprentice_compile (struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, const char *fn)
static int check_format (struct magic_set *ms, struct magic *m)
void file_delmagic (struct magic *p, int type, size_t entries)
struct mlistfile_apprentice (struct magic_set *ms, const char *fn, int action)
uint32_t file_signextend (struct magic_set *ms, struct magic *m, uint32_t v)
void file_showstr (FILE *fp, const char *s, size_t len)

Variables

static size_t maxmagic = 0
static size_t magicsize = sizeof(struct magic)
static const uint32_t ar []
static const char ext [] = ".mgc"


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

Referenced by parse().

#define IS_PLAINSTRING (  ) 

Value:

((t) == FILE_STRING || (t) == FILE_PSTRING || \
    (t) == FILE_BESTRING16 || (t) == FILE_LESTRING16)

Definition at line 77 of file apprentice.c.

Referenced by parse().

#define IS_STRING (  ) 

Value:

(IS_PLAINSTRING(t) || (t) == FILE_REGEX || \
    (t) == FILE_SEARCH)

Definition at line 80 of file apprentice.c.

Referenced by bs1(), and parse().

#define LOWCASE (  ) 

Value:

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

Definition at line 53 of file apprentice.c.

Referenced by eatsize().

#define MAP_FAILED   (void *) -1

Definition at line 66 of file apprentice.c.

Referenced by apprentice_map().

#define MAP_FILE   0

Definition at line 70 of file apprentice.c.

Referenced by apprentice_map().

#define MAXPATHLEN   1024

Definition at line 74 of file apprentice.c.

Referenced by apprentice_compile(), apprentice_map(), Fts_open(), and unwrap().

#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 NBESTRING16   10

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 NLESTRING16   10

Referenced by parse().

#define NLONG   4

Referenced by parse().

#define NPSTRING   7

Referenced by parse().

#define NREGEX   5

Referenced by parse().

#define NSEARCH   6

Referenced by parse().

#define NSHORT   5

Referenced by parse().

#define NSTRING   6

Referenced by parse().

#define RET   1

Referenced by apprentice_map().


Function Documentation

static int apprentice_1 ( struct magic_set ms,
const char *  fn,
int  action,
struct mlist mlist 
) [static]

static int apprentice_compile ( struct magic_set ms,
struct magic **  magicp,
uint32_t *  nmagicp,
const char *  fn 
) [static]

Definition at line 1175 of file apprentice.c.

References errno, file_error(), MAXPATHLEN, mkdbname(), and SEEK_SET.

Referenced by apprentice_1().

static int apprentice_file ( struct magic_set ms,
struct magic **  magicp,
uint32_t *  nmagicp,
const char *  fn,
int  action 
) [static]

Definition at line 319 of file apprentice.c.

References errno, magic_set::file, FILE_CHECK, file_error(), file_oomem(), magic_set::line, MAXMAGIS, and parse().

Referenced by apprentice_1().

static int apprentice_map ( struct magic_set ms,
struct magic **  magicp,
uint32_t *  nmagicp,
const char *  fn 
) [static]

static void bs1 ( struct magic m  )  [static]

static void byteswap ( struct magic magic,
uint32_t  nmagic 
) [static]

Definition at line 1233 of file apprentice.c.

References bs1().

Referenced by apprentice_map().

static int check_format ( struct magic_set ms,
struct magic m 
) [static]

Definition at line 786 of file apprentice.c.

References magic::desc, FILE_FORMAT_NAME, FILE_FORMAT_STRING, file_magwarn(), and magic::type.

Referenced by parse().

static void eatsize ( char **  p  )  [static]

Definition at line 1053 of file apprentice.c.

References LOWCASE.

Referenced by getvalue(), and parse().

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

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_showstr ( FILE *  fp,
const char *  s,
size_t  len 
)

Definition at line 997 of file apprentice.c.

Referenced by file_mdump(), and mdebug().

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

static char * getstr ( struct magic_set ms,
char *  s,
char *  p,
int  plen,
int *  slen 
) [static]

Definition at line 879 of file apprentice.c.

References file_error(), and hextoint().

static int getvalue ( struct magic_set ms,
struct magic m,
char **  p 
) [static]

static int hextoint ( int  c  )  [static]

Definition at line 979 of file apprentice.c.

Referenced by getstr().

static char * mkdbname ( const char *  fn,
char *  buf,
size_t  bufsiz,
int  strip 
) [static]

Definition at line 1217 of file apprentice.c.

References snprintf().

Referenced by apprentice_compile(), and apprentice_map().

static int parse ( struct magic_set ms,
struct magic **  magicp,
uint32_t *  nmagicp,
char *  l,
int  action 
) [static]

static const char* rcsid ( const char *  p  )  [static]

Definition at line 48 of file apprentice.c.

static uint16_t swap2 ( uint16_t  sv  )  [static]

Definition at line 1244 of file apprentice.c.

Referenced by bs1().

static uint32_t swap4 ( uint32_t  sv  )  [static]

Definition at line 1258 of file apprentice.c.

Referenced by apprentice_map(), and bs1().


Variable Documentation

const uint32_t ar[] [static]

Initial value:

 {
     0xF11E041C ,  2 
}

Definition at line 1168 of file apprentice.c.

Referenced by luaD_callhook().

const char ext[] = ".mgc" [static]

size_t magicsize = sizeof(struct magic) [static]

Definition at line 86 of file apprentice.c.

size_t maxmagic = 0 [static]

Definition at line 84 of file apprentice.c.


Generated on Fri Dec 12 13:02:10 2008 for rpm by  doxygen 1.5.6