]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
A few trivial optimizations
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Fri, 8 Jan 2010 15:32:48 +0000 (15:32 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Fri, 8 Jan 2010 15:32:48 +0000 (15:32 +0000)
grepday.c
report.c

index 6eca22defc12850269a636e47f0d09892d434835..d5d8bdeacdbbcc86fdadcbb09caa47699f5b28e4 100644 (file)
--- a/grepday.c
+++ b/grepday.c
@@ -245,9 +245,10 @@ void greport_day(const char *user)
    char csort[255];
    char data[20];
    int  count=0;
-   char oday[20];
-   char day[20];
-   char bytes[20];
+   int oday=0;
+   int day=0;
+   long long int llday;
+   long long int bytes;
    char ftime[128];
    long long int tot=0;
    time_t t;
@@ -443,37 +444,37 @@ void greport_day(const char *user)
          exit(1);
       }
       getword_start(&gwarea1,data);
-      if (getword(day,sizeof(day),&gwarea1,'/')<0) {
+      if (getword_atoll(&llday,&gwarea1,'/')<0) {
          printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp5);
          exit(1);
       }
       if(strcmp(DateFormat,"u") == 0) {
-         if (getword(day,sizeof(day),&gwarea1,'/')<0) {
+         if (getword_atoll(&llday,&gwarea1,'/')<0) {
             printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp5);
             exit(1);
          }
       }
+      day=(int)llday;
       if(!count) {
-         strcpy(oday,day);
+         oday=day;
          count++;
       }
-      if (getword(bytes,sizeof(bytes),&gwarea,'\t')<0 || getword(bytes,sizeof(bytes),&gwarea,'\t')<0) {
+      if (getword_skip(20,&gwarea,'\t')<0 || getword_atoll(&bytes,&gwarea,'\t')<0) {
          printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp5);
          exit(1);
       }
 
-      if(strcmp(oday,day) != 0) {
-         strcpy(warea,oday);
-         x1 = 44 +(atoi(oday) * 20);
+      if(oday!=day) {
+         x1 = 44 +(oday * 20);
          bar(x1,tot);
-         strcpy(oday,day);
+         oday=day;
          tot=0;
       }
-      tot=tot+my_atoll(bytes);
+      tot+=bytes;
    }
 
    if(tot) {
-      x1 = 44 +(atoi(day) * 20);
+      x1 = 44 +(day * 20);
       bar(x1,tot);
    }
 
index 6547c6d75050e31499f1efc53428151759a9a799..05998e7fbd62be389beb1e85af211cc394d3d7f1 100644 (file)
--- a/report.c
+++ b/report.c
@@ -328,7 +328,7 @@ void gerarel(void)
    if(email[0] == '\0') {
       if(strstr(ReportType,"downloads") != 0) download_report();
 
-      if(strlen(DansGuardianConf) > 0) {
+      if(DansGuardianConf[0] != '\0') {
          strcpy(wdirname,dirname);
          dansguardian_log();
       }
@@ -349,7 +349,7 @@ void gerarel(void)
 
       if(smartfilter) smartfilter_report();
 
-      if(strlen(DansGuardianConf) > 0) dansguardian_report();
+      if(DansGuardianConf[0] != '\0') dansguardian_report();
 
       squidguard_report();