LINT = splint
EXTRA_DIST = LEGAL.NOTICE MAINT Makefile.std magic2mime magic.mime \
- Localstuff Header $(magic_FRAGMENTS) file.man magic.man
+ Localstuff Header file.man
BUILT_SOURCES = listobjs $(man_MANS)
* extend the sign bit if the comparison is to be signed
*/
uint32_t
-signextend(struct magic *m, uint32_t v)
+file_signextend(struct magic *m, uint32_t v)
{
if (!(m->flag & UNSIGNED))
switch(m->type) {
case FILE_REGEX:
break;
default:
- magwarn("can't happen: m->type=%d\n", m->type);
+ file_magwarn("can't happen: m->type=%d\n", m->type);
return -1;
}
return v;
m->vallen = slen;
} else
if (m->reln != 'x') {
- m->value.l = signextend(m, strtoul(*p, p, 0));
+ m->value.l = file_signextend(m, strtoul(*p, p, 0));
eatsize(p);
}
return 0;
/* get offset, then skip over it */
m->offset = (int) strtoul(l,&t,0);
if (l == t)
- magwarn("offset %s invalid", l);
+ file_magwarn("offset %s invalid", l);
l = t;
if (m->flag & INDIR) {
m->in_type = FILE_BYTE;
break;
default:
- magwarn("indirect offset type %c invalid", *l);
+ file_magwarn("indirect offset type %c invalid", *l);
break;
}
l++;
else
t = l;
if (*t++ != ')')
- magwarn("missing ')' in indirect offset");
+ file_magwarn("missing ')' in indirect offset");
l = t;
}
m->type = FILE_REGEX;
l += sizeof("regex");
} else {
- magwarn("type %s invalid", l);
+ file_magwarn("type %s invalid", l);
return -1;
}
/* New-style anding: "0 byte&0x80 =0x80 dynamically linked" */
/* New and improved: ~ & | ^ + - * / % -- exciting, isn't it? */
if (*l == '~') {
- if (FILE_STRING != m->type && FILE_PSTRING != m->type)
+ if (m->type != FILE_STRING && m->type != FILE_PSTRING)
m->mask_op = FILE_OPINVERSE;
++l;
}
case '&':
m->mask_op |= FILE_OPAND;
++l;
- m->mask = signextend(m, strtoul(l, &l, 0));
+ m->mask = file_signextend(m, strtoul(l, &l, 0));
eatsize(&l);
break;
case '|':
m->mask_op |= FILE_OPOR;
++l;
- m->mask = signextend(m, strtoul(l, &l, 0));
+ m->mask = file_signextend(m, strtoul(l, &l, 0));
eatsize(&l);
break;
case '^':
m->mask_op |= FILE_OPXOR;
++l;
- m->mask = signextend(m, strtoul(l, &l, 0));
+ m->mask = file_signextend(m, strtoul(l, &l, 0));
eatsize(&l);
break;
case '+':
m->mask_op |= FILE_OPADD;
++l;
- m->mask = signextend(m, strtoul(l, &l, 0));
+ m->mask = file_signextend(m, strtoul(l, &l, 0));
eatsize(&l);
break;
case '-':
m->mask_op |= FILE_OPMINUS;
++l;
- m->mask = signextend(m, strtoul(l, &l, 0));
+ m->mask = file_signextend(m, strtoul(l, &l, 0));
eatsize(&l);
break;
case '*':
m->mask_op |= FILE_OPMULTIPLY;
++l;
- m->mask = signextend(m, strtoul(l, &l, 0));
+ m->mask = file_signextend(m, strtoul(l, &l, 0));
eatsize(&l);
break;
case '%':
m->mask_op |= FILE_OPMODULO;
++l;
- m->mask = signextend(m, strtoul(l, &l, 0));
+ m->mask = file_signextend(m, strtoul(l, &l, 0));
eatsize(&l);
break;
case '/':
- if (FILE_STRING != m->type && FILE_PSTRING != m->type) {
+ if (m->type != FILE_STRING && m->type != FILE_PSTRING) {
m->mask_op |= FILE_OPDIVIDE;
++l;
- m->mask = signextend(m, strtoul(l, &l, 0));
+ m->mask = file_signextend(m, strtoul(l, &l, 0));
eatsize(&l);
} else {
m->mask = 0L;
STRING_COMPACT_OPTIONAL_BLANK;
/*@switchbreak@*/ break;
default:
- magwarn("string extension %c invalid",
+ file_magwarn("string extension %c invalid",
*l);
return -1;
}
/*
* TODO finish this macro and start using it!
* #define offsetcheck {if (offset > HOWMANY-1)
- * magwarn("offset too big"); }
+ * file_magwarn("offset too big"); }
*/
/*
#ifndef COMPILE_ONLY
if (action == FILE_CHECK) {
- mdump(m);
+ file_mdump(m);
}
#endif
++(*nmagicp); /* make room for next */
* Print a string containing C character escapes.
*/
void
-showstr(FILE *fp, const char *s, int len)
+file_showstr(FILE *fp, const char *s, size_t len)
{
char c;
*/
switch (is_tar(fm)) {
case 1:
- fmagicPrintf(fm, ((fm->flags & FMAGIC_FLAGS_MIME)
+ file_printf(fm, ((fm->flags & FMAGIC_FLAGS_MIME)
? "application/x-tar" : "tar archive"));
return 1;
case 2:
- fmagicPrintf(fm, ((fm->flags & FMAGIC_FLAGS_MIME)
+ file_printf(fm, ((fm->flags & FMAGIC_FLAGS_MIME)
? "application/x-tar, POSIX" : "POSIX tar archive"));
return 1;
}
if ((fm->flags & FMAGIC_FLAGS_MIME)) {
if (subtype_mime != NULL)
- fmagicPrintf(fm, subtype_mime);
+ file_printf(fm, subtype_mime);
else
- fmagicPrintf(fm, "text/plain");
+ file_printf(fm, "text/plain");
if (code_mime != NULL) {
- fmagicPrintf(fm, "; charset=");
- fmagicPrintf(fm, code_mime);
+ file_printf(fm, "; charset=");
+ file_printf(fm, code_mime);
}
} else {
- fmagicPrintf(fm, code);
+ file_printf(fm, code);
if (subtype != NULL) {
- fmagicPrintf(fm, " ");
- fmagicPrintf(fm, subtype);
+ file_printf(fm, " ");
+ file_printf(fm, subtype);
}
- fmagicPrintf(fm, " ");
- fmagicPrintf(fm, type);
+ file_printf(fm, " ");
+ file_printf(fm, type);
if (has_long_lines)
- fmagicPrintf(fm, ", with very long lines");
+ file_printf(fm, ", with very long lines");
/*
* Only report line terminators if we find one other than LF,
*/
if ((n_crlf == 0 && n_cr == 0 && n_nel == 0 && n_lf == 0) ||
(n_crlf != 0 || n_cr != 0 || n_nel != 0)) {
- fmagicPrintf(fm, ", with");
+ file_printf(fm, ", with");
if (n_crlf == 0 && n_cr == 0 && n_nel == 0 && n_lf == 0)
- fmagicPrintf(fm, " no");
+ file_printf(fm, " no");
else {
if (n_crlf) {
- fmagicPrintf(fm, " CRLF");
+ file_printf(fm, " CRLF");
if (n_cr || n_lf || n_nel)
- fmagicPrintf(fm, ",");
+ file_printf(fm, ",");
}
if (n_cr) {
- fmagicPrintf(fm, " CR");
+ file_printf(fm, " CR");
if (n_lf || n_nel)
- fmagicPrintf(fm, ",");
+ file_printf(fm, ",");
}
if (n_lf) {
- fmagicPrintf(fm, " LF");
+ file_printf(fm, " LF");
if (n_nel)
- fmagicPrintf(fm, ",");
+ file_printf(fm, ",");
}
if (n_nel)
- fmagicPrintf(fm, " NEL");
+ file_printf(fm, " NEL");
}
- fmagicPrintf(fm, " line terminators");
+ file_printf(fm, " line terminators");
}
if (has_escapes)
- fmagicPrintf(fm, ", with escape sequences");
+ file_printf(fm, ", with escape sequences");
if (has_backspace)
- fmagicPrintf(fm, ", with overstriking");
+ file_printf(fm, ", with overstriking");
}
return 1;
}
int
-pipe2file(int fd, void *startbuf, size_t nbytes)
+file_pipe2file(int fd, const void *startbuf, size_t nbytes)
{
char buf[4096];
int r, tfd;
/*@globals fileSystem, internalState @*/
/*@modifies fm, fileSystem, internalState @*/;
-extern void fmagicPrintf(const fmagic fm, const char *f, ...)
+extern void file_printf(const fmagic fm, const char *f, ...)
/*@modifies fm @*/;
/*@observer@*/
-extern char *fmttime(long v, int local)
+extern const char *file_fmttime(uint32_t v, int local)
/*@*/;
-extern void magwarn(const char *f, ...)
+extern void file_magwarn(const char *f, ...)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
-extern void mdump(struct magic *m)
+extern void file_mdump(struct magic *m)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
-extern void showstr(FILE *fp, const char *s, int len)
+extern void file_showstr(FILE *fp, const char *s, size_t len)
/*@globals fileSystem @*/
/*@modifies fp, fileSystem @*/;
-extern uint32_t signextend(struct magic *m, uint32_t v)
+extern uint32_t file_signextend(struct magic *m, uint32_t v)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
-extern int pipe2file(int fd, void *startbuf, size_t nbytes)
+extern int file_pipe2file(int fd, const void *startbuf, size_t nbytes)
/*@globals errno, fileSystem, internalState @*/
/*@modifies errno, fileSystem, internalState @*/;
if (ret) {
/* Yes, I do mean stdout. */
/* No \n, caller will provide. */
- fmagicPrintf(fm, "can't stat `%s' (%s).", fn, strerror(errno));
+ file_printf(fm, "can't stat `%s' (%s).", fn, strerror(errno));
return 1;
}
if ((fm->flags & FMAGIC_FLAGS_MIME)) {
if ((st->st_mode & S_IFMT) != S_IFREG) {
- fmagicPrintf(fm, "application/x-not-regular-file");
+ file_printf(fm, "application/x-not-regular-file");
return 1;
}
}
else {
#if defined(S_ISUID) || defined(__LCLINT__)
- if (st->st_mode & S_ISUID) fmagicPrintf(fm, "setuid ");
+ if (st->st_mode & S_ISUID) file_printf(fm, "setuid ");
#endif
#if defined(S_ISGID) || defined(__LCLINT__)
- if (st->st_mode & S_ISGID) fmagicPrintf(fm, "setgid ");
+ if (st->st_mode & S_ISGID) file_printf(fm, "setgid ");
#endif
#if defined(S_ISVTX) || defined(__LCLINT__)
- if (st->st_mode & S_ISVTX) fmagicPrintf(fm, "sticky ");
+ if (st->st_mode & S_ISVTX) file_printf(fm, "sticky ");
#endif
}
switch (st->st_mode & S_IFMT) {
case S_IFDIR:
- fmagicPrintf(fm, "directory");
+ file_printf(fm, "directory");
return 1;
#if defined(S_IFCHR) || defined(__LCLINT__)
case S_IFCHR:
break;
#ifdef HAVE_STRUCT_STAT_ST_RDEV
# ifdef dv_unit
- fmagicPrintf(fm, "character special (%d/%d/%d)",
+ file_printf(fm, "character special (%d/%d/%d)",
major(st->st_rdev),
dv_unit(st->st_rdev),
dv_subunit(st->st_rdev));
# else
/*@-shiftimplementation@*/
- fmagicPrintf(fm, "character special (%ld/%ld)",
+ file_printf(fm, "character special (%ld/%ld)",
(long) major(st->st_rdev), (long) minor(st->st_rdev));
/*@=shiftimplementation@*/
# endif
#else
- fmagicPrintf(fm, "character special");
+ file_printf(fm, "character special");
#endif
return 1;
#endif
break;
#ifdef HAVE_STRUCT_STAT_ST_RDEV
# ifdef dv_unit
- fmagicPrintf(fm, "block special (%d/%d/%d)",
+ file_printf(fm, "block special (%d/%d/%d)",
major(st->st_rdev),
dv_unit(st->st_rdev),
dv_subunit(st->st_rdev));
# else
/*@-shiftimplementation@*/
- fmagicPrintf(fm, "block special (%ld/%ld)",
+ file_printf(fm, "block special (%ld/%ld)",
(long) major(st->st_rdev), (long) minor(st->st_rdev));
/*@=shiftimplementation@*/
# endif
#else
- fmagicPrintf(fm, "block special");
+ file_printf(fm, "block special");
#endif
return 1;
#endif
/* TODO add code to handle V7 MUX and Blit MUX files */
#if defined(S_IFIFO) || defined(__LCLINT__)
case S_IFIFO:
- fmagicPrintf(fm, "fifo (named pipe)");
+ file_printf(fm, "fifo (named pipe)");
return 1;
#endif
#if defined(S_IFDOOR)
case S_IFDOOR:
- fmagicPrintf(fm, "door");
+ file_printf(fm, "door");
return 1;
#endif
#if defined(S_IFLNK) || defined(__LCLINT__)
buf[0] = '\0';
if ((nch = readlink(fn, buf, BUFSIZ-1)) <= 0) {
- fmagicPrintf(fm, "unreadable symlink (%s).", strerror(errno));
+ file_printf(fm, "unreadable symlink (%s).", strerror(errno));
return 1;
}
buf[nch] = '\0'; /* readlink(2) needs this */
/*@-branchstate@*/
if (*buf == '/') {
if (stat(buf, &tstatbuf) < 0) {
- fmagicPrintf(fm, "broken symbolic link to %s", buf);
+ file_printf(fm, "broken symbolic link to %s", buf);
return 1;
}
}
tmp = buf2;
}
if (stat(tmp, &tstatbuf) < 0) {
- fmagicPrintf(fm, "broken symbolic link to %s", buf);
+ file_printf(fm, "broken symbolic link to %s", buf);
return 1;
}
}
/* Otherwise, handle it. */
if ((fm->flags & FMAGIC_FLAGS_FOLLOW)) {
- fmagicPrintf(fm, "\n");
+ file_printf(fm, "\n");
xx = fmagicProcess(fm, buf, strlen(buf));
return 1;
} else { /* just print what it points to */
- fmagicPrintf(fm, "symbolic link to %s", buf);
+ file_printf(fm, "symbolic link to %s", buf);
}
}
return 1;
#if defined(S_IFSOCK)
#ifndef __COHERENT__
case S_IFSOCK:
- fmagicPrintf(fm, "socket");
+ file_printf(fm, "socket");
return 1;
#endif
#endif
* when we read the file.)
*/
if (!(fm->flags & FMAGIC_FLAGS_SPECIAL) && st->st_size == 0) {
- fmagicPrintf(fm, ((fm->flags & FMAGIC_FLAGS_MIME)
+ file_printf(fm, ((fm->flags & FMAGIC_FLAGS_MIME)
? "application/x-empty" : "empty"));
return 1;
}
return 'a';
/* abandon hope, all ye who remain here */
- fmagicPrintf(fm, ((fm->flags & FMAGIC_FLAGS_MIME)
+ file_printf(fm, ((fm->flags & FMAGIC_FLAGS_MIME)
? "application/octet-stream" : "data"));
return '\0';
}
/*@=branchstate@*/
if (wid > 0 && !(fm->flags & FMAGIC_FLAGS_BRIEF))
- fmagicPrintf(fm, "%s:%*s ", fm->fn,
+ file_printf(fm, "%s:%*s ", fm->fn,
(int) (wid - strlen(fm->fn)), "");
if (fm->fn != stdname) {
if ((fm->fd = open(fm->fn, O_RDONLY)) < 0) {
/* We can't open it, but we were able to stat it. */
if (fm->sb.st_mode & 0002)
- fmagicPrintf(fm, "writeable, ");
+ file_printf(fm, "writeable, ");
if (fm->sb.st_mode & 0111)
- fmagicPrintf(fm, "executable, ");
- fmagicPrintf(fm, "can't read `%s' (%s).", fm->fn, strerror(errno));
+ file_printf(fm, "executable, ");
+ file_printf(fm, "can't read `%s' (%s).", fm->fn, strerror(errno));
goto exit;
}
}
}
if (fm->nb == 0)
- fmagicPrintf(fm, ((fm->flags & FMAGIC_FLAGS_MIME)
+ file_printf(fm, ((fm->flags & FMAGIC_FLAGS_MIME)
? "application/x-empty" : "empty"), fm);
else {
fm->buf[fm->nb++] = '\0'; /* null-terminate data buffer */
#ifndef COMPILE_ONLY
void
-mdump(struct magic *m)
+file_mdump(struct magic *m)
{
/*@observer@*/
static const char *typ[] = { "invalid", "byte", "short", "invalid",
((m->mask_op&0x7F) < SZOF(optyp)) ?
(void) fputc(optyp[m->mask_op&0x7F], stderr) :
(void) fputc('?', stderr);
- if (FILE_STRING != m->type || FILE_PSTRING != m->type)
+ if (m->type != FILE_STRING || m->type != FILE_PSTRING)
(void) fprintf(stderr, "%.8x", m->mask);
else {
if (m->mask & STRING_IGNORE_LOWERCASE)
case FILE_STRING:
case FILE_PSTRING:
case FILE_REGEX:
- showstr(stderr, m->value.s, -1);
+ file_showstr(stderr, m->value.s, ~0U);
break;
case FILE_DATE:
case FILE_LEDATE:
case FILE_BEDATE:
- (void)fprintf(stderr, "%s,", fmttime(m->value.l, 1));
+ (void)fprintf(stderr, "%s,",
+ file_fmttime(m->value.l, 1));
break;
case FILE_LDATE:
case FILE_LELDATE:
case FILE_BELDATE:
- (void)fprintf(stderr, "%s,", fmttime(m->value.l, 0));
+ (void)fprintf(stderr, "%s,",
+ file_fmttime(m->value.l, 0));
break;
default:
(void) fputs("*bad*", stderr);
/*VARARGS*/
void
-magwarn(const char *f, ...)
+file_magwarn(const char *f, ...)
{
fmagic fm = global_fmagic;
va_list va;
}
void
-fmagicPrintf(const fmagic fm, const char *f, ...)
+file_printf(const fmagic fm, const char *f, ...)
{
va_list va;
size_t nob;
#ifndef COMPILE_ONLY
-char *
-fmttime(long v, int local)
+const char *
+file_fmttime(uint32_t v, int local)
{
char *pp = "???";
char *rt;
/*@notreached@*/
}
if (shs_type == SHT_SYMTAB /* || shs_type == SHT_DYNSYM */) {
- fmagicPrintf(fm, ", not stripped");
+ file_printf(fm, ", not stripped");
return;
}
}
- fmagicPrintf(fm, ", stripped");
+ file_printf(fm, ", stripped");
}
/*@=bounds@*/
uint32_t *desc =
(uint32_t *)&nbuf[offset];
- fmagicPrintf(fm, ", for GNU/");
+ file_printf(fm, ", for GNU/");
switch (getu32(fm, desc[0])) {
case GNU_OS_LINUX:
- fmagicPrintf(fm, "Linux");
+ file_printf(fm, "Linux");
/*@switchbreak@*/ break;
case GNU_OS_HURD:
- fmagicPrintf(fm, "Hurd");
+ file_printf(fm, "Hurd");
/*@switchbreak@*/ break;
case GNU_OS_SOLARIS:
- fmagicPrintf(fm, "Solaris");
+ file_printf(fm, "Solaris");
/*@switchbreak@*/ break;
default:
- fmagicPrintf(fm, "<unknown>");
+ file_printf(fm, "<unknown>");
/*@switchbreak@*/ break;
}
- fmagicPrintf(fm, " %d.%d.%d",
+ file_printf(fm, " %d.%d.%d",
getu32(fm, desc[1]),
getu32(fm, desc[2]),
getu32(fm, desc[3]));
strcmp(&nbuf[nameoffset], "NetBSD") == 0 &&
nh_type == NT_NETBSD_VERSION &&
nh_descsz == 4) {
- fmagicPrintf(fm, ", for NetBSD");
+ file_printf(fm, ", for NetBSD");
/*
* Version number is stuck at 199905,
* and hence is basically content-free.
nh_descsz == 4) {
uint32_t desc = getu32(fm,
*(uint32_t *)&nbuf[offset]);
- fmagicPrintf(fm, ", for FreeBSD");
+ file_printf(fm, ", for FreeBSD");
/*
* Contents is __FreeBSD_version,
* whose relation to OS versions is
* FreeBSD that use this note.
*/
- fmagicPrintf(fm, " %d.%d", desc / 100000,
+ file_printf(fm, " %d.%d", desc / 100000,
desc / 10000 % 10);
if (desc / 1000 % 10 > 0)
- fmagicPrintf(fm, ".%d",
+ file_printf(fm, ".%d",
desc / 1000 % 10);
}
strcmp(&nbuf[nameoffset], "OpenBSD") == 0 &&
nh_type == NT_OPENBSD_VERSION &&
nh_descsz == 4) {
- fmagicPrintf(fm, ", for OpenBSD");
+ file_printf(fm, ", for OpenBSD");
/* Content of note is always 0 */
}
}
/*@switchbreak@*/ break;
}
}
- fmagicPrintf(fm, ", %s linked%s", linking_style, shared_libraries);
+ file_printf(fm, ", %s linked%s", linking_style, shared_libraries);
}
/*@=bounds@*/
os_style = OS_STYLE_NETBSD;
} else
/*@innercontinue@*/ continue;
- fmagicPrintf(fm, ", %s-style", os_style_names[os_style]);
+ file_printf(fm, ", %s-style", os_style_names[os_style]);
}
if (os_style == OS_STYLE_NETBSD &&
* offset 0x7c, and is up to 32-bytes,
* including the terminating NUL.
*/
- fmagicPrintf(fm, ", from '%.31s'", &nbuf[offset + 0x7c]);
+ file_printf(fm, ", from '%.31s'", &nbuf[offset + 0x7c]);
/*
* Extract the signal number. It is at
*/
memcpy(&signo, &nbuf[offset + 0x08],
sizeof(signo));
- fmagicPrintf(fm, " (signal %u)", getu32(fm, signo));
+ file_printf(fm, " (signal %u)", getu32(fm, signo));
} else
if (os_style != OS_STYLE_NETBSD &&
nh_type == NT_PRPSINFO) {
/*
* Well, that worked.
*/
- fmagicPrintf(fm, ", from '%.16s'",
+ file_printf(fm, ", from '%.16s'",
&nbuf[offset + prpsoffsets(i)]);
/*@innerbreak@*/ break;
* If we can't seek, it must be a pipe, socket or fifo.
*/
if((lseek(fm->fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE))
- fm->fd = pipe2file(fm->fd, fm->buf, fm->nb);
+ fm->fd = file_pipe2file(fm->fd, fm->buf, fm->nb);
/*
* ELF executables have multiple section headers in arbitrary
switch (m->type) {
case FILE_BYTE:
- v = signextend(m, p->b);
- fmagicPrintf(fm, m->desc, (unsigned char) v);
+ v = file_signextend(m, p->b);
+ file_printf(fm, m->desc, (unsigned char) v);
/*@-sizeoftype@*/
t = m->offset + sizeof(char);
/*@=sizeoftype@*/
case FILE_SHORT:
case FILE_BESHORT:
case FILE_LESHORT:
- v = signextend(m, p->h);
- fmagicPrintf(fm, m->desc, (unsigned short) v);
+ v = file_signextend(m, p->h);
+ file_printf(fm, m->desc, (unsigned short) v);
/*@-sizeoftype@*/
t = m->offset + sizeof(short);
/*@=sizeoftype@*/
case FILE_LONG:
case FILE_BELONG:
case FILE_LELONG:
- v = signextend(m, p->l);
- fmagicPrintf(fm, m->desc, (uint32_t) v);
+ v = file_signextend(m, p->l);
+ file_printf(fm, m->desc, (uint32_t) v);
/*@-sizeoftype@*/
t = m->offset + sizeof(int32_t);
/*@=sizeoftype@*/
case FILE_STRING:
case FILE_PSTRING:
if (m->reln == '=') {
- fmagicPrintf(fm, m->desc, m->value.s);
+ file_printf(fm, m->desc, m->value.s);
t = m->offset + strlen(m->value.s);
} else {
if (*m->value.s == '\0') {
if (cp != NULL)
*cp = '\0';
}
- fmagicPrintf(fm, m->desc, p->s);
+ file_printf(fm, m->desc, p->s);
t = m->offset + strlen(p->s);
}
break;
case FILE_DATE:
case FILE_BEDATE:
case FILE_LEDATE:
- fmagicPrintf(fm, m->desc, fmttime(p->l, 1));
+ file_printf(fm, m->desc, file_fmttime(p->l, 1));
/*@-sizeoftype@*/
t = m->offset + sizeof(time_t);
/*@=sizeoftype@*/
case FILE_LDATE:
case FILE_BELDATE:
case FILE_LELDATE:
- fmagicPrintf(fm, m->desc, fmttime(p->l, 0));
+ file_printf(fm, m->desc, file_fmttime(p->l, 0));
/*@-sizeoftype@*/
t = m->offset + sizeof(time_t);
/*@=sizeoftype@*/
break;
case FILE_REGEX:
- fmagicPrintf(fm, m->desc, p->s);
+ file_printf(fm, m->desc, p->s);
t = m->offset + strlen(p->s);
break;
static void
-fmagicSDebug(int32_t offset, char *str, int len)
+fmagicSDebug(int32_t offset, char *str, size_t len)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
(void) fprintf(stderr, "fmagicSGet @%d: ", offset);
- showstr(stderr, (char *) str, len);
+ file_showstr(stderr, (char *) str, len);
(void) fputc('\n', stderr);
(void) fputc('\n', stderr);
}
if (fm->flags & FMAGIC_FLAGS_DEBUG) {
fmagicSDebug(offset, (char *) p, sizeof(*p));
- mdump(m);
+ file_mdump(m);
}
if (m->flag & INDIR) {
if (fm->flags & FMAGIC_FLAGS_DEBUG) {
fmagicSDebug(offset, (char *) p, sizeof(*p));
- mdump(m);
+ file_mdump(m);
}
}
/*@-compmempass@*/
return 0;
}
- if(m->type != FILE_STRING && m->type != FILE_PSTRING)
- v = signextend(m, v);
+ if (m->type != FILE_STRING && m->type != FILE_PSTRING)
+ v = file_signextend(m, v);
switch (m->reln) {
case 'x':
if (! firstline) { /* we found another match */
/* put a newline and '-' to do some simple formatting */
- fmagicPrintf(fm, "\n- ");
+ file_printf(fm, "\n- ");
}
if ((cont_level+1) >= tmplen) {
if (need_separator
&& (m->nospflag == 0) && (m->desc[0] != '\0'))
{
- fmagicPrintf(fm, " ");
+ file_printf(fm, " ");
need_separator = 0;
}
if ((cont_level+1) >= tmplen) {