]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Applied an extended version of debian patch: opensuse_5_limit_sprintf.patch
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 9 Jul 2009 13:05:23 +0000 (13:05 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 9 Jul 2009 13:05:23 +0000 (13:05 +0000)
Function debuga format the output string itself, so there is no need to use sprintf.

17 files changed:
configure
configure.in
dansguardian_log.c
datafile.c
decomp.c
getconf.c
html.c
include/conf.h
include/defs.h
index.c
lastlog.c
log.c
report.c
sort.c
squidguard_log.c
useragent.c
util.c

index 35ae8f11390a1580f4c01e83336113117adab9d1..7f845cf8dab7d4771e30b6a3c97c81c52ccbab0f 100755 (executable)
--- a/configure
+++ b/configure
@@ -4668,12 +4668,13 @@ done
 
 
 
+
 
 
 for ac_header in stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \
                 dirent.h sys/socket.h netdb.h arpa/inet.h sys/types.h netinet/in.h sys/stat.h \
                 ctype.h gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h iconv.h \
-                errno.h sys/resource.h sys/wait.h
+                errno.h sys/resource.h sys/wait.h stdarg.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
index 108ebff58bd0a188121b330630ebb64ffa61b3d1..156046a4560e9d29d71c9a4d4f9bdcc71ecbef46 100644 (file)
@@ -48,7 +48,7 @@ fi
 AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \
                 dirent.h sys/socket.h netdb.h arpa/inet.h sys/types.h netinet/in.h sys/stat.h \
                 ctype.h gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h iconv.h \
-                errno.h sys/resource.h sys/wait.h)
+                errno.h sys/resource.h sys/wait.h stdarg.h)
 
 AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD="yes", HAVE_GD="")
 
index 8abd018b6ab6e2d32469fe88d0d04ee44a7e2999..bd913f3e9c9229eb5b48fd2bb0dbf55dc96ae737 100644 (file)
@@ -77,8 +77,7 @@ void dansguardian_log(void)
    sprintf(guard_ou,"%s/dansguardian.log",tmp);
 
    if(access(DansGuardianConf, R_OK) != 0) {
-      sprintf(msg,"Cannot open DansGuardian config file: %s",DansGuardianConf);
-      debuga(msg);
+      debuga("Cannot open DansGuardian config file: %s",DansGuardianConf);
       exit(1);
    }
 
@@ -112,8 +111,7 @@ void dansguardian_log(void)
          printf("SARG: Maybe you have a broken record or garbage in your %s entry.\n",text[7]);
          exit(1);
       }
-      sprintf(msg,"%s DansGuardian %s: %s",urly,buf,loglocation);
-      debuga(msg);
+      debuga("%s DansGuardian %s: %s",urly,buf,loglocation);
    }
 
    if((fp_in=MY_FOPEN(loglocation,"r"))==NULL) {
@@ -153,10 +151,8 @@ void dansguardian_log(void)
    if(fp_guard) fclose(fp_guard);
    if(fp_ou) fclose(fp_ou);
 
-   if(debug) {
-      sprintf(msg,"%s: %s",text[54],guard_ou);
-      debuga(msg);
-   }
+   if(debug)
+      debuga("%s: %s",text[54],guard_ou);
 
    sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 '%s' -o '%s'",guard_in, guard_ou);
    cstatus=system(tmp6);
index 9b674c06b2e2e018302ca08628e4797377a94d18..f0dea830d83197942effd864ab132743c46cd100 100644 (file)
@@ -40,7 +40,6 @@ void data_file(char *tmp)
    char olduser[MAXLEN], oldmsg[50], acccode[50], oldaccelap[10], oldacccode[50];
    char ipantes[MAXLEN], nameantes[MAXLEN]; 
    char accsmart[MAXLEN];
-   char Msg[MAXLEN];
    char wcrc[50];
    char crc2[50];
    char wdname[MAXLEN];
@@ -149,10 +148,8 @@ void data_file(char *tmp)
 }
    
    (void)closedir( dirp );
-   if(debug) {
-      sprintf(Msg,"Datafile %s successfully",DataFile);
-      debuga(Msg);
-   }
+   if(debug)
+      debuga("Datafile %s successfully",DataFile);
 }
 
 void saverecs(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache)
index 50ca8a5d9bf20bcd880d118867b8dcc1b270b6f0..686b73bbf4b9a12e341787eb70f49f6f3e41d119 100644 (file)
--- a/decomp.c
+++ b/decomp.c
@@ -32,14 +32,12 @@ void decomp(char *arq, char *zip, const char *tmp)
    int cstatus;
 
    if(access(arq, R_OK) != 0) {
-      sprintf(cmd,"%s: %s",text[64],arq);
-      debuga(cmd);
+      debuga("%s: %s",text[64],arq);
       exit(1);
    }
 
    if(strstr(arq,".gz") !=0) {
-      sprintf(cmd,"%s: %s > %s/sarg-file.in (zcat)",text[62],arq,tmp);
-      debuga(cmd);
+      debuga("%s: %s > %s/sarg-file.in (zcat)",text[62],arq,tmp);
       sprintf(cmd,"zcat %s > %s/sarg-file.in",arq,tmp);
       cstatus=system(cmd);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
@@ -53,8 +51,7 @@ void decomp(char *arq, char *zip, const char *tmp)
    }
 
    if(strstr(arq,".bz2") != 0) {
-      sprintf(cmd,"%s: %s > %s/sarg-file.in (bzcat)",text[62],arq,tmp);
-      debuga(cmd);
+      debuga("%s: %s > %s/sarg-file.in (bzcat)",text[62],arq,tmp);
       sprintf(cmd,"bzcat %s > %s/sarg-file.in",arq,tmp);
       cstatus=system(cmd);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
@@ -68,8 +65,7 @@ void decomp(char *arq, char *zip, const char *tmp)
    }
 
    if(strstr(arq,".Z")) {
-      sprintf(cmd,"%s: %s (uncompress)",text[62],arq);
-      debuga(cmd);
+      debuga("%s: %s (uncompress)",text[62],arq);
       sprintf(cmd,"uncompress %s",arq);
       cstatus=system(cmd);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
@@ -92,17 +88,15 @@ void recomp(const char *arq, const char *zip)
    int cstatus;
 
    if(access(arq, R_OK) != 0) {
-      sprintf(cmd,"%s: %s",text[64],arq);
-      debuga(cmd);
+      debuga("%s: %s",text[64],arq);
       exit(1);
    }
 
    if((strcmp(zip,"gzip") != 0) &&
       (strcmp(zip,"compress") != 0))
       return;
-   
-   sprintf(cmd,"%s: %s",text[63],arq);
-   debuga(cmd);
+
+   debuga("%s: %s",text[63],arq);
 
    sprintf(cmd,"%s %s",zip,arq);
    cstatus=system(cmd);
index f2fb8cc5c30d484fd1e63ecf97a3156934ad8d01..c9d71c3360dba5c050b7c62761e5836fe2f0a5af 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -1097,10 +1097,8 @@ void getconf(void)
    FILE *fp_in;
    char buf[MAXLEN];
 
-   if(debug) {
-      sprintf(Msg,"Loading configuration from: %s",ConfigFile);
-      debuga(Msg);
-   }
+   if(debug)
+      debuga("Loading configuration from: %s",ConfigFile);
 
    if ((fp_in = fopen(ConfigFile, "r")) == NULL) {
       fprintf(stderr, "SARG: (getconf) Cannot open file: %s\n",ConfigFile);
diff --git a/html.c b/html.c
index c88b6efd6d72d402e73a898892645de8ed403c3c..7f42f41f739d4168302929835d86abe2832f6d20 100644 (file)
--- a/html.c
+++ b/html.c
@@ -285,10 +285,9 @@ void htmlrel(void)
          if(userip) {
             strcpy(u2,usuario);
             fixip(u2);
-            sprintf(msg, "%s: %s",text[61],u2);
+            debuga("%s: %s",text[61],u2);
          } else
-            sprintf(msg, "%s: %s",text[61],usuario);
-            debuga(msg);
+            debuga("%s: %s",text[61],usuario);
       }
 
       fscanf(fp_in,"%s",nacc);
@@ -635,10 +634,8 @@ void htmlrel(void)
                fprintf(fp_usr,"%s\n",u2);
                fclose(fp_usr);
 
-               if(debug) {
-                  sprintf(msg, "%s %s %s (%s MB). %s %s",text[32],u2,text[74],PerUserLimit,text[75],PerUserLimitFile);
-                  debuga(msg);
-               }
+               if(debug)
+                  debuga("%s %s %s (%s MB). %s %s",text[32],u2,text[74],PerUserLimit,text[75],PerUserLimitFile);
             }
          }
       }
index 6a9063fbce7fb6d5aa5ad69539e0035ce59f6440..f9a2c712bbe55188db2eced21ce4b923302eda4c 100755 (executable)
@@ -79,6 +79,9 @@ gdPoint points[4];
 #if HAVE_GDFONTG_H
 #include <gdfontg.h>
 #endif
+#if HAVE_STDARG_H
+#include <stdarg.h>
+#endif
 
 #if HAVE_FOPEN64
 #define _FILE_OFFSET_BITS 64
index ea7d4e96eb109a9c781e0e7eb0175f3de38a7bb2..3f8a05cc007819cac5d8311ff91379025610fcc0 100755 (executable)
@@ -132,7 +132,7 @@ void write_html_header(FILE *fp_ou, const char * ind);
 void write_html_trailer(FILE *fp_ou);
 char *subs(char *str, char *from, char *to);
 void conv_month(char *month);
-void debuga(const char *msg);
+void debuga(const char *msg,...);
 void debugaz(const char *head, const char *msg);
 void my_lltoa(unsigned long long int n, char s[], int len);
 char *get_size(const char *path, const char *file);
diff --git a/index.c b/index.c
index 22bd7cb22fbea31d181c212a675cf8baace16eac..af32b5d85c3bad5c546acfd0734a8c836a45920d 100644 (file)
--- a/index.c
+++ b/index.c
@@ -66,7 +66,7 @@ void make_index(void)
       return;
    }
 
-   if(debug) debuga(text[53]);
+   if(debug) debuga("%s",text[53]);
 
   // Root dir
    dirp = opendir(outdir);
index 1c9a893de4deea04566918f3564da33b8dc6a7ba..bdf42585c69207f077cb4ca90d943beab66b0f05 100644 (file)
--- a/lastlog.c
+++ b/lastlog.c
@@ -101,10 +101,8 @@ void mklastlog(const char *outdir)
       buf[strlen(buf)-1]='\0';
      
       if(ftot) {
-         if(debug) {
-            sprintf(msg,"%s: %s",text[81],buf);
-            debuga(msg);
-         }
+         if(debug)
+            debuga("%s: %s",text[81],buf);
 //         sprintf(temp,"%s%s",outdir,buf);
          sprintf(temp,"rm -r %s%s",outdir,buf);
          system(temp);
diff --git a/log.c b/log.c
index 58100b0f560ef12d8d06b8568bb265325a9402de..eb27ac3b3358cc82e2d3925d715f1bbdcd638394 100644 (file)
--- a/log.c
+++ b/log.c
@@ -422,8 +422,7 @@ int main(int argc,char *argv[])
 
    if(ConfigFile[0] == '\0') sprintf(ConfigFile,"%s/sarg.conf",SYSCONFDIR);
    if(access(ConfigFile, R_OK) != 0) {
-      sprintf(msg,"Cannot open config file: %s - %s",ConfigFile,strerror(errno));
-      debuga(msg);
+      debuga("Cannot open config file: %s - %s",ConfigFile,strerror(errno));
       exit(1);
    }
 
@@ -483,8 +482,7 @@ int main(int argc,char *argv[])
       strcpy(hexclude,ExcludeHosts);
    if(strlen(hexclude) > 0) {
       if(access(hexclude, R_OK) != 0) {
-         sprintf(msg,"Cannot open exclude_hosts file: %s - %s",hexclude,strerror(errno));
-         debuga(msg);
+         debuga("Cannot open exclude_hosts file: %s - %s",hexclude,strerror(errno));
          exit(1);
       }
       gethexclude(hexclude,debug);
@@ -648,10 +646,8 @@ int main(int argc,char *argv[])
       printf("Language=%s\n\n",text[3]);
    }
 
-   if(debug){
-      sprintf(msg,"sarg %s: %s",text[73],VERSION);
-      debuga(msg);
-   }
+   if(debug)
+      debuga("sarg %s: %s",text[73],VERSION);
 
    if (strlen(Ulimit) > 0) {
 #if defined(RLIMIT_NOFILE)
@@ -670,15 +666,12 @@ int main(int argc,char *argv[])
  #elif defined(RLIMIT_OFILE)
          if(setrlimit (RLIMIT_OFILE, &rl) == -1) {
  #endif
-            sprintf(msg,"setrlimit error - %s\n",strerror(errno));
-            debuga(msg);
+            debuga("setrlimit error - %s\n",strerror(errno));
          }
       }
 
-      if(debug) {
-         sprintf(msg,"Maximum file descriptor: cur=%ld max=%ld, changed to cur="RLIM_STRING" max="RLIM_STRING,l1,l2,rl.rlim_cur,rl.rlim_max);
-         debuga(msg);
-      }
+      if(debug)
+         debuga("Maximum file descriptor: cur=%ld max=%ld, changed to cur="RLIM_STRING" max="RLIM_STRING,l1,l2,rl.rlim_cur,rl.rlim_max);
    }
 
    read_usertab(UserTabFile);
@@ -692,10 +685,8 @@ int main(int argc,char *argv[])
 
       strcpy(arqtt,arq);
       decomp(arq,zip,tmp);
-      if(debug) {
-         sprintf(msg, "%s: %s",text[7],arq);
-         debuga(msg);
-      }
+      if(debug)
+         debuga("%s: %s",text[7],arq);
 
       if((fp_in=MY_FOPEN(arq,"r"))==NULL) {
          fprintf(stderr, "%s: (log) %s: %s - %s\n",argv[0],text[8],arq,strerror(errno));
@@ -1144,23 +1135,23 @@ int main(int argc,char *argv[])
                tt=atoi(data);
                t=localtime(&tt);
 
-               strftime(tbuf2, 127, "%H%M", t);
+               strftime(tbuf2, sizeof(tbuf2), "%H%M", t);
                if(strncmp(df,"u",1) == 0)
-                  strftime(tbuf, 127, "%Y%b%d", t);
+                  strftime(tbuf, sizeof(tbuf), "%Y%b%d", t);
                if(strncmp(df,"e",1) == 0)
-                  strftime(tbuf, 127, "%d%b%Y", t);
+                  strftime(tbuf, sizeof(tbuf), "%d%b%Y", t);
                if(strncmp(df,"w",1) == 0) {
                   strcpy(IndexTree,"file");
-                  strftime(tbuf, 127, "%Y.%U", t);
+                  strftime(tbuf, sizeof(tbuf), "%Y.%U", t);
                }
 
-               strftime(dia, 127, "%d/%m/%Y", t);
-               strftime(wdata, 127, "%Y%m%d", t);
+               strftime(dia, sizeof(dia), "%d/%m/%Y", t);
+               strftime(wdata, sizeof(wdata), "%Y%m%d", t);
 
                idata=atoi(wdata);
 
                if(strncmp(df,"u",1)==0)
-                  strftime(dia, 127, "%m/%d/%Y", t);
+                  strftime(dia, sizeof(dia), "%m/%d/%Y", t);
                sprintf(hora,"%02d:%02d:%02d",t->tm_hour,t->tm_min,t->tm_sec);
             } else {
                strcpy(wtemp,data+1);
@@ -1186,9 +1177,9 @@ int main(int argc,char *argv[])
                }
 
                if(strcmp(df,"u") == 0)
-                  sprintf(tbuf,"%s%s%s",ano,mes,dia);
+                  snprintf(tbuf,sizeof(tbuf),"%s%s%s",ano,mes,dia);
                if(strcmp(df,"e") == 0)
-                  sprintf(tbuf,"%s%s%s",dia,mes,ano);
+                  snprintf(tbuf,sizeof(tbuf),"%s%s%s",dia,mes,ano);
                builddia(dia,mes,ano,df,wdata);
                idata=atoi(wdata);
             }
@@ -1420,20 +1411,19 @@ int main(int argc,char *argv[])
      fclose (fp_Write_User);
 
    if(debug) {
-      sprintf(msg, "   %s: %ld, %s: %ld, %s: %ld",text[10],totregsl,text[11],totregsg,text[68],totregsx);
-      debuga(msg);
+      debuga("   %s: %ld, %s: %ld, %s: %ld",text[10],totregsl,text[11],totregsg,text[68],totregsx);
 
       if((common_log) && (squid_log))
-         debuga(text[12]);
+         debuga("%s",text[12]);
 
       if((common_log) && (!squid_log)) 
-         debuga(text[13]);
+         debuga("%s",text[13]);
 
       if((!common_log) && (squid_log))
-         debuga(text[14]);
+         debuga("%s",text[14]);
 
       if(sarglog)
-         debuga(text[124]);
+         debuga("%s",text[124]);
 
       if((!common_log) && (!squid_log) && (!sarglog) && (!isalog)) {
          if(!totregsg) {
@@ -1477,10 +1467,8 @@ int main(int argc,char *argv[])
       debugaz("period",period);
    }
 
-   if(debug){
-     sprintf(msg, "%s: %s",text[17],period);
-     debuga(msg);
-   }
+   if(debug)
+      debuga("%s: %s",text[17],period);
 
    fclose(fp_in);
 //   fclose(fp_ou);
@@ -1514,10 +1502,8 @@ int main(int argc,char *argv[])
          }
       }
 
-      if(debug) {
-         sprintf(msg,"%s %s",text[123],arq_log);
-         debuga(msg);
-      }
+      if(debug)
+         debuga("%s %s",text[123],arq_log);
    }
 
    if(strstr(ReportType,"denied") != 0) {
@@ -1562,7 +1548,7 @@ int main(int argc,char *argv[])
       free(excludeuser);
 
    if(debug)
-      debuga(text[21]);
+      debuga("%s",text[21]);
 
    exit(0);
 
@@ -1574,14 +1560,11 @@ static void getusers(const char *pwdfile, int debug)
 
    FILE *fp_usr;
    char buf[255];
-   char Msg[255];
    char *str;
    unsigned long int nreg=0;
 
-   if(debug) {
-      sprintf(Msg,"%s: %s",text[60],pwdfile);
-      debuga(Msg);
-   }
+   if(debug)
+      debuga("%s: %s",text[60],pwdfile);
 
    if ((fp_usr = fopen(pwdfile, "r")) == NULL) {
       fprintf(stderr, "SARG: (getusers) %s: %s - %s\n",text[45],pwdfile,strerror(errno));
@@ -1622,13 +1605,10 @@ void gethexclude(char *hexfile, int debug)
 
    FILE *fp_ex;
    char buf[255];
-   char Msg[255];
    unsigned long int nreg=0;
 
-   if(debug) {
-      sprintf(Msg,"%s: %s",text[67],hexfile);
-      debuga(Msg);
-   }
+   if(debug)
+      debuga("%s: %s",text[67],hexfile);
 
    if ((fp_ex = fopen(hexfile, "r")) == NULL) {
       fprintf(stderr, "SARG: (gethexclude) %s: %s - %s\n",text[45],hexfile,strerror(errno));
@@ -1667,13 +1647,10 @@ void getuexclude(char *uexfile, int debug)
 
    FILE *fp_ex;
    char buf[255];
-   char Msg[255];
    unsigned long int nreg=0;
 
-   if(debug) {
-      sprintf(Msg,"%s: %s",text[67],uexfile);
-      debuga(Msg);
-   }
+   if(debug)
+      debuga("%s: %s",text[67],uexfile);
 
    if ((fp_ex = fopen(uexfile, "r")) == NULL) {
       fprintf(stderr, "SARG: (gethexclude) %s: %s - %s\n",text[45],uexfile,strerror(errno));
index 0509b63a598a093dd5afc5a76c2e215110b2aba2..38275e6e5a276e2bd61f94a0ca854699b97e80fc 100644 (file)
--- a/report.c
+++ b/report.c
@@ -391,8 +391,7 @@ static void maketmp(const char *user, const char *dirname, int debug, int indexo
    strcat(wdirname,user);
 
    if(debug){
-      sprintf(msg,"%s: %s",text[49],wdirname);
-      debuga(msg);
+      debuga("%s: %s",text[49],wdirname);
    }
 
    strcat(wdirname,".utmp");
diff --git a/sort.c b/sort.c
index 844be2b59c4ed769e13f5226965dfb2aed5309d8..3ee1d884b4c68f24d39d08c68815a71f708f2074 100644 (file)
--- a/sort.c
+++ b/sort.c
@@ -86,8 +86,7 @@ void tmpsort(void)
       strcat(arqin,direntp->d_name);
 
       if(debug) {
-         sprintf(msg,"%s: %s",text[54],arqou);
-         debuga(msg);
+         debuga("%s: %s",text[54],arqou);
       }
 
       strcat(arqou,".txt");
@@ -119,8 +118,7 @@ void sort_users_log(const char *tmp, int debug)
    int dlen;
 
    if(debug) {
-      sprintf(msg,"%s",text[138]);
-      debuga(msg);
+      debuga("%s",text[138]);
    }
 
    sprintf(wtmp,"%s/sarg",tmp);
index 21c1759d7c32053614622526f1ba82f970e93eea..79bc943d7cbea85c4d28f44f28a8550cfd9f9c05 100644 (file)
@@ -47,8 +47,7 @@ static void read_log(const char *wentp, FILE *fp_ou)
          printf("SARG: Maybe you have a broken record or garbage in your %s string.\n",text[7]);
          exit(1);
       }
-      sprintf(msg,"%s squidGuard %s: %s",urly,buf,wentp);
-      debuga(msg);
+      debuga("%s squidGuard %s: %s",urly,buf,wentp);
    }
 
    /* With squidGuard, you can log groups in only one log file.
@@ -225,8 +224,7 @@ void squidguard_log(void)
 
    if(strlen(SquidGuardConf) > 0) {
       if(access(SquidGuardConf, R_OK) != 0) {
-         sprintf(msg,"Cannot open squidGuard config file: %s",SquidGuardConf);
-         debuga(msg);
+         debuga("Cannot open squidGuard config file: %s",SquidGuardConf);
          exit(1);
       }
 
@@ -282,8 +280,7 @@ void squidguard_log(void)
    if (fp_ou) fclose(fp_ou);
 
    if(debug) {
-      sprintf(msg,"%s: %s",text[54],guard_ou);
-      debuga(msg);
+      debuga("%s: %s",text[54],guard_ou);
    }
 
    sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 '%s' -o '%s'",guard_in, guard_ou);
index 23c553fc043f81b75ec1e475f3df6505a1ced9c5..3518ac4d0db8a09a483488c1b7cf8b59bc73bd59 100644 (file)
@@ -66,8 +66,7 @@ void useragent(void)
    }
 
    if(debug) {
-      sprintf(msg,"%s: %s",text[66],UserAgentLog);
-      debuga(msg);
+      debuga("%s: %s",text[66],UserAgentLog);
    }
 
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
@@ -107,8 +106,7 @@ void useragent(void)
    strcpy(fdate,data);
 
    if(debug) {
-      sprintf(msg, "   %s: %ld",text[10],totregsl);
-      debuga(msg);
+      debuga("   %s: %ld",text[10],totregsl);
    }
 
    fclose(fp_in);
@@ -119,8 +117,7 @@ void useragent(void)
    }
 
    if(debug) {
-      sprintf(msg,"%s: %s",text[54],tmp2);
-      debuga(msg);
+      debuga("%s: %s",text[54],tmp2);
    }
 
    sprintf(csort,"sort -n -t '\\' -k 4,4 -k 3,3 -k 2,2 -k 1,1 -o '%s' '%s'",tmp2,tmp3);
@@ -144,7 +141,7 @@ void useragent(void)
    }
  
    if(debug)
-      debuga(text[72]);
+      debuga("%s",text[72]);
 
    fprintf(fp_ht, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n",CharSet);
    fputs("</head>\n",fp_ht);
diff --git a/util.c b/util.c
index 1b251656ef61930da994c387b61b620fa1dbfd98..807fe476dde26396e4a020cdce657f5672387c1b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -421,10 +421,15 @@ void fixper(char *tbuf, char *period, const char *duntil)
 }
 
 
-void debuga(const char *msg)
+void debuga(const char *msg,...)
 {
-  fprintf(stderr, "SARG: %s\n",msg);
+   va_list ap;
 
+   fputs("SARG: ",stderr);
+   va_start(ap,msg);
+   vfprintf(stderr,msg,ap);
+   va_end(ap);
+   fputc('\n',stderr);
 }
 
 
@@ -765,7 +770,7 @@ void gperiod(void)
    fclose(fp_ou);
 
    if(debug)
-      debuga((char *)text[50]);
+      debuga("%s",(char *)text[50]);
  
    return;
  
@@ -1137,8 +1142,7 @@ void removetmp(const char *outdir)
       return;
       
    if(debug) {
-      sprintf(msg,"%s: sarg-general, sarg-period",text[82]);
-      debuga(msg);
+      debuga("%s: sarg-general, sarg-period",text[82]);
    }
    sprintf(warea,"%s/sarg-general",outdir);
    if((fp_in=fopen(warea,"r"))==NULL){
@@ -1430,8 +1434,7 @@ void read_usertab(const char *UserTabFile)
 
    if (UserTabFile[0] != '\0') {
       if(debug) {
-         sprintf(msg,"%s: %s",text[86],UserTabFile);
-         debuga(msg);
+         debuga("%s: %s",text[86],UserTabFile);
       }
       if((fp_usr=fopen(UserTabFile,"r"))==NULL) {
          fprintf(stderr, "SARG: (log) %s: %s - %s\n",text[45],UserTabFile,strerror(errno));