[lwatch-cvs] files/src Makefile,1.5,1.6 lwatch.c,1.8,1.9 lwatch.conf,1.3,1.4 settings.c,1.9,1.10 str
Brought to you by:
arturcz
|
From: <ar...@us...> - 2002-06-30 00:24:01
|
Update of /cvsroot/lwatch/files/src
In directory usw-pr-cvs1:/tmp/cvs-serv32424
Modified Files:
Makefile lwatch.c lwatch.conf settings.c strpcre.c strpcre.h
Log Message:
Basic color support.
Index: Makefile
===================================================================
RCS file: /cvsroot/lwatch/files/src/Makefile,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Makefile 28 Jun 2002 13:10:06 -0000 1.5
--- Makefile 30 Jun 2002 00:23:53 -0000 1.6
***************
*** 47,52 ****
acolors.o: acolors.h
lwatch.o: control.h strpcre.h settings.h
! settings.o: defaults.h control.h settings.h strpcre.h yparse.h
! strpcre.o: strpcre.h
yparse.o: acolors.h settings.h strpcre.h yparse.h
--- 47,52 ----
acolors.o: acolors.h
lwatch.o: control.h strpcre.h settings.h
! settings.o: acolors.h control.h defaults.h settings.h strpcre.h yparse.h
! strpcre.o: acolors.h settings.h strpcre.h
yparse.o: acolors.h settings.h strpcre.h yparse.h
Index: lwatch.c
===================================================================
RCS file: /cvsroot/lwatch/files/src/lwatch.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** lwatch.c 29 Jun 2002 15:04:37 -0000 1.8
--- lwatch.c 30 Jun 2002 00:23:53 -0000 1.9
***************
*** 93,98 ****
while((pstop=strchr(pstart,'\n'))!=NULL) {
(*pstop++)='\0';
! /* parseline(pstart); */
! printf("%s\n",pstart);
pstart=pstop;
}
--- 93,97 ----
while((pstop=strchr(pstart,'\n'))!=NULL) {
(*pstop++)='\0';
! showline(pstart);
pstart=pstop;
}
Index: lwatch.conf
===================================================================
RCS file: /cvsroot/lwatch/files/src/lwatch.conf,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** lwatch.conf 28 Jun 2002 01:20:21 -0000 1.3
--- lwatch.conf 30 Jun 2002 00:23:53 -0000 1.4
***************
*** 1,6 ****
# Config file for lwatch
# Created by Artur Czechowski <ar...@he...>
! # $Id $
! # $Source $
# Format of this file is described in manual FIXME
--- 1,6 ----
# Config file for lwatch
# Created by Artur Czechowski <ar...@he...>
! # $Id$
! # $Source$
# Format of this file is described in manual FIXME
***************
*** 13,17 ****
# Default color for displaing message body
# mesg_color=white
! mesg_color=green
# Where is source for reading data?
--- 13,17 ----
# Default color for displaing message body
# mesg_color=white
! serv_color=green
# Where is source for reading data?
Index: settings.c
===================================================================
RCS file: /cvsroot/lwatch/files/src/settings.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** settings.c 29 Jun 2002 13:44:57 -0000 1.9
--- settings.c 30 Jun 2002 00:23:53 -0000 1.10
***************
*** 37,40 ****
--- 37,41 ----
#include <unistd.h>
+ #include "acolors.h"
#include "defaults.h"
#include "control.h"
***************
*** 43,50 ****
#include "yparse.h"
- #ifdef DEBUG
- #include "acolors.h"
- #endif
-
struct s_conf lw_conf;
struct s_action *lw_actions;
--- 44,47 ----
***************
*** 147,150 ****
--- 144,151 ----
void parse_config(void) {
+ lw_conf.def_date_color=FGCYAN;
+ lw_conf.def_host_color=FGMAGENTA;
+ lw_conf.def_serv_color=FGBLUE;
+ lw_conf.def_mesg_color=FGWHITE;
if(omit_config)
return;
Index: strpcre.c
===================================================================
RCS file: /cvsroot/lwatch/files/src/strpcre.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** strpcre.c 28 Jun 2002 11:03:58 -0000 1.2
--- strpcre.c 30 Jun 2002 00:23:53 -0000 1.3
***************
*** 34,39 ****
--- 34,46 ----
#include <string.h>
+ #include "acolors.h"
+ #include "settings.h"
#include "strpcre.h"
+ #define DATE_COLOR colmode[date_c]
+ #define HOST_COLOR colmode[host_c]
+ #define SERV_COLOR colmode[serv_c]
+ #define MESG_COLOR colmode[mesg_c]
+
struct {
pcre *pre;
***************
*** 41,44 ****
--- 48,56 ----
} parser;
+ struct {
+ int start,stop;
+ } re_matches[RE_NMATCHES];
+
+
int compile_re(char *re, pcre **pre, pcre_extra **prh) {
const char *re_error;
***************
*** 104,105 ****
--- 116,137 ----
}
+ void showline(char *input) {
+ int n;
+ int date_c,host_c,serv_c,mesg_c;
+ const char **re_str;
+
+ //memcpy((void*)&date_c,(void*)&lw_conf.def_date_color,4*sizeof(int));
+ date_c=lw_conf.def_date_color;
+ host_c=lw_conf.def_host_color;
+ serv_c=lw_conf.def_serv_color;
+ mesg_c=lw_conf.def_mesg_color;
+ n=pcre_exec(parser.pre,parser.prh,input,strlen(input),0,0,
+ (int*)&re_matches,RE_NMATCHES);
+ pcre_get_substring_list(input,(int*)&re_matches,n,&re_str);
+ printf("%s%s%s%s%s%s%s%s"_S_RESET"\n",
+ DATE_COLOR,re_str[1],
+ HOST_COLOR,re_str[2],
+ SERV_COLOR,re_str[3],
+ MESG_COLOR,re_str[4]);
+ pcre_free_substring_list(re_str);
+ }
Index: strpcre.h
===================================================================
RCS file: /cvsroot/lwatch/files/src/strpcre.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** strpcre.h 28 Jun 2002 11:03:58 -0000 1.3
--- strpcre.h 30 Jun 2002 00:23:53 -0000 1.4
***************
*** 34,37 ****
--- 34,38 ----
#define PCRE_COPT PCRE_CASELESS|PCRE_DOTALL
#define PARSELINE "^(.+?\\s.+?\\s.+?\\s)(.+?\\s)(.+?:\\s)(.*)$"
+ #define RE_NMATCHES 30
#define freestr(a) free((void*)a); a=NULL
***************
*** 41,42 ****
--- 42,44 ----
char *newstr(char *str);
char *addstr(char *s1, const char *s2);
+ void showline(char *str);
|