41 #if __UNIX__ && !defined(_MSC_VER)
44 #include <sys/param.h>
52 #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
53 #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
54 #define MAXPATHLEN 255
59 while (isascii((ut8)*l) && isspace((ut8)*l)) { \
63 #define LOWCASE(l) (isupper((ut8)(l)) ? tolower((ut8)(l)) : (l))
80 static int getvalue(RzMagic *ms,
struct rz_magic *,
const char **,
int);
82 static const char *
getstr(RzMagic *,
const char *,
char *,
int,
int *,
int);
85 static void eatsize(
const char **);
86 static int apprentice_1(RzMagic *,
const char *,
int,
struct mlist *);
91 static void bs1(
struct rz_magic *);
95 static char *
mkdbname(
const char *,
int);
105 static const char usg_hdr[] =
"cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
115 #define XX(s) s, (sizeof(s) - 1)
116 #define XX_NULL "", 0
117 {
XX(
"byte"), FILE_BYTE, FILE_FMT_NUM },
118 {
XX(
"short"), FILE_SHORT, FILE_FMT_NUM },
119 {
XX(
"default"), FILE_DEFAULT, FILE_FMT_STR },
120 {
XX(
"long"), FILE_LONG, FILE_FMT_NUM },
121 {
XX(
"string"), FILE_STRING, FILE_FMT_STR },
122 {
XX(
"date"), FILE_DATE, FILE_FMT_STR },
123 {
XX(
"beshort"), FILE_BESHORT, FILE_FMT_NUM },
124 {
XX(
"belong"), FILE_BELONG, FILE_FMT_NUM },
125 {
XX(
"bedate"), FILE_BEDATE, FILE_FMT_STR },
126 {
XX(
"leshort"), FILE_LESHORT, FILE_FMT_NUM },
127 {
XX(
"lelong"), FILE_LELONG, FILE_FMT_NUM },
128 {
XX(
"ledate"), FILE_LEDATE, FILE_FMT_STR },
129 {
XX(
"pstring"), FILE_PSTRING, FILE_FMT_STR },
130 {
XX(
"ldate"), FILE_LDATE, FILE_FMT_STR },
131 {
XX(
"beldate"), FILE_BELDATE, FILE_FMT_STR },
132 {
XX(
"leldate"), FILE_LELDATE, FILE_FMT_STR },
133 {
XX(
"regex"), FILE_REGEX, FILE_FMT_STR },
134 {
XX(
"bestring16"), FILE_BESTRING16, FILE_FMT_STR },
135 {
XX(
"lestring16"), FILE_LESTRING16, FILE_FMT_STR },
136 {
XX(
"search"), FILE_SEARCH, FILE_FMT_STR },
137 {
XX(
"medate"), FILE_MEDATE, FILE_FMT_STR },
138 {
XX(
"meldate"), FILE_MELDATE, FILE_FMT_STR },
139 {
XX(
"melong"), FILE_MELONG, FILE_FMT_NUM },
140 {
XX(
"quad"), FILE_QUAD, FILE_FMT_QUAD },
141 {
XX(
"lequad"), FILE_LEQUAD, FILE_FMT_QUAD },
142 {
XX(
"bequad"), FILE_BEQUAD, FILE_FMT_QUAD },
143 {
XX(
"qdate"), FILE_QDATE, FILE_FMT_STR },
144 {
XX(
"leqdate"), FILE_LEQDATE, FILE_FMT_STR },
145 {
XX(
"beqdate"), FILE_BEQDATE, FILE_FMT_STR },
146 {
XX(
"qldate"), FILE_QLDATE, FILE_FMT_STR },
147 {
XX(
"leqldate"), FILE_LEQLDATE, FILE_FMT_STR },
148 {
XX(
"beqldate"), FILE_BEQLDATE, FILE_FMT_STR },
149 {
XX(
"float"), FILE_FLOAT, FILE_FMT_FLOAT },
150 {
XX(
"befloat"), FILE_BEFLOAT, FILE_FMT_FLOAT },
151 {
XX(
"lefloat"), FILE_LEFLOAT, FILE_FMT_FLOAT },
152 {
XX(
"double"), FILE_DOUBLE, FILE_FMT_DOUBLE },
153 {
XX(
"bedouble"), FILE_BEDOUBLE, FILE_FMT_DOUBLE },
154 {
XX(
"ledouble"), FILE_LEDOUBLE, FILE_FMT_DOUBLE },
155 {
XX_NULL, FILE_INVALID, FILE_FMT_NONE },
160 static int get_type(
const char *l,
const char **t) {
164 if (strncmp(l,
p->name,
p->len) == 0) {
175 static bool done =
false;
182 if (
p->type >= FILE_NAMES_SIZE) {
194 struct rz_magic *magic =
NULL;
205 file_error(ms, 0,
"magic element size %lu != %lu",
206 (
unsigned long)(
size_t)
sizeof(*magic),
207 (
unsigned long)FILE_MAGICSIZE);
212 if (
action == FILE_COMPILE) {
238 if (!(ml =
malloc(
sizeof(*ml)))) {
248 mlist->prev->next = ml;
249 ml->prev = mlist->prev;
279 int file_err, errs = -1;
293 if (!(mlist =
malloc(
sizeof(*mlist)))) {
298 mlist->next = mlist->prev = mlist;
301 p = strchr(
fn, PATHSEP);
309 errs =
RZ_MAX(errs, file_err);
315 file_error(ms, 0,
"could not find any magic files!");
350 case FILE_BESTRING16:
351 case FILE_LESTRING16:
407 eprintf(
"Bad relation %c\n",
m->reln);
465 case FILE_BESTRING16:
466 case FILE_LESTRING16:
468 mstart->flag |= BINTEST;
474 mstart->flag |= BINTEST;
491 static const char *
bgets(
char *
line,
size_t line_sz,
const char *data) {
495 const char *nl = strchr(data,
'\n');
498 :
RZ_MIN(line_sz, strlen(data));
510 for (ms->line = 1; (data =
bgets(
line,
sizeof(
line), data)) !=
NULL; ms->line++) {
519 if (
line[0] ==
'\0') {
522 if (
line[0] ==
'#') {
558 for (ms->line = 1; fgets(
line,
sizeof(
line),
f) !=
NULL; ms->line++) {
567 if (
line[0] ==
'\0') {
570 if (
line[0] ==
'#') {
594 ut32 marraycount,
i, mentrycount = 0, starttest;
600 WIN32_FIND_DATAW
entry;
601 wchar_t dir[MAX_PATH];
608 char subfn[MAXPATHLEN];
610 ms->flags |= RZ_MAGIC_CHECK;
620 if (
action == FILE_CHECK) {
626 #if __WINDOWS__ && !defined(__CYGWIN__)
627 if ((wcpath = rz_utf8_to_utf16(
fn))) {
628 swprintf(dir, _countof(dir),
L"%ls\\*.*", wcpath);
629 hdir = FindFirstFileW(dir, &
entry);
632 if (wcsncmp(
entry.cFileName,
L".", 1) == 0)
634 if ((cfname = rz_utf16_to_utf8(
entry.cFileName))) {
635 snprintf(subfn,
sizeof(subfn),
"%s/%s",
fn, cfname);
636 if (
stat(subfn, &st) == 0 &&
S_ISREG(st.st_mode)) {
637 load_1(ms,
action, subfn, &errs, &marray, &marraycount);
641 }
while (FindNextFileW(hdir, &
entry));
652 if (*
d->d_name ==
'.') {
655 snprintf(subfn,
sizeof(subfn),
"%s/%s",
fn,
d->d_name);
656 if (
stat(subfn, &st) == 0 &&
S_ISREG(st.st_mode)) {
657 load_1(ms,
action, subfn, &errs, &marray, &marraycount);
674 for (
i = 0;
i < marraycount;) {
675 if (marray[
i].mp->cont_level != 0) {
683 if (ms->flags & RZ_MAGIC_DEBUG) {
684 (void)fprintf(stderr,
"%s%s%s: %s\n",
685 marray[
i].mp->mimetype,
686 marray[
i].
mp->mimetype[0] ==
'\0' ?
"" :
"; ",
687 marray[
i].
mp->desc[0] ? marray[
i].
mp->desc :
"(no description)",
688 marray[
i].
mp->flag & BINTEST ?
"binary" :
"text");
689 if (marray[
i].mp->flag & BINTEST) {
691 char *
p = strstr(marray[
i].mp->desc,
"text");
692 if (
p && (
p == marray[
i].mp->desc ||
isspace((
unsigned char)
p[-1])) &&
693 (
p +
SYMLEN - marray[
i].mp->desc == MAXstring ||
695 (void)fprintf(stderr,
696 "*** Possible binary test for text type\n");
700 }
while (++
i < marraycount && marray[
i].mp->cont_level != 0);
708 for (
i = 0;
i < marraycount;
i++) {
709 if (marray[
i].mp->cont_level == 0 &&
710 marray[
i].
mp->type == FILE_DEFAULT) {
711 while (++
i < marraycount) {
712 if (marray[
i].mp->cont_level == 0) {
716 if (
i != marraycount) {
717 ms->line = marray[
i].
mp->lineno;
718 file_magwarn(ms,
"level 0 \"default\" did not sort last");
724 for (
i = 0;
i < marraycount;
i++) {
728 if (!(*magicp =
malloc(1 + (
sizeof(**magicp) * mentrycount)))) {
729 file_oomem(ms,
sizeof(**magicp) * mentrycount);
735 for (
i = 0;
i < marraycount;
i++) {
736 (void)
memcpy(*magicp + mentrycount, marray[
i].mp,
737 marray[
i].cont_count *
sizeof(**magicp));
741 for (
i = 0;
i < marraycount;
i++) {
750 *nmagicp = mentrycount;
806 case FILE_BESTRING16:
807 case FILE_LESTRING16:
813 if (ms->flags & RZ_MAGIC_CHECK) {
824 if ((ms->flags & RZ_MAGIC_CHECK) == 0) {
829 case FILE_BESTRING16:
830 case FILE_LESTRING16:
831 if (
m->str_flags != 0) {
833 "no modifiers allowed for 16-bit strings\n");
839 if ((
m->str_flags & REGEX_OFFSET_START) != 0) {
841 "'/%c' only allowed on regex and search\n",
842 CHAR_REGEX_OFFSET_START);
847 if (
m->str_range == 0) {
849 "missing range; defaulting to %d\n",
850 STRING_DEFAULT_RANGE);
851 m->str_range = STRING_DEFAULT_RANGE;
856 if ((
m->str_flags & STRING_COMPACT_BLANK) != 0) {
861 if ((
m->str_flags & STRING_COMPACT_OPTIONAL_BLANK) != 0) {
863 CHAR_COMPACT_OPTIONAL_BLANK);
877 case '&':
return FILE_OPAND;
878 case '|':
return FILE_OPOR;
879 case '^':
return FILE_OPXOR;
880 case '+':
return FILE_OPADD;
881 case '-':
return FILE_OPMINUS;
882 case '*':
return FILE_OPMULTIPLY;
883 case '/':
return FILE_OPDIVIDE;
884 case '%':
return FILE_OPMODULO;
889 static int get_cond(
const char *l,
const char **t) {
890 const struct cond_tbl_s *
p;
891 static const struct cond_tbl_s {
896 {
"if", 2, COND_IF },
897 {
"elif", 4, COND_ELIF },
898 {
"else", 4, COND_ELSE },
899 {
"", 0, COND_NONE },
902 for (
p = cond_tbl;
p->len;
p++) {
903 if (strncmp(l,
p->name,
p->len) == 0 &&
916 last_cond = ms->c.li[cont_level].last_cond;
920 if (last_cond != COND_NONE && last_cond != COND_ELIF) {
921 if (ms->flags & RZ_MAGIC_CHECK) {
929 if (last_cond != COND_IF && last_cond != COND_ELIF) {
930 if (ms->flags & RZ_MAGIC_CHECK) {
935 last_cond = COND_ELIF;
938 if (last_cond != COND_IF && last_cond != COND_ELIF) {
939 if (ms->flags & RZ_MAGIC_CHECK) {
944 last_cond = COND_NONE;
947 last_cond = COND_NONE;
951 ms->c.li[cont_level].last_cond = last_cond;
959 static ut32 last_cont_level = 0;
963 const char *l =
line;
968 for (; *l ==
'>'; l++, cont_level++) {
971 if (cont_level == 0 || cont_level > last_cont_level) {
976 last_cont_level = cont_level;
977 #define ALLOC_CHUNK (size_t)10
978 #define ALLOC_INCR (size_t)200
979 if (cont_level != 0) {
980 if (*nmentryp == 0) {
981 file_error(ms, 0,
"No current entry for continuation");
984 me = &(*mentryp)[*nmentryp - 1];
988 if (!(nm =
realloc(me->
mp,
sizeof(*nm) * cnt))) {
997 m->cont_level = cont_level;
1010 me = &(*mentryp)[*nmentryp];
1034 if (
m->flag & OFFADD) {
1035 m->flag = (
m->flag & ~OFFADD) | INDIROFFADD;
1044 if (
m->cont_level == 0 && (
m->flag & (OFFADD | INDIROFFADD))) {
1045 if (ms->flags & RZ_MAGIC_CHECK) {
1051 m->offset = (
ut32)strtoul(l, &t, 0);
1052 if ((l == t) && (ms->flags & RZ_MAGIC_CHECK)) {
1057 if (
m->flag & INDIR) {
1058 m->in_type = FILE_LONG;
1067 m->in_type = FILE_LELONG;
1070 m->in_type = FILE_BELONG;
1073 m->in_type = FILE_MELONG;
1077 m->in_type = FILE_LESHORT;
1081 m->in_type = FILE_BESHORT;
1087 m->in_type = FILE_BYTE;
1092 m->in_type = FILE_LEDOUBLE;
1097 m->in_type = FILE_BEDOUBLE;
1100 if (ms->flags & RZ_MAGIC_CHECK) {
1102 "indirect offset type `%c' invalid",
1112 m->in_op |= FILE_OPINVERSE;
1120 m->in_op |= FILE_OPINDIRECT;
1124 m->in_offset = (
int32_t)strtol(l, &t, 0);
1126 if (ms->flags & RZ_MAGIC_CHECK) {
1128 "in_offset `%s' invalid", l);
1134 ((
m->in_op & FILE_OPINDIRECT) && *l++ !=
')')) {
1135 if (ms->flags & RZ_MAGIC_CHECK) {
1137 "missing ')' in indirect offset");
1155 if (
m->type == FILE_INVALID) {
1156 if (ms->flags & RZ_MAGIC_CHECK) {
1167 if (!MAGIC_IS_STRING(
m->type)) {
1168 m->mask_op |= FILE_OPINVERSE;
1169 }
else if (ms->flags & RZ_MAGIC_CHECK) {
1178 if (!MAGIC_IS_STRING(
m->type)) {
1182 val = (
ut64)strtoull(l, &t, 0);
1186 }
else if (
op == FILE_OPDIVIDE) {
1201 (ms->flags & RZ_MAGIC_CHECK)) {
1206 m->str_range = strtoul(l, &t, 0);
1207 if (
m->str_range == 0) {
1213 case CHAR_COMPACT_BLANK:
1214 m->str_flags |= STRING_COMPACT_BLANK;
1216 case CHAR_COMPACT_OPTIONAL_BLANK:
1218 STRING_COMPACT_OPTIONAL_BLANK;
1220 case CHAR_IGNORE_LOWERCASE:
1221 m->str_flags |= STRING_IGNORE_LOWERCASE;
1223 case CHAR_IGNORE_UPPERCASE:
1224 m->str_flags |= STRING_IGNORE_UPPERCASE;
1226 case CHAR_REGEX_OFFSET_START:
1227 m->str_flags |= REGEX_OFFSET_START;
1230 if (ms->flags & RZ_MAGIC_CHECK) {
1232 "string extension `%c' invalid",
1246 if (ms->flags & RZ_MAGIC_CHECK) {
1278 if (*l ==
'x' && ((isascii((
ut8)l[1]) &&
isspace((
ut8)l[1])) || !l[1])) {
1304 }
else if ((l[0] ==
'\\') && (l[1] ==
'b')) {
1309 for (
i = 0; (
m->desc[
i++] = *l++) !=
'\0' &&
i <
sizeof(
m->desc);) {
1311 if (
i ==
sizeof(
m->desc)) {
1312 m->desc[
sizeof(
m->desc) - 1] =
'\0';
1313 if (ms->flags & RZ_MAGIC_CHECK) {
1322 if (ms->flags & RZ_MAGIC_CHECK) {
1327 if (
action == FILE_CHECK) {
1330 m->mimetype[0] =
'\0';
1331 if (
m->cont_level == 0) {
1343 const char *l =
line;
1347 if (*nmentryp == 0) {
1348 file_error(ms, 0,
"No current entry for MIME type");
1352 me = &(*mentryp)[*nmentryp - 1];
1355 if (
m->mimetype[0] !=
'\0') {
1356 file_error(ms, 0,
"Current entry already has a MIME type: %s\n"
1357 "Description: %s\nNew type: %s",
1358 m->mimetype,
m->desc, l);
1364 *l && ((isascii((
ut8)*l) &&
isalnum((
ut8)*l)) || strchr(
"-+/.", *l)) &&
i <
sizeof(
m->mimetype);
1365 m->mimetype[
i++] = *l++) {
1367 if (
i ==
sizeof(
m->mimetype)) {
1368 m->desc[
sizeof(
m->mimetype) - 1] =
'\0';
1369 if (ms->flags & RZ_MAGIC_CHECK) {
1374 m->mimetype[
i] =
'\0';
1377 return (
i > 0) ? 0 : -1;
1408 if (*ptr++ !=
'l') {
1411 if (*ptr++ !=
'l') {
1455 case FILE_FMT_FLOAT:
1456 case FILE_FMT_DOUBLE:
1499 if (*ptr++ ==
's') {
1518 for (ptr =
m->desc; *ptr; ptr++) {
1533 file_magwarn(ms,
"Internal error inconsistency between "
1534 "m->type and format strings");
1538 file_magwarn(ms,
"No format string for `%s' with description "
1550 file_magwarn(ms,
"Printf format `%c' is not valid for type "
1551 "`%s' in description `%s'",
1552 ptr && *ptr ? *ptr :
'?',
1557 for (; *ptr; ptr++) {
1560 "Too many format strings (should have at most one) "
1561 "for `%s' with description `%s'",
1578 case FILE_BESTRING16:
1579 case FILE_LESTRING16:
1586 if (ms->flags & RZ_MAGIC_CHECK) {
1593 if (
m->type == FILE_PSTRING) {
1600 if (
m->reln !=
'x') {
1603 m->value.f = strtof(*
p, &ep);
1605 m->value.f = (
float)strtod(*
p, &ep);
1613 if (
m->reln !=
'x') {
1615 m->value.d = strtod(*
p, &ep);
1620 if (
m->reln !=
'x') {
1623 (
ut64)strtoull(*
p, &ep, 0));
1637 static const char *
getstr(RzMagic *ms,
const char *
s,
char *
p,
int plen,
int *slen,
int action) {
1638 const char *origs =
s;
1640 char *pmax =
p + plen - 1;
1643 while ((
c = *
s++) !=
'\0') {
1648 file_error(ms, 0,
"string too long: `%s'", origs);
1652 switch ((
c = *
s++)) {
1654 if (
action == FILE_COMPILE) {
1659 if (
action == FILE_COMPILE) {
1661 "escaped tab found, use \\t instead");
1666 if (
action == FILE_COMPILE) {
1669 "no need to escape `%c'",
c);
1672 "unknown escape sequence: \\%03o",
c);
1698 case 'a': *
p++ =
'\a';
break;
1699 case 'b': *
p++ =
'\b';
break;
1700 case 'f': *
p++ =
'\f';
break;
1701 case 'n': *
p++ =
'\n';
break;
1702 case 'r': *
p++ =
'\r';
break;
1703 case 't': *
p++ =
'\t';
break;
1704 case 'v': *
p++ =
'\v';
break;
1716 if (
c >=
'0' &&
c <=
'7') {
1719 if (
c >=
'0' &&
c <=
'7') {
1760 if (!isascii((
ut8)
c)) {
1766 if ((
c >=
'a') && (
c <=
'f')) {
1767 return c + 10 -
'a';
1769 if ((
c >=
'A') && (
c <=
'F')) {
1770 return c + 10 -
'A';
1790 if (
c >= 040 &&
c <= 0176) {
1795 case '\a': fputc(
'a', fp);
break;
1796 case '\b': fputc(
'b', fp);
break;
1797 case '\f': fputc(
'f', fp);
break;
1798 case '\n': fputc(
'n', fp);
break;
1799 case '\r': fputc(
'r', fp);
break;
1800 case '\t': fputc(
't', fp);
break;
1801 case '\v': fputc(
'v', fp);
break;
1802 default: fprintf(fp,
"%.3o",
c & 0377);
break;
1842 char *dbname =
NULL;
1855 file_error(ms, errno,
"cannot stat `%s'", dbname);
1858 if (st.st_size < 8) {
1859 file_error(ms, 0,
"file `%s' is too small", dbname);
1866 file_error(ms, errno,
"cannot map `%s'", dbname);
1871 if (!(mm =
malloc((
size_t)st.st_size))) {
1875 if (
read(
fd, mm, (
size_t)st.st_size) != (
size_t)st.st_size) {
1884 ptr = (
ut32 *)(
void *)*magicp;
1886 if (*ptr != MAGICNO) {
1887 if (
swap4(*ptr) != MAGICNO) {
1889 file_error(ms, 0,
"bad magic in `%s'", dbname);
1899 file_error(ms, 0,
"File %d.%d supports only %d version magic "
1900 "files. `%s' is version %d",
1905 *nmagicp = (
ut32)(st.st_size /
sizeof(
struct rz_magic));
1910 if (needsbyteswap) {
1954 file_error(ms, errno,
"cannot open `%s'", dbname);
1959 file_error(ms, errno,
"error writing `%s'", dbname);
1964 file_error(ms, errno,
"error seeking `%s'", dbname);
1968 if (
write(
fd, *magicp, (
sizeof(
struct rz_magic) * *nmagicp)) != (
int)(
sizeof(
struct rz_magic) * *nmagicp)) {
1969 file_error(ms, errno,
"error writing `%s'", dbname);
1981 static const char ext[] =
".mgc";
1990 if ((
p = strrchr(
fn,
'/')) !=
NULL) {
1995 extlen = strlen(
ext);
1996 if (fnlen + extlen + 1 > MAXPATHLEN) {
2003 buf[fnlen + extlen] = 0;
2013 for (
i = 0;
i < nmagic;
i++) {
2076 static void bs1(
struct rz_magic *
m) {
2077 m->cont_level =
swap2(
m->cont_level);
2081 if (MAGIC_IS_STRING(
m->type)) {
2082 m->str_range =
swap4(
m->str_range);
2083 m->str_flags =
swap4(
m->str_flags);
2085 m->value.q =
swap8(
m->value.q);
2086 m->num_mask =
swap8(
m->num_mask);
static const size_t file_nnames
static int check_format(RzMagic *, struct rz_magic *)
static int check_cond(RzMagic *ms, int cond, ut32 cont_level)
void file_showstr(FILE *fp, const char *s, size_t len)
static int apprentice_sort(const void *, const void *)
static void load_1(RzMagic *ms, int action, const char *file, int *errs, struct rz_magic_entry **marray, ut32 *marraycount)
ut64 file_signextend(RzMagic *ms, struct rz_magic *m, ut64 v)
static const char mime_marker[]
static const char usg_hdr[]
static int apprentice_1(RzMagic *, const char *, int, struct mlist *)
static void eatsize(const char **)
static const size_t file_nformats
static void set_test_type(struct rz_magic *mstart, struct rz_magic *m)
static int apprentice_map(RzMagic *, struct rz_magic **, ut32 *, const char *)
static int get_cond(const char *l, const char **t)
static int get_type(const char *l, const char **t)
static int apprentice_compile(RzMagic *, struct rz_magic **, ut32 *, const char *)
static int getvalue(RzMagic *ms, struct rz_magic *, const char **, int)
static int apprentice_load(RzMagic *, struct rz_magic **, ut32 *, const char *, int)
static void byteswap(struct rz_magic *, ut32)
static const char * getstr(RzMagic *, const char *, char *, int, int *, int)
static void load_b(RzMagic *ms, int action, const char *data, int *errs, struct rz_magic_entry **marray, ut32 *marraycount)
static int magic_file_formats[FILE_NAMES_SIZE]
static void init_file_tables(void)
static const char * magic_file_names[FILE_NAMES_SIZE]
static const char * bgets(char *line, size_t line_sz, const char *data)
static int parse(RzMagic *, struct rz_magic_entry **, ut32 *, const char *, size_t, int)
struct mlist * file_apprentice(RzMagic *ms, const char *fn, int action)
static size_t apprentice_r_magic_strength(const struct rz_magic *)
static int string_modifier_check(RzMagic *ms, struct rz_magic *m)
void file_delmagic(struct rz_magic *p, int type, size_t entries)
static const struct type_tbl_s type_tbl[]
static int parse_mime(RzMagic *, struct rz_magic_entry **, ut32 *, const char *)
static void bs1(struct rz_magic *)
static int check_format_type(const char *, int)
static char * mkdbname(const char *, int)
static const size_t mime_marker_len
int file_looks_utf8(const ut8 *, size_t, unichar *, size_t *)
RzList * entries(RzBinFile *bf)
const lzma_allocator const uint8_t size_t uint8_t * out
static static fork const void static count close
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset fstat
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep lseek
void file_badread(struct rz_magic_set *)
void file_oomem(struct rz_magic_set *, size_t)
void file_error(struct rz_magic_set *, int, const char *,...)
void file_mdump(struct rz_magic *)
void file_magwarn(struct rz_magic_set *, const char *,...)
int file_check_mem(struct rz_magic_set *, unsigned int)
RZ_API void Ht_() free(HtName_(Ht) *ht)
#define INVALID_HANDLE_VALUE
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * realloc(void *ptr, size_t size)
void * malloc(size_t size)
void * calloc(size_t number, size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags mmap
static const char struct stat static buf struct stat static buf static idle const char static path static fd const char static len const void static prot const char struct module static image struct kernel_sym static table unsigned char static buf static fsuid unsigned struct dirent unsigned static count const struct iovec static count static pid const void static len static flags const struct sched_param static p static pid static policy struct timespec static tp static suid unsigned fn
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname unsigned long static filedes void static end_data_segment static handler static getegid char static len static pgid const char static path static newfd static getpgrp static euid const sigset_t static mask const char static len const gid_t static list const char const char static newpath const char static library readdir
static const void static count static fd struct stat static buf struct pollfd unsigned static timeout void static offset munmap
#define FILE_VERSION_MAJOR
void qsort(void *a, size_t n, size_t es, int(*cmp)(const void *, const void *))
RZ_API size_t rz_str_ncpy(char *dst, const char *src, size_t n)
Secure string copy with null terminator.
RZ_API int rz_sys_open(const char *path, int perm, int mode)
RZ_API FILE * rz_sys_fopen(const char *path, const char *mode)
#define cond(bop, top, mask, flags)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]
int read(izstream &zs, T *x, Items items)