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
- File open is forced in binary mode
- Fixed rotate problem
- Added native Windows support to client.cc

Regards

Guido



-
=======================================================
Serassio Guido
Via Albenga, 11/4 10134 - Torino - ITALY
E-mail: [EMAIL PROTECTED]
WWW: http://www.serassio.it
Index: debug.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/debug.cc,v
retrieving revision 1.4
diff -u -p -r1.4 debug.cc
--- debug.cc    18 Jan 2003 03:14:47 -0000      1.4
+++ debug.cc    3 Feb 2003 17:48:20 -0000
@@ -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"
Index: disk.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/disk.cc,v
retrieving revision 1.4
diff -u -p -r1.4 disk.cc
--- disk.cc     23 Jan 2003 03:14:42 -0000      1.4
+++ disk.cc     3 Feb 2003 17:48:20 -0000
@@ -64,6 +64,9 @@ file_open(const char *path, int mode)
     PROF_start(file_open);
     if (FILE_MODE(mode) == O_WRONLY)
        mode |= O_APPEND;
+#ifdef _SQUID_MSWIN_ 
+    mode |= _O_BINARY;
+#endif
     mode |= SQUID_NONBLOCK;
     errno = 0;
     fd = open(path, mode, 0644);
Index: client.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/client.cc,v
retrieving revision 1.5
diff -u -p -r1.5 client.cc
--- client.cc   9 Jan 2003 11:52:30 -0000       1.5
+++ client.cc   3 Feb 2003 17:44:36 -0000
@@ -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: Profiler.c
===================================================================
RCS file: /cvsroot/squid/squid3/lib/Profiler.c,v
retrieving revision 1.3
diff -u -p -r1.3 Profiler.c
--- Profiler.c  18 Nov 2002 03:12:54 -0000      1.3
+++ Profiler.c  3 Feb 2003 17:33:57 -0000
@@ -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: rfc1123.c
===================================================================
RCS file: /cvsroot/squid/squid3/lib/rfc1123.c,v
retrieving revision 1.3
diff -u -p -r1.3 rfc1123.c
--- rfc1123.c   18 Nov 2002 03:12:54 -0000      1.3
+++ rfc1123.c   3 Feb 2003 17:33:57 -0000
@@ -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);


Reply via email to