]> granicus.if.org Git - file/commitdiff
WIN32 changes from Angelo Paolitto
authorChristos Zoulas <christos@zoulas.com>
Thu, 4 Dec 2014 15:56:46 +0000 (15:56 +0000)
committerChristos Zoulas <christos@zoulas.com>
Thu, 4 Dec 2014 15:56:46 +0000 (15:56 +0000)
src/cdf.c
src/compress.c
src/file.h
src/fsmagic.c
src/magic.c
src/readcdf.c
src/vasprintf.c

index db83b213b8dae197fbad2c56443dfa1b8d5b6c2b..9e3cf9fd2c6b335808a93c8353bdb0c7f9e60373 100644 (file)
--- a/src/cdf.c
+++ b/src/cdf.c
@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.68 2014/10/22 19:27:36 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.69 2014/12/04 15:56:46 christos Exp $")
 #endif
 
 #include <assert.h>
@@ -825,10 +825,11 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
                goto out;
        for (i = 0; i < sh.sh_properties; i++) {
                size_t tail = (i << 1) + 1;
+               size_t ofs;
                if (cdf_check_stream_offset(sst, h, p, tail * sizeof(uint32_t),
                    __LINE__) == -1)
                        goto out;
-               size_t ofs = CDF_GETUINT32(p, tail);
+               ofs = CDF_GETUINT32(p, tail);
                q = (const uint8_t *)(const void *)
                    ((const char *)(const void *)p + ofs
                    - 2 * sizeof(uint32_t));
index 5675d492f2a2a525e72c6a3a7a0f260718dd8d0b..4a6f42e8caa1b326165e8aa00d731f16d8eac189 100644 (file)
@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.74 2014/10/26 20:23:30 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.75 2014/12/04 15:56:46 christos Exp $")
 #endif
 
 #include "magic.h"
@@ -45,7 +45,7 @@ FILE_RCSID("@(#)$File: compress.c,v 1.74 2014/10/26 20:23:30 christos Exp $")
 #endif
 #include <string.h>
 #include <errno.h>
-#ifndef __MINGW32__
+#if !defined(__MINGW32__) && !defined(WIN32)
 #include <sys/ioctl.h>
 #endif
 #ifdef HAVE_SYS_WAIT_H
index 7a8fea70ab9922b56d10d12f5075ef0dc1b4bd24..14fa836d2bb77da6d23308d1e3807c1fe3f746e0 100644 (file)
@@ -27,7 +27,7 @@
  */
 /*
  * file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.160 2014/11/28 02:46:39 christos Exp $
+ * @(#)$File: file.h,v 1.161 2014/12/04 15:56:46 christos Exp $
  */
 
 #ifndef __file_h__
@@ -64,7 +64,9 @@
 #include <regex.h>
 #include <time.h>
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/param.h>
+#endif
 /* Do this here and now, because struct stat gets re-defined on solaris */
 #include <sys/stat.h>
 #include <stdarg.h>
index e95d1b0145627101355d9b8e871150ef37a6a740..1e8fd74d2a2077f4e7755fdb36ba706969902457 100644 (file)
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: fsmagic.c,v 1.74 2014/10/13 20:21:49 christos Exp $")
+FILE_RCSID("@(#)$File: fsmagic.c,v 1.75 2014/12/04 15:56:46 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -129,7 +129,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 
 #ifdef WIN32
        {
-               HANDLE hFile = CreateFile(fn, 0, FILE_SHARE_DELETE |
+               HANDLE hFile = CreateFile((LPCSTR)fn, 0, FILE_SHARE_DELETE |
                    FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0,
                    NULL);
                if (hFile != INVALID_HANDLE_VALUE) {
index d8cc04c5ece8c8324011bd4aacfb7e2589b25300..b0cf11c28b502c29211928f07025995e138dbe5e 100644 (file)
@@ -33,7 +33,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: magic.c,v 1.89 2014/11/28 02:46:39 christos Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.90 2014/12/04 15:56:46 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -128,6 +128,7 @@ out:
 #else
        char *hmagicp;
        char *tmppath = NULL;
+       LPTSTR dllpath;
        hmagicpath = NULL;
 
 #define APPENDPATH() \
@@ -173,7 +174,7 @@ out:
        }
 
        /* Third, try to get magic file relative to dll location */
-       LPTSTR dllpath = malloc(sizeof(*dllpath) * (MAX_PATH + 1));
+       dllpath = malloc(sizeof(*dllpath) * (MAX_PATH + 1));
        dllpath[MAX_PATH] = 0;  /* just in case long path gets truncated and not null terminated */
        if (GetModuleFileNameA(NULL, dllpath, MAX_PATH)){
                PathRemoveFileSpecA(dllpath);
index 0681acab02eaefff837d4182690261099bfbc80d..635a9263764c184eae45ab1c2f80baca1dcee679 100644 (file)
@@ -26,7 +26,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readcdf.c,v 1.48 2014/09/10 18:41:51 christos Exp $")
+FILE_RCSID("@(#)$File: readcdf.c,v 1.49 2014/12/04 15:56:46 christos Exp $")
 #endif
 
 #include <assert.h>
@@ -72,7 +72,7 @@ static const struct cv {
        const char *mime;
 } clsid2mime[] = {
        {
-               { 0x00000000000c1084LLU, 0x46000000000000c0LLU  },
+               { 0x00000000000c1084ULL, 0x46000000000000c0ULL  },
                "x-msi",
        },
        {       { 0,                     0                      },
@@ -80,7 +80,7 @@ static const struct cv {
        },
 }, clsid2desc[] = {
        {
-               { 0x00000000000c1084LLU, 0x46000000000000c0LLU  },
+               { 0x00000000000c1084ULL, 0x46000000000000c0ULL  },
                "MSI Installer",
        },
        {       { 0,                     0                      },
@@ -334,11 +334,11 @@ private char *
 format_clsid(char *buf, size_t len, const uint64_t uuid[2]) {
        snprintf(buf, len, "%.8" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.4" 
            PRIx64 "-%.12" PRIx64,
-           (uuid[0] >> 32) & (uint64_t)0x000000000ffffffffLLU,
-           (uuid[0] >> 16) & (uint64_t)0x0000000000000ffffLLU,
-           (uuid[0] >>  0) & (uint64_t)0x0000000000000ffffLLU
-           (uuid[1] >> 48) & (uint64_t)0x0000000000000ffffLLU,
-           (uuid[1] >>  0) & (uint64_t)0x0000fffffffffffffLLU);
+           (uuid[0] >> 32) & (uint64_t)0x000000000ffffffffULL,
+           (uuid[0] >> 16) & (uint64_t)0x0000000000000ffffULL,
+           (uuid[0] >>  0) & (uint64_t)0x0000000000000ffffULL
+           (uuid[1] >> 48) & (uint64_t)0x0000000000000ffffULL,
+           (uuid[1] >>  0) & (uint64_t)0x0000fffffffffffffULL);
        return buf;
 }
 #endif
@@ -355,6 +355,7 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
         int i;
         const char *expn = "";
         const char *corrupt = "corrupt: ";
+        const cdf_directory_t *root_storage;
 
         info.i_fd = fd;
         info.i_buf = buf;
@@ -388,7 +389,6 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
                 goto out2;
         }
 
-        const cdf_directory_t *root_storage;
         if ((i = cdf_read_short_stream(&info, &h, &sat, &dir, &sst,
            &root_storage)) == -1) {
                 expn = "Cannot read short stream";
index cc43ae3bf9b0519f8f99c909f86801448e2cf2b7..7a18bed763b6d71f1cac04f34b9a1181ca3ec1ba 100644 (file)
@@ -108,7 +108,7 @@ you use strange formats.
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: vasprintf.c,v 1.12 2014/05/14 23:09:21 christos Exp $")
+FILE_RCSID("@(#)$File: vasprintf.c,v 1.13 2014/12/04 15:56:46 christos Exp $")
 #endif /* lint */
 
 #include <assert.h>
@@ -633,11 +633,15 @@ int vasprintf(char **ptr, const char *format_string, va_list vargs)
 #ifdef va_copy
   va_copy (s.vargs, vargs);
 #else
-#ifdef __va_copy
+# ifdef __va_copy
   __va_copy (s.vargs, vargs);
-#else
+# else
+#  ifdef WIN32
+  s.vargs = vargs;
+#  else
   memcpy (&s.vargs, &vargs, sizeof (s.va_args));
-#endif /* __va_copy */
+#  endif /* WIN32 */
+# endif /* __va_copy */
 #endif /* va_copy */
   s.maxlen = (size_t)INT_MAX;