[lwatch-cvs] files/src acolors.h,1.3,1.4 strpcre.c,1.7,1.8
Brought to you by:
arturcz
|
From: <ar...@us...> - 2002-07-14 22:47:21
|
Update of /cvsroot/lwatch/files/src
In directory usw-pr-cvs1:/tmp/cvs-serv29025
Modified Files:
acolors.h strpcre.c
Log Message:
Part of new colourizing system.
Index: acolors.h
===================================================================
RCS file: /cvsroot/lwatch/files/src/acolors.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** acolors.h 13 Jul 2002 00:29:10 -0000 1.3
--- acolors.h 14 Jul 2002 22:47:13 -0000 1.4
***************
*** 59,62 ****
--- 59,63 ----
#define _S_BGWHITE "\e[47m"
+ #define _N_NATURAL 0
#define _N_CLEAR 1
#define _N_RESET _N_CLEAR
Index: strpcre.c
===================================================================
RCS file: /cvsroot/lwatch/files/src/strpcre.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** strpcre.c 13 Jul 2002 00:25:45 -0000 1.7
--- strpcre.c 14 Jul 2002 22:47:13 -0000 1.8
***************
*** 38,41 ****
--- 38,42 ----
#include "strpcre.h"
+ /* We change an idea
#define DATE_COLOR colmode[date_c]
#define HOST_COLOR colmode[host_c]
***************
*** 43,46 ****
--- 44,54 ----
#define MESG_COLOR colmode[mesg_c]
#define HL_COLOR colmode[hl_c]
+ */
+
+ #define DATE_COLOR date_c
+ #define HOST_COLOR host_c
+ #define SERV_COLOR serv_c
+ #define MESG_COLOR mesg_c
+ #define HL_COLOR hl_c
struct {
***************
*** 119,141 ****
char *hl_str(struct s_action *act,char *str) {
char *pmatch,*pres;
int i,j;
int start_match;
pmatch=newstr(str);
start_match=0;
while(pcre_exec(act->re,act->rh,pmatch,strlen(pmatch),start_match,0,(int*)&re_matches,RE_NMATCHES)>0) {
! pres=(char*)malloc(strlen(pmatch)+strlen(HL_COLOR)+strlen(MESG_COLOR)+1);
i=j=0;
while(j<re_matches->start)
pres[i++]=pmatch[j++];
j=0;
! while(pres[i++]=HL_COLOR[j++]);
i--;
j=re_matches->start;
while(j<re_matches->stop)
pres[i++]=pmatch[j++];
! pres[i]='\0';
j=0;
! while(pres[i++]=MESG_COLOR[j++]);
i--;
j=re_matches->stop;
--- 127,152 ----
char *hl_str(struct s_action *act,char *str) {
+ static char zero[]="^00";
char *pmatch,*pres;
+ char ctrl[4];
int i,j;
int start_match;
pmatch=newstr(str);
start_match=0;
+ sprintf(ctrl,"^%02i",HL_COLOR);
while(pcre_exec(act->re,act->rh,pmatch,strlen(pmatch),start_match,0,(int*)&re_matches,RE_NMATCHES)>0) {
! pres=(char*)malloc(strlen(pmatch)+7); /* ^cc ^00 NULL */
i=j=0;
while(j<re_matches->start)
pres[i++]=pmatch[j++];
j=0;
! while(pres[i++]=ctrl[j++]);
i--;
j=re_matches->start;
while(j<re_matches->stop)
pres[i++]=pmatch[j++];
! pres[i]='\0'; /* is this necessary? */
j=0;
! while(pres[i++]=zero[j++]);
i--;
j=re_matches->stop;
***************
*** 143,147 ****
free(pmatch);
pmatch=pres;
! start_match=re_matches->stop+strlen(MESG_COLOR);
}
return(pres);
--- 154,158 ----
free(pmatch);
pmatch=pres;
! start_match=re_matches->stop+4;
}
return(pres);
***************
*** 202,206 ****
#endif
if(!ignore) {
! printf("%s%s%s%s%s%s%s%s"_S_RESET"\n",
DATE_COLOR,date_s,
HOST_COLOR,host_s,
--- 213,217 ----
#endif
if(!ignore) {
! printf("^%02i%s^%02i%s^%02i%s^%02i%s^01\n",
DATE_COLOR,date_s,
HOST_COLOR,host_s,
|