]> granicus.if.org Git - file/commitdiff
- pass lint.
authorChristos Zoulas <christos@zoulas.com>
Wed, 26 Mar 2003 15:35:30 +0000 (15:35 +0000)
committerChristos Zoulas <christos@zoulas.com>
Wed, 26 Mar 2003 15:35:30 +0000 (15:35 +0000)
- fix pointer casts.
- only first error is kept.

12 files changed:
src/Makefile.in
src/apprentice.c
src/ascmagic.c
src/compress.c
src/file.c
src/file.h
src/funcs.c
src/is_tar.c
src/magic.c
src/print.c
src/readelf.c
src/softmagic.c

index cc64db4610ee82c529850829fac27c1ae90e8245..a2481370d835bf8e3f39d7844f2d7ecd57afddba 100644 (file)
@@ -1,8 +1,6 @@
-# Makefile.in generated by automake 1.7.3 from Makefile.am.
-# @configure_input@
+# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
 
-# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-# Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999, 2001 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.
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-@SET_MAKE@
+
+SHELL = @SHELL@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+
 top_builddir = ..
 
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
 INSTALL = @INSTALL@
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+host_alias = @host_alias@
 host_triplet = @host@
-ACLOCAL = @ACLOCAL@
-AMDEP_FALSE = @AMDEP_FALSE@
-AMDEP_TRUE = @AMDEP_TRUE@
+AMDEPBACKSLASH = @AMDEPBACKSLASH@
 AMTAR = @AMTAR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
+AS = @AS@
 AWK = @AWK@
 CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
 CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
 DEPDIR = @DEPDIR@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
+DLLTOOL = @DLLTOOL@
 EXEEXT = @EXEEXT@
-FSECT5_FALSE = @FSECT5_FALSE@
-FSECT5_TRUE = @FSECT5_TRUE@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
+GCJ = @GCJ@
+GCJFLAGS = @GCJFLAGS@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
 STRIP = @STRIP@
 VERSION = @VERSION@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
-am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
-am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-datadir = @datadir@
-exec_prefix = @exec_prefix@
 fsect = @fsect@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-includedir = @includedir@
-infodir = @infodir@
 install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-oldincludedir = @oldincludedir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
+
 MAGIC = $(pkgdatadir)/magic
 lib_LTLIBRARIES = libmagic.la
 include_HEADERS = magic.h
@@ -135,174 +104,110 @@ libmagic_la_LDFLAGS = -version-info 1:0:0
 
 file_SOURCES = file.c
 file_LDFLAGS = -lmagic
-subdir = src
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
-LTLIBRARIES = $(lib_LTLIBRARIES)
-
-libmagic_la_LIBADD =
-am_libmagic_la_OBJECTS = magic.lo apprentice.lo softmagic.lo ascmagic.lo \
-       compress.lo is_tar.lo readelf.lo print.lo fsmagic.lo funcs.lo \
-       apptype.lo
-libmagic_la_OBJECTS = $(am_libmagic_la_OBJECTS)
-bin_PROGRAMS = file$(EXEEXT)
-PROGRAMS = $(bin_PROGRAMS)
-
-am_file_OBJECTS = file.$(OBJEXT)
-file_OBJECTS = $(am_file_OBJECTS)
+CONFIG_HEADER = ../config.h ../$@)]
+CONFIG_CLEAN_FILES = 
+LTLIBRARIES =  $(lib_LTLIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I.. -I..
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+libmagic_la_LIBADD = 
+libmagic_la_OBJECTS =  magic.lo apprentice.lo softmagic.lo ascmagic.lo \
+compress.lo is_tar.lo readelf.lo print.lo fsmagic.lo funcs.lo \
+apptype.lo
+bin_PROGRAMS =  file$(EXEEXT)
+PROGRAMS =  $(bin_PROGRAMS)
+
+file_OBJECTS =  file.$(OBJEXT)
 file_LDADD = $(LDADD)
-file_DEPENDENCIES =
-
-DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/apprentice.Plo \
-@AMDEP_TRUE@   ./$(DEPDIR)/apptype.Plo ./$(DEPDIR)/ascmagic.Plo \
-@AMDEP_TRUE@   ./$(DEPDIR)/compress.Plo ./$(DEPDIR)/file.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/fsmagic.Plo ./$(DEPDIR)/funcs.Plo \
-@AMDEP_TRUE@   ./$(DEPDIR)/is_tar.Plo ./$(DEPDIR)/magic.Plo \
-@AMDEP_TRUE@   ./$(DEPDIR)/print.Plo ./$(DEPDIR)/readelf.Plo \
-@AMDEP_TRUE@   ./$(DEPDIR)/softmagic.Plo
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
-       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
-       $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+file_DEPENDENCIES = 
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-       $(AM_LDFLAGS) $(LDFLAGS) -o $@
-DIST_SOURCES = $(libmagic_la_SOURCES) $(file_SOURCES)
-HEADERS = $(include_HEADERS)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+HEADERS =  $(include_HEADERS)
+
+DIST_COMMON =  Makefile.am Makefile.in
 
-DIST_COMMON = $(include_HEADERS) Makefile.am Makefile.in
-SOURCES = $(libmagic_la_SOURCES) $(file_SOURCES)
 
-all: all-am
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
+TAR = gtar
+GZIP_ENV = --best
+DEP_FILES =  .deps/apprentice.P .deps/apptype.P .deps/ascmagic.P \
+.deps/compress.P .deps/file.P .deps/fsmagic.P .deps/funcs.P \
+.deps/is_tar.P .deps/magic.P .deps/print.P .deps/readelf.P \
+.deps/softmagic.P
+SOURCES = $(libmagic_la_SOURCES) $(file_SOURCES)
+OBJECTS = $(libmagic_la_OBJECTS) $(file_OBJECTS)
+
+all: all-redirect
 .SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
-       cd $(top_srcdir) && \
-         $(AUTOMAKE) --gnu  src/Makefile
-Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
-       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
-libLTLIBRARIES_INSTALL = $(INSTALL)
+.SUFFIXES: .S .c .lo .o .obj .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
+       cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile
+
+Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status $(BUILT_SOURCES)
+       cd $(top_builddir) \
+         && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-libLTLIBRARIES:
+
+clean-libLTLIBRARIES:
+       -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+
+distclean-libLTLIBRARIES:
+
+maintainer-clean-libLTLIBRARIES:
+
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
        @$(NORMAL_INSTALL)
        $(mkinstalldirs) $(DESTDIR)$(libdir)
        @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
          if test -f $$p; then \
-           f="`echo $$p | sed -e 's|^.*/||'`"; \
-           echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f"; \
-           $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f; \
+           echo "$(LIBTOOL)  --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
+           $(LIBTOOL)  --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
          else :; fi; \
        done
 
 uninstall-libLTLIBRARIES:
        @$(NORMAL_UNINSTALL)
-       @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-           p="`echo $$p | sed -e 's|^.*/||'`"; \
-         echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \
-         $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
+       list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+         $(LIBTOOL)  --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
        done
 
-clean-libLTLIBRARIES:
-       -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-       @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-         dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
-         test "$$dir" = "$$p" && dir=.; \
-         echo "rm -f \"$${dir}/so_locations\""; \
-         rm -f "$${dir}/so_locations"; \
-       done
-libmagic.la: $(libmagic_la_OBJECTS) $(libmagic_la_DEPENDENCIES) 
-       $(LINK) -rpath $(libdir) $(libmagic_la_LDFLAGS) $(libmagic_la_OBJECTS) $(libmagic_la_LIBADD) $(LIBS)
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
-install-binPROGRAMS: $(bin_PROGRAMS)
-       @$(NORMAL_INSTALL)
-       $(mkinstalldirs) $(DESTDIR)$(bindir)
-       @list='$(bin_PROGRAMS)'; for p in $$list; do \
-         p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-         if test -f $$p \
-            || test -f $$p1 \
-         ; then \
-           f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-          echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \
-          $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f || exit 1; \
-         else :; fi; \
-       done
+# FIXME: We should only use cygpath when building on Windows,
+# and only if it is available.
+.c.obj:
+       $(COMPILE) -c `cygpath -w $<`
 
-uninstall-binPROGRAMS:
-       @$(NORMAL_UNINSTALL)
-       @list='$(bin_PROGRAMS)'; for p in $$list; do \
-         f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-         echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
-         rm -f $(DESTDIR)$(bindir)/$$f; \
-       done
+.s.o:
+       $(COMPILE) -c $<
 
-clean-binPROGRAMS:
-       @list='$(bin_PROGRAMS)'; for p in $$list; do \
-         f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-         echo " rm -f $$p $$f"; \
-         rm -f $$p $$f ; \
-       done
-file$(EXEEXT): $(file_OBJECTS) $(file_DEPENDENCIES) 
-       @rm -f file$(EXEEXT)
-       $(LINK) $(file_LDFLAGS) $(file_OBJECTS) $(file_LDADD) $(LIBS)
+.S.o:
+       $(COMPILE) -c $<
 
 mostlyclean-compile:
-       -rm -f *.$(OBJEXT) core *.core
+       -rm -f *.o core *.core
+       -rm -f *.$(OBJEXT)
+
+clean-compile:
 
 distclean-compile:
        -rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/apprentice.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/apptype.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascmagic.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compress.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsmagic.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/funcs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_tar.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/magic.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readelf.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/softmagic.Plo@am__quote@
+maintainer-clean-compile:
 
-distclean-depend:
-       -rm -rf ./$(DEPDIR)
-
-.c.o:
-@am__fastdepCC_TRUE@   if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
-@am__fastdepCC_TRUE@     -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
-@am__fastdepCC_TRUE@   then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
-@am__fastdepCC_TRUE@   else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
-@am__fastdepCC_TRUE@   fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+.s.lo:
+       $(LIBTOOL) --mode=compile $(COMPILE) -c $<
 
-.c.obj:
-@am__fastdepCC_TRUE@   if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
-@am__fastdepCC_TRUE@     -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
-@am__fastdepCC_TRUE@   then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
-@am__fastdepCC_TRUE@   else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
-@am__fastdepCC_TRUE@   fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
-
-.c.lo:
-@am__fastdepCC_TRUE@   if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
-@am__fastdepCC_TRUE@     -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
-@am__fastdepCC_TRUE@   then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; \
-@am__fastdepCC_TRUE@   else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
-@am__fastdepCC_TRUE@   fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
+.S.lo:
+       $(LIBTOOL) --mode=compile $(COMPILE) -c $<
 
 mostlyclean-libtool:
        -rm -f *.lo
@@ -311,207 +216,221 @@ clean-libtool:
        -rm -rf .libs _libs
 
 distclean-libtool:
-       -rm -f libtool
-uninstall-info-am:
-includeHEADERS_INSTALL = $(INSTALL_HEADER)
+
+maintainer-clean-libtool:
+
+libmagic.la: $(libmagic_la_OBJECTS) $(libmagic_la_DEPENDENCIES)
+       $(LINK) -rpath $(libdir) $(libmagic_la_LDFLAGS) $(libmagic_la_OBJECTS) $(libmagic_la_LIBADD) $(LIBS)
+
+mostlyclean-binPROGRAMS:
+
+clean-binPROGRAMS:
+       -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+
+distclean-binPROGRAMS:
+
+maintainer-clean-binPROGRAMS:
+
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       $(mkinstalldirs) $(DESTDIR)$(bindir)
+       @list='$(bin_PROGRAMS)'; for p in $$list; do \
+         if test -f $$p; then \
+           echo " $(LIBTOOL)  --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
+           $(LIBTOOL)  --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+         else :; fi; \
+       done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       list='$(bin_PROGRAMS)'; for p in $$list; do \
+         rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+       done
+
+file$(EXEEXT): $(file_OBJECTS) $(file_DEPENDENCIES)
+       @rm -f file$(EXEEXT)
+       $(LINK) $(file_LDFLAGS) $(file_OBJECTS) $(file_LDADD) $(LIBS)
+
 install-includeHEADERS: $(include_HEADERS)
        @$(NORMAL_INSTALL)
        $(mkinstalldirs) $(DESTDIR)$(includedir)
        @list='$(include_HEADERS)'; for p in $$list; do \
-         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-         f="`echo $$p | sed -e 's|^.*/||'`"; \
-         echo " $(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f"; \
-         $(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f; \
+         if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
+         echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
+         $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
        done
 
 uninstall-includeHEADERS:
        @$(NORMAL_UNINSTALL)
-       @list='$(include_HEADERS)'; for p in $$list; do \
-         f="`echo $$p | sed -e 's|^.*/||'`"; \
-         echo " rm -f $(DESTDIR)$(includedir)/$$f"; \
-         rm -f $(DESTDIR)$(includedir)/$$f; \
+       list='$(include_HEADERS)'; for p in $$list; do \
+         rm -f $(DESTDIR)$(includedir)/$$p; \
        done
 
-ETAGS = etags
-ETAGSFLAGS =
-
-CTAGS = ctags
-CTAGSFLAGS =
-
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-       unique=`for i in $$list; do \
-           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-         done | \
-         $(AWK) '    { files[$$0] = 1; } \
+ID: $(HEADERS) $(SOURCES) $(LISP)
+       list='$(SOURCES) $(HEADERS)'; \
+       unique=`for i in $$list; do echo $$i; done | \
+         awk '    { files[$$0] = 1; } \
               END { for (i in files) print i; }'`; \
-       mkid -fID $$unique
+       here=`pwd` && cd $(srcdir) \
+         && mkid -f$$here/ID $$unique $(LISP)
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-               $(TAGS_FILES) $(LISP)
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
        tags=; \
        here=`pwd`; \
-       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-       unique=`for i in $$list; do \
-           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-         done | \
-         $(AWK) '    { files[$$0] = 1; } \
+       list='$(SOURCES) $(HEADERS)'; \
+       unique=`for i in $$list; do echo $$i; done | \
+         awk '    { files[$$0] = 1; } \
               END { for (i in files) print i; }'`; \
-       test -z "$(ETAGS_ARGS)$$tags$$unique" \
-         || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-            $$tags $$unique
+       test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+         || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
 
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-               $(TAGS_FILES) $(LISP)
-       tags=; \
-       here=`pwd`; \
-       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-       unique=`for i in $$list; do \
-           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-         done | \
-         $(AWK) '    { files[$$0] = 1; } \
-              END { for (i in files) print i; }'`; \
-       test -z "$(CTAGS_ARGS)$$tags$$unique" \
-         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-            $$tags $$unique
+mostlyclean-tags:
 
-GTAGS:
-       here=`$(am__cd) $(top_builddir) && pwd` \
-         && cd $(top_srcdir) \
-         && gtags -i $(GTAGS_ARGS) $$here
+clean-tags:
 
 distclean-tags:
-       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+       -rm -f TAGS ID
+
+maintainer-clean-tags:
 
-top_distdir = ..
-distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = src
 
 distdir: $(DISTFILES)
-       @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
-       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
-       list='$(DISTFILES)'; for file in $$list; do \
-         case $$file in \
-           $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
-           $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
-         esac; \
-         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
-         dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
-         if test "$$dir" != "$$file" && test "$$dir" != "."; then \
-           dir="/$$dir"; \
-           $(mkinstalldirs) "$(distdir)$$dir"; \
-         else \
-           dir=''; \
-         fi; \
+       here=`cd $(top_builddir) && pwd`; \
+       top_distdir=`cd $(top_distdir) && pwd`; \
+       distdir=`cd $(distdir) && pwd`; \
+       cd $(top_srcdir) \
+         && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu src/Makefile
+       @for file in $(DISTFILES); do \
+         d=$(srcdir); \
          if test -d $$d/$$file; then \
-           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-             cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
-           fi; \
-           cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+           cp -pr $$d/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
-           || cp -p $$d/$$file $(distdir)/$$file \
-           || exit 1; \
+           || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+           || cp -p $$d/$$file $(distdir)/$$file || :; \
          fi; \
        done
-check-am: all-am
-check: check-am
-all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS)
-install-binPROGRAMS: install-libLTLIBRARIES
 
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
 
-installdirs:
-       $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) $(DESTDIR)$(includedir)
+-include $(DEP_FILES)
 
-install: install-am
+mostlyclean-depend:
+
+clean-depend:
+
+distclean-depend:
+       -rm -rf .deps
+
+maintainer-clean-depend:
+
+%.o: %.c
+       @echo '$(COMPILE) -c $<'; \
+       $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+       @-cp .deps/$(*F).pp .deps/$(*F).P; \
+       tr ' ' '\012' < .deps/$(*F).pp \
+         | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+           >> .deps/$(*F).P; \
+       rm .deps/$(*F).pp
+
+%.lo: %.c
+       @echo '$(LTCOMPILE) -c $<'; \
+       $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+       @-sed -e 's/^\([^:]*\)\.o[      ]*:/\1.lo \1.o :/' \
+         < .deps/$(*F).pp > .deps/$(*F).P; \
+       tr ' ' '\012' < .deps/$(*F).pp \
+         | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+           >> .deps/$(*F).P; \
+       rm -f .deps/$(*F).pp
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am: install-libLTLIBRARIES install-binPROGRAMS
 install-exec: install-exec-am
+
+install-data-am: install-includeHEADERS
 install-data: install-data-am
-uninstall: uninstall-am
 
 install-am: all-am
        @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
+install: install-am
+uninstall-am: uninstall-libLTLIBRARIES uninstall-binPROGRAMS \
+               uninstall-includeHEADERS
+uninstall: uninstall-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS)
+all-redirect: all-am
 install-strip:
-       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-         INSTALL_STRIP_FLAG=-s \
-         `test -z '$(STRIP)' || \
-           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+       $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+       $(mkinstalldirs)  $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) \
+               $(DESTDIR)$(includedir)
+
+
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
        -rm -f Makefile $(CONFIG_CLEAN_FILES)
+       -rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-       @echo "This command is intended for maintainers to use"
-       @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
-       clean-libtool mostlyclean-am
-
-distclean: distclean-am
+mostlyclean-am:  mostlyclean-libLTLIBRARIES mostlyclean-compile \
+               mostlyclean-libtool mostlyclean-binPROGRAMS \
+               mostlyclean-tags mostlyclean-depend mostlyclean-generic
 
-distclean-am: clean-am distclean-compile distclean-depend \
-       distclean-generic distclean-libtool distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-info: info-am
-
-info-am:
+mostlyclean: mostlyclean-am
 
-install-data-am: install-includeHEADERS
+clean-am:  clean-libLTLIBRARIES clean-compile clean-libtool \
+               clean-binPROGRAMS clean-tags clean-depend clean-generic \
+               mostlyclean-am
 
-install-exec-am: install-binPROGRAMS install-libLTLIBRARIES
+clean: clean-am
 
-install-info: install-info-am
+distclean-am:  distclean-libLTLIBRARIES distclean-compile \
+               distclean-libtool distclean-binPROGRAMS distclean-tags \
+               distclean-depend distclean-generic clean-am
+       -rm -f libtool
 
-install-man:
+distclean: distclean-am
 
-installcheck-am:
+maintainer-clean-am:  maintainer-clean-libLTLIBRARIES \
+               maintainer-clean-compile maintainer-clean-libtool \
+               maintainer-clean-binPROGRAMS maintainer-clean-tags \
+               maintainer-clean-depend maintainer-clean-generic \
+               distclean-am
+       @echo "This command is intended for maintainers to use;"
+       @echo "it deletes files that may require special tools to rebuild."
 
 maintainer-clean: maintainer-clean-am
 
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
-       mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \
-       uninstall-info-am uninstall-libLTLIBRARIES
+.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
+clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
+uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
+distclean-compile clean-compile maintainer-clean-compile \
+mostlyclean-libtool distclean-libtool clean-libtool \
+maintainer-clean-libtool mostlyclean-binPROGRAMS distclean-binPROGRAMS \
+clean-binPROGRAMS maintainer-clean-binPROGRAMS uninstall-binPROGRAMS \
+install-binPROGRAMS uninstall-includeHEADERS install-includeHEADERS \
+tags mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
+distdir mostlyclean-depend distclean-depend clean-depend \
+maintainer-clean-depend info-am info dvi-am dvi check check-am \
+installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
-       clean-generic clean-libLTLIBRARIES clean-libtool ctags \
-       distclean distclean-compile distclean-depend distclean-generic \
-       distclean-libtool distclean-tags distdir dvi dvi-am info \
-       info-am install install-am install-binPROGRAMS install-data \
-       install-data-am install-exec install-exec-am \
-       install-includeHEADERS install-info install-info-am \
-       install-libLTLIBRARIES install-man install-strip installcheck \
-       installcheck-am installdirs maintainer-clean \
-       maintainer-clean-generic mostlyclean mostlyclean-compile \
-       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
-       tags uninstall uninstall-am uninstall-binPROGRAMS \
-       uninstall-includeHEADERS uninstall-info-am \
-       uninstall-libLTLIBRARIES
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
index f85d048786c16cf41109897e8d4efaaa99a10bee..dd43094c3cfbb4797f6d0d5b2b7cc283fe3d39ef 100644 (file)
@@ -50,7 +50,7 @@
 #endif
 
 #ifndef        lint
-FILE_RCSID("@(#)$Id: apprentice.c,v 1.54 2003/03/24 01:16:28 christos Exp $")
+FILE_RCSID("@(#)$Id: apprentice.c,v 1.55 2003/03/26 15:35:30 christos Exp $")
 #endif /* lint */
 
 #define        EATAB {while (isascii((unsigned char) *l) && \
@@ -94,13 +94,13 @@ private void byteswap(struct magic *, uint32_t);
 private void bs1(struct magic *);
 private uint16_t swap2(uint16_t);
 private uint32_t swap4(uint32_t);
-private char *mkdbname(struct magic_set *, const char *, char *, size_t);
+private char *mkdbname(const char *, char *, size_t);
 private int apprentice_map(struct magic_set *, struct magic **, uint32_t *,
-    const char *, int);
+    const char *);
 private int apprentice_compile(struct magic_set *, struct magic **, uint32_t *,
-    const char *, int);
+    const char *);
 
-private int maxmagic = 0;
+private size_t maxmagic = 0;
 
 #ifdef COMPILE_ONLY
 const char *magicfile;
@@ -146,14 +146,13 @@ apprentice_1(struct magic_set *ms, const char *fn, int action,
        if (action == FILE_COMPILE) {
                rv = apprentice_file(ms, &magic, &nmagic, fn, action);
                if (rv == 0) {
-                       rv = apprentice_compile(ms, &magic, &nmagic, fn,
-                           action);
+                       rv = apprentice_compile(ms, &magic, &nmagic, fn);
                        free(magic);
                }
                return rv;
        }
 #ifndef COMPILE_ONLY
-       if ((rv = apprentice_map(ms, &magic, &nmagic, fn, action)) == -1) {
+       if ((rv = apprentice_map(ms, &magic, &nmagic, fn)) == -1) {
                if (ms->flags & MAGIC_CHECK)
                        file_magwarn("Using regular magic file `%s'", fn);
                rv = apprentice_file(ms, &magic, &nmagic, fn, action);
@@ -320,7 +319,7 @@ file_signextend(struct magic_set *ms, struct magic *m, uint32_t v)
                        if (ms->flags & MAGIC_CHECK)
                            file_magwarn("can't happen: m->type=%d\n",
                                    m->type);
-                       return -1;
+                       return ~0U;
                }
        return v;
 }
@@ -335,6 +334,7 @@ parse(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, char *l,
        int i = 0;
        struct magic *m;
        char *t;
+       uint32_t val;
 
 #define ALLOC_INCR     200
        if (*nmagicp + 1 >= maxmagic){
@@ -452,7 +452,7 @@ parse(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, char *l,
                        break;
                }
                if (isdigit((unsigned char)*l)) 
-                       m->in_offset = strtoul(l, &t, 0);
+                       m->in_offset = (uint32_t)strtoul(l, &t, 0);
                else
                        t = l;
                if (*t++ != ')') 
@@ -552,54 +552,55 @@ parse(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, char *l,
                        m->mask_op = FILE_OPINVERSE;
                ++l;
        }
+       val = (uint32_t)strtoul(l, &l, 0);
        switch (*l) {
        case '&':
                m->mask_op |= FILE_OPAND;
                ++l;
-               m->mask = file_signextend(ms, m, strtoul(l, &l, 0));
+               m->mask = file_signextend(ms, m, val);
                eatsize(&l);
                break;
        case '|':
                m->mask_op |= FILE_OPOR;
                ++l;
-               m->mask = file_signextend(ms, m, strtoul(l, &l, 0));
+               m->mask = file_signextend(ms, m, val);
                eatsize(&l);
                break;
        case '^':
                m->mask_op |= FILE_OPXOR;
                ++l;
-               m->mask = file_signextend(ms, m, strtoul(l, &l, 0));
+               m->mask = file_signextend(ms, m, val);
                eatsize(&l);
                break;
        case '+':
                m->mask_op |= FILE_OPADD;
                ++l;
-               m->mask = file_signextend(ms, m, strtoul(l, &l, 0));
+               m->mask = file_signextend(ms, m, val);
                eatsize(&l);
                break;
        case '-':
                m->mask_op |= FILE_OPMINUS;
                ++l;
-               m->mask = file_signextend(ms, m, strtoul(l, &l, 0));
+               m->mask = file_signextend(ms, m, val);
                eatsize(&l);
                break;
        case '*':
                m->mask_op |= FILE_OPMULTIPLY;
                ++l;
-               m->mask = file_signextend(ms, m, strtoul(l, &l, 0));
+               m->mask = file_signextend(ms, m, val);
                eatsize(&l);
                break;
        case '%':
                m->mask_op |= FILE_OPMODULO;
                ++l;
-               m->mask = file_signextend(ms, m, strtoul(l, &l, 0));
+               m->mask = file_signextend(ms, m, val);
                eatsize(&l);
                break;
        case '/':
                if (FILE_STRING != m->type && FILE_PSTRING != m->type) {
                        m->mask_op |= FILE_OPDIVIDE;
                        ++l;
-                       m->mask = file_signextend(ms, m, strtoul(l, &l, 0));
+                       m->mask = file_signextend(ms, m, val);
                        eatsize(&l);
                } else {
                        m->mask = 0L;
@@ -650,7 +651,7 @@ parse(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, char *l,
                        ++l;
                        break;
                }
-               /* FALL THROUGH */
+               /*FALLTHROUGH*/
        default:
                if (*l == 'x' && isascii((unsigned char)l[1]) && 
                    isspace((unsigned char)l[1])) {
@@ -718,7 +719,8 @@ getvalue(struct magic_set *ms, struct magic *m, char **p)
                return 0;
        default:
                if (m->reln != 'x') {
-                       m->value.l = file_signextend(ms, m, strtoul(*p, p, 0));
+                       m->value.l = file_signextend(ms, m,
+                           (uint32_t)strtoul(*p, p, 0));
                        eatsize(p);
                }
                return 0;
@@ -850,13 +852,13 @@ hextoint(int c)
  * Print a string containing C character escapes.
  */
 protected void
-file_showstr(FILE *fp, const char *s, int len)
+file_showstr(FILE *fp, const char *s, size_t len)
 {
        char    c;
 
        for (;;) {
                c = *s++;
-               if (len == -1) {
+               if (len == ~0U) {
                        if (c == '\0')
                                break;
                }
@@ -933,7 +935,7 @@ eatsize(char **p)
  */
 private int
 apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
-    const char *fn, int action)
+    const char *fn)
 {
        int fd;
        struct stat st;
@@ -941,7 +943,7 @@ apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
        uint32_t version;
        int needsbyteswap;
        char buf[MAXPATHLEN];
-       char *dbname = mkdbname(ms, fn, buf, sizeof(buf));
+       char *dbname = mkdbname(fn, buf, sizeof(buf));
        void *mm;
 
        if (dbname == NULL)
@@ -975,7 +977,7 @@ apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
        *magicp = mm;
        (void)close(fd);
        fd = -1;
-       ptr = (uint32_t *) *magicp;
+       ptr = (uint32_t *)(void *)*magicp;
        if (*ptr != MAGICNO) {
                if (swap4(*ptr) != MAGICNO) {
                        file_error(ms, "Bad magic in `%s'", dbname);
@@ -993,7 +995,7 @@ apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
                    version, VERSIONNO, dbname);
                goto error;
        }
-       *nmagicp = (st.st_size / sizeof(struct magic)) - 1;
+       *nmagicp = (uint32_t)(st.st_size / sizeof(struct magic)) - 1;
        (*magicp)++;
        if (needsbyteswap)
                byteswap(*magicp, *nmagicp);
@@ -1023,11 +1025,11 @@ private const uint32_t ar[] = {
  */
 private int
 apprentice_compile(struct magic_set *ms, struct magic **magicp,
-    uint32_t *nmagicp, const char *fn, int action)
+    uint32_t *nmagicp, const char *fn)
 {
        int fd;
        char buf[MAXPATHLEN];
-       char *dbname = mkdbname(ms, fn, buf, sizeof(buf));
+       char *dbname = mkdbname(fn, buf, sizeof(buf));
 
        if (dbname == NULL) 
                return -1;
@@ -1043,7 +1045,8 @@ apprentice_compile(struct magic_set *ms, struct magic **magicp,
                return -1;
        }
 
-       if (lseek(fd, sizeof(struct magic), SEEK_SET) != sizeof(struct magic)) {
+       if (lseek(fd, (off_t)sizeof(struct magic), SEEK_SET)
+           != sizeof(struct magic)) {
                file_error(ms, "Error seeking `%s' (%s)", dbname,
                    strerror(errno));
                return -1;
@@ -1065,14 +1068,14 @@ private const char ext[] = ".mgc";
  * make a dbname
  */
 private char *
-mkdbname(struct magic_set *ms, const char *fn, char *buf, size_t bufsiz)
+mkdbname(const char *fn, char *buf, size_t bufsiz)
 {
        const char *p;
        if ((p = strrchr(fn, '/')) != NULL)
                p++;
        else
                p = fn;
-       snprintf(buf, bufsiz, "%s%s", p, ext);
+       (void)snprintf(buf, bufsiz, "%s%s", p, ext);
        return buf;
 }
 
@@ -1094,8 +1097,8 @@ private uint16_t
 swap2(uint16_t sv)
 {
        uint16_t rv;
-       uint8_t *s = (uint8_t *) &sv; 
-       uint8_t *d = (uint8_t *) &rv; 
+       uint8_t *s = (uint8_t *)(void *)&sv; 
+       uint8_t *d = (uint8_t *)(void *)&rv; 
        d[0] = s[1];
        d[1] = s[0];
        return rv;
@@ -1108,8 +1111,8 @@ private uint32_t
 swap4(uint32_t sv)
 {
        uint32_t rv;
-       uint8_t *s = (uint8_t *) &sv; 
-       uint8_t *d = (uint8_t *) &rv; 
+       uint8_t *s = (uint8_t *)(void *)&sv; 
+       uint8_t *d = (uint8_t *)(void *)&rv; 
        d[0] = s[3];
        d[1] = s[2];
        d[2] = s[1];
@@ -1124,8 +1127,8 @@ private void
 bs1(struct magic *m)
 {
        m->cont_level = swap2(m->cont_level);
-       m->offset = swap4(m->offset);
-       m->in_offset = swap4(m->in_offset);
+       m->offset = swap4((uint32_t)m->offset);
+       m->in_offset = swap4((uint32_t)m->in_offset);
        if (m->type != FILE_STRING)
                m->value.l = swap4(m->value.l);
        m->mask = swap4(m->mask);
index 14e728b81eac78dd55a4e21b05375414767c305d..6fd55f284e92857f65a290a75cc3074e17d9aa35 100644 (file)
@@ -54,7 +54,7 @@
 #include "names.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$Id: ascmagic.c,v 1.35 2003/03/23 21:16:26 christos Exp $")
+FILE_RCSID("@(#)$Id: ascmagic.c,v 1.36 2003/03/26 15:35:30 christos Exp $")
 #endif /* lint */
 
 typedef unsigned long unichar;
@@ -137,7 +137,7 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
                code = "UTF-8 Unicode";
                code_mime = "utf-8";
                type = "text";
-       } else if ((i = looks_unicode(buf, nbytes, ubuf, &ulen))) {
+       } else if ((i = looks_unicode(buf, nbytes, ubuf, &ulen)) != 0) {
                if (i == 1)
                        code = "Little-endian UTF-16 Unicode";
                else
@@ -256,7 +256,7 @@ subtype_identified:
                        n_cr++;
                        last_line_end = i;
                }
-               if (ubuf[i] == '\n' && (i - 1 <  0    || ubuf[i - 1] != '\r')) {
+               if (ubuf[i] == '\n' && ((int)i - 1 < 0 || ubuf[i - 1] != '\r')){
                        n_lf++;
                        last_line_end = i;
                }
@@ -600,7 +600,8 @@ looks_unicode(const unsigned char *buf, size_t nbytes, unichar *ubuf,
 
                if (ubuf[*ulen - 1] == 0xfffe)
                        return 0;
-               if (ubuf[*ulen - 1] < 128 && text_chars[ubuf[*ulen - 1]] != T)
+               if (ubuf[*ulen - 1] < 128 &&
+                   text_chars[(size_t)ubuf[*ulen - 1]] != T)
                        return 0;
        }
 
index 097983c1388b356a101ba2ec1eea342ecf93a12d..11f2773eef7b7187d5adcf62d7ac5283953557c9 100644 (file)
 #endif
 
 #ifndef lint
-FILE_RCSID("@(#)$Id: compress.c,v 1.29 2003/03/24 01:16:28 christos Exp $")
+FILE_RCSID("@(#)$Id: compress.c,v 1.30 2003/03/26 15:35:30 christos Exp $")
 #endif
 
 
 private struct {
        const char *magic;
-       int   maglen;
+       size_t maglen;
        const char *const argv[3];
-       int      silent;
+       int silent;
 } compr[] = {
        { "\037\235", 2, { "gzip", "-cdq", NULL }, 1 },         /* compressed */
        /* Uncompress can get stuck; so use gzip first if we have it
@@ -82,10 +82,10 @@ private int ncompr = sizeof(compr) / sizeof(compr[0]);
 
 private int swrite(int, const void *, size_t);
 private int sread(int, void *, size_t);
-private size_t uncompressbuf(struct magic_set *ms, int, const unsigned char *,
+private size_t uncompressbuf(struct magic_set *, size_t, const unsigned char *,
     unsigned char **, size_t);
 #ifdef HAVE_LIBZ
-private size_t uncompressgzipped(struct magic_set *ms, const unsigned char *,
+private size_t uncompressgzipped(struct magic_set *, const unsigned char *,
     unsigned char **, size_t);
 #endif
 
@@ -93,7 +93,6 @@ protected int
 file_zmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
 {
        unsigned char *newbuf;
-       size_t nsz;
        size_t i;
 
        if ((ms->flags & MAGIC_COMPRESS) == 0)
@@ -103,7 +102,7 @@ file_zmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
                if (nbytes < compr[i].maglen)
                        continue;
                if (memcmp(buf, compr[i].magic, compr[i].maglen) == 0 &&
-                   (nsz = uncompressbuf(ms, i, buf, &newbuf, nbytes)) != 0) {
+                   uncompressbuf(ms, i, buf, &newbuf, nbytes) != 0) {
                        free(newbuf);
                        if (file_printf(ms, " (") == -1)
                                return -1;
@@ -205,7 +204,7 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
                r = 1;
        else {
                while ((r = sread(fd, buf, sizeof(buf))) > 0)
-                       if (swrite(tfd, buf, r) != r)
+                       if (swrite(tfd, buf, (size_t)r) != r)
                                break;
        }
 
@@ -276,7 +275,8 @@ uncompressgzipped(struct magic_set *ms, const unsigned char *old,
        }
        
        /* XXX: const castaway, via strchr */
-       z.next_in = (Bytef *)strchr(old + data_start, old[data_start]);
+       z.next_in = (Bytef *)strchr((const char *)old + data_start,
+           old[data_start]);
        z.avail_in = n - data_start;
        z.next_out = *newch;
        z.avail_out = HOWMANY;
@@ -296,7 +296,7 @@ uncompressgzipped(struct magic_set *ms, const unsigned char *old,
                return 0;
        }
 
-       n = z.total_out;
+       n = (size_t)z.total_out;
        inflateEnd(&z);
        
        /* let's keep the nul-terminate tradition */
@@ -307,10 +307,11 @@ uncompressgzipped(struct magic_set *ms, const unsigned char *old,
 #endif
 
 private size_t
-uncompressbuf(struct magic_set *ms, int method, const unsigned char *old,
+uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old,
     unsigned char **newch, size_t n)
 {
        int fdin[2], fdout[2];
+       int r;
 
        /* The buffer is NUL terminated, and we don't need that. */
        n--;
@@ -322,7 +323,7 @@ uncompressbuf(struct magic_set *ms, int method, const unsigned char *old,
 
        if (pipe(fdin) == -1 || pipe(fdout) == -1) {
                file_error(ms, "Cannot create pipe (%s)", strerror(errno));     
-               return -1;
+               return 0;
        }
        switch (fork()) {
        case 0: /* child */
@@ -344,7 +345,7 @@ uncompressbuf(struct magic_set *ms, int method, const unsigned char *old,
                /*NOTREACHED*/
        case -1:
                file_error(ms, "Could not fork (%s)", strerror(errno));
-               return -1;
+               return 0;
 
        default: /* parent */
                (void) close(fdin[0]);
@@ -359,10 +360,12 @@ uncompressbuf(struct magic_set *ms, int method, const unsigned char *old,
                        n = 0;
                        goto err;
                }
-               if ((n = sread(fdout[0], *newch, HOWMANY)) <= 0) {
+               if ((r = sread(fdout[0], *newch, HOWMANY)) <= 0) {
                        free(*newch);
-                       n = 0;
+                       r = 0;
                        goto err;
+               } else {
+                       n = r;
                }
                /* NUL terminate, as every buffer is handled here. */
                (*newch)[n++] = '\0';
index 94fad898106c819ee9ec254c6af628eeb286407e..9ffdfe60fc60b19de446590fb0351699801cfa90 100644 (file)
@@ -72,7 +72,7 @@
 #include "patchlevel.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$Id: file.c,v 1.73 2003/03/24 01:34:21 christos Exp $")
+FILE_RCSID("@(#)$Id: file.c,v 1.74 2003/03/26 15:35:30 christos Exp $")
 #endif /* lint */
 
 
@@ -369,7 +369,7 @@ process(const char *inname, int wid)
                (void) printf("%s%c%*s ", inname, separator,
                    (int) (nopad ? 0 : (wid - strlen(inname))), "");
 
-       type = magic_file(magic, inname);
+       type = magic_file(magic, strcmp(inname, "-") == 0 ? NULL : inname);
        if (type == NULL)
                printf("ERROR: %s\n", magic_error(magic));
        else
index 060a12f135bd95e43b4a94c35a3dd7efb75de343..da8a66b6f4eb81357f375ba7a2814fd535d0dd78 100644 (file)
@@ -32,7 +32,7 @@
  */
 /*
  * file.h - definitions for file(1) program
- * @(#)$Id: file.h,v 1.48 2003/03/24 01:16:28 christos Exp $
+ * @(#)$Id: file.h,v 1.49 2003/03/26 15:35:30 christos Exp $
  */
 
 #ifndef __file_h__
 #define FILE_COMPILE   2
 
 #ifndef __GNUC__
+#ifndef __attribute__
 #define __attribute__(a)
 #endif
+#endif
 
 struct magic {
        uint16_t cont_level;    /* level of ">" */
@@ -172,8 +174,8 @@ struct magic_set {
 };
 
 struct stat;
-protected char *file_fmttime(long, int);
-protected int file_buffer(struct magic_set *, const void *buf, size_t);
+protected char *file_fmttime(uint32_t, int);
+protected int file_buffer(struct magic_set *, const void *, size_t);
 protected int file_fsmagic(struct magic_set *, const char *, struct stat *);
 protected int file_pipe2file(struct magic_set *, int, const void *, size_t);
 protected int file_printf(struct magic_set *, const char *, ...);
@@ -191,7 +193,7 @@ protected void file_oomem(struct magic_set *);
 protected void file_error(struct magic_set *, const char *, ...);
 protected void file_magwarn(const char *, ...);
 protected void file_mdump(struct magic *);
-protected void file_showstr(FILE *, const char *, int);
+protected void file_showstr(FILE *, const char *, size_t);
 
 #ifndef HAVE_STRERROR
 extern int sys_nerr;
index 7f0722f2ce5466557d9d22307729209cab813f54..10db81640da81bd7ebeafc50b691e12b37a08259 100644 (file)
@@ -39,7 +39,7 @@ protected int
 file_printf(struct magic_set *ms, const char *fmt, ...)
 {
        va_list ap;
-       int len;
+       size_t len;
        char *buf;
 
        va_start(ap, fmt);
@@ -69,21 +69,14 @@ file_printf(struct magic_set *ms, const char *fmt, ...)
  */
 /*VARARGS*/
 protected void
-#ifdef __STDC__
 file_error(struct magic_set *ms, const char *f, ...)
-#else
-error(va_alist)
-       va_dcl
-#endif
 {
        va_list va;
-#ifdef __STDC__
+       /* Only the first error is ok */
+       if (ms->haderr)
+           return;
        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); 
 
index 11136da68d258e22009475f7f10331d1a54f6571..be9311b68444a084b323736bf79e1555e0bc69a9 100644 (file)
 #include "tar.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$Id: is_tar.c,v 1.19 2003/03/23 21:16:26 christos Exp $")
+FILE_RCSID("@(#)$Id: is_tar.c,v 1.20 2003/03/26 15:35:30 christos Exp $")
 #endif
 
 #define        isodigit(c)     ( ((c) >= '0') && ((c) <= '7') )
 
-private int from_oct(int, char *);     /* Decode octal number */
+private int from_oct(int, const char *);       /* Decode octal number */
 
 /*
  * Return 
@@ -65,10 +65,10 @@ private int from_oct(int, char *);  /* Decode octal number */
 protected int
 file_is_tar(const unsigned char *buf, size_t nbytes)
 {
-       union record *header = (union record *)buf;
+       const union record *header = (const union record *)(const void *)buf;
        int     i;
        int     sum, recsum;
-       char    *p;
+       const char      *p;
 
        if (nbytes < sizeof(union record))
                return 0;
@@ -106,7 +106,7 @@ file_is_tar(const unsigned char *buf, size_t nbytes)
  * Result is -1 if the field is invalid (all blank, or nonoctal).
  */
 private int
-from_oct(int digs, char *where)
+from_oct(int digs, const char *where)
 {
        int     value;
 
index 8a8106c61b19e472d4d35a3d63ab03a9fcf02635..e9154c4c7c8509252be36cd562ffab9e9fc6f909 100644 (file)
@@ -1,3 +1,31 @@
+/*
+ * Copyright (c) Christos Zoulas 2003.
+ * All Rights Reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice immediately at the beginning of the file, without modification,
+ *    this list of conditions, and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *  
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
 
 #include "magic.h"
 #include "file.h"
@@ -36,7 +64,7 @@
 #include "patchlevel.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$Id: magic.c,v 1.5 2003/03/24 01:34:21 christos Exp $")
+FILE_RCSID("@(#)$Id: magic.c,v 1.6 2003/03/26 15:35:30 christos Exp $")
 #endif /* lint */
 
 #ifdef __EMX__
@@ -176,10 +204,15 @@ magic_file(struct magic_set *ms, const char *inname)
                return ms->o.buf;
        }
 
-       if ((fd = open(inname, O_RDONLY)) < 0) {
+#ifndef        STDIN_FILENO
+#define        STDIN_FILENO    0
+#endif
+       if (inname == NULL)
+               fd = STDIN_FILENO;
+       else if ((fd = open(inname, O_RDONLY)) < 0) {
                /* We can't open it, but we were able to stat it. */
                if (sb.st_mode & 0002)
-                       if (file_printf(ms, "writeable, ") == -1)
+                       if (file_printf(ms, "writable, ") == -1)
                                return NULL;
                if (sb.st_mode & 0111)
                        if (file_printf(ms, "executable, ") == -1)
@@ -211,7 +244,7 @@ magic_file(struct magic_set *ms, const char *inname)
                        return ms->o.buf;
                }
 #endif
-               if (file_buffer(ms, buf, nbytes) == -1)
+               if (file_buffer(ms, buf, (size_t)nbytes) == -1)
                        return NULL;
 #ifdef BUILTIN_ELF
                if (nbytes > 5) {
@@ -223,7 +256,7 @@ magic_file(struct magic_set *ms, const char *inname)
                         * information from the ELF headers that can't easily
                         * be extracted with rules in the magic file.
                         */
-                       file_tryelf(ms, fd, buf, nbytes);
+                       file_tryelf(ms, fd, buf, (size_t)nbytes);
                }
 #endif
        }
@@ -233,7 +266,7 @@ magic_file(struct magic_set *ms, const char *inname)
 
 
 public const char *
-magic_buf(struct magic_set *ms, const void *buf, size_t nb)
+magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
 {
        if (file_reset(ms) == -1)
                return NULL;
index f07c7b5df1f0ff19bf92ab33cc18faa0aac0188b..2bdc9fff740e18d040a307a22b106f532f83b5fd 100644 (file)
@@ -46,7 +46,7 @@
 #include <time.h>
 
 #ifndef lint
-FILE_RCSID("@(#)$Id: print.c,v 1.42 2003/03/24 01:16:28 christos Exp $")
+FILE_RCSID("@(#)$Id: print.c,v 1.43 2003/03/26 15:35:30 christos Exp $")
 #endif  /* lint */
 
 #define SZOF(a)        (sizeof(a) / sizeof(a[0]))
@@ -84,9 +84,10 @@ file_mdump(struct magic *m)
        if (m->mask_op & FILE_OPINVERSE)
                (void) fputc('~', stderr);
        if (m->mask) {
-               ((m->mask_op&0x7F) < SZOF(optyp)) ? 
-                       (void) fputc(optyp[m->mask_op&0x7F], stderr) :
-                       (void) fputc('?', stderr);
+               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, "%.8x", m->mask);
                else {
@@ -116,7 +117,7 @@ file_mdump(struct magic *m)
                case FILE_STRING:
                case FILE_PSTRING:
                case FILE_REGEX:
-                       file_showstr(stderr, m->value.s, -1);
+                       file_showstr(stderr, m->value.s, ~0U);
                        break;
                case FILE_DATE:
                case FILE_LEDATE:
@@ -155,7 +156,7 @@ file_magwarn(const char *f, ...)
 }
 
 protected char *
-file_fmttime(long v, int local)
+file_fmttime(uint32_t v, int local)
 {
        char *pp, *rt;
        time_t t = (time_t)v;
index a7a9780c7b6beaf133219ecab9796366103e6053..f5bfb86cbc2b4291a05f555c1a13ffec0752c6ab 100644 (file)
@@ -39,7 +39,7 @@
 #include "readelf.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$Id: readelf.c,v 1.30 2003/03/23 21:16:26 christos Exp $")
+FILE_RCSID("@(#)$Id: readelf.c,v 1.31 2003/03/26 15:35:30 christos Exp $")
 #endif
 
 #ifdef ELFCORE
@@ -142,21 +142,23 @@ getu64(int swap, uint64_t value)
 #define ph_offset      (class == ELFCLASS32            \
                         ? getu32(swap, ph32.p_offset)  \
                         : getu64(swap, ph64.p_offset))
-#define ph_align       (class == ELFCLASS32            \
-                        ? (ph32.p_align ? getu32(swap, ph32.p_align) : 4) \
-                        : (ph64.p_align ? getu64(swap, ph64.p_align) : 4))
+#define ph_align       (int)((class == ELFCLASS32      \
+                        ? (off_t) (ph32.p_align ?      \
+                           getu32(swap, ph32.p_align) : 4) \
+                        : (off_t) (ph64.p_align ?      \
+                           getu64(swap, ph64.p_align) : 4)))
 #define nh_size                (class == ELFCLASS32            \
-                        ? sizeof *nh32                 \
-                        : sizeof *nh64)
+                        ? sizeof nh32                  \
+                        : sizeof nh64)
 #define nh_type                (class == ELFCLASS32            \
-                        ? getu32(swap, nh32->n_type)   \
-                        : getu32(swap, nh64->n_type))
+                        ? getu32(swap, nh32.n_type)    \
+                        : getu32(swap, nh64.n_type))
 #define nh_namesz      (class == ELFCLASS32            \
-                        ? getu32(swap, nh32->n_namesz) \
-                        : getu32(swap, nh64->n_namesz))
+                        ? getu32(swap, nh32.n_namesz)  \
+                        : getu32(swap, nh64.n_namesz))
 #define nh_descsz      (class == ELFCLASS32            \
-                        ? getu32(swap, nh32->n_descsz) \
-                        : getu32(swap, nh64->n_descsz))
+                        ? getu32(swap, nh32.n_descsz)  \
+                        : getu32(swap, nh64.n_descsz))
 #define prpsoffsets(i) (class == ELFCLASS32            \
                         ? prpsoffsets32[i]             \
                         : prpsoffsets64[i])
@@ -216,7 +218,7 @@ dophn_core(struct magic_set *ms, int class, int swap, int fd, off_t off,
        Elf32_Phdr ph32;
        Elf64_Phdr ph64;
        size_t offset;
-       char nbuf[BUFSIZ];
+       unsigned char nbuf[BUFSIZ];
        int bufsize;
 
        if (size != ph_size) {
@@ -256,8 +258,8 @@ dophn_core(struct magic_set *ms, int class, int swap, int fd, off_t off,
                for (;;) {
                        if (offset >= bufsize)
                                break;
-                       offset = donote(ms, nbuf, offset, bufsize, class, swap,
-                           4);
+                       offset = donote(ms, nbuf, offset, (size_t)bufsize,
+                           class, swap, 4);
 
                }
        }
@@ -269,17 +271,17 @@ private size_t
 donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
     int class, int swap, int align)
 {
-       Elf32_Nhdr *nh32 = NULL;
-       Elf64_Nhdr *nh64 = NULL;
+       Elf32_Nhdr nh32;
+       Elf64_Nhdr nh64;
        size_t noff, doff;
 #ifdef ELFCORE
        int os_style = -1;
 #endif
 
        if (class == ELFCLASS32)
-               nh32 = (Elf32_Nhdr *)&nbuf[offset];
+               memcpy(&nh32, &nbuf[offset], sizeof(nh32));
        else
-               nh64 = (Elf64_Nhdr *)&nbuf[offset];
+               memcpy(&nh64, &nbuf[offset], sizeof(nh64));
        offset += nh_size;
 
        if ((nh_namesz == 0) && (nh_descsz == 0)) {
@@ -303,41 +305,44 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
        if (offset + nh_descsz >= size)
                return offset;
 
-       if (nh_namesz == 4 && strcmp(&nbuf[noff], "GNU") == 0 &&
+       if (nh_namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 &&
            nh_type == NT_GNU_VERSION && nh_descsz == 16) {
-               uint32_t *desc = (uint32_t *)&nbuf[doff];
+               uint32_t desc[4];
+               (void)memcpy(desc, &nbuf[doff], sizeof(desc));
 
                if (file_printf(ms, ", for GNU/") == -1)
-                       return -1;
+                       return size;
                switch (getu32(swap, desc[0])) {
                case GNU_OS_LINUX:
                        if (file_printf(ms, "Linux") == -1)
-                               return -1;
+                               return size;
                        break;
                case GNU_OS_HURD:
                        if (file_printf(ms, "Hurd") == -1)
-                               return -1;
+                               return size;
                        break;
                case GNU_OS_SOLARIS:
                        if (file_printf(ms, "Solaris") == -1)
-                               return -1;
+                               return size;
                        break;
                default:
                        if (file_printf(ms, "<unknown>") == -1)
-                               return -1;
+                               return size; 
                }
                if (file_printf(ms, " %d.%d.%d", getu32(swap, desc[1]),
                    getu32(swap, desc[2]), getu32(swap, desc[3])) == -1)
-                       return -1;
+                       return size;
                return size;
        }
 
-       if (nh_namesz == 7 && strcmp(&nbuf[noff], "NetBSD") == 0 &&
+       if (nh_namesz == 7 && strcmp((char *)&nbuf[noff], "NetBSD") == 0 &&
            nh_type == NT_NETBSD_VERSION && nh_descsz == 4) {
-               uint32_t desc = getu32(swap, *(uint32_t *)&nbuf[doff]);
+               uint32_t desc;
+               (void)memcpy(&desc, &nbuf[doff], sizeof(desc));
+               desc = getu32(swap, desc);
 
                if (file_printf(ms, ", for NetBSD") == -1)
-                       return -1;
+                       return size;
                /*
                 * The version number used to be stuck as 199905, and was thus
                 * basically content-free.  Newer versions of NetBSD have fixed
@@ -357,48 +362,52 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
                        u_int ver_maj = desc / 100000000;
 
                        if (file_printf(ms, " %u.%u", ver_maj, ver_min) == -1)
-                               return -1;
+                               return size;
                        if (ver_rel == 0 && ver_patch != 0) {
                                if (file_printf(ms, ".%u", ver_patch) == -1)
-                                       return -1;
+                                       return size;
                        } else if (ver_rel != 0 && ver_rel <= 26) {
-                               if (file_printf(ms, "%c", 'A' + ver_rel - 1) == -1)
-                                       return -1;
+                               if (file_printf(ms, "%c", 'A' + ver_rel - 1)
+                                   == -1)
+                                       return size;
                        } else if (ver_rel != 0 && ver_rel <= 52) {
-                               if (file_printf(ms, "Z%c", 'A' + ver_rel - 1) == -1)
-                                       return -1;
+                               if (file_printf(ms, "Z%c", 'A' + ver_rel - 1)
+                                   == -1)
+                                       return size;
                        } else if (ver_rel != 0) {
                                if (file_printf(ms, "<unknown>") == -1)
-                                       return -1;
+                                       return size;
                        }
                }
                return size;
        }
 
-       if (nh_namesz == 8 && strcmp(&nbuf[noff], "FreeBSD") == 0 &&
+       if (nh_namesz == 8 && strcmp((char *)&nbuf[noff], "FreeBSD") == 0 &&
            nh_type == NT_FREEBSD_VERSION && nh_descsz == 4) {
-               uint32_t desc = getu32(swap,
-                   *(uint32_t *)&nbuf[doff]);
+               uint32_t desc;
+               (void)memcpy(&desc, &nbuf[doff], sizeof(desc));
+               desc = getu32(swap, desc);
                if (file_printf(ms, ", for FreeBSD") == -1)
-                       return -1;
+                       return size;
                /*
                 * Contents is __FreeBSD_version, whose relation to OS versions
                 * is defined by a huge table in the Porters' Handbook. Happily,
                 * the first three digits are the version number, at least in
                 * versions of FreeBSD that use this note.
                 */
-               if (file_printf(ms, " %d.%d", desc / 100000, desc / 10000 % 10) == -1)
-                       return -1;
+               if (file_printf(ms, " %d.%d", desc / 100000, desc / 10000 % 10)
+                   == -1)
+                       return size;
                if (desc / 1000 % 10 > 0)
                        if (file_printf(ms, ".%d", desc / 1000 % 10) == -1)
-                               return -1;
+                               return size;
                return size;
        }
 
-       if (nh_namesz == 8 && strcmp(&nbuf[noff], "OpenBSD") == 0 &&
+       if (nh_namesz == 8 && strcmp((char *)&nbuf[noff], "OpenBSD") == 0 &&
            nh_type == NT_OPENBSD_VERSION && nh_descsz == 4) {
                if (file_printf(ms, ", for OpenBSD") == -1)
-                       return -1;
+                       return size;
                /* Content of note is always 0 */
                return size;
        }
@@ -417,23 +426,24 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
         * doesn't include the terminating null in the
         * name....
         */
-       if ((nh_namesz == 4 && strncmp(&nbuf[noff], "CORE", 4) == 0) ||
-           (nh_namesz == 5 && strcmp(&nbuf[noff], "CORE") == 0)) {
+       if ((nh_namesz == 4 && strncmp((char *)&nbuf[noff], "CORE", 4) == 0) ||
+           (nh_namesz == 5 && strcmp((char *)&nbuf[noff], "CORE") == 0)) {
                os_style = OS_STYLE_SVR4;
        } 
 
-       if ((nh_namesz == 8 && strcmp(&nbuf[noff], "FreeBSD") == 0)) {
+       if ((nh_namesz == 8 && strcmp((char *)&nbuf[noff], "FreeBSD") == 0)) {
                os_style = OS_STYLE_FREEBSD;
        }
 
-       if ((nh_namesz >= 11 && strncmp(&nbuf[noff], "NetBSD-CORE", 11) == 0)) {
+       if ((nh_namesz >= 11 && strncmp((char *)&nbuf[noff], "NetBSD-CORE", 11)
+           == 0)) {
                os_style = OS_STYLE_NETBSD;
        }
 
 #ifdef ELFCORE
        if (os_style != -1)
                if (file_printf(ms, ", %s-style", os_style_names[os_style]) == -1)
-                       return -1;
+                       return size;
 
        if (os_style == OS_STYLE_NETBSD && nh_type == NT_NETBSD_CORE_PROCINFO) {
                uint32_t signo;
@@ -443,7 +453,7 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
                 * including the terminating NUL.
                 */
                if (file_printf(ms, ", from '%.31s'", &nbuf[doff + 0x7c]) == -1)
-                       return -1;
+                       return size;
                
                /*
                 * Extract the signal number.  It is at
@@ -452,7 +462,7 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
                memcpy(&signo, &nbuf[doff + 0x08],
                    sizeof(signo));
                if (file_printf(ms, " (signal %u)", getu32(swap, signo)) == -1)
-                       return -1;
+                       return size;
                return size;
        } else if (os_style != OS_STYLE_NETBSD && nh_type == NT_PRPSINFO) {
                int i, j;
@@ -518,7 +528,7 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
                         */
                        if (file_printf(ms, ", from '%.16s'",
                            &nbuf[doff + prpsoffsets(i)]) == -1)
-                               return -1;
+                               return size;
                        return size;
 
                tryanother:
@@ -576,7 +586,7 @@ dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off,
        Elf64_Phdr ph64;
        const char *linking_style = "statically";
        const char *shared_libraries = "";
-       char nbuf[BUFSIZ];
+       unsigned char nbuf[BUFSIZ];
        int bufsize;
        size_t offset;
        off_t savedoffset;
@@ -595,7 +605,7 @@ dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off,
                        file_badread(ms);
                        return -1;
                }
-               if ((savedoffset = lseek(fd, 0, SEEK_CUR)) == (off_t)-1) {
+               if ((savedoffset = lseek(fd, (off_t)0, SEEK_CUR)) == (off_t)-1) {
                        file_badseek(ms);
                        return -1;
                }
@@ -626,8 +636,8 @@ dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off,
                        for (;;) {
                                if (offset >= bufsize)
                                        break;
-                               offset = donote(ms, nbuf, offset, bufsize,
-                                   class, swap, ph_align);
+                               offset = donote(ms, nbuf, offset,
+                                   (size_t)bufsize, class, swap, ph_align);
                        }
                        if (lseek(fd, savedoffset + offset, SEEK_SET)
                            == (off_t)-1) {
@@ -688,9 +698,9 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
                if (getu16(swap, elfhdr.e_type) == ET_CORE) {
 #ifdef ELFCORE
                        if (dophn_core(ms, class, swap, fd,
-                           getu32(swap, elfhdr.e_phoff),
+                           (off_t)getu32(swap, elfhdr.e_phoff),
                            getu16(swap, elfhdr.e_phnum), 
-                           getu16(swap, elfhdr.e_phentsize)) == -1)
+                           (size_t)getu16(swap, elfhdr.e_phentsize)) == -1)
                                return -1;
 #else
                        ;
@@ -698,15 +708,16 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
                } else {
                        if (getu16(swap, elfhdr.e_type) == ET_EXEC) {
                                if (dophn_exec(ms, class, swap,
-                                   fd, getu32(swap, elfhdr.e_phoff),
+                                   fd, (off_t)getu32(swap, elfhdr.e_phoff),
                                    getu16(swap, elfhdr.e_phnum), 
-                                   getu16(swap, elfhdr.e_phentsize)) == -1)
+                                   (size_t)getu16(swap, elfhdr.e_phentsize))
+                                   == -1)
                                        return -1;
                        }
                        if (doshn(ms, class, swap, fd,
-                           getu32(swap, elfhdr.e_shoff),
+                           (off_t)getu32(swap, elfhdr.e_shoff),
                            getu16(swap, elfhdr.e_shnum),
-                           getu16(swap, elfhdr.e_shentsize)) == -1)
+                           (size_t)getu16(swap, elfhdr.e_shentsize)) == -1)
                                return -1;
                }
                return 1;
@@ -726,12 +737,12 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
 #ifdef ELFCORE
                        if (dophn_core(ms, class, swap, fd,
 #ifdef USE_ARRAY_FOR_64BIT_TYPES
-                           getu32(swap, elfhdr.e_phoff[1]),
+                           (off_t)getu32(swap, elfhdr.e_phoff[1]),
 #else
-                           getu64(swap, elfhdr.e_phoff),
+                           (off_t)getu64(swap, elfhdr.e_phoff),
 #endif
                            getu16(swap, elfhdr.e_phnum), 
-                           getu16(swap, elfhdr.e_phentsize)) == -1)
+                           (size_t)getu16(swap, elfhdr.e_phentsize)) == -1)
                                return -1;
 #else
                        ;
@@ -740,22 +751,23 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
                        if (getu16(swap, elfhdr.e_type) == ET_EXEC) {
                                if (dophn_exec(ms, class, swap, fd,
 #ifdef USE_ARRAY_FOR_64BIT_TYPES
-                                   getu32(swap, elfhdr.e_phoff[1]),
+                                   (off_t)getu32(swap, elfhdr.e_phoff[1]),
 #else
-                                   getu64(swap, elfhdr.e_phoff),
+                                   (off_t)getu64(swap, elfhdr.e_phoff),
 #endif
                                    getu16(swap, elfhdr.e_phnum), 
-                                   getu16(swap, elfhdr.e_phentsize)) == -1)
+                                   (size_t)getu16(swap, elfhdr.e_phentsize))
+                                   == -1)
                                        return -1;
                        }
                        if (doshn(ms, class, swap, fd,
 #ifdef USE_ARRAY_FOR_64BIT_TYPES
-                           getu32(swap, elfhdr.e_shoff[1]),
+                           (off_t)getu32(swap, elfhdr.e_shoff[1]),
 #else
-                           getu64(swap, elfhdr.e_shoff),
+                           (off_t)getu64(swap, elfhdr.e_shoff),
 #endif
                            getu16(swap, elfhdr.e_shnum),
-                           getu16(swap, elfhdr.e_shentsize)) == -1)
+                           (size_t)getu16(swap, elfhdr.e_shentsize)) == -1)
                                return -1;
                }
                return 1;
index 7b069bc734f4d7cecdbec14667208624c8beaff1..4a718fae137d60b5ee3292f87489d4121f78a45a 100644 (file)
@@ -44,7 +44,7 @@
 
 
 #ifndef        lint
-FILE_RCSID("@(#)$Id: softmagic.c,v 1.57 2003/03/24 01:16:28 christos Exp $")
+FILE_RCSID("@(#)$Id: softmagic.c,v 1.58 2003/03/26 15:35:30 christos Exp $")
 #endif /* lint */
 
 private int match(struct magic_set *, struct magic *, uint32_t,
@@ -124,6 +124,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
                        return -1;
                case 0:
                        flush++;
+                       break;
                default:
                        break;
                }
@@ -249,7 +250,7 @@ mprint(struct magic_set *ms, union VALUETYPE *p, struct magic *m)
 
        switch (m->type) {
        case FILE_BYTE:
-               v = file_signextend(ms, m, p->b);
+               v = file_signextend(ms, m, (size_t)p->b);
                if (file_printf(ms, m->desc, (unsigned char) v) == -1)
                        return -1;
                t = m->offset + sizeof(char);
@@ -258,7 +259,7 @@ mprint(struct magic_set *ms, union VALUETYPE *p, struct magic *m)
        case FILE_SHORT:
        case FILE_BESHORT:
        case FILE_LESHORT:
-               v = file_signextend(ms, m, p->h);
+               v = file_signextend(ms, m, (size_t)p->h);
                if (file_printf(ms, m->desc, (unsigned short) v) == -1)
                        return -1;
                t = m->offset + sizeof(short);
@@ -613,12 +614,12 @@ mget(struct magic_set *ms, union VALUETYPE *p, const unsigned char *s,
                 * (starting at 1), not as bytes-from start-of-file
                 */
                unsigned char *b, *last = NULL;
-               if ((b = p->buf = strdup(s)) == NULL) {
+               if ((p->buf = strdup((const char *)s)) == NULL) {
                        file_oomem(ms);
                        return -1;
                }
-
-               for (; offset && (b = (unsigned char *)strchr(b, '\n')) != NULL;
+               for (b = (unsigned char *)p->buf; offset &&
+                   (b = (unsigned char *)strchr((char *)b, '\n')) != NULL;
                    offset--, s++)
                        last = b;
                if (last != NULL)
@@ -633,11 +634,11 @@ mget(struct magic_set *ms, union VALUETYPE *p, const unsigned char *s,
                int32_t have = nbytes - offset;
                memset(p, 0, sizeof(union VALUETYPE));
                if (have > 0)
-                       memcpy(p, s + offset, have);
+                       memcpy(p, s + offset, (size_t)have);
        }
 
        if ((ms->flags & MAGIC_DEBUG) != 0) {
-               mdebug(offset, (char *) p, sizeof(union VALUETYPE));
+               mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE));
                file_mdump(m);
        }
 
@@ -971,7 +972,8 @@ mget(struct magic_set *ms, union VALUETYPE *p, const unsigned char *s,
                memcpy(p, s + offset, sizeof(union VALUETYPE));
 
                if ((ms->flags & MAGIC_DEBUG) != 0) {
-                       mdebug(offset, (char *) p, sizeof(union VALUETYPE));
+                       mdebug(offset, (char *)(void *)p,
+                           sizeof(union VALUETYPE));
                        file_mdump(m);
                }
        }