From: Antoine Jacquet Date: Sat, 31 Aug 2002 22:00:00 +0000 (+0200) Subject: version 0.31 X-Git-Tag: v0.31 X-Git-Url: http://royale.zerezo.com/git/?a=commitdiff_plain;h=4f1235aec09bf9214b3ed89ed887024c04aea555;p=irssistats version 0.31 * spanish support (thank you Alex) * minor code changes * bugfix : division by 0 (thank you Qball) * better random topics / urls algorithm --- diff --git a/README b/README index 001b147..46b6627 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -irssistats 0.3 +irssistats 0.31 site: http://royale.zerezo.com/programmation/irssistats/ mail: royale@zerezo.com diff --git a/irssistats.c b/irssistats.c index c528da3..579fc39 100644 --- a/irssistats.c +++ b/irssistats.c @@ -18,7 +18,7 @@ #define MINWORDLENGTH 5 /* irssistats */ -#define VERSION "0.3" +#define VERSION "0.31" #define URL "http://royale.zerezo.com/programmation/irssistats/" /* Counters */ @@ -39,7 +39,7 @@ char *counters[NBCOUNTERS]={"C_SMILE","C_FROWN","C_EXCLAM","C_QUESTION","C_ME","C_TOPIC","C_MODE","C_KICK","C_KICKED","C_URL","C_JOIN","C_NICK","C_MONOLOGUE"}; /* Languages */ -#define NBLANGUAGES 2 +#define NBLANGUAGES 3 #define NBKEYS 38 char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and abbreviation */ { @@ -124,6 +124,48 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "C_JOIN", "ne sait pas s'il doit rester ou partir" }, { "C_NICK", "change souvent de nick" }, { "C_MONOLOGUE", "parle beaucoup de monologues" } + }, + { /* Spanish language */ + /* Submitted by Alex */ + { "Spanish", "es" }, + { "HEADER", "Estadísticas de #%s por %s" }, + { "LEGEND", "Leyenda" }, + { "LASTDAYS", "Estadísticas de los últimos días" }, + { "TOPHOURS", "Estadísticas por horas" }, + { "TOPUSERS", "Los que más escriben" }, + { "OTHERS", "Hay %d más que no llegaron..." }, + { "NBLINES", "líneas" }, + { "NICK", "nick" }, + { "AVGLETTERS", "letras por línea" }, + { "HOURS", "horas" }, + { "QUOTE", "Frase aleatoria" }, + { "TOPUSERSTIME", "Los que más escriben según la hora" }, + { "RANDTOPICS", "Algunos topics" }, + { "CHANGEDBY", "Puestos por" }, + { "NEWTOPIC", "topic" }, + { "RANDURLS", "Algunas URLs" }, + { "POSTEDBY", "puestas por" }, + { "POSTEDURL", "URL" }, + { "TOPWORDS", "Palabras más usadas" }, + { "WORD", "Palabra" }, + { "OCCURRENCES", "Frecuencia" }, + { "BIGNUMBERS", "Algunos datos..." }, + { "NUMBERS", "Número de veces" }, + { "TIME", "%d lineas procesadas en %d segundos" }, + { "FOOTER", "Estadísticas generadas por" }, + { "C_SMILE", "Suele estar felíz :)" }, + { "C_FROWN", "Suele estar triste :(" }, + { "C_EXCLAM", "Grita mucho !" }, + { "C_QUESTION", "Hace muchas preguntas ?" }, + { "C_ME", "Abusa del comando /me" }, + { "C_TOPIC", "Suele cambiar el topic" }, + { "C_MODE", "Cambia a veces los modos del canal" }, + { "C_KICK", "Le gusta patear" }, + { "C_KICKED", "Es pateado con frecuencia" }, + { "C_URL", "Pone muchas URLs" }, + { "C_JOIN", "No sabe si irse o quedarse" }, + { "C_NICK", "Cambia mucho de nick" }, + { "C_MONOLOGUE", "Habla solo" } } }; @@ -219,7 +261,7 @@ char *T(char *color) char *channel; char *maintainer; -struct +struct { char nick[MAXNICKLENGTH]; int lines; @@ -280,17 +322,17 @@ void findwords(char *message) while (isletter(*message)) { c=lowercase(*message)-'a'; - if ((*pos).next[(int)c]==NULL) + if (pos->next[(int)c]==NULL) { tmp=malloc(sizeof(struct letter)); - (*tmp).nb=0; - for (i=0;i<26;i++) (*tmp).next[i]=NULL; - (*pos).next[(int)c]=tmp; + tmp->nb=0; + for (i=0;i<26;i++) tmp->next[i]=NULL; + pos->next[(int)c]=tmp; } - pos=(*pos).next[(int)c]; + pos=pos->next[(int)c]; message++; } - (*pos).nb++; + pos->nb++; } return; } @@ -368,7 +410,7 @@ int dichotomic(char *nick) int main(int argc,char *argv[]) { int i,j,k; - int max,user,hour; + int max,user,temp,hour; int mononick,monolines; time_t debut; int totallines=0; @@ -449,15 +491,11 @@ int main(int argc,char *argv[]) for (i=21;message[i]!=':';i++); message=&message[i+2]; nbtopics++; - if ((nbtopics<=5) || (rand()%nbtopics==0)) + if ((nbtopics<=NBTOPICS) || (rand()%(nbtopics/NBTOPICS)==0)) { - for (i=4;i>0;i--) - { - strcpy(topics[i].nick,topics[i-1].nick); - strcpy(topics[i].topic,topics[i-1].topic); - } - strcpy(topics[0].nick,nick); - strncpy(topics[0].topic,message,MAXQUOTELENGTH); + temp=nbtopics<=NBTOPICS?nbtopics-1:rand()%NBTOPICS; + strcpy(topics[temp].nick,nick); + strncpy(topics[temp].topic,message,MAXQUOTELENGTH); } } else if (strncmp("was kicked from",message,15)==0) /* 00:00 -!- Nick was kicked from #channel by Nick [Reason] */ @@ -539,17 +577,12 @@ int main(int argc,char *argv[]) for (i=0;(message[i]!=' ') && (i0;i--) - { - strcpy(urls[i].nick,urls[i-1].nick); - strcpy(urls[i].url,urls[i-1].url); - strcpy(urls[i].shorturl,urls[i-1].shorturl); - } - strcpy(urls[0].nick,nick); - strcpy(urls[0].url,message); - strncpy(urls[0].shorturl,message,MAXQUOTELENGTH); + temp=nburls<=NBURLS?nburls-1:rand()%NBURLS; + strcpy(urls[temp].nick,nick); + strcpy(urls[temp].url,message); + strncpy(urls[temp].shorturl,message,MAXQUOTELENGTH); } } findwords(message); @@ -619,7 +652,7 @@ int main(int argc,char *argv[]) { printf("%d%s%d",T("BGTABLE"),i,T("BGTABLE"),users[user].nick,T("BGTABLE"),users[user].lines,T("BGTABLE")); for (j=0;j<4;j++) if (users[user].hours[j]!=0) printf("",j+1,100*users[user].hours[j]/users[user].lines); - printf("%d\"",T("BGTABLE"),users[user].letters/users[user].lines,T("BGTABLE"),users[user].letters/users[user].lines,T("BGTABLE")); + printf("%d\"",T("BGTABLE"),users[user].lines!=0?users[user].letters/users[user].lines:0,T("BGTABLE"),users[user].lines!=0?users[user].letters/users[user].lines:0,T("BGTABLE")); printhtml(users[user].quote); printf("\"\n"); users[user].lines=-1;