diff options
-rw-r--r-- | usr.bin/file/apprentice.c | 10 | ||||
-rw-r--r-- | usr.bin/file/file.h | 20 | ||||
-rw-r--r-- | usr.bin/file/readelf.c | 6 | ||||
-rw-r--r-- | usr.bin/file/softmagic.c | 46 |
4 files changed, 39 insertions, 43 deletions
diff --git a/usr.bin/file/apprentice.c b/usr.bin/file/apprentice.c index e484243bec1..482eb0a7484 100644 --- a/usr.bin/file/apprentice.c +++ b/usr.bin/file/apprentice.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apprentice.c,v 1.13 2002/03/14 06:51:41 mpech Exp $ */ +/* $OpenBSD: apprentice.c,v 1.14 2002/06/05 13:46:44 itojun Exp $ */ /* * apprentice - make one pass through /etc/magic, learning its secrets. @@ -36,7 +36,7 @@ #include "file.h" #ifndef lint -static char *moduleid = "$OpenBSD: apprentice.c,v 1.13 2002/03/14 06:51:41 mpech Exp $"; +static char *moduleid = "$OpenBSD: apprentice.c,v 1.14 2002/06/05 13:46:44 itojun Exp $"; #endif /* lint */ #define EATAB {while (isascii((unsigned char) *l) && \ @@ -133,10 +133,10 @@ int check; /* non-zero? checking-only run. */ /* * extend the sign bit if the comparison is to be signed */ -uint32 +uint32_t signextend(m, v) struct magic *m; -uint32 v; +uint32_t v; { if (!(m->flag & UNSIGNED)) switch(m->type) { @@ -159,7 +159,7 @@ uint32 v; case LONG: case BELONG: case LELONG: - v = (int32) v; + v = (int32_t) v; break; case STRING: break; diff --git a/usr.bin/file/file.h b/usr.bin/file/file.h index 16621dbfe0a..8f5c9071fed 100644 --- a/usr.bin/file/file.h +++ b/usr.bin/file/file.h @@ -1,4 +1,4 @@ -/* $OpenBSD: file.h,v 1.9 2002/02/17 19:42:30 millert Exp $ */ +/* $OpenBSD: file.h,v 1.10 2002/06/05 13:46:44 itojun Exp $ */ /* * file.h - definitions for file(1) program @@ -30,10 +30,6 @@ #ifndef __file_h__ #define __file_h__ -typedef int8_t int8; -typedef int32_t int32; -typedef u_int32_t uint32; - #ifndef HOWMANY # define HOWMANY 8192 /* how much of the file to look at */ #endif @@ -48,12 +44,12 @@ struct magic { #define ADD 4 /* if '>&' appears, */ short cont_level; /* level of ">" */ struct { - int8 type; /* byte short long */ - int32 offset; /* offset from indirection */ + int8_t type; /* byte short long */ + int32_t offset; /* offset from indirection */ } in; - int32 offset; /* offset to magic number */ + int32_t offset; /* offset to magic number */ unsigned char reln; /* relation (0=eq, '>'=gt, etc) */ - int8 type; /* int, short, long or string. */ + int8_t type; /* int, short, long or string. */ char vallen; /* length of string value, if any */ #define BYTE 1 #define SHORT 2 @@ -69,12 +65,12 @@ struct magic { union VALUETYPE { unsigned char b; unsigned short h; - uint32 l; + uint32_t l; char s[MAXstring]; unsigned char hs[2]; /* 2 bytes of a fixed-endian "short" */ unsigned char hl[4]; /* 2 bytes of a fixed-endian "long" */ } value; /* either number or string */ - uint32 mask; /* mask before comparison with value */ + uint32_t mask; /* mask before comparison with value */ char nospflag; /* supress space character */ char desc[MAXDESC]; /* description */ }; @@ -93,7 +89,7 @@ extern int softmagic(unsigned char *, int); extern int tryit(unsigned char *, int, int); extern int zmagic(unsigned char *, int); extern void ckfprintf(FILE *, const char *, ...); -extern uint32 signextend(struct magic *, unsigned int32); +extern uint32_t signextend(struct magic *, uint32_t); extern int internatmagic(unsigned char *, int); extern void tryelf(int, char *, int); diff --git a/usr.bin/file/readelf.c b/usr.bin/file/readelf.c index d6ee631de6d..6d7ea277202 100644 --- a/usr.bin/file/readelf.c +++ b/usr.bin/file/readelf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readelf.c,v 1.2 1998/07/10 15:05:26 mickey Exp $ */ +/* $OpenBSD: readelf.c,v 1.3 2002/06/05 13:46:44 itojun Exp $ */ #ifdef BUILTIN_ELF #include <sys/types.h> @@ -227,8 +227,8 @@ tryelf(fd, buf, nbytes) int nbytes; { union { - int32 l; - char c[sizeof (int32)]; + int32_t l; + char c[sizeof (int32_t)]; } u; /* diff --git a/usr.bin/file/softmagic.c b/usr.bin/file/softmagic.c index 7fed8964877..8a6e8af579f 100644 --- a/usr.bin/file/softmagic.c +++ b/usr.bin/file/softmagic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softmagic.c,v 1.7 2002/02/17 19:42:30 millert Exp $ */ +/* $OpenBSD: softmagic.c,v 1.8 2002/06/05 13:46:44 itojun Exp $ */ /* * softmagic - interpret variable magic from /etc/magic @@ -37,14 +37,14 @@ #include "file.h" #ifndef lint -static char *moduleid = "$OpenBSD: softmagic.c,v 1.7 2002/02/17 19:42:30 millert Exp $"; +static char *moduleid = "$OpenBSD: softmagic.c,v 1.8 2002/06/05 13:46:44 itojun Exp $"; #endif /* lint */ static int match(unsigned char *, int); static int mget(union VALUETYPE *, unsigned char *, struct magic *, int); static int mcheck(union VALUETYPE *, struct magic *); -static int32 mprint(union VALUETYPE *, struct magic *); -static void mdebug(int32, char *, int); +static int32_t mprint(union VALUETYPE *, struct magic *); +static void mdebug(int32_t, char *, int); static int mconvert(union VALUETYPE *, struct magic *); /* @@ -100,12 +100,12 @@ int nbytes; int cont_level = 0; int need_separator = 0; union VALUETYPE p; - static int32 *tmpoff = NULL; + static int32_t *tmpoff = NULL; static size_t tmplen = 0; - int32 oldoff = 0; + int32_t oldoff = 0; if (tmpoff == NULL) - if ((tmpoff = (int32 *) malloc(tmplen = 20)) == NULL) + if ((tmpoff = (int32_t *) malloc(tmplen = 20)) == NULL) err(1, "malloc"); for (magindex = 0; magindex < nmagic; magindex++) { @@ -131,7 +131,7 @@ int nbytes; need_separator = 1; /* and any continuations that match */ if (++cont_level >= tmplen) - if ((tmpoff = (int32 *) realloc(tmpoff, + if ((tmpoff = (int32_t *) realloc(tmpoff, tmplen += 20)) == NULL) err(1, "malloc"); while (magic[magindex+1].cont_level != 0 && @@ -176,7 +176,7 @@ int nbytes; */ if (++cont_level >= tmplen) if ((tmpoff = - (int32 *) realloc(tmpoff, + (int32_t *) realloc(tmpoff, tmplen += 20)) == NULL) err(1, "malloc"); } @@ -190,14 +190,14 @@ int nbytes; return 0; /* no match at all */ } -static int32 +static int32_t mprint(p, m) union VALUETYPE *p; struct magic *m; { char *pp, *rt; - uint32 v; - int32 t=0 ; + uint32_t v; + int32_t t=0 ; switch (m->type) { @@ -222,8 +222,8 @@ struct magic *m; case LELONG: v = p->l; v = signextend(m, v) & m->mask; - (void) printf(m->desc, (uint32) v); - t = m->offset + sizeof(int32); + (void) printf(m->desc, (uint32_t) v); + t = m->offset + sizeof(int32_t); break; case STRING: @@ -288,7 +288,7 @@ struct magic *m; return 1; case BELONG: case BEDATE: - p->l = (int32) + p->l = (int32_t) ((p->hl[0]<<24)|(p->hl[1]<<16)|(p->hl[2]<<8)|(p->hl[3])); return 1; case LESHORT: @@ -296,7 +296,7 @@ struct magic *m; return 1; case LELONG: case LEDATE: - p->l = (int32) + p->l = (int32_t) ((p->hl[3]<<24)|(p->hl[2]<<16)|(p->hl[1]<<8)|(p->hl[0])); return 1; default: @@ -308,7 +308,7 @@ struct magic *m; static void mdebug(offset, str, len) -int32 offset; +int32_t offset; char *str; int len; { @@ -325,7 +325,7 @@ unsigned char *s; struct magic *m; int nbytes; { - int32 offset = m->offset; + int32_t offset = m->offset; if (offset + sizeof(union VALUETYPE) <= nbytes) memcpy(p, s + offset, sizeof(union VALUETYPE)); @@ -334,7 +334,7 @@ int nbytes; * the usefulness of padding with zeroes eludes me, it * might even cause problems */ - int32 have = nbytes - offset; + int32_t have = nbytes - offset; memset(p, 0, sizeof(union VALUETYPE)); if (have > 0) memcpy(p, s + offset, have); @@ -384,8 +384,8 @@ mcheck(p, m) union VALUETYPE* p; struct magic *m; { - uint32 l = m->value.l; - uint32 v; + uint32_t l = m->value.l; + uint32_t v; int matched; if ( (m->value.s[0] == 'x') && (m->value.s[1] == '\0') ) { @@ -468,7 +468,7 @@ struct magic *m; v, l, matched); } else { - matched = (int32) v > (int32) l; + matched = (int32_t) v > (int32_t) l; if (debug) (void) fprintf(stderr, "%d > %d = %d\n", v, l, matched); @@ -483,7 +483,7 @@ struct magic *m; v, l, matched); } else { - matched = (int32) v < (int32) l; + matched = (int32_t) v < (int32_t) l; if (debug) (void) fprintf(stderr, "%d < %d = %d\n", v, l, matched); |