]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
WIN32 port update by Guido
authorhno <>
Sun, 1 Sep 2002 21:16:33 +0000 (21:16 +0000)
committerhno <>
Sun, 1 Sep 2002 21:16:33 +0000 (21:16 +0000)
fix the problems on Windows related to open file renaming and text/binary
file issues

src/acl.cc
src/cache_cf.cc
src/cache_diff.cc
src/cf_gen.cc
src/client.cc
src/debug.cc
src/disk.cc
src/fs/ufs/store_dir_ufs.cc
src/mime.cc
src/squid.h
src/tools.cc

index cbd2ee3fb1882de273b99ec7d5f6143010b333ce..7ae7258c3d965dfa61406bc4120e44c762674b3e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: acl.cc,v 1.281 2002/08/09 10:57:43 robertc Exp $
+ * $Id: acl.cc,v 1.282 2002/09/01 15:16:33 hno Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -128,7 +128,7 @@ strtokFile(void)
                debug(28, 0) ("strtokFile: %s not found\n", fn);
                return (NULL);
            }
-#if defined(_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
            setmode(fileno(aclFile), O_TEXT);
 #endif
            aclFromFile = 1;
index b812970d87055d945cfd8770e9876c6081451b76..d9e122f4a531f125dc313172e375e8408253f715 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.410 2002/09/01 13:54:16 hno Exp $
+ * $Id: cache_cf.cc,v 1.411 2002/09/01 15:16:33 hno Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -275,7 +275,7 @@ parseConfigFile(const char *file_name)
     if (fp == NULL)
        fatalf("Unable to open configuration file: %s: %s",
            file_name, xstrerror());
-#if defined(_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
     setmode(fileno(fp), O_TEXT);
 #endif
     cfg_filename = file_name;
index ce9e6fec43eac4b772deb4091f6a7a2eaf28c83b..a1024a88c6c81a4e7554da1fea7116695d35d1c5 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_diff.cc,v 1.15 2001/01/12 00:37:15 wessels Exp $
+ * $Id: cache_diff.cc,v 1.16 2002/09/01 15:16:33 hno Exp $
  *
  * AUTHOR: Alex Rousskov
  *
@@ -137,7 +137,7 @@ cacheIndexAddLog(CacheIndex * idx, const char *fname)
        fprintf(stderr, "cannot open %s: %s\n", fname, strerror(errno));
        return 0;
     }
-#if defined(_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
     setmode(fileno(file), O_BINARY);
 #endif
     scanned_count = cacheIndexScan(idx, fname, file);
index 2527bd5097507af8c18fe1268af79898c2c09af9..d7c80dbce893bb128b845de085756fb52f4b4453 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cf_gen.cc,v 1.45 2002/08/22 12:29:15 hno Exp $
+ * $Id: cf_gen.cc,v 1.46 2002/09/01 15:16:35 hno Exp $
  *
  * DEBUG: none          Generate squid.conf.default and cf_parser.h
  * AUTHOR: Max Okumoto
@@ -66,7 +66,7 @@
 #if HAVE_ASSERT_H
 #include <assert.h>
 #endif
-#if defined(_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
 #include <io.h>
 #endif
 #if HAVE_FCNTL_H
@@ -158,7 +158,7 @@ main(int argc, char *argv[])
        perror(input_filename);
        exit(1);
     }
-#if defined(_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
     setmode(fileno(fp), O_TEXT);
 #endif
     state = sSTART;
@@ -345,7 +345,7 @@ main(int argc, char *argv[])
        perror(output_filename);
        exit(1);
     }
-#if defined(_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
     setmode(fileno(fp), O_TEXT);
 #endif
     fprintf(fp,
@@ -370,7 +370,7 @@ main(int argc, char *argv[])
        perror(conf_filename);
        exit(1);
     }
-#if defined(_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
     setmode(fileno(fp), O_TEXT);
 #endif
     gen_conf(entries, fp);
index 8963b57b8b80e20ac06968ca57597279ff2517d2..28b72eb200569f0c26b8b41982506dd2a910deec 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client.cc,v 1.99 2002/07/15 21:24:48 hno Exp $
+ * $Id: client.cc,v 1.100 2002/09/01 15:16:35 hno Exp $
  *
  * DEBUG: section 0     WWW Client
  * AUTHOR: Harvest Derived
@@ -223,7 +223,7 @@ main(int argc, char *argv[])
                xstrerror());
            exit(-1);
        }
-#if defined(_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
        setmode(put_fd, O_BINARY);
 #endif
        fstat(put_fd, &sb);
index 539f8c9967e158926529f68413b1355cab66ebc1..3aa5a7bcaa1a36b9845403caec88614eb85bd453 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: debug.cc,v 1.84 2001/12/17 18:01:54 wessels Exp $
+ * $Id: debug.cc,v 1.85 2002/09/01 15:16:35 hno Exp $
  *
  * DEBUG: section 0     Debug Routines
  * AUTHOR: Harvest Derived
@@ -177,7 +177,7 @@ debugOpenLog(const char *logfile)
        fflush(stderr);
        debug_log = stderr;
     }
-#if defined(_SQUID_CYGWIN_)
+#if defined(_SQUID_CYGWIN_)||defined(_SQUID_MSWIN_)
     setmode(fileno(debug_log), O_TEXT);
 #endif
 }
@@ -237,6 +237,14 @@ _db_rotate_log(void)
        snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, i);
        rename(from, to);
     }
+/*
+ * You can't rename open files on Microsoft "operating systems"
+ * so we close before renaming.
+ */
+#ifdef _SQUID_MSWIN_
+    if (debug_log != stderr)
+       fclose(debug_log);
+#endif
     /* Rotate the current log to .0 */
     if (Config.Log.rotateNumber > 0) {
        snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, 0);
index 91ff433d76a9cd9e3f96954cc15b7526a70214b0..dca265d4391353b28b392d10a5cf4ada09247ab4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: disk.cc,v 1.159 2002/08/08 20:12:45 hno Exp $
+ * $Id: disk.cc,v 1.160 2002/09/01 15:16:35 hno Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
@@ -92,7 +92,7 @@ file_close(int fd)
        read_callback(-1, F->read_data);
     }
     if (F->flags.write_daemon) {
-#if defined(_SQUID_MSWIN_) || defined(_SQUID_OS2_) || defined (_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_OS2_) || defined(_SQUID_CYGWIN_)
        /*
         * on some operating systems, you can not delete or rename
         * open files, so we won't allow delayed close.
index f7ad79d93e0a249bd5d846974f3fce91cb21182a..b1ef74eb525ea13ed7650feceb47d039fd1c75eb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_ufs.cc,v 1.48 2002/08/09 10:57:46 robertc Exp $
+ * $Id: store_dir_ufs.cc,v 1.49 2002/09/01 15:16:36 hno Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -860,7 +860,7 @@ storeUfsDirCloseTmpSwapLog(SwapDir * sd)
     char *new_path = xstrdup(storeUfsDirSwapLogFile(sd, ".new"));
     int fd;
     file_close(ufsinfo->swaplog_fd);
-#if defined (_SQUID_OS2_) || defined (_SQUID_CYGWIN_)
+#if defined(_SQUID_OS2_) || defined(_SQUID_CYGWIN_) || defined(_SQUID_MSWIN_)
     if (unlink(swaplog_path) < 0) {
        debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror());
        fatal("storeUfsDirCloseTmpSwapLog: unlink failed");
@@ -1060,7 +1060,7 @@ storeUfsDirWriteCleanDone(SwapDir * sd)
     fd = state->fd;
     /* rename */
     if (state->fd >= 0) {
-#if defined(_SQUID_OS2_) || defined (_SQUID_CYGWIN_)
+#if defined(_SQUID_OS2_) || defined(_SQUID_CYGWIN_) || defined(_SQUID_MSWIN_)
        file_close(state->fd);
        state->fd = -1;
        if (unlink(state->cur) < 0)
index 950c08261d9967250d378b153aed926fabcb4808..c7a41c10c4fd80389a2c61b29defe8bc3aa8eef0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mime.cc,v 1.102 2001/11/13 17:32:15 hno Exp $
+ * $Id: mime.cc,v 1.103 2002/09/01 15:16:35 hno Exp $
  *
  * DEBUG: section 25    MIME Parsing
  * AUTHOR: Harvest Derived
@@ -297,7 +297,7 @@ mimeInit(char *filename)
        debug(50, 1) ("mimeInit: %s: %s\n", filename, xstrerror());
        return;
     }
-#if defined (_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
     setmode(fileno(fp), O_TEXT);
 #endif
     mimeFreeMemory();
index 5050d505e682a9e9bdb405d7227e2138c3bbe74d..e603bf35ef081b1b44dd35fc099664edb91ccece 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: squid.h,v 1.221 2002/08/09 10:57:43 robertc Exp $
+ * $Id: squid.h,v 1.222 2002/09/01 15:16:35 hno Exp $
  *
  * AUTHOR: Duane Wessels
  *
 #if HAVE_LIMITS_H
 #include <limits.h>
 #endif
-#if defined(_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
 #include <io.h>
 #endif
 
index 7334772a5899cb78cd09f2a7da9869e7f144017a..244577029f9ceae229e20854d9324350db0a8e24 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.220 2002/08/22 12:29:15 hno Exp $
+ * $Id: tools.cc,v 1.221 2002/09/01 15:16:35 hno Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -895,6 +895,9 @@ int
 xrename(const char *from, const char *to)
 {
     debug(21, 2) ("xrename: renaming %s to %s\n", from, to);
+#ifdef _SQUID_MSWIN_
+    remove(to);
+#endif
     if (0 == rename(from, to))
        return 0;
     debug(21, errno == ENOENT ? 2 : 1) ("xrename: Cannot rename %s to %s: %s\n",