[lwatch-cvs] files/src defaults.h,1.6,1.7 lwatch.c,1.15,1.16 lwatch.conf,1.15,1.16 settings.c,1.18,1
Brought to you by:
arturcz
|
From: <ar...@us...> - 2003-04-04 15:11:57
|
Update of /cvsroot/lwatch/files/src
In directory sc8-pr-cvs1:/tmp/cvs-serv9220/src
Modified Files:
defaults.h lwatch.c lwatch.conf settings.c settings.h yparse.l
Log Message:
- --fifo and -f are deprecated, use --input and -i instead
- new options for output file (-o and --output)
- -o means output file, use -O for omit config file
- fifo_file in configuration file is deprecated, use input_file instead it
- new option output_file in configuration
Index: defaults.h
===================================================================
RCS file: /cvsroot/lwatch/files/src/defaults.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** defaults.h 27 Mar 2003 16:08:18 -0000 1.6
--- defaults.h 4 Apr 2003 15:11:42 -0000 1.7
***************
*** 41,43 ****
--- 41,44 ----
#define DEF_CONF_FILE SYSCONFDIR "/lwatch.conf"
#define DEF_IN_FILE INPUTFILE
+ #define DEF_OUT_FILE "-"
#define DEF_CREATE_FIFO YES
Index: lwatch.c
===================================================================
RCS file: /cvsroot/lwatch/files/src/lwatch.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** lwatch.c 4 Apr 2003 12:01:43 -0000 1.15
--- lwatch.c 4 Apr 2003 15:11:42 -0000 1.16
***************
*** 60,64 ****
set_handlers();
init_parser();
! if(strcmp(lw_conf.fifo_file,"-")==0) {
fd=0;
#ifdef DEBUG
--- 60,64 ----
set_handlers();
init_parser();
! if(strcmp(lw_conf.in_file,"-")==0) {
fd=0;
#ifdef DEBUG
***************
*** 67,75 ****
} else {
struct stat sbuf;
! io_check(stat(lw_conf.fifo_file,&sbuf),lw_conf.fifo_file);
if(!S_ISFIFO(sbuf.st_mode)) die("ERROR: Regular file are not supported for now. See manual for details\n");
! io_check(fd=open(lw_conf.fifo_file,O_RDONLY),lw_conf.fifo_file);
#ifdef DEBUG
! printf("Input from %s\n",lw_conf.fifo_file);
#endif
}
--- 67,88 ----
} else {
struct stat sbuf;
! io_check(stat(lw_conf.in_file,&sbuf),lw_conf.in_file);
if(!S_ISFIFO(sbuf.st_mode)) die("ERROR: Regular file are not supported for now. See manual for details\n");
! io_check(fd=open(lw_conf.in_file,O_RDONLY),lw_conf.in_file);
#ifdef DEBUG
! printf("Input from %s\n",lw_conf.in_file);
! #endif
! }
! if(strcmp(lw_conf.out_file,"-")==0) {
! #ifdef DEBUG
! printf("Output to stdout\n");
! #endif
! } else {
! printf("raz\n");
! stdout=freopen(lw_conf.out_file,"w",stdout);
! printf("dwa\n");
! /* io_check(fd=open(lw_conf.out_file,O_WRONLY),lw_conf.out_file); */
! #ifdef DEBUG
! printf("Output to %s\n",lw_conf.out_file);
#endif
}
***************
*** 89,96 ****
/* from fifo */
#ifdef DEBUG
! printf("syslog closed second end of fifo %s\nTrying to reopen\n",lw_conf.fifo_file);
#endif
/* trying to reopen or die */
! io_check(fd=open(lw_conf.fifo_file,O_RDONLY),lw_conf.fifo_file);
input.fd=fd;
} else {
--- 102,109 ----
/* from fifo */
#ifdef DEBUG
! printf("syslog closed second end of fifo %s\nTrying to reopen\n",lw_conf.in_file);
#endif
/* trying to reopen or die */
! io_check(fd=open(lw_conf.in_file,O_RDONLY),lw_conf.in_file);
input.fd=fd;
} else {
Index: lwatch.conf
===================================================================
RCS file: /cvsroot/lwatch/files/src/lwatch.conf,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** lwatch.conf 3 Apr 2003 14:11:36 -0000 1.15
--- lwatch.conf 4 Apr 2003 15:11:42 -0000 1.16
***************
*** 17,21 ****
# if filename - it should be name fifo, where syslogd logs
# - means: read from stdin (via tail -f logfile | lwatch )
! input_fifo=/tmp/test
# NOT SUPPORTED IN THIS RELEASE!
--- 17,26 ----
# if filename - it should be name fifo, where syslogd logs
# - means: read from stdin (via tail -f logfile | lwatch )
! input_file=/dev/lwatch # remember about configure your syslog
!
! # Where to print colored logs?
! # Any filename accepted, especially /dev/tty* if you want to output into
! # console
! output_file=/dev/tty11
# NOT SUPPORTED IN THIS RELEASE!
Index: settings.c
===================================================================
RCS file: /cvsroot/lwatch/files/src/settings.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** settings.c 24 Mar 2003 14:23:41 -0000 1.18
--- settings.c 4 Apr 2003 15:11:43 -0000 1.19
***************
*** 94,99 ****
" -C, --config filename",
"\tread config from filename instead of " DEF_CONF_FILE ",",
! " -f, --fifo filename",
"\tread data from named fifo filename instead of " DEF_IN_FILE ",",
/*
" -c, --create-fifo",
--- 94,101 ----
" -C, --config filename",
"\tread config from filename instead of " DEF_CONF_FILE ",",
! " -i, --input filename",
"\tread data from named fifo filename instead of " DEF_IN_FILE ",",
+ " -o, --output filename",
+ "\twrite colored logs into filename instead of " DEF_OUT_FILE ",",
/*
" -c, --create-fifo",
***************
*** 102,106 ****
" -s, --show-unparsed",
"\tshows unparsed lines (like `last message repeated X times')",
! " -o, --omit-rc",
"\tdo not read values from config file",
" -h, --help",
--- 104,108 ----
" -s, --show-unparsed",
"\tshows unparsed lines (like `last message repeated X times')",
! " -O, --omit-rc",
"\tdo not read values from config file",
" -h, --help",
***************
*** 119,126 ****
{"version",0,0,'v'},
{"config",1,0,'C'},
! {"fifo",1,0,'f'},
{"create-fifo",0,0,'c'},
{"show-unparsed",0,0,'s'},
! {"omit-rc",0,0,'o'},
{"help",0,0,'h'},
{0,0,0,0}
--- 121,130 ----
{"version",0,0,'v'},
{"config",1,0,'C'},
! {"fifo",1,0,'f'}, /* FIXME: it should be removed in next releases */
! {"input",1,0,'i'},
! {"output",1,0,'o'},
{"create-fifo",0,0,'c'},
{"show-unparsed",0,0,'s'},
! {"omit-rc",0,0,'O'},
{"help",0,0,'h'},
{0,0,0,0}
***************
*** 136,140 ****
#endif
memset(&lw_conf,0,sizeof(lw_conf));
! while((c=getopt_long(argc,argv,"vC:f:cosh",opt,&idx))!=EOF) {
switch(c) {
case 'C':
--- 140,144 ----
#endif
memset(&lw_conf,0,sizeof(lw_conf));
! while((c=getopt_long(argc,argv,"vC:f:i:co:Osh",opt,&idx))!=EOF) {
switch(c) {
case 'C':
***************
*** 148,158 ****
}
break;
! case 'f':
if(strlen(optarg)>MAXPATHLEN) {
! die("Filename too long (%i bytes)\n",strlen(optarg));
} else {
! strncpy(lw_conf.fifo_file,optarg,MAXPATHLEN);
#ifdef DEBUG
! printf("Input file set to: %s\n",lw_conf.fifo_file);
#endif
}
--- 152,176 ----
}
break;
! case 'f':
! printf("USAGE OF --fifo AND -f IS DEPRECATED.\n");
! printf("PLEASE USE --input OR -i INSTEAD IT.\n");
! printf("OPTIONS --fifo AND -f ARE SUBJECTS TO REMOVE IN NEXT RELEASE.\n");
! case 'i':
if(strlen(optarg)>MAXPATHLEN) {
! die("Input filename too long (%i bytes)\n",strlen(optarg));
} else {
! strncpy(lw_conf.in_file,optarg,MAXPATHLEN);
#ifdef DEBUG
! printf("Input file set to: %s\n",lw_conf.in_file);
! #endif
! }
! break;
! case 'o':
! if(strlen(optarg)>MAXPATHLEN) {
! die("Output filename too long (%i bytes)\n",strlen(optarg));
! } else {
! strncpy(lw_conf.out_file,optarg,MAXPATHLEN);
! #ifdef DEBUG
! printf("Output file set to: %s\n",lw_conf.out_file);
#endif
}
***************
*** 170,174 ****
#endif
break;
! case 'o':
omit_config=1;
#ifdef DEBUG
--- 188,192 ----
#endif
break;
! case 'O':
omit_config=1;
#ifdef DEBUG
***************
*** 213,216 ****
--- 231,238 ----
#endif
fclose(yyin);
+ if(!strlen(lw_conf.in_file))
+ strncpy(lw_conf.in_file,DEF_IN_FILE,MAXPATHLEN);
+ if(!strlen(lw_conf.out_file))
+ strncpy(lw_conf.out_file,DEF_OUT_FILE,MAXPATHLEN);
#ifdef DEBUG
printf("date: %i, host: %i, serv: %i, mesg: %i\n",
Index: settings.h
===================================================================
RCS file: /cvsroot/lwatch/files/src/settings.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** settings.h 21 Mar 2003 15:35:53 -0000 1.8
--- settings.h 4 Apr 2003 15:11:43 -0000 1.9
***************
*** 36,40 ****
int def_date_color,def_host_color,def_serv_color,def_mesg_color;
char conf_file[MAXPATHLEN+1];
! char fifo_file[MAXPATHLEN+1];
int create_fifo;
int show_unparsed;
--- 36,41 ----
int def_date_color,def_host_color,def_serv_color,def_mesg_color;
char conf_file[MAXPATHLEN+1];
! char in_file[MAXPATHLEN+1];
! char out_file[MAXPATHLEN+1];
int create_fifo;
int show_unparsed;
Index: yparse.l
===================================================================
RCS file: /cvsroot/lwatch/files/src/yparse.l,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** yparse.l 21 Mar 2003 15:35:55 -0000 1.15
--- yparse.l 4 Apr 2003 15:11:46 -0000 1.16
***************
*** 69,73 ****
%option noyywrap
! M_KEYWORD input_fifo|create_fifo|show_unparsed
R_KEYCOLOR date_color|host_color|serv_color|mesg_color|color|highlight
R_KEYWORD match_service|match_host|ignore|exit
--- 69,73 ----
%option noyywrap
! M_KEYWORD input_fifo|input_file|output_file|create_fifo|show_unparsed
R_KEYCOLOR date_color|host_color|serv_color|mesg_color|color|highlight
R_KEYWORD match_service|match_host|ignore|exit
***************
*** 77,81 ****
COMMENT #.*
RETOKEN |\/
! TEXT [a-zA-Z_0-9/]*
BOOL yes|no
--- 77,81 ----
COMMENT #.*
RETOKEN |\/
! TEXT [a-zA-Z_0-9/-]*
BOOL yes|no
***************
*** 101,107 ****
<*>{COMMENT} ; /* Skip comments */
<INITIAL>input_fifo= {
! yypch=lw_conf.fifo_file;
#ifdef DEBUG
! strcpy(mymsg,"input_fifo");
#endif
PUSH(TEXT);
--- 101,122 ----
<*>{COMMENT} ; /* Skip comments */
<INITIAL>input_fifo= {
! printf("lwatch.conf: OPTION input_fifo IN LINE %i IS DEPRECATED.\n.USE input_file INSTEAD IT.\n",lineno);
! yypch=lw_conf.in_file;
#ifdef DEBUG
! strcpy(mymsg,"input_file");
! #endif
! PUSH(TEXT);
! }
! <INITIAL>input_file= {
! yypch=lw_conf.in_file;
! #ifdef DEBUG
! strcpy(mymsg,"input_file");
! #endif
! PUSH(TEXT);
! }
! <INITIAL>output_file= {
! yypch=lw_conf.out_file;
! #ifdef DEBUG
! strcpy(mymsg,"output_file");
#endif
PUSH(TEXT);
***************
*** 285,289 ****
}
-
-
%%
--- 300,302 ----
|