]> granicus.if.org Git - php/commitdiff
Make it compile on windows
authorEdin Kadribasic <edink@php.net>
Wed, 15 Jun 2005 00:11:29 +0000 (00:11 +0000)
committerEdin Kadribasic <edink@php.net>
Wed, 15 Jun 2005 00:11:29 +0000 (00:11 +0000)
ext/date/lib/datetime.h
ext/date/lib/parse_date.re
ext/date/lib/parse_tz.c
ext/date/lib/resource/parse_date.re
ext/date/lib/timelib_structs.h
ext/date/lib/tm2unixtime.c
ext/date/lib/unixtime2tm.c
ext/date/php_date.c

index e31c83233c18957348a222c87702e313d13ad156..553a2d094194cda8a41903ac406740079e3aa43d 100644 (file)
 #define TIMELIB_NONE             0x00
 #define TIMELIB_OVERRIDE_TIME    0x01
 
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647L
+#endif
+
+#ifndef LONG_MIN
+#define LONG_MIN (- LONG_MAX - 1)
+#endif
+
+
 /* From dow.c */
 int timelib_day_of_week(int y, int m, int d);
 int timelib_daynr_from_weeknr(int y, int w, int d);
@@ -35,7 +44,7 @@ void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options);
 void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi);
 
 /* From unixtime2tm.c */
-int timelib_apply_localtime(timelib_time *t, uint localtime);
+int timelib_apply_localtime(timelib_time *t, unsigned int       localtime);
 void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts);
 void timelib_unixtime2local(timelib_time *tm, timelib_sll ts, timelib_tzinfo* tz);
 void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz);
index 1f10a1be23a48f9bc21a119619b50aa6d0d77e53..93de7af8d1d57ca9a3d67444a4f16b9f73c9448f 100644 (file)
 #include <string.h>
 #include "datetime.h"
 
+#ifdef PHP_WIN32
+#define strcasecmp stricmp
+#define strtoll(s, f, b) _atoi64(s)
+#endif
+
 #define TIMELIB_SECOND  1
 #define TIMELIB_MINUTE  2
 #define TIMELIB_HOUR    3
@@ -113,14 +118,14 @@ typedef unsigned char uchar;
 #include "timelib_structs.h"
 
 typedef struct timelib_elems {
-       uint c;   /* Number of elements */
+       unsigned int c;   /* Number of elements */
        char **v; /* Values */
 } timelib_elems;
 
 typedef struct Scanner {
        int    fd;
        uchar  *lim, *str, *ptr, *cur, *tok, *pos;
-       uint   line, len;
+       unsigned int   line, len;
 
        struct timelib_time *time;
 } Scanner;
@@ -365,7 +370,7 @@ static char* timelib_ltrim(char *s)
 #if 0
 uchar *fill(Scanner *s, uchar *cursor){
        if(!s->eof){
-               uint cnt = s->tok - s->bot;
+               unsigned int cnt = s->tok - s->bot;
                if(cnt){
                        memcpy(s->bot, s->tok, s->lim - s->tok);
                        s->tok = s->bot;
index 401e635db28f31cbe849279e2651c3b5e4aecf87..f5eac2aeac6f3955877c596dc8fb805c3b662f3e 100644 (file)
 /* $Id$ */
 
 #include <stdio.h>
+#ifdef PHP_WIN32
+#include <winsock2.h>
+#else
 #include <netinet/in.h>
+#endif
 #include <string.h>
 
 #include "datetime.h"
index 1f10a1be23a48f9bc21a119619b50aa6d0d77e53..93de7af8d1d57ca9a3d67444a4f16b9f73c9448f 100644 (file)
 #include <string.h>
 #include "datetime.h"
 
+#ifdef PHP_WIN32
+#define strcasecmp stricmp
+#define strtoll(s, f, b) _atoi64(s)
+#endif
+
 #define TIMELIB_SECOND  1
 #define TIMELIB_MINUTE  2
 #define TIMELIB_HOUR    3
@@ -113,14 +118,14 @@ typedef unsigned char uchar;
 #include "timelib_structs.h"
 
 typedef struct timelib_elems {
-       uint c;   /* Number of elements */
+       unsigned int c;   /* Number of elements */
        char **v; /* Values */
 } timelib_elems;
 
 typedef struct Scanner {
        int    fd;
        uchar  *lim, *str, *ptr, *cur, *tok, *pos;
-       uint   line, len;
+       unsigned int   line, len;
 
        struct timelib_time *time;
 } Scanner;
@@ -365,7 +370,7 @@ static char* timelib_ltrim(char *s)
 #if 0
 uchar *fill(Scanner *s, uchar *cursor){
        if(!s->eof){
-               uint cnt = s->tok - s->bot;
+               unsigned int cnt = s->tok - s->bot;
                if(cnt){
                        memcpy(s->bot, s->tok, s->lim - s->tok);
                        s->tok = s->bot;
index 91a61156e4fcbed7f56bde9a979612d3c3db9fd4..eb49ad487b585bc9922ad6fd11af2fc14293c8ef 100644 (file)
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifdef PHP_WIN32
+#include <winsock2.h>
+#else
 #include <netinet/in.h>
+#endif
 
-#if defined(WIN32) && _MSC_VER < 1300
+#if defined(PHP_WIN32) && _MSC_VER < 1300
 typedef unsigned __int64 timelib_ull;
 typedef __int64 timelib_sll;
 #else
@@ -34,6 +38,11 @@ typedef unsigned long long timelib_ull;
 typedef signed long long timelib_sll;
 #endif
 
+#if defined(_MSC_VER)
+#define int32_t __int32
+#define uint32_t unsigned __int32
+#endif
+
 typedef struct ttinfo
 {
        int32_t      offset;
@@ -78,8 +87,8 @@ typedef struct timelib_rel_time {
 
 typedef struct timelib_time_offset {
        int32_t offset;
-       uint leap_secs;
-       uint is_dst;
+       unsigned int leap_secs;
+       unsigned int is_dst;
        char *abbr;
 } timelib_time_offset;
 
@@ -90,17 +99,17 @@ typedef struct timelib_time {
        int z;           /* GMT offset in minutes */
        char *tz_abbr;   /* Timezone abbreviation (display only) */
        timelib_tzinfo  *tz_info;   /* Timezone structure */
-       uint dst;        /* Flag if we were parsing a DST zone */
+       unsigned int dst;        /* Flag if we were parsing a DST zone */
        timelib_rel_time relative;
 
        timelib_sll sse; /* Seconds since epoch */
 
-       uint   have_time, have_date, have_zone, have_relative, have_weekday_relative, have_weeknr_day;
+       unsigned int   have_time, have_date, have_zone, have_relative, have_weekday_relative, have_weeknr_day;
 
-       uint sse_uptodate; /* !0 if the sse member is up to date with the date/time members */
-       uint tim_uptodate; /* !0 if the date/time members are up to date with the sse member */
-       uint is_localtime; /*  1 if the current struct represents localtime, 0 if it is in GMT */
-       uint zone_type;    /*  1 time offset,
+       unsigned int sse_uptodate; /* !0 if the sse member is up to date with the date/time members */
+       unsigned int tim_uptodate; /* !0 if the date/time members are up to date with the sse member */
+       unsigned int is_localtime; /*  1 if the current struct represents localtime, 0 if it is in GMT */
+       unsigned int zone_type;    /*  1 time offset,
                                                *  3 TimeZone identifier,
                                                *  2 TimeZone abbreviation */
 } timelib_time;
index 8b117666e09965dab46163f096bde605e86c98f6..507465fac70b6482bebd8f56e5420019aea4d68d 100644 (file)
@@ -133,7 +133,7 @@ static void do_adjust_relative(timelib_time* time)
 
 static timelib_sll do_years(int year)
 {
-       uint i;
+       unsigned int i;
        timelib_sll res = 0;
 
        if (year >= 1970) {
@@ -156,7 +156,7 @@ static timelib_sll do_years(int year)
        return res;
 }
 
-static timelib_sll do_months(uint month, uint year)
+static timelib_sll do_months(unsigned int month, unsigned int year)
 {
        if (is_leap(year)) {
                return ((month_tab_leap[month - 1] + 1) * SECS_PER_DAY);
@@ -165,12 +165,12 @@ static timelib_sll do_months(uint month, uint year)
        }
 }
 
-static timelib_sll do_days(uint day)
+static timelib_sll do_days(unsigned int day)
 {
        return ((day - 1) * SECS_PER_DAY);
 }
 
-static timelib_sll do_time(uint hour, uint minute, uint second)
+static timelib_sll do_time(unsigned int hour, unsigned int minute, unsigned int second)
 {
        timelib_sll res = 0;
 
index 8c282cfa564439a70fbcaf28bcd3969dc5427277..a198b405a98340d80032f06df1893fcafdabb514 100644 (file)
 #include <stdio.h>
 #include <string.h>
 
+#if defined(_MSC_VER)
+#define PHP_LL_CONST(n) n ## i64
+#else
+#define PHP_LL_CONST(n) n ## ll
+#endif
+
 #include "datetime.h"
 
 static int month_tab_leap[12] = { -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
@@ -61,7 +67,7 @@ void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts)
                /* Guess why this might be for, it has to do with a pope ;-). It's also
                 * only valid for Great Brittain and it's colonies. It needs fixing for
                 * other locales. *sigh*, why is this crap so complex! */
-               if (ts <= -6857352000ll) {
+               if (ts <= PHP_LL_CONST(-6857352000)) {
                        tmp_days -= 11;
                }
 
@@ -160,7 +166,7 @@ void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz)
 /* Converts the time stored in the struct to localtime if localtime = true,
  * otherwise it converts it to gmttime. This is only done when necessary
  * ofcourse. */
-int timelib_apply_localtime(timelib_time *t, uint localtime)
+int timelib_apply_localtime(timelib_time *t, unsigned int localtime)
 {
        if (localtime) {
                /* Converting from GMT time to local time */
index ffa97dc8f6ea393a8a3b76aa29b5808f088c6e55..e18be2df32945d02a6fe8573716f4c75f42b100a 100644 (file)
@@ -126,7 +126,7 @@ PHP_FUNCTION(strtotime)
        } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s", &times, &time_len) != FAILURE) {
                /* We have no initial timestamp */
                now = timelib_time_ctor();
-               timelib_unixtime2local(now, (signed long long) time(NULL), tzi);
+               timelib_unixtime2local(now, (timelib_sll) time(NULL), tzi);
        } else {
                timelib_tzinfo_ctor(tzi);
                RETURN_FALSE;