From 0ef0f1de6ebb995622b20562d98df6c4b5002138 Mon Sep 17 00:00:00 2001 From: robertc <> Date: Tue, 4 Feb 2003 04:33:14 +0000 Subject: [PATCH] Summary: More patches from Guido for windows. Keywords: Hi, This is the 3th of some splitted native Windows patches grouped by functionality. Native Windows port enhancements: - Another fix for profiling support - Added correct timezone handling - Fixed rotate problem - Added native Windows support to client.cc --- lib/Profiler.c | 6 +++++- lib/rfc1123.c | 5 +++-- src/client.cc | 31 +++++++++++++++++++++++++++++-- src/debug.cc | 8 +++++++- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/lib/Profiler.c b/lib/Profiler.c index cc2ba67834..9ca7edb2d5 100644 --- a/lib/Profiler.c +++ b/lib/Profiler.c @@ -1,6 +1,6 @@ /* - * $Id: Profiler.c,v 1.2 2003/01/23 00:37:01 robertc Exp $ + * $Id: Profiler.c,v 1.3 2003/02/03 21:33:14 robertc Exp $ * * DEBUG: section 81 CPU Profiling Routines * AUTHOR: Andres Kroonmaa, Sep.2000 @@ -125,7 +125,11 @@ int xprof_nesting = 0; /* Private stuff */ +#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ +static __inline void +#else static inline void +#endif xprof_update(xprof_stats_data * head) { head->delta = head->stop - head->start; diff --git a/lib/rfc1123.c b/lib/rfc1123.c index 6f2cadd395..42263ecad7 100644 --- a/lib/rfc1123.c +++ b/lib/rfc1123.c @@ -1,6 +1,6 @@ /* - * $Id: rfc1123.c,v 1.31 2003/01/23 00:37:01 robertc Exp $ + * $Id: rfc1123.c,v 1.32 2003/02/03 21:33:15 robertc Exp $ * * DEBUG: * AUTHOR: Harvest Derived @@ -260,6 +260,7 @@ parse_rfc1123(const char *str) #elif defined (_timezone) #elif defined(_SQUID_AIX_) #elif defined(_SQUID_CYGWIN_) +#elif defined(_SQUID_MSWIN_) #else extern time_t timezone; #endif @@ -269,7 +270,7 @@ parse_rfc1123(const char *str) */ if (tm->tm_isdst > 0) dst = -3600; -#if defined ( _timezone) || defined(_SQUID_CYGWIN_) +#if defined ( _timezone) || defined(_SQUID_CYGWIN_) || defined(_SQUID_MSWIN_) t -= (_timezone + dst); #else t -= (timezone + dst); diff --git a/src/client.cc b/src/client.cc index 6ffaffce3b..b224014711 100644 --- a/src/client.cc +++ b/src/client.cc @@ -1,6 +1,6 @@ /* - * $Id: client.cc,v 1.103 2003/01/23 00:37:17 robertc Exp $ + * $Id: client.cc,v 1.104 2003/02/03 21:33:15 robertc Exp $ * * DEBUG: section 0 WWW Client * AUTHOR: Harvest Derived @@ -47,8 +47,10 @@ static int Now(struct timeval *); static SIGHDLR catchSignal; static SIGHDLR pipe_handler; static void set_our_signal(void); +#ifndef _SQUID_MSWIN_ static ssize_t myread(int fd, void *buf, size_t len); static ssize_t mywrite(int fd, void *buf, size_t len); +#endif static int put_fd; static char *put_file = NULL; static struct stat sb; @@ -210,6 +212,12 @@ main(int argc, char *argv[]) break; } } +#ifdef _SQUID_MSWIN_ + { + WSADATA wsaData; + WSAStartup(2, &wsaData); + } +#endif /* Build the HTTP request */ if (strncmp(url, "mgr:", 4) == 0) { char *t = xstrdup(url + 4); @@ -304,7 +312,7 @@ main(int argc, char *argv[]) (void) sigaction(SIGINT, &sa, NULL); } #else - void (*osig) (); + void (*osig) (int); if ((osig = signal(SIGINT, catchSignal)) != SIG_DFL) (void) signal(SIGINT, osig); #endif @@ -333,7 +341,11 @@ main(int argc, char *argv[]) exit(1); } /* Send the HTTP request */ +#ifdef _SQUID_MSWIN_ + bytesWritten = send(conn, msg, strlen(msg), 0); +#else bytesWritten = mywrite(conn, msg, strlen(msg)); +#endif if (bytesWritten < 0) { perror("client: ERROR: write"); exit(1); @@ -344,8 +356,13 @@ main(int argc, char *argv[]) if (put_file) { int x; lseek(put_fd, 0, SEEK_SET); +#ifdef _SQUID_MSWIN_ + while ((x = read(put_fd, buf, sizeof(buf))) > 0) { + x = write(conn, buf, x); +#else while ((x = myread(put_fd, buf, sizeof(buf))) > 0) { x = mywrite(conn, buf, x); +#endif total_bytes += x; if (x <= 0) break; @@ -355,11 +372,19 @@ main(int argc, char *argv[]) } /* Read the data */ +#ifdef _SQUID_MSWIN_ + setmode(1, O_BINARY); + while ((len = recv(conn, buf, sizeof(buf), 0)) > 0) { +#else while ((len = myread(conn, buf, sizeof(buf))) > 0) { +#endif fsize += len; if (to_stdout) fwrite(buf, len, 1, stdout); } +#ifdef _SQUID_MSWIN_ + setmode(1, O_TEXT); +#endif (void) close(conn); /* done with socket */ if (interrupted) @@ -489,6 +514,7 @@ set_our_signal(void) } +#ifndef _SQUID_MSWIN_ static ssize_t myread(int fd, void *buf, size_t len) { @@ -502,3 +528,4 @@ mywrite(int fd, void *buf, size_t len) alarm(io_timeout); return write(fd, buf, len); } +#endif diff --git a/src/debug.cc b/src/debug.cc index 3c8a5f17be..56c41d225a 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -1,6 +1,6 @@ /* - * $Id: debug.cc,v 1.87 2003/01/23 00:37:19 robertc Exp $ + * $Id: debug.cc,v 1.88 2003/02/03 21:33:15 robertc Exp $ * * DEBUG: section 0 Debug Routines * AUTHOR: Harvest Derived @@ -239,6 +239,9 @@ _db_rotate_log(void) i--; snprintf(from, MAXPATHLEN, "%s.%d", debug_log_file, i - 1); snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, i); +#ifdef _SQUID_MSWIN_ + remove(to); +#endif rename(from, to); } /* @@ -252,6 +255,9 @@ _db_rotate_log(void) /* Rotate the current log to .0 */ if (Config.Log.rotateNumber > 0) { snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, 0); +#ifdef _SQUID_MSWIN_ + remove(to); +#endif rename(debug_log_file, to); } /* Close and reopen the log. It may have been renamed "manually" -- 2.47.3