]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
WIN32/Cygwin fixes by Guido
authorhno <>
Thu, 16 Aug 2001 06:16:15 +0000 (06:16 +0000)
committerhno <>
Thu, 16 Aug 2001 06:16:15 +0000 (06:16 +0000)
- Better GetOSVersion function, more squid "aware", added support for
Windows XP and future Windows versions.
- Added trap in WIN32_Subsystem_Init() for unknown or unsupported (WIN32s)
Windows version.
- Fixed compile warning in comm.c
- Changed exit() WIN32 hook, now less intrusive

And some ident fixes

19 files changed:
helpers/basic_auth/LDAP/squid_ldap_auth.c
helpers/ntlm_auth/SMB/ntlm.h
src/HttpReply.cc
src/cache_cf.cc
src/comm.cc
src/defines.h
src/disk.cc
src/dns_internal.cc
src/fs/coss/async_io.cc
src/fs/coss/async_io.h
src/fs/coss/store_dir_coss.cc
src/globals.h
src/main.cc
src/protos.h
src/repl/lru/store_repl_lru.cc
src/stat.cc
src/store_dir.cc
src/tools.cc
src/win32.cc

index b6e45035d4a5df9538180864fc666716e283a775..7abb84e8ce779dc689e673471fa5edda936c1490 100644 (file)
@@ -11,7 +11,7 @@
  * National Research Council
  * 
  * Usage: squid_ldap_auth -b basedn [-s searchscope]
- *                       [-f searchfilter] [-D binddn -w bindpasswd]
+ *                        [-f searchfilter] [-D binddn -w bindpasswd]
  *                        [-u attr] [-p] [-R] <ldap_server_name>
  * 
  * Dependencies: You need to get the OpenLDAP libraries
@@ -25,7 +25,7 @@
  * Changes:
  * 2001-05-02: Henrik Nordstrom <hno@squid-cache.org>
  *             - Support newer OpenLDAP 2.x libraries using the
- *              revised Internet Draft API which unfortunately
+ *               revised Internet Draft API which unfortunately
  *               is not backwards compatible with RFC1823..
  * 2001-04-15: Henrik Nordstrom <hno@squid-cache.org>
  *             - Added command line option for basedn
@@ -64,31 +64,38 @@ static int checkLDAP(LDAP * ld, char *userid, char *password);
 /* Yuck.. we need to glue to different versions of the API */
 
 #if defined(LDAP_API_VERSION) && LDAP_API_VERSION > 1823
-static int squid_ldap_errno(LDAP *ld)
+static int 
+squid_ldap_errno(LDAP * ld)
 {
     int err = 0;
     ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &err);
     return err;
 }
-static void squid_ldap_set_aliasderef(LDAP *ld, int deref)
+static void 
+squid_ldap_set_aliasderef(LDAP * ld, int deref)
 {
     ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
 }
-static void squid_ldap_set_referrals(LDAP *ld, int referrals)
+static void 
+squid_ldap_set_referrals(LDAP * ld, int referrals)
 {
     int *value = referrals ? LDAP_OPT_ON : LDAP_OPT_OFF;
     ldap_set_option(ld, LDAP_OPT_REFERRALS, value);
 }
+
 #else
-static int squid_ldap_errno(LDAP *ld)
+static int 
+squid_ldap_errno(LDAP * ld)
 {
     return ld->ld_errno;
 }
-static void squid_ldap_set_aliasderef(LDAP *ld, int deref)
+static void 
+squid_ldap_set_aliasderef(LDAP * ld, int deref)
 {
     ld->ld_deref = deref;
 }
-static void squid_ldap_set_referrals(LDAP *ld, int referrals)
+static void 
+squid_ldap_set_referrals(LDAP * ld, int referrals)
 {
     if (referrals)
        ld->ld_options |= ~LDAP_OPT_REFERRALS;
@@ -111,13 +118,13 @@ main(int argc, char **argv)
     while (argc > 2 && argv[1][0] == '-') {
        char *value = "";
        char option = argv[1][1];
-       switch(option) {
+       switch (option) {
        case 'p':
        case 'R':
            break;
        default:
            if (strlen(argv[1]) > 2) {
-               value = argv[1]+2;
+               value = argv[1] + 2;
            } else {
                value = argv[2];
                argv++;
@@ -127,57 +134,57 @@ main(int argc, char **argv)
        }
        argv++;
        argc--;
-       switch(option) {
+       switch (option) {
        case 'b':
-               basedn = value;
-               break;
+           basedn = value;
+           break;
        case 'f':
-               searchfilter = value;
-               break;
+           searchfilter = value;
+           break;
        case 'u':
-               userattr = value;
-               break;
+           userattr = value;
+           break;
        case 's':
-               if (strcmp(value, "base") == 0)
-                   searchscope = LDAP_SCOPE_BASE;
-               else if (strcmp(value, "one") == 0)
-                   searchscope = LDAP_SCOPE_ONELEVEL;
-               else if (strcmp(value, "sub") == 0)
-                   searchscope = LDAP_SCOPE_SUBTREE;
-               else {
-                   fprintf(stderr, "squid_ldap_auth: ERROR: Unknown search scope '%s'\n", value);
-                   exit(1);
-               }
-               break;
+           if (strcmp(value, "base") == 0)
+               searchscope = LDAP_SCOPE_BASE;
+           else if (strcmp(value, "one") == 0)
+               searchscope = LDAP_SCOPE_ONELEVEL;
+           else if (strcmp(value, "sub") == 0)
+               searchscope = LDAP_SCOPE_SUBTREE;
+           else {
+               fprintf(stderr, "squid_ldap_auth: ERROR: Unknown search scope '%s'\n", value);
+               exit(1);
+           }
+           break;
        case 'a':
-               if (strcmp(value, "never") == 0)
-                   aliasderef = LDAP_DEREF_NEVER;
-               else if (strcmp(value, "always") == 0)
-                   aliasderef = LDAP_DEREF_ALWAYS;
-               else if (strcmp(value, "search") == 0)
-                   aliasderef = LDAP_DEREF_SEARCHING;
-               else if (strcmp(value, "find") == 0)
-                   aliasderef = LDAP_DEREF_FINDING;
-               else {
-                   fprintf(stderr, "squid_ldap_auth: ERROR: Unknown alias dereference method '%s'\n", value);
-                   exit(1);
-               }
-               break;
+           if (strcmp(value, "never") == 0)
+               aliasderef = LDAP_DEREF_NEVER;
+           else if (strcmp(value, "always") == 0)
+               aliasderef = LDAP_DEREF_ALWAYS;
+           else if (strcmp(value, "search") == 0)
+               aliasderef = LDAP_DEREF_SEARCHING;
+           else if (strcmp(value, "find") == 0)
+               aliasderef = LDAP_DEREF_FINDING;
+           else {
+               fprintf(stderr, "squid_ldap_auth: ERROR: Unknown alias dereference method '%s'\n", value);
+               exit(1);
+           }
+           break;
        case 'D':
-               binddn = value;
-               break;
+           binddn = value;
+           break;
        case 'w':
-               bindpasswd = value;
-               break;
+           bindpasswd = value;
+           break;
        case 'p':
-               persistent = !persistent;
-               break;
+           persistent = !persistent;
+           break;
        case 'R':
-               noreferrals = !noreferrals;
-               break;
+           noreferrals = !noreferrals;
+           break;
        default:
-               fprintf(stderr, "squid_ldap_auth: ERROR: Unknown command line option '%c'\n", option);
-               exit(1);
+           fprintf(stderr, "squid_ldap_auth: ERROR: Unknown command line option '%c'\n", option);
+           exit(1);
        }
     }
 
@@ -212,7 +219,7 @@ main(int argc, char **argv)
        }
        *passwd++ = '\0';       /* Cut in username,password */
        tryagain = 1;
-recover:
+      recover:
        if (ld == NULL) {
            if ((ld = ldap_init(ldapServer, LDAP_PORT)) == NULL) {
                fprintf(stderr, "\nUnable to connect to LDAP server:%s port:%d\n",
@@ -258,7 +265,8 @@ checkLDAP(LDAP * ld, char *userid, char *password)
        char filter[256];
        LDAPMessage *res = NULL;
        LDAPMessage *entry;
-       char *searchattr[] = {NULL};
+       char *searchattr[] =
+       {NULL};
        char *userdn;
        int rc;
 
@@ -300,6 +308,6 @@ checkLDAP(LDAP * ld, char *userid, char *password)
 
     if (ldap_simple_bind_s(ld, dn, password) != LDAP_SUCCESS)
        return 1;
-    
+
     return 0;
 }
index 69643675033afe56b728cdd943d93116456fca4e..3230e579dd5ee38b4242391faf9c6585f32c9ac6 100644 (file)
@@ -57,7 +57,7 @@ static char *__foo;
 #define debug(X...)            /* */
 #endif /* DEBUG */
 #else /* __GNUC__ */
-static void 
+static void
 debug(char *format,...)
 {
 }
index bdfbafff473835fdd7e13df773f03cf24bfe9000..b8e6405a9c25b551fe2f31ea745761b045f1513b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpReply.cc,v 1.47 2001/07/28 09:21:31 hno Exp $
+ * $Id: HttpReply.cc,v 1.48 2001/08/16 00:16:15 hno Exp $
  *
  * DEBUG: section 58    HTTP Reply (Response)
  * AUTHOR: Alex Rousskov
@@ -469,7 +469,7 @@ httpReplyBodySize(method_t method, HttpReply * reply)
  * Calculates the maximum size allowed for an HTTP response
  */
 void
-httpReplyBodyBuildSize(request_t *request, HttpReply * reply, dlink_list *bodylist)
+httpReplyBodyBuildSize(request_t * request, HttpReply * reply, dlink_list * bodylist)
 {
     body_size *bs;
     aclCheck_t *checklist;
@@ -484,8 +484,8 @@ httpReplyBodyBuildSize(request_t *request, HttpReply * reply, dlink_list *bodyli
            /* Allow - use this entry */
            reply->maxBodySize = bs->maxsize;
            bs = NULL;
-           debug (58, 3) ("httpReplyBodyBuildSize: Setting maxBodySize to %d\n", reply->maxBodySize);
+           debug(58, 3) ("httpReplyBodyBuildSize: Setting maxBodySize to %d\n", reply->maxBodySize);
        }
-       aclChecklistFree(checklist); 
+       aclChecklistFree(checklist);
     }
 }
index e379086db43f4dbd7efe0444dab77da1a1a74df7..4f2ba2bb0ac5bbef2a57282e3c57e879db8ba05e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.387 2001/07/28 09:21:31 hno Exp $
+ * $Id: cache_cf.cc,v 1.388 2001/08/16 00:16:15 hno Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -1870,15 +1870,15 @@ parse_b_size_t(size_t * var)
     parseBytesLine(var, B_BYTES_STR);
 }
 
-CBDATA_TYPE (body_size);
+CBDATA_TYPE(body_size);
 
 static void
-parse_body_size_t(dlink_list *bodylist)
+parse_body_size_t(dlink_list * bodylist)
 {
     body_size *bs;
-    CBDATA_INIT_TYPE (body_size);
+    CBDATA_INIT_TYPE(body_size);
     bs = cbdataAlloc(body_size);
-    parse_size_t (&bs->maxsize);
+    parse_size_t(&bs->maxsize);
     aclParseAccessLine(&bs->access_list);
 
     dlinkAddTail(bs, &bs->node, bodylist);
@@ -1890,34 +1890,34 @@ dump_body_size_t(StoreEntry * entry, const char *name, dlink_list bodylist)
     body_size *bs;
     bs = (body_size *) bodylist.head;
     while (bs) {
-        acl_list *l;
+       acl_list *l;
        acl_access *head = bs->access_list;
        while (head != NULL) {
-            storeAppendPrintf(entry, "%s %d %s", name, bs->maxsize, 
+           storeAppendPrintf(entry, "%s %d %s", name, bs->maxsize,
                head->allow ? "Allow" : "Deny");
            for (l = head->acl_list; l != NULL; l = l->next) {
-               storeAppendPrintf(entry, " %s%s",
+               storeAppendPrintf(entry, " %s%s",
                    l->op ? null_string : "!",
                    l->acl->name);
            }
            storeAppendPrintf(entry, "\n");
            head = head->next;
-       }           
+       }
        bs = (body_size *) bs->node.next;
     }
 }
 
 static void
-free_body_size_t(dlink_list * bodylist) //acl_access ** head)
-{
+free_body_size_t(dlink_list * bodylist)                //acl_access ** head)
+ {
     body_size *bs, *tempnode;
     bs = (body_size *) bodylist->head;
     while (bs) {
-        bs->maxsize = 0;
+       bs->maxsize = 0;
        aclDestroyAccessList(&bs->access_list);
        tempnode = (body_size *) bs->node.next;
-       dlinkDelete (&bs->node, bodylist);
-       cbdataFree (bs);
+       dlinkDelete(&bs->node, bodylist);
+       cbdataFree(bs);
        bs = tempnode;
     }
 }
index fd8f1cf28f87c3b16c544e92b3322c54ddf8b0b3..0f53210da5501c01938bc86d522c7c451a494ffc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.318 2001/04/14 00:03:22 hno Exp $
+ * $Id: comm.cc,v 1.319 2001/08/16 00:16:16 hno Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -35,6 +35,9 @@
 
 #include "squid.h"
 
+#if defined(_SQUID_CYGWIN_)
+#include <sys/ioctl.h>
+#endif
 #ifdef HAVE_NETINET_TCP_H
 #include <netinet/tcp.h>
 #endif
index 808e3c72f8d0f00fb562f68d39518b2558245dbd..1f710d0e2ccef02c2885d418ab6064ff18d98e82 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: defines.h,v 1.93 2001/05/05 17:49:54 hno Exp $
+ * $Id: defines.h,v 1.94 2001/08/16 00:16:16 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
 #define _WIN_OS_WIN98  3
 #define _WIN_OS_WINNT  4
 #define _WIN_OS_WIN2K  5
-#define _WIN_OS_STRING_SZ 80
+#define _WIN_OS_WINXP  6
 #endif
index d71919f12003a6df0e3b6ac070b913be592903d0..4421e2ab5ff7f8e8c668671e193041ae12de38c8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: disk.cc,v 1.156 2001/07/28 22:43:24 hno Exp $
+ * $Id: disk.cc,v 1.157 2001/08/16 00:16:16 hno Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
@@ -295,7 +295,7 @@ file_write(int fd,
     off_t file_offset,
     void *ptr_to_buf,
     int len,
-    DWCB *handle,
+    DWCB * handle,
     void *handle_data,
     FREE * free_func)
 {
index f577dd5d24cea3f4c59b3a4df73c9dc907382533..f04e461a4f712184f0f69f8be91dcbbca8070001 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dns_internal.cc,v 1.39 2001/05/05 17:49:54 hno Exp $
+ * $Id: dns_internal.cc,v 1.40 2001/08/16 00:16:16 hno Exp $
  *
  * DEBUG: section 78    DNS lookups; interacts with lib/rfc1035.c
  * AUTHOR: Duane Wessels
@@ -159,7 +159,7 @@ idnsParseResolvConf(void)
        debug(78, 1) ("%s: %s\n", _PATH_RESOLV_CONF, xstrerror());
        return;
     }
-#if defined(_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
     setmode(fileno(fp), O_TEXT);
 #endif
     while (fgets(buf, 512, fp)) {
@@ -227,6 +227,7 @@ idnsParseWIN32Registry(void)
        }
        break;
     case _WIN_OS_WIN2K:
+    case _WIN_OS_WINXP:
        /* get nameservers from the Windows 2000 registry */
        /* search all interfaces for DNS server addresses */
        if (RegOpenKey(HKEY_LOCAL_MACHINE,
index 1e4f0513f00d20e09043451182c89d7463b1cf68..b3676ea98c9cd0647a4e77dcae4634f68245694a 100644 (file)
@@ -11,7 +11,7 @@
  * supports are read/write, and since COSS works on a single file
  * per storedir it should work just fine.
  *
- * $Id: async_io.cc,v 1.5 2001/08/12 22:23:22 adrian Exp $
+ * $Id: async_io.cc,v 1.6 2001/08/16 00:16:20 hno Exp $
  */
 
 #include "squid.h"
  * Return the index, or -1 if we can't find one.
  */
 static int
-a_file_findslot(async_queue_t *q)
+a_file_findslot(async_queue_t * q)
 {
-       int i;
-
-       /* Later we should use something a little more .. efficient :) */
-       for (i = 0; i < MAX_ASYNCOP; i++) {
-               if (q->aq_queue[i].aq_e_state == AQ_ENTRY_FREE)
-                       /* Found! */
-                       return i;
-       }
-       /* found nothing */
-       return -1;
+    int i;
+
+    /* Later we should use something a little more .. efficient :) */
+    for (i = 0; i < MAX_ASYNCOP; i++) {
+       if (q->aq_queue[i].aq_e_state == AQ_ENTRY_FREE)
+           /* Found! */
+           return i;
+    }
+    /* found nothing */
+    return -1;
 }
 
 
@@ -54,98 +54,96 @@ a_file_findslot(async_queue_t *q)
 /* Exported routines */
 
 void
-a_file_read(async_queue_t *q, int fd, void *buf, int req_len, off_t offset,
-  DRCB *callback, void *data)
+a_file_read(async_queue_t * q, int fd, void *buf, int req_len, off_t offset,
+    DRCB * callback, void *data)
 {
-       int slot;
-       async_queue_entry_t *qe;
+    int slot;
+    async_queue_entry_t *qe;
 
-       assert(q->aq_state == AQ_STATE_SETUP);
+    assert(q->aq_state == AQ_STATE_SETUP);
 
 #if 0
-       file_read(fd, buf, req_len, offset, callback, data);
+    file_read(fd, buf, req_len, offset, callback, data);
 #endif
-       /* Find a free slot */
-       slot = a_file_findslot(q);
-       if (slot < 0) {
-               /* No free slot? Callback error, and return */
-               fatal("Aiee! out of aiocb slots!\n");
-       }
-
-       /* Mark slot as ours */
-       qe = &q->aq_queue[slot];
-       qe->aq_e_state = AQ_ENTRY_USED;
-       qe->aq_e_callback.read = callback;
-       qe->aq_e_callback_data = data;
-       qe->aq_e_type = AQ_ENTRY_READ;
-       qe->aq_e_free = NULL;
-       qe->aq_e_buf = buf;
-       qe->aq_e_fd = fd;
-
-       qe->aq_e_aiocb.aio_fildes = fd;
-       qe->aq_e_aiocb.aio_nbytes = req_len;
-       qe->aq_e_aiocb.aio_offset = offset;
-       qe->aq_e_aiocb.aio_buf = buf;
-
-       /* Account */
-       q->aq_numpending++;
-
-       /* Lock */
-       cbdataLock(data);
-
-       /* Initiate aio */
-       if (aio_read(&qe->aq_e_aiocb) < 0) {
-               debug(1, 1)("Aiee! aio_read() returned error (%d)!\n", errno);
-               assert(1==0);
-       }
+    /* Find a free slot */
+    slot = a_file_findslot(q);
+    if (slot < 0) {
+       /* No free slot? Callback error, and return */
+       fatal("Aiee! out of aiocb slots!\n");
+    }
+    /* Mark slot as ours */
+    qe = &q->aq_queue[slot];
+    qe->aq_e_state = AQ_ENTRY_USED;
+    qe->aq_e_callback.read = callback;
+    qe->aq_e_callback_data = data;
+    qe->aq_e_type = AQ_ENTRY_READ;
+    qe->aq_e_free = NULL;
+    qe->aq_e_buf = buf;
+    qe->aq_e_fd = fd;
+
+    qe->aq_e_aiocb.aio_fildes = fd;
+    qe->aq_e_aiocb.aio_nbytes = req_len;
+    qe->aq_e_aiocb.aio_offset = offset;
+    qe->aq_e_aiocb.aio_buf = buf;
+
+    /* Account */
+    q->aq_numpending++;
+
+    /* Lock */
+    cbdataLock(data);
+
+    /* Initiate aio */
+    if (aio_read(&qe->aq_e_aiocb) < 0) {
+       debug(1, 1) ("Aiee! aio_read() returned error (%d)!\n", errno);
+       assert(1 == 0);
+    }
 }
 
 
 void
-a_file_write(async_queue_t *q, int fd, off_t offset, void *buf, int len,
-  DWCB *callback, void *data, FREE *freefunc)
+a_file_write(async_queue_t * q, int fd, off_t offset, void *buf, int len,
+    DWCB * callback, void *data, FREE * freefunc)
 {
-       int slot;
-       async_queue_entry_t *qe;
+    int slot;
+    async_queue_entry_t *qe;
 
-       assert(q->aq_state == AQ_STATE_SETUP);
+    assert(q->aq_state == AQ_STATE_SETUP);
 
 #if 0
-       file_write(fd, offset, buf, len, callback, data, freefunc);
+    file_write(fd, offset, buf, len, callback, data, freefunc);
 #endif
-       /* Find a free slot */
-       slot = a_file_findslot(q);
-       if (slot < 0) {
-               /* No free slot? Callback error, and return */
-               fatal("Aiee! out of aiocb slots!\n");
-       }
-
-       /* Mark slot as ours */
-       qe = &q->aq_queue[slot];
-       qe->aq_e_state = AQ_ENTRY_USED;
-       qe->aq_e_callback.write = callback;
-       qe->aq_e_callback_data = data;
-       qe->aq_e_type = AQ_ENTRY_WRITE;
-       qe->aq_e_free = freefunc;
-       qe->aq_e_buf = buf;
-       qe->aq_e_fd = fd;
-
-       qe->aq_e_aiocb.aio_fildes = fd;
-       qe->aq_e_aiocb.aio_nbytes = len;
-       qe->aq_e_aiocb.aio_offset = offset;
-       qe->aq_e_aiocb.aio_buf = buf;
-
-       /* Account */
-       q->aq_numpending++;
-
-       /* Lock */
-       cbdataLock(data);
-
-       /* Initiate aio */
-       if (aio_write(&qe->aq_e_aiocb) < 0) {
-               debug(1, 1)("Aiee! aio_read() returned error (%d)!\n", errno);
-               assert(1==0);
-       }
+    /* Find a free slot */
+    slot = a_file_findslot(q);
+    if (slot < 0) {
+       /* No free slot? Callback error, and return */
+       fatal("Aiee! out of aiocb slots!\n");
+    }
+    /* Mark slot as ours */
+    qe = &q->aq_queue[slot];
+    qe->aq_e_state = AQ_ENTRY_USED;
+    qe->aq_e_callback.write = callback;
+    qe->aq_e_callback_data = data;
+    qe->aq_e_type = AQ_ENTRY_WRITE;
+    qe->aq_e_free = freefunc;
+    qe->aq_e_buf = buf;
+    qe->aq_e_fd = fd;
+
+    qe->aq_e_aiocb.aio_fildes = fd;
+    qe->aq_e_aiocb.aio_nbytes = len;
+    qe->aq_e_aiocb.aio_offset = offset;
+    qe->aq_e_aiocb.aio_buf = buf;
+
+    /* Account */
+    q->aq_numpending++;
+
+    /* Lock */
+    cbdataLock(data);
+
+    /* Initiate aio */
+    if (aio_write(&qe->aq_e_aiocb) < 0) {
+       debug(1, 1) ("Aiee! aio_read() returned error (%d)!\n", errno);
+       assert(1 == 0);
+    }
 }
 
 
@@ -158,104 +156,102 @@ a_file_write(async_queue_t *q, int fd, off_t offset, void *buf, int len,
  * I'll make it much more optimal later.
  */
 int
-a_file_callback(async_queue_t *q)
+a_file_callback(async_queue_t * q)
 {
-       int i;
-       int completed = 0;
-       int retval, reterr;
-       DRCB *rc;
-       DWCB *wc;
-       FREE *freefunc;
-       void *callback_data;
-       void *buf;
-       int fd;
-       async_queue_entry_t *aqe;
-       async_queue_entry_type_t type;
-
-       assert(q->aq_state == AQ_STATE_SETUP);
-
-       /* Loop through all slots */
-       for (i = 0; i < MAX_ASYNCOP; i++) {
-               if (q->aq_queue[i].aq_e_state == AQ_ENTRY_USED) {
-                       aqe = &q->aq_queue[i];
-                       /* Active, get status */
-                       reterr = aio_error(&aqe->aq_e_aiocb);
-                       if (reterr < 0) {
-                               fatal("aio_error returned an error!\n");
-                       }
-                       if (reterr != EINPROGRESS) {
-                               /* Get the return code */
-                               retval = aio_return(&aqe->aq_e_aiocb);
-
-                               /* Get the callback parameters */
-                               callback_data = aqe->aq_e_callback_data;
-                               freefunc = aqe->aq_e_free;
-                               rc = aqe->aq_e_callback.read;
-                               wc = aqe->aq_e_callback.write;
-                               buf = aqe->aq_e_buf;
-                               fd = aqe->aq_e_fd;
-                               type = aqe->aq_e_type;
-
-                               /* Free slot */
-                               bzero(aqe, sizeof(async_queue_entry_t));
-                               aqe->aq_e_state = AQ_ENTRY_FREE;
-                               q->aq_numpending--;
-
-                               /* Callback */
-                               if (cbdataValid(callback_data)) {
-                                       if (type == AQ_ENTRY_READ)
-                                               rc(fd, buf, retval, reterr, callback_data);
-                                       if (type == AQ_ENTRY_WRITE)
-                                               wc(fd, reterr, retval, callback_data);
-                               }
-                               cbdataUnlock(callback_data);
-                               if (type == AQ_ENTRY_WRITE && freefunc)
-                                       freefunc(buf);
-                       }
+    int i;
+    int completed = 0;
+    int retval, reterr;
+    DRCB *rc;
+    DWCB *wc;
+    FREE *freefunc;
+    void *callback_data;
+    void *buf;
+    int fd;
+    async_queue_entry_t *aqe;
+    async_queue_entry_type_t type;
+
+    assert(q->aq_state == AQ_STATE_SETUP);
+
+    /* Loop through all slots */
+    for (i = 0; i < MAX_ASYNCOP; i++) {
+       if (q->aq_queue[i].aq_e_state == AQ_ENTRY_USED) {
+           aqe = &q->aq_queue[i];
+           /* Active, get status */
+           reterr = aio_error(&aqe->aq_e_aiocb);
+           if (reterr < 0) {
+               fatal("aio_error returned an error!\n");
+           }
+           if (reterr != EINPROGRESS) {
+               /* Get the return code */
+               retval = aio_return(&aqe->aq_e_aiocb);
+
+               /* Get the callback parameters */
+               callback_data = aqe->aq_e_callback_data;
+               freefunc = aqe->aq_e_free;
+               rc = aqe->aq_e_callback.read;
+               wc = aqe->aq_e_callback.write;
+               buf = aqe->aq_e_buf;
+               fd = aqe->aq_e_fd;
+               type = aqe->aq_e_type;
+
+               /* Free slot */
+               bzero(aqe, sizeof(async_queue_entry_t));
+               aqe->aq_e_state = AQ_ENTRY_FREE;
+               q->aq_numpending--;
+
+               /* Callback */
+               if (cbdataValid(callback_data)) {
+                   if (type == AQ_ENTRY_READ)
+                       rc(fd, buf, retval, reterr, callback_data);
+                   if (type == AQ_ENTRY_WRITE)
+                       wc(fd, reterr, retval, callback_data);
                }
-
+               cbdataUnlock(callback_data);
+               if (type == AQ_ENTRY_WRITE && freefunc)
+                   freefunc(buf);
+           }
        }
-       return completed;
+    }
+    return completed;
 }
 
 
 void
-a_file_setupqueue(async_queue_t *q)
+a_file_setupqueue(async_queue_t * q)
 {
-       int i;
+    int i;
 
-       /* Make sure the queue isn't setup */
-       assert(q->aq_state == AQ_STATE_NONE);
+    /* Make sure the queue isn't setup */
+    assert(q->aq_state == AQ_STATE_NONE);
 
-       /* Loop through, blanking the queue entries */
+    /* Loop through, blanking the queue entries */
 
-       /* Done */
-       q->aq_state = AQ_STATE_SETUP;
+    /* Done */
+    q->aq_state = AQ_STATE_SETUP;
 
 }
 
 
 void
-a_file_syncqueue(async_queue_t *q)
+a_file_syncqueue(async_queue_t * q)
 {
-       assert(q->aq_state == AQ_STATE_SETUP);
-
-       /*
-        * Keep calling callback to complete ops until the queue is empty
-        * We can't quit when callback returns 0 - some calls may not
-        * return any completed pending events, but they're still pending!
-        */
-       while (q->aq_numpending)
-               a_file_callback(q);
+    assert(q->aq_state == AQ_STATE_SETUP);
+
+    /*
+     * Keep calling callback to complete ops until the queue is empty
+     * We can't quit when callback returns 0 - some calls may not
+     * return any completed pending events, but they're still pending!
+     */
+    while (q->aq_numpending)
+       a_file_callback(q);
 }
 
 
 void
-a_file_closequeue(async_queue_t *q)
+a_file_closequeue(async_queue_t * q)
 {
-       assert(q->aq_state == AQ_STATE_SETUP);
+    assert(q->aq_state == AQ_STATE_SETUP);
 
-       a_file_syncqueue(q);
-       q->aq_state = AQ_STATE_NONE;
+    a_file_syncqueue(q);
+    q->aq_state = AQ_STATE_NONE;
 }
-
index 71f8d4a0e953f25f67e193d8e3c7815ea7142c46..6ad7b2e5ca57e4b714aa3fdb2dc0c1ce3b48ecad 100644 (file)
@@ -4,19 +4,19 @@
 #define MAX_ASYNCOP            128
 
 typedef enum {
-       AQ_STATE_NONE,          /* Not active/uninitialised */
-       AQ_STATE_SETUP          /* Initialised */
+    AQ_STATE_NONE,             /* Not active/uninitialised */
+    AQ_STATE_SETUP             /* Initialised */
 } async_queue_state_t;
 
 typedef enum {
-       AQ_ENTRY_FREE,
-       AQ_ENTRY_USED
+    AQ_ENTRY_FREE,
+    AQ_ENTRY_USED
 } async_queue_entry_state_t;
 
 typedef enum {
-       AQ_ENTRY_NONE,
-       AQ_ENTRY_READ,
-       AQ_ENTRY_WRITE
+    AQ_ENTRY_NONE,
+    AQ_ENTRY_READ,
+    AQ_ENTRY_WRITE
 } async_queue_entry_type_t;
 
 
@@ -25,35 +25,35 @@ typedef struct _async_queue async_queue_t;
 
 /* An async queue entry */
 struct _async_queue_entry {
-       async_queue_entry_state_t aq_e_state;
-       async_queue_entry_type_t aq_e_type;
-       struct aiocb aq_e_aiocb;
-       union {
-               DRCB *read;
-               DWCB *write;
-       } aq_e_callback;
-       void *aq_e_callback_data;
-       FREE *aq_e_free;
-       int aq_e_fd;
-       void *aq_e_buf;
+    async_queue_entry_state_t aq_e_state;
+    async_queue_entry_type_t aq_e_type;
+    struct aiocb aq_e_aiocb;
+    union {
+       DRCB *read;
+       DWCB *write;
+    } aq_e_callback;
+    void *aq_e_callback_data;
+    FREE *aq_e_free;
+    int aq_e_fd;
+    void *aq_e_buf;
 };
 
 /* An async queue */
 struct _async_queue {
-       async_queue_state_t aq_state;
-       async_queue_entry_t aq_queue[MAX_ASYNCOP]; /* queued ops */
-       int aq_numpending;                      /* Num of pending ops */
+    async_queue_state_t aq_state;
+    async_queue_entry_t aq_queue[MAX_ASYNCOP]; /* queued ops */
+    int aq_numpending;         /* Num of pending ops */
 };
 
 
 /* Functions */
-extern void a_file_read(async_queue_t *q, int fd, void *buf, int req_len,
-  off_t offset, DRCB *callback, void *data);
-extern void a_file_write(async_queue_t *q, int fd, off_t offset, void *buf,
-  int len, DWCB *callback, void *data, FREE *freefunc);
-extern int a_file_callback(async_queue_t *q);
-extern void a_file_setupqueue(async_queue_t *q);
-extern void a_file_syncqueue(async_queue_t *q);
-extern void a_file_closequeue(async_queue_t *q);
+extern void a_file_read(async_queue_t * q, int fd, void *buf, int req_len,
+    off_t offset, DRCB * callback, void *data);
+extern void a_file_write(async_queue_t * q, int fd, off_t offset, void *buf,
+    int len, DWCB * callback, void *data, FREE * freefunc);
+extern int a_file_callback(async_queue_t * q);
+extern void a_file_setupqueue(async_queue_t * q);
+extern void a_file_syncqueue(async_queue_t * q);
+extern void a_file_closequeue(async_queue_t * q);
 
 #endif
index 2647e090b9ac571f9d556615f3dcb687ed2d9549..7a5f390c9b8f5543bebae0bd79db178d94c66bb0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_coss.cc,v 1.28 2001/08/12 22:18:35 adrian Exp $
+ * $Id: store_dir_coss.cc,v 1.29 2001/08/16 00:16:20 hno Exp $
  *
  * DEBUG: section 81    Store COSS Directory Routines
  * AUTHOR: Eric Stern
@@ -160,8 +160,8 @@ storeCossDirInit(SwapDir * sd)
     storeCossDirRebuild(sd);
     cs->fd = file_open(sd->path, O_RDWR | O_CREAT);
     if (cs->fd < 0) {
-        debug(81, 1) ("%s: %s\n", sd->path, xstrerror());
-        fatal("storeCossDirInit: Failed to open a COSS directory.");
+       debug(81, 1) ("%s: %s\n", sd->path, xstrerror());
+       fatal("storeCossDirInit: Failed to open a COSS directory.");
     }
     n_coss_dirs++;
     (void) storeDirGetBlkSize(sd->path, &sd->fs.blksize);
@@ -657,7 +657,7 @@ storeCossDirShutdown(SwapDir * SD)
 {
     CossInfo *cs = (CossInfo *) SD->fsdata;
 
-    storeCossSync(SD); /* This'll call a_file_syncqueue() */
+    storeCossSync(SD);         /* This'll call a_file_syncqueue() */
     a_file_closequeue(&cs->aq);
     file_close(cs->fd);
     cs->fd = -1;
@@ -698,7 +698,7 @@ storeCossDirCheckObj(SwapDir * SD, const StoreEntry * e)
  * storeCossDirCallback - do the IO completions
  */
 static int
-storeCossDirCallback(SwapDir *SD)
+storeCossDirCallback(SwapDir * SD)
 {
     CossInfo *cs = (CossInfo *) SD->fsdata;
 
index d1a7b24d398b5e0f65f1622a99046360d5ab20f9..74124c3ffd2db91c72995bc59d58fcca69f5eaef 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: globals.h,v 1.104 2001/05/05 17:49:55 hno Exp $
+ * $Id: globals.h,v 1.105 2001/08/16 00:16:16 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -156,5 +156,5 @@ extern hash_table *proxy_auth_username_cache;       /* NULL */
 extern int incoming_sockets_accepted;
 #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
 extern unsigned int WIN32_OS_version;  /* 0 */
-extern char WIN32_OS_string[_WIN_OS_STRING_SZ];
+extern char *WIN32_OS_string;
 #endif
index 5c3ec5b109231e057c148ebe907b54382a034204..dbbe9b40157d46d927d8f706cfad20464d270c55 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.339 2001/05/20 00:09:25 hno Exp $
+ * $Id: main.cc,v 1.340 2001/08/16 00:16:16 hno Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -998,9 +998,5 @@ SquidShutdown(void *unused)
        version_string);
     if (debug_log)
        fclose(debug_log);
-#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
-    WIN32_Exit(0);
-#else
     exit(0);
-#endif
 }
index 07521d7549b9054576abba5cd12d05b4e7046b58..f130b92365dd16f90be55c38aa9a019aa6da7f5e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.409 2001/08/03 15:13:04 adrian Exp $
+ * $Id: protos.h,v 1.410 2001/08/16 00:16:17 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -1313,6 +1313,6 @@ int varyEvaluateMatch(StoreEntry * entry, request_t * req);
 /* CygWin & Windows NT Port */
 /* win32.c */
 #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
-extern int WIN32_Subsystem_Init();
-extern void WIN32_Exit(int);
+extern int WIN32_Subsystem_Init(void);
+extern void WIN32_Exit(void);
 #endif
index 7fd4d82fbd49bea4f319cfb837067ee385fa3cd9..93eb4f6c1728a83ed132345100410cdc25e0e081 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_repl_lru.cc,v 1.9 2001/07/04 00:12:06 hno Exp $
+ * $Id: store_repl_lru.cc,v 1.10 2001/08/16 00:16:22 hno Exp $
  *
  * DEBUG: section ?     LRU Removal policy
  * AUTHOR: Henrik Nordstrom
@@ -246,13 +246,13 @@ static void
 lru_stats(RemovalPolicy * policy, StoreEntry * sentry)
 {
     LruPolicyData *lru = policy->_data;
-    LruNode *lru_node = (LruNode *)lru->list.head;
+    LruNode *lru_node = (LruNode *) lru->list.head;
 
-again:
+  again:
     if (lru_node) {
-       StoreEntry * entry = (StoreEntry *) lru_node->node.data;
+       StoreEntry *entry = (StoreEntry *) lru_node->node.data;
        if (storeEntryLocked(entry)) {
-           lru_node = (LruNode *)lru_node->node.next;
+           lru_node = (LruNode *) lru_node->node.next;
            goto again;
        }
        storeAppendPrintf(sentry, "LRU reference age: %.2f days\n", (double) (squid_curtime - entry->lastref) / (double) (24 * 60 * 60));
index 067dd6aa7ec50ec548dc3ca3d63c73fa5e48ee93..edb099c2b550ea4b97d5ba0ccb9c3581fd166a68 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.347 2001/07/17 10:35:46 hno Exp $
+ * $Id: stat.cc,v 1.348 2001/08/16 00:16:18 hno Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -986,7 +986,7 @@ statCountersInitSpecial(StatCounters * C)
     statHistEnumInit(&C->comm_icp_incoming, INCOMING_ICP_MAX);
     statHistEnumInit(&C->comm_dns_incoming, INCOMING_DNS_MAX);
     statHistEnumInit(&C->comm_http_incoming, INCOMING_HTTP_MAX);
-    statHistIntInit(&C->select_fds_hist, 256); /* was SQUID_MAXFD, but it is way too much. It is OK to crop this statistics */
+    statHistIntInit(&C->select_fds_hist, 256); /* was SQUID_MAXFD, but it is way too much. It is OK to crop this statistics */
 }
 
 /* add special cases here as they arrive */
index b37fd61cd762c351d0d6519bfa62d1c586396848..e645347812c4c440daee6b0af41d7025a65c6c4b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir.cc,v 1.133 2001/08/11 19:09:21 adrian Exp $
+ * $Id: store_dir.cc,v 1.134 2001/08/16 00:16:18 hno Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -118,8 +118,8 @@ storeDirValidSwapDirSize(int swapdir, ssize_t objsize)
      * can't store it
      */
     if ((objsize == -1) &&
-        (Config.cacheSwap.swapDirs[swapdir].max_objsize != -1))
-        return 0;
+       (Config.cacheSwap.swapDirs[swapdir].max_objsize != -1))
+       return 0;
 
     /*
      * Else, make sure that the max object size is larger than objsize
@@ -225,7 +225,7 @@ storeDirSelectSwapDirLeastLoad(const StoreEntry * e)
        dirn = i;
     }
     if (dirn >= 0)
-        Config.cacheSwap.swapDirs[dirn].flags.selected = 1;
+       Config.cacheSwap.swapDirs[dirn].flags.selected = 1;
     return dirn;
 }
 
index 91eb9d6834608f6afe639d3d6cffa77cbcc7fbbb..3d009a3d770dc244bf2be34e29f1929f13549556 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.208 2001/08/11 18:27:20 adrian Exp $
+ * $Id: tools.cc,v 1.209 2001/08/16 00:16:19 hno Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -968,6 +968,9 @@ parseEtcHosts(void)
     char *lt = buf;
     char *addr = buf;
     char *host = NULL;
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
+    char *systemroot = NULL;
+#endif
     if (NULL == Config.etcHostsPath)
        return;
     if (0 == strcmp(Config.etcHostsPath, "none"))
@@ -978,7 +981,7 @@ parseEtcHosts(void)
            Config.etcHostsPath, xstrerror());
        return;
     }
-#if defined(_SQUID_CYGWIN_)
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
     setmode(fileno(fp), O_TEXT);
 #endif
     while (fgets(buf, 1024, fp)) {     /* for each line */
index b173141e6adc65dcf39abf29c5a92bbdb5d29b9e..1d3e8f277972ccafbf4064d8e7d51a98d98228b7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: win32.cc,v 1.1 2001/05/06 14:25:21 hno Exp $
+ * $Id: win32.cc,v 1.2 2001/08/16 00:16:19 hno Exp $
  *
  * * * * * * * * Legal stuff * * * * * * *
  *
@@ -28,7 +28,6 @@
 #include <windows.h>
 
 static unsigned int GetOSVersion();
-void WIN32_svcstatusupdate(DWORD);
 
 /* ====================================================================== */
 /* LOCAL FUNCTIONS */
@@ -39,37 +38,40 @@ GetOSVersion()
 {
     OSVERSIONINFO osvi;
 
+    safe_free(WIN32_OS_string);
     memset(&osvi, '\0', sizeof(OSVERSIONINFO));
     osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
     GetVersionEx((OSVERSIONINFO *) & osvi);
     switch (osvi.dwPlatformId) {
     case VER_PLATFORM_WIN32_NT:
        if (osvi.dwMajorVersion <= 4) {
-           strcpy(WIN32_OS_string, "Windows NT");
+           WIN32_OS_string = xstrdup("Windows NT");
            return _WIN_OS_WINNT;
        }
-       if (osvi.dwMajorVersion == 5) {
-           strcpy(WIN32_OS_string, "Windows 2000");
-           return _WIN_OS_WIN2K;
+       if ((osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion == 1)) {
+           WIN32_OS_string = xstrdup("Windows XP");
+           return _WIN_OS_WINXP;
        }
+       WIN32_OS_string = xstrdup("Windows 2000");
+       return _WIN_OS_WIN2K;
        break;
     case VER_PLATFORM_WIN32_WINDOWS:
        if ((osvi.dwMajorVersion > 4) ||
            ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0))) {
-           strcpy(WIN32_OS_string, "Windows 98");
+           WIN32_OS_string = xstrdup("Windows 98");
            return _WIN_OS_WIN98;
        }
-       strcpy(WIN32_OS_string, "Windows 95");
+       WIN32_OS_string = xstrdup("Windows 95");
        return _WIN_OS_WIN95;
        break;
     case VER_PLATFORM_WIN32s:
-       strcpy(WIN32_OS_string, "Windows 3.1 with WIN32S");
+       WIN32_OS_string = xstrdup("Windows 3.1 with WIN32S");
        return _WIN_OS_WIN32S;
        break;
     default:
        return _WIN_OS_UNKNOWN;
     }
-    strcpy(WIN32_OS_string, "Unknown");
+    WIN32_OS_string = xstrdup("Unknown");
     return _WIN_OS_UNKNOWN;
 }
 
@@ -77,16 +79,20 @@ GetOSVersion()
 /* PUBLIC FUNCTIONS */
 /* ====================================================================== */
 
-VOID
-WIN32_Exit(int ExitStatus)
+void
+WIN32_Exit()
 {
-    exit(0);
+    _exit(0);
 }
 
 int
 WIN32_Subsystem_Init()
 {
     WIN32_OS_version = GetOSVersion();
+    if ((WIN32_OS_version == _WIN_OS_UNKNOWN) || (WIN32_OS_version == _WIN_OS_WIN32S))
+       return 1;
+    if (atexit(WIN32_Exit) != 0)
+       return 1;
     return 0;
 }
 #endif