]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Continue the replacement of the user info and the translation of the error messages
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Tue, 2 Mar 2010 09:51:45 +0000 (09:51 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Tue, 2 Mar 2010 09:51:45 +0000 (09:51 +0000)
CMakeLists.txt
auth.c
authfail.c
documentation/util.txt
html.c
include/defs.h
include/info.h
index.c
splitlog.c
topsites.c
util.c

index 4b268155262e4025b4b7ead722f069755f3c88fb..ccc43ab5881cb656867b8ce0be2dd2ee6da8a631 100755 (executable)
@@ -3,7 +3,7 @@ PROJECT(sarg C)
 SET(sarg_VERSION 2)
 SET(sarg_REVISION "3rc1")
 SET(sarg_BUILD "")
-SET(sarg_BUILDDATE "Feb-10-2010")
+SET(sarg_BUILDDATE "Mar-02-2010")
 
 INCLUDE(AddFileDependencies)
 INCLUDE(CheckIncludeFile)
@@ -63,9 +63,16 @@ ADD_EXECUTABLE(sarg ${SRC})
 
 SET_TARGET_PROPERTIES(sarg PROPERTIES VERSION "${sarg_VERSION}.${sarg_REVISION}.${sarg_BUILD}")
 
-SET_TARGET_PROPERTIES(sarg PROPERTIES COMPILE_FLAGS "$ENV{CFLAGS} -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter")
+SET_TARGET_PROPERTIES(sarg PROPERTIES COMPILE_FLAGS "$ENV{CFLAGS} -Wall -Wno-sign-compare")
 SET_TARGET_PROPERTIES(sarg PROPERTIES LINK_FLAGS "$ENV{LDFLAGS}")
 
+CHECK_C_COMPILER_FLAG("-Wextra" HAVE_WEXTRA)
+IF(HAVE_WEXTRA)
+   # Not supported by gcc 3.3
+   GET_TARGET_PROPERTY(TMPCFLAGS sarg COMPILE_FLAGS)
+   SET_TARGET_PROPERTIES(sarg PROPERTIES COMPILE_FLAGS "${TMPCFLAGS} -Wextra -Wno-unused-parameter")
+ENDIF(HAVE_WEXTRA)
+
 CHECK_C_COMPILER_FLAG("-Werror=implicit-function-declaration" HAVE_WERROR_IMPLICIT_FUNCTION)
 IF(HAVE_WERROR_IMPLICIT_FUNCTION)
    GET_TARGET_PROPERTY(TMPCFLAGS sarg COMPILE_FLAGS)
@@ -264,7 +271,7 @@ ENDIF(NOT HAVE_MKSTEMP)
 
 # Gettext and friends
 IF(NOT HAVE_LC_MESSAGES)
-   UNSET(FILES)
+   SET(FILES)
    IF(HAVE_LOCALE_H)
       LIST(APPEND FILES "locale.h")
    ENDIF(HAVE_LOCALE_H)
diff --git a/auth.c b/auth.c
index 6673ef42a436c5eead5c1a906e2562a4bdd77e4b..61cf60aa68a7b97ab60f26577a89547b497b06fe 100644 (file)
--- a/auth.c
+++ b/auth.c
@@ -27,7 +27,7 @@
 #include "include/conf.h"
 #include "include/defs.h"
 
-void htaccess(const char *name)
+void htaccess(const struct userinfostruct *uinfo)
 {
    char htname[MAXLEN];
    FILE *fp_auth;
@@ -36,7 +36,10 @@ void htaccess(const char *name)
    if(!UserAuthentication)
       return;
 
-   sprintf(htname,"%s/%s/.htaccess",dirname,name);
+   if (snprintf(htname,sizeof(htname),"%s/%s/.htaccess",dirname,uinfo->filename)>=sizeof(htname)) {
+      debuga(_("File name too long: %s/%s/.htaccess"),dirname,uinfo->filename);
+      exit(1);
+   }
    if((fp_auth=fopen(htname,"w"))==NULL) {
       fprintf(stderr, "SARG: (auth) %s: %s - %s\n",text[45],htname,strerror(errno));
       exit(1);
@@ -51,7 +54,7 @@ void htaccess(const char *name)
    fputs("<Limit GET POST>\nRequire ",fp_auth);
    for (i=0 ; Require[i] ; i++)
       if (Require[i]=='%' && Require[i+1]=='u') {
-         fputs(name,fp_auth);
+         fputs(uinfo->id,fp_auth);
          i++;
       } else {
          fputc(Require[i],fp_auth);
index cdfa854293aa05b430c026e2eaae615c01315c10..edbdc2aa2e360d5f7c69938676667702f17db40a 100644 (file)
@@ -50,6 +50,7 @@ void authfail_report(void)
    int  z=0;
    int  count=0;
    int  cstatus;
+   int new_user;
    struct getwordstruct gwarea;
    struct longlinestruct line;
    struct userinfostruct *uinfo;
@@ -133,19 +134,21 @@ void authfail_report(void)
          exit(1);
       }
 
+      new_user=0;
       if(!z) {
          strcpy(ouser,user);
          strcpy(oip,ip);
          z++;
+         new_user=1;
       } else {
-         if(strcmp(ouser,user) == 0)
-            user[0]='\0';
-         if(user[0] != '\0')
+         if(strcmp(ouser,user) != 0) {
             strcpy(ouser,user);
-         if(strcmp(oip,ip) == 0)
-            ip[0]='\0';
-         if(ip[0] != '\0')
+            new_user=1;
+         }
+         if(strcmp(oip,ip) != 0) {
             strcpy(oip,ip);
+            new_user=1;
+         }
       }
 
      if(AuthfailReportLimit) {
@@ -159,7 +162,12 @@ void authfail_report(void)
             continue;
       }
 
-      fprintf(fp_ou,"<tr><td class=\"data2\">%s</td><td class=\"data2\">%s</td><td class=\"data2\">%s-%s</td><td class=\"data2\">",uinfo->label,ip,data,hora);
+      fputs("<tr>",fp_ou);
+      if (new_user)
+         fprintf(fp_ou,"<td class=\"data2\">%s</td><td class=\"data2\">%s</td>",uinfo->label,ip);
+      else
+         fputs("<td class=\"data2\"></td><td class=\"data2\"></td>",fp_ou);
+      fprintf(fp_ou,"<td class=\"data2\">%s-%s</td><td class=\"data2\">",data,hora);
       if(BlockIt[0]!='\0') {
          fprintf(fp_ou,"<a href=\"%s%s?url=",wwwDocumentRoot,BlockIt);
          output_html_url(fp_ou,url);
index 123052fb43113bdababccd9b1fcc14737ee8759e..56f7f18951913f4db403c32d2848775a88969923 100644 (file)
@@ -409,28 +409,28 @@ Format a date to display it in the report.
 
 
 
-/*! \fn void obtuser(const char *dirname, const char *name, char *tuser)
-Get the number of entries stored in a connection data directory. The number is read from
-the <tt>sarg-users</tt> file of the connection data's directory.
+/*! \fn int obtuser(const char *dirname, const char *name)
+Get the number of entries stored in a report data directory. The number is read from
+the <tt>sarg-users</tt> file of the report data's directory.
 
-\param dirname The directory to look for the connection directory.
-\param name The name of the connection directory whose <tt>sarg-users</tt> file must be read.
-\param tuser The buffer to store the content of the file. It must be more than 20
-bytes long.
+\param dirname The directory containing the reports.
+\param name The name of the report directory whose <tt>sarg-users</tt> file must be read.
+
+\return The number of entries in the report or zero if the file doesn't exists.
 */
 
 
 
 
 
-/*! \fn void obttotal(const char *dirname, const char *name, char *tbytes, const char *tuser, char *media)
-Count the total size transfered in a connection directory and compute the average number of bytes
+/*! \fn void obttotal(const char *dirname, const char *name, char *tbytes, int nuser, char *media)
+Count the total size transfered in a report directory and compute the average number of bytes
 per entry.
 
-\param dirname The directory to look for the connection directory.
-\param name The name of the connection directory whose <tt>sarg-general</tt> file must be read.
-\param tbytes A buffer to store the total number of bytes from this connection.
-\param tuser The number of entries in the connection directory.
+\param dirname The directory containing the reports.
+\param name The name of the report directory whose <tt>sarg-general</tt> file must be read.
+\param tbytes A buffer to store the total number of bytes from this report.
+\param nuser The number of entries in the report directory.
 \param media A buffer to store the average number of bytes per entry.
 */
 
@@ -559,19 +559,6 @@ Convert a string to all uppercases.
 
 
 
-/*! \fn void subs(char *str, int size, char *from, char *to)
-Replace one occurence of the string \a from by \a to in the string \a str.
-
-\param str The string in which to replace the text.
-\param size The size of the string buffer to detect a buffer overflow if \a to is longer than \a from.
-\param from The fragment of text to replace.
-\param to The text to replace instead of \a from.
-*/
-
-
-
-
-
 /*! \fn void removetmp(const char *outdir)
 Remove the file <tt>sarg-period</tt> from the output directory and purge the file <tt>sarg-general</tt> from
 all the lines but the total.
diff --git a/html.c b/html.c
index ca965e2795c49020fafe1804360d3bf782466409..60d84cbfb3e8ace7a18e270b3da195a2d3ad3cb2 100644 (file)
--- a/html.c
+++ b/html.c
@@ -42,7 +42,7 @@ void htmlrel(void)
    char *buf;
    char arqin[MAXLEN], arqou[MAXLEN], arqper[MAXLEN], arqip[MAXLEN];
    char *url, tmsg[50], csort[MAXLEN];
-   char period[MAXLEN], usuario[MAXLEN], wusuario[MAXLEN], duser[MAXLEN];
+   char period[MAXLEN], user[MAXLEN], duser[MAXLEN];
    char userhora[9], userdia[9];
    char user_ip[MAXLEN], olduserip[MAXLEN], tmp2[MAXLEN], tmp3[MAXLEN];
    char denied_report[255];
@@ -131,26 +131,26 @@ void htmlrel(void)
 
       count=1;
       if (dlen>0) {
-         if (dlen>=sizeof(wusuario)) continue;
-         strncpy(wusuario,direntp->d_name,dlen);
-         wusuario[dlen]=0;
+         if (dlen>=sizeof(user)) continue;
+         strncpy(user,direntp->d_name,dlen);
+         user[dlen]=0;
       } else {
-         wusuario[0]=0;
+         user[0]=0;
       }
 
-      uinfo=userinfo_find_from_file(wusuario);
+      uinfo=userinfo_find_from_file(user);
       if (!uinfo) {
-         debuga(_("Unknown user ID %s in directory %s"),wusuario,tmp);
+         debuga(_("Unknown user ID %s in directory %s"),user,tmp);
          exit(1);
       }
-      str=strrchr(wusuario,'.');
+      str=strrchr(user,'.');
       if (str)
          strcpy(denied_report,str+1);
       else
-         strcpy(denied_report,wusuario);
+         strcpy(denied_report,user);
 
-      if (snprintf(warea,sizeof(warea),"%s/%s",dirname,wusuario)>=sizeof(warea)) {
-         debuga(_("Destination directory too long: %s/%s"),dirname,wusuario);
+      if (snprintf(warea,sizeof(warea),"%s/%s",dirname,user)>=sizeof(warea)) {
+         debuga(_("Destination directory too long: %s/%s"),dirname,user);
          exit(1);
       }
       mkdir(warea,0755);
@@ -158,7 +158,6 @@ void htmlrel(void)
       report_day(uinfo);
       greport_day(uinfo);
 
-      strcpy(usuario,wusuario);
       if (snprintf(arqin,sizeof(arqin),"%s/%s",tmp,direntp->d_name)>=sizeof(arqin)) {
          debuga(_("Input file name too long: %s/%s"),tmp,direntp->d_name);
          exit(1);
@@ -267,7 +266,7 @@ void htmlrel(void)
       fputs("</tr>\n",fp_ou);
 
       if(debug) {
-         debuga("%s: %s",text[61],usuario);
+         debuga("%s: %s",text[61],uinfo->id);
       }
 
       while((buf=longline_read(fp_in,&line))!=NULL) {
@@ -315,7 +314,7 @@ void htmlrel(void)
                   ltext110[z1]=tolower(s[z1]);
                ltext110[z1]='\0';
                url_to_file(url,siteind,sizeof(siteind));
-               fprintf(fp_ou,"<td class=\"data\"><a href=\"tt%s-%s.html\"><img src=\"%s/datetime.png\" title=\"%s %s\" alt=\"T\"></a></td>",usuario,siteind,tmp6,ltext110,text[55]);
+               fprintf(fp_ou,"<td class=\"data\"><a href=\"tt%s-%s.html\"><img src=\"%s/datetime.png\" title=\"%s %s\" alt=\"T\"></a></td>",uinfo->filename,siteind,tmp6,ltext110,text[55]);
             } else {
                fprintf(fp_ou,"<td class=\"data\"></td>");
             }
@@ -366,10 +365,10 @@ void htmlrel(void)
          }
 
          if(iprel) {
-            strcpy(arqip,tmp);
-            strcat(arqip,"/");
-            strcat(arqip,usuario);
-            strcat(arqip,".ip");
+            if (snprintf(arqip,sizeof(arqip),"%s/%s.ip",tmp,uinfo->filename)>=sizeof(arqip)) {
+               debuga(_("File name too long: %s/%s.ip"),tmp,uinfo->filename);
+               exit(1);
+            }
 
             if ((fp_ip = fopen(arqip, "r")) == 0){
                fprintf(stderr, "SARG: (html6) %s: %s\n",text[45],arqip);
@@ -563,7 +562,7 @@ void htmlrel(void)
       write_html_trailer(fp_ou);
       fclose(fp_ou);
 
-      htaccess(wusuario);
+      htaccess(uinfo);
    }
 
    (void)closedir(dirp);
index addee806ff1ab7ed95a6b7407e6a173cc68d9a51..e7f95c3f125fe7fb844d634c0650c7571c3bacbd 100755 (executable)
@@ -62,7 +62,7 @@ struct userinfostruct
 };
 
 // auth.c
-void htaccess(const char *name);
+void htaccess(const struct userinfostruct *uinfo);
 
 // authfail.c
 void authfail_report(void);
@@ -224,7 +224,6 @@ void close_html_header(FILE *fp_ou);
 void write_html_trailer(FILE *fp_ou);
 void output_html_string(FILE *fp_ou,const char *str,int maxlen);
 void output_html_url(FILE *fp_ou,const char *url);
-void subs(char *str, int size, char *from, char *to);
 void conv_month(char *month);
 void debuga(const char *msg,...);
 void debugaz(const char *head, const char *msg);
@@ -236,8 +235,8 @@ void strip_latin(char *line);
 char *buildtime(long long int elap);
 void obtdate(const char *dirname, const char *name, char *data);
 void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second,int dst);
-void obtuser(const char *dirname, const char *name, char *tuser);
-void obttotal(const char *dirname, const char *name, char *tbytes, const char *tuser, char *media);
+int obtuser(const char *dirname, const char *name);
+void obttotal(const char *dirname, const char *name, char *tbytes, int nuser, char *media);
 void version(void);
 int vercode(const char *code);
 void load_excludecodes(const char *ExcludeCodes);
index ab13bc8e3a2859859293aa4586f7667c2c21a97f..914a5ab394ab927b3288174fdc4af0e926e37ced 100755 (executable)
@@ -1,3 +1,3 @@
-#define VERSION PACKAGE_VERSION" Feb-10-2010"
+#define VERSION PACKAGE_VERSION" Mar-02-2010"
 #define PGM PACKAGE_NAME
 #define URL "http://sarg.sourceforge.net"
diff --git a/index.c b/index.c
index 9b7a82bc8b4b8b3df585a289b5a614df5392fe40..b57d86eaa96dc2534b5de31f9608e971dbf80b10 100644 (file)
--- a/index.c
+++ b/index.c
@@ -276,7 +276,6 @@ static void make_file_index(void)
    char wdir[MAXLEN];
    char month[4];
    char data[80];
-   char tuser[20];
    char tbytes[20];
    char media[20];
    char ftime[128];
@@ -287,6 +286,7 @@ static void make_file_index(void)
    int order;
    int i;
    int cmp;
+   int tuser;
    struct getwordstruct gwarea;
    struct sortstruct
    {
@@ -402,9 +402,9 @@ static void make_file_index(void)
          item=sortlist[i];
       else
          item=sortlist[nsort-i-1];
-      obtuser(outdir,item->dirname,tuser);
+      tuser=obtuser(outdir,item->dirname);
       obttotal(outdir,item->dirname,tbytes,tuser,media);
-      fprintf(fp_ou,"<tr><td class=\"data2\"><a href='%s/%s'>%s</a></td><td class=\"data2\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",item->dirname,ReplaceIndex,item->dirname,item->date,tuser,tbytes,media);
+      fprintf(fp_ou,"<tr><td class=\"data2\"><a href='%s/%s'>%s</a></td><td class=\"data2\">%s</td><td class=\"data\">%d</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",item->dirname,ReplaceIndex,item->dirname,item->date,tuser,tbytes,media);
    }
    fputs("</table></div>\n",fp_ou);
    write_html_trailer(fp_ou);
index 4c7cfa08353abe12bb583d04b3c7cbb2626bf5df..377e7f694ceba671ea34af984ba659faf84e0067 100644 (file)
@@ -51,7 +51,7 @@ void splitlog(const char *arq, char *df, int dfrom, int duntil, char *convert)
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
       getword_start(&gwarea,buf);
       if (getword(data,sizeof(data),&gwarea,' ')<0) {
-         printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq);
+         debuga(_("Maybe you have a broken record or garbage in your %s file"),arq);
          exit(1);
       }
       tt=atoi(data);
index a1491cbc73ea0b202599f83b5414a4d950c6bae2..3149bebe6ec0e9411d67def087edf59f4676c8cb 100644 (file)
@@ -203,10 +203,7 @@ void topsites(void)
 
    fputs("<div class=\"report\"><table cellpadding=\"1\" cellspacing=\"2\">\n",fp_ou);
    fputs("<tr><td></td></tr>\n",fp_ou);
-   fprintf(fp_ou,"<tr><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th> \
-               <th class=\"header_l\">%s</th><th class=\"header_l\">%s</th> \
-               <th class=\"header_l\">%s</th></tr>\n", \
-               text[100],text[91],text[92],text[93],text[99]);
+   fprintf(fp_ou,"<tr><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",text[100],text[91],text[92],text[93],text[99]);
 
    regs=0;
    ntopsites = 0;
diff --git a/util.c b/util.c
index a185741fec533d2fd08e1eb96b038226fb70f855..b19e1d72270df4b8e411f23b031d5a52e09a750d 100644 (file)
--- a/util.c
+++ b/util.c
@@ -715,34 +715,34 @@ void formatdate(char *date,int date_size,int year,int month,int day,int hour,int
 }
 
 
-void obtuser(const char *dirname, const char *name, char *tuser)
+int obtuser(const char *dirname, const char *name)
 {
 
    FILE *fp_in;
    char wdir[MAXLEN];
+   char tuser[20];
+   int nuser;
 
    sprintf(wdir,"%s%s/sarg-users",dirname,name);
    if((fp_in=fopen(wdir,"r"))==NULL) {
       sprintf(wdir,"%s%s/users",dirname,name);
       if((fp_in=fopen(wdir,"r"))==NULL) {
-         tuser[0]='\0';
-         return;
+         return(0);
       }
    }
 
-   if (!fgets(tuser,20,fp_in)) {
-      fprintf(stderr,"Failed to read the user in %s\n",wdir);
+   if (!fgets(tuser,sizeof(tuser),fp_in)) {
+      debuga(_("Failed to read the number of users in %s"),wdir);
       exit(1);
    }
    fclose(fp_in);
-   fixendofline(tuser);
-
-   return;
+   nuser=atoi(tuser);
 
+   return(nuser);
 }
 
 
-void obttotal(const char *dirname, const char *name, char *tbytes, const char *tuser, char *media)
+void obttotal(const char *dirname, const char *name, char *tbytes, int nuser, char *media)
 {
    FILE *fp_in;
    char *buf;
@@ -750,7 +750,6 @@ void obttotal(const char *dirname, const char *name, char *tbytes, const char *t
    char user[MAX_USER_LEN];
    char sep;
    long long int med=0;
-   long long int wtuser=0;
    long long int twork=0;
    struct getwordstruct gwarea;
    struct longlinestruct line;
@@ -781,17 +780,17 @@ void obttotal(const char *dirname, const char *name, char *tbytes, const char *t
          continue;
       getword_start(&gwarea,buf);
       if (getword(user,sizeof(user),&gwarea,sep)<0) {
-         debuga(_("Maybe you have a invalid user in your %s file"),wdir);
+         debuga(_("There is a invalid user in file %s"),wdir);
          exit(1);
       }
       if(strcmp(warea,"TOTAL") != 0)
          continue;
       if (getword_skip(MAXLEN,&gwarea,sep)<0) {
-         debuga(_("Maybe you have a broken record or garbage in your %s file"),wdir);
+         debuga(_("There a broken total number of access in file %s"),wdir);
          exit(1);
       }
       if (getword_atoll(&twork,&gwarea,sep)<0) {
-         debuga(_("Maybe you have a broken record or garbage in your %s file"),wdir);
+         debuga(_("There is a broken number of bytes in file %s"),wdir);
          exit(1);
       }
       strcpy(tbytes,fixnum(twork,1));
@@ -800,13 +799,12 @@ void obttotal(const char *dirname, const char *name, char *tbytes, const char *t
    fclose(fp_in);
    longline_free(&line);
 
-   wtuser=my_atoll(tuser);
-   if(wtuser <= 0) {
+   if(nuser <= 0) {
       strcpy(media,"0");
       return;
    }
 
-   med=twork / wtuser;
+   med=twork / nuser;
    strcpy(media,fixnum(med,1));
 
    return;
@@ -851,7 +849,7 @@ static void copy_images(void)
    struct stat info;
 
    if (snprintf(images,sizeof(images),"%simages",outdir)>=sizeof(images)) {
-      fprintf(stderr,"SARG: Cannot copy images to target directory %simages\n",outdir);
+      debuga(_("Cannot copy images to target directory %simages"),outdir);
       exit(1);
    }
    if (access(images,R_OK)!=0) {
@@ -861,7 +859,7 @@ static void copy_images(void)
    strcpy(imgdir,IMAGEDIR);
    dirp = opendir(imgdir);
    if(dirp==NULL) {
-      fprintf(stderr, "SARG: (util) %s %s: %s\n","Can't open directory", imgdir,strerror(errno));
+      debuga(_("(util) Can't open directory %s: %s"),imgdir,strerror(errno));
       return;
    }
    while ((direntp = readdir( dirp )) != NULL ){
@@ -869,7 +867,7 @@ static void copy_images(void)
          continue;
       sprintf(srcfile,"%s/%s",imgdir,direntp->d_name);
       if (stat(srcfile,&info)) {
-         fprintf(stderr,"SARG: Cannot stat \"%s\" - %s\n",srcfile,strerror(errno));
+         debuga(_("Cannot stat \"%s\" - %s"),srcfile,strerror(errno));
          continue;
       }
       if (S_ISREG(info.st_mode)) {
@@ -880,7 +878,7 @@ static void copy_images(void)
             if(img_ou!=NULL) {
                while ((nread = fread(buffer,1,sizeof(buffer),img_in))>0) {
                   if (fwrite(buffer,1,nread,img_ou)!=nread) {
-                     fprintf(stderr,"SARG: Failed to copy image %s to %s\n",srcfile,dstfile);
+                     debuga(_("Failed to copy image %s to %s"),srcfile,dstfile);
                      break;
                   }
                }
@@ -1135,7 +1133,7 @@ void date_from(char *date, char *dfrom, char *duntil)
    wdate[sizeof(wdate)-1]='\0';
    if(strchr(wdate,'-') == NULL) {
       if (strlen(wdate)*2+1>=sizeof(wdate)) {
-         fprintf(stderr,"SARG: Invalid date range passed as argument.\n");
+         debuga(_("Invalid date range passed as argument"));
          exit(1);
       }
       strcat(wdate,"-");
@@ -1144,7 +1142,7 @@ void date_from(char *date, char *dfrom, char *duntil)
    }
 
    if (sscanf(wdate,"%d/%d/%d-%d/%d/%d",&diaf,&mesf,&anof,&diau,&mesu,&anou)!=6) {
-      fprintf(stderr,"SARG: The date range passed as argument is not formated as dd/mm/yyyy-dd/mm/yyyy.\n");
+      debuga(_("The date range passed as argument is not formated as dd/mm/yyyy-dd/mm/yyyy"));
       exit(1);
    }
 
@@ -1184,40 +1182,6 @@ char *strup(char *string)
 }
 
 
-void subs(char *str, int size, char *from, char *to)
-{
-   char *tmp;
-   int i;
-   int ss, st, sf;
-   int len;
-   int shift;
-
-   tmp = strstr(str, from);
-   if(tmp == NULL)
-      return;
-
-   ss = strlen(str);
-   sf = strlen(from);
-   st = strlen(to);
-   shift=st-sf;
-
-   if (shift>0) {
-      if (ss+shift>=size){
-         fprintf(stderr,"SARG: Cannot replace %s by %s in %s and fit within %d bytes\n",from,to,str,size);
-         exit(1);
-      }
-      for (i=strlen(tmp) ; i>=sf ; i--)
-         tmp[i+shift]=tmp[i];
-   } else if (shift<0) {
-      len=strlen(tmp);
-      for (i=sf ; i<=len ; i++)
-         tmp[i+shift]=tmp[i];
-   }
-   memcpy(tmp, to, st);
-   return;
-}
-
-
 void removetmp(const char *outdir)
 {
 
@@ -1231,7 +1195,7 @@ void removetmp(const char *outdir)
       debuga("%s: sarg-general, sarg-period",text[82]);
    }
    if (snprintf(warea,sizeof(warea),"%s/sarg-general",outdir)>=sizeof(warea)) {
-      fprintf(stderr, "SARG: (removetmp) directory too long to remove: %s/sarg-period\n",outdir);
+      debuga(_("(removetmp) directory too long to remove: %s/sarg-period"),outdir);
       exit(1);
    }
    if((fp_in=fopen(warea,"r"))==NULL){
@@ -1250,7 +1214,7 @@ void removetmp(const char *outdir)
    fputs(buf,fp_in);
    fclose(fp_in);
    if (snprintf(warea,sizeof(warea),"%s/sarg-period",outdir)>=sizeof(warea)) {
-      fprintf(stderr, "SARG: (removetmp) directory too long to remove: %s/sarg-period\n",outdir);
+      debuga(_("(removetmp) directory too long to remove: %s/sarg-period"),outdir);
       exit(1);
    }
    unlink(warea);
@@ -1275,7 +1239,7 @@ void load_excludecodes(const char *ExcludeCodes)
    bzero(excludecode,1024);
 
    if((fp_in=fopen(ExcludeCodes,"r"))==NULL) {
-     fprintf(stderr, "SARG: (util) Cannot open file: %s (exclude_codes)\n",ExcludeCodes);
+     debuga(_("(util) Cannot open file: %s (exclude_codes)"),ExcludeCodes);
      exit(1);
    }
 
@@ -1431,17 +1395,17 @@ char *get_size(const char *path, const char *file)
    char *ptr;
 
    if (snprintf(cmd,sizeof(cmd),"du -skh %s%s",path,file)>=sizeof(cmd)) {
-      printf("SARG: Cannot get disk space because the path %s%s is too long.\n",path,file);
+      debuga(_("Cannot get disk space because the path %s%s is too long"),path,file);
       exit(1);
    }
    fp = popen(cmd, "r");
    if (!fgets(response, sizeof(response), fp)) {
-      fprintf(stderr,"SARG: Cannot get disk size with command %s",cmd);
+      debuga(_("Cannot get disk size with command %s"),cmd);
       exit(1);
    }
    ptr=strchr(response,'\t');
    if (ptr==NULL) {
-      fprintf(stderr,"SARG: The command %s failed.\n",cmd);
+      debuga(_("The command %s failed"),cmd);
       exit(1);
    }
    pclose(fp);
@@ -1554,7 +1518,7 @@ void baddata(void)
    printf("SARG: ------------------------------------------------------------------------------\n");
 
    if (snprintf(dir,sizeof(dir),"%s/sarg",tmp)>=sizeof(dir)) {
-      fprintf(stderr,"SARG: temporary directory too long: %s/sarg\n",tmp);
+      debuga(_("temporary directory too long: %s/sarg"),tmp);
       exit(1);
    }
    unlinkdir(dir,0);
@@ -1607,7 +1571,7 @@ void url_to_file(const char *url,char *file,int filesize)
 
 void version(void)
 {
-   printf("SARG Version: %s\n",VERSION);
+   printf(_("SARG Version: %s\n"),VERSION);
    exit(0);
 }
 
@@ -1639,7 +1603,7 @@ void unlinkdir(const char *dir,int contentonly)
           (direntp->d_name[1] == '.' && direntp->d_name[2] == '\0')))
          continue;
       if (snprintf(dname,sizeof(dname),"%s/%s",dir,direntp->d_name)>=sizeof(dname)) {
-         fprintf(stderr,"SARG: directory name to delete too long: %s/%s\n",dir,direntp->d_name);
+         debuga(_("directory name to delete too long: %s/%s"),dir,direntp->d_name);
          exit(1);
       }
 #ifdef HAVE_LSTAT
@@ -1653,20 +1617,20 @@ void unlinkdir(const char *dir,int contentonly)
       }
       if (S_ISREG(st.st_mode)) {
          if (unlink(dname)) {
-            fprintf(stderr,"SARG: cannot delete %s - %s\n",dname,strerror(errno));
+            debuga(_("cannot delete %s - %s"),dname,strerror(errno));
             exit(1);
          }
       } else if (S_ISDIR(st.st_mode)) {
          unlinkdir(dname,0);
       } else {
-         fprintf(stderr,"SARG: unknown path type %s\n",dname);
+         debuga(_("unknown path type %s"),dname);
       }
    }
    closedir(dirp);
 
    if (!contentonly) {
       if (rmdir(dir)) {
-         fprintf(stderr,"SARG: cannot delete %s - %s\n",dir,strerror(errno));
+         debuga(_("cannot delete %s - %s"),dir,strerror(errno));
          exit(1);
       }
    }