Permalink
Browse files

- support for VC6 and some other platforms (before some other cleanup)

  • Loading branch information...
1 parent f3f71b7 commit 144527b190869c81bd5537e4153af7fba2eb78b9 @pierrejoye pierrejoye committed Oct 20, 2008
Showing with 27 additions and 17 deletions.
  1. +4 −0 ext/fileinfo/config.w32
  2. +6 −0 ext/fileinfo/libmagic/apprentice.c
  3. +17 −17 ext/fileinfo/libmagic/softmagic.c
View
4 ext/fileinfo/config.w32
@@ -13,6 +13,10 @@ if (PHP_FILEINFO != 'no') {
magic.c print.c \
readelf.c softmagic.c";
+ if (VCVERS <1500) {
+ ADD_FLAG('CFLAGS', '/Zm1000');
+ }
+
EXTENSION('fileinfo', 'fileinfo.c', true, "/I" + configure_module_dirname + "/libmagic /I" + configure_module_dirname);
ADD_SOURCES(configure_module_dirname + '\\libmagic', LIBMAGIC_SOURCES, "fileinfo");
} else {
View
6 ext/fileinfo/libmagic/apprentice.c
@@ -38,11 +38,17 @@
#ifdef PHP_WIN32
#include "win32/unistd.h"
+#if _MSC_VER <= 1300
+#include "win32/php_strtoi64.h"
+#endif
#define strtoull _strtoui64
#else
#include <unistd.h>
#endif
+
+
+
#include <string.h>
#include <assert.h>
#include <ctype.h>
View
34 ext/fileinfo/libmagic/softmagic.c
@@ -582,16 +582,16 @@ cvt_64(union VALUETYPE *p, const struct magic *m)
if (m->num_mask) \
switch (m->mask_op & FILE_OPS_MASK) { \
case FILE_OPADD: \
- p->fld += cast m->num_mask; \
+ p->fld += cast (int64_t)m->num_mask; \
break; \
case FILE_OPMINUS: \
- p->fld -= cast m->num_mask; \
+ p->fld -= cast (int64_t)m->num_mask; \
break; \
case FILE_OPMULTIPLY: \
- p->fld *= cast m->num_mask; \
+ p->fld *= cast (int64_t)m->num_mask; \
break; \
case FILE_OPDIVIDE: \
- p->fld /= cast m->num_mask; \
+ p->fld /= cast (int64_t)m->num_mask; \
break; \
} \
@@ -1860,23 +1860,23 @@ magiccheck(struct magic_set *ms, struct magic *m)
case 'x':
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%llu == *any* = 1\n",
- (unsigned long long)v);
+ (uint64_t)v);
matched = 1;
break;
case '!':
matched = v != l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%llu != %llu = %d\n",
- (unsigned long long)v, (unsigned long long)l,
+ (uint64_t)v, (uint64_t)l,
matched);
break;
case '=':
matched = v == l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%llu == %llu = %d\n",
- (unsigned long long)v, (unsigned long long)l,
+ (uint64_t)v, (uint64_t)l,
matched);
break;
@@ -1885,14 +1885,14 @@ magiccheck(struct magic_set *ms, struct magic *m)
matched = v > l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%llu > %llu = %d\n",
- (unsigned long long)v,
- (unsigned long long)l, matched);
+ (uint64_t)v,
+ (uint64_t)l, matched);
}
else {
matched = (int64_t) v > (int64_t) l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%lld > %lld = %d\n",
- (long long)v, (long long)l, matched);
+ (uint64_t)v, (uint64_t)l, matched);
}
break;
@@ -1901,31 +1901,31 @@ magiccheck(struct magic_set *ms, struct magic *m)
matched = v < l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%llu < %llu = %d\n",
- (unsigned long long)v,
- (unsigned long long)l, matched);
+ (uint64_t)v,
+ (uint64_t)l, matched);
}
else {
matched = (int64_t) v < (int64_t) l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%lld < %lld = %d\n",
- (long long)v, (long long)l, matched);
+ (int64_t)v, (int64_t)l, matched);
}
break;
case '&':
matched = (v & l) == l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "((%llx & %llx) == %llx) = %d\n",
- (unsigned long long)v, (unsigned long long)l,
- (unsigned long long)l, matched);
+ (uint64_t)v, (uint64_t)l,
+ (uint64_t)l, matched);
break;
case '^':
matched = (v & l) != l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "((%llx & %llx) != %llx) = %d\n",
- (unsigned long long)v, (unsigned long long)l,
- (unsigned long long)l, matched);
+ (uint64_t)v, (uint64_t)l,
+ (uint64_t)l, matched);
break;
default:

0 comments on commit 144527b

Please sign in to comment.