X-Git-Url: http://royale.zerezo.com/git/?p=irssistats;a=blobdiff_plain;f=irssistats.c;h=e2e0691462cc1e12e5a999e18a7a58fe2aa67500;hp=e287e770703b3c56630252fb2638001fda7971cf;hb=15f7335dede205c07b40a2fc419151f3d717e534;hpb=b0ce1f03b1c243f376a37773641161c55349bcf3 diff --git a/irssistats.c b/irssistats.c index e287e77..e2e0691 100644 --- a/irssistats.c +++ b/irssistats.c @@ -1,5 +1,5 @@ /* - * irssistats version 0.74 + * irssistats version 0.75 * * This tool generates IRC stats based on irssi logs. * Usage: irssistats [/path/to/file.conf] @@ -49,7 +49,7 @@ #define MINWORDLENGTH 5 /* irssistats */ -#define VERSION "0.74" +#define VERSION "0.75" #define URL "http://royale.zerezo.com/irssistats/" /* Counters */ @@ -504,7 +504,7 @@ char *keys[NBLANGUAGES][NBKEYS+1][2]= /* first key used for language name and ab { "POSTEDURL", "URL" }, { "TOPWORDS", "þÁÓÔÏ ÉÓÐÏÌØÚÕÅÍÙÅ ÓÌÏ×Á" }, { "WORD", "ÓÌÏ×Ï" }, - { "OCCURRENCES", "ÐÒÏÉÛÅÓÔ×ÉÑ" }, + { "OCCURRENCES", "ÐÒÏÉÓÛÅÓÔ×ÉÑ" }, { "BIGNUMBERS", "îÅÓËÏÌØËÏ ÂÏÌØÛÉÈ ÞÉÓÅÌ..." }, { "NUMBERS", "ÞÉÓÌÁ" }, { "TIME", "%d ÓÔÒÏË (%d ÄÎÅÊ) ÏÂÒÁÂÏÔÁÎÏ ÚÁ %d ÓÅËÕÎÄ" }, @@ -1164,7 +1164,24 @@ void parse_log(char *logfile) if (message[j-1]==')') users[i].counters[D_SMILE]++; else if (message[j-1]=='(') users[i].counters[D_FROWN]++; } - if (rand()%users[i].lines==0) strncpy(users[i].quote,message,MAXQUOTELENGTH); + // Fetch a random message, messages between 25 and 70 chars are + // preferred (pisg-style, gets "better" quotes) + // + if (rand()%users[i].lines==0) { + + int len = strlen(message); + // if we have a "good" quote, use it + if ( len > 25 && len < 70 ) + { + strncpy(users[i].quote,message,MAXQUOTELENGTH); + } else { + int len2 = strlen(users[i].quote); + if ( !(len2 > 25 && len2 < 70 )) { + strncpy(users[i].quote,message,MAXQUOTELENGTH); + } + } + } + if (strncmp("http://",message,7)==0) { users[i].counters[D_URL]++; @@ -1544,19 +1561,19 @@ void gen_xhtml(char *xhtmlfile) fclose(fic); } -void parse_config(char *configfile) +void expand(char *path) { - void expand(char *path) + char temp[MAXLINELENGTH]; + if (*path=='~') { - char temp[MAXLINELENGTH]; - if (*path=='~') - { - snprintf(temp,MAXLINELENGTH-1,"%s%s",getenv("HOME"),path+1); - temp[MAXLINELENGTH-1]='\0'; - strcpy(path,temp); - } + snprintf(temp,MAXLINELENGTH-1,"%s%s",getenv("HOME"),path+1); + temp[MAXLINELENGTH-1]='\0'; + strcpy(path,temp); } - +} + +void parse_config(char *configfile) +{ FILE *fic; char line[MAXLINELENGTH]; char keyword[MAXLINELENGTH]; @@ -1812,7 +1829,6 @@ void parse_config(char *configfile) int main(int argc,char *argv[]) { (void) setlocale(LC_ALL, ""); - if ((users=malloc(maxusers*sizeof(struct user)))==NULL) { fprintf(stderr,"unable to malloc memory\n"); exit(1); } srand(debut=time(NULL)); if (argc==1) parse_config(NULL); @@ -1825,3 +1841,4 @@ int main(int argc,char *argv[]) } return(0); } +