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1_6:1.8 FSL_0_1_5:1.8 FSL_0_1_1:1.7 LMTP2NNTP_1_2a5:1.7 LMTP2NNTP_1_2a4:1.7 LMTP2NNTP_1_2a3:1.7 LMTP2NNTP_1_2a1:1.5; locks; strict; comment @ * @; 1.16 date 2005.10.03.08.08.11; author rse; state Exp; branches; next 1.15; 1.15 date 2005.02.03.09.42.36; author rse; state Exp; branches; next 1.14; 1.14 date 2005.01.24.15.03.18; author rse; state Exp; branches; next 1.13; 1.13 date 2003.11.06.11.50.58; author ms; state Exp; branches; next 1.12; 1.12 date 2003.01.06.11.41.52; author rse; state Exp; branches; next 1.11; 1.11 date 2003.01.06.11.19.45; author rse; state Exp; branches; next 1.10; 1.10 date 2002.11.09.14.37.45; author rse; state Exp; branches; next 1.9; 1.9 date 2002.07.30.19.08.25; author rse; state Exp; branches; next 1.8; 1.8 date 2002.07.25.07.54.51; author rse; state Exp; branches; next 1.7; 1.7 date 2002.01.02.17.07.38; author rse; state Exp; branches; next 1.6; 1.6 date 2001.12.14.12.42.07; author rse; state Exp; branches; next 1.5; 1.5 date 2001.11.08.21.58.00; author rse; state Exp; branches; next 1.4; 1.4 date 2001.11.08.09.33.37; author rse; state Exp; branches; next 1.3; 1.3 date 2001.11.08.09.28.35; author rse; state Exp; branches; next 1.2; 1.2 date 2001.11.07.16.29.56; author rse; state Exp; branches; next 1.1; 1.1 date 2001.11.07.16.17.09; author rse; state Exp; branches; next ; desc @@ 1.16 log @Adjust copyright messages for new year 2005. @ text @%{ /* ** OSSP l2 - Flexible Logging ** Copyright (c) 2001-2005 Cable & Wireless ** Copyright (c) 2001-2005 The OSSP Project ** Copyright (c) 2001-2005 Ralf S. Engelschall ** ** This file is part of OSSP l2, a flexible logging library which ** can be found at http://www.ossp.org/pkg/lib/l2/. ** ** Permission to use, copy, modify, and distribute this software for ** any purpose with or without fee is hereby granted, provided that ** the above copyright notice and this permission notice appear in all ** copies. ** ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** ** l2_spec_scan.l: GNU Flex (Lex-style) scanner specification ** ** ATTENTION: This requires GNU Flex 2.5.10 or newer! */ #include "l2.h" /* for l2_xxx() */ #include "l2_spec.h" /* for l2_spec_ctx_t */ #include "l2_spec_parse.h" /* for T_XXXX */ /* how to find our own context */ #define CTX ((l2_spec_ctx_t *)yyget_extra(yyscanner)) /* provide own input handling */ #define YY_NO_UNPUT 1 #undef YY_INPUT #define YY_INPUT(buf,result,max_size) (result = yyinput(CTX, buf, max_size)) static int yyinput(l2_spec_ctx_t *ctx, char *buf, int max_size); /* location tracking */ #define YY_USER_INIT \ yylloc->first = 0; \ yylloc->last = 0; #define YY_USER_ACTION \ yylloc->first = yylloc->last; \ yylloc->last += yyleng; #define YY_USER_ACTION_ROLLBACK \ yylloc->last = yylloc->first %} /* scanner options */ %pointer %option stack %option reentrant %option bison-bridge %option bison-locations %option never-interactive %option noyywrap %option nounput %option noyy_top_state %option nounistd /* scanner states */ %x SS_PARAM %x SS_PARAM_Q %% /* local variables */ char caParam[2048]; char *cpParam = NULL; /* parameter value */ \" { if (cpParam == NULL) cpParam = caParam; BEGIN(SS_PARAM_Q); } \\. { if (cpParam == NULL) cpParam = caParam; *cpParam++ = yytext[1]; } [^ \t\r\n\\,)"]+ { char *cp = yytext; if (cpParam == NULL) cpParam = caParam; while (*cp != '\0') *cpParam++ = *cp++; } (.|\n) { if (cpParam == NULL) cpParam = caParam; *cpParam = '\0'; yylval->cpValue = strdup(caParam); cpParam = NULL; yyless(0); YY_USER_ACTION_ROLLBACK; return T_PARAM; } \" { BEGIN(SS_PARAM); } \n { l2_spec_error(CTX, L2_ERR_SYN, yylloc, "Unterminated string"); return 0; } \\[0-7]{1,3} { unsigned int result; (void)sscanf(yytext+1, "%o", &result); if (result > 0xff) { l2_spec_error(CTX, L2_ERR_SYN, yylloc, "Escape sequence out of bound"); return 0; } else *cpParam++ = result; } \\x[0-9a-fA-F]{2} { unsigned int result; (void)sscanf(yytext+1, "%x", &result); if (result > 0xff) { l2_spec_error(CTX, L2_ERR_SYN, yylloc, "Escape sequence out of bound"); return 0; } else *cpParam++ = result; } \\n { *cpParam++ = '\n'; } \\r { *cpParam++ = '\r'; } \\t { *cpParam++ = '\t'; } \\b { *cpParam++ = '\b'; } \\f { *cpParam++ = '\f'; } \\(.|\n) { *cpParam++ = yytext[1]; } [^\\\"]+ { char *cp = yytext; while (*cp != '\0') *cpParam++ = *cp++; } (.|\n) { *cpParam++ = yytext[0]; } /* whitespaces */ [ \t\n]+ { /* NOOP */ } /* operators */ "->" { return T_OP_ARROW; } /* identifiers */ [a-zA-Z][a-zA-Z0-9_-]* { yylval->cpValue = strdup(yytext); return T_ID; } /* anything else is returned as is... */ .|\n { return yytext[0]; } %% /* external scanner state transitions */ void l2_spec_scan_push(l2_spec_ctx_t *ctx, const char *state); void l2_spec_scan_push(l2_spec_ctx_t *ctx, const char *state) { if (strcmp(state, "SS_PARAM") == 0) yy_push_state(SS_PARAM, ctx->yyscan); } void l2_spec_scan_pop(l2_spec_ctx_t *ctx); void l2_spec_scan_pop(l2_spec_ctx_t *ctx) { yy_pop_state(ctx->yyscan); } /* buffer-based input routine */ static int yyinput(l2_spec_ctx_t *ctx, char *buf, int max_size) { int n; n = (ctx->inputbuf + ctx->inputlen - ctx->inputptr); if (n > max_size) n = max_size; if (n <= 0) return YY_NULL; memcpy(buf, ctx->inputptr, n); ctx->inputptr += n; return n; } @ 1.15 log @Fix compile warnings for Flex generation code by using the %options nounput, noyy_top_state and nounistd. @ text @d4 3 a6 3 ** Copyright (c) 2001-2004 Cable & Wireless ** Copyright (c) 2001-2004 The OSSP Project ** Copyright (c) 2001-2004 Ralf S. Engelschall @ 1.14 log @Adjust copyright messages for new year 2005. @ text @d66 3 @ 1.13 log @Add bison-locations to conditionally include new M4 yylloc macro into analyzer skeleton code. Keep now redundant bison-bridge option around (this doesn't hurt), just incase the new conditional reentrant yylloc reverts. @ text @d4 3 a6 3 ** Copyright (c) 2001-2003 Cable & Wireless Deutschland GmbH ** Copyright (c) 2001-2003 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2001-2003 Ralf S. Engelschall @ 1.12 log @- remove trailing whitespaces - adjust copyright messages - consistently use "OSSP l2" - consistently talk about "Flexible Logging" - use standard OSSP ASCII-art @ text @d63 1 @ 1.11 log @upgrade to the latest Flex & Bison & Autoconf combo @ text @d3 4 a6 3 ** OSSP l2 - Logging Library ** Copyright (c) 2001-2002 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2001-2002 Cable & Wireless Deutschland (http://www.cw.com/de/) d8 1 a8 1 ** This file is part of OSSP L2, a flexible logging library which d110 1 a110 1 } d154 1 a154 1 "->" { @ 1.10 log @ok, with the latest and greatest plus a little tweaking it works again. @ text @d30 1 a30 1 ** ATTENTION: This requires GNU Flex 2.5.6-dev-2001.11.01 or newer! @ 1.9 log @polish for release @ text @d60 2 a61 1 %option reentrant-bison @ 1.8 log @upgrade to flex-beta 2.5.10 (incompatible, so require it) @ text @d3 1 a3 1 ** L2 - OSSP Logging Library d8 1 a8 1 ** can be found at http://www.ossp.org/pkg/l2/. @ 1.7 log @bump copyright year @ text @d38 1 a38 1 #define CTX ((l2_spec_ctx_t *)yyget_extra(yy_globals)) @ 1.6 log @Whoohooo! Add support for location tracking. This way the reported errors contain line, column, context and found/expected information. Now the specification parser is full featured... @ text @d4 2 a5 2 ** Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) @ 1.5 log @Enhance the specification parser to be more smart in parsing parameter values in order to remove the burden on the user to provide massive syntactic sugar. One now can name=value or name="value" or even name=va"lu"e, i.e., do not require quotation marks. But if they are present they can be used to introduce spaces or special characters with \xXX notation. @ text @d45 10 d99 1 d106 1 a106 2 l2_env_errorinfo(CTX->env, L2_ERR_ARG, "%s", "Unterminated string"); CTX->rv = L2_ERR_ARG; d113 1 a113 2 l2_env_errorinfo(CTX->env, L2_ERR_ARG, "%s", "Escape sequence out of bound"); CTX->rv = L2_ERR_ARG; d123 1 a123 2 l2_env_errorinfo(CTX->env, L2_ERR_ARG, "%s", "Escape sequence out of bound"); CTX->rv = L2_ERR_ARG; @ 1.4 log @more polishing @ text @d49 1 d55 2 a56 1 %x str d61 2 a62 2 char caStr[2048]; char *cpStr = NULL; d64 29 a92 3 /* whitespaces */ [ \t\n]+ { /* NOOP */ d94 1 a94 13 /* C-style strings ("...") */ \" { cpStr = caStr; BEGIN(str); } \" { BEGIN(INITIAL); *cpStr = '\0'; yylval->cpValue = strdup(caStr); return T_STRING; } \n { d97 1 d99 1 a99 1 \\[0-7]{1,3} { d105 1 d108 1 a108 1 *cpStr++ = result; d110 10 a119 3 \\[0-9]+ { l2_env_errorinfo(CTX->env, L2_ERR_ARG, "%s", "Bad escape sequence"); CTX->rv = L2_ERR_ARG; d121 7 a127 7 \\n { *cpStr++ = '\n'; } \\r { *cpStr++ = '\r'; } \\t { *cpStr++ = '\t'; } \\b { *cpStr++ = '\b'; } \\f { *cpStr++ = '\f'; } \\(.|\n) { *cpStr++ = yytext[1]; d129 1 a129 1 [^\\\n\"]+ { d132 4 a135 1 *cpStr++ = *cp++; d137 4 a140 2 . { *cpStr++ = yytext[1]; d160 13 @ 1.3 log @code cleanups and documentation @ text @d58 3 a60 3 /* local variables */ char caStr[2048]; char *cpStr = NULL; d62 1 a62 3 /* * Whitespaces */ d67 1 a67 3 /* * C-style strings ("...") */ d113 1 a113 3 /* * Operators */ d118 1 a118 3 /* * Identifiers */ d124 1 a124 3 /* * Anything else is returned as is... */ @ 1.2 log @fix warning @ text @d47 1 a48 1 /* %option stack */ d53 1 d58 1 d141 1 @ 1.1 log @HEADS UP, guys: Here comes the first cut for the long-awaited channel tree specification parser and channel tree builder. This certainly makes L2 finally _THE_ killer library in the logging field. Woohooo... and the crowd goes wild! It allows one to build an arbitrary complex logging channel tree out of a single textual specification. An example follows: noop -> { prefix(prefix="[%d-%m-%Y/%H:%M:%S] %L test[%P]: ", timezone="local") -> filter(regex="hecking", negate="0") -> buffer(size="800") -> file(path="l2_test.log",append="1",perm="420"); error: syslog(ident="L2-Test", facility="user", remotehost="en1", logpid="1", target="remote"); panic: smtp(rcpt="rse@@engelschall.com", host="en1", port="25" } This allows one to log nice timestamp-prefixed messages containing the word "hecking" to a buffered file. Additionally if the message has a level higher or equal to "error" it also logs it remotely via UDP to the syslogd on en1. And additionally if the message is a panic message, it is also sent out as an Email via SMTP to the MTA on en1. Ever thought a C library has to be dull and simple? ;) PS: This stuff certainly needs more polishing and cleanup and also a few things I'll enhance in the future (for instance to remove the restriction that parameter values have to be in quotation marks, etc.). @ text @d85 1 a85 1 int result; @