/*
- * $Id: acl.cc,v 1.228 2001/01/02 00:09:55 wessels Exp $
+ * $Id: acl.cc,v 1.229 2001/01/04 03:42:34 wessels Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
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;
/*
- * $Id: cache_cf.cc,v 1.362 2001/01/02 01:41:30 wessels Exp $
+ * $Id: cache_cf.cc,v 1.363 2001/01/04 03:42:34 wessels Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
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;
/*
- * $Id: cache_diff.cc,v 1.13 2000/10/31 23:48:13 wessels Exp $
+ * $Id: cache_diff.cc,v 1.14 2001/01/04 03:42:34 wessels Exp $
*
* AUTHOR: Alex Rousskov
*
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);
/*
- * $Id: cf_gen.cc,v 1.37 2000/11/25 16:02:14 adrian Exp $
+ * $Id: cf_gen.cc,v 1.38 2001/01/04 03:42:34 wessels Exp $
*
* DEBUG: none Generate squid.conf and cf_parser.c
* AUTHOR: Max Okumoto
#if HAVE_ASSERT_H
#include <assert.h>
#endif
+#if defined(_SQUID_CYGWIN_)
+#include <io.h>
+#endif
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
#include "util.h"
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];
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"
perror(conf_filename);
exit(1);
}
+#if defined(_SQUID_CYGWIN_)
+ setmode(fileno(fp), O_TEXT);
+#endif
gen_conf(entries, fp);
fclose(fp);
/*
- * $Id: client.cc,v 1.89 2000/08/15 02:37:14 wessels Exp $
+ * $Id: client.cc,v 1.90 2001/01/04 03:42:34 wessels Exp $
*
* DEBUG: section 0 WWW Client
* AUTHOR: Harvest Derived
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);
/*
- * $Id: debug.cc,v 1.78 2000/03/06 16:23:30 wessels Exp $
+ * $Id: debug.cc,v 1.79 2001/01/04 03:42:34 wessels Exp $
*
* DEBUG: section 0 Debug Routines
* AUTHOR: Harvest Derived
fflush(stderr);
debug_log = stderr;
}
+#if defined(_SQUID_CYGWIN_)
+ setmode(fileno(debug_log), O_TEXT);
+#endif
}
void
/*
- * $Id: defines.h,v 1.83 2000/10/17 08:06:03 adrian Exp $
+ * $Id: defines.h,v 1.84 2001/01/04 03:42:34 wessels Exp $
*
*
* SQUID Internet Object Cache http://squid.nlanr.net/Squid/
#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
/*
- * $Id: dns_internal.cc,v 1.34 2000/11/03 17:03:54 wessels Exp $
+ * $Id: dns_internal.cc,v 1.35 2001/01/04 03:42:34 wessels Exp $
*
* DEBUG: section 78 DNS lookups; interacts with lib/rfc1035.c
* AUTHOR: Duane Wessels
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)
/*
- * $Id: errorpage.cc,v 1.158 2000/12/08 23:58:08 wessels Exp $
+ * $Id: errorpage.cc,v 1.159 2001/01/04 03:42:34 wessels Exp $
*
* DEBUG: section 4 Error Generation
* AUTHOR: Duane Wessels
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)
/*
- * $Id: store_dir_ufs.cc,v 1.21 2001/01/02 01:41:35 wessels Exp $
+ * $Id: store_dir_ufs.cc,v 1.22 2001/01/04 03:42:38 wessels Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
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.");
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
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");
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.");
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.");
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;
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);
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);
static void
storeUfsDirWriteCleanDone(SwapDir * sd)
{
+ int fd;
struct _clean_state *state = sd->log.clean.state;
if (NULL == state)
return;
* 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);
/*
- * $Id: store_io_ufs.cc,v 1.3 2000/06/26 20:17:13 adrian Exp $
+ * $Id: store_io_ufs.cc,v 1.4 2001/01/04 03:42:38 wessels Exp $
*
* DEBUG: section 79 Storage Manager UFS Interface
* AUTHOR: Duane Wessels
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;
{
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;
/*
- * $Id: logfile.cc,v 1.6 2000/10/10 18:15:30 wessels Exp $
+ * $Id: logfile.cc,v 1.7 2001/01/04 03:42:34 wessels Exp $
*
* DEBUG: section 50 Log file handling
* AUTHOR: Duane Wessels
{
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"
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());
/*
- * $Id: main.cc,v 1.326 2001/01/01 16:24:39 hno Exp $
+ * $Id: main.cc,v 1.327 2001/01/04 03:42:34 wessels Exp $
*
* DEBUG: section 1 Startup and Main Loop
* AUTHOR: Harvest Derived
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);
}
* 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);
/*
- * $Id: mime.cc,v 1.97 2001/01/01 16:24:39 hno Exp $
+ * $Id: mime.cc,v 1.98 2001/01/04 03:42:35 wessels Exp $
*
* DEBUG: section 25 MIME Parsing
* AUTHOR: Harvest Derived
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, '#')))
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;
/*
- * $Id: net_db.cc,v 1.153 2000/11/13 23:30:26 wessels Exp $
+ * $Id: net_db.cc,v 1.154 2001/01/04 03:42:35 wessels Exp $
*
* DEBUG: section 38 Network Measurement Database
* AUTHOR: Duane Wessels
* 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)
/*
- * $Id: send-announce.cc,v 1.58 2000/03/06 16:23:34 wessels Exp $
+ * $Id: send-announce.cc,v 1.59 2001/01/04 03:42:35 wessels Exp $
*
* DEBUG: section 27 Cache Announcer
* AUTHOR: Duane Wessels
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;
/*
- * $Id: squid.h,v 1.203 2000/08/07 23:01:18 wessels Exp $
+ * $Id: squid.h,v 1.204 2001/01/04 03:42:35 wessels Exp $
*
* AUTHOR: Duane Wessels
*
#if HAVE_LIMITS_H
#include <limits.h>
#endif
+#if defined(_SQUID_CYGWIN_)
+#include <io.h>
+#endif
#if HAVE_DIRENT_H
#include <dirent.h>
/*
- * $Id: tools.cc,v 1.201 2000/12/31 23:53:08 wessels Exp $
+ * $Id: tools.cc,v 1.202 2001/01/04 03:42:35 wessels Exp $
*
* DEBUG: section 21 Misc Functions
* AUTHOR: Harvest Derived
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) {
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 */