#include "file.h"
#include "magic.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/param.h>
Include dependency graph for apprentice.c:
Go to the source code of this file.
Data Structures | |
struct | magic_entry |
struct | type_tbl_s |
Defines | |
#define | EATAB |
#define | LOWCASE(l) |
#define | MAP_FAILED (void *) -1 |
#define | MAP_FILE 0 |
#define | MAXPATHLEN 1024 |
#define | XX(s) s, (sizeof(s) - 1) |
#define | XX_NULL NULL, 0 |
#define | MULT 10 |
#define | ALLOC_CHUNK (size_t)10 |
#define | ALLOC_INCR (size_t)200 |
#define | RET 1 |
Functions | |
static const char * | rcsid (const char *p) |
static int | getvalue (struct magic_set *ms, struct magic *m, const char **p, int action) |
static int | hextoint (int c) |
static const char * | getstr (struct magic_set *ms, const char *s, char *p, int plen, int *slen, int action) |
static int | parse (struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp, const char *line, size_t lineno, int action) |
static void | eatsize (const char **p) |
static int | apprentice_1 (struct magic_set *ms, const char *fn, int action, struct mlist *mlist) |
static size_t | apprentice_magic_strength (const struct magic *m) |
static int | apprentice_sort (const void *a, const void *b) |
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 uint64_t | swap8 (uint64_t sv) |
static char * | mkdbname (const char *fn, char *buf, size_t bufsiz, int strip) |
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_type (const char *ptr, int type) |
static int | check_format (struct magic_set *ms, struct magic *m) |
static int | get_type (const char *l, const char **t) |
static void | init_file_tables (void) |
void | file_delmagic (struct magic *p, int type, size_t entries) |
mlist * | file_apprentice (struct magic_set *ms, const char *fn, int action) |
uint64_t | file_signextend (struct magic_set *ms, struct magic *m, uint64_t v) |
static int | string_modifier_check (struct magic_set *ms, struct magic const *m) |
static int | get_op (char c) |
static int | get_cond (const char *l, const char **t) |
static int | check_cond (struct magic_set *ms, int cond, uint32_t cont_level) |
void | file_showstr (FILE *fp, const char *s, size_t len) |
Variables | |
int | file_formats [33] |
const size_t | file_nformats = 33 |
const char * | file_names [33] |
const size_t | file_nnames = 33 |
static size_t | maxmagic = 0 |
static size_t | magicsize = sizeof(struct magic) |
static const struct type_tbl_s | type_tbl [] |
static const uint32_t | ar [] |
static const char | ext [] = ".mgc" |
|
Referenced by parse(). |
|
Referenced by parse(). |
|
Value: {while (isascii((unsigned char) *l) && \ isspace((unsigned char) *l)) ++l;} Definition at line 52 of file apprentice.c. Referenced by parse(). |
|
Value: (isupper((unsigned char) (l)) ? \ tolower((unsigned char) (l)) : (l)) Definition at line 54 of file apprentice.c. Referenced by eatsize(). |
|
Definition at line 67 of file apprentice.c. Referenced by apprentice_map(). |
|
Definition at line 71 of file apprentice.c. Referenced by apprentice_map(). |
|
Definition at line 75 of file apprentice.c. Referenced by apprentice_compile(), apprentice_map(), Fts_open(), and unwrap(). |
|
Referenced by apprentice_magic_strength(). |
|
Referenced by apprentice_map(). |
|
|
|
|
|
Definition at line 275 of file apprentice.c. References apprentice_compile(), apprentice_file(), apprentice_map(), FILE_COMPILE, file_delmagic(), file_error(), FILE_MAGICSIZE, file_magwarn(), file_oomem(), magic_set::flags, magic, MAGIC_CHECK, mlist::mapped, mlist::next, and mlist::prev. Referenced by file_apprentice(). |
|
Definition at line 1773 of file apprentice.c. References errno, file_error(), MAXPATHLEN, mkdbname(), O_BINARY, and SEEK_SET. Referenced by apprentice_1(). |
|
Definition at line 552 of file apprentice.c. References errno, magic_set::file, FILE_CHECK, file_error(), file_oomem(), magic_set::flags, magic_set::line, MAGIC_CHECK, MAXMAGIS, and parse(). Referenced by apprentice_1(). |
|
Definition at line 428 of file apprentice.c. References FILE_BEDATE, FILE_BELDATE, FILE_BELONG, FILE_BEQDATE, FILE_BEQLDATE, FILE_BEQUAD, FILE_BESHORT, FILE_BESTRING16, FILE_BYTE, FILE_DATE, FILE_DEFAULT, FILE_LDATE, FILE_LEDATE, FILE_LELDATE, FILE_LELONG, FILE_LEQDATE, FILE_LEQLDATE, FILE_LEQUAD, FILE_LESHORT, FILE_LESTRING16, FILE_LONG, FILE_MEDATE, FILE_MELDATE, FILE_MELONG, FILE_PSTRING, FILE_QDATE, FILE_QLDATE, FILE_QUAD, FILE_REGEX, FILE_SEARCH, FILE_SHORT, FILE_STRING, MULT, magic::reln, magic::type, and magic::vallen. Referenced by apprentice_sort(). |
|
Definition at line 1677 of file apprentice.c. References byteswap(), errno, file_badread(), file_error(), file_oomem(), MAGICNO, MAP_FAILED, MAP_FILE, MAXPATHLEN, mkdbname(), O_BINARY, RET, swap4(), and VERSIONNO. Referenced by apprentice_1(). |
|
Definition at line 533 of file apprentice.c. References apprentice_magic_strength(), and magic_entry::mp. |
|
Definition at line 1892 of file apprentice.c. References magic::cont_level, magic::in_offset, IS_STRING, magic::lineno, magic::offset, magic::VALUETYPE::q, swap2(), swap4(), swap8(), magic::type, and magic::value. Referenced by byteswap(). |
|
Definition at line 1831 of file apprentice.c. Referenced by apprentice_map(). |
|
Definition at line 826 of file apprentice.c. References magic_set::c, COND_ELIF, COND_ELSE, COND_IF, COND_NONE, file_magwarn(), magic_set::flags, magic_set::cont::level_info::last_cond, magic_set::cont::li, and MAGIC_CHECK. Referenced by parse(). |
|
Definition at line 1337 of file apprentice.c. References check_format_type(), magic::desc, file_error(), FILE_FMT_NONE, and magic::type. Referenced by parse(). |
|
Definition at line 1234 of file apprentice.c. References FILE_FMT_NUM, FILE_FMT_QUAD, and FILE_FMT_STR. Referenced by check_format(). |
|
Definition at line 1651 of file apprentice.c. References LOWCASE. Referenced by getvalue(), and parse(). |
|
Definition at line 359 of file apprentice.c. References apprentice_1(), file_error(), file_oomem(), magic_set::flags, getenv(), init_file_tables(), MAGIC, MAGIC_MIME, mime, and PATHSEP. Referenced by magic_check(), magic_compile(), and magic_load(). |
|
Definition at line 336 of file apprentice.c. Referenced by apprentice_1(), and free_mlist(). |
|
Definition at line 1592 of file apprentice.c. Referenced by file_mdump(), and mdebug(). |
|
Definition at line 663 of file apprentice.c. References FILE_BEDATE, FILE_BELDATE, FILE_BELONG, FILE_BEQDATE, FILE_BEQLDATE, FILE_BEQUAD, FILE_BESHORT, FILE_BESTRING16, FILE_BYTE, FILE_DATE, FILE_DEFAULT, FILE_LDATE, FILE_LEDATE, FILE_LELDATE, FILE_LELONG, FILE_LEQDATE, FILE_LEQLDATE, FILE_LEQUAD, FILE_LESHORT, FILE_LESTRING16, FILE_LONG, file_magwarn(), FILE_MEDATE, FILE_MELDATE, FILE_MELONG, FILE_PSTRING, FILE_QDATE, FILE_QLDATE, FILE_QUAD, FILE_REGEX, FILE_SEARCH, FILE_SHORT, FILE_STRING, magic::flag, magic_set::flags, MAGIC_CHECK, magic::type, and UNSIGNED. Referenced by getvalue(), mprint(), and parse(). |
|
Definition at line 797 of file apprentice.c. References cond(), COND_ELIF, COND_ELSE, COND_IF, and COND_NONE. Referenced by parse(). |
|
Definition at line 770 of file apprentice.c. References FILE_OPADD, FILE_OPAND, FILE_OPDIVIDE, FILE_OPMINUS, FILE_OPMODULO, FILE_OPMULTIPLY, FILE_OPOR, and FILE_OPXOR. Referenced by parse(). |
|
Definition at line 235 of file apprentice.c. References type_tbl_s::len, type_tbl_s::name, and type_tbl. Referenced by parse(). |
|
Definition at line 1431 of file apprentice.c. References FILE_COMPILE, file_error(), file_magwarn(), and hextoint(). |
|
Definition at line 1392 of file apprentice.c. References eatsize(), FILE_BESTRING16, FILE_LESTRING16, file_magwarn(), FILE_PSTRING, FILE_REGEX, FILE_SEARCH, file_signextend(), FILE_STRING, magic_set::flags, getstr, MAGIC_CHECK, magic::VALUETYPE::q, magic::reln, magic::VALUETYPE::s, magic::type, magic::vallen, and magic::value. Referenced by parse(). |
|
Definition at line 1574 of file apprentice.c. Referenced by getstr(). |
|
Definition at line 251 of file apprentice.c. References FILE_NAMES_SIZE, type_tbl_s::format, type_tbl_s::name, type_tbl_s::type, and type_tbl. Referenced by file_apprentice(). |
|
Definition at line 1815 of file apprentice.c. References snprintf(). Referenced by apprentice_compile(), and apprentice_map(). |
|
|
Definition at line 49 of file apprentice.c. |
|
Definition at line 724 of file apprentice.c. References CHAR_COMPACT_BLANK, CHAR_COMPACT_OPTIONAL_BLANK, CHAR_REGEX_OFFSET_START, FILE_BESTRING16, FILE_LESTRING16, file_magwarn(), FILE_PSTRING, FILE_REGEX, FILE_SEARCH, FILE_STRING, magic_set::flags, MAGIC_CHECK, REGEX_OFFSET_START, STRING_COMPACT_BLANK, STRING_COMPACT_OPTIONAL_BLANK, and magic::type. Referenced by parse(). |
|
Definition at line 1842 of file apprentice.c. Referenced by bs1(). |
|
Definition at line 1856 of file apprentice.c. Referenced by apprentice_map(), and bs1(). |
|
Definition at line 1872 of file apprentice.c. Referenced by bs1(). |
|
Initial value: { 0xF11E041C , 4 } Definition at line 1766 of file apprentice.c. Referenced by freeAttrRec(), luaD_callhook(), nullAttrRec(), and parseForAttr(). |
|
Definition at line 1810 of file apprentice.c. Referenced by findTag(), hdr_subscript(), init_rpm(), rcsid(), rpmDisplayQueryTags(), rpmecFree(), and rpmecNew(). |
|
Definition at line 85 of file apprentice.c. |
|
Definition at line 89 of file apprentice.c. Referenced by file_mdump(). |
|
Definition at line 87 of file apprentice.c. |
|
Definition at line 91 of file apprentice.c. Referenced by file_mdump(). |
|
Definition at line 96 of file apprentice.c. |
|
Definition at line 94 of file apprentice.c. |
|
Referenced by get_type(), and init_file_tables(). |