--------------------- PatchSet 5850 Date: 2003/08/02 02:06:24 Author: hno Branch: customlog-2_5 Tag: (none) Log: MFC: Fix config file dumps and other minor fixes Members: src/access_log.c:1.15.6.3.2.3->1.15.6.3.2.4 Index: squid/src/access_log.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/access_log.c,v retrieving revision 1.15.6.3.2.3 retrieving revision 1.15.6.3.2.4 diff -u -r1.15.6.3.2.3 -r1.15.6.3.2.4 --- squid/src/access_log.c 30 Jul 2003 15:23:21 -0000 1.15.6.3.2.3 +++ squid/src/access_log.c 2 Aug 2003 02:06:24 -0000 1.15.6.3.2.4 @@ -1,6 +1,6 @@ /* - * $Id: access_log.c,v 1.15.6.3.2.3 2003/07/30 15:23:21 hno Exp $ + * $Id: access_log.c,v 1.15.6.3.2.4 2003/08/02 02:06:24 hno Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -647,7 +647,7 @@ out = tmp; } if (out && *out) { - if (quote) { + if (quote || fmt->quote != LOG_QUOTE_NONE) { char *newout = NULL; int newfree = 0; switch (fmt->quote) { @@ -798,11 +798,15 @@ else lt->data.header.separator = ','; lt->data.header.element = cp; - lt->type += 1; + lt->type = (lt->type == LFT_REQUEST_HEADER) ? + LFT_REQUEST_HEADER_ELEM : + LFT_REPLY_HEADER_ELEM; } lt->data.header.header = header; } else { - lt->type += 2; + lt->type = (lt->type == LFT_REQUEST_HEADER) ? + LFT_REQUEST_ALL_HEADERS : + LFT_REPLY_ALL_HEADERS; Config.onoff.log_mime_hdrs = 1; } break; @@ -863,26 +867,41 @@ for (format = definitions; format; format = format->next) { debug(46, 0) ("Dumping logformat definition for %s\n", format->name); storeAppendPrintf(entry, "logformat %s ", format->name); - t = format->format; - while (t != NULL) { + for (t = format->format; t; t = t->next) { if (t->type == LFT_STRING) storeAppendPrintf(entry, "%s", t->data.string); else { - char arg[256]; - arg[0] = '\0'; - switch (t->type) { + char argbuf[256]; + char *arg = NULL; + logformat_bcode_t type = t->type; + + switch (type) { /* special cases */ case LFT_STRING: break; case LFT_REQUEST_HEADER_ELEM: case LFT_REPLY_HEADER_ELEM: if (t->data.header.separator != ',') - snprintf(arg, sizeof(arg), "%s:%c%s", t->data.header.header, t->data.header.separator, t->data.header.element); + snprintf(argbuf, sizeof(argbuf), "%s:%c%s", t->data.header.header, t->data.header.separator, t->data.header.element); else - snprintf(arg, sizeof(arg), "%s:%s", t->data.header.header, t->data.header.element); + snprintf(argbuf, sizeof(argbuf), "%s:%s", t->data.header.header, t->data.header.element); + + arg = argbuf; + type = (type == LFT_REQUEST_HEADER_ELEM) ? + LFT_REQUEST_HEADER : + LFT_REPLY_HEADER; + break; + + case LFT_REQUEST_ALL_HEADERS: + case LFT_REPLY_ALL_HEADERS: + type = (type == LFT_REQUEST_ALL_HEADERS) ? + LFT_REQUEST_HEADER : + LFT_REPLY_HEADER; + break; + default: if (t->data.string) - xstrncpy(arg, t->data.string, sizeof(arg)); + arg = t->data.string; break; } storeAppend(entry, "%", 1); @@ -904,11 +923,13 @@ } if (t->left) storeAppend(entry, "-", 1); + if (t->zero) + storeAppend(entry, "0", 1); if (t->width) storeAppendPrintf(entry, "%d", (int) t->width); if (t->precision) storeAppendPrintf(entry, ".%d", (int) t->precision); - if (*arg) + if (arg) storeAppendPrintf(entry, "{%s}", arg); for (te = logformat_token_table; te->config != NULL; te++) { if (te->token_type == t->type) { @@ -916,11 +937,13 @@ break; } } + if (t->space) + storeAppend(entry, " ", 1); assert(te->config != NULL); - break; } } } + storeAppend(entry, "\n", 1); } void