X-Git-Url: http://royale.zerezo.com/git/?p=irssistats;a=blobdiff_plain;f=irssistats.c;h=b7a855ca2ec362c4e8b13465d5796e67c3bd2a89;hp=2ecbf427135b91e9eacca4b08f7130f522664cc1;hb=3908ded2c18f259d9eea9f31600020cf940ada3e;hpb=28cb9313d122c6e781833259cebcbb0c94dc9241 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) {