diff options
Diffstat (limited to 'src/print.c')
-rw-r--r-- | src/print.c | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/src/print.c b/src/print.c index d2a7bf84..6b019eba 100644 --- a/src/print.c +++ b/src/print.c @@ -41,7 +41,7 @@ #include <time.h> #ifndef lint -FILE_RCSID("@(#)$File: print.c,v 1.57 2007/01/12 17:38:28 christos Exp $") +FILE_RCSID("@(#)$File: print.c,v 1.58 2007/01/16 14:58:48 ljt Exp $") #endif /* lint */ #define SZOF(a) (sizeof(a) / sizeof(a[0])) @@ -64,8 +64,8 @@ file_mdump(struct magic *m) 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] : '?', + ((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 * |