summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rw-r--r--Makefile.in8
-rwxr-xr-xconfigure178
-rw-r--r--configure.in1
-rw-r--r--doc/file.man60
-rw-r--r--doc/magic.man52
-rw-r--r--src/apprentice.c151
-rw-r--r--src/ascmagic.c61
-rw-r--r--src/compress.c44
-rw-r--r--src/file.c83
-rw-r--r--src/file.h114
-rw-r--r--src/fsmagic.c7
-rw-r--r--src/is_tar.c15
-rw-r--r--src/print.c51
-rw-r--r--src/readelf.c63
-rw-r--r--src/readelf.h4
-rw-r--r--src/softmagic.c116
17 files changed, 424 insertions, 585 deletions
diff --git a/Makefile.am b/Makefile.am
index 820e33e6..b16d2bba 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -139,6 +139,7 @@ Magdir/mips \
Magdir/mirage \
Magdir/mkid \
Magdir/mmdf \
+Magdir/mlssa \
Magdir/modem \
Magdir/motorola \
Magdir/msdos \
diff --git a/Makefile.in b/Makefile.in
index e65f44fd..737ab83f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,6 +1,6 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -86,7 +86,7 @@ EXTRA_DIST = LEGAL.NOTICE MAINT PORTING Makefile.std magic2mime Localstuff Head
CLEANFILES = $(man_MANS) magic magic.mgc magic.mime.mgc
-magic_FRAGMENTS = Magdir/acorn Magdir/adi Magdir/adventure Magdir/allegro Magdir/alliant Magdir/alpha Magdir/amanda Magdir/amigaos Magdir/animation Magdir/apl Magdir/apple Magdir/applix Magdir/archive Magdir/asterix Magdir/att3b Magdir/audio Magdir/blender Magdir/blit Magdir/bsdi Magdir/c-lang Magdir/chi Magdir/cisco Magdir/citrus Magdir/claris Magdir/clipper Magdir/commands Magdir/compress Magdir/console Magdir/convex Magdir/ctags Magdir/cvs Magdir/database Magdir/diamond Magdir/diff Magdir/digital Magdir/dolby Magdir/dump Magdir/dyadic Magdir/editors Magdir/elf Magdir/encore Magdir/epoc Magdir/filesystems Magdir/flash Magdir/fonts Magdir/frame Magdir/freebsd Magdir/fsav Magdir/gimp Magdir/gnu Magdir/grace Magdir/gringotts Magdir/hitachi-sh Magdir/hp Magdir/ibm370 Magdir/ibm6000 Magdir/iff Magdir/images Magdir/intel Magdir/interleaf Magdir/island Magdir/ispell Magdir/java Magdir/jpeg Magdir/karma Magdir/lecter Magdir/lex Magdir/lif Magdir/linux Magdir/lisp Magdir/mach Magdir/macintosh Magdir/magic Magdir/mail.news Magdir/maple Magdir/mathematica Magdir/mcrypt Magdir/mime Magdir/mips Magdir/mirage Magdir/mkid Magdir/mmdf Magdir/modem Magdir/motorola Magdir/msdos Magdir/msvc Magdir/natinst Magdir/ncr Magdir/netbsd Magdir/netscape Magdir/news Magdir/nitpicker Magdir/octave Magdir/olf Magdir/os2 Magdir/os9 Magdir/osf1 Magdir/palm Magdir/parix Magdir/pbm Magdir/pdf Magdir/pdp Magdir/perl Magdir/pgp Magdir/pkgadd Magdir/plus5 Magdir/printer Magdir/project Magdir/psdbms Magdir/pulsar Magdir/pyramid Magdir/python Magdir/riff Magdir/rpm Magdir/rtf Magdir/sc Magdir/sccs Magdir/sendmail Magdir/sequent Magdir/sgml Magdir/sharc Magdir/sketch Magdir/smalltalk Magdir/sniffer Magdir/softquad Magdir/spectrum Magdir/sun Magdir/sysex Magdir/teapot Magdir/terminfo Magdir/tex Magdir/tgif Magdir/ti-8x Magdir/timezone Magdir/troff Magdir/tuxedo Magdir/typeset Magdir/unknown Magdir/uuencode Magdir/varied.out Magdir/vax Magdir/vicar Magdir/visx Magdir/vms Magdir/vmware Magdir/vorbis Magdir/vxl Magdir/wordperfect Magdir/xdelta Magdir/xenix Magdir/zilog Magdir/zyxel
+magic_FRAGMENTS = Magdir/acorn Magdir/adi Magdir/adventure Magdir/allegro Magdir/alliant Magdir/alpha Magdir/amanda Magdir/amigaos Magdir/animation Magdir/apl Magdir/apple Magdir/applix Magdir/archive Magdir/asterix Magdir/att3b Magdir/audio Magdir/blender Magdir/blit Magdir/bsdi Magdir/c-lang Magdir/chi Magdir/cisco Magdir/citrus Magdir/claris Magdir/clipper Magdir/commands Magdir/compress Magdir/console Magdir/convex Magdir/ctags Magdir/cvs Magdir/database Magdir/diamond Magdir/diff Magdir/digital Magdir/dolby Magdir/dump Magdir/dyadic Magdir/editors Magdir/elf Magdir/encore Magdir/epoc Magdir/filesystems Magdir/flash Magdir/fonts Magdir/frame Magdir/freebsd Magdir/fsav Magdir/gimp Magdir/gnu Magdir/grace Magdir/gringotts Magdir/hitachi-sh Magdir/hp Magdir/ibm370 Magdir/ibm6000 Magdir/iff Magdir/images Magdir/intel Magdir/interleaf Magdir/island Magdir/ispell Magdir/java Magdir/jpeg Magdir/karma Magdir/lecter Magdir/lex Magdir/lif Magdir/linux Magdir/lisp Magdir/mach Magdir/macintosh Magdir/magic Magdir/mail.news Magdir/maple Magdir/mathematica Magdir/mcrypt Magdir/mime Magdir/mips Magdir/mirage Magdir/mkid Magdir/mmdf Magdir/mlssa Magdir/modem Magdir/motorola Magdir/msdos Magdir/msvc Magdir/natinst Magdir/ncr Magdir/netbsd Magdir/netscape Magdir/news Magdir/nitpicker Magdir/octave Magdir/olf Magdir/os2 Magdir/os9 Magdir/osf1 Magdir/palm Magdir/parix Magdir/pbm Magdir/pdf Magdir/pdp Magdir/perl Magdir/pgp Magdir/pkgadd Magdir/plus5 Magdir/printer Magdir/project Magdir/psdbms Magdir/pulsar Magdir/pyramid Magdir/python Magdir/riff Magdir/rpm Magdir/rtf Magdir/sc Magdir/sccs Magdir/sendmail Magdir/sequent Magdir/sgml Magdir/sharc Magdir/sketch Magdir/smalltalk Magdir/sniffer Magdir/softquad Magdir/spectrum Magdir/sun Magdir/sysex Magdir/teapot Magdir/terminfo Magdir/tex Magdir/tgif Magdir/ti-8x Magdir/timezone Magdir/troff Magdir/tuxedo Magdir/typeset Magdir/unknown Magdir/uuencode Magdir/varied.out Magdir/vax Magdir/vicar Magdir/visx Magdir/vms Magdir/vmware Magdir/vorbis Magdir/vxl Magdir/wordperfect Magdir/xdelta Magdir/xenix Magdir/zilog Magdir/zyxel
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -122,7 +122,7 @@ missing mkinstalldirs
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-TAR = tar
+TAR = gtar
GZIP_ENV = --best
SOURCES = $(file_SOURCES)
OBJECTS = $(file_OBJECTS)
diff --git a/configure b/configure
index a7326e77..f3d36281 100755
--- a/configure
+++ b/configure
@@ -1748,14 +1748,54 @@ else
fi
done
+for ac_hdr in stdint.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1756: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1761 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1766: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1754: checking for working const" >&5
+echo "configure:1794: checking for working const" >&5
if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1759 "configure"
+#line 1799 "configure"
#include "confdefs.h"
int main() {
@@ -1804,7 +1844,7 @@ ccp = (char const *const *) p;
; return 0; }
EOF
-if { (eval echo configure:1808: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1848: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_const=yes
else
@@ -1825,12 +1865,12 @@ EOF
fi
echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:1829: checking for off_t" >&5
+echo "configure:1869: checking for off_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1834 "configure"
+#line 1874 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -1858,12 +1898,12 @@ EOF
fi
echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:1862: checking for size_t" >&5
+echo "configure:1902: checking for size_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1867 "configure"
+#line 1907 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -1891,12 +1931,12 @@ EOF
fi
echo $ac_n "checking for st_rdev in struct stat""... $ac_c" 1>&6
-echo "configure:1895: checking for st_rdev in struct stat" >&5
+echo "configure:1935: checking for st_rdev in struct stat" >&5
if eval "test \"`echo '$''{'ac_cv_struct_st_rdev'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1900 "configure"
+#line 1940 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -1904,7 +1944,7 @@ int main() {
struct stat s; s.st_rdev;
; return 0; }
EOF
-if { (eval echo configure:1908: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1948: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_rdev=yes
else
@@ -1925,12 +1965,12 @@ EOF
fi
echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:1929: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:1969: checking whether struct tm is in sys/time.h or time.h" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1934 "configure"
+#line 1974 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <time.h>
@@ -1938,7 +1978,7 @@ int main() {
struct tm *tp; tp->tm_sec;
; return 0; }
EOF
-if { (eval echo configure:1942: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1982: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm=time.h
else
@@ -1959,12 +1999,12 @@ EOF
fi
echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:1963: checking for tm_zone in struct tm" >&5
+echo "configure:2003: checking for tm_zone in struct tm" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1968 "configure"
+#line 2008 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_cv_struct_tm>
@@ -1972,7 +2012,7 @@ int main() {
struct tm tm; tm.tm_zone;
; return 0; }
EOF
-if { (eval echo configure:1976: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2016: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm_zone=yes
else
@@ -1992,12 +2032,12 @@ EOF
fi
echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:1996: checking for tzname" >&5
+echo "configure:2036: checking for tzname" >&5
if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2001 "configure"
+#line 2041 "configure"
#include "confdefs.h"
#include <time.h>
#ifndef tzname /* For SGI. */
@@ -2007,7 +2047,7 @@ int main() {
atoi(*tzname);
; return 0; }
EOF
-if { (eval echo configure:2011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2051: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_var_tzname=yes
else
@@ -2028,12 +2068,12 @@ EOF
fi
echo $ac_n "checking for tm_isdst in struct tm""... $ac_c" 1>&6
-echo "configure:2032: checking for tm_isdst in struct tm" >&5
+echo "configure:2072: checking for tm_isdst in struct tm" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm_isdst'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2037 "configure"
+#line 2077 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_cv_struct_tm>
@@ -2041,7 +2081,7 @@ int main() {
struct tm tm; tm.tm_isdst;
; return 0; }
EOF
-if { (eval echo configure:2045: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2085: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm_isdst=yes
else
@@ -2061,12 +2101,12 @@ EOF
fi
echo $ac_n "checking for daylight""... $ac_c" 1>&6
-echo "configure:2065: checking for daylight" >&5
+echo "configure:2105: checking for daylight" >&5
if eval "test \"`echo '$''{'ac_cv_var_daylight'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2070 "configure"
+#line 2110 "configure"
#include "confdefs.h"
#include <time.h>
#ifndef daylight /* In case IRIX #defines this, too */
@@ -2076,7 +2116,7 @@ int main() {
atoi(daylight);
; return 0; }
EOF
-if { (eval echo configure:2080: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_var_daylight=yes
else
@@ -2107,7 +2147,7 @@ fi
echo $ac_n "checking for special C compiler options needed for large files=
""... $ac_c" 1>&6
-echo "configure:2111: checking for special C compiler options needed for large files=
+echo "configure:2151: checking for special C compiler options needed for large files=
" >&5
if eval "test \"`echo '$''{'ac_cv_sys_largefile_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2117,7 +2157,7 @@ else
# IRIX 6.2 and later do not support large files by default,
# so use the C compiler's -n32 option if that helps.
cat > conftest.$ac_ext <<EOF
-#line 2121 "configure"
+#line 2161 "configure"
#include "confdefs.h"
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
@@ -2133,7 +2173,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:2137: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2177: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
:
else
echo "configure: failed program was:" >&5
@@ -2142,7 +2182,7 @@ else
ac_save_CC="$CC"
CC="$CC -n32"
cat > conftest.$ac_ext <<EOF
-#line 2146 "configure"
+#line 2186 "configure"
#include "confdefs.h"
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
@@ -2158,7 +2198,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:2162: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2202: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_sys_largefile_CC=' -n32'
else
@@ -2178,13 +2218,13 @@ echo "$ac_t""$ac_cv_sys_largefile_CC" 1>&6
fi
echo $ac_n "checking for _FILE_OFFSET_BITS value needed for large files""... $ac_c" 1>&6
-echo "configure:2182: checking for _FILE_OFFSET_BITS value needed for large files" >&5
+echo "configure:2222: checking for _FILE_OFFSET_BITS value needed for large files" >&5
if eval "test \"`echo '$''{'ac_cv_sys_file_offset_bits'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_sys_file_offset_bits=no
cat > conftest.$ac_ext <<EOF
-#line 2188 "configure"
+#line 2228 "configure"
#include "confdefs.h"
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
@@ -2200,14 +2240,14 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:2204: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2244: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
:
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
cat > conftest.$ac_ext <<EOF
-#line 2211 "configure"
+#line 2251 "configure"
#include "confdefs.h"
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
@@ -2225,7 +2265,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:2229: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2269: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_sys_file_offset_bits=64
else
@@ -2245,13 +2285,13 @@ EOF
fi
echo $ac_n "checking for _LARGE_FILES value needed for large files""... $ac_c" 1>&6
-echo "configure:2249: checking for _LARGE_FILES value needed for large files" >&5
+echo "configure:2289: checking for _LARGE_FILES value needed for large files" >&5
if eval "test \"`echo '$''{'ac_cv_sys_large_files'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_sys_large_files=no
cat > conftest.$ac_ext <<EOF
-#line 2255 "configure"
+#line 2295 "configure"
#include "confdefs.h"
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
@@ -2267,14 +2307,14 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:2271: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2311: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
:
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
cat > conftest.$ac_ext <<EOF
-#line 2278 "configure"
+#line 2318 "configure"
#include "confdefs.h"
#define _LARGE_FILES 1
#include <sys/types.h>
@@ -2292,7 +2332,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:2296: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2336: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_sys_large_files=1
else
@@ -2315,12 +2355,12 @@ EOF
echo $ac_n "checking for uint8_t""... $ac_c" 1>&6
-echo "configure:2319: checking for uint8_t" >&5
+echo "configure:2359: checking for uint8_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_uint8_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2324 "configure"
+#line 2364 "configure"
#include "confdefs.h"
#if HAVE_STDINT_H
#include <stdint.h>
@@ -2351,12 +2391,12 @@ EOF
fi
echo $ac_n "checking for uint16_t""... $ac_c" 1>&6
-echo "configure:2355: checking for uint16_t" >&5
+echo "configure:2395: checking for uint16_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_uint16_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2360 "configure"
+#line 2400 "configure"
#include "confdefs.h"
#if HAVE_STDINT_H
#include <stdint.h>
@@ -2387,12 +2427,12 @@ EOF
fi
echo $ac_n "checking for uint32_t""... $ac_c" 1>&6
-echo "configure:2391: checking for uint32_t" >&5
+echo "configure:2431: checking for uint32_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_uint32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2396 "configure"
+#line 2436 "configure"
#include "confdefs.h"
#if HAVE_STDINT_H
#include <stdint.h>
@@ -2423,7 +2463,7 @@ EOF
fi
echo $ac_n "checking for long long""... $ac_c" 1>&6
-echo "configure:2427: checking for long long" >&5
+echo "configure:2467: checking for long long" >&5
if eval "test \"`echo '$''{'ac_cv_c_long_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2434,13 +2474,13 @@ if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 2438 "configure"
+#line 2478 "configure"
#include "confdefs.h"
int main() {
long long foo = 0;
exit(sizeof(long long) < sizeof(long)); }
EOF
-if { (eval echo configure:2444: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2484: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_long_long=yes
else
@@ -2469,12 +2509,12 @@ else
long64='unsigned long';
fi
echo $ac_n "checking for uint64_t""... $ac_c" 1>&6
-echo "configure:2473: checking for uint64_t" >&5
+echo "configure:2513: checking for uint64_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_uint64_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2478 "configure"
+#line 2518 "configure"
#include "confdefs.h"
#if HAVE_STDINT_H
#include <stdint.h>
@@ -2508,7 +2548,7 @@ fi
echo $ac_n "checking size of uint8_t""... $ac_c" 1>&6
-echo "configure:2512: checking size of uint8_t" >&5
+echo "configure:2552: checking size of uint8_t" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_uint8_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2516,7 +2556,7 @@ else
ac_cv_sizeof_uint8_t=0
else
cat > conftest.$ac_ext <<EOF
-#line 2520 "configure"
+#line 2560 "configure"
#include "confdefs.h"
#if HAVE_STDINT_H
#include <stdint.h>
@@ -2535,7 +2575,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2579: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_uint8_t=`cat conftestval`
else
@@ -2556,7 +2596,7 @@ EOF
echo $ac_n "checking size of uint16_t""... $ac_c" 1>&6
-echo "configure:2560: checking size of uint16_t" >&5
+echo "configure:2600: checking size of uint16_t" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_uint16_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2564,7 +2604,7 @@ else
ac_cv_sizeof_uint16_t=0
else
cat > conftest.$ac_ext <<EOF
-#line 2568 "configure"
+#line 2608 "configure"
#include "confdefs.h"
#if HAVE_STDINT_H
#include <stdint.h>
@@ -2583,7 +2623,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2587: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_uint16_t=`cat conftestval`
else
@@ -2604,7 +2644,7 @@ EOF
echo $ac_n "checking size of uint32_t""... $ac_c" 1>&6
-echo "configure:2608: checking size of uint32_t" >&5
+echo "configure:2648: checking size of uint32_t" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_uint32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2612,7 +2652,7 @@ else
ac_cv_sizeof_uint32_t=0
else
cat > conftest.$ac_ext <<EOF
-#line 2616 "configure"
+#line 2656 "configure"
#include "confdefs.h"
#if HAVE_STDINT_H
#include <stdint.h>
@@ -2631,7 +2671,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_uint32_t=`cat conftestval`
else
@@ -2652,7 +2692,7 @@ EOF
echo $ac_n "checking size of uint64_t""... $ac_c" 1>&6
-echo "configure:2656: checking size of uint64_t" >&5
+echo "configure:2696: checking size of uint64_t" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_uint64_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2660,7 +2700,7 @@ else
ac_cv_sizeof_uint64_t=0
else
cat > conftest.$ac_ext <<EOF
-#line 2664 "configure"
+#line 2704 "configure"
#include "confdefs.h"
#if HAVE_STDINT_H
#include <stdint.h>
@@ -2679,7 +2719,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2683: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_uint64_t=`cat conftestval`
else
@@ -2703,12 +2743,12 @@ EOF
for ac_func in mmap strerror strtoul mkstemp
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2707: checking for $ac_func" >&5
+echo "configure:2747: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2712 "configure"
+#line 2752 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2731,7 +2771,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2735: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2775: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2757,7 +2797,7 @@ done
echo $ac_n "checking for gzopen in -lz""... $ac_c" 1>&6
-echo "configure:2761: checking for gzopen in -lz" >&5
+echo "configure:2801: checking for gzopen in -lz" >&5
ac_lib_var=`echo z'_'gzopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2765,7 +2805,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lz $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2769 "configure"
+#line 2809 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -2776,7 +2816,7 @@ int main() {
gzopen()
; return 0; }
EOF
-if { (eval echo configure:2780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
diff --git a/configure.in b/configure.in
index faafb716..3a15661b 100644
--- a/configure.in
+++ b/configure.in
@@ -63,6 +63,7 @@ AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h)
AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(getopt.h)
AC_CHECK_HEADERS(locale.h)
+AC_CHECK_HEADERS(stdint.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
diff --git a/doc/file.man b/doc/file.man
index de2885aa..de3e0a6e 100644
--- a/doc/file.man
+++ b/doc/file.man
@@ -1,5 +1,5 @@
.TH FILE __CSECTION__ "Copyright but distributable"
-.\" $Id: file.man,v 1.41 2002/05/16 18:45:56 christos Exp $
+.\" $Id: file.man,v 1.42 2002/07/03 18:26:37 christos Exp $
.SH NAME
file
\- determine file type
@@ -13,16 +13,16 @@ file
.I namefile
]
[
-.B \-m
+.B \-m
.I magicfiles
]
.I file
-\&...
+\*[Am]...
.br
.B file
.B -C
[
-.B \-m
+.B \-m
magicfile ]
.SH DESCRIPTION
This manual page documents version __VERSION__ of the
@@ -54,7 +54,7 @@ Exceptions are well-known file formats (core files, tar archives)
that are known to contain binary data.
When modifying the file
.I __MAGIC__
-or the program itself,
+or the program itself,
.B "preserve these keywords" .
People depend on knowing that all the readable files in a directory
have the word ``text'' printed.
@@ -77,13 +77,13 @@ Any known file types appropriate to the system you are running on
implement them)
are intuited if they are defined in
the system header file
-.IR <sys/stat.h> .
+.IR \*[Lt]sys/stat.h\*[Gt] .
.PP
The magic number tests are used to check for files with data in
particular fixed formats.
The canonical example of this is a binary executable (compiled program)
.I a.out
-file, whose format is defined in
+file, whose format is defined in
.I a.out.h
and possibly
.I exec.h
@@ -97,7 +97,7 @@ offset into the file can usually be described in this way.
The information identifying these files is read from the compiled
magic file
.I __MAGIC__.mgc ,
-or
+or
.I __MAGIC__
if the compile file does not exist.
.PP
@@ -135,13 +135,13 @@ For example, the keyword
.B .br
indicates that the file is most likely a
.BR troff (1)
-input file, just as the keyword
+input file, just as the keyword
.B struct
indicates a C program.
These tests are less reliable than the previous
two groups, so they are performed last.
The language test routines also test for some miscellany
-(such as
+(such as
.BR tar (1)
archives).
.PP
@@ -154,7 +154,7 @@ Do not prepend filenames to output lines (brief mode).
.TP 8
.B \-c
Cause a checking printout of the parsed form of the magic file.
-This is usually used in conjunction with
+This is usually used in conjunction with
.B \-m
to debug a new magic file before installing it.
.TP 8
@@ -163,11 +163,11 @@ Write a magic.mgc output file that contains a pre-parsed version of
file.
.TP 8
.BI \-f " namefile"
-Read the names of the files to be examined from
+Read the names of the files to be examined from
.I namefile
-(one per line)
+(one per line)
before the argument list.
-Either
+Either
.I namefile
or at least one filename argument must be present;
to test the standard input, use ``\-'' as a filename argument.
@@ -250,22 +250,22 @@ can be used to set the default magic number files.
.SH STANDARDS CONFORMANCE
This program is believed to exceed the System V Interface Definition
of FILE(CMD), as near as one can determine from the vague language
-contained therein.
+contained therein.
Its behaviour is mostly compatible with the System V program of the same name.
This version knows more magic, however, so it will produce
-different (albeit more accurate) output in many cases.
+different (albeit more accurate) output in many cases.
.PP
-The one significant difference
+The one significant difference
between this version and System V
is that this version treats any white space
as a delimiter, so that spaces in pattern strings must be escaped.
For example,
.br
->10 string language impress\ (imPRESS data)
+\*[Gt]10 string language impress\ (imPRESS data)
.br
in an existing magic file would have to be changed to
.br
->10 string language\e impress (imPRESS data)
+\*[Gt]10 string language\e impress (imPRESS data)
.br
In addition, in this version, if a pattern string contains a backslash,
it must be escaped. For example
@@ -281,16 +281,16 @@ SunOS releases 3.2 and later from Sun Microsystems include a
.BR file (1)
command derived from the System V one, but with some extensions.
My version differs from Sun's only in minor ways.
-It includes the extension of the `&' operator, used as,
+It includes the extension of the `\*[Am]' operator, used as,
for example,
.br
->16 long&0x7fffffff >0 not stripped
+\*[Gt]16 long\*[Am]0x7fffffff \*[Gt]0 not stripped
.SH MAGIC DIRECTORY
The magic file entries have been collected from various sources,
mainly USENET, and contributed by various authors.
Christos Zoulas (address below) will collect additional
or corrected magic file entries.
-A consolidation of magic file entries
+A consolidation of magic file entries
will be distributed periodically.
.PP
The order of entries in the magic file is significant.
@@ -300,7 +300,7 @@ If your old
.B file
command uses a magic file,
keep the old magic file around for comparison purposes
-(rename it to
+(rename it to
.IR __MAGIC__.orig ).
.SH EXAMPLES
.nf
@@ -335,7 +335,7 @@ not stripped
.fi
.SH HISTORY
-There has been a
+There has been a
.B file
command in every \s-1UNIX\s0 since at least Research Version 4
(man page dated November, 1973).
@@ -344,14 +344,14 @@ the external list of magic number types.
This slowed the program down slightly but made it a lot more flexible.
.PP
This program, based on the System V version,
-was written by Ian Darwin <ian@darwinsys.com>
+was written by Ian Darwin \*[Lt]ian@darwinsys.com\*[Gt]
without looking at anybody else's source code.
.PP
John Gilmore revised the code extensively, making it better than
the first version.
Geoff Collyer found several inadequacies
and provided some magic file entries.
-Contributions by the `&' operator by Rob McMahon, cudcv@warwick.ac.uk, 1989.
+Contributions by the `\*[Am]' operator by Rob McMahon, cudcv@warwick.ac.uk, 1989.
.PP
Guy Harris, guy@netapp.com, made many changes from 1993 to the present.
.PP
@@ -418,11 +418,11 @@ commands vs man page macros.
Regular expression support would make this easy.
.PP
The program doesn't grok \s-2FORTRAN\s0.
-It should be able to figure \s-2FORTRAN\s0 by seeing some keywords which
+It should be able to figure \s-2FORTRAN\s0 by seeing some keywords which
appear indented at the start of line.
Regular expression support would make this easy.
.PP
-The list of keywords in
+The list of keywords in
.I ascmagic
probably belongs in the Magic file.
This could be done by using some keyword like `*' for the offset value.
@@ -434,12 +434,12 @@ have fetched it. Complain about conflicts in the magic file entries.
Make a rule that the magic entries sort based on file offset rather
than position within the magic file?
.PP
-The program should provide a way to give an estimate
+The program should provide a way to give an estimate
of ``how good'' a guess is.
We end up removing guesses (e.g. ``From '' as first 5 chars of file) because
they are not as good as other guesses (e.g. ``Newsgroups:'' versus
``Return-Path:''). Still, if the others don't pan out, it should be
-possible to use the first guess.
+possible to use the first guess.
.PP
This program is slower than some vendors' file commands.
The new support for multiple character codes makes it even slower.
diff --git a/doc/magic.man b/doc/magic.man
index 34c79931..81e5fb38 100644
--- a/doc/magic.man
+++ b/doc/magic.man
@@ -70,7 +70,7 @@ than UTC.
.RE
.PP
The numeric types may optionally be followed by
-.B &
+.B \*[Am]
and a numeric value,
to specify that the value is to be AND'ed with the
numeric value before any comparisons are done. Prepending a
@@ -87,17 +87,17 @@ may be preceded by a character indicating the operation to be performed.
It may be
.BR = ,
to specify that the value from the file must equal the specified value,
-.BR < ,
+.BR \*[Lt] ,
to specify that the value from the file must be less than the specified
value,
-.BR > ,
+.BR \*[Gt] ,
to specify that the value from the file must be greater than the specified
value,
-.BR & ,
-to specify that the value from the file must have set all of the bits
+.BR \*[Am] ,
+to specify that the value from the file must have set all of the bits
that are set in the specified value,
.BR ^ ,
-to specify that the value from the file must have clear any of the bits
+to specify that the value from the file must have clear any of the bits
that are set in the specified value, or
.BR x ,
to specify that any value will match. If the character is omitted,
@@ -113,19 +113,19 @@ is octal, and
is hexadecimal.
.IP
For string values, the byte string from the
-file must match the specified byte string.
+file must match the specified byte string.
The operators
.BR = ,
-.B <
+.B \*[Lt]
and
-.B >
+.B \*[Gt]
(but not
-.BR & )
+.BR \*[Am] )
can be applied to strings.
The length used for matching is that of the string argument
in the magic file. This means that a line can match any string, and
then presumably print that string, by doing
-.B >\e0
+.B \*[Gt]\e0
(because all strings are greater than the null string).
.IP message
The message to be printed if the comparison succeeds. If the string
@@ -136,11 +136,11 @@ performed) is printed using the message as the format string.
.PP
Some file formats contain additional information which is to be printed
along with the file type. A line which begins with the character
-.B >
+.B \*[Gt]
indicates additional tests and messages to be printed. The number of
-.B >
+.B \*[Gt]
on the line indicates the level of the test; a line with no
-.B >
+.B \*[Gt]
at the beginning is considered to be at level 0.
Each line at level
.IB n \(pl1
@@ -156,7 +156,7 @@ line at level
.I n
terminates this.
If the first character following the last
-.B >
+.B \*[Gt]
is a
.B (
then the string after the parenthesis is interpreted as an indirect offset.
@@ -164,11 +164,11 @@ That means that the number after the parenthesis is used as an offset in
the file. The value at that offset is read, and is used again as an offset
in the file. Indirect offsets are of the form:
.BI (( x [.[bslBSL]][+-][ y ]).
-The value of
+The value of
.I x
is used as an offset in the file. A byte, short or long is read at that offset
-depending on the
-.B [bslBSL]
+depending on the
+.B [bslBSL]
type specifier. The capitalized types interpret the number as a big endian
value, whereas the small letter versions interpet the number as a little
endian value. To that number the value of
@@ -179,13 +179,13 @@ if one is not specified is long.
Sometimes you do not know the exact offset as this depends on the length of
preceding fields. You can specify an offset relative to the end of the
last uplevel field (of course this may only be done for sublevel tests, i.e.
-test beginning with
-.B >
+test beginning with
+.B \*[Gt]
). Such a relative offset is specified using
-.B &
+.B \*[Am]
as a prefix to the offset.
.SH BUGS
-The formats
+The formats
.IR long ,
.IR belong ,
.IR lelong ,
@@ -197,7 +197,7 @@ The formats
and
.I ledate
are system-dependent; perhaps they should be specified as a number
-of bytes (2B, 4B, etc),
+of bytes (2B, 4B, etc),
since the files being recognized typically come from
a system on which the lengths are invariant.
.PP
@@ -210,13 +210,13 @@ indirect offsets.
.\" From: guy@sun.uucp (Guy Harris)
.\" Newsgroups: net.bugs.usg
.\" Subject: /etc/magic's format isn't well documented
-.\" Message-ID: <2752@sun.uucp>
+.\" Message-ID: \*[Lt]2752@sun.uucp\*[Gt]
.\" Date: 3 Sep 85 08:19:07 GMT
.\" Organization: Sun Microsystems, Inc.
.\" Lines: 136
-.\"
+.\"
.\" Here's a manual page for the format accepted by the "file" made by adding
.\" the changes I posted to the S5R2 version.
.\"
.\" Modified for Ian Darwin's version of the file command.
-.\" @(#)$Id: magic.man,v 1.18 2002/05/16 18:45:56 christos Exp $
+.\" @(#)$Id: magic.man,v 1.19 2002/07/03 18:26:38 christos Exp $
diff --git a/src/apprentice.c b/src/apprentice.c
index 1cda7d78..fa005dff 100644
--- a/src/apprentice.c
+++ b/src/apprentice.c
@@ -33,12 +33,13 @@
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
+#include <sys/stat.h>
#ifdef QUICK
#include <sys/mman.h>
#endif
#ifndef lint
-FILE_RCSID("@(#)$Id: apprentice.c,v 1.47 2002/06/11 17:31:46 christos Exp $")
+FILE_RCSID("@(#)$Id: apprentice.c,v 1.48 2002/07/03 18:26:37 christos Exp $")
#endif /* lint */
#define EATAB {while (isascii((unsigned char) *l) && \
@@ -70,23 +71,20 @@ FILE_RCSID("@(#)$Id: apprentice.c,v 1.47 2002/06/11 17:31:46 christos Exp $")
#endif
-static int getvalue __P((struct magic *, char **));
-static int hextoint __P((int));
-static char *getstr __P((char *, char *, int, int *));
-static int parse __P((struct magic **, uint32 *, char *, int));
-static void eatsize __P((char **));
-static int apprentice_1 __P((const char *, int));
-static int apprentice_file __P((struct magic **, uint32 *,
- const char *, int));
-static void byteswap __P((struct magic *, uint32));
-static void bs1 __P((struct magic *));
-static uint16 swap2 __P((uint16));
-static uint32 swap4 __P((uint32));
-static char *mkdbname __P((const char *));
-static int apprentice_map __P((struct magic **, uint32 *,
- const char *, int));
-static int apprentice_compile __P((struct magic **, uint32 *,
- const char *, int));
+static int getvalue(struct magic *, char **);
+static int hextoint(int);
+static char *getstr(char *, char *, int, int *);
+static int parse(struct magic **, uint32_t *, char *, int);
+static void eatsize(char **);
+static int apprentice_1(const char *, int);
+static int apprentice_file(struct magic **, uint32_t *, const char *, int);
+static void byteswap(struct magic *, uint32_t);
+static void bs1(struct magic *);
+static uint16_t swap2(uint16_t);
+static uint32_t swap4(uint32_t);
+static char *mkdbname(const char *);
+static int apprentice_map(struct magic **, uint32_t *, const char *, int);
+static int apprentice_compile(struct magic **, uint32_t *, const char *, int);
static int maxmagic = 0;
@@ -97,12 +95,10 @@ const char *magicfile;
char *progname;
int lineno;
-int main __P((int, char *[]));
+int main(int, char *[]);
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
int ret;
@@ -126,12 +122,10 @@ main(argc, argv)
* Handle one file.
*/
static int
-apprentice_1(fn, action)
- const char *fn;
- int action;
+apprentice_1(const char *fn, int action)
{
struct magic *magic = NULL;
- uint32 nmagic = 0;
+ uint32_t nmagic = 0;
struct mlist *ml;
int rv = -1;
@@ -176,10 +170,9 @@ apprentice_1(fn, action)
}
+/* const char *fn: list of magic files */
int
-apprentice(fn, action)
- const char *fn; /* list of magic files */
- int action;
+apprentice(const char *fn, int action)
{
char *p, *mfn;
int file_err, errs = -1;
@@ -217,13 +210,11 @@ apprentice(fn, action)
/*
* parse from a file
+ * const char *fn: name of magic file
*/
static int
-apprentice_file(magicp, nmagicp, fn, action)
- struct magic **magicp;
- uint32 *nmagicp;
- const char *fn; /* name of magic file */
- int action;
+apprentice_file(struct magic **magicp, uint32_t *nmagicp, const char *fn,
+ int action)
{
static const char hdr[] =
"cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
@@ -275,10 +266,8 @@ apprentice_file(magicp, nmagicp, fn, action)
/*
* extend the sign bit if the comparison is to be signed
*/
-uint32
-signextend(m, v)
- struct magic *m;
- uint32 v;
+uint32_t
+signextend(struct magic *m, uint32_t v)
{
if (!(m->flag & UNSIGNED))
switch(m->type) {
@@ -304,7 +293,7 @@ signextend(m, v)
case LONG:
case BELONG:
case LELONG:
- v = (int32) v;
+ v = (int32_t) v;
break;
case STRING:
case PSTRING:
@@ -323,11 +312,7 @@ signextend(m, v)
* parse one line from magic file, put into magic[index++] if valid
*/
static int
-parse(magicp, nmagicp, l, action)
- struct magic **magicp;
- uint32 *nmagicp;
- char *l;
- int action;
+parse(struct magic **magicp, uint32_t *nmagicp, char *l, int action)
{
int i = 0;
struct magic *m;
@@ -681,9 +666,11 @@ GetDesc:
while ((m->desc[i++] = *l++) != '\0' && i<MAXDESC)
/* NULLBODY */;
+#ifndef COMPILE_ONLY
if (action == CHECK) {
mdump(m);
}
+#endif
++(*nmagicp); /* make room for next */
return 0;
}
@@ -694,9 +681,7 @@ GetDesc:
* just after the number read. Return 0 for success, non-zero for failure.
*/
static int
-getvalue(m, p)
- struct magic *m;
- char **p;
+getvalue(struct magic *m, char **p)
{
int slen;
@@ -718,10 +703,7 @@ getvalue(m, p)
* Return updated scan pointer as function result.
*/
static char *
-getstr(s, p, plen, slen)
- char *s;
- char *p;
- int plen, *slen;
+getstr(char *s, char *p, int plen, int *slen)
{
char *origs = s, *origp = p;
char *pmax = p + plen - 1;
@@ -821,8 +803,7 @@ out:
/* Single hex char to int; -1 if not a hex char. */
static int
-hextoint(c)
- int c;
+hextoint(int c)
{
if (!isascii((unsigned char) c))
return -1;
@@ -840,10 +821,7 @@ hextoint(c)
* Print a string containing C character escapes.
*/
void
-showstr(fp, s, len)
- FILE *fp;
- const char *s;
- int len;
+showstr(FILE *fp, const char *s, int len)
{
char c;
@@ -899,8 +877,7 @@ showstr(fp, s, len)
* eatsize(): Eat the size spec from a number [eg. 10UL]
*/
static void
-eatsize(p)
- char **p;
+eatsize(char **p)
{
char *l = *p;
@@ -926,16 +903,13 @@ eatsize(p)
* handle a compiled file.
*/
static int
-apprentice_map(magicp, nmagicp, fn, action)
- struct magic **magicp;
- uint32 *nmagicp;
- const char *fn;
- int action;
+apprentice_map(struct magic **magicp, uint32_t *nmagicp, const char *fn,
+ int action)
{
int fd;
struct stat st;
- uint32 *ptr;
- uint32 version;
+ uint32_t *ptr;
+ uint32_t version;
int needsbyteswap;
char *dbname = mkdbname(fn);
void *mm;
@@ -974,7 +948,7 @@ apprentice_map(magicp, nmagicp, fn, action)
*magicp = mm;
(void)close(fd);
fd = -1;
- ptr = (uint32 *) *magicp;
+ ptr = (uint32_t *) *magicp;
if (*ptr != MAGICNO) {
if (swap4(*ptr) != MAGICNO) {
(void)fprintf(stderr, "%s: Bad magic in `%s'\n",
@@ -1020,15 +994,12 @@ error:
* handle an mmaped file.
*/
static int
-apprentice_compile(magicp, nmagicp, fn, action)
- struct magic **magicp;
- uint32 *nmagicp;
- const char *fn;
- int action;
+apprentice_compile(struct magic **magicp, uint32_t *nmagicp, const char *fn,
+ int action)
{
int fd;
char *dbname = mkdbname(fn);
- static const uint32 ar[] = {
+ static const uint32_t ar[] = {
MAGICNO, VERSIONNO
};
@@ -1068,8 +1039,7 @@ apprentice_compile(magicp, nmagicp, fn, action)
* make a dbname
*/
char *
-mkdbname(fn)
- const char *fn;
+mkdbname(const char *fn)
{
static const char ext[] = ".mgc";
static char *buf = NULL;
@@ -1092,11 +1062,9 @@ mkdbname(fn)
* Byteswap an mmap'ed file if needed
*/
static void
-byteswap(magic, nmagic)
- struct magic *magic;
- uint32 nmagic;
+byteswap(struct magic *magic, uint32_t nmagic)
{
- uint32 i;
+ uint32_t i;
for (i = 0; i < nmagic; i++)
bs1(&magic[i]);
}
@@ -1104,13 +1072,12 @@ byteswap(magic, nmagic)
/*
* swap a short
*/
-static uint16
-swap2(sv)
- uint16 sv;
+static uint16_t
+swap2(uint16_t sv)
{
- uint16 rv;
- uint8 *s = (uint8 *) &sv;
- uint8 *d = (uint8 *) &rv;
+ uint16_t rv;
+ uint8_t *s = (uint8_t *) &sv;
+ uint8_t *d = (uint8_t *) &rv;
d[0] = s[1];
d[1] = s[0];
return rv;
@@ -1119,13 +1086,12 @@ swap2(sv)
/*
* swap an int
*/
-static uint32
-swap4(sv)
- uint32 sv;
+static uint32_t
+swap4(uint32_t sv)
{
- uint32 rv;
- uint8 *s = (uint8 *) &sv;
- uint8 *d = (uint8 *) &rv;
+ uint32_t rv;
+ uint8_t *s = (uint8_t *) &sv;
+ uint8_t *d = (uint8_t *) &rv;
d[0] = s[3];
d[1] = s[2];
d[2] = s[1];
@@ -1137,8 +1103,7 @@ swap4(sv)
* byteswap a single magic entry
*/
static
-void bs1(m)
- struct magic *m;
+void bs1(struct magic *m)
{
m->cont_level = swap2(m->cont_level);
m->offset = swap4(m->offset);
diff --git a/src/ascmagic.c b/src/ascmagic.c
index a155da66..cbbcbe83 100644
--- a/src/ascmagic.c
+++ b/src/ascmagic.c
@@ -45,7 +45,7 @@
#include "names.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: ascmagic.c,v 1.31 2002/06/11 17:31:46 christos Exp $")
+FILE_RCSID("@(#)$Id: ascmagic.c,v 1.32 2002/07/03 18:26:37 christos Exp $")
#endif /* lint */
typedef unsigned long unichar;
@@ -54,18 +54,17 @@ typedef unsigned long unichar;
#define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \
|| (x) == 0x85 || (x) == '\f')
-static int looks_ascii __P((const unsigned char *, int, unichar *, int *));
-static int looks_utf8 __P((const unsigned char *, int, unichar *, int *));
-static int looks_unicode __P((const unsigned char *, int, unichar *, int *));
-static int looks_latin1 __P((const unsigned char *, int, unichar *, int *));
-static int looks_extended __P((const unsigned char *, int, unichar *, int *));
-static void from_ebcdic __P((const unsigned char *, int, unsigned char *));
-static int ascmatch __P((const unsigned char *, const unichar *, int));
+static int looks_ascii(const unsigned char *, int, unichar *, int *);
+static int looks_utf8(const unsigned char *, int, unichar *, int *);
+static int looks_unicode(const unsigned char *, int, unichar *, int *);
+static int looks_latin1(const unsigned char *, int, unichar *, int *);
+static int looks_extended(const unsigned char *, int, unichar *, int *);
+static void from_ebcdic(const unsigned char *, int, unsigned char *);
+static int ascmatch(const unsigned char *, const unichar *, int);
+/* int nbytes: size actually read */
int
-ascmagic(buf, nbytes)
- unsigned char *buf;
- int nbytes; /* size actually read */
+ascmagic(unsigned char *buf, int nbytes)
{
int i;
char nbuf[HOWMANY+1]; /* one extra for terminating '\0' */
@@ -321,10 +320,7 @@ subtype_identified:
}
static int
-ascmatch(s, us, ulen)
- const unsigned char *s;
- const unichar *us;
- int ulen;
+ascmatch(const unsigned char *s, const unichar *us, int ulen)
{
size_t i;
@@ -419,11 +415,7 @@ static char text_chars[256] = {
};
static int
-looks_ascii(buf, nbytes, ubuf, ulen)
- const unsigned char *buf;
- int nbytes;
- unichar *ubuf;
- int *ulen;
+looks_ascii(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
{
int i;
@@ -442,11 +434,7 @@ looks_ascii(buf, nbytes, ubuf, ulen)
}
static int
-looks_latin1(buf, nbytes, ubuf, ulen)
- const unsigned char *buf;
- int nbytes;
- unichar *ubuf;
- int *ulen;
+looks_latin1(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
{
int i;
@@ -465,11 +453,7 @@ looks_latin1(buf, nbytes, ubuf, ulen)
}
static int
-looks_extended(buf, nbytes, ubuf, ulen)
- const unsigned char *buf;
- int nbytes;
- unichar *ubuf;
- int *ulen;
+looks_extended(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
{
int i;
@@ -488,11 +472,7 @@ looks_extended(buf, nbytes, ubuf, ulen)
}
int
-looks_utf8(buf, nbytes, ubuf, ulen)
- const unsigned char *buf;
- int nbytes;
- unichar *ubuf;
- int *ulen;
+looks_utf8(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
{
int i, n;
unichar c;
@@ -554,11 +534,7 @@ done:
}
static int
-looks_unicode(buf, nbytes, ubuf, ulen)
- const unsigned char *buf;
- int nbytes;
- unichar *ubuf;
- int *ulen;
+looks_unicode(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
{
int bigend;
int i;
@@ -675,10 +651,7 @@ unsigned char ebcdic_1047_to_8859[] = {
* Copy buf[0 ... nbytes-1] into out[], translating EBCDIC to ASCII.
*/
static void
-from_ebcdic(buf, nbytes, out)
- const unsigned char *buf;
- int nbytes;
- unsigned char *out;
+from_ebcdic(const unsigned char *buf, int nbytes, unsigned char *out)
{
int i;
diff --git a/src/compress.c b/src/compress.c
index f71c2a69..4e1219c9 100644
--- a/src/compress.c
+++ b/src/compress.c
@@ -19,7 +19,7 @@
#endif
#ifndef lint
-FILE_RCSID("@(#)$Id: compress.c,v 1.24 2002/06/11 17:31:46 christos Exp $")
+FILE_RCSID("@(#)$Id: compress.c,v 1.25 2002/07/03 18:26:37 christos Exp $")
#endif
@@ -44,20 +44,15 @@ static struct {
static int ncompr = sizeof(compr) / sizeof(compr[0]);
-static int swrite __P((int, const void *, size_t));
-static int sread __P((int, void *, size_t));
-static int uncompressbuf __P((int, const unsigned char *, unsigned char **,
- int));
+static int swrite(int, const void *, size_t);
+static int sread(int, void *, size_t);
+static int uncompressbuf(int, const unsigned char *, unsigned char **, int);
#ifdef HAVE_LIBZ
-static int uncompressgzipped __P((const unsigned char *, unsigned char **,
- int));
+static int uncompressgzipped(const unsigned char *, unsigned char **, int);
#endif
int
-zmagic(fname, buf, nbytes)
- const char *fname;
- unsigned char *buf;
- int nbytes;
+zmagic(const char *fname, unsigned char *buf, int nbytes)
{
unsigned char *newbuf;
int newsize;
@@ -87,10 +82,7 @@ zmagic(fname, buf, nbytes)
* `safe' write for sockets and pipes.
*/
static int
-swrite(fd, buf, n)
- int fd;
- const void *buf;
- size_t n;
+swrite(int fd, const void *buf, size_t n)
{
int rv;
size_t rn = n;
@@ -115,10 +107,7 @@ swrite(fd, buf, n)
* `safe' read for sockets and pipes.
*/
static int
-sread(fd, buf, n)
- int fd;
- void *buf;
- size_t n;
+sread(int fd, void *buf, size_t n)
{
int rv;
size_t rn = n;
@@ -141,10 +130,7 @@ sread(fd, buf, n)
}
int
-pipe2file(fd, startbuf, nbytes)
- int fd;
- void *startbuf;
- size_t nbytes;
+pipe2file(int fd, void *startbuf, size_t nbytes)
{
char buf[4096];
int r, tfd;
@@ -217,10 +203,7 @@ pipe2file(fd, startbuf, nbytes)
#define FCOMMENT (1 << 4)
static int
-uncompressgzipped(old, newch, n)
- const unsigned char *old;
- unsigned char **newch;
- int n;
+uncompressgzipped(const unsigned char *old, unsigned char **newch, int n)
{
unsigned char flg = old[3];
int data_start = 10;
@@ -277,11 +260,8 @@ uncompressgzipped(old, newch, n)
#endif
static int
-uncompressbuf(method, old, newch, n)
- int method;
- const unsigned char *old;
- unsigned char **newch;
- int n;
+uncompressbuf(int method, const unsigned char *old, unsigned char **newch,
+ int n)
{
int fdin[2], fdout[2];
diff --git a/src/file.c b/src/file.c
index 632af4ed..2bc51ea5 100644
--- a/src/file.c
+++ b/src/file.c
@@ -30,6 +30,7 @@
#include <unistd.h>
#include <string.h>
#include <sys/param.h> /* for MAXPATHLEN */
+#include <sys/stat.h>
#include <fcntl.h> /* for open() */
#ifdef RESTORE_TIME
# if (__COHERENT__ >= 0x420)
@@ -58,7 +59,7 @@
#include "patchlevel.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: file.c,v 1.64 2002/06/11 17:31:46 christos Exp $")
+FILE_RCSID("@(#)$Id: file.c,v 1.65 2002/07/03 18:26:37 christos Exp $")
#endif /* lint */
@@ -103,25 +104,23 @@ char *progname; /* used throughout */
int lineno; /* line number in the magic file */
-static void unwrap __P((char *fn));
-static void usage __P((void));
+static void unwrap(char *fn);
+static void usage(void);
#ifdef HAVE_GETOPT_H
-static void help __P((void));
+static void help(void);
#endif
#if 0
-static int byteconv4 __P((int, int, int));
-static short byteconv2 __P((int, int, int));
+static int byteconv4(int, int, int);
+static short byteconv2(int, int, int);
#endif
-int main __P((int, char *[]));
+int main(int, char *[]);
/*
* main - parse arguments and handle options
*/
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char **argv)
{
int c;
int action = 0, didsomefiles = 0, errflg = 0, ret = 0, app = 0;
@@ -291,8 +290,7 @@ main(argc, argv)
* unwrap -- read a file of filenames, do each one.
*/
static void
-unwrap(fn)
- char *fn;
+unwrap(char *fn)
{
char buf[MAXPATHLEN];
FILE *f;
@@ -336,10 +334,7 @@ unwrap(fn)
* big_endian whether we are a big endian host
*/
static int
-byteconv4(from, same, big_endian)
- int from;
- int same;
- int big_endian;
+byteconv4(int from, int same, int big_endian)
{
if (same)
return from;
@@ -366,10 +361,7 @@ byteconv4(from, same, big_endian)
* Same as byteconv4, but for shorts
*/
static short
-byteconv2(from, same, big_endian)
- int from;
- int same;
- int big_endian;
+byteconv2(int from, int same, int big_endian)
{
if (same)
return from;
@@ -394,9 +386,7 @@ byteconv2(from, same, big_endian)
* process - process input file
*/
void
-process(inname, wid)
- const char *inname;
- int wid;
+process(const char *inname, int wid)
{
int fd = 0;
static const char stdname[] = "standard input";
@@ -496,10 +486,7 @@ process(inname, wid)
int
-tryit(fn, buf, nb, zfl)
- const char *fn; /* file name*/
- unsigned char *buf; /* buffer */
- int nb, zfl;
+tryit(const char *fn, unsigned char *buf, int nb, int zfl)
{
/*
@@ -533,7 +520,7 @@ tryit(fn, buf, nb, zfl)
}
static void
-usage()
+usage(void)
{
(void)fprintf(stderr, USAGE, progname);
(void)fprintf(stderr, "Usage: %s -C [-m magic]\n", progname);
@@ -545,28 +532,28 @@ usage()
#ifdef HAVE_GETOPT_H
static void
-help()
+help(void)
{
puts(
-"Usage: file [OPTION]... [FILE]...
-Determine file type of FILEs.
-
- -m, --magic-file LIST use LIST as a colon-separated list of magic
- number files
- -z, --uncompress try to look inside compressed files
- -b, --brief do not prepend filenames to output lines
- -c, --checking-printout print the parsed form of the magic file, use in
- conjunction with -m to debug a new magic file
- before installing it
- -f, --files-from FILE read the filenames to be examined from FILE
- -i, --mime output mime type strings
- -k, --keep-going don't stop at the first match
- -L, --dereference causes symlinks to be followed
- -n, --no-buffer do not buffer output
- -s, --special-files treat special (block/char devices) files as
- ordinary ones
- --help display this help and exit
- --version output version information and exit"
+"Usage: file [OPTION]... [FILE]...\n"
+"Determine file type of FILEs.\n"
+"\n"
+" -m, --magic-file LIST use LIST as a colon-separated list of magic\n"
+" number files\n"
+" -z, --uncompress try to look inside compressed files\n"
+" -b, --brief do not prepend filenames to output lines\n"
+" -c, --checking-printout print the parsed form of the magic file, use in\n"
+" conjunction with -m to debug a new magic file\n"
+" before installing it\n"
+" -f, --files-from FILE read the filenames to be examined from FILE\n"
+" -i, --mime output mime type strings\n"
+" -k, --keep-going don't stop at the first match\n"
+" -L, --dereference causes symlinks to be followed\n"
+" -n, --no-buffer do not buffer output\n"
+" -s, --special-files treat special (block/char devices) files as\n"
+" ordinary ones\n"
+" --help display this help and exit\n"
+" --version output version information and exit\n"
);
exit(0);
}
diff --git a/src/file.h b/src/file.h
index 7ba5f4ab..49a69a46 100644
--- a/src/file.h
+++ b/src/file.h
@@ -1,6 +1,6 @@
/*
* file.h - definitions for file(1) program
- * @(#)$Id: file.h,v 1.41 2002/06/11 17:31:46 christos Exp $
+ * @(#)$Id: file.h,v 1.42 2002/07/03 18:26:37 christos Exp $
*
* Copyright (c) Ian F. Darwin, 1987.
* Written by Ian F. Darwin.
@@ -39,17 +39,16 @@
#include <config.h>
#endif
-typedef int int32;
-typedef unsigned int uint32;
-typedef short int16;
-typedef unsigned short uint16;
-typedef char int8;
-typedef unsigned char uint8;
+#include <errno.h>
+#include <stdio.h>
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
#ifndef HOWMANY
# define HOWMANY 16384 /* how much of the file to look at */
#endif
-#define MAXMAGIS 1000 /* max entries in /etc/magic */
+#define MAXMAGIS 4096 /* max entries in /etc/magic */
#define MAXDESC 50 /* max leng of text description */
#define MAXstring 32 /* max leng of "string" types */
@@ -60,16 +59,16 @@ typedef unsigned char uint8;
#define COMPILE 2
struct magic {
- uint16 cont_level;/* level of ">" */
- uint8 nospflag; /* supress space character */
- uint8 flag;
+ uint16_t cont_level; /* level of ">" */
+ uint8_t nospflag; /* supress space character */
+ uint8_t flag;
#define INDIR 1 /* if '>(...)' appears, */
#define UNSIGNED 2 /* comparison is unsigned */
#define OFFADD 4 /* if '>&' appears, */
- uint8 reln; /* relation (0=eq, '>'=gt, etc) */
- uint8 vallen; /* length of string value, if any */
- uint8 type; /* int, short, long or string. */
- uint8 in_type; /* type of indirrection */
+ uint8_t reln; /* relation (0=eq, '>'=gt, etc) */
+ uint8_t vallen; /* length of string value, if any */
+ uint8_t type; /* int, short, long or string. */
+ uint8_t in_type; /* type of indirrection */
#define BYTE 1
#define SHORT 2
#define LONG 4
@@ -86,8 +85,8 @@ struct magic {
#define BELDATE 15
#define LELDATE 16
#define REGEX 17
- uint8 in_op; /* operator for indirection */
- uint8 mask_op; /* operator for mask */
+ uint8_t in_op; /* operator for indirection */
+ uint8_t mask_op; /* operator for mask */
#define OPAND 1
#define OPOR 2
#define OPXOR 3
@@ -97,20 +96,20 @@ struct magic {
#define OPDIVIDE 7
#define OPMODULO 8
#define OPINVERSE 0x80
- int32 offset; /* offset to magic number */
- int32 in_offset; /* offset from indirection */
+ int32_t offset; /* offset to magic number */
+ int32_t in_offset; /* offset from indirection */
union VALUETYPE {
- unsigned char b;
- unsigned short h;
- uint32 l;
+ uint8_t b;
+ uint16_t h;
+ uint32_t l;
char s[MAXstring];
char *buf;
- unsigned char hs[2]; /* 2 bytes of a fixed-endian "short" */
- unsigned char hl[4]; /* 4 bytes of a fixed-endian "long" */
+ uint8_t hs[2]; /* 2 bytes of a fixed-endian "short" */
+ uint8_t hl[4]; /* 4 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 desc[MAXDESC]; /* description */
-};
+} __attribute__((__packed__));
#define BIT(A) (1 << (A))
#define STRING_IGNORE_LOWERCASE BIT(0)
@@ -124,47 +123,30 @@ struct magic {
/* list of magic entries */
struct mlist {
struct magic *magic; /* array of magic entries */
- uint32 nmagic; /* number of entries in array */
+ uint32_t nmagic; /* number of entries in array */
struct mlist *next, *prev;
};
-#include <stdio.h> /* Include that here, to make sure __P gets defined */
-#include <errno.h>
-/*
- * Include it here, so that we don't run into problems with silly OS's that
- * do #define renaming for large file support (Hi Solaris).
- */
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifndef __P
-# if defined(__STDC__) || defined(__cplusplus)
-# define __P(a) a
-# else
-# define __P(a) ()
-# define const
-# endif
-#endif
-
-extern int apprentice __P((const char *, int));
-extern int ascmagic __P((unsigned char *, int));
-extern void error __P((const char *, ...));
-extern void ckfputs __P((const char *, FILE *));
-extern int fsmagic __P((const char *, struct stat *));
-extern char *fmttime __P((long, int));
-extern int is_compress __P((const unsigned char *, int *));
-extern int is_tar __P((unsigned char *, int));
-extern void magwarn __P((const char *, ...));
-extern void mdump __P((struct magic *));
-extern void process __P((const char *, int));
-extern void showstr __P((FILE *, const char *, int));
-extern int softmagic __P((unsigned char *, int));
-extern int tryit __P((const char *, unsigned char *, int, int));
-extern int zmagic __P((const char *, unsigned char *, int));
-extern void ckfprintf __P((FILE *, const char *, ...));
-extern uint32 signextend __P((struct magic *, unsigned int32));
-extern void tryelf __P((int, unsigned char *, int));
-extern int pipe2file __P((int, void *, size_t));
+extern int apprentice(const char *, int);
+extern int ascmagic(unsigned char *, int);
+extern void error(const char *, ...);
+extern void ckfputs(const char *, FILE *);
+struct stat;
+extern int fsmagic(const char *, struct stat *);
+extern char *fmttime(long, int);
+extern int is_compress(const unsigned char *, int *);
+extern int is_tar(unsigned char *, int);
+extern void magwarn(const char *, ...);
+extern void mdump(struct magic *);
+extern void process(const char *, int);
+extern void showstr(FILE *, const char *, int);
+extern int softmagic(unsigned char *, int);
+extern int tryit(const char *, unsigned char *, int, int);
+extern int zmagic(const char *, unsigned char *, int);
+extern void ckfprintf(FILE *, const char *, ...);
+extern uint32_t signextend(struct magic *, unsigned int32);
+extern void tryelf(int, unsigned char *, int);
+extern int pipe2file(int, void *, size_t);
extern char *progname; /* the program name */
@@ -199,13 +181,9 @@ extern char *sys_errlist[];
#define QUICK
#endif
-#ifdef __STDC__
#define FILE_RCSID(id) \
static const char *rcsid(const char *p) { \
return rcsid(p = id); \
}
-#else
-#define FILE_RCSID(id) static char rcsid[] = id;
-#endif
#endif /* __file_h__ */
diff --git a/src/fsmagic.c b/src/fsmagic.c
index d0148f8f..38ec56ff 100644
--- a/src/fsmagic.c
+++ b/src/fsmagic.c
@@ -30,6 +30,7 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#include <sys/stat.h>
#include <stdlib.h>
/* Since major is a function on SVR4, we can't use `ifndef major'. */
#ifdef MAJOR_IN_MKDEV
@@ -51,13 +52,11 @@
#undef HAVE_MAJOR
#ifndef lint
-FILE_RCSID("@(#)$Id: fsmagic.c,v 1.34 2002/06/11 17:31:46 christos Exp $")
+FILE_RCSID("@(#)$Id: fsmagic.c,v 1.35 2002/07/03 18:26:37 christos Exp $")
#endif /* lint */
int
-fsmagic(fn, sb)
- const char *fn;
- struct stat *sb;
+fsmagic(const char *fn, struct stat *sb)
{
int ret = 0;
diff --git a/src/is_tar.c b/src/is_tar.c
index 86df93d6..de7a1691 100644
--- a/src/is_tar.c
+++ b/src/is_tar.c
@@ -5,7 +5,7 @@
* Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu).
*
* @(#)list.c 1.18 9/23/86 Public Domain - gnu
- * $Id: is_tar.c,v 1.16 2002/06/11 17:31:46 christos Exp $
+ * $Id: is_tar.c,v 1.17 2002/07/03 18:26:38 christos Exp $
*
* Comments changed and some code/comments reformatted
* for file command by Ian Darwin.
@@ -14,15 +14,16 @@
#include "file.h"
#include <string.h>
#include <ctype.h>
+#include <sys/types.h>
#include "tar.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: is_tar.c,v 1.16 2002/06/11 17:31:46 christos Exp $")
+FILE_RCSID("@(#)$Id: is_tar.c,v 1.17 2002/07/03 18:26:38 christos Exp $")
#endif
#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )
-static int from_oct __P((int, char *)); /* Decode octal number */
+static int from_oct(int, char *); /* Decode octal number */
/*
* Return
@@ -31,9 +32,7 @@ static int from_oct __P((int, char *)); /* Decode octal number */
* 2 for Unix Std (POSIX) tar file.
*/
int
-is_tar(buf, nbytes)
- unsigned char *buf;
- int nbytes;
+is_tar(unsigned char *buf, int nbytes)
{
union record *header = (union record *)buf;
int i;
@@ -76,9 +75,7 @@ is_tar(buf, nbytes)
* Result is -1 if the field is invalid (all blank, or nonoctal).
*/
static int
-from_oct(digs, where)
- int digs;
- char *where;
+from_oct(int digs, char *where)
{
int value;
diff --git a/src/print.c b/src/print.c
index 6f5659df..57c154e7 100644
--- a/src/print.c
+++ b/src/print.c
@@ -39,14 +39,13 @@
#include <time.h>
#ifndef lint
-FILE_RCSID("@(#)$Id: print.c,v 1.36 2002/06/11 17:31:46 christos Exp $")
+FILE_RCSID("@(#)$Id: print.c,v 1.37 2002/07/03 18:26:38 christos Exp $")
#endif /* lint */
#define SZOF(a) (sizeof(a) / sizeof(a[0]))
void
-mdump(m)
- struct magic *m;
+mdump(struct magic *m)
{
static const char *typ[] = { "invalid", "byte", "short", "invalid",
"long", "string", "date", "beshort",
@@ -134,9 +133,7 @@ mdump(m)
* ckfprintf - fprintf, but with error checking
*/
void
-ckfputs(str, fil)
- const char *str;
- FILE *fil;
+ckfputs(const char *str, FILE *fil)
{
if (fputs(str,fil) == EOF)
error("write failed.\n");
@@ -144,23 +141,11 @@ ckfputs(str, fil)
/*VARARGS*/
void
-#ifdef __STDC__
ckfprintf(FILE *f, const char *fmt, ...)
-#else
-ckfprintf(va_alist)
- va_dcl
-#endif
{
va_list va;
-#ifdef __STDC__
+
va_start(va, fmt);
-#else
- FILE *f;
- const char *fmt;
- va_start(va);
- f = va_arg(va, FILE *);
- fmt = va_arg(va, const char *);
-#endif
(void) vfprintf(f, fmt, va);
if (ferror(f))
error("write failed.\n");
@@ -172,21 +157,11 @@ ckfprintf(va_alist)
*/
/*VARARGS*/
void
-#ifdef __STDC__
error(const char *f, ...)
-#else
-error(va_alist)
- va_dcl
-#endif
{
va_list va;
-#ifdef __STDC__
+
va_start(va, f);
-#else
- const char *f;
- va_start(va);
- f = va_arg(va, const char *);
-#endif
/* cuz we use stdout for most, stderr here */
(void) fflush(stdout);
@@ -199,21 +174,11 @@ error(va_alist)
/*VARARGS*/
void
-#ifdef __STDC__
magwarn(const char *f, ...)
-#else
-magwarn(va_alist)
- va_dcl
-#endif
{
va_list va;
-#ifdef __STDC__
+
va_start(va, f);
-#else
- const char *f;
- va_start(va);
- f = va_arg(va, const char *);
-#endif
/* cuz we use stdout for most, stderr here */
(void) fflush(stdout);
@@ -227,9 +192,7 @@ magwarn(va_alist)
char *
-fmttime(v, local)
- long v;
- int local;
+fmttime(long v, int local)
{
char *pp, *rt;
time_t t = (time_t)v;
diff --git a/src/readelf.c b/src/readelf.c
index 13f14f2b..0ae8ef31 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -11,23 +11,21 @@
#include "readelf.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: readelf.c,v 1.21 2002/06/11 17:31:46 christos Exp $")
+FILE_RCSID("@(#)$Id: readelf.c,v 1.22 2002/07/03 18:26:38 christos Exp $")
#endif
#ifdef ELFCORE
-static void dophn_core __P((int, int, int, off_t, int, size_t));
+static void dophn_core(int, int, int, off_t, int, size_t);
#endif
-static void dophn_exec __P((int, int, int, off_t, int, size_t));
-static void doshn __P((int, int, int, off_t, int, size_t));
+static void dophn_exec(int, int, int, off_t, int, size_t);
+static void doshn(int, int, int, off_t, int, size_t);
-static uint16_t getu16 __P((int, int));
-static uint32_t getu32 __P((int, uint32_t));
-static uint64_t getu64 __P((int, uint64_t));
+static uint16_t getu16(int, uint16_t);
+static uint32_t getu32(int, uint32_t);
+static uint64_t getu64(int, uint64_t);
static uint16_t
-getu16(swap, value)
- int swap;
- uint16_t value;
+getu16(int swap, uint16_t value)
{
union {
uint16_t ui;
@@ -46,9 +44,7 @@ getu16(swap, value)
}
static uint32_t
-getu32(swap, value)
- int swap;
- uint32_t value;
+getu32(int swap, uint32_t value)
{
union {
uint32_t ui;
@@ -69,9 +65,7 @@ getu32(swap, value)
}
static uint64_t
-getu64(swap, value)
- int swap;
- uint64_t value;
+getu64(int swap, uint64_t value)
{
union {
uint64_t ui;
@@ -127,13 +121,7 @@ getu64(swap, value)
: prpsoffsets64[i])
static void
-doshn(class, swap, fd, off, num, size)
- int class;
- int swap;
- int fd;
- off_t off;
- int num;
- size_t size;
+doshn(int class, int swap, int fd, off_t off, int num, size_t size)
{
Elf32_Shdr sh32;
Elf64_Shdr sh64;
@@ -158,13 +146,7 @@ doshn(class, swap, fd, off, num, size)
* otherwise it's statically linked.
*/
static void
-dophn_exec(class, swap, fd, off, num, size)
- int class;
- int swap;
- int fd;
- off_t off;
- int num;
- size_t size;
+dophn_exec(int class, int swap, int fd, off_t off, int num, size_t size)
{
Elf32_Phdr ph32;
Elf32_Nhdr *nh32 = NULL;
@@ -350,13 +332,7 @@ static const char *os_style_names[] = {
};
static void
-dophn_core(class, swap, fd, off, num, size)
- int class;
- int swap;
- int fd;
- off_t off;
- int num;
- size_t size;
+dophn_core(int class, int swap, int fd, off_t off, int num, size_t size)
{
Elf32_Phdr ph32;
Elf32_Nhdr *nh32 = NULL;
@@ -551,14 +527,11 @@ dophn_core(class, swap, fd, off, num, size)
#endif
void
-tryelf(fd, buf, nbytes)
- int fd;
- unsigned char *buf;
- int nbytes;
+tryelf(int fd, unsigned char *buf, int nbytes)
{
union {
- int32 l;
- char c[sizeof (int32)];
+ int32_t l;
+ char c[sizeof (int32_t)];
} u;
int class;
int swap;
@@ -591,7 +564,7 @@ tryelf(fd, buf, nbytes)
u.l = 1;
(void) memcpy(&elfhdr, buf, sizeof elfhdr);
- swap = (u.c[sizeof(int32) - 1] + 1) != elfhdr.e_ident[5];
+ swap = (u.c[sizeof(int32_t) - 1] + 1) != elfhdr.e_ident[5];
if (getu16(swap, elfhdr.e_type) == ET_CORE)
#ifdef ELFCORE
@@ -628,7 +601,7 @@ tryelf(fd, buf, nbytes)
u.l = 1;
(void) memcpy(&elfhdr, buf, sizeof elfhdr);
- swap = (u.c[sizeof(int32) - 1] + 1) != elfhdr.e_ident[5];
+ swap = (u.c[sizeof(int32_t) - 1] + 1) != elfhdr.e_ident[5];
if (getu16(swap, elfhdr.e_type) == ET_CORE)
#ifdef ELFCORE
diff --git a/src/readelf.h b/src/readelf.h
index c0d3ba29..f7494de6 100644
--- a/src/readelf.h
+++ b/src/readelf.h
@@ -1,6 +1,8 @@
+/* $NetBSD: readelf.h,v 1.9 2002/05/18 07:00:47 pooka Exp $ */
+
/*
* readelf.h
- * @(#)$Id: readelf.h,v 1.9 2002/05/16 18:45:56 christos Exp $
+ * @(#)Id: readelf.h,v 1.9 2002/05/16 18:45:56 christos Exp
*
* Provide elf data structures for non-elf machines, allowing file
* non-elf hosts to determine if an elf binary is stripped.
diff --git a/src/softmagic.c b/src/softmagic.c
index b5b680f3..891910c7 100644
--- a/src/softmagic.c
+++ b/src/softmagic.c
@@ -34,16 +34,15 @@
#ifndef lint
-FILE_RCSID("@(#)$Id: softmagic.c,v 1.50 2002/06/11 17:31:46 christos Exp $")
+FILE_RCSID("@(#)$Id: softmagic.c,v 1.51 2002/07/03 18:26:38 christos Exp $")
#endif /* lint */
-static int match __P((struct magic *, uint32, unsigned char *, int));
-static int mget __P((union VALUETYPE *,
- unsigned char *, struct magic *, int));
-static int mcheck __P((union VALUETYPE *, struct magic *));
-static int32 mprint __P((union VALUETYPE *, struct magic *));
-static void mdebug __P((int32, char *, int));
-static int mconvert __P((union VALUETYPE *, struct magic *));
+static int match(struct magic *, uint32_t, unsigned char *, int);
+static int mget(union VALUETYPE *, unsigned char *, struct magic *, int);
+static int mcheck(union VALUETYPE *, struct magic *);
+static int32_t mprint(union VALUETYPE *, struct magic *);
+static void mdebug(int32_t, char *, int);
+static int mconvert(union VALUETYPE *, struct magic *);
extern int kflag;
@@ -54,9 +53,7 @@ extern int kflag;
*/
/*ARGSUSED1*/ /* nbytes passed for regularity, maybe need later */
int
-softmagic(buf, nbytes)
- unsigned char *buf;
- int nbytes;
+softmagic(unsigned char *buf, int nbytes)
{
struct mlist *ml;
@@ -95,24 +92,20 @@ softmagic(buf, nbytes)
* so that higher-level continuations are processed.
*/
static int
-match(magic, nmagic, s, nbytes)
- struct magic *magic;
- uint32 nmagic;
- unsigned char *s;
- int nbytes;
+match(struct magic *magic, uint32_t nmagic, unsigned char *s, int nbytes)
{
int magindex = 0;
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;
int returnval = 0; /* if a match is found it is set to 1*/
int firstline = 1; /* a flag to print X\n X\n- X */
if (tmpoff == NULL)
- if ((tmpoff = (int32 *) malloc(tmplen = 20)) == NULL)
+ if ((tmpoff = (int32_t *) malloc(tmplen = 20)) == NULL)
error("out of memory\n");
for (magindex = 0; magindex < nmagic; magindex++) {
@@ -143,7 +136,7 @@ match(magic, nmagic, s, 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)
error("out of memory\n");
while (magic[magindex+1].cont_level != 0 &&
@@ -190,7 +183,7 @@ match(magic, nmagic, s, nbytes)
*/
if (++cont_level >= tmplen)
if ((tmpoff =
- (int32 *) realloc(tmpoff,
+ (int32_t *) realloc(tmpoff,
tmplen += 20)) == NULL)
error("out of memory\n");
}
@@ -208,13 +201,11 @@ match(magic, nmagic, s, nbytes)
return returnval; /* This is hit if -k is set or there is no match */
}
-static int32
-mprint(p, m)
- union VALUETYPE *p;
- struct magic *m;
+static int32_t
+mprint(union VALUETYPE *p, struct magic *m)
{
- uint32 v;
- int32 t=0 ;
+ uint32_t v;
+ int32_t t=0 ;
switch (m->type) {
@@ -236,8 +227,8 @@ mprint(p, m)
case BELONG:
case LELONG:
v = signextend(m, p->l);
- (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,9 +279,7 @@ mprint(p, m)
* (unless you have a better idea)
*/
static int
-mconvert(p, m)
- union VALUETYPE *p;
- struct magic *m;
+mconvert(union VALUETYPE *p, struct magic *m)
{
switch (m->type) {
case BYTE:
@@ -448,7 +437,7 @@ mconvert(p, m)
case BELONG:
case BEDATE:
case BELDATE:
- p->l = (int32)
+ p->l = (int32_t)
((p->hl[0]<<24)|(p->hl[1]<<16)|(p->hl[2]<<8)|(p->hl[3]));
if (m->mask)
switch (m->mask_op&0x7F) {
@@ -515,7 +504,7 @@ mconvert(p, m)
case LELONG:
case LEDATE:
case LELDATE:
- p->l = (int32)
+ p->l = (int32_t)
((p->hl[3]<<24)|(p->hl[2]<<16)|(p->hl[1]<<8)|(p->hl[0]));
if (m->mask)
switch (m->mask_op&0x7F) {
@@ -557,10 +546,7 @@ mconvert(p, m)
static void
-mdebug(offset, str, len)
- int32 offset;
- char *str;
- int len;
+mdebug(int32_t offset, char *str, int len)
{
(void) fprintf(stderr, "mget @%d: ", offset);
showstr(stderr, (char *) str, len);
@@ -569,13 +555,9 @@ mdebug(offset, str, len)
}
static int
-mget(p, s, m, nbytes)
- union VALUETYPE* p;
- unsigned char *s;
- struct magic *m;
- int nbytes;
+mget(union VALUETYPE *p, unsigned char *s, struct magic *m, int nbytes)
{
- int32 offset = m->offset;
+ int32_t offset = m->offset;
if (m->type == REGEX) {
/*
@@ -595,7 +577,7 @@ mget(p, s, m, 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);
@@ -768,56 +750,56 @@ mget(p, s, m, nbytes)
if (m->in_offset)
switch (m->in_op&0x7F) {
case OPAND:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) &
m->in_offset;
break;
case OPOR:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) |
m->in_offset;
break;
case OPXOR:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) ^
m->in_offset;
break;
case OPADD:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) +
m->in_offset;
break;
case OPMINUS:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) -
m->in_offset;
break;
case OPMULTIPLY:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) *
m->in_offset;
break;
case OPDIVIDE:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) /
m->in_offset;
break;
case OPMODULO:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) %
@@ -831,56 +813,56 @@ mget(p, s, m, nbytes)
if (m->in_offset)
switch (m->in_op&0x7F) {
case OPAND:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) &
m->in_offset;
break;
case OPOR:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) |
m->in_offset;
break;
case OPXOR:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) ^
m->in_offset;
break;
case OPADD:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) +
m->in_offset;
break;
case OPMINUS:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) -
m->in_offset;
break;
case OPMULTIPLY:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) *
m->in_offset;
break;
case OPDIVIDE:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) /
m->in_offset;
break;
case OPMODULO:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) %
@@ -946,12 +928,10 @@ mget(p, s, m, nbytes)
}
static int
-mcheck(p, m)
- union VALUETYPE* p;
- struct magic *m;
+mcheck(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') ) {
@@ -1082,7 +1062,7 @@ mcheck(p, 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);
@@ -1097,7 +1077,7 @@ mcheck(p, 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);