The unified diff between revisions [24a6de80..] and [642aa1fd..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'src/cache_cf.c'
#
#
# patch "src/cache_cf.c"
# from [fb9d5934b7aa8024a96c7917b89d4ccb3cda8e4c]
# to [3de9d671c5a5209cb03e46039ab088a115569e12]
#
============================================================
--- src/cache_cf.c fb9d5934b7aa8024a96c7917b89d4ccb3cda8e4c
+++ src/cache_cf.c 3de9d671c5a5209cb03e46039ab088a115569e12
@@ -60,6 +60,14 @@ static void dump_cachedir_option_maxsize
static void dump_cachedir_option_readonly(StoreEntry * e, const char *option, SwapDir * sd);
static void parse_cachedir_option_maxsize(SwapDir * sd, const char *option, const char *value, int reconfiguring);
static void dump_cachedir_option_maxsize(StoreEntry * e, const char *option, SwapDir * sd);
+static void parse_logformat(logformat ** logformat_definitions);
+static void parse_access_log(customlog ** customlog_definitions);
+static void dump_logformat(StoreEntry * entry, const char *name, logformat * definitions);
+static void dump_access_log(StoreEntry * entry, const char *name, customlog * definitions);
+static void free_logformat(logformat ** definitions);
+static void free_access_log(customlog ** definitions);
+
+
static struct cache_dir_option common_cachedir_options[] =
{
{"read-only", parse_cachedir_option_readonly, dump_cachedir_option_readonly},
@@ -2634,3 +2642,144 @@ strtokFile(void)
return t;
}
}
+
+static void
+parse_logformat(logformat ** logformat_definitions)
+{
+ logformat *nlf;
+ char *name, *def;
+
+ if ((name = strtok(NULL, w_space)) == NULL)
+ self_destruct();
+ if ((def = strtok(NULL, "\r\n")) == NULL)
+ self_destruct();
+
+ debug(3, 1) ("Logformat for '%s' is '%s'\n", name, def);
+
+ nlf = xcalloc(1, sizeof(logformat));
+ nlf->name = xstrdup(name);
+ if (!accessLogParseLogFormat(&nlf->format, def))
+ self_destruct();
+ nlf->next = *logformat_definitions;
+ *logformat_definitions = nlf;
+}
+
+static void
+parse_access_log(customlog ** logs)
+{
+ const char *filename, *logdef_name;
+ customlog *cl;
+ logformat *lf;
+
+ cl = xcalloc(1, sizeof(*cl));
+
+ if ((filename = strtok(NULL, w_space)) == NULL)
+ self_destruct();
+
+ if (strcmp(filename, "none") == 0) {
+ cl->type = CLF_NONE;
+ goto done;
+ }
+ if ((logdef_name = strtok(NULL, w_space)) == NULL)
+ logdef_name = "auto";
+
+ debug(3, 9) ("Log definition name '%s' file '%s'\n", logdef_name, filename);
+
+ cl->filename = xstrdup(filename);
+
+ /* look for the definition pointer corresponding to this name */
+ lf = Config.Log.logformats;
+ while (lf != NULL) {
+ debug(3, 9) ("Comparing against '%s'\n", lf->name);
+ if (strcmp(lf->name, logdef_name) == 0)
+ break;
+ lf = lf->next;
+ }
+ if (lf != NULL) {
+ cl->type = CLF_CUSTOM;
+ cl->logFormat = lf;
+ } else if (strcmp(logdef_name, "auto") == 0) {
+ cl->type = CLF_AUTO;
+ } else if (strcmp(logdef_name, "squid") == 0) {
+ cl->type = CLF_SQUID;
+ } else if (strcmp(logdef_name, "common") == 0) {
+ cl->type = CLF_COMMON;
+ } else {
+ debug(3, 0) ("Log format '%s' is not defined\n", logdef_name);
+ self_destruct();
+ }
+
+ done:
+ aclParseAclList(&cl->aclList);
+
+ while (*logs)
+ logs = &(*logs)->next;
+ *logs = cl;
+}
+
+static void
+dump_logformat(StoreEntry * entry, const char *name, logformat * definitions)
+{
+ accessLogDumpLogFormat(entry, name, definitions);
+}
+
+static void
+dump_access_log(StoreEntry * entry, const char *name, customlog * logs)
+{
+ customlog *log;
+ for (log = logs; log; log = log->next) {
+ storeAppendPrintf(entry, "%s ", name);
+ switch (log->type) {
+ case CLF_CUSTOM:
+ storeAppendPrintf(entry, "%s %s", log->filename, log->logFormat->name);
+ break;
+ case CLF_NONE:
+ storeAppendPrintf(entry, "none");
+ break;
+ case CLF_SQUID:
+ storeAppendPrintf(entry, "%s squid", log->filename);
+ break;
+ case CLF_COMMON:
+ storeAppendPrintf(entry, "%s squid", log->filename);
+ break;
+ case CLF_AUTO:
+ if (log->aclList)
+ storeAppendPrintf(entry, "%s auto", log->filename);
+ else
+ storeAppendPrintf(entry, "%s", log->filename);
+ break;
+ case CLF_UNKNOWN:
+ break;
+ }
+ if (log->aclList)
+ dump_acl_list(entry, log->aclList);
+ storeAppendPrintf(entry, "\n");
+ }
+}
+
+static void
+free_logformat(logformat ** definitions)
+{
+ while (*definitions) {
+ logformat *format = *definitions;
+ *definitions = format->next;
+ accessLogFreeLogFormat(&format->format);
+ xfree(format);
+ }
+}
+
+static void
+free_access_log(customlog ** definitions)
+{
+ while (*definitions) {
+ customlog *log = *definitions;
+ *definitions = log->next;
+
+ log->logFormat = NULL;
+ log->type = CLF_UNKNOWN;
+ if (log->aclList)
+ aclDestroyAclList(&log->aclList);
+ safe_free(log->filename);
+ xfree(log);
+ }
+}