From: Pierre Joye Date: Mon, 16 Mar 2009 15:02:44 +0000 (+0000) Subject: - fix the build for win (vc6 or vc9) X-Git-Tag: php-5.4.0alpha1~191^2~4139 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b72606c92ff08c5061126916311554d49b4321f4;p=php - fix the build for win (vc6 or vc9) - fix logic in time convertion - force shared on windows, will fix the dirent issue later (no, it is not enough to simply remove the dep or header include) - add myself before I forget again --- diff --git a/ext/fileinfo/CREDITS b/ext/fileinfo/CREDITS index 0a001657de..acd0e843d0 100644 --- a/ext/fileinfo/CREDITS +++ b/ext/fileinfo/CREDITS @@ -1,2 +1,2 @@ fileinfo -Ilia Alshanetsky, Scott MacVicar, Derick Rethans +Ilia Alshanetsky, Pierre Alain Joye, Scott MacVicar, Derick Rethans diff --git a/ext/fileinfo/config.w32 b/ext/fileinfo/config.w32 index f70da0ec65..4e790695c1 100644 --- a/ext/fileinfo/config.w32 +++ b/ext/fileinfo/config.w32 @@ -4,7 +4,8 @@ ARG_ENABLE("fileinfo", "fileinfo support", "no"); if (PHP_FILEINFO != 'no') { - + if (CHECK_HEADER_ADD_INCLUDE("dirent.h", "CFLAGS_FILEINFO") && + CHECK_LIB("dirent_a.lib", "fileinfo", PHP_FILEINFO)) { LIBMAGIC_SOURCES=" apprentice.c apptype.c ascmagic.c \ cdf.c cdf_time.c compress.c \ encoding.c fsmagic.c funcs.c \ @@ -15,6 +16,10 @@ if (PHP_FILEINFO != 'no') { ADD_FLAG('CFLAGS', '/Zm1000'); } - EXTENSION('fileinfo', 'fileinfo.c', null, "/I" + configure_module_dirname + "/libmagic /I" + configure_module_dirname); + EXTENSION('fileinfo', 'fileinfo.c', true, "/I" + configure_module_dirname + "/libmagic /I" + configure_module_dirname); ADD_SOURCES(configure_module_dirname + '\\libmagic', LIBMAGIC_SOURCES, "fileinfo"); + } else { + WARNING("fileinfo not enabled; libraries and headers not found"); + PHP_FILEINFO = "no"; + } } diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c index 152e6a5013..db1d11f7fb 100644 --- a/ext/fileinfo/libmagic/cdf.c +++ b/ext/fileinfo/libmagic/cdf.c @@ -1001,7 +1001,11 @@ cdf_dump_property_info(const cdf_property_info_t *info, size_t count) break; case CDF_FILETIME: tp = info[i].pi_tp; +#if defined(PHP_WIN32 ) && _MSC_VER <= 1500 + if (tp < 1000000000000000i64) { +#else if (tp < 1000000000000000LL) { +#endif cdf_print_elapsed_time(buf, sizeof(buf), tp); printf("timestamp %s\n", buf); } else { diff --git a/ext/fileinfo/libmagic/cdf.h b/ext/fileinfo/libmagic/cdf.h index a4a0f6d152..f020942705 100644 --- a/ext/fileinfo/libmagic/cdf.h +++ b/ext/fileinfo/libmagic/cdf.h @@ -42,7 +42,11 @@ typedef int32_t cdf_secid_t; typedef struct { uint64_t h_magic; -#define CDF_MAGIC 0xE11AB1A1E011CFD0LL +#if defined(PHP_WIN32 ) && _MSC_VER <= 1500 +# define CDF_MAGIC 0xE11AB1A1E011CFD0i64 +#else +# define CDF_MAGIC 0xE11AB1A1E011CFD0LL +#endif uint64_t h_uuid[2]; uint16_t h_revision; uint16_t h_version; diff --git a/ext/fileinfo/libmagic/cdf_time.c b/ext/fileinfo/libmagic/cdf_time.c index e06419c2dc..ac416ea2fe 100644 --- a/ext/fileinfo/libmagic/cdf_time.c +++ b/ext/fileinfo/libmagic/cdf_time.c @@ -104,8 +104,8 @@ cdf_timestamp_to_timespec(struct timeval *ts, cdf_timestamp_t t) #endif int rdays; - /* Unit is 100,000's of microseconds */ - ts->tv_usec = (t % CDF_TIME_PREC) * 100000; + /* Time interval, in microseconds */ + ts->tv_usec = (t % CDF_TIME_PREC) * CDF_TIME_PREC; t /= CDF_TIME_PREC; tm.tm_sec = t % 60; @@ -153,7 +153,7 @@ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timeval *ts) errno = EINVAL; return -1; } - *t = (ts->ts_usec / 100000) * CDF_TIME_PREC; + *t = (ts->ts_usec / CDF_TIME_PREC) * CDF_TIME_PREC; *t = tm.tm_sec; *t += tm.tm_min * 60; *t += tm.tm_hour * 60 * 60; diff --git a/ext/fileinfo/libmagic/file.h b/ext/fileinfo/libmagic/file.h index 503e852ea7..d97343bddc 100644 --- a/ext/fileinfo/libmagic/file.h +++ b/ext/fileinfo/libmagic/file.h @@ -403,10 +403,10 @@ extern char *sys_errlist[]; #define strtoul(a, b, c) strtol(a, b, c) #endif -#ifndef HAVE_STRLCPY +#ifndef strlcpy size_t strlcpy(char *dst, const char *src, size_t siz); #endif -#ifndef HAVE_STRLCAT +#ifndef strlcat size_t strlcat(char *dst, const char *src, size_t siz); #endif diff --git a/ext/fileinfo/libmagic/readcdf.c b/ext/fileinfo/libmagic/readcdf.c index 8ec44e5cd6..c9ac33b42c 100644 --- a/ext/fileinfo/libmagic/readcdf.c +++ b/ext/fileinfo/libmagic/readcdf.c @@ -96,7 +96,11 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info, case CDF_FILETIME: tp = info[i].pi_tp; if (tp != 0) { +#if defined(PHP_WIN32 ) && _MSC_VER <= 1500 + if (tp < 1000000000000000i64) { +#else if (tp < 1000000000000000LL) { +#endif char tbuf[64]; cdf_print_elapsed_time(tbuf, sizeof(tbuf), tp);