[lwatch-cvs] files/src defaults.h, 1.9, 1.10 lwatch.conf, 1.28, 1.29 settings.c, 1.35, 1.36 setting
Brought to you by:
arturcz
|
From: Artur R. C. <ar...@us...> - 2009-03-23 21:15:38
|
Update of /cvsroot/lwatch/files/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18648/src Modified Files: defaults.h lwatch.conf settings.c settings.h strpcre.c yparse.l Log Message: default value for exit/continue on matching rule is configurable now Index: settings.c =================================================================== RCS file: /cvsroot/lwatch/files/src/settings.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** settings.c 21 Mar 2009 10:54:34 -0000 1.35 --- settings.c 23 Mar 2009 21:15:34 -0000 1.36 *************** *** 207,210 **** --- 207,211 ---- lw_conf.def_serv_color=_N_BLUE; lw_conf.def_mesg_color=_N_LIGHTGRAY; + lw_conf.def_action_rule=DEF_ACTION_RULE; if(omit_config) return; *************** *** 235,238 **** --- 236,240 ---- lw_conf.def_serv_color, lw_conf.def_mesg_color); + /* FIXME dodaÄ output dla koÅczenia */ #endif *************** *** 260,264 **** paction->highlight_color, paction->ignore?"yes":"no", ! paction->exit?"yes":"no", paction->match_service?"yes":"no", paction->match_host?"yes":"no"); --- 262,266 ---- paction->highlight_color, paction->ignore?"yes":"no", ! (paction->action==RULE_DEFAULT)?(action_exit(*paction)?"yes (default)":"no (default)"):(action_exit(*paction)?"yes":"no"), paction->match_service?"yes":"no", paction->match_host?"yes":"no"); Index: yparse.l =================================================================== RCS file: /cvsroot/lwatch/files/src/yparse.l,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** yparse.l 21 Mar 2009 10:54:34 -0000 1.30 --- yparse.l 23 Mar 2009 21:15:34 -0000 1.31 *************** *** 72,78 **** %option noyywrap nounput ! M_KEYWORD input_file|output_file|show_unparsed|cfg_ver|use_syslog|log_level R_KEYCOLOR date_color|host_color|serv_color|mesg_color|color|highlight ! R_KEYWORD match_service|match_host|ignore|exit COLOR black|red|green|brown|blue|magenta|cyan|lightgray|darkgray|brightred|brightgreen|yellow|brightblue|purple|brightcyan|white STRING ".*" --- 72,79 ---- %option noyywrap nounput ! M_KEYWORD input_file|output_file|show_unparsed|cfg_ver|use_syslog|log_level|rule_action R_KEYCOLOR date_color|host_color|serv_color|mesg_color|color|highlight ! R_KEYWORD match_service|match_host|ignore|continue|exit ! RA_KEYWORD continue|exit COLOR black|red|green|brown|blue|magenta|cyan|lightgray|darkgray|brightred|brightgreen|yellow|brightblue|purple|brightcyan|white STRING ".*" *************** *** 84,88 **** INTVAL [0-9]* ! %x COLOR REGEXP ERROR SECOND ACTION MULTI TEXT BOOLEAN INTEGER %% --- 85,89 ---- INTVAL [0-9]* ! %x COLOR REGEXP ERROR SECOND ACTION MULTI TEXT BOOLEAN INTEGER RULEACTION %% *************** *** 111,114 **** --- 112,123 ---- #endif } + <INITIAL>rule_action= { + PUSH(RULEACTION); + yyip=&lw_conf.def_action_rule; + #ifdef DEBUG + strcpy(mymsg,"rule_action"); + #endif + + } <INITIAL>output_file= { PUSH(TEXT); *************** *** 240,243 **** --- 249,263 ---- POP; } + <RULEACTION>{RA_KEYWORD} { + if(!strcasecmp(yytext,"exit")) { + *yyip=RULE_EXIT; + } else { + *yyip=RULE_CONTINUE; + } + #ifdef DEBUG + fprintf(stderr,"Set %s to %s (%i)\n",mymsg,yytext,*yyip); + #endif + POP; + } <INTEGER>{INTVAL} { *yyip=0; *************** *** 271,275 **** <MULTI,ACTION>ignore { action.ignore=1; ! action.exit=1; #ifdef DEBUG fprintf(stderr,"Ignore RE\n"); --- 291,295 ---- <MULTI,ACTION>ignore { action.ignore=1; ! action.action=RULE_EXIT; #ifdef DEBUG fprintf(stderr,"Ignore RE\n"); *************** *** 277,285 **** } <MULTI,ACTION>exit { ! action.exit=1; #ifdef DEBUG fprintf(stderr,"Exit on action\n"); #endif } <INITIAL>\/ { BEGIN(SECOND); --- 297,317 ---- } <MULTI,ACTION>exit { ! action.action=RULE_EXIT; #ifdef DEBUG fprintf(stderr,"Exit on action\n"); #endif } + <MULTI,ACTION>continue { + if(action.ignore==1) { + #ifdef DEBUG + fprintf(stderr,"This rule is for ignoring the pattern. Using continue makes no sense"); + #endif + } else { + action.action=RULE_CONTINUE; + #ifdef DEBUG + fprintf(stderr,"Continue with the next action\n"); + #endif + } + } <INITIAL>\/ { BEGIN(SECOND); Index: settings.h =================================================================== RCS file: /cvsroot/lwatch/files/src/settings.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** settings.h 21 Mar 2009 10:54:34 -0000 1.15 --- settings.h 23 Mar 2009 21:15:34 -0000 1.16 *************** *** 33,36 **** --- 33,38 ---- #include <pcre.h> + #include "defaults.h" + struct s_conf { int def_date_color,def_host_color,def_serv_color,def_mesg_color; *************** *** 41,44 **** --- 43,47 ---- int use_syslog; int log_level; + int def_action_rule; int cfg_ver; /* wersja formatu pliku konfiguracyjnego */ }; *************** *** 59,63 **** match_host, /* match hostname instead message */ ignore, /* ignore this line and do not display */ ! exit; /* dont process next options */ }; --- 62,66 ---- match_host, /* match hostname instead message */ ignore, /* ignore this line and do not display */ ! action; /* process next rule? */ }; *************** *** 70,71 **** --- 73,76 ---- extern struct s_action *lw_actions; extern int no_actions; + + #define action_exit(a) ((a).action==RULE_EXIT)||(((a).action==RULE_DEFAULT)&&(lw_conf.def_action_rule==RULE_EXIT)) Index: strpcre.c =================================================================== RCS file: /cvsroot/lwatch/files/src/strpcre.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** strpcre.c 21 Mar 2009 10:54:34 -0000 1.30 --- strpcre.c 23 Mar 2009 21:15:34 -0000 1.31 *************** *** 214,218 **** mesg_s=match; } ! if(lw_actions[i].exit) /* dont check other actions */ break; } --- 214,218 ---- mesg_s=match; } ! if(action_exit(lw_actions[i])) /* dont check other actions */ break; } Index: lwatch.conf =================================================================== RCS file: /cvsroot/lwatch/files/src/lwatch.conf,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** lwatch.conf 21 Mar 2009 10:54:34 -0000 1.28 --- lwatch.conf 23 Mar 2009 21:15:34 -0000 1.29 *************** *** 10,13 **** --- 10,18 ---- cfg_ver=1 + # The default is that after success match the rule is executed + # then the next rule is taken into action. You can change this behavior + # changing rule_action from continue to exit. Read lwatch.conf(5) for details. + # rule_action=continue + # Available colors: # black red green brown blue magenta cyan lightgray darkgray brightred *************** *** 65,68 **** --- 70,74 ---- color=red serv_color=brown + continue } Index: defaults.h =================================================================== RCS file: /cvsroot/lwatch/files/src/defaults.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** defaults.h 21 Mar 2009 10:54:34 -0000 1.9 --- defaults.h 23 Mar 2009 21:15:34 -0000 1.10 *************** *** 35,38 **** --- 35,42 ---- #define NO 0 + #define RULE_DEFAULT 0 + #define RULE_EXIT 1 + #define RULE_CONTINUE 2 + #define DEF_DATE_COLOR CYAN #define DEF_HOST_COLOR MAGENTA *************** *** 43,44 **** --- 47,49 ---- #define DEF_OUT_FILE "-" #define DEF_CREATE_FIFO YES + #define DEF_ACTION_RULE RULE_CONTINUE |