diff options
Diffstat (limited to 'contrib/file/print.c')
-rw-r--r-- | contrib/file/print.c | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/contrib/file/print.c b/contrib/file/print.c index 28cca18..d1d1ec1 100644 --- a/contrib/file/print.c +++ b/contrib/file/print.c @@ -41,7 +41,7 @@ #include <time.h> #ifndef lint -FILE_RCSID("@(#)$Id: print.c,v 1.56 2006/12/08 20:31:07 christos Exp $") +FILE_RCSID("@(#)$File: print.c,v 1.59 2007/03/05 02:41:29 christos Exp $") #endif /* lint */ #define SZOF(a) (sizeof(a) / sizeof(a[0])) @@ -52,8 +52,8 @@ file_mdump(struct magic *m) { private const char optyp[] = { FILE_OPS }; - (void) fprintf(stderr, "[%zu", m->lineno); - (void) fprintf(stderr, ">>>>>>>> %d" + 8 - (m->cont_level & 7), + (void) fprintf(stderr, "[%u", m->lineno); + (void) fprintf(stderr, ">>>>>>>> %u" + 8 - (m->cont_level & 7), m->offset); if (m->flag & INDIR) { @@ -63,9 +63,9 @@ file_mdump(struct magic *m) file_names[m->in_type] : "*bad*"); if (m->in_op & FILE_OPINVERSE) (void) fputc('~', stderr); - (void) fprintf(stderr, "%c%d),", - ((m->in_op&0x7F) < SZOF(optyp)) ? - optyp[m->in_op&0x7F] : '?', + (void) fprintf(stderr, "%c%u),", + ((m->in_op & FILE_OPS_MASK) < SZOF(optyp)) ? + optyp[m->in_op & FILE_OPS_MASK] : '?', m->in_offset); } (void) fprintf(stderr, " %s%s", (m->flag & UNSIGNED) ? "u" : "", @@ -73,25 +73,36 @@ file_mdump(struct magic *m) (m->type < file_nnames) ? file_names[m->type] : "*bad*"); if (m->mask_op & FILE_OPINVERSE) (void) fputc('~', stderr); - if (m->mask) { - if ((m->mask_op & 0x7F) < SZOF(optyp)) - fputc(optyp[m->mask_op&0x7F], stderr); - else - fputc('?', stderr); - if (FILE_STRING != m->type || FILE_PSTRING != m->type) - (void) fprintf(stderr, "%.8llx", - (unsigned long long)m->mask); - else { - if (m->mask & STRING_IGNORE_LOWERCASE) - (void) fputc(CHAR_IGNORE_LOWERCASE, stderr); - if (m->mask & STRING_COMPACT_BLANK) + + if (IS_STRING(m->type)) { + if (m->str_flags) { + (void) fputc('/', stderr); + if (m->str_flags & STRING_COMPACT_BLANK) (void) fputc(CHAR_COMPACT_BLANK, stderr); - if (m->mask & STRING_COMPACT_OPTIONAL_BLANK) + if (m->str_flags & STRING_COMPACT_OPTIONAL_BLANK) (void) fputc(CHAR_COMPACT_OPTIONAL_BLANK, - stderr); + stderr); + if (m->str_flags & STRING_IGNORE_LOWERCASE) + (void) fputc(CHAR_IGNORE_LOWERCASE, stderr); + if (m->str_flags & STRING_IGNORE_UPPERCASE) + (void) fputc(CHAR_IGNORE_UPPERCASE, stderr); + if (m->str_flags & REGEX_OFFSET_START) + (void) fputc(CHAR_REGEX_OFFSET_START, stderr); + } + if (m->str_count) + (void) fprintf(stderr, "/%u", m->str_count); + } + else { + if ((m->mask_op & FILE_OPS_MASK) < SZOF(optyp)) + (void) fputc(optyp[m->mask_op & FILE_OPS_MASK], stderr); + else + (void) fputc('?', stderr); + + if (m->num_mask) { + (void) fprintf(stderr, "%.8llx", + (unsigned long long)m->num_mask); } } - (void) fprintf(stderr, ",%c", m->reln); if (m->reln != 'x') { @@ -146,6 +157,9 @@ file_mdump(struct magic *m) (void)fprintf(stderr, "%s,", file_fmttime((uint32_t)m->value.q, 0)); break; + case FILE_DEFAULT: + /* XXX - do anything here? */ + break; default: (void) fputs("*bad*", stderr); break; @@ -169,7 +183,7 @@ file_magwarn(struct magic_set *ms, const char *f, ...) (unsigned long)ms->line); (void) vfprintf(stderr, f, va); va_end(va); - fputc('\n', stderr); + (void) fputc('\n', stderr); } protected const char * |