* 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
* 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
/* 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;
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++;
}
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);
}
}
}
*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",
char filter[256];
LDAPMessage *res = NULL;
LDAPMessage *entry;
- char *searchattr[] = {NULL};
+ char *searchattr[] =
+ {NULL};
char *userdn;
int rc;
if (ldap_simple_bind_s(ld, dn, password) != LDAP_SUCCESS)
return 1;
-
+
return 0;
}
#define debug(X...) /* */
#endif /* DEBUG */
#else /* __GNUC__ */
-static void
+static void
debug(char *format,...)
{
}
/*
- * $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
* 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;
/* 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);
}
}
/*
- * $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
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);
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;
}
}
/*
- * $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
#include "squid.h"
+#if defined(_SQUID_CYGWIN_)
+#include <sys/ioctl.h>
+#endif
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
#endif
/*
- * $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
/*
- * $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
off_t file_offset,
void *ptr_to_buf,
int len,
- DWCB *handle,
+ DWCB * handle,
void *handle_data,
FREE * free_func)
{
/*
- * $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
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)) {
}
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,
* 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;
}
/* 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);
+ }
}
* 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;
}
-
#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;
/* 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
/*
- * $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
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);
{
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;
* storeCossDirCallback - do the IO completions
*/
static int
-storeCossDirCallback(SwapDir *SD)
+storeCossDirCallback(SwapDir * SD)
{
CossInfo *cs = (CossInfo *) SD->fsdata;
/*
- * $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/
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
/*
- * $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
version_string);
if (debug_log)
fclose(debug_log);
-#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
- WIN32_Exit(0);
-#else
exit(0);
-#endif
}
/*
- * $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/
/* 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
/*
- * $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
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));
/*
- * $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
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 */
/*
- * $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
* 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
dirn = i;
}
if (dirn >= 0)
- Config.cacheSwap.swapDirs[dirn].flags.selected = 1;
+ Config.cacheSwap.swapDirs[dirn].flags.selected = 1;
return dirn;
}
/*
- * $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
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"))
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 */
/*
- * $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 * * * * * * *
*
#include <windows.h>
static unsigned int GetOSVersion();
-void WIN32_svcstatusupdate(DWORD);
/* ====================================================================== */
/* LOCAL FUNCTIONS */
{
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;
}
/* 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