small irssistats localization patch
[irssistats] / irssistats.c
index e287e77..e2e0691 100644 (file)
@@ -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]
  *
  * This tool generates IRC stats based on irssi logs.
  * Usage: irssistats [/path/to/file.conf]
@@ -49,7 +49,7 @@
 #define MINWORDLENGTH 5
 
 /* irssistats */
 #define MINWORDLENGTH 5
 
 /* irssistats */
-#define VERSION "0.74"
+#define VERSION "0.75"
 #define URL "http://royale.zerezo.com/irssistats/"
 
 /* Counters */
 #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",         "ÓÌÏ×Ï" },
     { "POSTEDURL",    "URL" },
     { "TOPWORDS",     "þÁÓÔÏ ÉÓÐÏÌØÚÕÅÍÙÅ ÓÌÏ×Á" },
     { "WORD",         "ÓÌÏ×Ï" },
-    { "OCCURRENCES",  "ÐÒÏÉÛÅÓÔ×ÉÑ" },
+    { "OCCURRENCES",  "ÐÒÏÉÓÛÅÓÔ×ÉÑ" },
     { "BIGNUMBERS",   "îÅÓËÏÌØËÏ ÂÏÌØÛÉÈ ÞÉÓÅÌ..." },
     { "NUMBERS",      "ÞÉÓÌÁ" },
     { "TIME",         "%d ÓÔÒÏË (%d ÄÎÅÊ) ÏÂÒÁÂÏÔÁÎÏ ÚÁ %d ÓÅËÕÎÄ" },
     { "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 (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]++;
         if (strncmp("http://",message,7)==0)
         {
           users[i].counters[D_URL]++;
@@ -1544,19 +1561,19 @@ void gen_xhtml(char *xhtmlfile)
   fclose(fic);
 }
 
   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];
   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, "");
 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);
   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);
 }
   }
   return(0);
 }
+