This file is generated from the cygwin branch in CVS on SourceForge Thu Jan 4 00:01:45 2001 GMT See http://squid.sourceforge.net/ Index: squid/src/acl.c diff -u squid/src/acl.c:1.6 squid/src/acl.c:1.6.2.1 --- squid/src/acl.c:1.6 Mon Jan 1 16:02:11 2001 +++ squid/src/acl.c Wed Jan 3 07:22:19 2001 @@ -120,6 +120,9 @@ debug(28, 0) ("strtokFile: %s not found\n", fn); return (NULL); } +#if defined(_SQUID_CYGWIN_) + setmode(fileno(aclFile), O_TEXT); +#endif aclFromFile = 1; } else { return t; Index: squid/src/cache_cf.c diff -u squid/src/cache_cf.c:1.6 squid/src/cache_cf.c:1.6.10.1 --- squid/src/cache_cf.c:1.6 Tue Dec 12 15:21:17 2000 +++ squid/src/cache_cf.c Wed Jan 3 07:22:19 2001 @@ -218,6 +218,9 @@ if ((fp = fopen(file_name, "r")) == NULL) fatalf("Unable to open configuration file: %s: %s", file_name, xstrerror()); +#if defined(_SQUID_CYGWIN_) + setmode(fileno(fp), O_TEXT); +#endif cfg_filename = file_name; if ((token = strrchr(cfg_filename, '/'))) cfg_filename = token + 1; Index: squid/src/cache_diff.c diff -u squid/src/cache_diff.c:1.4 squid/src/cache_diff.c:1.4.26.1 --- squid/src/cache_diff.c:1.4 Fri Nov 3 00:39:20 2000 +++ squid/src/cache_diff.c Wed Jan 3 07:22:19 2001 @@ -137,6 +137,9 @@ fprintf(stderr, "cannot open %s: %s\n", fname, strerror(errno)); return 0; } +#if defined(_SQUID_CYGWIN_) + setmode(fileno(file), O_BINARY); +#endif scanned_count = cacheIndexScan(idx, fname, file); fclose(file); Index: squid/src/cf_gen.c diff -u squid/src/cf_gen.c:1.4 squid/src/cf_gen.c:1.4.18.1 --- squid/src/cf_gen.c:1.4 Tue Nov 28 03:35:36 2000 +++ squid/src/cf_gen.c Wed Jan 3 07:22:19 2001 @@ -66,6 +66,12 @@ #if HAVE_ASSERT_H #include #endif +#if defined(_SQUID_CYGWIN_) +#include +#endif +#if HAVE_FCNTL_H +#include +#endif #include "util.h" @@ -145,6 +151,9 @@ perror(input_filename); exit(1); } +#if defined(_SQUID_CYGWIN_) + setmode(fileno(fp), O_TEXT); +#endif state = sSTART; while (feof(fp) == 0 && state != sEXIT) { char buff[MAX_LINE]; @@ -318,6 +327,9 @@ perror(output_filename); exit(1); } +#if defined(_SQUID_CYGWIN_) + setmode(fileno(fp), O_TEXT); +#endif fprintf(fp, "/*\n" " * Generated automatically from %s by %s\n" @@ -340,6 +352,9 @@ perror(conf_filename); exit(1); } +#if defined(_SQUID_CYGWIN_) + setmode(fileno(fp), O_TEXT); +#endif gen_conf(entries, fp); fclose(fp); Index: squid/src/client.c diff -u squid/src/client.c:1.3 squid/src/client.c:1.3.28.1 --- squid/src/client.c:1.3 Mon Oct 23 08:04:20 2000 +++ squid/src/client.c Wed Jan 3 07:22:19 2001 @@ -203,6 +203,9 @@ xstrerror()); exit(-1); } +#if defined(_SQUID_CYGWIN_) + setmode(put_fd, O_BINARY); +#endif fstat(put_fd, &sb); } snprintf(msg, BUFSIZ, "%s %s HTTP/1.0\r\n", method, url); Index: squid/src/debug.c diff -u squid/src/debug.c:1.3 squid/src/debug.c:1.3.26.1 --- squid/src/debug.c:1.3 Mon Oct 23 08:04:20 2000 +++ squid/src/debug.c Wed Jan 3 07:22:19 2001 @@ -157,6 +157,9 @@ fflush(stderr); debug_log = stderr; } +#if defined(_SQUID_CYGWIN_) + setmode(fileno(debug_log), O_TEXT); +#endif } void Index: squid/src/defines.h diff -u squid/src/defines.h:1.3 squid/src/defines.h:1.3.22.1 --- squid/src/defines.h:1.3 Mon Oct 23 08:04:20 2000 +++ squid/src/defines.h Wed Jan 3 15:52:41 2001 @@ -281,3 +281,10 @@ #ifndef _PATH_DEVNULL #define _PATH_DEVNULL "/dev/null" #endif + +#ifndef O_TEXT +#define O_TEXT 0 +#endif +#ifndef O_BINARY +#define O_BINARY 0 +#endif Index: squid/src/dns_internal.c diff -u squid/src/dns_internal.c:1.5 squid/src/dns_internal.c:1.5.26.1 --- squid/src/dns_internal.c:1.5 Fri Nov 3 13:04:27 2000 +++ squid/src/dns_internal.c Wed Jan 3 07:22:19 2001 @@ -148,6 +148,9 @@ debug(78, 1) ("%s: %s\n", _PATH_RESOLV_CONF, xstrerror()); return; } +#if defined(_SQUID_CYGWIN_) + setmode(fileno(fp), O_TEXT); +#endif while (fgets(buf, 512, fp)) { t = strtok(buf, w_space); if (NULL == t) Index: squid/src/errorpage.c diff -u squid/src/errorpage.c:1.6 squid/src/errorpage.c:1.6.10.2 --- squid/src/errorpage.c:1.6 Tue Dec 12 15:21:18 2000 +++ squid/src/errorpage.c Wed Jan 3 15:52:41 2001 @@ -171,7 +171,7 @@ char *text; snprintf(path, sizeof(path), "%s/%s", dir, page_name); - fd = file_open(path, O_RDONLY); + fd = file_open(path, O_RDONLY | O_TEXT); if (fd < 0 || fstat(fd, &sb) < 0) { debug(4, 0) ("errorTryLoadText: '%s': %s\n", path, xstrerror()); if (fd >= 0) Index: squid/src/logfile.c diff -u squid/src/logfile.c:1.2 squid/src/logfile.c:1.2.30.3 --- squid/src/logfile.c:1.2 Sat Oct 21 08:16:12 2000 +++ squid/src/logfile.c Wed Jan 3 16:00:31 2001 @@ -41,7 +41,7 @@ { int fd; Logfile *lf; - fd = file_open(path, O_WRONLY | O_CREAT); + fd = file_open(path, O_WRONLY | O_CREAT | O_TEXT); if (DISK_ERROR == fd) { if (ENOENT == errno && fatal_flag) { fatalf("Cannot open '%s' because\n" @@ -108,7 +108,7 @@ xrename(lf->path, to); } /* Reopen the log. It may have been renamed "manually" */ - lf->fd = file_open(lf->path, O_WRONLY | O_CREAT); + lf->fd = file_open(lf->path, O_WRONLY | O_CREAT | O_TEXT); if (DISK_ERROR == lf->fd && lf->flags.fatal) { debug(50, 1) ("logfileRotate: %s: %s\n", lf->path, xstrerror()); fatalf("Cannot open %s: %s", lf->path, xstrerror()); Index: squid/src/main.c diff -u squid/src/main.c:1.12 squid/src/main.c:1.12.2.3 --- squid/src/main.c:1.12 Mon Jan 1 16:02:11 2001 +++ squid/src/main.c Wed Jan 3 16:00:31 2001 @@ -845,7 +845,7 @@ syslog(LOG_ALERT, "setsid failed: %s", xstrerror()); closelog(); #ifdef TIOCNOTTY - if ((i = open("/dev/tty", O_RDWR)) >= 0) { + if ((i = open("/dev/tty", O_RDWR | O_TEXT)) >= 0) { ioctl(i, TIOCNOTTY, NULL); close(i); } @@ -858,7 +858,7 @@ * 1.1.3. execvp had a bit overflow error in a loop.. */ /* Connect stdio to /dev/null in daemon mode */ - nullfd = open("/dev/null", O_RDWR); + nullfd = open("/dev/null", O_RDWR | O_TEXT); dup2(nullfd, 0); if (opt_debug_stderr < 0) { dup2(nullfd, 1); Index: squid/src/mime.c diff -u squid/src/mime.c:1.6 squid/src/mime.c:1.6.2.2 --- squid/src/mime.c:1.6 Mon Jan 1 16:02:11 2001 +++ squid/src/mime.c Wed Jan 3 15:52:41 2001 @@ -297,6 +297,9 @@ debug(50, 1) ("mimeInit: %s: %s\n", filename, xstrerror()); return; } +#if defined (_SQUID_CYGWIN_) + setmode(fileno(fp), O_TEXT); +#endif mimeFreeMemory(); while (fgets(buf, BUFSIZ, fp)) { if ((t = strchr(buf, '#'))) @@ -406,7 +409,7 @@ if (storeGetPublic(url, METHOD_GET)) return; snprintf(path, MAXPATHLEN, "%s/%s", Config.icons.directory, icon); - fd = file_open(path, O_RDONLY); + fd = file_open(path, O_RDONLY | O_BINARY); if (fd < 0) { debug(25, 0) ("mimeLoadIconFile: %s: %s\n", path, xstrerror()); return; Index: squid/src/net_db.c diff -u squid/src/net_db.c:1.6 squid/src/net_db.c:1.6.16.2 --- squid/src/net_db.c:1.6 Tue Nov 14 05:03:47 2000 +++ squid/src/net_db.c Wed Jan 3 15:52:41 2001 @@ -435,7 +435,7 @@ * Solaris bugs, its a bad idea. fopen can fail if more than * 256 FDs are open. */ - fd = file_open(path, O_RDONLY); + fd = file_open(path, O_RDONLY | O_TEXT); if (fd < 0) return; if (fstat(fd, &sb) < 0) Index: squid/src/send-announce.c diff -u squid/src/send-announce.c:1.3 squid/src/send-announce.c:1.3.22.2 --- squid/src/send-announce.c:1.3 Mon Oct 23 08:04:21 2000 +++ squid/src/send-announce.c Wed Jan 3 15:52:41 2001 @@ -88,7 +88,7 @@ strcat(sndbuf, tbuf); l = strlen(sndbuf); if ((file = Config.Announce.file) != NULL) { - fd = file_open(file, O_RDONLY); + fd = file_open(file, O_RDONLY | O_TEXT); if (fd > -1 && (n = read(fd, sndbuf + l, BUFSIZ - l - 1)) > 0) { fd_bytes(fd, n, FD_READ); l += n; Index: squid/src/squid.h diff -u squid/src/squid.h:1.3 squid/src/squid.h:1.3.22.1 --- squid/src/squid.h:1.3 Mon Oct 23 08:04:22 2000 +++ squid/src/squid.h Wed Jan 3 07:22:19 2001 @@ -191,6 +191,9 @@ #if HAVE_LIMITS_H #include #endif +#if defined(_SQUID_CYGWIN_) +#include +#endif #if HAVE_DIRENT_H #include Index: squid/src/tools.c diff -u squid/src/tools.c:1.7 squid/src/tools.c:1.7.2.2 --- squid/src/tools.c:1.7 Mon Jan 1 02:40:06 2001 +++ squid/src/tools.c Wed Jan 3 15:52:41 2001 @@ -578,7 +578,7 @@ return; enter_suid(); old_umask = umask(022); - fd = file_open(f, O_WRONLY | O_CREAT | O_TRUNC); + fd = file_open(f, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT); umask(old_umask); leave_suid(); if (fd < 0) { @@ -955,6 +955,9 @@ Config.etcHostsPath, xstrerror()); return; } +#if defined(_SQUID_CYGWIN_) + setmode(fileno(fp), O_TEXT); +#endif while (fgets(buf, 1024, fp)) { /* for each line */ wordlist *hosts = NULL; if (buf[0] == '#') /* MS-windows likes to add comments */ Index: squid/src/fs/ufs/store_dir_ufs.c diff -u squid/src/fs/ufs/store_dir_ufs.c:1.5 squid/src/fs/ufs/store_dir_ufs.c:1.5.10.3 --- squid/src/fs/ufs/store_dir_ufs.c:1.5 Tue Dec 12 15:21:23 2000 +++ squid/src/fs/ufs/store_dir_ufs.c Wed Jan 3 15:52:41 2001 @@ -322,7 +322,7 @@ char *path; int fd; path = storeUfsDirSwapLogFile(sd, NULL); - fd = file_open(path, O_WRONLY | O_CREAT); + fd = file_open(path, O_WRONLY | O_CREAT | O_BINARY); if (fd < 0) { debug(50, 1) ("%s: %s\n", path, xstrerror()); fatal("storeUfsDirOpenSwapLog: Failed to open swap log."); @@ -754,7 +754,7 @@ snprintf(rb->fullfilename, SQUID_MAXPATHLEN, "%s/%s", rb->fullpath, rb->entry->d_name); debug(20, 3) ("storeUfsDirGetNextFile: Opening %s\n", rb->fullfilename); - fd = file_open(rb->fullfilename, O_RDONLY); + fd = file_open(rb->fullfilename, O_RDONLY | O_BINARY); if (fd < 0) debug(50, 1) ("storeUfsDirGetNextFile: %s: %s\n", rb->fullfilename, xstrerror()); else @@ -860,7 +860,7 @@ char *new_path = xstrdup(storeUfsDirSwapLogFile(sd, ".new")); int fd; file_close(ufsinfo->swaplog_fd); -#ifdef _SQUID_OS2_ +#if defined (_SQUID_OS2_) || defined (_SQUID_CYGWIN_) if (unlink(swaplog_path) < 0) { debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror()); fatal("storeUfsDirCloseTmpSwapLog: unlink failed"); @@ -869,7 +869,7 @@ if (xrename(new_path, swaplog_path) < 0) { fatal("storeUfsDirCloseTmpSwapLog: rename failed"); } - fd = file_open(swaplog_path, O_WRONLY | O_CREAT); + fd = file_open(swaplog_path, O_WRONLY | O_CREAT | O_BINARY); if (fd < 0) { debug(50, 1) ("%s: %s\n", swaplog_path, xstrerror()); fatal("storeUfsDirCloseTmpSwapLog: Failed to open swap log."); @@ -903,7 +903,7 @@ if (ufsinfo->swaplog_fd >= 0) file_close(ufsinfo->swaplog_fd); /* open a write-only FD for the new log */ - fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC); + fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); if (fd < 0) { debug(50, 1) ("%s: %s\n", new_path, xstrerror()); fatal("storeDirOpenTmpSwapLog: Failed to open swap log."); @@ -915,6 +915,9 @@ debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror()); fatal("Failed to open swap log for reading"); } +#if defined(_SQUID_CYGWIN_) + setmode(fileno(fp), O_BINARY); +#endif memset(&clean_sb, '\0', sizeof(struct stat)); if (stat(clean_path, &clean_sb) < 0) *clean_flag = 0; @@ -953,7 +956,7 @@ sd->log.clean.write = NULL; sd->log.clean.state = NULL; state->new = xstrdup(storeUfsDirSwapLogFile(sd, ".clean")); - state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC); + state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); if (state->fd < 0) { xfree(state->new); xfree(state); @@ -964,7 +967,9 @@ state->outbuf = xcalloc(CLEAN_BUF_SZ, 1); state->outbuf_offset = 0; state->walker = sd->repl->WalkInit(sd->repl); +#if !(defined(_SQUID_OS2_) || defined (_SQUID_CYGWIN_)) unlink(state->new); +#endif unlink(state->cln); debug(20, 3) ("storeDirWriteCleanLogs: opened %s, FD %d\n", state->new, state->fd); @@ -1032,6 +1037,7 @@ static void storeUfsDirWriteCleanDone(SwapDir * sd) { + int fd; struct _clean_state *state = sd->log.clean.state; if (NULL == state) return; @@ -1053,24 +1059,26 @@ * so we have to close before renaming. */ storeUfsDirCloseSwapLog(sd); + /* save the fd value for a later test */ + fd = state->fd; /* rename */ if (state->fd >= 0) { -#ifdef _SQUID_OS2_ +#if defined(_SQUID_OS2_) || defined (_SQUID_CYGWIN_) file_close(state->fd); state->fd = -1; - if (unlink(cur) < 0) + if (unlink(state->cur) < 0) debug(50, 0) ("storeDirWriteCleanLogs: unlinkd failed: %s, %s\n", - xstrerror(), cur); + xstrerror(), state->cur); #endif xrename(state->new, state->cur); } /* touch a timestamp file if we're not still validating */ if (store_dirs_rebuilding) (void) 0; - else if (state->fd < 0) + else if (fd < 0) (void) 0; else - file_close(file_open(state->cln, O_WRONLY | O_CREAT | O_TRUNC)); + file_close(file_open(state->cln, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY)); /* close */ safe_free(state->cur); safe_free(state->new); Index: squid/src/fs/ufs/store_io_ufs.c diff -u squid/src/fs/ufs/store_io_ufs.c:1.2 squid/src/fs/ufs/store_io_ufs.c:1.2.24.2 --- squid/src/fs/ufs/store_io_ufs.c:1.2 Sat Oct 21 09:44:46 2000 +++ squid/src/fs/ufs/store_io_ufs.c Wed Jan 3 15:52:41 2001 @@ -54,7 +54,7 @@ struct stat sb; int fd; debug(79, 3) ("storeUfsOpen: fileno %08X\n", f); - fd = file_open(path, O_RDONLY); + fd = file_open(path, O_RDONLY | O_BINARY); if (fd < 0) { debug(79, 3) ("storeUfsOpen: got failure (%d)\n", errno); return NULL; @@ -88,7 +88,7 @@ { storeIOState *sio; int fd; - int mode = (O_WRONLY | O_CREAT | O_TRUNC); + int mode = (O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); char *path; ufsinfo_t *ufsinfo = (ufsinfo_t *) SD->fsdata; sfileno filn;