]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Summary: More patches from Guido for windows.
authorrobertc <>
Tue, 4 Feb 2003 04:33:14 +0000 (04:33 +0000)
committerrobertc <>
Tue, 4 Feb 2003 04:33:14 +0000 (04:33 +0000)
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
lib/rfc1123.c
src/client.cc
src/debug.cc

index cc2ba67834c8be5daf46f3d37bc748ba6394b8e8..9ca7edb2d587a8dffebf0c5c9431cc746dce243b 100644 (file)
@@ -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;
index 6f2cadd39540fff5f3ac465ee2d454a3b5594311..42263ecad71f606f596fbe06fd47df61a9aa1871 100644 (file)
@@ -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);
index 6ffaffce3b81aee5b3861784e80087434ae9d75f..b2240147111e65d608a47c6a1011788b8e55d576 100644 (file)
@@ -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
index 3c8a5f17bea4f75b0c916e375c3386e309b3155f..56c41d225af0d69d5d9a1e56fb3fc2615919110d 100644 (file)
@@ -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"