derick          Thu Jun 16 14:34:43 2005 EDT

  Modified files:              
    /php-src/ext/date/lib       parse_tz.c timelib.h timelib_structs.h 
  Log:
  - Fixed headers for FreeBSD
  - Moved from ntohl to own macro
  - Export timelib_dump_tzinfo
  
  
http://cvs.php.net/diff.php/php-src/ext/date/lib/parse_tz.c?r1=1.5&r2=1.6&ty=u
Index: php-src/ext/date/lib/parse_tz.c
diff -u php-src/ext/date/lib/parse_tz.c:1.5 php-src/ext/date/lib/parse_tz.c:1.6
--- php-src/ext/date/lib/parse_tz.c:1.5 Thu Jun 16 13:12:41 2005
+++ php-src/ext/date/lib/parse_tz.c     Thu Jun 16 14:34:42 2005
@@ -16,30 +16,32 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: parse_tz.c,v 1.5 2005/06/16 17:12:41 derick Exp $ */
+/* $Id: parse_tz.c,v 1.6 2005/06/16 18:34:42 derick Exp $ */
 
 #include <stdio.h>
 #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 @@
                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 @@
                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 @@
        free(buffer);
 }
 
-#if 0
-static void dumpinfo(timelib_tzinfo *tz)
+void timelib_dump_tzinfo(timelib_tzinfo *tz)
 {
        uint32_t i;
 
@@ -159,7 +160,7 @@
        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 @@
                        tz->leap_times[i].offset);
        }
 }
-#endif
 
 static int seek_to_tz_position(char **tzf, char *timezone)
 {
http://cvs.php.net/diff.php/php-src/ext/date/lib/timelib.h?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/date/lib/timelib.h
diff -u php-src/ext/date/lib/timelib.h:1.1 php-src/ext/date/lib/timelib.h:1.2
--- php-src/ext/date/lib/timelib.h:1.1  Thu Jun 16 13:12:41 2005
+++ php-src/ext/date/lib/timelib.h      Thu Jun 16 14:34:42 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: timelib.h,v 1.1 2005/06/16 17:12:41 derick Exp $ */
+/* $Id: timelib.h,v 1.2 2005/06/16 18:34:42 derick Exp $ */
 
 #include "timelib_structs.h"
 
@@ -53,6 +53,7 @@
 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();
http://cvs.php.net/diff.php/php-src/ext/date/lib/timelib_structs.h?r1=1.5&r2=1.6&ty=u
Index: php-src/ext/date/lib/timelib_structs.h
diff -u php-src/ext/date/lib/timelib_structs.h:1.5 
php-src/ext/date/lib/timelib_structs.h:1.6
--- php-src/ext/date/lib/timelib_structs.h:1.5  Wed Jun 15 07:01:05 2005
+++ php-src/ext/date/lib/timelib_structs.h      Thu Jun 16 14:34:42 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: timelib_structs.h,v 1.5 2005/06/15 11:01:05 derick Exp $ */
+/* $Id: timelib_structs.h,v 1.6 2005/06/16 18:34:42 derick Exp $ */
 
 #ifndef __TIMELIB_STRUCTS_H__
 #define __TIMELIB_STRUCTS_H__
@@ -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

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to