]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - lastlog.c
Optimize away a useless strcpy.
[thirdparty/sarg.git] / lastlog.c
index 55aeaa0d24fe31d0ce33a438212be0d9e06a966e..0ff25aa2c1b2a8435f8ca0c5b9482b414cf4709e 100644 (file)
--- a/lastlog.c
+++ b/lastlog.c
@@ -55,14 +55,14 @@ static struct DirEntry *AppendDirEntry(struct DirEntry *List,time_t CreationTime
 
        entry=malloc(sizeof(*entry));
        if (!entry) {
-               debuga(_("Not enough memory to store a report to purge\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store a report to purge\n"));
                DeleteDirList(List);
                return(NULL);
        }
        entry->Name=malloc((NameLen+1)*sizeof(char));
        if (!entry->Name) {
                free(entry);
-               debuga(_("Not enough memory to store a report to purge\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store a report to purge\n"));
                DeleteDirList(List);
                return(NULL);
        }
@@ -93,19 +93,19 @@ static struct DirEntry *BuildDirDateList(struct DirEntry *List,char *Path,int Pa
        int name_len;
 
        if ((dirp = opendir(Path)) == NULL) {
-               debuga(_("Cannot open directory \"%s\": %s\n"),Path,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),Path,strerror(errno));
                exit(EXIT_FAILURE);
        }
        while ((direntp = readdir( dirp )) != NULL )
        {
                name_len=strlen(direntp->d_name);
                if (RootPos+name_len+1>=PathSize) {
-                       debuga(_("Directory entry \"%s%s\" too long to purge the old reports\n"),Path,direntp->d_name);
+                       debuga(__FILE__,__LINE__,_("Directory entry \"%s%s\" too long to purge the old reports\n"),Path,direntp->d_name);
                        exit(EXIT_FAILURE);
                }
                strcpy(Path+Length,direntp->d_name);
                if (stat(Path,&statb) == -1) {
-                       debuga(_("Failed to get the statistics of file \"%s\": %s\n"),Path,strerror(errno));
+                       debuga(__FILE__,__LINE__,_("Failed to get the statistics of file \"%s\": %s\n"),Path,strerror(errno));
                        continue;
                }
                if (!S_ISDIR(statb.st_mode)) continue;
@@ -118,7 +118,7 @@ static struct DirEntry *BuildDirDateList(struct DirEntry *List,char *Path,int Pa
                                List=BuildDirDateList(List,Path,PathSize,RootPos,Length+name_len+1,1);
                                if (!List)
                                {
-                                       debuga(_("Old reports deletion not undertaken due to previous error\n"));
+                                       debuga(__FILE__,__LINE__,_("Old reports deletion not undertaken due to previous error\n"));
                                        break;
                                }
                        }
@@ -130,7 +130,7 @@ static struct DirEntry *BuildDirDateList(struct DirEntry *List,char *Path,int Pa
                                List=AppendDirEntry(List,statb.st_mtime,Path+RootPos,Length-RootPos+name_len);
                                if (!List)
                                {
-                                       debuga(_("Old reports deletion not undertaken due to previous error\n"));
+                                       debuga(__FILE__,__LINE__,_("Old reports deletion not undertaken due to previous error\n"));
                                        break;
                                }
                        }
@@ -153,24 +153,24 @@ static struct DirEntry *BuildDirList(const char *Path)
 
        name_pos=strlen(Path);
        if (name_pos>=sizeof(warea)) {
-               debuga(_("The directory name \"%s\" containing the old reports to purge is too long\n"),Path);
+               debuga(__FILE__,__LINE__,_("The directory name \"%s\" containing the old reports to purge is too long\n"),Path);
                exit(EXIT_FAILURE);
        }
        strcpy(warea,Path);
        if ((dirp = opendir(outdir)) == NULL) {
-               debuga(_("Cannot open directory \"%s\": %s\n"),outdir,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),outdir,strerror(errno));
                exit(EXIT_FAILURE);
        }
        while ((direntp = readdir( dirp )) != NULL )
        {
                name_len=strlen(direntp->d_name);
                if (name_pos+name_len+1>=sizeof(warea)) {
-                       debuga(_("Directory entry \"%s%s\" too long to purge the old reports\n"),Path,direntp->d_name);
+                       debuga(__FILE__,__LINE__,_("Directory entry \"%s%s\" too long to purge the old reports\n"),Path,direntp->d_name);
                        exit(EXIT_FAILURE);
                }
                strcpy(warea+name_pos,direntp->d_name);
                if (stat(warea,&statb) == -1) {
-                       debuga(_("Failed to get the statistics of file \"%s\": %s\n"),warea,strerror(errno));
+                       debuga(__FILE__,__LINE__,_("Failed to get the statistics of file \"%s\": %s\n"),warea,strerror(errno));
                        continue;
                }
                if (!S_ISDIR(statb.st_mode)) continue;
@@ -179,7 +179,7 @@ static struct DirEntry *BuildDirList(const char *Path)
                        List=AppendDirEntry(List,statb.st_mtime,direntp->d_name,name_len);
                        if (!List)
                        {
-                               debuga(_("Old reports deletion not undertaken due to previous error\n"));
+                               debuga(__FILE__,__LINE__,_("Old reports deletion not undertaken due to previous error\n"));
                                break;
                        }
                }
@@ -190,7 +190,7 @@ static struct DirEntry *BuildDirList(const char *Path)
                        List=BuildDirDateList(List,warea,sizeof(warea),name_pos,name_pos+name_len+1,0);
                        if (!List)
                        {
-                               debuga(_("Old reports deletion not undertaken due to previous error\n"));
+                               debuga(__FILE__,__LINE__,_("Old reports deletion not undertaken due to previous error\n"));
                                break;
                        }
                }
@@ -212,7 +212,7 @@ static void DeleteEmptyDirs(char *Path,int PathSize,int BasePos)
                if (Dir-Path<=BasePos) break;
                *Dir='\0';
                if ((dirp = opendir(Path)) == NULL) {
-                       debuga(_("Cannot open directory \"%s\": %s\n"),Path,strerror(errno));
+                       debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),Path,strerror(errno));
                        return;
                }
                index=false;
@@ -232,21 +232,21 @@ static void DeleteEmptyDirs(char *Path,int PathSize,int BasePos)
                        break;
                }
                if (debug)
-                       debuga(_("Deleting empty directory \"%s\"\n"),Path);
+                       debuga(__FILE__,__LINE__,_("Deleting empty directory \"%s\"\n"),Path);
                if (index) {
                        if (strlen(Path)+strlen(INDEX_HTML_FILE)+2>=PathSize) {
-                               debuga(_("Buffer too small to delete index file \"%s/%s\""),Path,INDEX_HTML_FILE);
+                               debuga(__FILE__,__LINE__,_("Buffer too small to delete index file \"%s/%s\""),Path,INDEX_HTML_FILE);
                                exit(EXIT_FAILURE);
                        }
                        strcat(Path,"/"INDEX_HTML_FILE);
                        if (unlink(Path)==-1) {
-                               debuga(_("Failed to delete \"%s\": %s\n"),Path,strerror(errno));
+                               debuga(__FILE__,__LINE__,_("Failed to delete \"%s\": %s\n"),Path,strerror(errno));
                                exit(EXIT_FAILURE);
                        }
                        *Dir='\0';
                }
                if (rmdir(Path)) {
-                       debuga(_("Cannot delete \"%s\": %s\n"),Path,strerror(errno));
+                       debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),Path,strerror(errno));
                        exit(EXIT_FAILURE);
                }
        }
@@ -269,12 +269,12 @@ void mklastlog(const char *outdir)
 
        for (ptr=List ; ptr ; ptr=ptr->Next) ftot++;
        if (debug)
-               debuga(ngettext("%d report directory found\n","%d report directories found\n",ftot),ftot);
+               debuga(__FILE__,__LINE__,ngettext("%d report directory found\n","%d report directories found\n",ftot),ftot);
 
        if(ftot<=LastLog) {
                DeleteDirList(List);
                if (debug) {
-                       debuga(ngettext("No old reports to delete as only %d report currently exists\n",
+                       debuga(__FILE__,__LINE__,ngettext("No old reports to delete as only %d report currently exists\n",
                                                "No old reports to delete as only %d reports currently exist\n",ftot),ftot);
                }
                return;
@@ -282,22 +282,22 @@ void mklastlog(const char *outdir)
 
        ftot-=LastLog;
        if (debug)
-               debuga(ngettext("%d old report to delete\n","%d old reports to delete\n",ftot),ftot);
+               debuga(__FILE__,__LINE__,ngettext("%d old report to delete\n","%d old reports to delete\n",ftot),ftot);
 
        name_pos=strlen(outdir);
        if (name_pos>=sizeof(warea)) {
                DeleteDirList(List);
-               debuga(_("The directory name \"%s\" containing the old reports to purge is too long\n"),outdir);
+               debuga(__FILE__,__LINE__,_("The directory name \"%s\" containing the old reports to purge is too long\n"),outdir);
                exit(EXIT_FAILURE);
        }
        strcpy(warea,outdir);
        for (ptr=List ; ptr && ftot>0 ; ptr=ptr->Next)
        {
                if(debug)
-                       debuga(_("Removing old report file %s\n"),ptr->Name);
+                       debuga(__FILE__,__LINE__,_("Removing old report file %s\n"),ptr->Name);
                if (name_pos+strlen(ptr->Name)+1>=sizeof(warea)) {
                        DeleteDirList(List);
-                       debuga(_("Path too long: "));
+                       debuga(__FILE__,__LINE__,_("Path too long: "));
                        debuga_more("%s%s\n",outdir,ptr->Name);
                        exit(EXIT_FAILURE);
                }