From 3908ded2c18f259d9eea9f31600020cf940ada3e Mon Sep 17 00:00:00 2001 From: Antoine Jacquet Date: Mon, 14 Oct 2002 00:00:00 +0200 Subject: [PATCH] version 0.4 * nick alias support using regular expression * some code fix --- Makefile | 2 +- README | 14 ++++++++-- irssistats.c | 68 +++++++++++++++++++++++++++++++++++---------- sample.nickfile.txt | 57 +++++++++++++++++++++++++++++++++++++ 4 files changed, 123 insertions(+), 18 deletions(-) create mode 100644 sample.nickfile.txt diff --git a/Makefile b/Makefile index b18226a..1e9ff5b 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,2 @@ irssistats:irssistats.c - gcc -ansi -pedantic -Wall -Werror -o irssistats irssistats.c + gcc -o irssistats irssistats.c diff --git a/README b/README index 03656ab..01aaf4f 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -irssistats 0.32 +irssistats 0.4 site: http://royale.zerezo.com/programmation/irssistats/ mail: royale@zerezo.com @@ -7,7 +7,17 @@ make cp pix/*.png /path/to/webdir/ usage: -cat /path/to/file.log | ./irssistats channel maintainer language theme > /path/to/webdir/index.html +cat /path/to/file.log | ./irssistats channel maintainer language theme [nickfile] > /path/to/webdir/index.html + +nickfile: +Since version 0.4 of irssistats, you can use a nickfile to specify nicks to join. +Each line of the nickfile contains the final nick and a regular expression. +Examples : + royale ^[Rr]oyale : join nicks starting with "Royale" or "royale" to the final nick "royale" + royale ^antoine$ : also join the nick "antoine" to the final nick "royale" + djakette [Dd]ja : join any nick that contains "Dja" or "dja" to final nick "djakette" +The nickfile must not contain any comments. +You can also take a look at the "sample.nickfile.txt" in this package. links: http://torus.lnet.lut.fi/ircstats/ diff --git a/irssistats.c b/irssistats.c index 2ecbf42..b7a855c 100644 --- a/irssistats.c +++ b/irssistats.c @@ -1,9 +1,10 @@ -/* Usage: cat /path/to/file.log | ./irssistats channel maintainer language theme > /path/to/file.html */ +/* Usage: cat /path/to/file.log | ./irssistats channel maintainer language theme [nickfile] > /path/to/file.html */ #include #include #include #include +#include /* Config */ #define MAXUSERS 5000 @@ -18,7 +19,7 @@ #define MINWORDLENGTH 5 /* irssistats */ -#define VERSION "0.32" +#define VERSION "0.4" #define URL "http://royale.zerezo.com/programmation/irssistats/" /* Counters */ @@ -460,12 +461,14 @@ int main(int argc,char *argv[]) char c; char *nick,*message; char line[MAXLINELENGTH]; + FILE *fic; + regex_t preg; /*** INIT ***/ - if (argc!=5) + if ((argc<5) || (argc>6)) { - fprintf(stderr,"Usage: cat /path/to/file.log | ./irssistats channel maintainer language theme > /path/to/file.html\n\n"); + fprintf(stderr,"Usage: cat /path/to/file.log | ./irssistats channel maintainer language theme [nickfile] > /path/to/file.html\n\n"); fprintf(stderr,"Version :\nirssistats %s\n\n",VERSION); fprintf(stderr,"Supported languages :\n"); for (i=0;i') /* 00:00 <>>>?Nick<<<> the personal message */ + /* 00:00 <>>?Nick<<> the personal message */ { - for (i=11;line[i]!='<';i++); - nick=&line[11]; + for (i=10;line[i]!='<';i++); + nick=&line[10]; + if (line[9]=='>') nick++; message=&line[i+5]; } else /* 00:00 the message */ @@ -636,6 +639,39 @@ int main(int argc,char *argv[]) bestwords(words,0); + /*** ALIAS ***/ + + if (argc==6) + { + if ((fic=fopen(argv[5],"rt"))==NULL) { fprintf(stderr,"can't open nick file\n"); exit(1); } + while (fscanf(fic,"%s",line)==1) + { + user=dichotomic(line); + fscanf(fic,"%s",line); + if (regcomp(&preg,line,0)!=0) { fprintf(stderr,"error in nick file"); exit(1); } + temp=users[user].lines; + for (i=0;i=0)) + { + if (users[i].lines>temp) /* for nick alias, keep the random quote of the most used nick */ + { + strcpy(users[user].quote,users[i].quote); + temp=users[i].lines; + } + users[user].lines+=users[i].lines; + users[user].letters+=users[i].letters; + for (j=0;j<4;j++) users[user].hours[j]+=users[i].hours[j]; + for (j=0;jmax) max=users[user=j].lines; if (user!=-1) { @@ -701,10 +737,12 @@ int main(int argc,char *argv[]) } } printf("\n"); - if (nbusers>NBUSERS) + temp=0; + for (i=0;i<=nbusers;i++) if (users[i].lines>=0) temp++; + if (temp>0) { printf("
"); - printf(L("OTHERS"),nbusers-50); + printf(L("OTHERS"),temp); printf("
\n"); } printf("

\n\n"); @@ -720,7 +758,7 @@ int main(int argc,char *argv[]) for (j=0;j<4;j++) { user=-1; - max=-1; + max=0; for (k=0;kmax) max=users[user=k].hours[j]; if (user!=-1) { diff --git a/sample.nickfile.txt b/sample.nickfile.txt new file mode 100644 index 0000000..25d6d2d --- /dev/null +++ b/sample.nickfile.txt @@ -0,0 +1,57 @@ +royale ^royale +royale ^antoine + +sektor ^[Ss]ektor +sektor ^[Ss]oviet +sektor ^guillaume + +Skorn ^Skorn + +ed- ^ed +ed- ^fionna +ed- ^voyager +ed- ^laurent + +Baloo ^Baloo + +DocJ [Dd]oc[Jj] + +Connard ^Connard + +Trash ^Trash + +Zetam ^[Zz]etam + +vinc ^vinc + +Clak ^Clak + +N4in N4in + +Kin ^Kin + +J377 J377 + +SpetsnaZ ^SpetsnaZ +SpetsnaZ Spets + +eXistenZ e[Xx]isten[Zz] + +tit-namour ^tit + +Domitille Domi +Domitille Domy +Domitille Mimitille + +Kalimero ^Jo\[zeRezo\] + +Djakette [Dd]jakette +Djakette ^\[BTF\]Dja +Djakette ^FonsD\|Dja +Djakette ^dja + +piTi``kOrB` ^piTi``kOrB` + +Clowny Clowny + +toul toul \ No newline at end of file -- 2.20.1