--------------------- PatchSet 5800 Date: 2003/06/27 01:15:18 Author: hno Branch: icap-2_5 Tag: (none) Log: Indented according to Squid-2 coding style Members: src/cache_cf.c:1.38.6.11.2.3->1.38.6.11.2.4 src/cf_gen_defines:1.5.48.1->1.5.48.2 src/client_side.c:1.47.2.28.2.5->1.47.2.28.2.6 src/enums.h:1.29.2.8.2.1->1.29.2.8.2.2 src/forward.c:1.13.6.3.2.1->1.13.6.3.2.2 src/http.c:1.17.6.3.6.4->1.17.6.3.6.5 src/icap.c:1.1.16.6->1.1.16.7 src/icap_opt.c:1.1.2.2->1.1.2.3 src/mem.c:1.13.28.1->1.13.28.2 src/protos.h:1.41.6.13.2.3->1.41.6.13.2.4 src/squid.h:1.13.6.6.2.1->1.13.6.6.2.2 src/structs.h:1.48.2.9.2.4->1.48.2.9.2.5 src/typedefs.h:1.25.6.1.6.3->1.25.6.1.6.4 Index: squid/src/cache_cf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cache_cf.c,v retrieving revision 1.38.6.11.2.3 retrieving revision 1.38.6.11.2.4 diff -u -r1.38.6.11.2.3 -r1.38.6.11.2.4 --- squid/src/cache_cf.c 10 Jun 2003 12:57:41 -0000 1.38.6.11.2.3 +++ squid/src/cache_cf.c 27 Jun 2003 01:15:18 -0000 1.38.6.11.2.4 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.c,v 1.38.6.11.2.3 2003/06/10 12:57:41 hno Exp $ + * $Id: cache_cf.c,v 1.38.6.11.2.4 2003/06/27 01:15:18 hno Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -2066,15 +2066,15 @@ /*************************************************** * prototypes */ -static int icap_service_process(icap_service *s); -static void icap_service_init(icap_service *s); -static void icap_service_destroy(icap_service *s); -icap_service* icap_service_lookup(char *name); -static int icap_class_process(icap_class *c); -static void icap_class_destroy(icap_class *c); -static void icap_access_destroy(icap_access* a); +static int icap_service_process(icap_service * s); +static void icap_service_init(icap_service * s); +static void icap_service_destroy(icap_service * s); +icap_service *icap_service_lookup(char *name); +static int icap_class_process(icap_class * c); +static void icap_class_destroy(icap_class * c); +static void icap_access_destroy(icap_access * a); static void dump_wordlist(StoreEntry * entry, const char *name, wordlist * list); -static void icap_class_add(icap_class *c); +static void icap_class_add(icap_class * c); /*************************************************** * icap_service @@ -2086,7 +2086,7 @@ */ static void -parse_icap_service_type(IcapConfig * cfg) +parse_icap_service_type(IcapConfig * cfg) { icap_service *A = NULL; icap_service *B = NULL; @@ -2098,42 +2098,41 @@ parse_string(&A->type_name); parse_ushort(&A->bypass); parse_string(&A->uri); - debug(3,5) ("parse_icap_service_type (line %d): %s %s %d %s\n", config_lineno, A->name, A->type_name, A->bypass, A->name); - + debug(3, 5) ("parse_icap_service_type (line %d): %s %s %d %s\n", config_lineno, A->name, A->type_name, A->bypass, A->name); + if (icap_service_process(A)) { - /* put into linked list */ - for (B = cfg->service_head, T = &cfg->service_head; B; T = &B->next, B = B->next); - *T = A; + /* put into linked list */ + for (B = cfg->service_head, T = &cfg->service_head; B; T = &B->next, B = B->next); + *T = A; } else { - /* clean up structure */ - debug(3,0) ("parse_icap_service_type (line %d): skipping %s\n", config_lineno, A->name); - icap_service_destroy(A); - cbdataFree(A); + /* clean up structure */ + debug(3, 0) ("parse_icap_service_type (line %d): skipping %s\n", config_lineno, A->name); + icap_service_destroy(A); + cbdataFree(A); } - + } static void -dump_icap_service_type(StoreEntry *e, const char *name, IcapConfig cfg) +dump_icap_service_type(StoreEntry * e, const char *name, IcapConfig cfg) { icap_service *current_node = NULL; - + if (!cfg.service_head) { storeAppendPrintf(e, "%s 0\n", name); return; } - current_node = cfg.service_head; while (current_node) { storeAppendPrintf(e, "%s %s %s %d %s\n", name, current_node->name, current_node->type_name, current_node->bypass, current_node->uri); current_node = current_node->next; } - + } static void -free_icap_service_type(IcapConfig * cfg) +free_icap_service_type(IcapConfig * cfg) { while (cfg->service_head) { icap_service *current_node = cfg->service_head; @@ -2149,7 +2148,7 @@ * returns 1 if everything was ok */ static int -icap_service_process(icap_service *s) +icap_service_process(icap_service * s) { char *start, *end; char *tailp; @@ -2157,91 +2156,89 @@ int port_in_uri; s->type = icapServiceToType(s->type_name); if (s->type >= ICAP_SERVICE_MAX) { - debug(3,0) ("icap_service_process (line %d): wrong service type %s\n", config_lineno, s->type_name); - return 0; + debug(3, 0) ("icap_service_process (line %d): wrong service type %s\n", config_lineno, s->type_name); + return 0; } - if (s->type == ICAP_SERVICE_REQMOD_PRECACHE || s->type == ICAP_SERVICE_REQMOD_POSTCACHE) { s->method = ICAP_METHOD_REQMOD; - } else if(s->type == ICAP_SERVICE_RESPMOD_PRECACHE || s->type == ICAP_SERVICE_RESPMOD_POSTCACHE) { + } else if (s->type == ICAP_SERVICE_RESPMOD_PRECACHE || s->type == ICAP_SERVICE_RESPMOD_POSTCACHE) { s->method = ICAP_METHOD_RESPMOD; } - - debug(3,5) ("icap_service_process (line %d): type=%s\n", config_lineno, icapServiceToStr(s->type)); - if (strncmp (s->uri,"icap://", 7) != 0) { - debug(3,0) ("icap_service_process (line %d): wrong uri: %s\n", config_lineno, s->uri); - return 0; + debug(3, 5) ("icap_service_process (line %d): type=%s\n", config_lineno, icapServiceToStr(s->type)); + if (strncmp(s->uri, "icap://", 7) != 0) { + debug(3, 0) ("icap_service_process (line %d): wrong uri: %s\n", config_lineno, s->uri); + return 0; } start = s->uri + 7; - if ((end = strchr(start, ':')) != NULL ) { - /* ok */ - port_in_uri=1; - debug(3,5) ("icap_service_process (line %d): port given\n", config_lineno); - } else if ((end = strchr(start,'/')) != NULL ) { - /* ok */ - port_in_uri=0; - debug(3,5) ("icap_service_process (line %d): no port given\n", config_lineno); + if ((end = strchr(start, ':')) != NULL) { + /* ok */ + port_in_uri = 1; + debug(3, 5) ("icap_service_process (line %d): port given\n", config_lineno); + } else if ((end = strchr(start, '/')) != NULL) { + /* ok */ + port_in_uri = 0; + debug(3, 5) ("icap_service_process (line %d): no port given\n", config_lineno); } else { - debug(3,0) ("icap_service_process (line %d): wrong service uri: %s\n", config_lineno, s->uri); - return 0; + debug(3, 0) ("icap_service_process (line %d): wrong service uri: %s\n", config_lineno, s->uri); + return 0; } len = end - start; s->hostname = xstrndup(start, len + 1); s->hostname[len] = 0; start = end; - + if (port_in_uri) { - start++; /* skip ':' */ - if ((end = strchr(start, '/')) != NULL) { - s->port = strtoul(start, &tailp, 0) % 65536; - if (tailp != end) { - debug(3,0) ("icap_service_process (line %d): wrong service uri (port could not be parsed): %s\n", config_lineno, s->uri); - return 0; - } - debug(3,5) ("icap_service_process (line %d): port=%d\n", config_lineno, s->port); - start = end; - if (start[0] != '/') { - debug(3,0) ("icap_service_process (line %d): no '/' between port and resource found in %s\n", config_lineno, s->uri); - return 0; - } - } + start++; /* skip ':' */ + if ((end = strchr(start, '/')) != NULL) { + s->port = strtoul(start, &tailp, 0) % 65536; + if (tailp != end) { + debug(3, 0) ("icap_service_process (line %d): wrong service uri (port could not be parsed): %s\n", config_lineno, s->uri); + return 0; + } + debug(3, 5) ("icap_service_process (line %d): port=%d\n", config_lineno, s->port); + start = end; + if (start[0] != '/') { + debug(3, 0) ("icap_service_process (line %d): no '/' between port and resource found in %s\n", config_lineno, s->uri); + return 0; + } + } } else { - /* no explicit ICAP port; first ask by getservbyname or default to - hardwired port 1344 per ICAP specification section 4.2 */ - struct servent *serv = getservbyname("icap", "tcp"); - if (serv) { - s->port = htons(serv->s_port); - debug(3,5) ("icap_service_process (line %d): default port=%d getservbyname(icap,tcp)\n", config_lineno, s->port); - } else { - s->port = 1344; - debug(3,5) ("icap_service_process (line %d): default hardwired port=%d\n", config_lineno, s->port); - } + /* no explicit ICAP port; first ask by getservbyname or default to + * hardwired port 1344 per ICAP specification section 4.2 */ + struct servent *serv = getservbyname("icap", "tcp"); + if (serv) { + s->port = htons(serv->s_port); + debug(3, 5) ("icap_service_process (line %d): default port=%d getservbyname(icap,tcp)\n", config_lineno, s->port); + } else { + s->port = 1344; + debug(3, 5) ("icap_service_process (line %d): default hardwired port=%d\n", config_lineno, s->port); + } } - start++; /* skip '/' */ + start++; /* skip '/' */ /* the rest is resource name */ end = strchr(start, '\0'); len = end - start; if (len > 1024) { - debug(3,0) ("icap_service_process (line %d): long resource name (>1024), probably wrong\n", config_lineno); + debug(3, 0) ("icap_service_process (line %d): long resource name (>1024), probably wrong\n", config_lineno); } s->resource = xstrndup(start, len + 1); s->resource[len] = 0; /* check bypass */ - if ( (s->bypass != 0) && (s->bypass != 1)) { - debug(3,0) ("icap_service_process (line %d): invalid bypass value\n", config_lineno); - return 0; + if ((s->bypass != 0) && (s->bypass != 1)) { + debug(3, 0) ("icap_service_process (line %d): invalid bypass value\n", config_lineno); + return 0; } - return 1; + return 1; } /* * constructor - */ + */ static void -icap_service_init(icap_service *s) +icap_service_init(icap_service * s) { - s->type = ICAP_SERVICE_MAX; /* means undefined */ + s->type = ICAP_SERVICE_MAX; /* means undefined */ s->preview = Config.icapcfg.preview_size; s->opt = 0; s->istag = StringNull; @@ -2249,32 +2246,32 @@ s->transfer_ignore = StringNull; s->transfer_complete = StringNull; } - + /* * destructor * frees only strings, but don't touch the linked list */ static void -icap_service_destroy(icap_service *s) +icap_service_destroy(icap_service * s) { xfree(s->name); xfree(s->uri); xfree(s->type_name); xfree(s->hostname); xfree(s->resource); - assert(s->opt == 0); /* there should be no opt request running now */ + assert(s->opt == 0); /* there should be no opt request running now */ stringClean(&s->istag); stringClean(&s->transfer_preview); stringClean(&s->transfer_ignore); stringClean(&s->transfer_complete); } - + icap_service * -icap_service_lookup(char *name) +icap_service_lookup(char *name) { icap_service *iter; for (iter = Config.icapcfg.service_head; iter; iter = iter->next) { - if (! strcmp(name, iter->name)) { + if (!strcmp(name, iter->name)) { return iter; } } @@ -2286,7 +2283,7 @@ */ static void -icap_service_list_add(icap_service_list **isl, icap_service *service) +icap_service_list_add(icap_service_list ** isl, icap_service * service) { icap_service_list **iter; icap_service_list *new; @@ -2302,70 +2299,69 @@ } else { *isl = new; } -} +} /* * free the linked list without touching references icap_service */ static void -icap_service_list_destroy(icap_service_list* isl) +icap_service_list_destroy(icap_service_list * isl) { icap_service_list *current; icap_service_list *next; - + current = isl; while (current) { next = current->next; memFree(current, MEM_ICAP_SERVICE_LIST); current = next; } -} +} /*************************************************** * icap_class */ static void -parse_icap_class_type(IcapConfig *cfg) +parse_icap_class_type(IcapConfig * cfg) { - icap_class *s = NULL; + icap_class *s = NULL; s = memAllocate(MEM_ICAP_CLASS); parse_string(&s->name); parse_wordlist(&s->services); - + if (icap_class_process(s)) { /* if ok, put into linked list */ icap_class_add(s); } else { /* clean up structure */ - debug(3,0) ("parse_icap_class_type (line %d): skipping %s\n", config_lineno, s->name); - icap_class_destroy(s); - memFree(s, MEM_ICAP_CLASS); + debug(3, 0) ("parse_icap_class_type (line %d): skipping %s\n", config_lineno, s->name); + icap_class_destroy(s); + memFree(s, MEM_ICAP_CLASS); } } static void -dump_icap_class_type(StoreEntry *e, const char *name, IcapConfig cfg) +dump_icap_class_type(StoreEntry * e, const char *name, IcapConfig cfg) { - icap_class* current_node = NULL; + icap_class *current_node = NULL; LOCAL_ARRAY(char, nom, 64); if (!cfg.class_head) { storeAppendPrintf(e, "%s 0\n", name); return; } - current_node = cfg.class_head; while (current_node) { - snprintf(nom, 64, "%s %s", name, current_node->name); + snprintf(nom, 64, "%s %s", name, current_node->name); dump_wordlist(e, nom, current_node->services); current_node = current_node->next; } } static void -free_icap_class_type(IcapConfig *cfg) +free_icap_class_type(IcapConfig * cfg) { while (cfg->class_head) { icap_class *current_node = cfg->class_head; @@ -2378,8 +2374,8 @@ /* * process services list, return 1, if at least one service was found */ -static int -icap_class_process(icap_class *c) +static int +icap_class_process(icap_class * c) { icap_service_list *isl = NULL; wordlist *iter; @@ -2390,7 +2386,7 @@ if (service) { icap_service_list_add(&isl, service); } else { - debug(3,0) ("icap_class_process (line %d): skipping service %s in class %s\n", config_lineno, iter->key, c->name); + debug(3, 0) ("icap_class_process (line %d): skipping service %s in class %s\n", config_lineno, iter->key, c->name); } } @@ -2406,7 +2402,7 @@ * classes with hidden-flag are skipped */ static icap_class * -icap_class_lookup(char *name) +icap_class_lookup(char *name) { icap_class *iter; for (iter = Config.icapcfg.class_head; iter; iter = iter->next) { @@ -2420,15 +2416,15 @@ /* * adds an icap_class to the global IcapConfig */ -static void -icap_class_add(icap_class *c) +static void +icap_class_add(icap_class * c) { - icap_class *cp = NULL; - icap_class **t = NULL; + icap_class *cp = NULL; + icap_class **t = NULL; IcapConfig *cfg = &Config.icapcfg; if (c) { for (cp = cfg->class_head, t = &cfg->class_head; cp; t = &cp->next, cp = cp->next); - *t = c; + *t = c; } } @@ -2436,7 +2432,7 @@ * free allocated memory inside icap_class */ static void -icap_class_destroy(icap_class *c) +icap_class_destroy(icap_class * c) { xfree(c->name); wordlistDestroy(&c->services); @@ -2449,7 +2445,7 @@ /* format: icap_access {allow|deny} acl, ... */ static void -parse_icap_access_type(IcapConfig * cfg) +parse_icap_access_type(IcapConfig * cfg) { icap_access *A = NULL; icap_access *B = NULL; @@ -2460,7 +2456,7 @@ A = memAllocate(MEM_ICAP_ACCESS); parse_string(&A->service_name); - + /* * try to find a class with the given name first. if not found, search * the services. if a service is found, create a new hidden class with @@ -2468,71 +2464,69 @@ * * the special classname All is allowed only in deny rules, because * the class is not used there. - */ + */ if (!strcmp(A->service_name, "None")) { - no_class = 1; + no_class = 1; } else { - A->class = icap_class_lookup(A->service_name); - if (!A->class) { - s = icap_service_lookup(A->service_name); - if (s) { - c = memAllocate(MEM_ICAP_CLASS); - c->name = xstrdup("(hidden)"); - c->hidden = 1; - wordlistAdd(&c->services, A->service_name); - c->isl = memAllocate(MEM_ICAP_SERVICE_LIST); - c->isl->service = s; - icap_class_add(c); - A->class = c; - } else { - debug(3,0) ("parse_icap_access_type (line %d): servicename %s not found. skipping.\n", config_lineno, A->service_name); - memFree(A, MEM_ICAP_ACCESS); - return; - } - } + A->class = icap_class_lookup(A->service_name); + if (!A->class) { + s = icap_service_lookup(A->service_name); + if (s) { + c = memAllocate(MEM_ICAP_CLASS); + c->name = xstrdup("(hidden)"); + c->hidden = 1; + wordlistAdd(&c->services, A->service_name); + c->isl = memAllocate(MEM_ICAP_SERVICE_LIST); + c->isl->service = s; + icap_class_add(c); + A->class = c; + } else { + debug(3, 0) ("parse_icap_access_type (line %d): servicename %s not found. skipping.\n", config_lineno, A->service_name); + memFree(A, MEM_ICAP_ACCESS); + return; + } + } } - + aclParseAccessLine(&(A->access)); - debug(3,5) ("parse_icap_access_type (line %d): %s\n", config_lineno, A->service_name); + debug(3, 5) ("parse_icap_access_type (line %d): %s\n", config_lineno, A->service_name); /* check that All class is only used in deny rule */ if (no_class && A->access->allow) { - memFree(A, MEM_ICAP_ACCESS); - debug(3,0) ("parse_icap_access (line %d): special class 'None' only allowed in deny rule. skipping.\n", config_lineno); - return; + memFree(A, MEM_ICAP_ACCESS); + debug(3, 0) ("parse_icap_access (line %d): special class 'None' only allowed in deny rule. skipping.\n", config_lineno); + return; } - - if (A->access) { + if (A->access) { for (B = cfg->access_head, T = &cfg->access_head; B; T = &B->next, B = B->next); - *T = A; + *T = A; } else { - debug(3,0) ("parse_icap_access_type (line %d): invalid line skipped\n", config_lineno); + debug(3, 0) ("parse_icap_access_type (line %d): invalid line skipped\n", config_lineno); memFree(A, MEM_ICAP_ACCESS); } } static void -dump_icap_access_type(StoreEntry *e, const char *name, IcapConfig cfg) +dump_icap_access_type(StoreEntry * e, const char *name, IcapConfig cfg) { - icap_access* current_node = NULL; + icap_access *current_node = NULL; LOCAL_ARRAY(char, nom, 64); if (!cfg.access_head) { storeAppendPrintf(e, "%s 0\n", name); return; } - current_node = cfg.access_head; while (current_node) { - snprintf(nom, 64, "%s %s", name, current_node->service_name); + snprintf(nom, 64, "%s %s", name, current_node->service_name); dump_acl_access(e, nom, current_node->access); current_node = current_node->next; } } static void -free_icap_access_type(IcapConfig * cfg) +free_icap_access_type(IcapConfig * cfg) { while (cfg->access_head) { icap_access *current_node = cfg->access_head; @@ -2546,8 +2540,8 @@ * destructor * frees everything but the linked list */ -static void -icap_access_destroy(icap_access* a) +static void +icap_access_destroy(icap_access * a) { xfree(a->service_name); aclDestroyAccessList(&a->access); @@ -2557,27 +2551,27 @@ * for debugging purposes only */ void -dump_icap_config(IcapConfig* cfg) +dump_icap_config(IcapConfig * cfg) { - icap_service* s_iter; - icap_class* c_iter; - icap_access* a_iter; + icap_service *s_iter; + icap_class *c_iter; + icap_access *a_iter; icap_service_list *isl_iter; - acl_list* l; - debug(3,0)("IcapConfig: onoff = %d\n", cfg->onoff); - debug(3,0)("IcapConfig: service_head = %d\n", (int) cfg->service_head); - debug(3,0)("IcapConfig: class_head = %d\n", (int) cfg->class_head); - debug(3,0)("IcapConfig: access_head = %d\n", (int) cfg->access_head); - - debug(3,0) ("IcapConfig: services =\n"); + acl_list *l; + debug(3, 0) ("IcapConfig: onoff = %d\n", cfg->onoff); + debug(3, 0) ("IcapConfig: service_head = %d\n", (int) cfg->service_head); + debug(3, 0) ("IcapConfig: class_head = %d\n", (int) cfg->class_head); + debug(3, 0) ("IcapConfig: access_head = %d\n", (int) cfg->access_head); + + debug(3, 0) ("IcapConfig: services =\n"); for (s_iter = cfg->service_head; s_iter; s_iter = s_iter->next) { printf(" %s: \n", s_iter->name); printf(" bypass = %d\n", s_iter->bypass); - printf(" hostname = %s\n", s_iter->hostname); - printf(" port = %d\n", s_iter->port); - printf(" resource = %s\n", s_iter->resource); + printf(" hostname = %s\n", s_iter->hostname); + printf(" port = %d\n", s_iter->port); + printf(" resource = %s\n", s_iter->resource); } - debug(3,0) ("IcapConfig: classes =\n"); + debug(3, 0) ("IcapConfig: classes =\n"); for (c_iter = cfg->class_head; c_iter; c_iter = c_iter->next) { printf(" %s: \n", c_iter->name); printf(" services = \n"); @@ -2585,15 +2579,15 @@ printf(" %s\n", isl_iter->service->name); } } - debug(3,0)("IcapConfig: access =\n"); + debug(3, 0) ("IcapConfig: access =\n"); for (a_iter = cfg->access_head; a_iter; a_iter = a_iter->next) { - printf(" service_name = %s\n", a_iter->service_name); - printf(" access = %s", a_iter->access->allow ? "allow" : "deny"); - for (l = a_iter->access->acl_list; l != NULL; l = l->next) { - printf(" %s%s", - l->op ? null_string : "!", - l->acl->name); - } + printf(" service_name = %s\n", a_iter->service_name); + printf(" access = %s", a_iter->access->allow ? "allow" : "deny"); + for (l = a_iter->access->acl_list; l != NULL; l = l->next) { + printf(" %s%s", + l->op ? null_string : "!", + l->acl->name); + } printf("\n"); } } Index: squid/src/cf_gen_defines =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cf_gen_defines,v retrieving revision 1.5.48.1 retrieving revision 1.5.48.2 diff -u -r1.5.48.1 -r1.5.48.2 --- squid/src/cf_gen_defines 4 Apr 2003 16:54:36 -0000 1.5.48.1 +++ squid/src/cf_gen_defines 27 Jun 2003 01:15:18 -0000 1.5.48.2 @@ -1,38 +1,38 @@ -#!/usr/bin/awk -f +#!/usr/bin/awk -f BEGIN { - print "/* Generated automatically from cf.data.pre" + print "/* Generated automatically from cf.data.pre" print " * DO NOT EDIT" print "*/" print "struct { const char *name; const char *enable; int defined;} defines[] = {" - define["DELAY_POOLS"]="--enable-delay-pools" - define["HTTP_VIOLATIONS"]="--enable-http-violations" - define["SQUID_SNMP"]="--enable-snmp" - define["USE_CACHE_DIGESTS"]="--enable-cache-digests" - define["USE_DNSSERVERS"]="--disable-internal-dns" - define["!USE_DNSSERVERS"]="--enable-internal-dns" - define["USE_HTCP"]="--enable-htcp" - define["USE_ICMP"]="--enable-icmp" - define["USE_IDENT"]="--enable-ident-lookups" - define["USE_REFERER_LOG"]="--enable-referer-log" - define["USE_SSL"]="--enable-ssl" - define["USE_UNLINKD"]="--enable-unlinkd" - define["USE_USERAGENT_LOG"]="--enable-useragent-log" - define["USE_WCCP"]="--enable-wccp" - define["HS_FEAT_ICAP"]="--enable-icap-support" + define["DELAY_POOLS"] = "--enable-delay-pools" + define["HTTP_VIOLATIONS"] = "--enable-http-violations" + define["SQUID_SNMP"] = "--enable-snmp" + define["USE_CACHE_DIGESTS"] = "--enable-cache-digests" + define["USE_DNSSERVERS"] = "--disable-internal-dns" + define["!USE_DNSSERVERS"] = "--enable-internal-dns" + define["USE_HTCP"] = "--enable-htcp" + define["USE_ICMP"] = "--enable-icmp" + define["USE_IDENT"] = "--enable-ident-lookups" + define["USE_REFERER_LOG"] = "--enable-referer-log" + define["USE_SSL"] = "--enable-ssl" + define["USE_UNLINKD"] = "--enable-unlinkd" + define["USE_USERAGENT_LOG"] = "--enable-useragent-log" + define["USE_WCCP"] = "--enable-wccp" + define["HS_FEAT_ICAP"] = "--enable-icap-support" } /^IFDEF:/ { - if (define[$2] != "") - DEFINE=define[$2] - else - DEFINE="-D" $2 - print "{\"" $2 "\", \"" DEFINE "\", " - print "#if " $2 - print "1" - print "#else" - print "0" - print "#endif" - print "}," -} -END { + if (define[$2] != "") + DEFINE = define[$2] + else + DEFINE = "-D" $2 + print "{\"" $2 "\", \"" DEFINE "\", " + print "#if " $2 + print "1" + print "#else" + print "0" + print "#endif" + print "}," + } + END { print "{(void *)0L, 0}};" -} + } Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.47.2.28.2.5 retrieving revision 1.47.2.28.2.6 diff -u -r1.47.2.28.2.5 -r1.47.2.28.2.6 --- squid/src/client_side.c 27 May 2003 12:57:43 -0000 1.47.2.28.2.5 +++ squid/src/client_side.c 27 Jun 2003 01:15:18 -0000 1.47.2.28.2.6 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.47.2.28.2.5 2003/05/27 12:57:43 hno Exp $ + * $Id: client_side.c,v 1.47.2.28.2.6 2003/06/27 01:15:18 hno Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -37,7 +37,7 @@ /* I am using some of these functions in ICAP */ #ifdef HS_FEAT_ICAP -#define STATIC +#define STATIC #else #define STATIC static #endif @@ -347,11 +347,11 @@ } clientInterpretRequestHeaders(http); #if HS_FEAT_ICAP - /* only for testing, try to do aclCheck for icap */ - http->request->flags.do_icap = 0; - if (Config.icapcfg.onoff) - if (icapCheckAcl(http)) - http->request->flags.do_icap = 1; + /* only for testing, try to do aclCheck for icap */ + http->request->flags.do_icap = 0; + if (Config.icapcfg.onoff) + if (icapCheckAcl(http)) + http->request->flags.do_icap = 1; #endif #if HEADERS_LOG headersLog(0, 1, request->method, request); @@ -3383,9 +3383,9 @@ commSetSelect(fd, COMM_SELECT_READ, clientReadRequest, connState, 0); commSetDefer(fd, clientReadDefer, connState); clientdbEstablished(peer.sin_addr, 1); - /* fix this later */ - assert(N); - (*N)++; + /* fix this later */ + assert(N); + (*N)++; } } Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/enums.h,v retrieving revision 1.29.2.8.2.1 retrieving revision 1.29.2.8.2.2 diff -u -r1.29.2.8.2.1 -r1.29.2.8.2.2 --- squid/src/enums.h 4 Apr 2003 16:55:10 -0000 1.29.2.8.2.1 +++ squid/src/enums.h 27 Jun 2003 01:15:18 -0000 1.29.2.8.2.2 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.29.2.8.2.1 2003/04/04 16:55:10 hno Exp $ + * $Id: enums.h,v 1.29.2.8.2.2 2003/06/27 01:15:18 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -610,10 +610,10 @@ MEM_SWAP_LOG_DATA, MEM_CLIENT_REQ_BUF, #if HS_FEAT_ICAP - MEM_ICAP_OPT_DATA, - MEM_ICAP_SERVICE_LIST, - MEM_ICAP_CLASS, - MEM_ICAP_ACCESS, + MEM_ICAP_OPT_DATA, + MEM_ICAP_SERVICE_LIST, + MEM_ICAP_CLASS, + MEM_ICAP_ACCESS, #endif MEM_MAX } mem_type; @@ -724,11 +724,11 @@ * ICAP states: Maily required for Preview support for RESPMOD. */ typedef enum { - ICAP_EndOfInputData = 1, /* No more data to be expected on HTTP connection */ - ICAP_PreviewDone = 2, /* Handling of preview data finished or no preview at all */ - ICAP_WaitForPreviewReply = 4, /* Expect reply from ICAP server after preview */ - ICAP_WaitForReply = 8, /* Expect final reply from ICAP server */ - ICAP_GotReply = 16, + ICAP_EndOfInputData = 1, /* No more data to be expected on HTTP connection */ + ICAP_PreviewDone = 2, /* Handling of preview data finished or no preview at all */ + ICAP_WaitForPreviewReply = 4, /* Expect reply from ICAP server after preview */ + ICAP_WaitForReply = 8, /* Expect final reply from ICAP server */ + ICAP_GotReply = 16, } icapState; /* @@ -821,6 +821,7 @@ ICAP_METHOD_REQMOD, ICAP_METHOD_RESPMOD } icap_method_t; + #endif /* HS_FEAT_ICAP */ #endif /* SQUID_ENUMS_H */ Index: squid/src/forward.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/forward.c,v retrieving revision 1.13.6.3.2.1 retrieving revision 1.13.6.3.2.2 diff -u -r1.13.6.3.2.1 -r1.13.6.3.2.2 --- squid/src/forward.c 4 Apr 2003 16:55:26 -0000 1.13.6.3.2.1 +++ squid/src/forward.c 27 Jun 2003 01:15:18 -0000 1.13.6.3.2.2 @@ -1,6 +1,6 @@ /* - * $Id: forward.c,v 1.13.6.3.2.1 2003/04/04 16:55:26 hno Exp $ + * $Id: forward.c,v 1.13.6.3.2.2 2003/06/27 01:15:18 hno Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -38,7 +38,7 @@ /* I am using some of these functions in ICAP */ #ifdef HS_FEAT_ICAP -#define STATIC +#define STATIC #else #define STATIC static #endif Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.17.6.3.6.4 retrieving revision 1.17.6.3.6.5 diff -u -r1.17.6.3.6.4 -r1.17.6.3.6.5 --- squid/src/http.c 27 Jun 2003 00:56:06 -0000 1.17.6.3.6.4 +++ squid/src/http.c 27 Jun 2003 01:15:18 -0000 1.17.6.3.6.5 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.17.6.3.6.4 2003/06/27 00:56:06 hno Exp $ + * $Id: http.c,v 1.17.6.3.6.5 2003/06/27 01:15:18 hno Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -74,8 +74,8 @@ debug(11, 3) ("httpStateFree: FD %d, httpState = %p\n", fd, data); #ifdef HS_FEAT_ICAP if (httpState->icap) { - icapStateFree (httpState->icap); - httpState->icap = NULL; + icapStateFree(httpState->icap); + httpState->icap = NULL; } #endif storeUnlockObject(httpState->entry); @@ -680,12 +680,12 @@ #if defined (HS_FEAT_ICAP) && defined (ICAP_CHUNKED) /* read data on ICAP connection in chunked encoding */ if (httpState->icap && httpState->icap->icap_fd == fd) { - if (icapReadChunkedBody (fd, httpState, len, buf)) - return; + if (icapReadChunkedBody(fd, httpState, len, buf)) + return; } else #endif - if (fd == httpState->fd) - storeAppend(entry, buf, len); + if (fd == httpState->fd) + storeAppend(entry, buf, len); debug(11, 5) ("httpReadReply: after storeAppend FD %d read %d\n", fd, len); @@ -738,8 +738,8 @@ icapSendRespMod(httpState, buf, len, 0); } else #endif - /* Wait for EOF condition */ - commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); + /* Wait for EOF condition */ + commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); } } } @@ -1229,4 +1229,3 @@ version->major = major; version->minor = minor; } - Index: squid/src/icap.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap.c,v retrieving revision 1.1.16.6 retrieving revision 1.1.16.7 diff -u -r1.1.16.6 -r1.1.16.7 --- squid/src/icap.c 27 Jun 2003 01:05:34 -0000 1.1.16.6 +++ squid/src/icap.c 27 Jun 2003 01:15:18 -0000 1.1.16.7 @@ -1,5 +1,5 @@ /* - * $Id: icap.c,v 1.1.16.6 2003/06/27 01:05:34 hno Exp $ + * $Id: icap.c,v 1.1.16.7 2003/06/27 01:15:18 hno Exp $ * This file has the ICAP client code... * * Author: Geetha Manjunath, @@ -41,8 +41,8 @@ static PF icapConnectTimeout; static void icapReadResponse(int fd, HttpStateData * httpState); -static void getICAPReqModString(MemBuf * mb, int hdrLen, int bodyLen, char *service, char* client_addr); -static void getICAPRespModString(MemBuf * mb, int o1, int o2, int o3, char *service, char* client_addr); +static void getICAPReqModString(MemBuf * mb, int hdrLen, int bodyLen, char *service, char *client_addr); +static void getICAPRespModString(MemBuf * mb, int o1, int o2, int o3, char *service, char *client_addr); static int buildRespModHeader(MemBuf * mb, HttpStateData * httpState, char *buf, ssize_t len, int theEnd); static void scheduleReadReply(int fd, void *data); static IcapStateData *startICAP(const char *note); @@ -135,9 +135,10 @@ /* End of ICAP header found - Read the \r\n\r\n too */ len = headlen; else { - /* Header is bigger */ - read_sz *=2; - if (read_sz < SQUID_TCP_SO_RCVBUF) continue; + /* Header is bigger */ + read_sz *= 2; + if (read_sz < SQUID_TCP_SO_RCVBUF) + continue; } if (!isIcap) isIcap = !(!strstr(tmpbuf, "ICAP")); @@ -221,7 +222,7 @@ connState->read_request_hook = icapReqModReadReplyDone; connState->read_request_hook_data = httpState; cbdataLock(connState->read_request_hook_data); - + connState->in.buf = memAllocate(MEM_CLIENT_REQ_BUF); /* * This seems to be false. It crashes when freeing this buffer again, because @@ -232,30 +233,30 @@ comm_add_close_handler(fd, connStateFree, connState); cbdataLock(httpState); commSetTimeout(fd, Config.Timeout.request, icapConnectTimeout, - connState); + connState); clientReadRequest(fd, connState); return; } } static int -icapReqModReadReplyDone(ConnStateData *connState, clientHttpRequest *http, void *data) +icapReqModReadReplyDone(ConnStateData * connState, clientHttpRequest * http, void *data) { HttpStateData *httpState = data; request_t *new_req; request_t *old_req; - + new_req = requestLink(http->request); - /* Unlink the request from our faked connState */ - { - clientHttpRequest **H; - for (H = &connState->chr; *H != http; H = &(*H)->next); - assert(*H); - *H = (*H)->next; - connState->nrequests--; - assert(!connState->nrequests); - } + /* Unlink the request from our faked connState */ + { + clientHttpRequest **H; + for (H = &connState->chr; *H != http; H = &(*H)->next); + assert(*H); + *H = (*H)->next; + connState->nrequests--; + assert(!connState->nrequests); + } assert(connState->nrequests == 0); assert(connState->chr == NULL); @@ -284,9 +285,9 @@ proxy_req->flags = new_req->flags; proxy_req->lastmod = new_req->lastmod; httpState->request = requestLink(proxy_req); - } else { + } else { httpState->request = requestLink(new_req); - } + } /* cleanup */ requestUnlink(old_req); @@ -360,30 +361,30 @@ StoreEntry *entry = httpState->entry; char *client_addr; int cfd; - int blen = 0; + int blen = 0; void *b = NULL; int icap_fd = icap->icap_fd; icap_service *service; if (req->method == METHOD_POST) { - /* TODO: - * Data is usually missing. Sending of data has to be postponed until - * it is read. But we have to take care that some ICAP servers may not - * be able to start the ICAP response before the complete request body - * is read. In that case we do not have the request header to send to - * the HTTP server that the HTTP code needs before reading the body - * from the client. - * At least way, it could work that POSTs are sent to the ICAP server - * without body for now. - */ - ConnStateData *conn = httpState->orig_request->body_connection; - if (conn) { - blen = conn->body.bufsize; - b = conn->body.buf; - if ( ! b) - blen = 0; /* make sure this goes together */ - } + /* TODO: + * Data is usually missing. Sending of data has to be postponed until + * it is read. But we have to take care that some ICAP servers may not + * be able to start the ICAP response before the complete request body + * is read. In that case we do not have the request header to send to + * the HTTP server that the HTTP code needs before reading the body + * from the client. + * At least way, it could work that POSTs are sent to the ICAP server + * without body for now. + */ + ConnStateData *conn = httpState->orig_request->body_connection; + if (conn) { + blen = conn->body.bufsize; + b = conn->body.buf; + if (!b) + blen = 0; /* make sure this goes together */ } + } /* cfd = client fd */ if (entry->mem_obj) cfd = entry->mem_obj->fd; @@ -418,11 +419,11 @@ memBufClean(&mb_hdr); if (blen > 0) { - memBufPrintf(&mb, "%x\r\n", blen); - memBufAppend(&mb, b, blen); - memBufAppend(&mb, crlf, 2); - /* if (httpState->orig_request->content_length > 0 - * Need to check and see if we have to put content length header */ + memBufPrintf(&mb, "%x\r\n", blen); + memBufAppend(&mb, b, blen); + memBufAppend(&mb, crlf, 2); + /* if (httpState->orig_request->content_length > 0 + * Need to check and see if we have to put content length header */ } memBufAppend(&mb, crlf, 2); debug(21, 3) ("icapSendReqMod: FD %d:\n%s\n", httpState->fd, mb.buf); @@ -460,11 +461,11 @@ icap = startICAP(service->uri); if (!icap) - return -1; + return -1; icap->current_service = service; icap->reqmod = 1; - icap->http_fd = httpState->fd; + icap->http_fd = httpState->fd; httpState->icap = icap; #if 1 @@ -507,7 +508,7 @@ read_sz = EXPECTED_ICAP_HEADER_LEN; /* To fix: If the len of ICAP header is exactly read_sz - we have problems */ - /* tmp = NULL; */ + /* tmp = NULL; */ len = 0; headlen = 0; tmpicap = icap_header; @@ -515,16 +516,17 @@ while (!headlen && len >= 0) { /* len = read(fd, tmpbuf, read_sz); */ len = recv(fd, tmpbuf, read_sz, MSG_PEEK); - /* tmp = strstr(tmpbuf, "\r\n\r\n"); */ + /* tmp = strstr(tmpbuf, "\r\n\r\n"); */ if (len > 0) { headlen = headersEnd(tmpbuf, len); if (headlen) /* End of ICAP header found - Read the \r\n\r\n too */ len = headlen; else { - /* Header is bigger */ - read_sz *=2; - if (read_sz < SQUID_TCP_SO_RCVBUF) continue; + /* Header is bigger */ + read_sz *= 2; + if (read_sz < SQUID_TCP_SO_RCVBUF) + continue; } if (!isIcap) isIcap = !(!strstr(tmpbuf, "ICAP")); @@ -568,32 +570,31 @@ }; /* printf("Version = %g, Status = %d, String = %s\n",ver,status,tmpbuf); */ } - if ((httpState->icap->state & ICAP_WaitForPreviewReply) != 0) { - if (status == 100) { - debug(21, 5) ("icapRespModReadReply: 100 Continue received, httpState=%p\n", httpState); - httpState->icap->state &= ~ICAP_WaitForPreviewReply; - /* call again icapSendRespMod to handle data that was received while waiting fot this ICAP response */ - icapSendRespMod (httpState, NULL, 0, 0); - return; - } else if (status == 204) { - IcapStateData *icap = httpState->icap; - comm_close(fd); - httpState->icap = NULL; - if ((icap->state & ICAP_EndOfInputData) != 0) { - /* Reset is required to avoid duplicate stmemFreeDataUpto , - * but will I loose all info now ? */ - /* storeEntryReset(entry); */ - /* stmemFreeDataUpto(&(entry->mem_obj->data_hdr), -icap->sc); */ - fwdComplete(httpState->fwd); - } else { - cbdataLock(httpState); - commSetSelect(httpState->fd, COMM_SELECT_READ, httpReadReply, - httpState, 0); - } - icapStateFree(icap); - return; + if (status == 100) { + debug(21, 5) ("icapRespModReadReply: 100 Continue received, httpState=%p\n", httpState); + httpState->icap->state &= ~ICAP_WaitForPreviewReply; + /* call again icapSendRespMod to handle data that was received while waiting fot this ICAP response */ + icapSendRespMod(httpState, NULL, 0, 0); + return; + } else if (status == 204) { + IcapStateData *icap = httpState->icap; + comm_close(fd); + httpState->icap = NULL; + if ((icap->state & ICAP_EndOfInputData) != 0) { + /* Reset is required to avoid duplicate stmemFreeDataUpto , + * but will I loose all info now ? */ + /* storeEntryReset(entry); */ + /* stmemFreeDataUpto(&(entry->mem_obj->data_hdr), -icap->sc); */ + fwdComplete(httpState->fwd); + } else { + cbdataLock(httpState); + commSetSelect(httpState->fd, COMM_SELECT_READ, httpReadReply, + httpState, 0); } + icapStateFree(icap); + return; + } } if (!headlen || len != headlen || status != 200) { /* Did not find a proper ICAP response */ @@ -620,9 +621,9 @@ comm_close(fd); return; } - /* got the reply, no need to come here again */ - httpState->icap->state &= ~ICAP_WaitForReply; - httpState->icap->state |= ICAP_GotReply; + /* got the reply, no need to come here again */ + httpState->icap->state &= ~ICAP_WaitForReply; + httpState->icap->state |= ICAP_GotReply; /* Read the response here */ icapReadResponse(fd, httpState); } @@ -637,13 +638,13 @@ entry = httpState->entry; mem = entry->mem_obj; - assert (httpState->icap); + assert(httpState->icap); debug(21, 5) ("icapReadResponse: fd %d, httpState %p, ICAP state flags %X\n", fd, httpState, httpState->icap->state); /* do not delete the ICAP field here. * it is needed to route data now still coming from the HTTP * connection up to the ICAP server - icapStateFree(httpState->icap); - httpState->icap = NULL; + icapStateFree(httpState->icap); + httpState->icap = NULL; */ httpState->fd = fd; /* now read the HTTP data from the ICAP connection */ comm_add_close_handler(fd, httpStateFree, httpState); @@ -668,57 +669,57 @@ StoreEntry *entry = httpState->entry; debug(21, 5) ("icapSendRespModDone: FD %d: size %d: errflag %d.\n", - fd, size, errflag); - if (httpState->icap) { - debug(21, 5) ("icapSendRespModDone: ICAP state flags %X\n", httpState->icap->state); - } + fd, size, errflag); + if (httpState->icap) { + debug(21, 5) ("icapSendRespModDone: ICAP state flags %X\n", httpState->icap->state); + } if (cbdataValid(httpState)) { - if (httpState->icap && cbdataValid(httpState->icap)) { - if ((httpState->icap->state & ICAP_EndOfInputData) == 0) { - cbdataLock(httpState); - debug(21, 5) ("icapSendRespModDone: FD %d: commSetSelect on read httpReadReply get more orig data.\n", httpState->icap->http_fd); - commSetSelect(httpState->icap->http_fd, COMM_SELECT_READ, httpReadReply, - httpState, 0); - } - } + if (httpState->icap && cbdataValid(httpState->icap)) { + if ((httpState->icap->state & ICAP_EndOfInputData) == 0) { + cbdataLock(httpState); + debug(21, 5) ("icapSendRespModDone: FD %d: commSetSelect on read httpReadReply get more orig data.\n", httpState->icap->http_fd); + commSetSelect(httpState->icap->http_fd, COMM_SELECT_READ, httpReadReply, + httpState, 0); + } + } } if (size > 0) { - fd_bytes(fd, size, FD_WRITE); - kb_incr(&statCounter.server.all.kbytes_out, size); - kb_incr(&statCounter.server.http.kbytes_out, size); + fd_bytes(fd, size, FD_WRITE); + kb_incr(&statCounter.server.all.kbytes_out, size); + kb_incr(&statCounter.server.http.kbytes_out, size); } if (errflag == COMM_ERR_CLOSING) - return; + return; if (errflag) { - err = errorCon(ERR_WRITE_ERROR, HTTP_INTERNAL_SERVER_ERROR); - err->xerrno = errno; - if (cbdataValid(httpState)) - err->request = requestLink(httpState->request); - storeEntryReset(entry); - errorAppendEntry(entry, err); - comm_close(fd); - return; + err = errorCon(ERR_WRITE_ERROR, HTTP_INTERNAL_SERVER_ERROR); + err->xerrno = errno; + if (cbdataValid(httpState)) + err->request = requestLink(httpState->request); + storeEntryReset(entry); + errorAppendEntry(entry, err); + comm_close(fd); + return; } if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { - comm_close(fd); - return; + comm_close(fd); + return; } if (httpState->icap && - (httpState->icap->state & (ICAP_WaitForPreviewReply | ICAP_WaitForReply)) != 0) { - /* Schedule reading the ICAP response */ - debug(21, 3) ("icapSendRespModDone: FD %d: commSetSelect on read icapRespModReadReply.\n", fd); - commSetSelect(fd, COMM_SELECT_READ, icapRespModReadReply, httpState, 0); - cbdataLock(httpState); - if ((httpState->icap->state & (ICAP_WaitForPreviewReply | ICAP_EndOfInputData)) != 0) { - /* - * Set the read timeout only after all data has been sent - * or we are waiting for a preview response - * If the ICAP server does not return any data till all data - * has been sent, we are likely to hit the timeout for large - * HTTP bodies - */ - commSetTimeout(fd, Config.Timeout.read, icapConnectTimeout, httpState); - } + (httpState->icap->state & (ICAP_WaitForPreviewReply | ICAP_WaitForReply)) != 0) { + /* Schedule reading the ICAP response */ + debug(21, 3) ("icapSendRespModDone: FD %d: commSetSelect on read icapRespModReadReply.\n", fd); + commSetSelect(fd, COMM_SELECT_READ, icapRespModReadReply, httpState, 0); + cbdataLock(httpState); + if ((httpState->icap->state & (ICAP_WaitForPreviewReply | ICAP_EndOfInputData)) != 0) { + /* + * Set the read timeout only after all data has been sent + * or we are waiting for a preview response + * If the ICAP server does not return any data till all data + * has been sent, we are likely to hit the timeout for large + * HTTP bodies + */ + commSetTimeout(fd, Config.Timeout.read, icapConnectTimeout, httpState); + } } } @@ -755,108 +756,106 @@ const int preview_size = icap->preview_size; char ch; debug(21, 5) ("icapSendRespMod: httpState %p: len %d, theEnd %d, icap state %X.\n", - httpState, len, theEnd, icap->state); + httpState, len, theEnd, icap->state); memBufDefInit(&mb); - if (theEnd) - icap->state |= ICAP_EndOfInputData; - - if (icap->sc == 0) { - /* No data sent yet. Start with headers */ - icap->sc = buildRespModHeader (&mb, httpState, buf, len, theEnd); - buf = ((char*) buf) + icap->sc; - len -= icap->sc; - } - - if (preview_size < 0) /* preview feature off */ - icap->state |= ICAP_PreviewDone; - - if ((icap->state & ICAP_PreviewDone) == 0) { - /* preview not yet sent */ - if (icap->sc > 0 && icap->buffer.size <= preview_size && len > 0) { - /* Try to collect at least preview_size+1 bytes */ - /* By collecting one more byte than needed for preview we know best */ - /* whether we have to send the ieof chunk extension */ - size = icap->buffer.size + len; - if (size > preview_size+1) - size = preview_size+1; - size -= icap->buffer.size; - debug(21, 3) ("icapSendRespMod: FD %d: copy %d more bytes to preview buffer.\n", icap->http_fd, size); - memBufAppend (&icap->buffer, buf, size); - buf = ((char*) buf) + size; - len -= size; - } + if (theEnd) + icap->state |= ICAP_EndOfInputData; - if (icap->buffer.size > preview_size || theEnd) { - /* we got enough bytes for preview or this is the last call */ - /* add preview preview now */ - if (icap->buffer.size > 0) { - size = icap->buffer.size; - if (size > preview_size) - size = preview_size; - memBufPrintf(&mb, "%x\r\n", size); - memBufAppend(&mb, icap->buffer.buf, size); - memBufAppend(&mb, crlf, 2); - icap->sc += size; - } - if (icap->buffer.size <= preview_size) { - /* content length is less than preview size+1 */ - memBufAppend(&mb, "0; ieof\r\n\r\n", 11); - memBufReset (&icap->buffer); /* will now be used for other data */ - } else { - memBufAppend(&mb, "0\r\n\r\n", 5); - /* end of preview, wait for continue or 204 signal */ - /* copy the extra byte and all other data to the icap buffer */ - /* so that it can be handled next time */ - ch = icap->buffer.buf[preview_size]; - memBufReset (&icap->buffer); /* will now be used for other data */ - memBufAppend(&icap->buffer, &ch, 1); - debug(21, 3) ("icapSendRespMod: FD %d: sending preview and keeping %d bytes in internal buf.\n", icap->http_fd, len+1); - if (len > 0) - memBufAppend(&icap->buffer, buf, len); - } - icap->state |= ICAP_PreviewDone | ICAP_WaitForPreviewReply; - } - } else if ((icap->state & ICAP_WaitForPreviewReply) != 0) { - /* received new data while waiting for preview response */ - /* add data to internal buffer and send later */ - debug(21, 3) ("icapSendRespMod: FD %d: add %d more bytes to internal buf while wiaiting for preview-response.\n", icap->http_fd, len); + if (icap->sc == 0) { + /* No data sent yet. Start with headers */ + icap->sc = buildRespModHeader(&mb, httpState, buf, len, theEnd); + buf = ((char *) buf) + icap->sc; + len -= icap->sc; + } + if (preview_size < 0) /* preview feature off */ + icap->state |= ICAP_PreviewDone; + + if ((icap->state & ICAP_PreviewDone) == 0) { + /* preview not yet sent */ + if (icap->sc > 0 && icap->buffer.size <= preview_size && len > 0) { + /* Try to collect at least preview_size+1 bytes */ + /* By collecting one more byte than needed for preview we know best */ + /* whether we have to send the ieof chunk extension */ + size = icap->buffer.size + len; + if (size > preview_size + 1) + size = preview_size + 1; + size -= icap->buffer.size; + debug(21, 3) ("icapSendRespMod: FD %d: copy %d more bytes to preview buffer.\n", icap->http_fd, size); + memBufAppend(&icap->buffer, buf, size); + buf = ((char *) buf) + size; + len -= size; + } + if (icap->buffer.size > preview_size || theEnd) { + /* we got enough bytes for preview or this is the last call */ + /* add preview preview now */ + if (icap->buffer.size > 0) { + size = icap->buffer.size; + if (size > preview_size) + size = preview_size; + memBufPrintf(&mb, "%x\r\n", size); + memBufAppend(&mb, icap->buffer.buf, size); + memBufAppend(&mb, crlf, 2); + icap->sc += size; + } + if (icap->buffer.size <= preview_size) { + /* content length is less than preview size+1 */ + memBufAppend(&mb, "0; ieof\r\n\r\n", 11); + memBufReset(&icap->buffer); /* will now be used for other data */ + } else { + memBufAppend(&mb, "0\r\n\r\n", 5); + /* end of preview, wait for continue or 204 signal */ + /* copy the extra byte and all other data to the icap buffer */ + /* so that it can be handled next time */ + ch = icap->buffer.buf[preview_size]; + memBufReset(&icap->buffer); /* will now be used for other data */ + memBufAppend(&icap->buffer, &ch, 1); + debug(21, 3) ("icapSendRespMod: FD %d: sending preview and keeping %d bytes in internal buf.\n", icap->http_fd, len + 1); if (len > 0) - memBufAppend (&icap->buffer, buf, len); - /* do not send any data now while waiting for preview response */ - /* but prepare for read more data on the HTTP connection */ - if ((icap->state & ICAP_EndOfInputData) == 0) { - cbdataLock (httpState); - debug(21, 3) ("icapSendRespMod: FD %d: commSetSelect on read httpReadReply waiting for preview response.\n", icap->http_fd); - commSetSelect(icap->http_fd, COMM_SELECT_READ, httpReadReply, - httpState, 0); - } - return 0; - } else { - /* after preview completed and ICAP preview response received*/ - /* there may still be some data in the buffer */ - if (icap->buffer.size > 0) { - memBufPrintf(&mb, "%x\r\n", icap->buffer.size); - memBufAppend(&mb, icap->buffer.buf, icap->buffer.size); - memBufAppend(&mb, crlf, 2); - icap->sc += icap->buffer.size; - memBufReset (&icap->buffer); - } - if (len > 0) { - memBufPrintf(&mb, "%x\r\n", len); - memBufAppend(&mb, buf, len); - memBufAppend(&mb, crlf, 2); - icap->sc += len; - } - if ((icap->state & ICAP_EndOfInputData) != 0) { - /* send zero end chunk */ - memBufAppend(&mb, "0\r\n\r\n", 5); - } - /* wait for data coming from ICAP server as soon as we sent something */ - /* but of course only until we got the response header */ - if ((icap->state & ICAP_GotReply) == 0) - icap->state |= ICAP_WaitForReply; + memBufAppend(&icap->buffer, buf, len); + } + icap->state |= ICAP_PreviewDone | ICAP_WaitForPreviewReply; } + } else if ((icap->state & ICAP_WaitForPreviewReply) != 0) { + /* received new data while waiting for preview response */ + /* add data to internal buffer and send later */ + debug(21, 3) ("icapSendRespMod: FD %d: add %d more bytes to internal buf while wiaiting for preview-response.\n", icap->http_fd, len); + if (len > 0) + memBufAppend(&icap->buffer, buf, len); + /* do not send any data now while waiting for preview response */ + /* but prepare for read more data on the HTTP connection */ + if ((icap->state & ICAP_EndOfInputData) == 0) { + cbdataLock(httpState); + debug(21, 3) ("icapSendRespMod: FD %d: commSetSelect on read httpReadReply waiting for preview response.\n", icap->http_fd); + commSetSelect(icap->http_fd, COMM_SELECT_READ, httpReadReply, + httpState, 0); + } + return 0; + } else { + /* after preview completed and ICAP preview response received */ + /* there may still be some data in the buffer */ + if (icap->buffer.size > 0) { + memBufPrintf(&mb, "%x\r\n", icap->buffer.size); + memBufAppend(&mb, icap->buffer.buf, icap->buffer.size); + memBufAppend(&mb, crlf, 2); + icap->sc += icap->buffer.size; + memBufReset(&icap->buffer); + } + if (len > 0) { + memBufPrintf(&mb, "%x\r\n", len); + memBufAppend(&mb, buf, len); + memBufAppend(&mb, crlf, 2); + icap->sc += len; + } + if ((icap->state & ICAP_EndOfInputData) != 0) { + /* send zero end chunk */ + memBufAppend(&mb, "0\r\n\r\n", 5); + } + /* wait for data coming from ICAP server as soon as we sent something */ + /* but of course only until we got the response header */ + if ((icap->state & ICAP_GotReply) == 0) + icap->state |= ICAP_WaitForReply; + } commSetDefer(icap->icap_fd, NULL, NULL); commSetTimeout(icap->icap_fd, -1, NULL, NULL); @@ -918,8 +917,8 @@ #else getICAPRespModString(mb, 0, o2, -1, service->uri, client_addr); #endif - if (icap->preview_size >= 0 ) - memBufPrintf(mb, "Preview: %d\r\n", icap->preview_size); + if (icap->preview_size >= 0) + memBufPrintf(mb, "Preview: %d\r\n", icap->preview_size); memBufAppend(mb, "Connection: close\r\n", 19); memBufAppend(mb, crlf, 2); @@ -938,7 +937,7 @@ if (httpState->orig_request->flags.do_icap) if (startICAPrespmod(httpState) >= 0) return; - debug(21, 3) ("scheduleReadReply: FD %d, httpState %p: call httpReadReply directly.\n", fd, httpState); + debug(21, 3) ("scheduleReadReply: FD %d, httpState %p: call httpReadReply directly.\n", fd, httpState); httpReadReply(fd, httpState); } @@ -977,10 +976,10 @@ return -1; icap->current_service = service; - icap->preview_size = service->preview; + icap->preview_size = service->preview; httpState->icap = icap; fd = icap->icap_fd; - icap->http_fd = httpState->fd; + icap->http_fd = httpState->fd; /* Dont send to client just now */ storeBuffer(httpState->entry); @@ -1022,20 +1021,21 @@ icap->enc_res_hdr = -1; icap->enc_null_body = -1; icap->enc_res_body = -1; - icap->state = 0; - icap->chunk_size = -1; - memBufDefInit(&icap->buffer); + icap->state = 0; + icap->chunk_size = -1; + memBufDefInit(&icap->buffer); debug(21, 3) ("New ICAP connection: fd %d\n", fd); return icap; } -void icapStateFree(IcapStateData *icap) +void +icapStateFree(IcapStateData * icap) { - if (icap) { - memBufClean(&icap->buffer); - cbdataFree (icap); - } + if (icap) { + memBufClean(&icap->buffer); + cbdataFree(icap); + } } int @@ -1068,16 +1068,16 @@ } void -getICAPReqModString(MemBuf * mb, int hdrLen, int bodyLen, char *service, char* client_addr) +getICAPReqModString(MemBuf * mb, int hdrLen, int bodyLen, char *service, char *client_addr) { /* memBufAppend(mb, reqModString,strlen(reqModString)); */ memBufPrintf(mb, "REQMOD %s ICAP/1.0\r\n", service); memBufPrintf(mb, "Encapsulated: req-hdr=0"); /* TODO: Change the offset using 'request' if needed */ if (bodyLen > 0) - memBufPrintf(mb, ", req-body=%d", hdrLen); - else - memBufPrintf(mb, ", null-body=%d", hdrLen); + memBufPrintf(mb, ", req-body=%d", hdrLen); + else + memBufPrintf(mb, ", null-body=%d", hdrLen); memBufAppend(mb, crlf, 2); if (Config.icapcfg.send_client_ip) { memBufPrintf(mb, "X-Client-IP: %s\r\n", client_addr); @@ -1086,7 +1086,7 @@ void -getICAPRespModString(MemBuf * mb, int o1, int o2, int o3, char *service, char* client_addr) +getICAPRespModString(MemBuf * mb, int o1, int o2, int o3, char *service, char *client_addr) { /* memBufAppend(mb, respModString,strlen(respModString)); */ memBufPrintf(mb, "RESPMOD %s ICAP/1.0\r\nEncapsulated:", service); @@ -1299,7 +1299,7 @@ if (end <= start) { /* no line found, need more code here, now we are in deep trouble, buffer stops with */ /* half a chunk size line. For now stop here. */ - icap->chunk_size = -2; // we are done + icap->chunk_size = -2; // we are done return nextStart; } @@ -1346,59 +1346,58 @@ } int -icapReadChunkedBody (int fd, void* data, int len, char* buf) +icapReadChunkedBody(int fd, void *data, int len, char *buf) { HttpStateData *httpState = data; StoreEntry *entry = httpState->entry; int bufOffset; - if (httpState->icap->chunk_size == -2) { - debug(21, 3) ("zero end chunk reached\n"); - len = 0; /* don't add anything else */ - } else if (httpState->reply_hdr_state == 2 && httpState->icap->chunk_size >= 0) { - /* read data which is transfered in chunked encoding */ - /* set bufOffset to beginning of body data */ - /* If header was already written to store, we can read from beginning */ - if (entry->mem_obj && entry->mem_obj->inmem_hi > 0) - bufOffset = 0; - else - bufOffset = headersEnd(httpState->reply_hdr, httpState->reply_hdr_size); - - /* Store the header if we didn't do so yet */ - assert (fd == httpState->fd); /* check the condition that the other storeAppends must fulfill */ - if (bufOffset > 0) - storeAppend(entry, buf, bufOffset); - - while (bufOffset < len) { - if (httpState->icap->chunk_size == 0) { - bufOffset += icapReadChunkSize(httpState->icap, buf + bufOffset, len - bufOffset); - debug(21, 3) ("got chunksize %d, new offset %d\n", httpState->icap->chunk_size, bufOffset); - if (httpState->icap->chunk_size == -2) { - debug(21, 3) ("zero end chunk reached\n"); - len = 0; /* don't add anything else */ - /* break; */ - /* let's try to close the connection here */ - fwdComplete(httpState->fwd); - comm_close(fd); - return 1; /* break from httpReadReply */ - } - } - if (httpState->icap->chunk_size > 0) { - if (httpState->icap->chunk_size >= len - bufOffset) { - storeAppend(entry, buf + bufOffset, len - bufOffset); - httpState->icap->chunk_size -= len - bufOffset; - bufOffset = len; - } else { - storeAppend(entry, buf + bufOffset, httpState->icap->chunk_size); - bufOffset += httpState->icap->chunk_size; - httpState->icap->chunk_size = 0; - } - } + if (httpState->icap->chunk_size == -2) { + debug(21, 3) ("zero end chunk reached\n"); + len = 0; /* don't add anything else */ + } else if (httpState->reply_hdr_state == 2 && httpState->icap->chunk_size >= 0) { + /* read data which is transfered in chunked encoding */ + /* set bufOffset to beginning of body data */ + /* If header was already written to store, we can read from beginning */ + if (entry->mem_obj && entry->mem_obj->inmem_hi > 0) + bufOffset = 0; + else + bufOffset = headersEnd(httpState->reply_hdr, httpState->reply_hdr_size); + + /* Store the header if we didn't do so yet */ + assert(fd == httpState->fd); /* check the condition that the other storeAppends must fulfill */ + if (bufOffset > 0) + storeAppend(entry, buf, bufOffset); + + while (bufOffset < len) { + if (httpState->icap->chunk_size == 0) { + bufOffset += icapReadChunkSize(httpState->icap, buf + bufOffset, len - bufOffset); + debug(21, 3) ("got chunksize %d, new offset %d\n", httpState->icap->chunk_size, bufOffset); + if (httpState->icap->chunk_size == -2) { + debug(21, 3) ("zero end chunk reached\n"); + len = 0; /* don't add anything else */ + /* break; */ + /* let's try to close the connection here */ + fwdComplete(httpState->fwd); + comm_close(fd); + return 1; /* break from httpReadReply */ } - } else { - if (fd == httpState->fd) - storeAppend(entry, buf, len); + } + if (httpState->icap->chunk_size > 0) { + if (httpState->icap->chunk_size >= len - bufOffset) { + storeAppend(entry, buf + bufOffset, len - bufOffset); + httpState->icap->chunk_size -= len - bufOffset; + bufOffset = len; + } else { + storeAppend(entry, buf + bufOffset, httpState->icap->chunk_size); + bufOffset += httpState->icap->chunk_size; + httpState->icap->chunk_size = 0; + } + } } - return 0; + } else { + if (fd == httpState->fd) + storeAppend(entry, buf, len); + } + return 0; } - Index: squid/src/icap_opt.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_opt.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/src/icap_opt.c 7 Apr 2003 13:29:05 -0000 1.1.2.2 +++ squid/src/icap_opt.c 27 Jun 2003 01:15:18 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* - * $Id: icap_opt.c,v 1.1.2.2 2003/04/07 13:29:05 hno Exp $ + * $Id: icap_opt.c,v 1.1.2.3 2003/06/27 01:15:18 hno Exp $ * * DEBUG: section 21 ICAP OPTIONS request * AUTHOR: Ralf Horstmann @@ -43,29 +43,29 @@ static void icapOptStart(void *data); static void icapOptTimeout(int fd, void *data); static void icapOptConnectDone(int server_fd, int status, void *data); -static void icapOptWriteComplete(int fd, char* bufnotused, size_t size, int errflag, void *data); +static void icapOptWriteComplete(int fd, char *bufnotused, size_t size, int errflag, void *data); static void icapOptReadReply(int fd, void *data); /* * reply parsing functions */ -static int icapOptParseReply(icap_service *s, const char* buf); -static void icapOptParseEntry(icap_service *s, const char *blk_start, const char *blk_end); -static int icapIsolateLine(const char **parse_start, const char **blk_start, const char **blk_end); +static int icapOptParseReply(icap_service * s, const char *buf); +static void icapOptParseEntry(icap_service * s, const char *blk_start, const char *blk_end); +static int icapIsolateLine(const char **parse_start, const char **blk_start, const char **blk_end); /* * helper functions */ -static void icapOptDataInit(IcapOptData *i); -static void icapOptDataFree(IcapOptData *i); +static void icapOptDataInit(IcapOptData * i); +static void icapOptDataFree(IcapOptData * i); /*************************************************************/ #define OPTIONS_DEFAULT_TTL 300 #define TIMEOUT 10 -void -icapOptInit() +void +icapOptInit() { icap_service *s; @@ -78,10 +78,10 @@ } void -icapOptShutdown() +icapOptShutdown() { icap_service *s; - + s = Config.icapcfg.service_head; while (s) { if (eventFind(icapOptStart, s)) { @@ -99,7 +99,7 @@ int ctimeout = TIMEOUT; const char *host = s->hostname; unsigned short port = s->port; - debug(21,3) ("icapOptStart: starting OPTIONS request for %s (%s)\n", s->name, s->uri); + debug(21, 3) ("icapOptStart: starting OPTIONS request for %s (%s)\n", s->name, s->uri); fd = comm_open(SOCK_STREAM, 0, no_addr, @@ -111,7 +111,7 @@ eventAdd("icapOptStart", icapOptStart, s, OPTIONS_DEFAULT_TTL, 1); return; } - assert(s->opt == NULL); /* if not null, another options request might be running */ + assert(s->opt == NULL); /* if not null, another options request might be running */ s->opt = memAllocate(MEM_ICAP_OPT_DATA); icapOptDataInit(s->opt); cbdataLock(s); @@ -119,15 +119,15 @@ commConnectStart(fd, host, port, icapOptConnectDone, s); } -static void +static void icapOptTimeout(int fd, void *data) { icap_service *s = data; - IcapOptData *i = s->opt; + IcapOptData *i = s->opt; int valid; - + debug(21, 3) ("icapOptConnectTimeout: fd=%d, service=%s\n", fd, s->uri); - + comm_close(fd); valid = cbdataValid(s); cbdataUnlock(s); @@ -135,20 +135,19 @@ icapOptDataFree(i); return; } - /* try again later */ icapOptDataFree(i); s->opt = NULL; s->unreachable = 1; eventAdd("icapOptStart", icapOptStart, s, OPTIONS_DEFAULT_TTL, 1); - + } -static void +static void icapOptConnectDone(int server_fd, int status, void *data) { icap_service *s = data; - IcapOptData *i = s->opt; + IcapOptData *i = s->opt; MemBuf request; int valid; @@ -159,7 +158,6 @@ icapOptDataFree(i); return; } - if (status != COMM_OK) { debug(21, 3) ("icapOptConnectDone: Connection not ok\n"); comm_close(server_fd); @@ -181,11 +179,11 @@ comm_write_mbuf(server_fd, request, icapOptWriteComplete, s); } -static void -icapOptWriteComplete(int fd, char* bufnotused, size_t size, int errflag, void *data) +static void +icapOptWriteComplete(int fd, char *bufnotused, size_t size, int errflag, void *data) { icap_service *s = data; - IcapOptData *i = s->opt; + IcapOptData *i = s->opt; int valid; valid = cbdataValid(s); @@ -195,7 +193,6 @@ icapOptDataFree(i); return; } - debug(21, 5) ("icapOptWriteComplete: FD %d: size %d: errflag %d.\n", fd, size, errflag); if (size > 0) { @@ -212,17 +209,16 @@ eventAdd("icapOptStart", icapOptStart, s, OPTIONS_DEFAULT_TTL, 1); comm_close(fd); return; - } - + } cbdataLock(s); - commSetSelect(fd, COMM_SELECT_READ, icapOptReadReply, s, 0); + commSetSelect(fd, COMM_SELECT_READ, icapOptReadReply, s, 0); } -static void -icapOptReadReply(int fd, void *data) +static void +icapOptReadReply(int fd, void *data) { icap_service *s = data; - IcapOptData *i = s->opt; + IcapOptData *i = s->opt; int size; int len = i->size - i->offset - 1; int valid; @@ -234,17 +230,16 @@ icapOptDataFree(i); return; } - if (len == 0) { /* Grow the request memory area to accomodate for a large request */ printf("PANIC: not enough memory\n"); - /* i->buf = memReallocBuf(i->buf, i->size * 2, &i->size); +#if 0 + i->buf = memReallocBuf(i->buf, i->size * 2, &i->size); debug(21, 2) ("icapoptReadReply: growing reply buffer: offset=%ld size=%ld\n", - (long) i->offset, (long) i->size); + (long) i->offset, (long) i->size); len = i->size - i->offset - 1; - */ +#endif } - size = FD_READ_METHOD(fd, i->buf + i->offset, len); i->offset += size; debug(21, 3) ("icapOptReadReply: Got %d bytes of data\n", size); @@ -263,7 +258,7 @@ } else if (size == 0) { /* no more data, now we can parse the reply */ debug(21, 3) ("icapOptReadReply: FD %d: connection closed\n", fd); - i->buf[i->offset] = '\0'; /* for string functions */ + i->buf[i->offset] = '\0'; /* for string functions */ s->unreachable = 0; if (icapOptParseReply(s, i->buf) && s->options_ttl > 0) { debug(21, 3) ("icapOptReadReply: OPTIONS request successful. scheduling again in %d seconds\n", s->options_ttl); @@ -280,7 +275,7 @@ /* data received */ /* commSetSelect(fd, Type, handler, client_data, timeout) */ cbdataLock(s); - commSetSelect(fd, COMM_SELECT_READ, icapOptReadReply, data, 0 ); + commSetSelect(fd, COMM_SELECT_READ, icapOptReadReply, data, 0); } } @@ -289,17 +284,17 @@ { int slen = strcspn(*parse_start, "\r\n"); - if (!(*parse_start)[slen]) /* no crlf */ + if (!(*parse_start)[slen]) /* no crlf */ return 0; - - if (slen == 0) /* empty line */ + + if (slen == 0) /* empty line */ return 0; *blk_start = *parse_start; *blk_end = *blk_start + slen; /* set it to the beginning of next line */ - *parse_start = *blk_end; + *parse_start = *blk_end; while (**parse_start == '\r') /* CR */ (*parse_start)++; if (**parse_start == '\n') /* LF */ @@ -309,107 +304,106 @@ /* process a single header entry between blk_start and blk_end */ static void -icapOptParseEntry(icap_service *s, const char *blk_start, const char *blk_end) +icapOptParseEntry(icap_service * s, const char *blk_start, const char *blk_end) { const char *name_end = strchr(blk_start, ':'); - const int name_len = name_end ? name_end - blk_start : 0; - const char *value_start = blk_start + name_len + 1; /* skip ':' */ + const int name_len = name_end ? name_end - blk_start : 0; + const char *value_start = blk_start + name_len + 1; /* skip ':' */ int value_len; int new; - + if (!name_len || name_end > blk_end) { - debug(21,5) ("icapOptParseEntry: strange header. skipping\n"); + debug(21, 5) ("icapOptParseEntry: strange header. skipping\n"); return; } if (name_len > 65536) { - debug(21,5) ("icapOptParseEntry: unusual long header item. skipping.\n"); + debug(21, 5) ("icapOptParseEntry: unusual long header item. skipping.\n"); return; } while (xisspace(*value_start) && value_start < blk_end) { value_start++; } if (value_start >= blk_end) { - debug (21,5) ("icapOptParseEntry: no value found\n"); + debug(21, 5) ("icapOptParseEntry: no value found\n"); return; } - value_len = blk_end - value_start; - - + + /* extract information */ - if (!strncmp("Allow", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found Allow\n"); + if (!strncmp("Allow", blk_start, name_len)) { + debug(21, 5) ("icapOptParseEntry: found Allow\n"); if (!strncmp("204", value_start, 3)) { s->flags.allow_204 = 1; } else { - debug(21,3)("icapOptParseEntry: Allow value unknown"); + debug(21, 3) ("icapOptParseEntry: Allow value unknown"); } } else if (!strncmp("Connection", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found Connection\n"); + debug(21, 5) ("icapOptParseEntry: found Connection\n"); } else if (!strncmp("Encapsulated", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found Encapsulated\n"); + debug(21, 5) ("icapOptParseEntry: found Encapsulated\n"); } else if (!strncmp("ISTAG", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found ISTAG\n"); + debug(21, 5) ("icapOptParseEntry: found ISTAG\n"); stringClean(&s->istag); stringLimitInit(&s->istag, value_start, value_len); } else if (!strncmp("Max-Connections", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found Max-Connections\n"); + debug(21, 5) ("icapOptParseEntry: found Max-Connections\n"); errno = 0; new = strtol(value_start, NULL, 10); if (errno) { - debug (21,5)("icapOptParseEntry: Max-Connections: could not parse value\n"); + debug(21, 5) ("icapOptParseEntry: Max-Connections: could not parse value\n"); } else { - debug (21,5)("icapOptParseEntry: Max-Connections: new value=%d\n", new); + debug(21, 5) ("icapOptParseEntry: Max-Connections: new value=%d\n", new); s->max_connections = new; - } + } } else if (!strncmp("Methods", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found Methods\n"); + debug(21, 5) ("icapOptParseEntry: found Methods\n"); } else if (!strncmp("Options-TTL", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found Options-TTL\n"); + debug(21, 5) ("icapOptParseEntry: found Options-TTL\n"); errno = 0; new = strtol(value_start, NULL, 10); if (errno) { - debug (21,5)("icapOptParseEntry: Options-TTL: could not parse value\n"); + debug(21, 5) ("icapOptParseEntry: Options-TTL: could not parse value\n"); } else { - debug (21,5)("icapOptParseEntry: Options-TTL: new value=%d\n", new); + debug(21, 5) ("icapOptParseEntry: Options-TTL: new value=%d\n", new); s->options_ttl = new; } } else if (!strncmp("Preview", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found Preview\n"); + debug(21, 5) ("icapOptParseEntry: found Preview\n"); errno = 0; new = strtol(value_start, NULL, 10); if (errno) { - debug (21,5)("icapOptParseEntry: Preview: could not parse value\n"); + debug(21, 5) ("icapOptParseEntry: Preview: could not parse value\n"); } else { - debug (21,5)("icapOptParseEntry: Preview: new value=%d\n", new); + debug(21, 5) ("icapOptParseEntry: Preview: new value=%d\n", new); s->preview = new; } } else if (!strncmp("Service", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found Service\n"); + debug(21, 5) ("icapOptParseEntry: found Service\n"); } else if (!strncmp("Service-ID", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found Service-ID\n"); + debug(21, 5) ("icapOptParseEntry: found Service-ID\n"); } else if (!strncmp("Transfer-Preview", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found Transfer-Preview\n"); + debug(21, 5) ("icapOptParseEntry: found Transfer-Preview\n"); stringClean(&s->transfer_preview); stringLimitInit(&s->transfer_preview, value_start, value_len); } else if (!strncmp("Transfer-Ignore", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found Transfer-Ignore\n"); + debug(21, 5) ("icapOptParseEntry: found Transfer-Ignore\n"); stringClean(&s->transfer_ignore); stringLimitInit(&s->transfer_ignore, value_start, value_len); } else if (!strncmp("Transfer-Complete", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found Transfer-Complete\n"); + debug(21, 5) ("icapOptParseEntry: found Transfer-Complete\n"); stringClean(&s->transfer_complete); stringLimitInit(&s->transfer_complete, value_start, value_len); } else if (!strncmp("X-Include", blk_start, name_len)) { - debug (21,5)("icapOptParseEntry: found X-Include\n"); + debug(21, 5) ("icapOptParseEntry: found X-Include\n"); } else { - debug (21,5)("icapOptParseEntry: unknown options header\n"); + debug(21, 5) ("icapOptParseEntry: unknown options header\n"); } } /* parse OPTIONS reply */ -static int -icapOptParseReply(icap_service *s, const char* buf) +static int +icapOptParseReply(icap_service * s, const char *buf) { LOCAL_ARRAY(char, tmpbuf, SQUID_TCP_SO_RCVBUF); float ver; @@ -421,39 +415,38 @@ const char *blk_end; if (sscanf(buf, "ICAP/%f %d %s\r", &ver, &status, tmpbuf) < 3 - || ver <= 0.0) { - debug(21,2)("icapOptParseReply: bad status line <%s>\n", buf); + || ver <= 0.0) { + debug(21, 2) ("icapOptParseReply: bad status line <%s>\n", buf); return 0; } - debug(21,3)("icapOptParseReply: got reply: \n", ver, status, tmpbuf); - + debug(21, 3) ("icapOptParseReply: got reply: \n", ver, status, tmpbuf); + if (status != 200) { - debug(21,3)("icapOptParseReply: status = %d != 200", status); + debug(21, 3) ("icapOptParseReply: status = %d != 200", status); return 0; } - parse_start = buf; headlen = headersEnd(parse_start, s->opt->offset); if (!headlen) { - debug(21,2)("icapOptParseReply: end of headers could not be found\n"); + debug(21, 2) ("icapOptParseReply: end of headers could not be found\n"); return 0; } - head_end = parse_start + headlen -1; + head_end = parse_start + headlen - 1; while (*(head_end - 1) == '\r') - head_end--; + head_end--; assert(*(head_end - 1) == '\n'); if (*head_end != '\r' && *head_end != '\n') return 0; /* failure */ /* skip status line */ - if( !icapIsolateLine(&parse_start, &blk_start, &blk_end)) { - debug(21,3)("icapOptParseReply: failure in isolating status line\n"); + if (!icapIsolateLine(&parse_start, &blk_start, &blk_end)) { + debug(21, 3) ("icapOptParseReply: failure in isolating status line\n"); return 0; } /* now we might start real parsing */ while (icapIsolateLine(&parse_start, &blk_start, &blk_end)) { if (blk_end > head_end || blk_start > head_end || blk_start >= blk_end) { - debug(21,3)("icapOptParseReply: header limit exceeded. finished.\n"); + debug(21, 3) ("icapOptParseReply: header limit exceeded. finished.\n"); break; } icapOptParseEntry(s, blk_start, blk_end); @@ -462,13 +455,13 @@ } static void -icapOptDataInit(IcapOptData *i) +icapOptDataInit(IcapOptData * i) { - i->buf = memAllocBuf(HTTP_REPLY_BUF_SZ, &i->size); + i->buf = memAllocBuf(HTTP_REPLY_BUF_SZ, &i->size); } -static void -icapOptDataFree(IcapOptData *i) +static void +icapOptDataFree(IcapOptData * i) { if (i) { memFreeBuf(i->size, i->buf); Index: squid/src/mem.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/mem.c,v retrieving revision 1.13.28.1 retrieving revision 1.13.28.2 diff -u -r1.13.28.1 -r1.13.28.2 --- squid/src/mem.c 4 Apr 2003 16:55:41 -0000 1.13.28.1 +++ squid/src/mem.c 27 Jun 2003 01:15:18 -0000 1.13.28.2 @@ -1,6 +1,6 @@ /* - * $Id: mem.c,v 1.13.28.1 2003/04/04 16:55:41 hno Exp $ + * $Id: mem.c,v 1.13.28.2 2003/06/27 01:15:18 hno Exp $ * * DEBUG: section 13 High Level Memory Pool Management * AUTHOR: Harvest Derived @@ -245,10 +245,10 @@ #ifdef HS_FEAT_ICAP memDataInit(MEM_ICAP_OPT_DATA, "IcapOptData", sizeof(IcapOptData), 0); - memDataInit(MEM_ICAP_SERVICE_LIST, "icap_service_list", sizeof(icap_service_list),0); + memDataInit(MEM_ICAP_SERVICE_LIST, "icap_service_list", sizeof(icap_service_list), 0); memDataInit(MEM_ICAP_CLASS, "icap_class", sizeof(icap_class), 0); memDataInit(MEM_ICAP_ACCESS, "icap_access", sizeof(icap_access), 0); -#endif +#endif /* init string pools */ for (i = 0; i < mem_str_pool_count; i++) { Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.41.6.13.2.3 retrieving revision 1.41.6.13.2.4 diff -u -r1.41.6.13.2.3 -r1.41.6.13.2.4 --- squid/src/protos.h 9 May 2003 14:19:36 -0000 1.41.6.13.2.3 +++ squid/src/protos.h 27 Jun 2003 01:15:19 -0000 1.41.6.13.2.4 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.41.6.13.2.3 2003/05/09 14:19:36 hno Exp $ + * $Id: protos.h,v 1.41.6.13.2.4 2003/06/27 01:15:19 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1349,11 +1349,11 @@ #ifdef HS_FEAT_ICAP /* icap.c */ int icapInit(void); -const char* icapServiceToStr(const icap_service_t type); +const char *icapServiceToStr(const icap_service_t type); icap_service_t icapServiceToType(const char *s); -int icapCheckAcl( clientHttpRequest *http ); -void icapStateFree (IcapStateData *icap); -int icapReadChunkedBody (int fd, void* data, int len, char* buf); +int icapCheckAcl(clientHttpRequest * http); +void icapStateFree(IcapStateData * icap); +int icapReadChunkedBody(int fd, void *data, int len, char *buf); int icapSendRespMod(HttpStateData * httpState, void *buf, int len, int theEnd); int startICAPrespmod(HttpStateData * httpState); int startICAPreqmod(HttpStateData * httpState); @@ -1361,7 +1361,7 @@ void icapOptInit(void); void icapOptShutdown(void); /* for debugging purposes only */ -void dump_icap_config(IcapConfig* cfg); +void dump_icap_config(IcapConfig * cfg); /* Various functions hooked into by the ICAP client code but which * is otherwise considered private to respective module: */ Index: squid/src/squid.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/squid.h,v retrieving revision 1.13.6.6.2.1 retrieving revision 1.13.6.6.2.2 diff -u -r1.13.6.6.2.1 -r1.13.6.6.2.2 --- squid/src/squid.h 4 Apr 2003 16:55:49 -0000 1.13.6.6.2.1 +++ squid/src/squid.h 27 Jun 2003 01:15:19 -0000 1.13.6.6.2.2 @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.13.6.6.2.1 2003/04/04 16:55:49 hno Exp $ + * $Id: squid.h,v 1.13.6.6.2.2 2003/06/27 01:15:19 hno Exp $ * * AUTHOR: Duane Wessels * @@ -44,7 +44,7 @@ #ifdef HS_FEAT_ICAP #define ICAP_CHUNKED 1 -#endif +#endif /* * On some systems, FD_SETSIZE is set to something lower than the * actual number of files which can be opened. IRIX is one case, Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.48.2.9.2.4 retrieving revision 1.48.2.9.2.5 diff -u -r1.48.2.9.2.4 -r1.48.2.9.2.5 --- squid/src/structs.h 27 May 2003 12:57:44 -0000 1.48.2.9.2.4 +++ squid/src/structs.h 27 Jun 2003 01:15:19 -0000 1.48.2.9.2.5 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.48.2.9.2.4 2003/05/27 12:57:44 hno Exp $ + * $Id: structs.h,v 1.48.2.9.2.5 2003/06/27 01:15:19 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -379,11 +379,12 @@ int onoff; icap_service *service_head; /* icap_service_list *service_list_head; */ - icap_class *class_head; - icap_access *access_head; + icap_class *class_head; + icap_access *access_head; int preview_size; int send_client_ip; }; + #endif /* HS_FEAT_ICAP */ struct _SquidConfig { @@ -988,7 +989,7 @@ int icap_fd; int http_fd; int sc; - icapState state; + icapState state; icap_service *current_service; int enc_res_hdr; int enc_null_body; @@ -1001,18 +1002,18 @@ struct _icap_service { icap_service *next; - char *name; /* name to be used when referencing ths service */ - char *uri; /* uri of server/service to use */ - char *type_name; /* {req|resp}mod_{pre|post}cache */ + char *name; /* name to be used when referencing ths service */ + char *uri; /* uri of server/service to use */ + char *type_name; /* {req|resp}mod_{pre|post}cache */ - char *hostname; + char *hostname; unsigned short int port; char *resource; - icap_service_t type; /* parsed type */ + icap_service_t type; /* parsed type */ icap_method_t method; - ushort bypass; /* flag: bypass allowed */ - ushort unreachable; /* flag: set to 1 if options request fails */ - IcapOptData *opt; /* temp data needed during opt request */ + ushort bypass; /* flag: bypass allowed */ + ushort unreachable; /* flag: set to 1 if options request fails */ + IcapOptData *opt; /* temp data needed during opt request */ struct { unsigned int allow_204:1; } flags; @@ -1023,21 +1024,21 @@ String transfer_complete; int max_connections; int options_ttl; -}; +}; struct _icap_service_list { - icap_service_list* next; - icap_service* service; + icap_service_list *next; + icap_service *service; }; struct _icap_class { icap_class *next; - char* name; - wordlist* services; + char *name; + wordlist *services; icap_service_list *isl; - ushort hidden; /* for unnamed classes */ + ushort hidden; /* for unnamed classes */ }; - + struct _icap_access { icap_access *next; char *service_name; @@ -1045,7 +1046,7 @@ acl_access *access; }; -struct _IcapOptData { +struct _IcapOptData { char *buf; off_t offset; size_t size; @@ -1066,7 +1067,7 @@ http_state_flags flags; FwdState *fwd; #ifdef HS_FEAT_ICAP - struct _IcapStateData *icap; + struct _IcapStateData *icap; #endif }; @@ -1698,8 +1699,8 @@ unsigned int body_sent:1; unsigned int reset_tcp:1; #if HS_FEAT_ICAP - /* if any icap acl matches, this is set to true */ - unsigned int do_icap:1; + /* if any icap acl matches, this is set to true */ + unsigned int do_icap:1; #endif }; Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.25.6.1.6.3 retrieving revision 1.25.6.1.6.4 diff -u -r1.25.6.1.6.3 -r1.25.6.1.6.4 --- squid/src/typedefs.h 27 May 2003 12:57:44 -0000 1.25.6.1.6.3 +++ squid/src/typedefs.h 27 Jun 2003 01:15:19 -0000 1.25.6.1.6.4 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.25.6.1.6.3 2003/05/27 12:57:44 hno Exp $ + * $Id: typedefs.h,v 1.25.6.1.6.4 2003/06/27 01:15:19 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -373,6 +373,6 @@ typedef struct _external_acl_entry external_acl_entry; /* Request hooks */ -typedef int REQHOOK(ConnStateData *connState, clientHttpRequest *http, void *data); +typedef int REQHOOK(ConnStateData * connState, clientHttpRequest * http, void *data); #endif /* SQUID_TYPEDEFS_H */