akosut 97/07/08 14:18:51
Modified: src mod_usertrack.c
Log:
Fix mod_usertrack to work with Windows.
Revision Changes Path
1.12 +18 -2 apache/src/mod_usertrack.c
Index: mod_usertrack.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_usertrack.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -c -C3 -r1.11 -r1.12
*** mod_usertrack.c 1997/07/07 14:34:28 1.11
--- mod_usertrack.c 1997/07/08 21:18:50 1.12
***************
*** 97,103 ****
--- 97,105 ----
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
+ #ifndef WIN32
#include <sys/time.h>
+ #endif
module usertrack_module;
***************
*** 106,111 ****
--- 108,117 ----
time_t expires;
} cookie_log_state;
+ static const char month_names[12][4] = {
+ "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
+ };
+
/* Define this to allow post-2000 cookies. Cookies use two-digit dates,
* so it might be dicey. (Netscape does it correctly, but others may not)
*/
***************
*** 123,129 ****
#if defined(NO_GETTIMEOFDAY)
clock_t mpe_times;
struct tms mpe_tms;
! #else
struct timeval tv;
struct timezone tz = { 0 , 0 };
#endif
--- 129,135 ----
#if defined(NO_GETTIMEOFDAY)
clock_t mpe_times;
struct tms mpe_tms;
! #elif !defined(WIN32)
struct timeval tv;
struct timezone tz = { 0 , 0 };
#endif
***************
*** 146,151 ****
--- 152,167 ----
ap_snprintf(cookiebuf, 1024, "%s%d%ld%ld", rname, (int)getpid(),
(long)time(NULL), (long)mpe_tms.tms_utime);
+ #elif defined(WIN32)
+ /* We lack gettimeofday() and we lack times(). So we'll use
+ * a combination of time() and GetTickCount(), which returns
+ * milliseconds since Windows was started. It should be relatively
+ * unique.
+ */
+
+ ap_snprintf(cookiebuf, 1024, "%s%d%ld%ld", rname, (int)getpid(),
+ (long)time(NULL), (long)GetTickCount());
+
#else
gettimeofday(&tv, &tz);
***************
*** 174,180 ****
ap_snprintf(new_cookie, 1024,
"%s%s; path=/; expires=%s, %.2d-%s-%.2d %.2d:%.2d:%.2d GMT",
COOKIE_NAME, cookiebuf, days[tms->tm_wday],
! tms->tm_mday, month_snames[tms->tm_mon],
(tms->tm_year >= 100) ? tms->tm_year - 100 : tms->tm_year,
tms->tm_hour, tms->tm_min, tms->tm_sec);
}
--- 190,196 ----
ap_snprintf(new_cookie, 1024,
"%s%s; path=/; expires=%s, %.2d-%s-%.2d %.2d:%.2d:%.2d GMT",
COOKIE_NAME, cookiebuf, days[tms->tm_wday],
! tms->tm_mday, month_names[tms->tm_mon],
(tms->tm_year >= 100) ? tms->tm_year - 100 : tms->tm_year,
tms->tm_hour, tms->tm_min, tms->tm_sec);
}