]> granicus.if.org Git - php/commitdiff
- Fixed headers for FreeBSD
authorDerick Rethans <derick@php.net>
Thu, 16 Jun 2005 18:34:42 +0000 (18:34 +0000)
committerDerick Rethans <derick@php.net>
Thu, 16 Jun 2005 18:34:42 +0000 (18:34 +0000)
- Moved from ntohl to own macro
- Export timelib_dump_tzinfo

ext/date/lib/parse_tz.c
ext/date/lib/timelib.h
ext/date/lib/timelib_structs.h

index 879274783657cb6ecad1d8985f711ee43f8aead6..b3680c5d429a00fe32a19b2a74edd1e5bee7028a 100644 (file)
 #ifdef WIN32
 #include <winsock2.h>
 #else
-#include <netinet/in.h>
+#include <inttypes.h>
 #endif
 #include <string.h>
 
 #include "timelib.h"
 #include "timezonedb.h"
 
+#define timelib_conv_int(l) ((l & 0x000000ff) << 24) + ((l & 0x0000ff00) << 8) + ((l & 0x00ff0000) >> 8) + ((l & 0xff000000) >> 24)
+
 static void read_header(char **tzf, timelib_tzinfo *tz)
 {
        uint32_t buffer[6];
 
        memcpy(&buffer, *tzf, sizeof(buffer));
-       tz->ttisgmtcnt = htonl(buffer[0]);
-       tz->ttisstdcnt = htonl(buffer[1]);
-       tz->leapcnt    = htonl(buffer[2]);
-       tz->timecnt    = htonl(buffer[3]);
-       tz->typecnt    = htonl(buffer[4]);
-       tz->charcnt    = htonl(buffer[5]);
+       tz->ttisgmtcnt = timelib_conv_int(buffer[0]);
+       tz->ttisstdcnt = timelib_conv_int(buffer[1]);
+       tz->leapcnt    = timelib_conv_int(buffer[2]);
+       tz->timecnt    = timelib_conv_int(buffer[3]);
+       tz->typecnt    = timelib_conv_int(buffer[4]);
+       tz->charcnt    = timelib_conv_int(buffer[5]);
        *tzf += sizeof(buffer);
 }
 
@@ -57,7 +59,7 @@ static void read_transistions(char **tzf, timelib_tzinfo *tz)
                memcpy(buffer, *tzf, sizeof(int32_t) * tz->timecnt);
                *tzf += (sizeof(int32_t) * tz->timecnt);
                for (i = 0; i < tz->timecnt; i++) {
-                       buffer[i] = htonl(buffer[i]);
+                       buffer[i] = timelib_conv_int(buffer[i]);
                }
 
                cbuffer = (unsigned char*) malloc(tz->timecnt * sizeof(unsigned char));
@@ -114,8 +116,8 @@ static void read_types(char **tzf, timelib_tzinfo *tz)
                return;
        }
        for (i = 0; i < tz->leapcnt; i++) {
-               tz->leap_times[i].trans = htonl(leap_buffer[i * 2]);
-               tz->leap_times[i].offset = htonl(leap_buffer[i * 2 + 1]);
+               tz->leap_times[i].trans = timelib_conv_int(leap_buffer[i * 2]);
+               tz->leap_times[i].offset = timelib_conv_int(leap_buffer[i * 2 + 1]);
        }
        free(leap_buffer);
        
@@ -144,8 +146,7 @@ static void read_types(char **tzf, timelib_tzinfo *tz)
        free(buffer);
 }
 
-#if 0
-static void dumpinfo(timelib_tzinfo *tz)
+void timelib_dump_tzinfo(timelib_tzinfo *tz)
 {
        uint32_t i;
 
@@ -159,7 +160,7 @@ static void dumpinfo(timelib_tzinfo *tz)
        for (i = 0; i < tz->timecnt; i++) {
                printf ("%08X (%12d) = %3d [%5ld %1d %3d '%s' (%d,%d)]\n",
                        tz->trans[i], tz->trans[i], tz->trans_idx[i],
-                       tz->type[tz->trans_idx[i]].offset,
+                       (long int) tz->type[tz->trans_idx[i]].offset,
                        tz->type[tz->trans_idx[i]].isdst,
                        tz->type[tz->trans_idx[i]].abbr_idx,
                        &tz->timezone_abbr[tz->type[tz->trans_idx[i]].abbr_idx],
@@ -174,7 +175,6 @@ static void dumpinfo(timelib_tzinfo *tz)
                        tz->leap_times[i].offset);
        }
 }
-#endif
 
 static int seek_to_tz_position(char **tzf, char *timezone)
 {
index affc6f6ace3516717fd62e1770bcd5cd4cc84916..347c5213d8576dac63aa711262d57e2bcbd1ef4b 100644 (file)
@@ -53,6 +53,7 @@ void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz);
 timelib_tzinfo *timelib_parse_tzfile(char *timezone);
 int timelib_timestamp_is_in_dst(timelib_sll ts, timelib_tzinfo *tz);
 timelib_time_offset *timelib_get_time_zone_info(timelib_sll ts, timelib_tzinfo *tz);
+void timelib_dump_tzinfo(timelib_tzinfo *tz);
 
 /* From timelib.c */
 timelib_tzinfo* timelib_tzinfo_ctor();
index b86b47352d67c96058df4dec241a0014ec28914f..edc11351deac895f7cffce4d74917c3c467bfb63 100644 (file)
@@ -27,7 +27,7 @@
 #ifdef WIN32
 #include <winsock2.h>
 #else
-#include <netinet/in.h>
+#include <inttypes.h>
 #endif
 
 #if defined(_MSC_VER) && _MSC_VER < 1300