This file is generated from the cygwin branch in CVS on SourceForge Wed Jan 3 16:59:27 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/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.1 --- squid/src/errorpage.c:1.6 Tue Dec 12 15:21:18 2000 +++ squid/src/errorpage.c Wed Jan 3 07:22:19 2001 @@ -171,7 +171,11 @@ char *text; snprintf(path, sizeof(path), "%s/%s", dir, page_name); +#if defined (_SQUID_CYGWIN_) + fd = file_open(path, O_RDONLY | O_TEXT); +#else fd = file_open(path, O_RDONLY); +#endif 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.1 --- squid/src/logfile.c:1.2 Sat Oct 21 08:16:12 2000 +++ squid/src/logfile.c Wed Jan 3 07:22:19 2001 @@ -41,7 +41,11 @@ { int fd; Logfile *lf; +#if defined (_SQUID_CYGWIN_) + fd = file_open(path, O_WRONLY | O_CREAT | O_TEXT); +#else fd = file_open(path, O_WRONLY | O_CREAT); +#endif if (DISK_ERROR == fd) { if (ENOENT == errno && fatal_flag) { fatalf("Cannot open '%s' because\n" @@ -108,7 +112,11 @@ xrename(lf->path, to); } /* Reopen the log. It may have been renamed "manually" */ +#if defined (_SQUID_CYGWIN_) + lf->fd = file_open(lf->path, O_WRONLY | O_CREAT | O_TEXT); +#else lf->fd = file_open(lf->path, O_WRONLY | O_CREAT); +#endif 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.1 --- squid/src/main.c:1.12 Mon Jan 1 16:02:11 2001 +++ squid/src/main.c Wed Jan 3 07:22:19 2001 @@ -845,7 +845,11 @@ syslog(LOG_ALERT, "setsid failed: %s", xstrerror()); closelog(); #ifdef TIOCNOTTY +#if defined(_SQUID_CYGWIN_) + if ((i = open("/dev/tty", O_RDWR | O_TEXT)) >= 0) { +#else if ((i = open("/dev/tty", O_RDWR)) >= 0) { +#endif ioctl(i, TIOCNOTTY, NULL); close(i); } @@ -858,7 +862,12 @@ * 1.1.3. execvp had a bit overflow error in a loop.. */ /* Connect stdio to /dev/null in daemon mode */ +#if defined(_SQUID_CYGWIN_) + nullfd = open("/dev/null", O_RDWR | O_TEXT); +#else nullfd = open("/dev/null", O_RDWR); +#endif + 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.1 --- squid/src/mime.c:1.6 Mon Jan 1 16:02:11 2001 +++ squid/src/mime.c Wed Jan 3 07:22:19 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,11 @@ if (storeGetPublic(url, METHOD_GET)) return; snprintf(path, MAXPATHLEN, "%s/%s", Config.icons.directory, icon); +#if defined (_SQUID_CYGWIN_) fd = file_open(path, O_RDONLY); +#else + fd = file_open(path, O_RDONLY | O_BINARY); +#endif 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.1 --- squid/src/net_db.c:1.6 Tue Nov 14 05:03:47 2000 +++ squid/src/net_db.c Wed Jan 3 07:22:19 2001 @@ -435,7 +435,11 @@ * Solaris bugs, its a bad idea. fopen can fail if more than * 256 FDs are open. */ +#if defined (_SQUID_CYGWIN_) + fd = file_open(path, O_RDONLY | O_TEXT); +#else fd = file_open(path, O_RDONLY); +#endif 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.1 --- squid/src/send-announce.c:1.3 Mon Oct 23 08:04:21 2000 +++ squid/src/send-announce.c Wed Jan 3 07:22:19 2001 @@ -88,7 +88,11 @@ strcat(sndbuf, tbuf); l = strlen(sndbuf); if ((file = Config.Announce.file) != NULL) { - fd = file_open(file, O_RDONLY); +#if defined (_SQUID_CYGWIN_) + fd = file_open(file, O_RDONLY | O_TEXT); +#else + fd = file_open(file, O_RDONLY); +#endif 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.1 --- squid/src/tools.c:1.7 Mon Jan 1 02:40:06 2001 +++ squid/src/tools.c Wed Jan 3 07:22:19 2001 @@ -578,7 +578,11 @@ return; enter_suid(); old_umask = umask(022); +#if defined(_SQUID_CYGWIN_) + fd = file_open(f, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT); +#else fd = file_open(f, O_WRONLY | O_CREAT | O_TRUNC); +#endif umask(old_umask); leave_suid(); if (fd < 0) { @@ -955,6 +959,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.2 --- 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 08:57:52 2001 @@ -322,7 +322,11 @@ char *path; int fd; path = storeUfsDirSwapLogFile(sd, NULL); +#if defined(_SQUID_CYGWIN_) + fd = file_open(path, O_WRONLY | O_CREAT | O_BINARY); +#else fd = file_open(path, O_WRONLY | O_CREAT); +#endif if (fd < 0) { debug(50, 1) ("%s: %s\n", path, xstrerror()); fatal("storeUfsDirOpenSwapLog: Failed to open swap log."); @@ -754,7 +758,11 @@ 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); +#if defined(_SQUID_CYGWIN_) + fd = file_open(rb->fullfilename, O_RDONLY | O_BINARY); +#else + fd = file_open(rb->fullfilename, O_RDONLY); +#endif if (fd < 0) debug(50, 1) ("storeUfsDirGetNextFile: %s: %s\n", rb->fullfilename, xstrerror()); else @@ -860,7 +868,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 +877,11 @@ if (xrename(new_path, swaplog_path) < 0) { fatal("storeUfsDirCloseTmpSwapLog: rename failed"); } +#if defined(_SQUID_CYGWIN_) + fd = file_open(swaplog_path, O_WRONLY | O_CREAT | O_BINARY); +#else fd = file_open(swaplog_path, O_WRONLY | O_CREAT); +#endif if (fd < 0) { debug(50, 1) ("%s: %s\n", swaplog_path, xstrerror()); fatal("storeUfsDirCloseTmpSwapLog: Failed to open swap log."); @@ -903,7 +915,11 @@ if (ufsinfo->swaplog_fd >= 0) file_close(ufsinfo->swaplog_fd); /* open a write-only FD for the new log */ +#if defined(_SQUID_CYGWIN_) + fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); +#else fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC); +#endif if (fd < 0) { debug(50, 1) ("%s: %s\n", new_path, xstrerror()); fatal("storeDirOpenTmpSwapLog: Failed to open swap log."); @@ -915,6 +931,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 +972,11 @@ sd->log.clean.write = NULL; sd->log.clean.state = NULL; state->new = xstrdup(storeUfsDirSwapLogFile(sd, ".clean")); +#if defined(_SQUID_CYGWIN_) + state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); +#else state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC); +#endif if (state->fd < 0) { xfree(state->new); xfree(state); @@ -964,7 +987,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 +1057,7 @@ static void storeUfsDirWriteCleanDone(SwapDir * sd) { + int fd; struct _clean_state *state = sd->log.clean.state; if (NULL == state) return; @@ -1053,24 +1079,30 @@ * 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)); +#if defined(_SQUID_CYGWIN_) + file_close(file_open(state->cln, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY)); +#else + file_close(file_open(state->cln, O_WRONLY | O_CREAT | O_TRUNC)); +#endif /* 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.1 --- 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 07:22:20 2001 @@ -54,7 +54,11 @@ struct stat sb; int fd; debug(79, 3) ("storeUfsOpen: fileno %08X\n", f); +#if defined (_SQUID_CYGWIN_) + fd = file_open(path, O_RDONLY | O_BINARY); +#else fd = file_open(path, O_RDONLY); +#endif if (fd < 0) { debug(79, 3) ("storeUfsOpen: got failure (%d)\n", errno); return NULL; @@ -88,7 +92,11 @@ { storeIOState *sio; int fd; +#if defined (_SQUID_CYGWIN_) + int mode = (O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); +#else int mode = (O_WRONLY | O_CREAT | O_TRUNC); +#endif char *path; ufsinfo_t *ufsinfo = (ufsinfo_t *) SD->fsdata; sfileno filn;