--------------------- PatchSet 3028 Date: 2001/09/15 10:53:59 Author: serassio Branch: nt-2_3-tolsty Tag: (none) Log: Fixed indent problems Members: src/cf_gen.c:1.1.1.3.4.1.2.2.2.1->1.1.1.3.4.1.2.2.2.2 src/client.c:1.1.1.3.4.1.2.2.2.2->1.1.1.3.4.1.2.2.2.3 src/client_side.c:1.1.1.3.4.6.2.4.2.2->1.1.1.3.4.6.2.4.2.3 Index: squid/src/cf_gen.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cf_gen.c,v retrieving revision 1.1.1.3.4.1.2.2.2.1 retrieving revision 1.1.1.3.4.1.2.2.2.2 diff -u -r1.1.1.3.4.1.2.2.2.1 -r1.1.1.3.4.1.2.2.2.2 --- squid/src/cf_gen.c 27 Aug 2001 21:48:20 -0000 1.1.1.3.4.1.2.2.2.1 +++ squid/src/cf_gen.c 15 Sep 2001 10:53:59 -0000 1.1.1.3.4.1.2.2.2.2 @@ -1,5 +1,5 @@ /* - * $Id: cf_gen.c,v 1.1.1.3.4.1.2.2.2.1 2001/08/27 21:48:20 tolsty Exp $ + * $Id: cf_gen.c,v 1.1.1.3.4.1.2.2.2.2 2001/09/15 10:53:59 serassio Exp $ * * DEBUG: none * AUTHOR: Max Okumoto @@ -70,8 +70,7 @@ #define _PATH_PARSER "cf_parser.c" #define _PATH_SQUID_CONF "squid.conf" -enum State -{ +enum State { sSTART, s1, sDOC, @@ -79,15 +78,12 @@ sEXIT }; -typedef struct Line -{ +typedef struct Line { char *data; struct Line *next; -} -Line; +} Line; -typedef struct Entry -{ +typedef struct Entry { char *name; char *type; char *loc; @@ -98,8 +94,7 @@ Line *doc; Line *nocomment; struct Entry *next; -} -Entry; +} Entry; static const char WS[] = " \t"; @@ -317,7 +312,9 @@ " *\n" " * Abstract: This file contains routines used to configure the\n" " * variables in the squid server.\n" - " */\n" "\n", input_filename, argv[0] + " */\n" + "\n", + input_filename, argv[0] ); rc = gen_default(entries, fp); gen_default_if_none(entries, fp); @@ -349,13 +346,17 @@ "\tLOCAL_ARRAY(char, tmp_line, BUFSIZ);\n" "\txstrncpy(tmp_line, s, BUFSIZ);\n" "\txstrncpy(config_input_line, s, BUFSIZ);\n" - "\tconfig_lineno++;\n" "\tparse_line(tmp_line);\n" "}\n"); + "\tconfig_lineno++;\n" + "\tparse_line(tmp_line);\n" + "}\n" + ); fprintf(fp, "static void\n" "default_all(void)\n" "{\n" "\tcfg_filename = \"Default Configuration\";\n" - "\tconfig_lineno = 0;\n"); + "\tconfig_lineno = 0;\n" + ); for (entry = head; entry != NULL; entry = entry->next) { assert(entry->name); assert(entry != entry->next); @@ -379,7 +380,8 @@ fprintf(fp, "\t/* No default for %s */\n", entry->name); } else { fprintf(fp, "\tdefault_line(\"%s %s\");\n", - entry->name, entry->default_value); + entry->name, + entry->default_value); } if (entry->ifdef) fprintf(fp, "#endif\n"); @@ -393,7 +395,11 @@ gen_default_if_none(Entry * head, FILE * fp) { Entry *entry; - fprintf(fp, "static void\n" "defaults_if_none(void)\n" "{\n"); + fprintf(fp, + "static void\n" + "defaults_if_none(void)\n" + "{\n" + ); for (entry = head; entry != NULL; entry = entry->next) { assert(entry->name); assert(entry->loc); @@ -404,7 +410,10 @@ fprintf(fp, "\tif (check_null_%s(%s))\n" "\t\tdefault_line(\"%s %s\");\n", - entry->type, entry->loc, entry->name, entry->default_if_none); + entry->type, + entry->loc, + entry->name, + entry->default_if_none); if (entry->ifdef) fprintf(fp, "#endif\n"); } @@ -424,19 +433,28 @@ "\tchar\t*token;\n" "\tdebug(0,10)(\"parse_line: %%s\\n\", buff);\n" "\tif ((token = strtok(buff, w_space)) == NULL)\n" - "\t\t(void) 0;\t/* ignore empty lines */\n"); + "\t\t(void) 0;\t/* ignore empty lines */\n" + ); for (entry = head; entry != NULL; entry = entry->next) { if (strcmp(entry->name, "comment") == 0) continue; if (entry->ifdef) fprintf(fp, "#if %s\n", entry->ifdef); - fprintf(fp, "\telse if (!strcmp(token, \"%s\"))\n", entry->name); + fprintf(fp, "\telse if (!strcmp(token, \"%s\"))\n", + entry->name + ); assert(entry->loc); if (strcmp(entry->loc, "none") == 0) { - fprintf(fp, "\t\tparse_%s();\n", entry->type); + fprintf(fp, + "\t\tparse_%s();\n", + entry->type + ); } else { - fprintf(fp, "\t\tparse_%s(&%s);\n", entry->type, entry->loc); + fprintf(fp, + "\t\tparse_%s(&%s);\n", + entry->type, entry->loc + ); } if (entry->ifdef) fprintf(fp, "#endif\n"); @@ -444,14 +462,21 @@ fprintf(fp, "\telse\n" - "\t\tresult = 0; /* failure */\n" "\treturn(result);\n" "}\n\n"); + "\t\tresult = 0; /* failure */\n" + "\treturn(result);\n" + "}\n\n" + ); } static void gen_dump(Entry * head, FILE * fp) { Entry *entry; - fprintf(fp, "static void\n" "dump_config(StoreEntry *entry)\n" "{\n"); + fprintf(fp, + "static void\n" + "dump_config(StoreEntry *entry)\n" + "{\n" + ); for (entry = head; entry != NULL; entry = entry->next) { assert(entry->loc); if (strcmp(entry->loc, "none") == 0) @@ -461,7 +486,9 @@ if (entry->ifdef) fprintf(fp, "#if %s\n", entry->ifdef); fprintf(fp, "\tdump_%s(entry, \"%s\", %s);\n", - entry->type, entry->name, entry->loc); + entry->type, + entry->name, + entry->loc); if (entry->ifdef) fprintf(fp, "#endif\n"); } @@ -472,7 +499,11 @@ gen_free(Entry * head, FILE * fp) { Entry *entry; - fprintf(fp, "static void\n" "free_all(void)\n" "{\n"); + fprintf(fp, + "static void\n" + "free_all(void)\n" + "{\n" + ); for (entry = head; entry != NULL; entry = entry->next) { assert(entry->loc); if (strcmp(entry->loc, "none") == 0) Index: squid/src/client.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/client.c,v retrieving revision 1.1.1.3.4.1.2.2.2.2 retrieving revision 1.1.1.3.4.1.2.2.2.3 diff -u -r1.1.1.3.4.1.2.2.2.2 -r1.1.1.3.4.1.2.2.2.3 --- squid/src/client.c 31 Aug 2001 06:24:34 -0000 1.1.1.3.4.1.2.2.2.2 +++ squid/src/client.c 15 Sep 2001 10:53:59 -0000 1.1.1.3.4.1.2.2.2.3 @@ -1,5 +1,5 @@ /* - * $Id: client.c,v 1.1.1.3.4.1.2.2.2.2 2001/08/31 06:24:34 tolsty Exp $ + * $Id: client.c,v 1.1.1.3.4.1.2.2.2.3 2001/09/15 10:53:59 serassio Exp $ * * DEBUG: section 0 WWW Client * AUTHOR: Harvest Derived @@ -200,7 +200,8 @@ put_fd = open(put_file, O_RDONLY); set_our_signal(); if (put_fd < 0) { - fprintf(stderr, "%s: can't open file (%s)\n", argv[0], xstrerror()); + fprintf(stderr, "%s: can't open file (%s)\n", argv[0], + xstrerror()); exit(-1); } #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) @@ -272,9 +273,7 @@ } if (client_comm_connect(conn, hostname, port, ping ? &tv1 : NULL) < 0) { if (errno == 0) { - fprintf(stderr, - "client: ERROR: Cannot connect to %s:%d: Host unknown.\n", - hostname, port); + fprintf(stderr, "client: ERROR: Cannot connect to %s:%d: Host unknown.\n", hostname, port); } else { char tbuf[BUFSIZ]; snprintf(tbuf, BUFSIZ, "client: ERROR: Cannot connect to %s:%d", @@ -337,8 +336,7 @@ elapsed_msec = tvSubMsec(tv1, tv2); t2s = tv2.tv_sec; tmp = localtime(&t2s); - fprintf(stderr, - "%d-%02d-%02d %02d:%02d:%02d [%d]: %ld.%03ld secs, %f KB/s\n", + fprintf(stderr, "%d-%02d-%02d %02d:%02d:%02d [%d]: %ld.%03ld secs, %f KB/s\n", tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec, i + 1, elapsed_msec / 1000, elapsed_msec % 1000, @@ -364,8 +362,8 @@ ping_mean = ping_sum / i; fprintf(stderr, "%d requests, round-trip (secs) min/avg/max = " "%ld.%03ld/%ld.%03ld/%ld.%03ld\n", i, - ping_min / 1000, ping_min % 1000, ping_mean / 1000, - ping_mean % 1000, ping_max / 1000, ping_max % 1000); + ping_min / 1000, ping_min % 1000, ping_mean / 1000, ping_mean % 1000, + ping_max / 1000, ping_max % 1000); } exit(0); /*NOTREACHED */ @@ -388,13 +386,11 @@ xmemcpy(&from_addr.sin_addr, hp->h_addr, hp->h_length); from_addr.sin_port = 0; } - return bind(sock, (struct sockaddr *) &from_addr, - sizeof(struct sockaddr_in)); + return bind(sock, (struct sockaddr *) &from_addr, sizeof(struct sockaddr_in)); } static int -client_comm_connect(int sock, char *dest_host, u_short dest_port, - struct timeval *tvp) +client_comm_connect(int sock, char *dest_host, u_short dest_port, struct timeval *tvp) { static const struct hostent *hp = NULL; static struct sockaddr_in to_addr; @@ -411,8 +407,7 @@ } if (tvp) (void) Now(tvp); - return connect(sock, (struct sockaddr *) &to_addr, - sizeof(struct sockaddr_in)); + return connect(sock, (struct sockaddr *) &to_addr, sizeof(struct sockaddr_in)); } static int Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.1.1.3.4.6.2.4.2.2 retrieving revision 1.1.1.3.4.6.2.4.2.3 diff -u -r1.1.1.3.4.6.2.4.2.2 -r1.1.1.3.4.6.2.4.2.3 --- squid/src/client_side.c 31 Aug 2001 06:24:34 -0000 1.1.1.3.4.6.2.4.2.2 +++ squid/src/client_side.c 15 Sep 2001 10:53:59 -0000 1.1.1.3.4.6.2.4.2.3 @@ -1,5 +1,5 @@ /* - * $Id: client_side.c,v 1.1.1.3.4.6.2.4.2.2 2001/08/31 06:24:34 tolsty Exp $ + * $Id: client_side.c,v 1.1.1.3.4.6.2.4.2.3 2001/09/15 10:53:59 serassio Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -82,14 +82,11 @@ static void checkFailureRatio(err_type, hier_code); static void clientProcessMiss(clientHttpRequest *); static void clientBuildReplyHeader(clientHttpRequest * http, HttpReply * rep); -static clientHttpRequest *parseHttpRequestAbort(ConnStateData * conn, - const char *uri); -static clientHttpRequest *parseHttpRequest(ConnStateData *, method_t *, int *, - char **, size_t *); +static clientHttpRequest *parseHttpRequestAbort(ConnStateData * conn, const char *uri); +static clientHttpRequest *parseHttpRequest(ConnStateData *, method_t *, int *, char **, size_t *); static RH clientRedirectDone; static STCB clientHandleIMSReply; -static int clientGetsOldEntry(StoreEntry * new, StoreEntry * old, - request_t * request); +static int clientGetsOldEntry(StoreEntry * new, StoreEntry * old, request_t * request); static int checkAccelOnly(clientHttpRequest *); #if USE_IDENT static IDCB clientIdentDone; @@ -98,8 +95,7 @@ static STCB clientSendMoreData; static STCB clientCacheHit; static void clientSetKeepaliveFlag(clientHttpRequest *); -static void clientPackRangeHdr(const HttpReply * rep, - const HttpHdrRangeSpec * spec, String boundary, MemBuf * mb); +static void clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, String boundary, MemBuf * mb); static void clientPackTermBound(String boundary, MemBuf * mb); static void clientInterpretRequestHeaders(clientHttpRequest *); static void clientProcessRequest(clientHttpRequest *); @@ -152,7 +148,8 @@ return; } http->acl_checklist = aclChecklistCreate(Config.accessList.http, - http->request, conn->ident); + http->request, + conn->ident); #if USE_IDENT /* * hack for ident ACL. It needs to get full addresses, and a @@ -327,7 +324,9 @@ */ assert(storeClientListSearch(http->old_entry->mem_obj, http)); entry = storeCreateEntry(url, - http->log_uri, http->request->flags, http->request->method); + http->log_uri, + http->request->flags, + http->request->method); /* NOTE, don't call storeLockObject(), storeCreateEntry() does it */ storeClientListAdd(entry, http); #if DELAY_POOLS @@ -346,12 +345,13 @@ http->out.offset, http->out.offset, CLIENT_SOCK_SZ, - memAllocate(MEM_CLIENT_SOCK_BUF), clientHandleIMSReply, http); + memAllocate(MEM_CLIENT_SOCK_BUF), + clientHandleIMSReply, + http); } static int -clientGetsOldEntry(StoreEntry * new_entry, StoreEntry * old_entry, - request_t * request) +clientGetsOldEntry(StoreEntry * new_entry, StoreEntry * old_entry, request_t * request) { const http_status status = new_entry->mem_obj->reply->sline.status; if (0 == status) { @@ -418,14 +418,10 @@ storeUnlockObject(entry); entry = http->entry = http->old_entry; } else if (STORE_PENDING == entry->store_status && 0 == status) { - debug(33, 3) ("clientHandleIMSReply: Incomplete headers for '%s'\n", - url); + debug(33, 3) ("clientHandleIMSReply: Incomplete headers for '%s'\n", url); if (size >= CLIENT_SOCK_SZ) { /* will not get any bigger than that */ - debug(33, - 3) - ("clientHandleIMSReply: Reply is too large '%s', using old entry\n", - url); + debug(33, 3) ("clientHandleIMSReply: Reply is too large '%s', using old entry\n", url); /* use old entry, this repeats the code abovez */ http->log_type = LOG_TCP_REFRESH_FAIL_HIT; storeUnregister(entry, http); @@ -436,7 +432,10 @@ storeClientCopy(entry, http->out.offset + size, http->out.offset, - CLIENT_SOCK_SZ, buf, clientHandleIMSReply, http); + CLIENT_SOCK_SZ, + buf, + clientHandleIMSReply, + http); return; } } else if (clientGetsOldEntry(entry, http->old_entry, http->request)) { @@ -481,7 +480,11 @@ if (recopy) { storeClientCopy(entry, http->out.offset, - http->out.offset, CLIENT_SOCK_SZ, buf, clientSendMoreData, http); + http->out.offset, + CLIENT_SOCK_SZ, + buf, + clientSendMoreData, + http); } else { clientSendMoreData(data, buf, size); } @@ -527,16 +530,13 @@ StoreEntry *entry; ErrorState *err = NULL; HttpReply *r; - debug(33, 3) ("Config2.onoff.enable_purge = %d\n", - Config2.onoff.enable_purge); + debug(33, 3) ("Config2.onoff.enable_purge = %d\n", Config2.onoff.enable_purge); if (!Config2.onoff.enable_purge) { http->log_type = LOG_TCP_DENIED; err = errorCon(ERR_ACCESS_DENIED, HTTP_FORBIDDEN); err->request = requestLink(http->request); err->src_addr = http->conn->peer.sin_addr; - http->entry = - clientCreateStoreEntry(http, http->request->method, - null_request_flags); + http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); errorAppendEntry(http->entry, err); return; } @@ -547,13 +547,13 @@ storeRelease(entry); http->http_code = HTTP_OK; } - debug(33, 4) ("clientPurgeRequest: Not modified '%s'\n", storeUrl(entry)); + debug(33, 4) ("clientPurgeRequest: Not modified '%s'\n", + storeUrl(entry)); /* * Make a new entry to hold the reply to be written * to the client. */ - http->entry = - clientCreateStoreEntry(http, http->request->method, null_request_flags); + http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); httpReplyReset(r = http->entry->mem_obj->reply); httpReplySetHeaders(r, 1.0, http->http_code, NULL, NULL, 0, 0, -1); httpReplySwapOut(r, http->entry); @@ -687,8 +687,7 @@ } accessLogLog(&http->al); clientUpdateCounters(http); - clientdbUpdate(conn->peer.sin_addr, http->log_type, PROTO_HTTP, - http->out.size); + clientdbUpdate(conn->peer.sin_addr, http->log_type, PROTO_HTTP, http->out.size); } if (http->acl_checklist) aclChecklistFree(http->acl_checklist); @@ -1007,8 +1006,7 @@ static int clientIfRangeMatch(clientHttpRequest * http, HttpReply * rep) { - const TimeOrTag spec = - httpHeaderGetTimeOrTag(&http->request->header, HDR_IF_RANGE); + const TimeOrTag spec = httpHeaderGetTimeOrTag(&http->request->header, HDR_IF_RANGE); /* check for parsing falure */ if (!spec.valid) return 0; @@ -1020,9 +1018,7 @@ if (!rep_tag.str) return 0; /* entity has no etag to compare with! */ if (spec.tag.weak || rep_tag.weak) { - debug(33, 1) - - ("clientIfRangeMatch: Weak ETags are not allowed in If-Range: %s ? %s\n", + debug(33, 1) ("clientIfRangeMatch: Weak ETags are not allowed in If-Range: %s ? %s\n", spec.tag.str, rep_tag.str); return 0; /* must use strong validator for sub-range requests */ } @@ -1093,8 +1089,7 @@ range_err = "unknown length"; else if (rep->content_length != http->entry->mem_obj->reply->content_length) range_err = "INCONSISTENT length"; /* a bug? */ - else if (httpHeaderHas(&http->request->header, HDR_IF_RANGE) - && !clientIfRangeMatch(http, rep)) + else if (httpHeaderHas(&http->request->header, HDR_IF_RANGE) && !clientIfRangeMatch(http, rep)) range_err = "If-Range match failed"; else if (!httpHdrRangeCanonize(http->request->range, rep->content_length)) range_err = "canonization failed"; @@ -1102,16 +1097,14 @@ range_err = "too complex range header"; /* get rid of our range specs on error */ if (range_err) { - debug(33, 3) ("clientBuildRangeHeader: will not do ranges: %s.\n", - range_err); + debug(33, 3) ("clientBuildRangeHeader: will not do ranges: %s.\n", range_err); httpHdrRangeDestroy(http->request->range); http->request->range = NULL; } else { const int spec_count = http->request->range->specs.count; int actual_clen = -1; - debug(33, 3) - ("clientBuildRangeHeader: range spec count: %d virgin clen: %d\n", + debug(33, 3) ("clientBuildRangeHeader: range spec count: %d virgin clen: %d\n", spec_count, rep->content_length); assert(spec_count > 0); /* ETags should not be returned with Partial Content replies? */ @@ -1119,8 +1112,7 @@ /* append appropriate header(s) */ if (spec_count == 1) { HttpHdrRangePos pos = HttpHdrRangeInitPos; - const HttpHdrRangeSpec *spec = - httpHdrRangeGetSpec(http->request->range, &pos); + const HttpHdrRangeSpec *spec = httpHdrRangeGetSpec(http->request->range, &pos); assert(spec); /* append Content-Range */ httpHeaderAddContRange(hdr, *spec, rep->content_length); @@ -1145,8 +1137,7 @@ assert(actual_clen >= 0); httpHeaderDelById(hdr, HDR_CONTENT_LENGTH); httpHeaderPutInt(hdr, HDR_CONTENT_LENGTH, actual_clen); - debug(33, 3) ("clientBuildRangeHeader: actual content length: %d\n", - actual_clen); + debug(33, 3) ("clientBuildRangeHeader: actual content length: %d\n", actual_clen); } } @@ -1232,8 +1223,7 @@ getMyHostname(), ntohs(Config.Sockaddr.http->s.sin_port)); #endif if (httpReplyBodySize(request->method, rep) < 0) { - debug(33, 3) - ("clientBuildReplyHeader: can't keep-alive, unknown body size\n"); + debug(33, 3) ("clientBuildReplyHeader: can't keep-alive, unknown body size\n"); request->flags.proxy_keepalive = 0; } /* Signal keep-alive if needed */ @@ -1329,7 +1319,11 @@ debug(33, 3) ("clientCacheHit: waiting for HTTP reply headers\n"); storeClientCopy(e, http->out.offset + size, - http->out.offset, CLIENT_SOCK_SZ, buf, clientCacheHit, http); + http->out.offset, + CLIENT_SOCK_SZ, + buf, + clientCacheHit, + http); } return; } @@ -1412,9 +1406,7 @@ memFree(buf, MEM_CLIENT_SOCK_BUF); storeUnregister(e, http); storeUnlockObject(e); - e = - clientCreateStoreEntry(http, http->request->method, - null_request_flags); + e = clientCreateStoreEntry(http, http->request->method, null_request_flags); /* * Copy timestamp from the original entry so the 304 * reply has a meaningful Age: header. @@ -1448,8 +1440,7 @@ /* appends a "part" HTTP header (as in a multi-part/range reply) to the buffer */ static void -clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, - String boundary, MemBuf * mb) +clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, String boundary, MemBuf * mb) { HttpHeader hdr; Packer p; @@ -1457,16 +1448,14 @@ assert(spec); /* put boundary */ - debug(33, 5) ("clientPackRangeHdr: appending boundary: %s\n", - strBuf(boundary)); + debug(33, 5) ("clientPackRangeHdr: appending boundary: %s\n", strBuf(boundary)); /* rfc2046 requires to _prepend_ boundary with ! */ memBufPrintf(mb, "\r\n--%s\r\n", strBuf(boundary)); /* stuff the header with required entries and pack it */ httpHeaderInit(&hdr, hoReply); if (httpHeaderHas(&rep->header, HDR_CONTENT_TYPE)) - httpHeaderPutStr(&hdr, HDR_CONTENT_TYPE, httpHeaderGetStr(&rep->header, - HDR_CONTENT_TYPE)); + httpHeaderPutStr(&hdr, HDR_CONTENT_TYPE, httpHeaderGetStr(&rep->header, HDR_CONTENT_TYPE)); httpHeaderAddContRange(&hdr, *spec, rep->content_length); packerToMemInit(&p, mb); httpHeaderPackInto(&hdr, &p); @@ -1483,7 +1472,10 @@ */ static void clientPackRange(clientHttpRequest * http, - HttpHdrRangeIter * i, const char **buf, ssize_t * size, MemBuf * mb) + HttpHdrRangeIter * i, + const char **buf, + ssize_t * size, + MemBuf * mb) { const ssize_t copy_sz = i->debt_size <= *size ? i->debt_size : *size; off_t body_off = http->out.offset - i->prefix_size; @@ -1498,13 +1490,14 @@ * put boundary and headers at the beginning of a range in a * multi-range */ - if (http->request->range->specs.count > 1 - && i->debt_size == i->spec->length) { + if (http->request->range->specs.count > 1 && i->debt_size == i->spec->length) { assert(http->entry->mem_obj); - clientPackRangeHdr(http->entry->mem_obj->reply, /* original reply */ + clientPackRangeHdr( + http->entry->mem_obj->reply, /* original reply */ i->spec, /* current range */ i->boundary, /* boundary, the same for all */ - mb); + mb + ); } /* * append content @@ -1529,8 +1522,7 @@ * increments iterator "i" * used by clientPackMoreRanges */ static int -clientCanPackMoreRanges(const clientHttpRequest * http, HttpHdrRangeIter * i, - ssize_t size) +clientCanPackMoreRanges(const clientHttpRequest * http, HttpHdrRangeIter * i, ssize_t size) { /* first update "i" if needed */ if (!i->debt_size) { @@ -1545,8 +1537,7 @@ /* extracts "ranges" from buf and appends them to mb, updating all offsets and such */ /* returns true if we need more data */ static int -clientPackMoreRanges(clientHttpRequest * http, const char *buf, ssize_t size, - MemBuf * mb) +clientPackMoreRanges(clientHttpRequest * http, const char *buf, ssize_t size, MemBuf * mb) { HttpHdrRangeIter *i = &http->range_iter; /* offset in range specs does not count the prefix of an http msg */ @@ -1561,12 +1552,8 @@ start = i->spec->offset + i->spec->length - i->debt_size; debug(33, 3) ("clientPackMoreRanges: in: offset: %d size: %d\n", (int) body_off, size); - debug(33, 3) - - ("clientPackMoreRanges: out: start: %d spec[%d]: [%d, %d), len: %d debt: %d\n", - (int) start, (int) i->pos, i->spec->offset, - (int) (i->spec->offset + i->spec->length), i->spec->length, - i->debt_size); + debug(33, 3) ("clientPackMoreRanges: out: start: %d spec[%d]: [%d, %d), len: %d debt: %d\n", + (int) start, (int) i->pos, i->spec->offset, (int) (i->spec->offset + i->spec->length), i->spec->length, i->debt_size); assert(body_off <= start); /* we did not miss it */ /* skip up to start */ if (body_off + size > start) { @@ -1588,22 +1575,16 @@ } } assert(!i->debt_size == !i->spec); /* paranoid sync condition */ - debug(33, 3) - - - ("clientPackMoreRanges: buf exhausted: in: offset: %d size: %d need_more: %d\n", + debug(33, 3) ("clientPackMoreRanges: buf exhausted: in: offset: %d size: %d need_more: %d\n", (int) body_off, size, i->debt_size); if (i->debt_size) { - debug(33, 3) - ("clientPackMoreRanges: need more: spec[%d]: [%d, %d), len: %d\n", - (int) i->pos, i->spec->offset, - (int) (i->spec->offset + i->spec->length), i->spec->length); + debug(33, 3) ("clientPackMoreRanges: need more: spec[%d]: [%d, %d), len: %d\n", + (int) i->pos, i->spec->offset, (int) (i->spec->offset + i->spec->length), i->spec->length); /* skip the data we do not need if possible */ if (i->debt_size == i->spec->length) /* at the start of the cur. spec */ body_off = i->spec->offset; else - assert(body_off == - i->spec->offset + i->spec->length - i->debt_size); + assert(body_off == i->spec->offset + i->spec->length - i->debt_size); } else if (http->request->range->specs.count > 1) { /* put terminating boundary for multiparts */ clientPackTermBound(i->boundary, mb); @@ -1705,17 +1686,17 @@ assert(body_size >= 0); body_buf = buf + rep->hdr_sz; http->range_iter.prefix_size = rep->hdr_sz; - debug(33, 3) - - ("clientSendMoreData: Appending %d bytes after %d bytes of headers\n", + debug(33, 3) ("clientSendMoreData: Appending %d bytes after %d bytes of headers\n", body_size, rep->hdr_sz); - } else if (size < CLIENT_SOCK_SZ - && entry->store_status == STORE_PENDING) { + } else if (size < CLIENT_SOCK_SZ && entry->store_status == STORE_PENDING) { /* wait for more to arrive */ storeClientCopy(entry, http->out.offset + size, http->out.offset, - CLIENT_SOCK_SZ, buf, clientSendMoreData, http); + CLIENT_SOCK_SZ, + buf, + clientSendMoreData, + http); return; } /* reset range iterator */ @@ -1817,22 +1798,22 @@ http->out.offset, http->out.offset, CLIENT_SOCK_SZ, - memAllocate(MEM_CLIENT_SOCK_BUF), clientSendMoreData, http); + memAllocate(MEM_CLIENT_SOCK_BUF), + clientSendMoreData, + http); } } } static void -clientWriteComplete(int fd, char *bufnotused, size_t size, int errflag, - void *data) +clientWriteComplete(int fd, char *bufnotused, size_t size, int errflag, void *data) { clientHttpRequest *http = data; StoreEntry *entry = http->entry; int done; http->out.size += size; debug(33, 5) ("clientWriteComplete: FD %d, sz %d, err %d, off %d, len %d\n", - fd, size, errflag, (int) http->out.offset, - entry ? objectLen(entry) : 0); + fd, size, errflag, (int) http->out.offset, entry ? objectLen(entry) : 0); if (size > 0) { kb_incr(&Counter.client_http.kbytes_out, size); if (isTcpHit(http->log_type)) @@ -1857,8 +1838,7 @@ debug(33, 5) ("clientWriteComplete: closing, !done\n"); comm_close(fd); } else if (clientGotNotEnough(http)) { - debug(33, - 5) ("clientWriteComplete: client didn't get all it expected\n"); + debug(33, 5) ("clientWriteComplete: client didn't get all it expected\n"); comm_close(fd); } else if (http->request->flags.proxy_keepalive) { debug(33, 5) ("clientWriteComplete: FD %d Keeping Alive\n", fd); @@ -1877,7 +1857,9 @@ http->out.offset, http->out.offset, CLIENT_SOCK_SZ, - memAllocate(MEM_CLIENT_SOCK_BUF), clientSendMoreData, http); + memAllocate(MEM_CLIENT_SOCK_BUF), + clientSendMoreData, + http); } } @@ -1987,7 +1969,8 @@ int fd = http->conn->fd; HttpReply *rep; debug(33, 4) ("clientProcessRequest: %s '%s'\n", - RequestMethodStr[r->method], url); + RequestMethodStr[r->method], + url); if (r->method == METHOD_CONNECT) { http->log_type = LOG_TCP_MISS; sslStart(fd, url, r, &http->out.size); @@ -1997,8 +1980,7 @@ return; } else if (r->method == METHOD_TRACE) { if (r->max_forwards == 0) { - http->entry = - clientCreateStoreEntry(http, r->method, null_request_flags); + http->entry = clientCreateStoreEntry(http, r->method, null_request_flags); storeReleaseRequest(http->entry); storeBuffer(http->entry); rep = httpReplyCreate(); @@ -2020,7 +2002,8 @@ http->log_type = clientProcessRequest2(http); } debug(33, 4) ("clientProcessRequest: %s for '%s'\n", - log_tags[http->log_type], http->uri); + log_tags[http->log_type], + http->uri); http->out.offset = 0; if (NULL != http->entry) { storeLockObject(http->entry); @@ -2034,7 +2017,9 @@ http->out.offset, http->out.offset, CLIENT_SOCK_SZ, - memAllocate(MEM_CLIENT_SOCK_BUF), clientCacheHit, http); + memAllocate(MEM_CLIENT_SOCK_BUF), + clientCacheHit, + http); } else { /* MISS CASE */ clientProcessMiss(http); @@ -2058,8 +2043,7 @@ */ if (http->entry) { if (EBIT_TEST(http->entry->flags, ENTRY_SPECIAL)) { - debug(33, 0) ("clientProcessMiss: miss on a special object (%s).\n", - url); + debug(33, 0) ("clientProcessMiss: miss on a special object (%s).\n", url); debug(33, 0) ("\tlog_type = %s\n", log_tags[http->log_type]); storeEntryDump(http->entry, 1); } @@ -2079,8 +2063,7 @@ err = errorCon(ERR_ACCESS_DENIED, HTTP_FORBIDDEN); err->request = requestLink(r); err->src_addr = http->conn->peer.sin_addr; - http->entry = - clientCreateStoreEntry(http, r->method, null_request_flags); + http->entry = clientCreateStoreEntry(http, r->method, null_request_flags); errorAppendEntry(http->entry, err); return; } @@ -2169,8 +2152,7 @@ /* Barf on NULL characters in the headers */ if (strlen(inbuf) != req_sz) { - debug(33, - 1) ("parseHttpRequest: Requestheader contains NULL characters\n"); + debug(33, 1) ("parseHttpRequest: Requestheader contains NULL characters\n"); return parseHttpRequestAbort(conn, "error:invalid-request"); } /* Look for request method */ @@ -2251,8 +2233,7 @@ *(*prefix_p + prefix_sz) = '\0'; dlinkAdd(http, &http->active, &ClientActiveRequests); - debug(33, 5) ("parseHttpRequest: Request Header is\n%s\n", - (*prefix_p) + *req_line_sz_p); + debug(33, 5) ("parseHttpRequest: Request Header is\n%s\n", (*prefix_p) + *req_line_sz_p); if ((t = strchr(url, '#'))) /* remove HTML anchors */ *t = '\0'; @@ -2283,9 +2264,11 @@ *q++ = '\0'; vport = atoi(q); } - url_sz = strlen(url) + 32 + Config.appendDomainLen + strlen(t); + url_sz = strlen(url) + 32 + Config.appendDomainLen + + strlen(t); http->uri = xcalloc(url_sz, 1); - snprintf(http->uri, url_sz, "http://%s:%d%s", t, vport, url); + snprintf(http->uri, url_sz, "http://%s:%d%s", + t, vport, url); } else if (vhost_mode) { int vport; /* Put the local socket IP address as the hostname */ @@ -2310,22 +2293,22 @@ } if (ioctl(natfd, SIOCGNATL, &natLookup) < 0) { if (errno != ESRCH) { - debug(50, 1) - - ("parseHttpRequest: NAT lookup failed: ioctl(SIOCGNATL)\n"); + debug(50, 1) ("parseHttpRequest: NAT lookup failed: ioctl(SIOCGNATL)\n"); close(natfd); natfd = -1; - return parseHttpRequestAbort(conn, - "error:nat-lookup-failed"); + return parseHttpRequestAbort(conn, "error:nat-lookup-failed"); } else snprintf(http->uri, url_sz, "http://%s:%d%s", - inet_ntoa(http->conn->me.sin_addr), vport, url); + inet_ntoa(http->conn->me.sin_addr), + vport, url); } else snprintf(http->uri, url_sz, "http://%s:%d%s", - inet_ntoa(natLookup.nl_realip), vport, url); + inet_ntoa(natLookup.nl_realip), + vport, url); #else snprintf(http->uri, url_sz, "http://%s:%d%s", - inet_ntoa(http->conn->me.sin_addr), vport, url); + inet_ntoa(http->conn->me.sin_addr), + vport, url); #endif debug(33, 5) ("VHOST REWRITE: '%s'\n", http->uri); } else { @@ -2414,8 +2397,7 @@ comm_close(fd); return; } else if (conn->in.offset == 0) { - debug(50, 2) ("clientReadRequest: FD %d: no data to process: %s\n", - fd, xstrerror()); + debug(50, 2) ("clientReadRequest: FD %d: no data to process: %s\n", fd, xstrerror()); return; } /* Continue to process previously read data */ @@ -2436,18 +2418,17 @@ /* Limit the number of concurrent requests to 2 */ for (H = &conn->chr, nrequests = 0; *H; H = &(*H)->next, nrequests++); if (nrequests >= 2) { - debug(33, 3) - ("clientReadRequest: FD %d max concurrent requests reached\n", fd); - debug(33, 5) - - ("clientReadRequest: FD %d defering new request until one is done\n", - fd); + debug(33, 3) ("clientReadRequest: FD %d max concurrent requests reached\n", fd); + debug(33, 5) ("clientReadRequest: FD %d defering new request until one is done\n", fd); conn->defer.until = squid_curtime + 100; /* Reset when a request is complete */ break; } /* Process request */ http = parseHttpRequest(conn, - &method, &parser_return_code, &prefix, &req_line_sz); + &method, + &parser_return_code, + &prefix, + &req_line_sz); if (!http) safe_free(prefix); if (http) { @@ -2460,8 +2441,7 @@ * data to the beginning */ if (conn->in.offset > 0) - xmemmove(conn->in.buf, conn->in.buf + http->req_sz, - conn->in.offset); + xmemmove(conn->in.buf, conn->in.buf + http->req_sz, conn->in.offset); /* add to the client request queue */ for (H = &conn->chr; *H; H = &(*H)->next); *H = http; @@ -2471,8 +2451,7 @@ debug(33, 1) ("clientReadRequest: FD %d Invalid Request\n", fd); err = errorCon(ERR_INVALID_REQ, HTTP_BAD_REQUEST); err->request_hdrs = xstrdup(conn->in.buf); - http->entry = - clientCreateStoreEntry(http, method, null_request_flags); + http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); safe_free(prefix); break; @@ -2483,8 +2462,7 @@ err->src_addr = conn->peer.sin_addr; err->url = xstrdup(http->uri); http->al.http.code = err->http_status; - http->entry = - clientCreateStoreEntry(http, method, null_request_flags); + http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); safe_free(prefix); break; @@ -2500,12 +2478,10 @@ if (!http->flags.internal) { if (internalCheck(strBuf(request->urlpath))) { if (internalHostnameIs(request->host) && - request->port == - ntohs(Config.Sockaddr.http->s.sin_port)) { + request->port == ntohs(Config.Sockaddr.http->s.sin_port)) { http->flags.internal = 1; } else if (internalStaticCheck(strBuf(request->urlpath))) { - xstrncpy(request->host, internalHostname(), - SQUIDHOSTNAMELEN); + xstrncpy(request->host, internalHostname(), SQUIDHOSTNAMELEN); request->port = ntohs(Config.Sockaddr.http->s.sin_port); http->flags.internal = 1; } @@ -2530,9 +2506,7 @@ err->request = requestLink(request); request->flags.proxy_keepalive = 0; http->al.http.code = err->http_status; - http->entry = - clientCreateStoreEntry(http, request->method, - null_request_flags); + http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); errorAppendEntry(http->entry, err); break; } @@ -2541,9 +2515,7 @@ err->src_addr = conn->peer.sin_addr; err->request = requestLink(request); http->al.http.code = err->http_status; - http->entry = - clientCreateStoreEntry(http, request->method, - null_request_flags); + http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); errorAppendEntry(http->entry, err); break; } @@ -2568,8 +2540,7 @@ xmemcpy(request->body, conn->in.buf, request->body_sz); conn->in.offset -= copy_len; if (conn->in.offset) - xmemmove(conn->in.buf, conn->in.buf + copy_len, - conn->in.offset); + xmemmove(conn->in.buf, conn->in.buf + copy_len, conn->in.offset); } /* * if we didn't get the full body now, then more will @@ -2602,18 +2573,14 @@ /* The request is too large to handle */ debug(33, 1) ("Request header is too large (%d bytes)\n", (int) conn->in.offset); - debug(33, - 1) ("Config 'request_header_max_size'= %d bytes.\n", + debug(33, 1) ("Config 'request_header_max_size'= %d bytes.\n", Config.maxRequestHeaderSize); err = errorCon(ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE); - http = - parseHttpRequestAbort(conn, "error:request-too-large"); + http = parseHttpRequestAbort(conn, "error:request-too-large"); /* add to the client request queue */ for (H = &conn->chr; *H; H = &(*H)->next); *H = http; - http->entry = - clientCreateStoreEntry(http, METHOD_NONE, - null_request_flags); + http->entry = clientCreateStoreEntry(http, METHOD_NONE, null_request_flags); errorAppendEntry(http->entry, err); return; } @@ -2621,8 +2588,7 @@ conn->in.size += REQUEST_BUF_SIZE; conn->in.buf = xrealloc(conn->in.buf, conn->in.size); /* XXX account conn->in.buf */ - debug(33, - 3) ("Handling a large request, offset=%d inbufsize=%d\n", + debug(33, 3) ("Handling a large request, offset=%d inbufsize=%d\n", (int) conn->in.offset, conn->in.size); k = conn->in.size - 1 - conn->in.offset; } @@ -2680,8 +2646,7 @@ if (fdNFree() >= RESERVED_FD) return 0; if (last_warn + 15 < squid_curtime) { - debug(33, - 0) ("WARNING! Your cache is running out of filedescriptors\n"); + debug(33, 0) ("WARNING! Your cache is running out of filedescriptors\n"); last_warn = squid_curtime; } return 1; @@ -2811,8 +2776,7 @@ static int clientGotNotEnough(clientHttpRequest * http) { - int cl = - httpReplyBodySize(http->request->method, http->entry->mem_obj->reply); + int cl = httpReplyBodySize(http->request->method, http->entry->mem_obj->reply); int hs = http->entry->mem_obj->reply->hdr_sz; assert(cl >= 0); if (http->out.offset < cl + hs) @@ -2876,8 +2840,12 @@ continue; } enter_suid(); - fd = comm_open(SOCK_STREAM, 0, s->s.sin_addr, - ntohs(s->s.sin_port), COMM_NONBLOCKING, "HTTP Socket"); + fd = comm_open(SOCK_STREAM, + 0, + s->s.sin_addr, + ntohs(s->s.sin_port), + COMM_NONBLOCKING, + "HTTP Socket"); leave_suid(); if (fd < 0) continue; @@ -2889,7 +2857,9 @@ */ commSetDefer(fd, httpAcceptDefer, NULL); debug(1, 1) ("Accepting HTTP connections at %s, port %d, FD %d.\n", - inet_ntoa(s->s.sin_addr), (int) ntohs(s->s.sin_port), fd); + inet_ntoa(s->s.sin_addr), + (int) ntohs(s->s.sin_port), + fd); HttpSockets[NHttpSockets++] = fd; } if (NHttpSockets < 1)