]> granicus.if.org Git - file/commitdiff
Fix bzip2 issue
authorChristos Zoulas <christos@zoulas.com>
Fri, 7 Jan 2005 19:17:24 +0000 (19:17 +0000)
committerChristos Zoulas <christos@zoulas.com>
Fri, 7 Jan 2005 19:17:24 +0000 (19:17 +0000)
13 files changed:
ChangeLog
Makefile.in
aclocal.m4
configure
doc/Makefile.in
magic/Makefile.in
magic/magic.mime
python/Makefile.in
src/Makefile.in
src/compress.c
src/file.h
src/funcs.c
src/magic.c

index c7ca5450aad09283833541180206640156b20fe4..62143e10cc347be7b3a8b2d7d27833dfcfca4a30 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-12-07 14:15  Christos Zoulas  <christos@zoulas.com>
+
+       * bzip2 needs a lot of input buffer space on some files
+         before it can begin uncompressing. This makes file -z
+         fail on some bz2 files. Fix it by giving it a copy of
+         the file descriptor to read as much as it wants if we
+         have access to it. <christos@zoulas.com>
+
 2004-11-24 12:39  Christos Zoulas  <christos@zoulas.com>
 
        * Stack smash fix, and ELF more conservative reading.
index 33f9e83c4d36e0546b3268f27014150aaf6d94e9..99dcdb8230d964d7bd3e78914f77d0f7f0b1ce2d 100644 (file)
@@ -75,6 +75,7 @@ ECHO = @ECHO@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
+MAINT = @MAINT@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
@@ -116,18 +117,18 @@ all: config.h
 
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno
-$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
        cd $(top_srcdir) && \
          $(AUTOMAKE) --foreign  Makefile
-Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
        cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)
 
 $(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
        $(SHELL) ./config.status --recheck
-$(srcdir)/configure:  $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
+$(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
        cd $(srcdir) && $(AUTOCONF)
 
-$(ACLOCAL_M4):  configure.in acinclude.m4
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.in acinclude.m4
        cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
 
 config.h: stamp-h1
@@ -140,7 +141,7 @@ stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
        @rm -f stamp-h1
        cd $(top_builddir) && $(SHELL) ./config.status config.h
 
-$(srcdir)/config.h.in:  $(top_srcdir)/configure.in $(ACLOCAL_M4) 
+$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(top_srcdir)/configure.in $(ACLOCAL_M4) 
        cd $(top_srcdir) && $(AUTOHEADER)
        touch $(srcdir)/config.h.in
 
index 7b09909535a1a2ec44aeb1b926d0dddd4c5feec1..8a86889989e5bafa2e3c44348efe3ee2ff121580 100644 (file)
@@ -1119,6 +1119,43 @@ AC_DEFUN([AM_CONFIG_HEADER],
 [AC_FOREACH([_AM_File], [$1], [_AM_CONFIG_HEADER(_AM_File, [$2], [$3])])
 ])# AM_CONFIG_HEADER
 
+# Add --enable-maintainer-mode option to configure.
+# From Jim Meyering
+
+# Copyright 1996, 1998, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 1
+
+AC_DEFUN([AM_MAINTAINER_MODE],
+[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
+  dnl maintainer-mode is disabled by default
+  AC_ARG_ENABLE(maintainer-mode,
+[  --enable-maintainer-mode enable make rules and dependencies not useful
+                          (and sometimes confusing) to the casual installer],
+      USE_MAINTAINER_MODE=$enableval,
+      USE_MAINTAINER_MODE=no)
+  AC_MSG_RESULT([$USE_MAINTAINER_MODE])
+  AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
+  MAINT=$MAINTAINER_MODE_TRUE
+  AC_SUBST(MAINT)dnl
+]
+)
+
 # libtool.m4 - Configure libtool for the host system. -*-Shell-script-*-
 
 # serial 46 AC_PROG_LIBTOOL
index 26a1e14f22b8de7f117dfac51a8a10cdf416dcd3..e5854d6f4b349d3e973e789f1224f91c78ddc064 100755 (executable)
--- a/configure
+++ b/configure
@@ -990,6 +990,8 @@ if test -n "$ac_init_help"; then
 Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-maintainer-mode enable make rules and dependencies not useful
+                          (and sometimes confusing) to the casual installer
   --disable-elf            disable builtin ELF support
   --disable-elf-core       disable ELF core file support
   --enable-fsect-man5      enable file formats in man section 5
@@ -1751,6 +1753,30 @@ ac_config_headers="$ac_config_headers config.h"
 
 
 
+echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5
+echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6
+    # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
+if test "${enable_maintainer_mode+set}" = set; then
+  enableval="$enable_maintainer_mode"
+  USE_MAINTAINER_MODE=$enableval
+else
+  USE_MAINTAINER_MODE=no
+fi;
+  echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5
+echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6
+
+
+if test $USE_MAINTAINER_MODE = yes; then
+  MAINTAINER_MODE_TRUE=
+  MAINTAINER_MODE_FALSE='#'
+else
+  MAINTAINER_MODE_TRUE='#'
+  MAINTAINER_MODE_FALSE=
+fi
+
+  MAINT=$MAINTAINER_MODE_TRUE
+
+
 
 echo "$as_me:$LINENO: checking for builtin ELF support" >&5
 echo $ECHO_N "checking for builtin ELF support... $ECHO_C" >&6
@@ -4328,7 +4354,7 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
 case $host in
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 4331 "configure"' > conftest.$ac_ext
+  echo '#line 4357 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -4864,7 +4890,7 @@ chmod -w .
 save_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
 compiler_c_o=no
-if { (eval echo configure:4867: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
+if { (eval echo configure:4893: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
   # The compiler can only warn and ignore the option if not recognized
   # So say no if there are warnings
   if test -s out/conftest.err; then
@@ -6657,7 +6683,7 @@ else
     lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 6660 "configure"
+#line 6686 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -6755,7 +6781,7 @@ else
     lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 6758 "configure"
+#line 6784 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
 
 DEFS=-DHAVE_CONFIG_H
 
+if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"MAINTAINER_MODE\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 if test -z "${FSECT5_TRUE}" && test -z "${FSECT5_FALSE}"; then
   { { echo "$as_me:$LINENO: error: conditional \"FSECT5\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -11508,6 +11541,9 @@ s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t
 s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t
 s,@AWK@,$AWK,;t t
 s,@SET_MAKE@,$SET_MAKE,;t t
+s,@MAINTAINER_MODE_TRUE@,$MAINTAINER_MODE_TRUE,;t t
+s,@MAINTAINER_MODE_FALSE@,$MAINTAINER_MODE_FALSE,;t t
+s,@MAINT@,$MAINT,;t t
 s,@fsect@,$fsect,;t t
 s,@FSECT5_TRUE@,$FSECT5_TRUE,;t t
 s,@FSECT5_FALSE@,$FSECT5_FALSE,;t t
index 0810e5fc1b0acfd8d88a9fb822a90013646d9616..cfa9ef65ba24909605c7a0f07485b5a4d91f8d58 100644 (file)
@@ -75,6 +75,7 @@ ECHO = @ECHO@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
+MAINT = @MAINT@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
@@ -103,10 +104,10 @@ DIST_COMMON = Makefile.am Makefile.in
 all: all-am
 
 .SUFFIXES:
-$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
        cd $(top_srcdir) && \
          $(AUTOMAKE) --gnu  doc/Makefile
-Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
        cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
 
 mostlyclean-libtool:
index e5bd17315ded37d2dff094feac012f460f6b88d3..0e78128b68d803e111c40162cae39981e949797e 100644 (file)
@@ -75,6 +75,7 @@ ECHO = @ECHO@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
+MAINT = @MAINT@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
@@ -284,10 +285,10 @@ DIST_COMMON = Makefile.am Makefile.in
 all: all-am
 
 .SUFFIXES:
-$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
        cd $(top_srcdir) && \
          $(AUTOMAKE) --gnu  magic/Makefile
-Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
        cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
 
 mostlyclean-libtool:
index 5c484bf1bb59629c6708fe68efa5edb20e0b521e..9be5646748f32004f9b1c88a332c4c6acccba707 100644 (file)
 
 # XPM icons (Greg Roelofs, newt@uchicago.edu)
 # ideally should go into "images", but entries below would tag XPM as C source
-0      string          /*\ XPM         image/x-xpm     7bit
+0      string          /*\ XPM         image/x-xpmi 7bit
 
 # 3DS (3d Studio files)
 16     beshort         0x3d3d          image/x-3ds
index 06b11494a35913c11d9af86a388a16cbe3990830..dd6322dee0d87d961fe5d28544199e5866574a91 100644 (file)
@@ -75,6 +75,7 @@ ECHO = @ECHO@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
+MAINT = @MAINT@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
@@ -95,10 +96,10 @@ DIST_COMMON = README Makefile.am Makefile.in
 all: all-am
 
 .SUFFIXES:
-$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
        cd $(top_srcdir) && \
          $(AUTOMAKE) --gnu  python/Makefile
-Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
        cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
 
 mostlyclean-libtool:
index a154aff8fcb46d97552d6f55b4159c5caa1028e6..b1c1450d50fcd9b11bedc5babce37a546236cc42 100644 (file)
@@ -152,10 +152,10 @@ all: all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
        cd $(top_srcdir) && \
          $(AUTOMAKE) --gnu  src/Makefile
-Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
        cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
 libLTLIBRARIES_INSTALL = $(INSTALL)
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
index 78fcf42abbc8535044bb2a1f702c73d0fbd786ce..a176b8e2a2ac3180e34c4aacc3aa02116e0b4483 100644 (file)
@@ -50,7 +50,7 @@
 #endif
 
 #ifndef lint
-FILE_RCSID("@(#)$Id: compress.c,v 1.40 2004/12/20 19:48:59 christos Exp $")
+FILE_RCSID("@(#)$Id: compress.c,v 1.41 2005/01/07 19:17:26 christos Exp $")
 #endif
 
 
@@ -77,15 +77,16 @@ private int ncompr = sizeof(compr) / sizeof(compr[0]);
 
 private ssize_t swrite(int, const void *, size_t);
 private ssize_t sread(int, void *, size_t);
-private size_t uncompressbuf(struct magic_set *, size_t, const unsigned char *,
-    unsigned char **, size_t);
+private size_t uncompressbuf(struct magic_set *, int, size_t,
+    const unsigned char *, unsigned char **, size_t);
 #ifdef HAVE_LIBZ
 private size_t uncompressgzipped(struct magic_set *, const unsigned char *,
     unsigned char **, size_t);
 #endif
 
 protected int
-file_zmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
+file_zmagic(struct magic_set *ms, int fd, const unsigned char *buf,
+    size_t nbytes)
 {
        unsigned char *newbuf = NULL;
        size_t i, nsz;
@@ -98,14 +99,15 @@ 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) {
+                   (nsz = uncompressbuf(ms, fd, i, buf, &newbuf,
+                   nbytes)) != 0) {
                        ms->flags &= ~MAGIC_COMPRESS;
                        rv = -1;
-                       if (file_buffer(ms, newbuf, nsz) == -1)
+                       if (file_buffer(ms, -1, newbuf, nsz) == -1)
                                goto error;
                        if (file_printf(ms, " (") == -1)
                                goto error;
-                       if (file_buffer(ms, buf, nbytes) == -1)
+                       if (file_buffer(ms, -1, buf, nbytes) == -1)
                                goto error;
                        if (file_printf(ms, ")") == -1)
                                goto error;
@@ -308,8 +310,8 @@ uncompressgzipped(struct magic_set *ms, const unsigned char *old,
 #endif
 
 private size_t
-uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old,
-    unsigned char **newch, size_t n)
+uncompressbuf(struct magic_set *ms, int fd, size_t method,
+    const unsigned char *old, unsigned char **newch, size_t n)
 {
        int fdin[2], fdout[2];
        int r;
@@ -321,26 +323,37 @@ uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old,
        (void)fflush(stdout);
        (void)fflush(stderr);
 
-       if (pipe(fdin) == -1 || pipe(fdout) == -1) {
+       if ((fd != -1 && pipe(fdin) == -1) || pipe(fdout) == -1) {
                file_error(ms, errno, "cannot create pipe");    
                return 0;
        }
        switch (fork()) {
        case 0: /* child */
                (void) close(0);
-               (void) dup(fdin[0]);
-               (void) close(fdin[0]);
-               (void) close(fdin[1]);
+               if (fd != -1) {
+                   (void) dup(fd);
+                   (void) lseek(0, (off_t)0, SEEK_SET);
+               } else {
+                   (void) dup(fdin[0]);
+                   (void) close(fdin[0]);
+                   (void) close(fdin[1]);
+               }
 
                (void) close(1);
                (void) dup(fdout[1]);
                (void) close(fdout[0]);
                (void) close(fdout[1]);
+#ifndef DEBUG
                if (compr[method].silent)
-                       (void) close(2);
+                       (void)close(2);
+#endif
 
                execvp(compr[method].argv[0],
                       (char *const *)compr[method].argv);
+#ifdef DEBUG
+               (void)fprintf(stderr, "exec `%s' failed (%s)\n",
+                   compr[method].argv[0], strerror(errno));
+#endif
                exit(1);
                /*NOTREACHED*/
        case -1:
@@ -348,31 +361,55 @@ uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old,
                return 0;
 
        default: /* parent */
-               (void) close(fdin[0]);
                (void) close(fdout[1]);
-               /* fork again, to avoid blocking because both pipes filled */
-               switch (fork()) {
-               case 0: /* child */
-                       (void)close(fdout[0]);
-                       if (swrite(fdin[1], old, n) != n)
+               if (fd == -1) {
+                       (void) close(fdin[0]);
+                       /* 
+                        * fork again, to avoid blocking because both
+                        * pipes filled
+                        */
+                       switch (fork()) {
+                       case 0: /* child */
+                               (void)close(fdout[0]);
+                               if (swrite(fdin[1], old, n) != n) {
+#ifdef DEBUG
+                                       (void)fprintf(stderr,
+                                           "Write failed (%s)\n",
+                                           strerror(errno));
+#endif
+                                       exit(1);
+                               }
+                               exit(0);
+                               /*NOTREACHED*/
+
+                       case -1:
+#ifdef DEBUG
+                               (void)fprintf(stderr, "Fork failed (%s)\n",
+                                   strerror(errno));
+#endif
                                exit(1);
-                       exit(0);
-                       /*NOTREACHED*/
+                               /*NOTREACHED*/
 
-               case -1:
-                       exit(1);
-                       /*NOTREACHED*/
-
-               default:  /* parent */
-                       break;
+                       default:  /* parent */
+                               break;
+                       }
+                       (void) close(fdin[1]);
+                       fdin[1] = -1;
                }
-               (void) close(fdin[1]);
-               fdin[1] = -1;
+
                if ((*newch = (unsigned char *) malloc(HOWMANY + 1)) == NULL) {
+#ifdef DEBUG
+                       (void)fprintf(stderr, "Malloc failed (%s)\n",
+                           strerror(errno));
+#endif
                        n = 0;
                        goto err;
                }
                if ((r = sread(fdout[0], *newch, HOWMANY)) <= 0) {
+#ifdef DEBUG
+                       (void)fprintf(stderr, "Read failed (%s)\n",
+                           strerror(errno));
+#endif
                        free(*newch);
                        n = 0;
                        newch[0] = '\0';
index f29bba01afc42e54da3e9b11a8011f4bb8e05b6c..1fa77586cf18067b3d6c0ea044c3246937e90831 100644 (file)
@@ -27,7 +27,7 @@
  */
 /*
  * file.h - definitions for file(1) program
- * @(#)$Id: file.h,v 1.64 2004/11/20 23:50:12 christos Exp $
+ * @(#)$Id: file.h,v 1.65 2005/01/07 19:17:26 christos Exp $
  */
 
 #ifndef __file_h__
@@ -241,13 +241,13 @@ struct magic_set {
 
 struct stat;
 protected char *file_fmttime(uint32_t, int);
-protected int file_buffer(struct magic_set *, const void *, size_t);
+protected int file_buffer(struct magic_set *, int, 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 *, ...);
 protected int file_reset(struct magic_set *);
 protected int file_tryelf(struct magic_set *, int, const unsigned char *, size_t);
-protected int file_zmagic(struct magic_set *, const unsigned char *, size_t);
+protected int file_zmagic(struct magic_set *, int, const unsigned char *, size_t);
 protected int file_ascmagic(struct magic_set *, const unsigned char *, size_t);
 protected int file_is_tar(struct magic_set *, const unsigned char *, size_t);
 protected int file_softmagic(struct magic_set *, const unsigned char *, size_t);
index bd77f13cabc25d089d78c184765b933bd8209c44..a2ceff7f8e44db83220c96656dafb58c0d92b224 100644 (file)
@@ -32,7 +32,7 @@
 #include <ctype.h>
 
 #ifndef        lint
-FILE_RCSID("@(#)$Id: funcs.c,v 1.13 2004/09/11 19:15:57 christos Exp $")
+FILE_RCSID("@(#)$Id: funcs.c,v 1.14 2005/01/07 19:17:27 christos Exp $")
 #endif /* lint */
 /*
  * Like printf, only we print to a buffer and advance it.
@@ -110,11 +110,11 @@ file_badread(struct magic_set *ms)
 
 #ifndef COMPILE_ONLY
 protected int
-file_buffer(struct magic_set *ms, const void *buf, size_t nb)
+file_buffer(struct magic_set *ms, int fd, const void *buf, size_t nb)
 {
     int m;
     /* try compression stuff */
-    if ((m = file_zmagic(ms, buf, nb)) == 0) {
+    if ((m = file_zmagic(ms, fd, buf, nb)) == 0) {
        /* Check if we have a tar file */
        if ((m = file_is_tar(ms, buf, nb)) == 0) {
            /* try tests in /etc/magic (or surrogate magic file) */
index 4516ba85cf21e1177881b538f8d0d94e3a8aa35a..872b62d0af9b73189100ed41fcfc2eb003508c87 100644 (file)
@@ -63,7 +63,7 @@
 #include "patchlevel.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$Id: magic.c,v 1.24 2004/09/27 15:28:37 christos Exp $")
+FILE_RCSID("@(#)$Id: magic.c,v 1.25 2005/01/07 19:17:27 christos Exp $")
 #endif /* lint */
 
 #ifdef __EMX__
@@ -277,7 +277,7 @@ magic_file(struct magic_set *ms, const char *inname)
                        goto gotit;
                }
 #endif
-               if (file_buffer(ms, buf, (size_t)nbytes) == -1)
+               if (file_buffer(ms, fd, buf, (size_t)nbytes) == -1)
                        goto done;
 #ifdef BUILTIN_ELF
                if (nbytes > 5) {
@@ -311,7 +311,7 @@ magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
         * The main work is done here!
         * We have the file name and/or the data buffer to be identified. 
         */
-       if (file_buffer(ms, buf, nb) == -1) {
+       if (file_buffer(ms, -1, buf, nb) == -1) {
                return NULL;
        }
        return file_getbuffer(ms);