]> granicus.if.org Git - php/commitdiff
- MFH
authorPierre Joye <pajoye@php.net>
Thu, 6 Nov 2008 13:56:49 +0000 (13:56 +0000)
committerPierre Joye <pajoye@php.net>
Thu, 6 Nov 2008 13:56:49 +0000 (13:56 +0000)
 - add 64bit typedef support
 - fix vc6 build (1/2)
 - still broken/does not build cleanly, more to come

ext/fileinfo/config.w32
ext/fileinfo/fileinfo.c
ext/fileinfo/libmagic/apprentice.c
ext/fileinfo/libmagic/softmagic.c

index f94929c81ffeea735215e474168e252f90e1dada..085f9b2c3e65200ade041eab319e5a81bff15bb6 100644 (file)
@@ -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 {
index 1db520c41ad72e95bdae6255f1e4735d0c9578c6..8b012c1aefb95e26d6f87dd358e3dcd0bc1dd61a 100644 (file)
@@ -324,7 +324,7 @@ PHP_FUNCTION(finfo_open)
                RETURN_FALSE;
        }
 
-       if (file && *file) { /* user specified filed, perform open_basedir checks */
+       if (file && *file) { /* user specified file, perform open_basedir checks */
                if (!VCWD_REALPATH(file, resolved_path)) {
                        RETURN_FALSE;
                }
@@ -533,9 +533,6 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
                                php_stream *stream = php_stream_open_wrapper_ex(buffer, "rb", REPORT_ERRORS, NULL, context);
 
                                if (!stream) {
-                                       if (mimetype_emu) {
-                                               magic_close(magic);
-                                       }
                                        RETVAL_FALSE;
                                        goto clean;
                                }
@@ -545,6 +542,7 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
                        }
                        break;
                }
+
                default:
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can only process string or stream arguments");
        }
index 6879c2f078d2d31c3622166e204f8a7683d98a99..6f4b72381217d5c0c5eac3c92d75bc51c8ba56a6 100644 (file)
@@ -584,7 +584,7 @@ private void
 load_1(struct magic_set *ms, int action, const char *fn, int *errs,
    struct magic_entry **marray, uint32_t *marraycount)
 {
-       zstr buffer;
+       char buffer[BUFSIZ + 1];
        char *line;
        size_t line_len;
        size_t lineno = 0;
@@ -598,13 +598,14 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs,
 #else
        stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS, NULL);
 #endif
+
        if (stream == NULL) {
                if (errno != ENOENT)
                        file_error(ms, errno, "cannot read magic file `%s'",
                                   fn);
                (*errs)++;
        } else {
-               buffer.v = emalloc(BUFSIZ+1);
+
                /* read and parse this file */
                for (ms->line = 1; (line = php_stream_get_line(stream, buffer , BUFSIZ, &line_len)) != NULL; ms->line++) {
                        if (line_len == 0) /* null line, garbage, etc */
@@ -652,7 +653,7 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs,
                        if (parse(ms, marray, marraycount, line, lineno, action) != 0)
                                (*errs)++;
                }
-               efree(buffer.v);
+
                php_stream_close(stream);
        }
 }
index 095090500791323c200ed31c55846094ee781c8b..deb420ec33b8d022f94c77eddc85d835a66ae1f6 100644 (file)
@@ -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; \
                } \
 
@@ -1865,7 +1865,7 @@ 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;
 
@@ -1873,7 +1873,7 @@ 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,
+                           (uint64_t)v, (uint64_t)l,
                            matched);
                break;
 
@@ -1881,7 +1881,7 @@ 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,
+                           (uint64_t)v, (uint64_t)l,
                            matched);
                break;
 
@@ -1890,14 +1890,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;
 
@@ -1906,14 +1906,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);
+                                      (int64_t)v, (int64_t)l, matched);
                }
                break;
 
@@ -1921,16 +1921,16 @@ magiccheck(struct magic_set *ms, struct magic *m)
                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: