#include <stdio.h>#include <errno.h>#include <fcntl.h>#include <regex.h>#include <sys/types.h>#include <sys/stat.h>Include dependency graph for file.h:

This graph shows which files directly or indirectly include this file:

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::cont::level_info |
| struct | magic_set::out |
Defines | |
| #define | ENABLE_CONDITIONALS |
| #define | MAGIC "/etc/magic" |
| #define | PATHSEP ':' |
| #define | private static |
| #define | public |
| #define | __GNUC_PREREQ__(x, y) 0 |
| #define | f__unused |
| #define | MIN(a, b) (((a) < (b)) ? (a) : (b)) |
| #define | HOWMANY (256 * 1024) |
| #define | MAXMAGIS 8192 |
| #define | MAXDESC 64 |
| #define | MAXstring 32 |
| #define | MAGICNO 0xF11E041C |
| #define | VERSIONNO 4 |
| #define | FILE_MAGICSIZE (32 * 4) |
| #define | FILE_LOAD 0 |
| #define | FILE_CHECK 1 |
| #define | FILE_COMPILE 2 |
| #define | INDIR 1 |
| #define | OFFADD 2 |
| #define | INDIROFFADD 4 |
| #define | UNSIGNED 8 |
| #define | FILE_INVALID 0 |
| #define | FILE_BYTE 1 |
| #define | FILE_SHORT 2 |
| #define | FILE_DEFAULT 3 |
| #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_MEDATE 21 |
| #define | FILE_MELDATE 22 |
| #define | FILE_MELONG 23 |
| #define | FILE_QUAD 24 |
| #define | FILE_LEQUAD 25 |
| #define | FILE_BEQUAD 26 |
| #define | FILE_QDATE 27 |
| #define | FILE_LEQDATE 28 |
| #define | FILE_BEQDATE 29 |
| #define | FILE_QLDATE 30 |
| #define | FILE_LEQLDATE 31 |
| #define | FILE_BEQLDATE 32 |
| #define | FILE_NAMES_SIZE 33 |
| #define | IS_STRING(t) |
| #define | FILE_FMT_NONE 0 |
| #define | FILE_FMT_NUM 1 |
| #define | FILE_FMT_STR 2 |
| #define | FILE_FMT_QUAD 3 |
| #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_OPS_MASK 0x07 |
| #define | FILE_UNUSED_1 0x08 |
| #define | FILE_UNUSED_2 0x10 |
| #define | FILE_UNUSED_3 0x20 |
| #define | FILE_OPINVERSE 0x40 |
| #define | FILE_OPINDIRECT 0x80 |
| #define | COND_NONE 0 |
| #define | COND_IF 1 |
| #define | COND_ELIF 2 |
| #define | COND_ELSE 3 |
| #define | num_mask _u._mask |
| #define | str_count _u._s._count |
| #define | str_flags _u._s._flags |
| #define | BIT(A) (1 << (A)) |
| #define | STRING_COMPACT_BLANK BIT(0) |
| #define | STRING_COMPACT_OPTIONAL_BLANK BIT(1) |
| #define | STRING_IGNORE_LOWERCASE BIT(2) |
| #define | STRING_IGNORE_UPPERCASE BIT(3) |
| #define | REGEX_OFFSET_START BIT(4) |
| #define | CHAR_COMPACT_BLANK 'B' |
| #define | CHAR_COMPACT_OPTIONAL_BLANK 'b' |
| #define | CHAR_IGNORE_LOWERCASE 'c' |
| #define | CHAR_IGNORE_UPPERCASE 'C' |
| #define | CHAR_REGEX_OFFSET_START 's' |
| #define | STRING_IGNORE_CASE (STRING_IGNORE_LOWERCASE|STRING_IGNORE_UPPERCASE) |
| #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 fd, const char *inname, const void *buf, size_t nb) |
| int | file_fsmagic (struct magic_set *ms, const char *, struct stat *sb) |
| int | file_pipe2file (struct magic_set *ms, int, const void *, size_t) |
| 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 fd, const char *name, const unsigned char *buf, size_t nbytes) |
| 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) |
| mlist * | file_apprentice (struct magic_set *ms, const char *, int) |
| uint64_t | file_signextend (struct magic_set *ms, struct magic *, uint64_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, size_t) |
| void | file_error (struct magic_set *ms, int error, const char *f,...) |
| void | file_magerror (struct magic_set *ms, const char *,...) |
| void | file_magwarn (struct magic_set *ms, const char *,...) |
| void | file_mdump (struct magic *) |
| void | file_showstr (FILE *fp, const char *, size_t) |
| size_t | file_mbswidth (const char *) |
| const char * | file_getbuffer (struct magic_set *ms) |
| ssize_t | sread (int fd, void *buf, size_t n, int canbepipe) |
| int | file_check_mem (struct magic_set *ms, unsigned int) |
| int | snprintf (char *, size_t, const char *,...) |
Variables | |
| const char * | file_names [] |
| const size_t | file_nnames |
| int | sys_nerr |
| char * | sys_errlist [] |
| #define CHAR_COMPACT_BLANK 'B' |
Definition at line 246 of file file.h.
Referenced by file_mdump(), parse(), and string_modifier_check().
| #define CHAR_COMPACT_OPTIONAL_BLANK 'b' |
Definition at line 247 of file file.h.
Referenced by file_mdump(), parse(), and string_modifier_check().
| #define CHAR_IGNORE_LOWERCASE 'c' |
| #define CHAR_IGNORE_UPPERCASE 'C' |
| #define CHAR_REGEX_OFFSET_START 's' |
Definition at line 250 of file file.h.
Referenced by file_mdump(), parse(), and string_modifier_check().
| #define COND_ELIF 2 |
| #define COND_ELSE 3 |
| #define COND_IF 1 |
| #define COND_NONE 0 |
Definition at line 201 of file file.h.
Referenced by check_cond(), file_check_mem(), and get_cond().
| #define FILE_BEDATE 9 |
Definition at line 133 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint().
| #define FILE_BELDATE 15 |
Definition at line 139 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint().
| #define FILE_BELONG 8 |
Definition at line 132 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse().
| #define FILE_BEQDATE 29 |
Definition at line 153 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint().
| #define FILE_BEQLDATE 32 |
Definition at line 156 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint().
| #define FILE_BEQUAD 26 |
Definition at line 150 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint().
| #define FILE_BESHORT 7 |
Definition at line 131 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse().
| #define FILE_BESTRING16 18 |
Definition at line 142 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), getvalue(), magiccheck(), mconvert(), mcopy(), mprint(), and string_modifier_check().
| #define FILE_BYTE 1 |
Definition at line 125 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse().
| #define FILE_CHECK 1 |
Definition at line 106 of file file.h.
Referenced by apprentice_file(), magic_check(), main(), and parse().
| #define FILE_COMPILE 2 |
Definition at line 107 of file file.h.
Referenced by apprentice_1(), getstr(), magic_compile(), and main().
| #define FILE_DATE 6 |
Definition at line 130 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint().
| #define FILE_DEFAULT 3 |
Definition at line 127 of file file.h.
Referenced by apprentice_file(), apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), match(), mconvert(), mget(), and mprint().
| #define FILE_FMT_NONE 0 |
| #define FILE_FMT_NUM 1 |
| #define FILE_FMT_QUAD 3 |
| #define FILE_FMT_STR 2 |
| #define FILE_LDATE 14 |
Definition at line 138 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint().
| #define FILE_LEDATE 12 |
Definition at line 136 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint().
| #define FILE_LELDATE 16 |
Definition at line 140 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint().
| #define FILE_LELONG 11 |
Definition at line 135 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse().
| #define FILE_LEQDATE 28 |
Definition at line 152 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint().
| #define FILE_LEQLDATE 31 |
Definition at line 155 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint().
| #define FILE_LEQUAD 25 |
Definition at line 149 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint().
| #define FILE_LESHORT 10 |
Definition at line 134 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse().
| #define FILE_LESTRING16 19 |
Definition at line 143 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), getvalue(), magiccheck(), mconvert(), mcopy(), mprint(), and string_modifier_check().
| #define FILE_LOAD 0 |
| #define FILE_LONG 4 |
Definition at line 128 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse().
| #define FILE_MAGICSIZE (32 * 4) |
| #define FILE_MEDATE 21 |
Definition at line 145 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint().
| #define FILE_MELDATE 22 |
Definition at line 146 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint().
| #define FILE_MELONG 23 |
Definition at line 147 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse().
| #define FILE_NAMES_SIZE 33 |
| #define FILE_OPDIVIDE 6 |
| #define FILE_OPINDIRECT 0x80 |
| #define FILE_OPINVERSE 0x40 |
| #define FILE_OPMULTIPLY 5 |
| #define FILE_OPS "&|^+-*/%" |
| #define FILE_OPS_MASK 0x07 |
| #define FILE_PSTRING 13 |
Definition at line 137 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), getvalue(), magiccheck(), mconvert(), mcopy(), mget(), mprint(), and string_modifier_check().
| #define FILE_QDATE 27 |
Definition at line 151 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint().
| #define FILE_QLDATE 30 |
Definition at line 154 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint().
| #define FILE_QUAD 24 |
Definition at line 148 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint().
| #define FILE_RCSID | ( | id | ) |
| #define FILE_REGEX 17 |
Definition at line 141 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), getvalue(), magiccheck(), mconvert(), mcopy(), mget(), mprint(), and string_modifier_check().
| #define FILE_SEARCH 20 |
Definition at line 144 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), getvalue(), magiccheck(), mconvert(), mcopy(), mget(), mprint(), and string_modifier_check().
| #define FILE_SHORT 2 |
Definition at line 126 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint().
| #define FILE_STRING 5 |
Definition at line 129 of file file.h.
Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), getvalue(), magiccheck(), mconvert(), mcopy(), mget(), mprint(), and string_modifier_check().
| #define HOWMANY (256 * 1024) |
| #define INDIR 1 |
| #define IS_STRING | ( | t | ) |
Value:
((t) == FILE_STRING || \ (t) == FILE_PSTRING || \ (t) == FILE_BESTRING16 || \ (t) == FILE_LESTRING16 || \ (t) == FILE_REGEX || \ (t) == FILE_SEARCH || \ (t) == FILE_DEFAULT)
Definition at line 159 of file file.h.
Referenced by bs1(), file_mdump(), and parse().
| #define MAGIC "/etc/magic" |
| #define MAGICNO 0xF11E041C |
| #define MAXMAGIS 8192 |
| #define MIN | ( | a, | |||
| b | ) | (((a) < (b)) ? (a) : (b)) |
| #define O_BINARY 0 |
Definition at line 406 of file file.h.
Referenced by apprentice_compile(), apprentice_map(), and magic_file().
| #define PATHSEP ':' |
| #define REGEX_OFFSET_START BIT(4) |
Definition at line 245 of file file.h.
Referenced by file_mdump(), mprint(), parse(), and string_modifier_check().
| #define strerror | ( | e | ) | (((e) >= 0 && (e) < sys_nerr) ? sys_errlist[(e)] : "Unknown error") |
Definition at line 388 of file file.h.
Referenced by checkOwners(), checkPassPhrase(), cpioStrerror(), dbiOpen(), doScript(), fdFgets(), fdWritable(), file_error_core(), file_fsmagic(), fsmStage(), Fstrerror(), getFdErrstr(), getFilesystemList(), getOutputFrom(), load(), lzdClose(), lzdWrite(), main(), makeGPGSignature(), makePGPSignature(), packageBinaries(), prepFetch(), processSourceFiles(), rpmdbRebuild(), rpmdsGetconf(), rpmfcClassify(), rpmGetFilesystemUsage(), rpmProblemString(), rpmQueryVerify(), runScript(), ufdRead(), ufdWrite(), uncompressbuf(), unwrap(), and urlStrerror().
| #define STRING_COMPACT_BLANK BIT(0) |
Definition at line 241 of file file.h.
Referenced by file_mdump(), file_strncmp(), parse(), and string_modifier_check().
| #define STRING_COMPACT_OPTIONAL_BLANK BIT(1) |
Definition at line 242 of file file.h.
Referenced by file_mdump(), file_strncmp(), parse(), and string_modifier_check().
| #define STRING_IGNORE_CASE (STRING_IGNORE_LOWERCASE|STRING_IGNORE_UPPERCASE) |
| #define STRING_IGNORE_LOWERCASE BIT(2) |
| #define STRING_IGNORE_UPPERCASE BIT(3) |
| #define strtoul | ( | a, | |||
| b, | |||||
| c | ) | strtol(a, b, c) |
Definition at line 393 of file file.h.
Referenced by addCanon(), parse(), parseFormat(), parseNum(), rpmEVRparse(), rpmQueryVerify(), and strntoul().
| #define UNSIGNED 8 |
Definition at line 117 of file file.h.
Referenced by file_mdump(), file_signextend(), magiccheck(), and parse().
| #define VERSIONNO 4 |
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().
| int file_ascmagic | ( | struct magic_set * | ms, | |
| const unsigned char * | , | |||
| size_t | ||||
| ) |
Definition at line 83 of file ascmagic.c.
References ascmatch(), magic_set::flags, from_ebcdic(), ISSPC, looks_ascii(), looks_extended(), looks_latin1(), looks_unicode(), looks_utf8(), MAGIC_NO_CHECK_FORTRAN, MAGIC_NO_CHECK_TOKENS, MAGIC_NO_CHECK_TROFF, names::name, NNAMES, names::type, and types.
Referenced by file_buffer().
| void file_badread | ( | struct magic_set * | ms | ) |
Definition at line 150 of file funcs.c.
References errno, and file_error().
Referenced by apprentice_map().