Fix symbol conflict with libmagic

This commit is contained in:
meme 2024-02-20 17:17:52 +00:00 committed by pancake
parent 148614ebde
commit e3fa281635
9 changed files with 253 additions and 257 deletions

View File

@ -190,7 +190,7 @@ static int apprentice_1(RMagic *ms, const char *fn, int action, struct mlist *ml
}
ms->haderr = 0;
if (magicsize != FILE_MAGICSIZE) {
file_error (ms, 0, "magic element size %lu != %lu",
__magic_file_error (ms, 0, "magic element size %lu != %lu",
(unsigned long)(size_t)sizeof (*magic),
(unsigned long)FILE_MAGICSIZE);
return -1;
@ -209,7 +209,7 @@ static int apprentice_1(RMagic *ms, const char *fn, int action, struct mlist *ml
if ((rv = apprentice_map (ms, &magic, &nmagic, fn)) == -1) {
//if (ms->flags & R_MAGIC_CHECK)
// file_magwarn(ms, "using regular magic file `%s'", fn);
// __magic_file_magwarn(ms, "using regular magic file `%s'", fn);
rv = apprentice_load (ms, &magic, &nmagic, fn, action);
if (rv != 0) {
return -1;
@ -219,13 +219,13 @@ static int apprentice_1(RMagic *ms, const char *fn, int action, struct mlist *ml
mapped = rv;
if (!magic) {
file_delmagic (magic, mapped, nmagic);
__magic_file_delmagic (magic, mapped, nmagic);
return -1;
}
if (!(ml = malloc (sizeof (*ml)))) {
file_delmagic (magic, mapped, nmagic);
file_oomem (ms, sizeof (*ml));
__magic_file_delmagic (magic, mapped, nmagic);
__magic_file_oomem (ms, sizeof (*ml));
return -1;
}
@ -240,7 +240,7 @@ static int apprentice_1(RMagic *ms, const char *fn, int action, struct mlist *ml
return 0;
}
void file_delmagic(struct r_magic *p, int type, size_t entries) {
void __magic_file_delmagic(struct r_magic *p, int type, size_t entries) {
if (p) {
switch (type) {
#if QUICK
@ -262,7 +262,7 @@ void file_delmagic(struct r_magic *p, int type, size_t entries) {
}
/* const char *fn: list of magic files and directories */
struct mlist *file_apprentice(RMagic *ms, const char *fn, size_t fn_size, int action) {
struct mlist *__magic_file_apprentice(RMagic *ms, const char *fn, size_t fn_size, int action) {
char *p, *mfn;
int file_err, errs = -1;
struct mlist *mlist;
@ -272,14 +272,14 @@ struct mlist *file_apprentice(RMagic *ms, const char *fn, size_t fn_size, int ac
}
if (!(mfn = r_str_ndup (fn, fn_size))) {
file_oomem (ms, fn_size);
__magic_file_oomem (ms, fn_size);
return NULL;
}
fn = mfn;
if (!(mlist = malloc (sizeof (*mlist)))) {
free (mfn);
file_oomem (ms, sizeof (*mlist));
__magic_file_oomem (ms, sizeof (*mlist));
return NULL;
}
mlist->next = mlist->prev = mlist;
@ -299,7 +299,7 @@ struct mlist *file_apprentice(RMagic *ms, const char *fn, size_t fn_size, int ac
if (errs == -1) {
free (mfn);
R_FREE (mlist);
file_error (ms, 0, "could not find any magic files!");
__magic_file_error (ms, 0, "could not find any magic files!");
return NULL;
}
free (mfn);
@ -457,7 +457,7 @@ static void set_test_type(struct r_magic *mstart, struct r_magic *m) {
case FILE_REGEX:
case FILE_SEARCH:
/* binary test if pattern is not text */
if (file_looks_utf8 ((const ut8 *)m->value.s, m->vallen, NULL, NULL) == 0) {
if (__magic_file_looks_utf8 ((const ut8 *)m->value.s, m->vallen, NULL, NULL) == 0) {
mstart->flag |= BINTEST;
}
break;
@ -536,7 +536,7 @@ static void load_1(RMagic *ms, int action, const char *file, int *errs, struct r
FILE *f = r_sandbox_fopen (ms->file = file, "r");
if (!f) {
if (errno != ENOENT) {
file_error (ms, errno, "cannot read magic file `%s'", file);
__magic_file_error (ms, errno, "cannot read magic file `%s'", file);
}
(*errs)++;
return;
@ -597,7 +597,7 @@ static int apprentice_load(RMagic *ms, struct r_magic **magicp, ut32 *nmagicp, c
ms->flags |= R_MAGIC_CHECK; /* Enable checks for parsed files */
maxmagic = MAXMAGIS;
if (!(marray = calloc (maxmagic, sizeof (*marray)))) {
file_oomem (ms, maxmagic * sizeof (*marray));
__magic_file_oomem (ms, maxmagic * sizeof (*marray));
return -1;
}
marraycount = 0;
@ -706,7 +706,7 @@ static int apprentice_load(RMagic *ms, struct r_magic **magicp, ut32 *nmagicp, c
}
if (i != marraycount) {
ms->line = marray[i].mp->lineno; /* XXX - Ugh! */
file_magwarn (ms, "level 0 \"default\" did not sort last");
__magic_file_magwarn (ms, "level 0 \"default\" did not sort last");
}
break;
}
@ -717,7 +717,7 @@ static int apprentice_load(RMagic *ms, struct r_magic **magicp, ut32 *nmagicp, c
}
if (!(*magicp = malloc (1 + (sizeof (**magicp) * mentrycount)))) {
file_oomem (ms, sizeof (**magicp) * mentrycount);
__magic_file_oomem (ms, sizeof (**magicp) * mentrycount);
errs++;
goto out;
}
@ -745,7 +745,7 @@ out:
/*
* extend the sign bit if the comparison is to be signed
*/
ut64 file_signextend(RMagic *ms, struct r_magic *m, ut64 v) {
ut64 __magic_file_signextend(RMagic *ms, struct r_magic *m, ut64 v) {
if (!(m->flag & UNSIGNED)) {
switch (m->type) {
/*
@ -802,7 +802,7 @@ ut64 file_signextend(RMagic *ms, struct r_magic *m, ut64 v) {
break;
default:
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms, "cannot happen: m->type=%d\n",
__magic_file_magwarn (ms, "cannot happen: m->type=%d\n",
m->type);
}
return ~0U;
@ -820,7 +820,7 @@ static int string_modifier_check(RMagic *ms, struct r_magic *m) {
case FILE_BESTRING16:
case FILE_LESTRING16:
if (m->str_flags != 0) {
file_magwarn(ms,
__magic_file_magwarn(ms,
"no modifiers allowed for 16-bit strings\n");
return -1;
}
@ -828,7 +828,7 @@ static int string_modifier_check(RMagic *ms, struct r_magic *m) {
case FILE_STRING:
case FILE_PSTRING:
if ((m->str_flags & REGEX_OFFSET_START) != 0) {
file_magwarn(ms,
__magic_file_magwarn(ms,
"'/%c' only allowed on regex and search\n",
CHAR_REGEX_OFFSET_START);
return -1;
@ -836,7 +836,7 @@ static int string_modifier_check(RMagic *ms, struct r_magic *m) {
break;
case FILE_SEARCH:
if (m->str_range == 0) {
file_magwarn(ms,
__magic_file_magwarn(ms,
"missing range; defaulting to %d\n",
STRING_DEFAULT_RANGE);
m->str_range = STRING_DEFAULT_RANGE;
@ -845,18 +845,18 @@ static int string_modifier_check(RMagic *ms, struct r_magic *m) {
break;
case FILE_REGEX:
if ((m->str_flags & STRING_COMPACT_BLANK) != 0) {
file_magwarn(ms, "'/%c' not allowed on regex\n",
__magic_file_magwarn(ms, "'/%c' not allowed on regex\n",
CHAR_COMPACT_BLANK);
return -1;
}
if ((m->str_flags & STRING_COMPACT_OPTIONAL_BLANK) != 0) {
file_magwarn(ms, "'/%c' not allowed on regex\n",
__magic_file_magwarn(ms, "'/%c' not allowed on regex\n",
CHAR_COMPACT_OPTIONAL_BLANK);
return -1;
}
break;
default:
file_magwarn (ms, "coding error: m->type=%d\n",
__magic_file_magwarn (ms, "coding error: m->type=%d\n",
m->type);
return -1;
}
@ -910,7 +910,7 @@ static int check_cond(RMagic *ms, int cond, ut32 cont_level) {
case COND_IF:
if (last_cond != COND_NONE && last_cond != COND_ELIF) {
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms, "syntax error: `if'");
__magic_file_magwarn (ms, "syntax error: `if'");
}
return -1;
}
@ -919,7 +919,7 @@ static int check_cond(RMagic *ms, int cond, ut32 cont_level) {
case COND_ELIF:
if (last_cond != COND_IF && last_cond != COND_ELIF) {
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms, "syntax error: `elif'");
__magic_file_magwarn (ms, "syntax error: `elif'");
}
return -1;
}
@ -928,7 +928,7 @@ static int check_cond(RMagic *ms, int cond, ut32 cont_level) {
case COND_ELSE:
if (last_cond != COND_IF && last_cond != COND_ELIF) {
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms, "syntax error: `else'");
__magic_file_magwarn (ms, "syntax error: `else'");
}
return -1;
}
@ -959,7 +959,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
;
}
if (cont_level == 0 || cont_level > ms->last_cont_level) {
if (file_check_mem (ms, cont_level) == -1) {
if (__magic_file_check_mem (ms, cont_level) == -1) {
return -1;
}
}
@ -968,7 +968,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
#define ALLOC_INCR (size_t)200
if (cont_level != 0) {
if (*nmentryp == 0) {
file_error (ms, 0, "No current entry for continuation");
__magic_file_error (ms, 0, "No current entry for continuation");
return -1;
}
me = &(*mentryp)[*nmentryp - 1];
@ -976,7 +976,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
struct r_magic *nm;
size_t cnt = me->max_count + ALLOC_CHUNK;
if (!(nm = realloc(me->mp, sizeof (*nm) * cnt))) {
file_oomem(ms, sizeof (*nm) * cnt);
__magic_file_oomem(ms, sizeof (*nm) * cnt);
return -1;
}
me->mp = nm;
@ -991,7 +991,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
maxmagic += ALLOC_INCR;
if (!(mp = realloc (*mentryp, sizeof (*mp) * maxmagic))) {
file_oomem (ms, sizeof (*mp) * maxmagic);
__magic_file_oomem (ms, sizeof (*mp) * maxmagic);
return -1;
}
(void)memset(&mp[*nmentryp], 0, sizeof (*mp) * ALLOC_INCR);
@ -1000,7 +1000,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
me = &(*mentryp)[*nmentryp];
if (!me->mp) {
if (!(m = malloc (sizeof (*m) * ALLOC_CHUNK))) {
file_oomem (ms, sizeof (*m) * ALLOC_CHUNK);
__magic_file_oomem (ms, sizeof (*m) * ALLOC_CHUNK);
return -1;
}
me->mp = m;
@ -1033,14 +1033,14 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
/* Indirect offsets are not valid at level 0. */
if (m->cont_level == 0 && (m->flag & (OFFADD | INDIROFFADD))) {
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms, "relative offset at level 0");
__magic_file_magwarn (ms, "relative offset at level 0");
}
}
/* get offset, then skip over it */
m->offset = (ut32)strtoul(l, &t, 0);
if ((l == t) && (ms->flags & R_MAGIC_CHECK)) {
file_magwarn (ms, "offset `%s' invalid", l);
__magic_file_magwarn (ms, "offset `%s' invalid", l);
}
l = t;
@ -1088,7 +1088,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
break;
default:
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms,
__magic_file_magwarn (ms,
"indirect offset type `%c' invalid",
*l);
}
@ -1114,7 +1114,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
m->in_offset = (int32_t)strtol(l, &t, 0);
if (l == t) {
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms,
__magic_file_magwarn (ms,
"in_offset `%s' invalid", l);
}
}
@ -1123,7 +1123,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
if (*l++ != ')' ||
((m->in_op & FILE_OPINDIRECT) && *l++ != ')')) {
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms,
__magic_file_magwarn (ms,
"missing ')' in indirect offset");
}
}
@ -1144,7 +1144,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
m->type = get_type(l, &l);
if (m->type == FILE_INVALID) {
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms, "type `%s' invalid", l);
__magic_file_magwarn (ms, "type `%s' invalid", l);
}
return -1;
}
@ -1157,7 +1157,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
if (!MAGIC_IS_STRING (m->type)) {
m->mask_op |= FILE_OPINVERSE;
} else if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms, "'~' invalid for string types");
__magic_file_magwarn (ms, "'~' invalid for string types");
}
l++;
}
@ -1171,7 +1171,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
m->mask_op |= op;
val = (ut64)strtoull (l, &t, 0);
l = t;
m->num_mask = file_signextend (ms, m, val);
m->num_mask = __magic_file_signextend (ms, m, val);
eatsize (&l);
} else if (op == FILE_OPDIVIDE) {
int have_range = 0;
@ -1183,13 +1183,13 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
case '9':
if (have_range &&
(ms->flags & R_MAGIC_CHECK)) {
file_magwarn (ms,
__magic_file_magwarn (ms,
"multiple ranges");
}
have_range = 1;
m->str_range = strtoul(l, &t, 0);
if (m->str_range == 0) {
file_magwarn (ms,
__magic_file_magwarn (ms,
"zero range");
}
l = t - 1;
@ -1212,7 +1212,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
break;
default:
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms,
__magic_file_magwarn (ms,
"string extension `%c' invalid",
*l);
}
@ -1228,7 +1228,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
}
} else {
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms, "invalid string op: %c", *t);
__magic_file_magwarn (ms, "invalid string op: %c", *t);
}
return -1;
}
@ -1295,7 +1295,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
if (i == sizeof (m->desc)) {
m->desc[sizeof (m->desc) - 1] = '\0';
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms, "description `%s' truncated", m->desc);
__magic_file_magwarn (ms, "description `%s' truncated", m->desc);
}
}
@ -1309,7 +1309,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
}
}
if (action == FILE_CHECK) {
file_mdump (ms, m);
__magic_file_mdump (ms, m);
}
m->mimetype[0] = '\0'; /* initialise MIME type to none */
if (m->cont_level == 0) {
@ -1329,7 +1329,7 @@ static int parse_mime(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp
struct r_magic_entry *me;
if (*nmentryp == 0) {
file_error (ms, 0, "No current entry for MIME type");
__magic_file_error (ms, 0, "No current entry for MIME type");
return -1;
}
@ -1337,7 +1337,7 @@ static int parse_mime(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp
m = &me->mp[me->cont_count == 0 ? 0 : me->cont_count - 1];
if (m->mimetype[0] != '\0') {
file_error (ms, 0, "Current entry already has a MIME type: %s\n"
__magic_file_error (ms, 0, "Current entry already has a MIME type: %s\n"
"Description: %s\nNew type: %s", m->mimetype, m->desc, l);
return -1;
}
@ -1349,7 +1349,7 @@ static int parse_mime(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp
if (i == sizeof (m->mimetype)) {
m->desc[sizeof (m->mimetype) - 1] = '\0';
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms, "MIME type `%s' truncated %zu",
__magic_file_magwarn (ms, "MIME type `%s' truncated %zu",
m->mimetype, i);
}
} else {
@ -1508,12 +1508,12 @@ static int check_format(RMagic *ms, struct r_magic *m) {
}
if (m->type >= FILE_NAMES_SIZE) {
file_magwarn(ms, "Internal error inconsistency between "
__magic_file_magwarn(ms, "Internal error inconsistency between "
"m->type and format strings");
return -1;
}
if (ms->magic_file_formats[m->type] == FILE_FMT_NONE) {
file_magwarn(ms, "No format string for `%s' with description "
__magic_file_magwarn(ms, "No format string for `%s' with description "
"`%s'", m->desc, ms->magic_file_names[m->type]);
return -1;
}
@ -1524,7 +1524,7 @@ static int check_format(RMagic *ms, struct r_magic *m) {
* TODO: this error message is unhelpful if the format
* string is not one character long
*/
file_magwarn(ms, "Printf format `%c' is not valid for type "
__magic_file_magwarn(ms, "Printf format `%c' is not valid for type "
"`%s' in description `%s'",
ptr && *ptr ? *ptr : '?',
ms->magic_file_names[m->type], m->desc);
@ -1533,7 +1533,7 @@ static int check_format(RMagic *ms, struct r_magic *m) {
for (; *ptr; ptr++) {
if (*ptr == '%') {
file_magwarn (ms,
__magic_file_magwarn (ms,
"Too many format strings (should have at most one) "
"for `%s' with description `%s'",
ms->magic_file_names[m->type], m->desc);
@ -1561,7 +1561,7 @@ static int getvalue(RMagic *ms, struct r_magic *m, const char **p, int action) {
*p = getstr (ms, *p, m->value.s, sizeof (m->value.s), &slen, action);
if (!*p) {
if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms, "cannot get string from `%s'",
__magic_file_magwarn (ms, "cannot get string from `%s'",
m->value.s);
}
return -1;
@ -1596,7 +1596,7 @@ static int getvalue(RMagic *ms, struct r_magic *m, const char **p, int action) {
default:
if (m->reln != 'x') {
char *ep;
m->value.q = file_signextend(ms, m,
m->value.q = __magic_file_signextend(ms, m,
(ut64)strtoull(*p, &ep, 0));
*p = ep;
eatsize(p);
@ -1622,19 +1622,19 @@ static const char *getstr(RMagic *ms, const char *s, char *p, int plen, int *sle
break;
}
if (p >= pmax) {
file_error (ms, 0, "string too long: `%s'", origs);
__magic_file_error (ms, 0, "string too long: `%s'", origs);
return NULL;
}
if (c == '\\') {
switch ((c = *s++)) {
case '\0':
if (action == FILE_COMPILE) {
file_magwarn (ms, "incomplete escape");
__magic_file_magwarn (ms, "incomplete escape");
}
goto out;
case '\t':
if (action == FILE_COMPILE) {
file_magwarn(ms,
__magic_file_magwarn(ms,
"escaped tab found, use \\t instead");
action++;
}
@ -1642,10 +1642,10 @@ static const char *getstr(RMagic *ms, const char *s, char *p, int plen, int *sle
default:
if (action == FILE_COMPILE) {
if (isprint ((ut8)c)) {
file_magwarn (ms,
__magic_file_magwarn (ms,
"no need to escape `%c'", c);
} else {
file_magwarn (ms,
__magic_file_magwarn (ms,
"unknown escape sequence: \\%03o", c);
}
}
@ -1754,7 +1754,7 @@ static int hextoint(int c) {
/*
* Print a string containing C character escapes.
*/
void file_showstr(FILE *fp, const char *s, size_t len) {
void __magic_file_showstr(FILE *fp, const char *s, size_t len) {
for (;;) {
char c = *s++;
if (len == ~0U) {
@ -1831,28 +1831,28 @@ static int apprentice_map(RMagic *ms, struct r_magic **magicp, ut32 *nmagicp, co
}
if (fstat(fd, &st) == -1) {
file_error (ms, errno, "cannot stat `%s'", dbname);
__magic_file_error (ms, errno, "cannot stat `%s'", dbname);
goto error1;
}
if (st.st_size < 8) {
file_error (ms, 0, "file `%s' is too small", dbname);
__magic_file_error (ms, 0, "file `%s' is too small", dbname);
goto error1;
}
#if QUICK
if ((mm = mmap (0, (size_t)st.st_size, PROT_READ, //OPENBSDBUG |PROT_WRITE,
MAP_PRIVATE|MAP_FILE, fd, (off_t)0)) == MAP_FAILED) {
file_error (ms, errno, "cannot map `%s'", dbname);
__magic_file_error (ms, errno, "cannot map `%s'", dbname);
goto error1;
}
#define RET 2
#else
if (!(mm = malloc ((size_t)st.st_size))) {
file_oomem(ms, (size_t)st.st_size);
__magic_file_oomem(ms, (size_t)st.st_size);
goto error1;
}
if (read (fd, mm, (size_t)st.st_size) != (size_t)st.st_size) {
file_badread(ms);
__magic_file_badread(ms);
goto error1;
}
#define RET 1
@ -1864,8 +1864,8 @@ static int apprentice_map(RMagic *ms, struct r_magic **magicp, ut32 *nmagicp, co
if (*ptr != MAGICNO) {
if (swap4(*ptr) != MAGICNO) {
//OPENBSDBUG file_error (ms, 0, "bad magic in `%s'");
file_error (ms, 0, "bad magic in `%s'", dbname);
//OPENBSDBUG __magic_file_error (ms, 0, "bad magic in `%s'");
__magic_file_error (ms, 0, "bad magic in `%s'", dbname);
goto error1;
}
needsbyteswap = 1;
@ -1875,7 +1875,7 @@ static int apprentice_map(RMagic *ms, struct r_magic **magicp, ut32 *nmagicp, co
version = needsbyteswap? swap4(ptr[1]): ptr[1];
if (version != VERSIONNO) {
file_error (ms, 0, "File %d.%d supports only %d version magic "
__magic_file_error (ms, 0, "File %d.%d supports only %d version magic "
"files. `%s' is version %d", FILE_VERSION_MAJOR, patchlevel,
VERSIONNO, dbname, version);
goto error1;
@ -1929,24 +1929,24 @@ static int apprentice_compile(RMagic *ms, struct r_magic **magicp, ut32 *nmagicp
}
if ((fd = r_sandbox_open(dbname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644)) == -1) {
file_error (ms, errno, "cannot open `%s'", dbname);
__magic_file_error (ms, errno, "cannot open `%s'", dbname);
goto out;
}
if (write(fd, ar, sizeof (ar)) != (int)sizeof (ar)) {
file_error (ms, errno, "error writing `%s'", dbname);
__magic_file_error (ms, errno, "error writing `%s'", dbname);
goto beach;
}
if (lseek(fd, (off_t)sizeof (struct r_magic), SEEK_SET)
!= sizeof (struct r_magic)) {
file_error (ms, errno, "error seeking `%s'", dbname);
__magic_file_error (ms, errno, "error seeking `%s'", dbname);
goto beach;
}
if (write(fd, *magicp, (sizeof (struct r_magic) * *nmagicp))
!= (int)(sizeof (struct r_magic) * *nmagicp)) {
file_error (ms, errno, "error writing `%s'", dbname);
__magic_file_error (ms, errno, "error writing `%s'", dbname);
goto beach;
}

View File

@ -106,7 +106,7 @@ R_API void r_magic_from_ebcdic(const ut8 *buf, size_t nbytes, ut8 *out) {
static int looks_ascii(const ut8 *, size_t, unichar *, size_t *);
static int looks_utf8_with_BOM(const ut8 *, size_t, unichar *, size_t *);
int file_looks_utf8(const ut8 *, size_t, unichar *, size_t *);
int __magic_file_looks_utf8(const ut8 *, size_t, unichar *, size_t *);
static int looks_ucs16(const ut8 *, size_t, unichar *, size_t *);
static int looks_latin1(const ut8 *, size_t, unichar *, size_t *);
static int looks_extended(const ut8 *, size_t, unichar *, size_t *);
@ -114,7 +114,7 @@ R_API void r_magic_from_ebcdic(const ut8 *, size_t, ut8 *);
static int ascmatch(const ut8 *, const unichar *, size_t);
static ut8 *encode_utf8(ut8 *, size_t, unichar *, size_t);
int file_ascmagic(RMagic *ms, const ut8 *buf, size_t nbytes) {
int __magic_file_ascmagic(RMagic *ms, const ut8 *buf, size_t nbytes) {
return 0;
size_t i;
ut8 *nbuf = NULL, *utf8_buf = NULL, *utf8_end;
@ -171,7 +171,7 @@ return 0;
code = "UTF-8 Unicode (with BOM)";
code_mime = "utf-8";
type = "text";
} else if (file_looks_utf8(buf, nbytes, ubuf, &ulen) > 1) {
} else if (__magic_file_looks_utf8(buf, nbytes, ubuf, &ulen) > 1) {
code = "UTF-8 Unicode";
code_mime = "utf-8";
type = "text";
@ -226,13 +226,13 @@ return 0;
re-converting conversion. */
mlen = ulen * 6;
if (!(utf8_buf = malloc(mlen))) {
file_oomem(ms, mlen);
__magic_file_oomem(ms, mlen);
goto done;
}
if (!(utf8_end = encode_utf8 (utf8_buf, mlen, ubuf, ulen))) {
goto done;
}
if (file_softmagic(ms, utf8_buf, utf8_end - utf8_buf, TEXTTEST) != 0) {
if (__magic_file_softmagic(ms, utf8_buf, utf8_end - utf8_buf, TEXTTEST) != 0) {
rv = 1;
goto done;
}
@ -322,11 +322,11 @@ subtype_identified:
if (mime) {
if (mime & R_MAGIC_MIME_TYPE) {
if (subtype_mime) {
if (file_printf (ms, subtype_mime) == -1) {
if (__magic_file_printf (ms, subtype_mime) == -1) {
goto done;
}
} else {
if (file_printf (ms, "text/plain") == -1) {
if (__magic_file_printf (ms, "text/plain") == -1) {
goto done;
}
}
@ -334,43 +334,43 @@ subtype_identified:
if ((mime == 0 || mime == R_MAGIC_MIME) && code_mime) {
if ((mime & R_MAGIC_MIME_TYPE) &&
file_printf (ms, " charset=") == -1) {
__magic_file_printf (ms, " charset=") == -1) {
goto done;
}
if (file_printf (ms, code_mime) == -1) {
if (__magic_file_printf (ms, code_mime) == -1) {
goto done;
}
}
if (mime == R_MAGIC_MIME_ENCODING) {
if (file_printf (ms, "binary") == -1) {
if (__magic_file_printf (ms, "binary") == -1) {
rv = 1;
goto done;
}
}
} else {
if (file_printf (ms, code) == -1) {
if (__magic_file_printf (ms, code) == -1) {
goto done;
}
if (subtype) {
if (file_printf (ms, " ") == -1) {
if (__magic_file_printf (ms, " ") == -1) {
goto done;
}
if (file_printf (ms, subtype) == -1) {
if (__magic_file_printf (ms, subtype) == -1) {
goto done;
}
}
if (file_printf (ms, " ") == -1) {
if (__magic_file_printf (ms, " ") == -1) {
goto done;
}
if (file_printf (ms, type) == -1) {
if (__magic_file_printf (ms, type) == -1) {
goto done;
}
if (has_long_lines) {
if (file_printf (ms, ", with very long lines") == -1) {
if (__magic_file_printf (ms, ", with very long lines") == -1) {
goto done;
}
}
@ -381,64 +381,64 @@ subtype_identified:
*/
if ((n_crlf == 0 && n_cr == 0 && n_nel == 0 && n_lf == 0) ||
(n_crlf != 0 || n_cr != 0 || n_nel != 0)) {
if (file_printf (ms, ", with") == -1) {
if (__magic_file_printf (ms, ", with") == -1) {
goto done;
}
if (n_crlf == 0 && n_cr == 0 && n_nel == 0 && n_lf == 0) {
if (file_printf (ms, " no") == -1) {
if (__magic_file_printf (ms, " no") == -1) {
goto done;
}
} else {
if (n_crlf) {
if (file_printf (ms, " CRLF") == -1) {
if (__magic_file_printf (ms, " CRLF") == -1) {
goto done;
}
if (n_cr || n_lf || n_nel) {
if (file_printf (ms, ",") == -1) {
if (__magic_file_printf (ms, ",") == -1) {
goto done;
}
}
}
if (n_cr) {
if (file_printf (ms, " CR") == -1) {
if (__magic_file_printf (ms, " CR") == -1) {
goto done;
}
if (n_lf || n_nel) {
if (file_printf (ms, ",") == -1) {
if (__magic_file_printf (ms, ",") == -1) {
goto done;
}
}
}
if (n_lf) {
if (file_printf (ms, " LF") == -1) {
if (__magic_file_printf (ms, " LF") == -1) {
goto done;
}
if (n_nel) {
if (file_printf (ms, ",") == -1) {
if (__magic_file_printf (ms, ",") == -1) {
goto done;
}
}
}
if (n_nel) {
if (file_printf (ms, " NEL") == -1) {
if (__magic_file_printf (ms, " NEL") == -1) {
goto done;
}
}
}
if (file_printf (ms, " line terminators") == -1) {
if (__magic_file_printf (ms, " line terminators") == -1) {
goto done;
}
}
if (has_escapes) {
if (file_printf (ms, ", with escape sequences") == -1) {
if (__magic_file_printf (ms, ", with escape sequences") == -1) {
goto done;
}
}
if (has_backspace) {
if (file_printf (ms, ", with overstriking") == -1) {
if (__magic_file_printf (ms, ", with overstriking") == -1) {
goto done;
}
}
@ -653,7 +653,7 @@ static ut8 * encode_utf8(ut8 *buf, size_t len, unichar *ubuf, size_t ulen) {
* If ubuf is non-NULL on entry, text is decoded into ubuf, *ulen;
* ubuf must be big enough!
*/
int file_looks_utf8(const ut8 *buf, size_t nbytes, unichar *ubuf, size_t *ulen) {
int __magic_file_looks_utf8(const ut8 *buf, size_t nbytes, unichar *ubuf, size_t *ulen) {
size_t i;
int n;
unichar c;
@ -731,7 +731,7 @@ done:
*/
static int looks_utf8_with_BOM(const ut8 *buf, size_t nbytes, unichar *ubuf, size_t *ulen) {
if (nbytes > 3 && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf) {
return file_looks_utf8 (buf + 3, nbytes - 3, ubuf, ulen);
return __magic_file_looks_utf8 (buf + 3, nbytes - 3, ubuf, ulen);
}
return -1;
}

View File

@ -54,33 +54,29 @@ typedef unsigned int ssize_t;
typedef unsigned long unichar;
struct stat;
const char *file_fmttime(unsigned int, int, char *);
int file_buffer(struct r_magic_set *, int, const char *, const void *, size_t);
int file_fsmagic(struct r_magic_set *, const char *, struct stat *);
int file_pipe2file(struct r_magic_set *, int, const void *, size_t);
int file_printf(struct r_magic_set *, const char *, ...);
int file_reset(struct r_magic_set *);
int file_tryelf(struct r_magic_set *, int, const unsigned char *, size_t);
int file_zmagic(struct r_magic_set *, int, const char *, const ut8*, size_t);
int file_ascmagic(struct r_magic_set *, const unsigned char *, size_t);
int file_is_tar(struct r_magic_set *, const unsigned char *, size_t);
int file_softmagic(struct r_magic_set *, const unsigned char *, size_t, int);
struct mlist *file_apprentice(struct r_magic_set *, const char *, size_t, int);
ut64 file_signextend(RMagic *, struct r_magic *, ut64);
void file_delmagic(struct r_magic *, int type, size_t entries);
void file_badread(struct r_magic_set *);
void file_badseek(struct r_magic_set *);
void file_oomem(struct r_magic_set *, size_t);
void file_error(struct r_magic_set *, int, const char *, ...);
void file_magerror(struct r_magic_set *, const char *, ...);
void file_magwarn(struct r_magic_set *, const char *, ...);
void file_mdump(struct r_magic_set *, struct r_magic *);
void file_showstr(FILE *, const char *, size_t);
size_t file_mbswidth(const char *);
const char *file_getbuffer(struct r_magic_set *);
ssize_t sread(int, void *, size_t, int);
int file_check_mem(struct r_magic_set *, unsigned int);
int file_looks_utf8(const unsigned char *, size_t, unichar *, size_t *);
R_IPI const char *__magic_file_fmttime(unsigned int, int, char *);
R_IPI int __magic_file_buffer(RMagic *, int, const char *, const void *, size_t);
R_IPI int __magic_file_fsmagic(RMagic *, const char *, struct stat *);
R_IPI int __magic_file_printf(RMagic *, const char *, ...);
R_IPI int __magic_file_reset(RMagic *);
R_IPI int __magic_file_zmagic(RMagic *, int, const char *, const ut8*, size_t);
R_IPI int __magic_file_ascmagic(RMagic *, const unsigned char *, size_t);
R_IPI int __magic_file_is_tar(RMagic *, const unsigned char *, size_t);
R_IPI int __magic_file_softmagic(RMagic *, const unsigned char *, size_t, int);
R_IPI struct mlist *__magic_file_apprentice(RMagic *, const char *, size_t, int);
R_IPI ut64 __magic_file_signextend(RMagic *, struct r_magic *, ut64);
R_IPI void __magic_file_delmagic(struct r_magic *, int type, size_t entries);
R_IPI void __magic_file_badread(RMagic *);
R_IPI void __magic_file_badseek(RMagic *);
R_IPI void __magic_file_oomem(RMagic *, size_t);
R_IPI void __magic_file_error(RMagic *, int, const char *, ...);
R_IPI void __magic_file_magerror(RMagic *, const char *, ...);
R_IPI void __magic_file_magwarn(RMagic *, const char *, ...);
R_IPI void __magic_file_mdump(RMagic *, struct r_magic *);
R_IPI void __magic_file_showstr(FILE *, const char *, size_t);
R_IPI const char *__magic_file_getbuffer(RMagic *);
R_IPI int __magic_file_check_mem(RMagic *, unsigned int);
R_IPI int __magic_file_looks_utf8(const unsigned char *, size_t, unichar *, size_t *);
#ifndef HAVE_VASPRINTF
int vasprintf(char **ptr, const char *format_string, va_list vargs);

View File

@ -68,17 +68,17 @@ static int bad_link(RMagic *ms, int err, char *buf) {
const char *errfmt = "broken symbolic link to `%s'";
#endif
if (ms->flags & R_MAGIC_ERROR) {
file_error (ms, err, errfmt, buf);
__magic_file_error (ms, err, errfmt, buf);
return -1;
}
if (file_printf (ms, errfmt, buf) == -1) {
if (__magic_file_printf (ms, errfmt, buf) == -1) {
return -1;
}
return 1;
}
#endif
int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) {
int __magic_file_fsmagic(RMagic *ms, const char *fn, struct stat *sb) {
int ret = 0;
int mime = ms->flags & R_MAGIC_MIME;
#ifdef S_IFLNK
@ -105,10 +105,10 @@ int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) {
if (ret) {
if (ms->flags & R_MAGIC_ERROR) {
file_error (ms, errno, "cannot stat `%s'", fn);
__magic_file_error (ms, errno, "cannot stat `%s'", fn);
return -1;
}
if (file_printf (ms, "cannot open `%s' (%s)",
if (__magic_file_printf (ms, "cannot open `%s' (%s)",
fn, strerror (errno)) == -1)
return -1;
return 1;
@ -117,7 +117,7 @@ int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) {
if (mime) {
if ((sb->st_mode & S_IFMT) != S_IFREG) {
if ((mime & R_MAGIC_MIME_TYPE) &&
file_printf (ms, "application/x-not-regular-file")
__magic_file_printf (ms, "application/x-not-regular-file")
== -1)
return -1;
return 1;
@ -125,24 +125,24 @@ int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) {
} else {
#ifdef S_ISUID
if (sb->st_mode & S_ISUID)
if (file_printf(ms, "setuid ") == -1)
if (__magic_file_printf(ms, "setuid ") == -1)
return -1;
#endif
#ifdef S_ISGID
if (sb->st_mode & S_ISGID)
if (file_printf(ms, "setgid ") == -1)
if (__magic_file_printf(ms, "setgid ") == -1)
return -1;
#endif
#ifdef S_ISVTX
if (sb->st_mode & S_ISVTX)
if (file_printf(ms, "sticky ") == -1)
if (__magic_file_printf(ms, "sticky ") == -1)
return -1;
#endif
}
switch (sb->st_mode & S_IFMT) {
case S_IFDIR:
if (file_printf (ms, "directory") == -1)
if (__magic_file_printf (ms, "directory") == -1)
return -1;
return 1;
#ifdef S_IFCHR
@ -157,19 +157,19 @@ int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) {
}
#ifdef HAVE_STAT_ST_RDEV
# ifdef dv_unit
if (file_printf (ms, "character special (%d/%d/%d)",
if (__magic_file_printf (ms, "character special (%d/%d/%d)",
major (sb->st_rdev), dv_unit(sb->st_rdev),
dv_subunit (sb->st_rdev)) == -1) {
return -1;
}
# else
if (file_printf (ms, "character special (%ld/%ld)",
if (__magic_file_printf (ms, "character special (%ld/%ld)",
(long) major (sb->st_rdev), (long) minor(sb->st_rdev)) == -1) {
return -1;
}
# endif
#else
if (file_printf (ms, "character special") == -1) {
if (__magic_file_printf (ms, "character special") == -1) {
return -1;
}
#endif
@ -187,18 +187,18 @@ int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) {
}
#ifdef HAVE_STAT_ST_RDEV
# ifdef dv_unit
if (file_printf (ms, "block special (%d/%d/%d)",
if (__magic_file_printf (ms, "block special (%d/%d/%d)",
major(sb->st_rdev), dv_unit (sb->st_rdev),
dv_subunit (sb->st_rdev)) == -1) {
return -1;
}
# else
if (file_printf (ms, "block special (%ld/%ld)",
if (__magic_file_printf (ms, "block special (%ld/%ld)",
(long)major (sb->st_rdev), (long)minor (sb->st_rdev)) == -1)
return -1;
# endif
#else
if (file_printf (ms, "block special") == -1) {
if (__magic_file_printf (ms, "block special") == -1) {
return -1;
}
#endif
@ -210,23 +210,23 @@ int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) {
if ((ms->flags & R_MAGIC_DEVICES) != 0) {
break;
}
if (file_printf (ms, "fifo (named pipe)") == -1) {
if (__magic_file_printf (ms, "fifo (named pipe)") == -1) {
return -1;
}
return 1;
#endif
#ifdef S_IFDOOR
case S_IFDOOR:
return (file_printf (ms, "door") == -1)? -1: 1;
return (__magic_file_printf (ms, "door") == -1)? -1: 1;
#endif
#ifdef S_IFLNK
case S_IFLNK:
if ((nch = readlink (fn, buf, BUFSIZ-1)) <= 0) {
if (ms->flags & R_MAGIC_ERROR) {
file_error (ms, errno, "unreadable symlink `%s'", fn);
__magic_file_error (ms, errno, "unreadable symlink `%s'", fn);
return -1;
}
if (file_printf(ms,
if (__magic_file_printf(ms,
"unreadable symlink `%s' (%s)", fn,
strerror(errno)) == -1)
return -1;
@ -247,10 +247,10 @@ int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) {
} else {
if (tmp - fn + 1 > BUFSIZ) {
if (ms->flags & R_MAGIC_ERROR) {
file_error (ms, 0, "path too long: `%s'", buf);
__magic_file_error (ms, 0, "path too long: `%s'", buf);
return -1;
}
if (file_printf (ms, "path too long: `%s'", fn) == -1) {
if (__magic_file_printf (ms, "path too long: `%s'", fn) == -1) {
return -1;
}
return 1;
@ -271,7 +271,7 @@ int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) {
ms->flags |= R_MAGIC_SYMLINK;
return p ? 1 : -1;
} else { /* just print what it points to */
if (file_printf (ms, "symbolic link to `%s'", buf) == -1)
if (__magic_file_printf (ms, "symbolic link to `%s'", buf) == -1)
return -1;
}
return 1;
@ -279,7 +279,7 @@ int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) {
#if 0
#ifdef S_IFSOCK
case S_IFSOCK:
if (file_printf(ms, "socket") == -1)
if (__magic_file_printf(ms, "socket") == -1)
return -1;
return 1;
#endif
@ -287,7 +287,7 @@ int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) {
case S_IFREG:
break;
default:
file_error (ms, 0, "invalid mode 0%o", sb->st_mode);
__magic_file_error (ms, 0, "invalid mode 0%o", sb->st_mode);
return -1;
/*NOTREACHED*/
}
@ -305,7 +305,7 @@ int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) {
*/
if ((ms->flags & R_MAGIC_DEVICES) == 0 && sb->st_size == 0) {
if ((!mime || (mime & R_MAGIC_MIME_TYPE)) &&
file_printf (ms, mime ? "application/x-empty" : "empty") == -1)
__magic_file_printf (ms, mime ? "application/x-empty" : "empty") == -1)
return -1;
return 1;
}

View File

@ -92,14 +92,14 @@ static int file_vprintf(RMagic *ms, const char *fmt, va_list ap) {
ms->o.buf = buf;
return 0;
out:
file_error (ms, errno, "vasprintf failed");
__magic_file_error (ms, errno, "vasprintf failed");
return -1;
}
/*
* Like printf, only we append to a buffer.
*/
int file_printf(RMagic *ms, const char *fmt, ...) {
int __magic_file_printf(RMagic *ms, const char *fmt, ...) {
va_list ap;
int ret;
@ -113,7 +113,7 @@ int file_printf(RMagic *ms, const char *fmt, ...) {
* error - print best error message possible
*/
/*VARARGS*/
static void file_error_core(RMagic *ms, int error, const char *f, va_list va, ut32 lineno) {
static void __magic_file_error_core(RMagic *ms, int error, const char *f, va_list va, ut32 lineno) {
/* Only the first error is ok */
if (!ms || ms->haderr) {
return;
@ -121,12 +121,12 @@ static void file_error_core(RMagic *ms, int error, const char *f, va_list va, ut
if (lineno != 0) {
free (ms->o.buf);
ms->o.buf = NULL;
(void)file_printf (ms, "line %u: ", lineno);
(void)__magic_file_printf (ms, "line %u: ", lineno);
}
// OPENBSDBUG
file_vprintf (ms, f, va);
if (error > 0) {
(void)file_printf (ms, " (%s)", strerror (error));
(void)__magic_file_printf (ms, " (%s)", strerror (error));
}
ms->haderr++;
ms->error = error;
@ -134,10 +134,10 @@ static void file_error_core(RMagic *ms, int error, const char *f, va_list va, ut
/*VARARGS*/
// XXX deprecate and just use R_LOG
void file_error(RMagic *ms, int error, const char *f, ...) {
void __magic_file_error(RMagic *ms, int error, const char *f, ...) {
va_list va;
va_start (va, f);
file_error_core (ms, error, f, va, 0);
__magic_file_error_core (ms, error, f, va, 0);
va_end (va);
}
@ -145,26 +145,26 @@ void file_error(RMagic *ms, int error, const char *f, ...) {
* Print an error with magic line number.
*/
/*VARARGS*/
void file_magerror(RMagic *ms, const char *f, ...) {
void __magic_file_magerror(RMagic *ms, const char *f, ...) {
va_list va;
va_start (va, f);
file_error_core (ms, 0, f, va, ms->line);
__magic_file_error_core (ms, 0, f, va, ms->line);
va_end (va);
}
void file_oomem(RMagic *ms, size_t len) {
file_error (ms, errno, "cannot allocate %u bytes", (unsigned int)len);
void __magic_file_oomem(RMagic *ms, size_t len) {
__magic_file_error (ms, errno, "cannot allocate %u bytes", (unsigned int)len);
}
void file_badseek(RMagic *ms) {
file_error (ms, errno, "error seeking");
void __magic_file_badseek(RMagic *ms) {
__magic_file_error (ms, errno, "error seeking");
}
void file_badread(RMagic *ms) {
file_error (ms, errno, "error reading");
void __magic_file_badread(RMagic *ms) {
__magic_file_error (ms, errno, "error reading");
}
int file_buffer(RMagic *ms, int fd, const char *inname, const void *buf, size_t nb) {
int __magic_file_buffer(RMagic *ms, int fd, const char *inname, const void *buf, size_t nb) {
int mime, m = 0;
if (!ms) {
return -1;
@ -172,13 +172,13 @@ int file_buffer(RMagic *ms, int fd, const char *inname, const void *buf, size_t
mime = ms->flags & R_MAGIC_MIME;
if (nb == 0) {
if ((!mime || (mime & R_MAGIC_MIME_TYPE)) &&
file_printf (ms, mime ? "application/x-empty" : "empty") == -1) {
__magic_file_printf (ms, mime ? "application/x-empty" : "empty") == -1) {
return -1;
}
return 1;
} else if (nb == 1) {
if ((!mime || (mime & R_MAGIC_MIME_TYPE)) &&
file_printf (ms, mime ? "application/octet-stream" : "very short file (no magic)") == -1) {
__magic_file_printf (ms, mime ? "application/octet-stream" : "very short file (no magic)") == -1) {
return -1;
}
return 1;
@ -187,21 +187,21 @@ int file_buffer(RMagic *ms, int fd, const char *inname, const void *buf, size_t
#if 0
/* try compression stuff */
if ((ms->flags & R_MAGIC_NO_CHECK_COMPRESS) != 0 ||
(m = file_zmagic(ms, fd, inname, buf, nb)) == 0) {
(m = __magic_file_zmagic(ms, fd, inname, buf, nb)) == 0) {
#endif
/* Check if we have a tar file */
if ((ms->flags & R_MAGIC_NO_CHECK_TAR) != 0 ||
(m = file_is_tar(ms, buf, nb)) == 0) {
(m = __magic_file_is_tar(ms, buf, nb)) == 0) {
/* try tests in /etc/magic (or surrogate magic file) */
if ((ms->flags & R_MAGIC_NO_CHECK_SOFT) != 0 ||
(m = file_softmagic(ms, buf, nb, BINTEST)) == 0) {
(m = __magic_file_softmagic(ms, buf, nb, BINTEST)) == 0) {
/* try known keywords, check whether it is ASCII */
if ((ms->flags & R_MAGIC_NO_CHECK_ASCII) != 0 ||
(m = file_ascmagic(ms, buf, nb)) == 0) {
(m = __magic_file_ascmagic(ms, buf, nb)) == 0) {
/* abandon hope, all ye who remain here */
if ((!mime || (mime & R_MAGIC_MIME_TYPE))) {
// if (mime)
file_printf (ms, "application/octet-stream");
__magic_file_printf (ms, "application/octet-stream");
return -1;
}
m = 1;
@ -214,7 +214,7 @@ int file_buffer(RMagic *ms, int fd, const char *inname, const void *buf, size_t
return m;
}
int file_reset(RMagic *ms) {
int __magic_file_reset(RMagic *ms) {
if (!ms) {
return 0;
}
@ -238,7 +238,7 @@ int file_reset(RMagic *ms) {
*(n)++ = (((ut32)*(o) >> 0) & 7) + '0', \
(o)++)
const char *file_getbuffer(RMagic *ms) {
const char *__magic_file_getbuffer(RMagic *ms) {
char *pbuf, *op, *np;
size_t psize, len;
@ -258,12 +258,12 @@ const char *file_getbuffer(RMagic *ms) {
/* * 4 is for octal representation, + 1 is for NUL */
len = strlen (ms->o.buf);
if (len > (SIZE_MAX - 1) / 4) {
file_oomem (ms, len);
__magic_file_oomem (ms, len);
return NULL;
}
psize = len * 4 + 1;
if (!(pbuf = realloc (ms->o.pbuf, psize))) {
file_oomem (ms, psize);
__magic_file_oomem (ms, psize);
return NULL;
}
ms->o.pbuf = pbuf;
@ -320,13 +320,13 @@ const char *file_getbuffer(RMagic *ms) {
return ms->o.pbuf;
}
int file_check_mem(RMagic *ms, unsigned int level) {
int __magic_file_check_mem(RMagic *ms, unsigned int level) {
if (level >= ms->c.len) {
size_t len = (ms->c.len += 20) * sizeof (*ms->c.li);
ms->c.li = (!ms->c.li) ? malloc (len) :
realloc (ms->c.li, len);
if (!ms->c.li) {
file_oomem (ms, len);
__magic_file_oomem (ms, len);
return -1;
}
}

View File

@ -122,7 +122,7 @@ static int is_tar(const ut8 *buf, size_t nbytes) {
return 1; /* Old fashioned tar archive */
}
int file_is_tar(RMagic *ms, const ut8 *buf, size_t nbytes) {
int __magic_file_is_tar(RMagic *ms, const ut8 *buf, size_t nbytes) {
/*
* Do the tar test first, because if the first file in the tar
* archive starts with a dot, we can confuse it with an nroff file.
@ -136,7 +136,7 @@ int file_is_tar(RMagic *ms, const ut8 *buf, size_t nbytes) {
if (mime == R_MAGIC_MIME_ENCODING) {
return 0;
}
if (file_printf (ms, mime ? "application/x-tar" : tartype[tar - 1]) == -1) {
if (__magic_file_printf (ms, mime ? "application/x-tar" : tartype[tar - 1]) == -1) {
return -1;
}
return 1;

View File

@ -65,7 +65,7 @@ static void free_mlist(struct mlist *mlist) {
for (ml = mlist->next; ml != mlist;) {
struct mlist *next = ml->next;
struct r_magic *mg = ml->magic;
file_delmagic (mg, ml->mapped, ml->nmagic);
__magic_file_delmagic (mg, ml->mapped, ml->nmagic);
free (ml);
ml = next;
}
@ -75,21 +75,21 @@ static void free_mlist(struct mlist *mlist) {
static int info_from_stat(RMagic *ms, unsigned short md) {
/* We cannot open it, but we were able to stat it. */
if (md & 0222) {
if (file_printf (ms, "writable, ") == -1) {
if (__magic_file_printf (ms, "writable, ") == -1) {
return -1;
}
}
if (md & 0111) {
if (file_printf (ms, "executable, ") == -1) {
if (__magic_file_printf (ms, "executable, ") == -1) {
return -1;
}
}
if (S_ISREG (md)) {
if (file_printf (ms, "regular file, ") == -1) {
if (__magic_file_printf (ms, "regular file, ") == -1) {
return -1;
}
}
if (file_printf (ms, "no read permission") == -1) {
if (__magic_file_printf (ms, "no read permission") == -1) {
return -1;
}
return 0;
@ -117,11 +117,11 @@ static const char *file_or_fd(RMagic *ms, const char *inname, int fd) {
return NULL;
}
if (file_reset (ms) == -1) {
if (__magic_file_reset (ms) == -1) {
goto done;
}
switch (file_fsmagic (ms, inname, &sb)) {
switch (__magic_file_fsmagic (ms, inname, &sb)) {
case -1: goto done; /* error */
case 0: break; /* nothing found */
default: rv = 0; goto done; /* matched it and printed type */
@ -184,7 +184,7 @@ static const char *file_or_fd(RMagic *ms, const char *inname, int fd) {
} else {
#endif
if ((nbytes = read(fd, (char *)buf, HOWMANY)) == -1) {
file_error(ms, errno, "cannot read `%s'", inname);
__magic_file_error(ms, errno, "cannot read `%s'", inname);
goto done;
}
#ifdef O_NONBLOCK
@ -192,14 +192,14 @@ static const char *file_or_fd(RMagic *ms, const char *inname, int fd) {
#endif
(void)memset (buf + nbytes, 0, SLOP); /* NUL terminate */
if (file_buffer (ms, fd, inname, buf, (size_t)nbytes) == -1) {
if (__magic_file_buffer (ms, fd, inname, buf, (size_t)nbytes) == -1) {
goto done;
}
rv = 0;
done:
free (buf);
close_and_restore (ms, inname, fd, &sb);
return rv == 0 ? file_getbuffer(ms) : NULL;
return rv == 0 ? __magic_file_getbuffer(ms) : NULL;
}
/* API */
@ -220,7 +220,7 @@ R_API RMagic* r_magic_new(int flags) {
free (ms);
return NULL;
}
file_reset (ms);
__magic_file_reset (ms);
ms->mlist = NULL;
ms->file = "unknown";
ms->line = 0;
@ -239,7 +239,7 @@ R_API void r_magic_free(RMagic *ms) {
R_API bool r_magic_load_buffer(RMagic* ms, const ut8 *magicdata, size_t magicdata_size) {
if (magicdata_size > 0 && *magicdata == '#') {
struct mlist *ml = file_apprentice (ms, (const char *)magicdata, magicdata_size, FILE_LOAD);
struct mlist *ml = __magic_file_apprentice (ms, (const char *)magicdata, magicdata_size, FILE_LOAD);
if (ml) {
free_mlist (ms->mlist);
ms->mlist = ml;
@ -252,7 +252,7 @@ R_API bool r_magic_load_buffer(RMagic* ms, const ut8 *magicdata, size_t magicdat
}
R_API bool r_magic_load(RMagic* ms, const char *magicfile) {
struct mlist *ml = file_apprentice (ms, magicfile, strlen (magicfile), FILE_LOAD);
struct mlist *ml = __magic_file_apprentice (ms, magicfile, strlen (magicfile), FILE_LOAD);
if (ml) {
free_mlist (ms->mlist);
ms->mlist = ml;
@ -262,13 +262,13 @@ R_API bool r_magic_load(RMagic* ms, const char *magicfile) {
}
R_API bool r_magic_compile(RMagic *ms, const char *magicfile) {
struct mlist *ml = file_apprentice (ms, magicfile, strlen (magicfile), FILE_COMPILE);
struct mlist *ml = __magic_file_apprentice (ms, magicfile, strlen (magicfile), FILE_COMPILE);
free_mlist (ml);
return ml;
}
R_API bool r_magic_check(RMagic *ms, const char *magicfile) {
struct mlist *ml = file_apprentice (ms, magicfile, strlen (magicfile), FILE_CHECK);
struct mlist *ml = __magic_file_apprentice (ms, magicfile, strlen (magicfile), FILE_CHECK);
free_mlist (ml);
return ml;
}
@ -282,13 +282,13 @@ R_API const char *r_magic_file(RMagic *ms, const char *inname) {
}
R_API const char *r_magic_buffer(RMagic *ms, const void *buf, size_t nb) {
if (file_reset (ms) == -1) {
if (__magic_file_reset (ms) == -1) {
return NULL;
}
if (file_buffer (ms, -1, NULL, buf, nb) == -1) {
if (__magic_file_buffer (ms, -1, NULL, buf, nb) == -1) {
return NULL;
}
return file_getbuffer (ms);
return __magic_file_getbuffer (ms);
}
R_API const char *r_magic_error(RMagic *ms) {

View File

@ -39,7 +39,7 @@
#define SZOF(a) (sizeof (a) / sizeof (a[0]))
#ifndef COMPILE_ONLY
void file_mdump(RMagic *ms, struct r_magic *m) {
void __magic_file_mdump(RMagic *ms, struct r_magic *m) {
char pp[ASCTIME_BUF_MAXLEN];
(void) eprintf ("[%u", m->lineno);
@ -116,33 +116,33 @@ void file_mdump(RMagic *ms, struct r_magic *m) {
case FILE_BESTRING16:
case FILE_LESTRING16:
case FILE_SEARCH:
file_showstr(stderr, m->value.s, (size_t)m->vallen);
__magic_file_showstr(stderr, m->value.s, (size_t)m->vallen);
break;
case FILE_DATE:
case FILE_LEDATE:
case FILE_BEDATE:
case FILE_MEDATE:
(void)eprintf ("%s,",
file_fmttime (m->value.l, 1, pp));
__magic_file_fmttime (m->value.l, 1, pp));
break;
case FILE_LDATE:
case FILE_LELDATE:
case FILE_BELDATE:
case FILE_MELDATE:
(void)eprintf ("%s,",
file_fmttime (m->value.l, 0, pp));
__magic_file_fmttime (m->value.l, 0, pp));
break;
case FILE_QDATE:
case FILE_LEQDATE:
case FILE_BEQDATE:
(void)eprintf ("%s,",
file_fmttime ((ut32)m->value.q, 1, pp));
__magic_file_fmttime ((ut32)m->value.q, 1, pp));
break;
case FILE_QLDATE:
case FILE_LEQLDATE:
case FILE_BEQLDATE:
(void)eprintf ("%s,",
file_fmttime ((ut32)m->value.q, 0, pp));
__magic_file_fmttime ((ut32)m->value.q, 0, pp));
break;
case FILE_FLOAT:
case FILE_BEFLOAT:
@ -167,7 +167,7 @@ void file_mdump(RMagic *ms, struct r_magic *m) {
#endif
/*VARARGS*/
void file_magwarn(struct r_magic_set *ms, const char *f, ...) {
void __magic_file_magwarn(RMagic *ms, const char *f, ...) {
va_list va;
RStrBuf *sb = r_strbuf_new ("");
if (R_STR_ISNOTEMPTY (ms->file)) {
@ -182,7 +182,7 @@ void file_magwarn(struct r_magic_set *ms, const char *f, ...) {
free (msg);
}
const char *file_fmttime(ut32 v, int local, char *pp) {
const char *__magic_file_fmttime(ut32 v, int local, char *pp) {
time_t t = (time_t)v;
if (local) {

View File

@ -65,7 +65,7 @@ static void cvt_64(union VALUETYPE *, const struct r_magic *);
* Passed the name and FILE * of one file to be typed.
*/
/*ARGSUSED1*/ /* nbytes passed for regularity, maybe need later */
int file_softmagic(RMagic *ms, const ut8 *buf, size_t nbytes, int mode) {
int __magic_file_softmagic(RMagic *ms, const ut8 *buf, size_t nbytes, int mode) {
struct mlist *ml;
int rv;
for (ml = ms->mlist->next; ml != ms->mlist; ml = ml->next) {
@ -111,7 +111,7 @@ static int match(RMagic *ms, struct r_magic *magic, ut32 nmagic, const ut8 *s, s
int firstline = 1; /* a flag to print X\n X\n- X */
int printed_something = 0;
if (file_check_mem (ms, cont_level) == -1) {
if (__magic_file_check_mem (ms, cont_level) == -1) {
return -1;
}
for (magindex = 0; magindex < nmagic; magindex++) {
@ -172,7 +172,7 @@ static int match(RMagic *ms, struct r_magic *magic, ut32 nmagic, const ut8 *s, s
}
/* and any continuations that match */
if (file_check_mem(ms, ++cont_level) == -1) {
if (__magic_file_check_mem(ms, ++cont_level) == -1) {
return -1;
}
@ -239,7 +239,7 @@ static int match(RMagic *ms, struct r_magic *magic, ut32 nmagic, const ut8 *s, s
if (need_separator
&& ((m->flag & NOSPACE) == 0)
&& *R_MAGIC_DESC) {
if (file_printf (ms, " ") == -1) {
if (__magic_file_printf (ms, " ") == -1) {
return -1;
}
need_separator = 0;
@ -256,7 +256,7 @@ static int match(RMagic *ms, struct r_magic *magic, ut32 nmagic, const ut8 *s, s
* at a higher level,
* process them.
*/
if (file_check_mem (ms, ++cont_level) == -1) {
if (__magic_file_check_mem (ms, ++cont_level) == -1) {
return -1;
}
break;
@ -284,7 +284,7 @@ static int check_fmt(RMagic *ms, struct r_magic *m) {
rc = r_regex_init (&rx, "%[-0-9\\.]*s", R_REGEX_EXTENDED|R_REGEX_NOSUB);
if (rc) {
char *errmsg = r_regex_error (&rx, rc);
file_magerror (ms, "regex error %d, (%s)", rc, errmsg);
__magic_file_magerror (ms, "regex error %d, (%s)", rc, errmsg);
free (errmsg);
return -1;
} else {
@ -318,7 +318,7 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
switch (m->type) {
case FILE_BYTE:
v = file_signextend(ms, m, (ut64)p->b);
v = __magic_file_signextend(ms, m, (ut64)p->b);
switch (check_fmt(ms, m)) {
case -1:
return -1;
@ -328,13 +328,13 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
free (buf);
return -1;
}
if (file_printf (ms, R_MAGIC_DESC, buf) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, buf) == -1) {
free (buf);
return -1;
}
break;
default:
if (file_printf (ms, R_MAGIC_DESC, (ut8)v) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, (ut8)v) == -1) {
return -1;
}
break;
@ -344,7 +344,7 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
case FILE_SHORT:
case FILE_BESHORT:
case FILE_LESHORT:
v = file_signextend (ms, m, (ut64)p->h);
v = __magic_file_signextend (ms, m, (ut64)p->h);
switch (check_fmt (ms, m)) {
case -1:
return -1;
@ -354,13 +354,13 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
free (buf);
return -1;
}
if (file_printf(ms, R_MAGIC_DESC, buf) == -1) {
if (__magic_file_printf(ms, R_MAGIC_DESC, buf) == -1) {
free (buf);
return -1;
}
break;
default:
if (file_printf (ms, R_MAGIC_DESC, (unsigned short)v) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, (unsigned short)v) == -1) {
return -1;
}
break;
@ -371,7 +371,7 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
case FILE_BELONG:
case FILE_LELONG:
case FILE_MELONG:
v = file_signextend(ms, m, (ut64)p->l);
v = __magic_file_signextend(ms, m, (ut64)p->l);
switch (check_fmt(ms, m)) {
case -1:
return -1;
@ -381,13 +381,13 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
free (buf);
return -1;
}
if (file_printf(ms, R_MAGIC_DESC, buf) == -1) {
if (__magic_file_printf(ms, R_MAGIC_DESC, buf) == -1) {
free (buf);
return -1;
}
break;
default:
if (file_printf (ms, R_MAGIC_DESC, (ut32)v) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, (ut32)v) == -1) {
return -1;
}
break;
@ -397,8 +397,8 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
case FILE_QUAD:
case FILE_BEQUAD:
case FILE_LEQUAD:
v = file_signextend(ms, m, p->q);
if (file_printf (ms, R_MAGIC_DESC, (ut64)v) == -1) {
v = __magic_file_signextend(ms, m, p->q);
if (__magic_file_printf (ms, R_MAGIC_DESC, (ut64)v) == -1) {
return -1;
}
t = ms->offset + sizeof (ut64);
@ -409,7 +409,7 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
case FILE_BESTRING16:
case FILE_LESTRING16:
if (m->reln == '=' || m->reln == '!') {
if (file_printf (ms, R_MAGIC_DESC, m->value.s) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, m->value.s) == -1) {
return -1;
}
t = ms->offset + m->vallen;
@ -418,7 +418,7 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
if (*m->value.s == '\0') {
p->s[strcspn (p->s, "\n")] = '\0';
}
if (file_printf (ms, R_MAGIC_DESC, p->s) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, p->s) == -1) {
return -1;
}
t = ms->offset + strlen (p->s);
@ -431,7 +431,7 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
case FILE_BEDATE:
case FILE_LEDATE:
case FILE_MEDATE:
if (file_printf (ms, R_MAGIC_DESC, file_fmttime (p->l, 1, pp)) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, __magic_file_fmttime (p->l, 1, pp)) == -1) {
return -1;
}
t = ms->offset + sizeof (time_t);
@ -440,7 +440,7 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
case FILE_BELDATE:
case FILE_LELDATE:
case FILE_MELDATE:
if (file_printf (ms, R_MAGIC_DESC, file_fmttime (p->l, 0, pp)) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, __magic_file_fmttime (p->l, 0, pp)) == -1) {
return -1;
}
t = ms->offset + sizeof (time_t);
@ -448,7 +448,7 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
case FILE_QDATE:
case FILE_BEQDATE:
case FILE_LEQDATE:
if (file_printf (ms, R_MAGIC_DESC, file_fmttime ((ut32)p->q, 1, pp)) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, __magic_file_fmttime ((ut32)p->q, 1, pp)) == -1) {
return -1;
}
t = ms->offset + sizeof (ut64);
@ -456,7 +456,7 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
case FILE_QLDATE:
case FILE_BEQLDATE:
case FILE_LEQLDATE:
if (file_printf (ms, R_MAGIC_DESC, file_fmttime ((ut32)p->q, 0, pp)) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, __magic_file_fmttime ((ut32)p->q, 0, pp)) == -1) {
return -1;
}
t = ms->offset + sizeof (ut64);
@ -474,13 +474,13 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
free (buf);
return -1;
}
if (file_printf (ms, R_MAGIC_DESC, buf) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, buf) == -1) {
free (buf);
return -1;
}
break;
default:
if (file_printf (ms, R_MAGIC_DESC, vf) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, vf) == -1) {
return -1;
}
break;
@ -500,13 +500,13 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
free (buf);
return -1;
}
if (file_printf (ms, R_MAGIC_DESC, buf) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, buf) == -1) {
free (buf);
return -1;
}
break;
default:
if (file_printf (ms, R_MAGIC_DESC, vd) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, vd) == -1) {
return -1;
}
break;
@ -516,10 +516,10 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
case FILE_REGEX: {
char *cp = r_str_ndup ((const char *)ms->search.s, ms->search.rm_len);
if (!cp) {
file_oomem(ms, ms->search.rm_len);
__magic_file_oomem(ms, ms->search.rm_len);
return -1;
}
int rval = file_printf(ms, R_MAGIC_DESC, cp);
int rval = __magic_file_printf(ms, R_MAGIC_DESC, cp);
free (cp);
if (rval == -1) {
return -1;
@ -533,7 +533,7 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
}
case FILE_SEARCH:
if (file_printf (ms, R_MAGIC_DESC, m->value.s) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, m->value.s) == -1) {
return -1;
}
if ((m->str_flags & REGEX_OFFSET_START)) {
@ -543,13 +543,13 @@ static st32 mprint(RMagic *ms, struct r_magic *m) {
}
break;
case FILE_DEFAULT:
if (file_printf (ms, R_MAGIC_DESC, m->value.s) == -1) {
if (__magic_file_printf (ms, R_MAGIC_DESC, m->value.s) == -1) {
return -1;
}
t = ms->offset;
break;
default:
file_magerror(ms, "invalid m->type (%d) in mprint()", m->type);
__magic_file_magerror(ms, "invalid m->type (%d) in mprint()", m->type);
return -1;
}
free (buf);
@ -764,7 +764,7 @@ static int mconvert(RMagic *ms, struct r_magic *m) {
case FILE_DEFAULT:
return 1;
default:
file_magerror(ms, "invalid type %d in mconvert()", m->type);
__magic_file_magerror(ms, "invalid type %d in mconvert()", m->type);
return 0;
}
}
@ -772,7 +772,7 @@ static int mconvert(RMagic *ms, struct r_magic *m) {
static void mdebug(ut32 offset, const char *str, size_t len) {
eprintf ("mget @%d: ", offset);
file_showstr (stderr, str, len);
__magic_file_showstr (stderr, str, len);
(void) fputc('\n', stderr);
(void) fputc('\n', stderr);
}
@ -835,7 +835,7 @@ static int mcopy(RMagic *ms, union VALUETYPE *p, int type, int indir, const ut8
/* check for pointer overflow */
if (src < s) {
file_magerror(ms, "invalid offset %u in mcopy()",
__magic_file_magerror(ms, "invalid offset %u in mcopy()",
offset);
return -1;
}
@ -892,7 +892,7 @@ static int mget(RMagic *ms, const ut8 *s, struct r_magic *m, size_t nbytes, unsi
if ((ms->flags & R_MAGIC_DEBUG) != 0) {
mdebug (offset, (char *)(void *)p, sizeof (union VALUETYPE));
file_mdump (ms, m);
__magic_file_mdump (ms, m);
}
if (m->flag & INDIR) {
@ -1165,7 +1165,7 @@ static int mget(RMagic *ms, const ut8 *s, struct r_magic *m, size_t nbytes, unsi
if ((ms->flags & R_MAGIC_DEBUG) != 0) {
mdebug (offset, (char *)(void *)p, sizeof (union VALUETYPE));
file_mdump (ms, m);
__magic_file_mdump (ms, m);
}
}
@ -1350,7 +1350,7 @@ static int magiccheck(RMagic *ms, struct r_magic *m) {
case '>': matched = fv > fl; break;
case '<': matched = fv < fl; break;
default:
file_magerror(ms, "cannot happen with float: invalid relation `%c'", m->reln);
__magic_file_magerror(ms, "cannot happen with float: invalid relation `%c'", m->reln);
return -1;
}
return matched;
@ -1366,7 +1366,7 @@ static int magiccheck(RMagic *ms, struct r_magic *m) {
case '>': matched = dv > dl; break;
case '<': matched = dv < dl; break;
default:
file_magerror (ms, "cannot happen with double: invalid relation `%c'", m->reln);
__magic_file_magerror (ms, "cannot happen with double: invalid relation `%c'", m->reln);
return -1;
}
return matched;
@ -1425,7 +1425,7 @@ static int magiccheck(RMagic *ms, struct r_magic *m) {
((m->str_flags & STRING_IGNORE_CASE) ? R_REGEX_ICASE : 0));
if (rc) {
errmsg = r_regex_error(&rx, rc);
file_magerror(ms, "regex error %d, (%s)",
__magic_file_magerror(ms, "regex error %d, (%s)",
rc, errmsg);
free (errmsg);
v = (ut64) - 1;
@ -1456,7 +1456,7 @@ static int magiccheck(RMagic *ms, struct r_magic *m) {
break;
default:
errmsg = r_regex_error (&rx, rc);
file_magerror (ms, "regexec error %d, (%s)", rc, errmsg);
__magic_file_magerror (ms, "regexec error %d, (%s)", rc, errmsg);
free (errmsg);
v = UT64_MAX;
break;
@ -1469,11 +1469,11 @@ static int magiccheck(RMagic *ms, struct r_magic *m) {
break;
}
default:
file_magerror (ms, "invalid type %d in magiccheck()", m->type);
__magic_file_magerror (ms, "invalid type %d in magiccheck()", m->type);
return -1;
}
v = file_signextend (ms, m, v);
v = __magic_file_signextend (ms, m, v);
switch (m->reln) {
case 'x':
if ((ms->flags & R_MAGIC_DEBUG) != 0) {
@ -1532,13 +1532,13 @@ static int magiccheck(RMagic *ms, struct r_magic *m) {
}
break;
default:
file_magerror (ms, "cannot happen: invalid relation `%c'", m->reln);
__magic_file_magerror (ms, "cannot happen: invalid relation `%c'", m->reln);
return -1;
}
return matched;
}
static int print_sep(RMagic *ms, int firstline) {
return firstline? 0: file_printf (ms, "\n- ");
return firstline? 0: __magic_file_printf (ms, "\n- ");
}
#endif