#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 [] |
|
|
|
|
|
Definition at line 246 of file file.h. Referenced by file_mdump(), parse(), and string_modifier_check(). |
|
Definition at line 247 of file file.h. Referenced by file_mdump(), parse(), and string_modifier_check(). |
|
Definition at line 248 of file file.h. Referenced by file_mdump(), and parse(). |
|
Definition at line 249 of file file.h. Referenced by file_mdump(), and parse(). |
|
Definition at line 250 of file file.h. Referenced by file_mdump(), parse(), and string_modifier_check(). |
|
Definition at line 203 of file file.h. Referenced by check_cond(), get_cond(), and match(). |
|
Definition at line 204 of file file.h. Referenced by check_cond(), get_cond(), and match(). |
|
Definition at line 202 of file file.h. Referenced by check_cond(), and get_cond(). |
|
Definition at line 201 of file file.h. Referenced by check_cond(), file_check_mem(), and get_cond(). |
|
|
|
|
|
Definition at line 133 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint(). |
|
Definition at line 139 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint(). |
|
Definition at line 132 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse(). |
|
Definition at line 153 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint(). |
|
Definition at line 156 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint(). |
|
Definition at line 150 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint(). |
|
Definition at line 131 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse(). |
|
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(). |
|
Definition at line 125 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse(). |
|
Definition at line 106 of file file.h. Referenced by apprentice_file(), magic_check(), main(), and parse(). |
|
Definition at line 107 of file file.h. Referenced by apprentice_1(), getstr(), magic_compile(), and main(). |
|
Definition at line 130 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint(). |
|
Definition at line 127 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), match(), mconvert(), mget(), and mprint(). |
|
Definition at line 168 of file file.h. Referenced by check_format(). |
|
Definition at line 169 of file file.h. Referenced by check_format_type(). |
|
Definition at line 171 of file file.h. Referenced by check_format_type(). |
|
Definition at line 170 of file file.h. Referenced by check_format_type(). |
|
Definition at line 124 of file file.h. Referenced by parse(). |
|
Definition at line 138 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint(). |
|
Definition at line 136 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint(). |
|
Definition at line 140 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint(). |
|
Definition at line 135 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse(). |
|
Definition at line 152 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint(). |
|
Definition at line 155 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint(). |
|
Definition at line 149 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint(). |
|
Definition at line 134 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse(). |
|
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(). |
|
Definition at line 105 of file file.h. Referenced by magic_load(). |
|
Definition at line 128 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse(). |
|
Definition at line 103 of file file.h. Referenced by apprentice_1(). |
|
Definition at line 145 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint(). |
|
Definition at line 146 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint(). |
|
Definition at line 147 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), mprint(), and parse(). |
|
Definition at line 157 of file file.h. Referenced by init_file_tables(). |
|
|
|
|
|
|
|
|
|
Definition at line 197 of file file.h. Referenced by file_mdump(), mget(), and parse(). |
|
|
|
|
|
|
|
|
|
Definition at line 184 of file file.h. Referenced by file_mdump(). |
|
Definition at line 193 of file file.h. Referenced by file_mdump(), and mget(). |
|
|
|
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(). |
|
Definition at line 151 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint(). |
|
Definition at line 154 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint(). |
|
Definition at line 148 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), and mprint(). |
|
Value: |
|
Definition at line 141 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), getvalue(), mconvert(), mcopy(), mget(), mprint(), and string_modifier_check(). |
|
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(). |
|
Definition at line 126 of file file.h. Referenced by apprentice_magic_strength(), file_mdump(), file_signextend(), magiccheck(), mconvert(), mget(), and mprint(). |
|
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(). |
|
|
|
|
|
|
|
Definition at line 95 of file file.h. Referenced by magic_file(), and uncompressbuf(). |
|
Definition at line 114 of file file.h. Referenced by file_mdump(), mget(), and parse(). |
|
|
|
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(). |
|
Definition at line 57 of file file.h. Referenced by file_apprentice(). |
|
Definition at line 101 of file file.h. Referenced by apprentice_map(). |
|
|
|
Definition at line 97 of file file.h. Referenced by apprentice_file(). |
|
|
|
Definition at line 91 of file file.h. Referenced by magiccheck(). |
|
|
|
Definition at line 404 of file file.h. Referenced by apprentice_compile(), apprentice_map(), and magic_file(). |
|
|
|
Definition at line 63 of file file.h. Referenced by file_apprentice(). |
|
|
|
|
|
Definition at line 245 of file file.h. Referenced by file_mdump(), mprint(), parse(), and string_modifier_check(). |
|
|
|
|
|
Definition at line 386 of file file.h. Referenced by checkOwners(), checkPassPhrase(), cpioStrerror(), dbiOpen(), doScript(), fdFgets(), fdWritable(), file_error_core(), file_fsmagic(), Fstrerror(), getFdErrstr(), getFilesystemList(), getOutputFrom(), load(), lzdClose(), lzdWrite(), main(), makeGPGSignature(), makePGPSignature(), packageBinaries(), prepFetch(), processSourceFiles(), rpmdbRebuild(), rpmfcClassify(), rpmProblemString(), rpmQueryVerify(), uncompressbuf(), unwrap(), and urlStrerror(). |
|
Definition at line 241 of file file.h. Referenced by file_mdump(), file_strncmp(), parse(), and string_modifier_check(). |
|
Definition at line 242 of file file.h. Referenced by file_mdump(), file_strncmp(), parse(), and string_modifier_check(). |
|
|
|
Definition at line 243 of file file.h. Referenced by file_mdump(), file_strncmp(), and parse(). |
|
Definition at line 244 of file file.h. Referenced by file_mdump(), file_strncmp(), and parse(). |
|
Definition at line 391 of file file.h. Referenced by addCanon(), parse(), parseFormat(), parseNum(), rpmEVRparse(), rpmQueryVerify(), and strntoul(). |
|
Definition at line 117 of file file.h. Referenced by file_mdump(), file_signextend(), and parse(). |
|
Definition at line 102 of file file.h. Referenced by apprentice_map(). |
|
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 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(). |
|
Definition at line 159 of file funcs.c. References errno, and file_error(). Referenced by apprentice_map(). |
|
Definition at line 153 of file funcs.c. References errno, and file_error(). Referenced by file_pipe2file(). |
|
Definition at line 166 of file funcs.c. References file_ascmagic(), file_is_tar(), file_printf(), file_softmagic(), file_tryelf(), file_zmagic(), magic_set::flags, MAGIC_MIME, MAGIC_NO_CHECK_APPTYPE, MAGIC_NO_CHECK_ASCII, MAGIC_NO_CHECK_COMPRESS, MAGIC_NO_CHECK_ELF, MAGIC_NO_CHECK_SOFT, and MAGIC_NO_CHECK_TAR. Referenced by file_zmagic(), magic_buffer(), and magic_file(). |
|
Definition at line 326 of file funcs.c. References magic_set::c, COND_NONE, file_oomem(), magic_set::cont::level_info::got_match, magic_set::cont::level_info::last_cond, magic_set::cont::level_info::last_match, magic_set::cont::len, and magic_set::cont::li. |
|
Definition at line 336 of file apprentice.c. Referenced by apprentice_1(), and free_mlist(). |
|
Definition at line 125 of file funcs.c. References file_error_core(). Referenced by apprentice_1(), apprentice_compile(), apprentice_file(), apprentice_map(), check_format(), file_apprentice(), file_badread(), file_badseek(), file_fsmagic(), file_oomem(), file_pipe2file(), file_reset(), getstr(), magic_file(), parse(), rcsid(), and uncompressbuf(). |
|
Definition at line 190 of file print.c. Referenced by file_mdump(), and mprint(). |
|
Definition at line 64 of file fsmagic.c. References errno, file_error(), file_printf(), magic_set::flags, magic_set::haderr, MAGIC_DEVICES, MAGIC_ERROR, magic_file(), MAGIC_MIME, MAGIC_SYMLINK, major, minor, S_IFSOCK, and strerror. Referenced by magic_file(). |
|
Definition at line 248 of file funcs.c. References magic_set::out::buf, file_oomem(), magic_set::flags, magic_set::haderr, magic_set::out::left, MAGIC_RAW, magic_set::o, OCTALIFY, magic_set::out::pbuf, magic_set::out::psize, magic_set::out::size, and SIZE_T_MAX. Referenced by magic_buffer(), and magic_file(). |
|
Definition at line 59 of file is_tar.c. References file_printf(), is_tar(), and MAGIC_MIME. Referenced by file_buffer(). |
|
Definition at line 138 of file funcs.c. References file_error_core(), and magic_set::line. Referenced by check_fmt(), mconvert(), mcopy(), and mprint(). |
|
Definition at line 174 of file print.c. References magic_set::file, and magic_set::line. Referenced by apprentice_1(), check_cond(), file_signextend(), getstr(), getvalue(), parse(), and string_modifier_check(). |
|
|
|
|
Definition at line 147 of file funcs.c. References errno, and file_error(). Referenced by apprentice_1(), apprentice_file(), apprentice_map(), file_apprentice(), file_check_mem(), file_getbuffer(), file_printf(), mprint(), and parse(). |
|
Definition at line 236 of file compress.c. References errno, file_badseek(), file_error(), SEEK_SET, sread(), and swrite(). |
|
Definition at line 63 of file funcs.c. References magic_set::out::buf, file_oomem(), magic_set::out::left, magic_set::o, magic_set::out::ptr, magic_set::out::size, and vsnprintf(). Referenced by file_buffer(), file_fsmagic(), file_is_tar(), file_zmagic(), info_from_stat(), magic_file(), match(), mprint(), print_sep(), and rcsid(). |
|
Definition at line 226 of file funcs.c. References magic_set::out::buf, magic_set::error, file_error(), magic_set::haderr, magic_set::out::left, magic_set::mlist, magic_set::o, magic_set::out::ptr, and magic_set::out::size. Referenced by magic_buffer(), and magic_file(). |
|
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 83 of file softmagic.c. References mlist::magic, match(), magic_set::mlist, mlist::next, and mlist::nmagic. Referenced by file_buffer(). |
|
Referenced by file_buffer(). |
|
Definition at line 106 of file compress.c. References file_buffer(), file_printf(), magic_set::flags, MAGIC_COMPRESS, maglen, NODATA, and uncompressbuf(). Referenced by file_buffer(). |
|
Definition at line 361 of file funcs.c. Referenced by file_error_core(), headerCheck(), mkdbname(), mprint(), pgpsigFormat(), rpmfcHelper(), rpmProblemString(), rpmpsmStage(), rpmReadHeader(), rpmReadSignature(), xmlFormat(), and yamlFormat(). |
|
Definition at line 172 of file compress.c. References check, errno, and STDIN_FILENO. Referenced by file_pipe2file(), magic_file(), and uncompressbuf(). |
|
Definition at line 89 of file apprentice.c. Referenced by file_mdump(). |
|
Definition at line 91 of file apprentice.c. Referenced by file_mdump(). |
|
|
|
|