=== modified file 'src/client_db.cc' --- src/client_db.cc 2011-08-04 03:21:06 +0000 +++ src/client_db.cc 2011-09-11 06:40:41 +0000 @@ -34,7 +34,7 @@ #include "squid.h" #include "event.h" -#include "format/Tokens.h" +#include "format/Token.h" #include "ClientInfo.h" #include "ip/Address.h" #include "mgr/Registration.h" === modified file 'src/client_side_reply.cc' --- src/client_side_reply.cc 2011-08-10 15:54:51 +0000 +++ src/client_side_reply.cc 2011-09-14 06:26:24 +0000 @@ -55,7 +55,7 @@ #endif #include "fde.h" #include "forward.h" -#include "format/Tokens.h" +#include "format/Token.h" #include "HttpReply.h" #include "HttpRequest.h" #include "ip/QosConfig.h" === modified file 'src/client_side_request.cc' --- src/client_side_request.cc 2011-11-04 23:28:49 +0000 +++ src/client_side_request.cc 2011-11-04 23:30:16 +0000 @@ -66,7 +66,7 @@ #include "comm/Write.h" #include "compat/inet_pton.h" #include "fde.h" -#include "format/Tokens.h" +#include "format/Token.h" #include "HttpHdrCc.h" #include "HttpReply.h" #include "HttpRequest.h" === added file 'src/format/ByteCode.h' --- src/format/ByteCode.h 1970-01-01 00:00:00 +0000 +++ src/format/ByteCode.h 2011-09-23 00:58:53 +0000 @@ -0,0 +1,209 @@ +#ifndef _SQUID_FMT_BYTECODE_H +#define _SQUID_FMT_BYTECODE_H + +/* + * Squid configuration allows users to define custom formats in + * several components. + * - logging + * - external ACL input + * - deny page URL + * + * These enumerations and classes define the API for parsing of + * format directives to define these patterns. Along with output + * functionality to produce formatted buffers. + */ + +namespace Format +{ + +/* + * Bytecodes for the configureable format stuff + */ +typedef enum { + LFT_NONE, /* dummy */ + + /* arbitrary string between tokens */ + LFT_STRING, + + /* client TCP connection remote end details */ + LFT_CLIENT_IP_ADDRESS, + LFT_CLIENT_FQDN, + LFT_CLIENT_PORT, + LFT_CLIENT_EUI, + + /* client TCP connection local end details */ + LFT_CLIENT_LOCAL_IP, + LFT_CLIENT_LOCAL_PORT, + /*LFT_CLIENT_LOCAL_FQDN, (rDNS) */ + + /* client connection local squid.conf details */ + LFT_LOCAL_LISTENING_IP, + LFT_LOCAL_LISTENING_PORT, + /*LFT_LOCAL_LISTENING_NAME, (myportname) */ + + /* server TCP connection remote end details */ + LFT_SERVER_IP_ADDRESS, + LFT_SERVER_FQDN_OR_PEER_NAME, + LFT_SERVER_PORT, + + /* server TCP connection local end details */ + LFT_SERVER_LOCAL_IP, + LFT_SERVER_LOCAL_IP_OLD_27, + LFT_SERVER_LOCAL_PORT, + + /* original Request-Line details recieved from client */ + LFT_CLIENT_REQ_METHOD, + LFT_CLIENT_REQ_URI, + LFT_CLIENT_REQ_URLPATH, + /* LFT_CLIENT_REQ_QUERY, */ + LFT_CLIENT_REQ_VERSION, + + /* Request-Line details recieved from client (legacy, filtered) */ + LFT_REQUEST_METHOD, + LFT_REQUEST_URI, + LFT_REQUEST_URLPATH_OLD_31, + /*LFT_REQUEST_QUERY, */ + LFT_REQUEST_VERSION_OLD_2X, + LFT_REQUEST_VERSION, + + /* request header details pre-adaptation */ + LFT_REQUEST_HEADER, + LFT_REQUEST_HEADER_ELEM, + LFT_REQUEST_ALL_HEADERS, + + /* request header details post-adaptation */ + LFT_ADAPTED_REQUEST_HEADER, + LFT_ADAPTED_REQUEST_HEADER_ELEM, + LFT_ADAPTED_REQUEST_ALL_HEADERS, + + /* Request-Line details sent to the server/peer */ + LFT_SERVER_REQ_METHOD, + LFT_SERVER_REQ_URI, + LFT_SERVER_REQ_URLPATH, + /*LFT_SERVER_REQ_QUERY, */ + LFT_SERVER_REQ_VERSION, + + /* request meta details */ + LFT_REQUEST_SIZE_TOTAL, + /*LFT_REQUEST_SIZE_LINE, */ + LFT_REQUEST_SIZE_HEADERS, + /*LFT_REQUEST_SIZE_BODY, */ + /*LFT_REQUEST_SIZE_BODY_NO_TE, */ + + /* original Status-Line details recieved from server */ + // XXX: todo + + /* Status-Line details sent to the client */ + // XXX: todo + + /* response Status-Line details (legacy, filtered) */ + LFT_HTTP_SENT_STATUS_CODE_OLD_30, + LFT_HTTP_SENT_STATUS_CODE, + LFT_HTTP_RECEIVED_STATUS_CODE, + /*LFT_HTTP_STATUS, */ + LFT_HTTP_BODY_BYTES_READ, + + /* response header details pre-adaptation */ + LFT_REPLY_HEADER, + LFT_REPLY_HEADER_ELEM, + LFT_REPLY_ALL_HEADERS, + + /* response header details post-adaptation */ + /* LFT_ADAPTED_REPLY_HEADER, */ + /* LFT_ADAPTED_REPLY_HEADER_ELEM, */ + /* LFT_ADAPTED_REPLY_ALL_HEADERS, */ + + /* response meta details */ + LFT_REPLY_SIZE_TOTAL, + LFT_REPLY_HIGHOFFSET, + LFT_REPLY_OBJECTSIZE, + /*LFT_REPLY_SIZE_LINE, */ + LFT_REPLY_SIZE_HEADERS, + /*LFT_REPLY_SIZE_BODY, */ + /*LFT_REPLY_SIZE_BODY_NO_TE, */ + + /* client credentials */ + LFT_USER_NAME, /* any source will do */ + LFT_USER_LOGIN, + LFT_USER_IDENT, + /*LFT_USER_REALM, */ + /*LFT_USER_SCHEME, */ + LFT_USER_EXTERNAL, + /* LFT_USER_SSL_CERT, */ + + /* global time details */ + LFT_TIME_SECONDS_SINCE_EPOCH, + LFT_TIME_SUBSECOND, + LFT_TIME_LOCALTIME, + LFT_TIME_GMT, + + /* processing time details */ + LFT_TIME_TO_HANDLE_REQUEST, + LFT_PEER_RESPONSE_TIME, + LFT_TOTAL_SERVER_SIDE_RESPONSE_TIME, + LFT_DNS_WAIT_TIME, + + /* Squid internal processing details */ + LFT_SQUID_STATUS, + LFT_SQUID_ERROR, + LFT_SQUID_ERROR_DETAIL, + LFT_SQUID_HIERARCHY, + + LFT_MIME_TYPE, + LFT_TAG, + LFT_IO_SIZE_TOTAL, + LFT_EXT_LOG, + + LFT_SEQUENCE_NUMBER, + +#if USE_ADAPTATION + LFT_ADAPTATION_SUM_XACT_TIMES, + LFT_ADAPTATION_ALL_XACT_TIMES, + LFT_ADAPTATION_LAST_HEADER, + LFT_ADAPTATION_LAST_HEADER_ELEM, + LFT_ADAPTATION_LAST_ALL_HEADERS, +#endif + +#if ICAP_CLIENT + + LFT_ICAP_TOTAL_TIME, + + LFT_ICAP_ADDR, + LFT_ICAP_SERV_NAME, + LFT_ICAP_REQUEST_URI, + LFT_ICAP_REQUEST_METHOD, + LFT_ICAP_BYTES_SENT, + LFT_ICAP_BYTES_READ, + LFT_ICAP_BODY_BYTES_READ, + + LFT_ICAP_REQ_HEADER, + LFT_ICAP_REQ_HEADER_ELEM, + LFT_ICAP_REQ_ALL_HEADERS, + + LFT_ICAP_REP_HEADER, + LFT_ICAP_REP_HEADER_ELEM, + LFT_ICAP_REP_ALL_HEADERS, + + LFT_ICAP_TR_RESPONSE_TIME, + LFT_ICAP_IO_TIME, + LFT_ICAP_OUTCOME, + LFT_ICAP_STATUS_CODE, +#endif + + LFT_PERCENT /* special string cases for escaped chars */ +} ByteCode_t; + +/// Quoting style for a format output. +enum Quoting { + LOG_QUOTE_NONE = 0, + LOG_QUOTE_QUOTES, + LOG_QUOTE_MIMEBLOB, + LOG_QUOTE_URL, + LOG_QUOTE_RAW +}; + +extern const char *log_tags[]; + +} // namespace Format + +#endif /* _SQUID_FMT_BYTECODE_H */ === added file 'src/format/Config.cc' --- src/format/Config.cc 1970-01-01 00:00:00 +0000 +++ src/format/Config.cc 2011-11-05 11:08:25 +0000 @@ -0,0 +1,44 @@ +#include "config.h" +#include "format/Config.h" +#include "protos.h" +#include + +Format::FmtConfig Format::TheConfig; + +void +Format::FmtConfig::parseFormats() +{ + char *name, *def; + + if ((name = strtok(NULL, w_space)) == NULL) + self_destruct(); + + if ((def = strtok(NULL, "\r\n")) == NULL) { + self_destruct(); + return; + } + + debugs(3, 2, "Custom Format for '" << name << "' is '" << def << "'"); + + Format *nlf = new Format(name); + + if (!nlf->parse(def)) { + self_destruct(); + return; + } + + // add to global config list + nlf->next = formats; + formats = nlf; +} + +void +Format::FmtConfig::registerTokens(const String &nsName, TokenTableEntry const *tokenArray) +{ +// assert(tokenArray != NULL); + + if (tokenArray != NULL) + tokens.push_back(TokenNamespace(nsName, tokenArray)); + else + debugs(0,0, "BUG: format tokens for '" << nsName << "' missing!"); +} === added file 'src/format/Config.h' --- src/format/Config.h 1970-01-01 00:00:00 +0000 +++ src/format/Config.h 2011-11-05 11:08:10 +0000 @@ -0,0 +1,69 @@ +#ifndef SQUID_SRC_FORMAT_CONFIG_H +#define SQUID_SRC_FORMAT_CONFIG_H + +#include "format/Format.h" +#include "format/TokenTableEntry.h" +#include "SquidString.h" +#include + +class StoreEntry; + +namespace Format +{ + +/// A namespace or 'set' of tokens +/// components register their namespace prefix and an array of tokens +/// which can then be embeded in any format. +class TokenNamespace +{ +public: + explicit TokenNamespace(const String &nsName, TokenTableEntry const *tSet) : prefix(nsName), tokenSet(tSet) {}; + ~TokenNamespace() {}; + + /// prefix namespace name (excluding '::') + String prefix; + + /// array of tokens inside this namespace + TokenTableEntry const *tokenSet; +}; + +class FmtConfig +{ +public: + void parseFormats(); + void dumpFormats(StoreEntry *e, const char *name) { + formats->dump(e, name); + } + + /* Register a namespace set of tokens to be accepted by the format parser. + * Multiple arrays can be registered, they will be scanned for + * in order registered. So care needs to be taken that arrays registered + * first do not overlap or consume tokens registered later for a namespace. + */ + void registerTokens(const String &nsName, TokenTableEntry const *tokenArray); + + /// Linked list of custom formats + Format *formats; + + /// list of token namespaces registered + std::list tokens; + +#if USE_ADAPTATION + bool hasAdaptToken; +#endif + +#if ICAP_CLIENT + bool hasIcapToken; +#endif +}; + +extern FmtConfig TheConfig; + +} // namespace Format + +// Legacy parsing wrappers +#define parse_format(X) (X)->parseFormats() +#define free_format(X) do{ delete (*X).formats; (*X).formats=NULL; }while(false) +#define dump_format(E,N,D) (D).dumpFormats((E),(N)) + +#endif === modified file 'src/format/Format.cc' --- src/format/Format.cc 2011-10-14 01:49:17 +0000 +++ src/format/Format.cc 2011-10-16 05:00:24 +0000 @@ -5,7 +5,7 @@ #include "errorpage.h" #include "format/Format.h" #include "format/Quoting.h" -#include "format/Tokens.h" +#include "format/Token.h" #include "HttpRequest.h" #include "MemBuf.h" #include "rfc1738.h" @@ -516,7 +516,7 @@ break; #if USE_ADAPTATION - case LTF_ADAPTATION_SUM_XACT_TIMES: + case LFT_ADAPTATION_SUM_XACT_TIMES: if (al->request) { Adaptation::History::Pointer ah = al->request->adaptHistory(); if (ah != NULL) @@ -525,7 +525,7 @@ } break; - case LTF_ADAPTATION_ALL_XACT_TIMES: + case LFT_ADAPTATION_ALL_XACT_TIMES: if (al->request) { Adaptation::History::Pointer ah = al->request->adaptHistory(); if (ah != NULL) === modified file 'src/format/Makefile.am' --- src/format/Makefile.am 2011-08-04 03:21:06 +0000 +++ src/format/Makefile.am 2011-09-11 06:58:13 +0000 @@ -4,10 +4,14 @@ noinst_LTLIBRARIES = libformat.la libformat_la_SOURCES = \ + ByteCode.h \ + Config.cc \ + Config.h \ Format.cc \ Format.h \ Quoting.cc \ Quoting.h \ - Tokens.cc \ - Tokens.h + Token.cc \ + Token.h \ + TokenTableEntry.h === renamed file 'src/format/Tokens.cc' => 'src/format/Token.cc' --- src/format/Tokens.cc 2011-10-13 17:05:25 +0000 +++ src/format/Token.cc 2011-11-05 11:07:28 +0000 @@ -1,5 +1,6 @@ #include "config.h" -#include "format/Tokens.h" +#include "format/Config.h" +#include "format/Token.h" #include "Store.h" const char *Format::log_tags[] = { @@ -36,7 +37,7 @@ { /// 1-char tokens. -static struct TokenTableEntry TokenTable1C[] = { +static TokenTableEntry TokenTable1C[] = { {">a", LFT_CLIENT_IP_ADDRESS}, {">p", LFT_CLIENT_PORT}, @@ -59,7 +60,7 @@ }; /// 2-char tokens -static struct TokenTableEntry TokenTable2C[] = { +static TokenTableEntry TokenTable2C[] = { {">la", LFT_CLIENT_LOCAL_IP}, {"la", LFT_LOCAL_LISTENING_IP}, @@ -143,19 +144,26 @@ {NULL, LFT_NONE} /* this must be last */ }; +/// Miscellaneous >2 byte tokens +static TokenTableEntry TokenTableMisc[] = { + {">eui", LFT_CLIENT_EUI}, + {"err_code", LFT_SQUID_ERROR }, + {"err_detail", LFT_SQUID_ERROR_DETAIL }, + {NULL, LFT_NONE} /* this must be last */ +}; + #if USE_ADAPTATION -/// Adaptation (adapt::) tokens -static struct TokenTableEntry TokenTableAdapt[] = { - {"all_trs", LTF_ADAPTATION_ALL_XACT_TIMES}, - {"sum_trs", LTF_ADAPTATION_SUM_XACT_TIMES}, +static TokenTableEntry TokenTableAdapt[] = { + {"all_trs", LFT_ADAPTATION_ALL_XACT_TIMES}, + {"sum_trs", LFT_ADAPTATION_SUM_XACT_TIMES}, {"st", LFT_ICAP_BYTES_SENT}, - {"st", LFT_ICAP_BYTES_SENT}, + {"h", LFT_ICAP_REQ_HEADER}, {"2 byte tokens -static struct TokenTableEntry TokenTableMisc[] = { - {">eui", LFT_CLIENT_EUI}, - {"err_code", LFT_SQUID_ERROR }, - {"err_detail", LFT_SQUID_ERROR_DETAIL }, - {NULL, LFT_NONE} /* this must be last */ -}; - } // namespace Format +/// Register all components custom format tokens +void +Format::Token::Init() +{ + // TODO standard log tokens + // TODO external ACL fmt tokens + +#if USE_ADAPTATION + TheConfig.registerTokens(String("adapt"),TokenTableAdapt); +#endif +#if ICAP_CLIENT + TheConfig.registerTokens(String("icap"),TokenTableIcap); +#endif + + // TODO tokens for OpenSSL errors in "ssl::" +} + /// Scans a token table to see if the next token exists there /// returns a pointer to next unparsed byte and updates type member if found char * -Format::Token::scanForToken(const struct TokenTableEntry *table, char *cur) +Format::Token::scanForToken(TokenTableEntry const table[], char *cur) { - for (const struct TokenTableEntry *lte = table; lte->config != NULL; lte++) { + for (TokenTableEntry const *lte = table; lte->config != NULL; lte++) { if (strncmp(lte->config, cur, strlen(lte->config)) == 0) { type = lte->token_type; label = lte->config; @@ -322,26 +339,20 @@ type = LFT_NONE; - // Scan each token namespace - if (strncmp(cur, "icap::", 6) == 0) { -#if ICAP_CLIENT - cur += 6; - debugs(46, 5, HERE << "scan for icap:: token"); - cur = scanForToken(TokenTableIcap, cur); -#else - debugs(46, DBG_IMPORTANT, "ERROR: Format uses icap:: token. ICAP disabled!"); -#endif - } else if (strncmp(cur, "adapt::", 7) == 0) { -#if USE_ADAPTATION - cur += 7; - debugs(46, 5, HERE << "scan for adapt:: token"); - cur = scanForToken(TokenTableAdapt, cur); -#else - debugs(46, DBG_IMPORTANT, "ERROR: Format uses adapt:: token. Adaptation disabled!"); -#endif - } else { + // Scan each registered token namespace + for (std::list::const_iterator itr = TheConfig.tokens.begin(); itr != TheConfig.tokens.end(); itr++) { + const size_t len = itr->prefix.size(); + if (itr->prefix.cmp(cur, len) != 0 && cur[len+1] == ':' && cur[len+2] == ':') { + const char *old = cur; + cur = scanForToken(itr->tokenSet, cur); + if (old != cur) // found + break; + } + } + + if (type == LFT_NONE) { // For upward compatibility, assume "http::" prefix as default prefix - // for all log access formating codes, except those starting with a + // for all log access formatting codes, except those starting with a // "%" or a known namespace. (ie "icap::", "adapt::") if (strncmp(cur,"http::", 6) == 0 && *(cur+6) != '%' ) cur += 6; === renamed file 'src/format/Tokens.h' => 'src/format/Token.h' --- src/format/Tokens.h 2011-10-13 17:05:25 +0000 +++ src/format/Token.h 2011-11-05 08:38:12 +0000 @@ -1,5 +1,7 @@ -#ifndef _SQUID_FMT_TOKENS_H -#define _SQUID_FMT_TOKENS_H +#ifndef _SQUID_FORMAT_TOKEN_H +#define _SQUID_FORMAT_TOKEN_H + +#include "format/TokenTableEntry.h" /* * Squid configuration allows users to define custom formats in @@ -18,168 +20,6 @@ #define LOG_BUF_SZ (MAX_URL<<2) -/* - * Bytecodes for the configureable format stuff - */ -typedef enum { - LFT_NONE, /* dummy */ - LFT_STRING, - - LFT_CLIENT_IP_ADDRESS, - LFT_CLIENT_FQDN, - LFT_CLIENT_PORT, - LFT_CLIENT_EUI, - - LFT_SERVER_IP_ADDRESS, - LFT_SERVER_FQDN_OR_PEER_NAME, - LFT_SERVER_PORT, - - LFT_CLIENT_LOCAL_IP, - LFT_LOCAL_LISTENING_IP, - LFT_CLIENT_LOCAL_PORT, - LFT_LOCAL_LISTENING_PORT, - /*LFT_LOCAL_NAME, */ - - LFT_SERVER_LOCAL_IP, - LFT_SERVER_LOCAL_IP_OLD_27, - LFT_SERVER_LOCAL_PORT, - - LFT_TIME_SECONDS_SINCE_EPOCH, - LFT_TIME_SUBSECOND, - LFT_TIME_LOCALTIME, - LFT_TIME_GMT, - LFT_TIME_TO_HANDLE_REQUEST, - - LFT_PEER_RESPONSE_TIME, - LFT_TOTAL_SERVER_SIDE_RESPONSE_TIME, - LFT_DNS_WAIT_TIME, - - LFT_REQUEST_HEADER, - LFT_REQUEST_HEADER_ELEM, - LFT_REQUEST_ALL_HEADERS, - - LFT_ADAPTED_REQUEST_HEADER, - LFT_ADAPTED_REQUEST_HEADER_ELEM, - LFT_ADAPTED_REQUEST_ALL_HEADERS, - - LFT_REPLY_HEADER, - LFT_REPLY_HEADER_ELEM, - LFT_REPLY_ALL_HEADERS, - - LFT_USER_NAME, - LFT_USER_LOGIN, - LFT_USER_IDENT, - /*LFT_USER_REALM, */ - /*LFT_USER_SCHEME, */ - LFT_USER_EXTERNAL, - - LFT_HTTP_SENT_STATUS_CODE_OLD_30, - LFT_HTTP_SENT_STATUS_CODE, - LFT_HTTP_RECEIVED_STATUS_CODE, - /*LFT_HTTP_STATUS, */ - LFT_HTTP_BODY_BYTES_READ, - - LFT_SQUID_STATUS, - LFT_SQUID_ERROR, - LFT_SQUID_ERROR_DETAIL, - LFT_SQUID_HIERARCHY, - - LFT_MIME_TYPE, - - /* original Request-Line details receved from client */ - LFT_CLIENT_REQ_METHOD, - LFT_CLIENT_REQ_URI, - LFT_CLIENT_REQ_URLPATH, - /* LFT_CLIENT_REQ_QUERY, */ - LFT_CLIENT_REQ_VERSION, - - /* Request-Line details receved from client (legacy, filtered) */ - LFT_REQUEST_METHOD, - LFT_REQUEST_URI, - LFT_REQUEST_URLPATH_OLD_31, - /*LFT_REQUEST_QUERY, */ - LFT_REQUEST_VERSION_OLD_2X, - LFT_REQUEST_VERSION, - - /* Request-Line details sent to the server/peer */ - LFT_SERVER_REQ_METHOD, - LFT_SERVER_REQ_URI, - LFT_SERVER_REQ_URLPATH, - /*LFT_SERVER_REQ_QUERY, */ - LFT_SERVER_REQ_VERSION, - - LFT_REQUEST_SIZE_TOTAL, - /*LFT_REQUEST_SIZE_LINE, */ - LFT_REQUEST_SIZE_HEADERS, - /*LFT_REQUEST_SIZE_BODY, */ - /*LFT_REQUEST_SIZE_BODY_NO_TE, */ - - LFT_REPLY_SIZE_TOTAL, - LFT_REPLY_HIGHOFFSET, - LFT_REPLY_OBJECTSIZE, - /*LFT_REPLY_SIZE_LINE, */ - LFT_REPLY_SIZE_HEADERS, - /*LFT_REPLY_SIZE_BODY, */ - /*LFT_REPLY_SIZE_BODY_NO_TE, */ - - LFT_TAG, - LFT_IO_SIZE_TOTAL, - LFT_EXT_LOG, - - LFT_SEQUENCE_NUMBER, - -#if USE_ADAPTATION - LTF_ADAPTATION_SUM_XACT_TIMES, - LTF_ADAPTATION_ALL_XACT_TIMES, - LFT_ADAPTATION_LAST_HEADER, - LFT_ADAPTATION_LAST_HEADER_ELEM, - LFT_ADAPTATION_LAST_ALL_HEADERS, -#endif - -#if ICAP_CLIENT - - LFT_ICAP_TOTAL_TIME, - - LFT_ICAP_ADDR, - LFT_ICAP_SERV_NAME, - LFT_ICAP_REQUEST_URI, - LFT_ICAP_REQUEST_METHOD, - LFT_ICAP_BYTES_SENT, - LFT_ICAP_BYTES_READ, - LFT_ICAP_BODY_BYTES_READ, - - LFT_ICAP_REQ_HEADER, - LFT_ICAP_REQ_HEADER_ELEM, - LFT_ICAP_REQ_ALL_HEADERS, - - LFT_ICAP_REP_HEADER, - LFT_ICAP_REP_HEADER_ELEM, - LFT_ICAP_REP_ALL_HEADERS, - - LFT_ICAP_TR_RESPONSE_TIME, - LFT_ICAP_IO_TIME, - LFT_ICAP_OUTCOME, - LFT_ICAP_STATUS_CODE, -#endif - - LFT_PERCENT /* special string cases for escaped chars */ -} ByteCode_t; - -/// Quoting style for a format output. -enum Quoting { - LOG_QUOTE_NONE = 0, - LOG_QUOTE_QUOTES, - LOG_QUOTE_MIMEBLOB, - LOG_QUOTE_URL, - LOG_QUOTE_RAW -}; - -struct TokenTableEntry { - const char *config; - ByteCode_t token_type; - int options; -}; - // XXX: inherit from linked list class Token { @@ -197,6 +37,9 @@ { data.string = NULL; }; ~Token(); + /// Initialize the format token registrations + static void Init(); + /** parses a single token. Returns the token length in characters, * and fills in this item with the token information. * def is for sure null-terminated. @@ -225,11 +68,11 @@ Token *next; /* todo: move from linked list to array */ private: - char *scanForToken(const struct TokenTableEntry *table, char *cur); + char *scanForToken(TokenTableEntry const table[], char *cur); }; extern const char *log_tags[]; } // namespace Format -#endif /* _SQUID_FMT_TOKENS_H */ +#endif /* _SQUID_FORMAT_TOKEN_H */ === added file 'src/format/TokenTableEntry.h' --- src/format/TokenTableEntry.h 1970-01-01 00:00:00 +0000 +++ src/format/TokenTableEntry.h 2011-10-08 06:15:13 +0000 @@ -0,0 +1,30 @@ +#ifndef _SQUID_FORMAT_TOKENTABLEENTRY_H +#define _SQUID_FORMAT_TOKENTABLEENTRY_H + +#include "format/ByteCode.h" + +/* + * Squid configuration allows users to define custom formats in + * several components. + * - logging + * - external ACL input + * - deny page URL + * + * These enumerations and classes define the API for parsing of + * format directives to define these patterns. Along with output + * functionality to produce formatted buffers. + */ + +namespace Format +{ + +class TokenTableEntry { +public: + const char *config; + ByteCode_t token_type; + int options; +}; + +} // namespace Format + +#endif /* _SQUID_FORMAT_TOKENTABLEENTRY_H */ === modified file 'src/log/FormatHttpdCombined.cc' --- src/log/FormatHttpdCombined.cc 2011-08-04 03:21:06 +0000 +++ src/log/FormatHttpdCombined.cc 2011-09-11 06:30:44 +0000 @@ -34,7 +34,7 @@ #include "config.h" #include "AccessLogEntry.h" -#include "format/Tokens.h" +#include "format/Token.h" #include "format/Quoting.h" #include "HttpRequest.h" #include "log/File.h" === modified file 'src/log/FormatHttpdCommon.cc' --- src/log/FormatHttpdCommon.cc 2011-08-04 03:21:06 +0000 +++ src/log/FormatHttpdCommon.cc 2011-09-11 06:31:17 +0000 @@ -35,7 +35,7 @@ #include "config.h" #include "AccessLogEntry.h" #include "format/Quoting.h" -#include "format/Tokens.h" +#include "format/Token.h" #include "log/File.h" #include "log/Formats.h" #include "SquidTime.h" === modified file 'src/log/FormatSquidCustom.cc' --- src/log/FormatSquidCustom.cc 2011-08-04 03:21:06 +0000 +++ src/log/FormatSquidCustom.cc 2011-09-11 06:34:32 +0000 @@ -34,7 +34,6 @@ #include "config.h" #include "AccessLogEntry.h" -#include "format/Tokens.h" #include "log/File.h" #include "log/Formats.h" #include "MemBuf.h" === modified file 'src/log/FormatSquidNative.cc' --- src/log/FormatSquidNative.cc 2011-08-20 15:57:06 +0000 +++ src/log/FormatSquidNative.cc 2011-09-11 06:35:16 +0000 @@ -35,7 +35,7 @@ #include "config.h" #include "AccessLogEntry.h" #include "format/Quoting.h" -#include "format/Tokens.h" +#include "format/Token.h" #include "log/File.h" #include "log/Formats.h" #include "SquidTime.h" === modified file 'src/log/access_log.cc' --- src/log/access_log.cc 2011-09-09 20:41:40 +0000 +++ src/log/access_log.cc 2011-09-22 11:32:19 +0000 @@ -47,7 +47,7 @@ #include "eui/Eui48.h" #include "eui/Eui64.h" #endif -#include "format/Tokens.h" +#include "format/Token.h" #include "hier_code.h" #include "HttpReply.h" #include "HttpRequest.h" @@ -322,8 +322,8 @@ #if USE_ADAPTATION for (Format::Token * curr_token = (log->logFormat?log->logFormat->format:NULL); curr_token; curr_token = curr_token->next) { - if (curr_token->type == Format::LTF_ADAPTATION_SUM_XACT_TIMES || - curr_token->type == Format::LTF_ADAPTATION_ALL_XACT_TIMES || + if (curr_token->type == Format::LFT_ADAPTATION_SUM_XACT_TIMES || + curr_token->type == Format::LFT_ADAPTATION_ALL_XACT_TIMES || curr_token->type == Format::LFT_ADAPTATION_LAST_HEADER || curr_token->type == Format::LFT_ADAPTATION_LAST_HEADER_ELEM || curr_token->type == Format::LFT_ADAPTATION_LAST_ALL_HEADERS) { === modified file 'src/main.cc' --- src/main.cc 2011-11-03 10:02:02 +0000 +++ src/main.cc 2011-11-05 09:41:52 +0000 @@ -63,6 +63,7 @@ #include "event.h" #include "EventLoop.h" #include "ExternalACL.h" +#include "format/Token.h" #include "fs/Module.h" #include "PeerSelectState.h" #include "Store.h" @@ -1105,6 +1106,8 @@ // TODO: pconn is a good candidate for new-style registration // PconnModule::GetInstance()->registerWithCacheManager(); // moved to PconnModule::PconnModule() + + Format::Token::Init(); } if (IamPrimaryProcess()) { === modified file 'src/stat.cc' --- src/stat.cc 2011-10-14 16:21:48 +0000 +++ src/stat.cc 2011-10-16 05:00:24 +0000 @@ -34,7 +34,7 @@ #include "squid.h" #include "event.h" -#include "format/Tokens.h" +#include "format/Token.h" #include "StoreClient.h" #if USE_AUTH #include "auth/UserRequest.h" === modified file 'src/store_log.cc' --- src/store_log.cc 2011-08-04 03:21:06 +0000 +++ src/store_log.cc 2011-09-11 06:54:54 +0000 @@ -33,7 +33,7 @@ */ #include "squid.h" -#include "format/Tokens.h" +#include "format/Token.h" #include "HttpReply.h" #include "log/File.h" #include "MemObject.h"