]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Configure the images directory in sarg.conf
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Thu, 5 Mar 2015 15:34:19 +0000 (16:34 +0100)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Thu, 5 Mar 2015 15:34:19 +0000 (16:34 +0100)
The directory where the images resides can be changed at run time by
setting image_dir in sarg.conf.

getconf.c
util.c

index ddd8830683db0ca89201d8db25567b608f102a1b..49f6c886216f8b8f5f0ae5e194946b48dc3c0a40 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -35,6 +35,7 @@ extern FileListObject AccessLog;
 extern int PerUserLimitsNumber;
 extern struct PerUserLimitStruct PerUserLimits[MAX_USER_LIMITS];
 extern enum PerUserFileCreationEnum PerUserFileCreation;
+extern char ImageDir[MAXLEN];
 
 struct param_list
 {
@@ -951,6 +952,8 @@ static void parmtest(char *buf)
                return;
        }
 
+       if (getparam_string("image_dir",buf,ImageDir,sizeof(ImageDir))>0) return;
+
        printf(_("SARG: Unknown option %s\n"),buf);
 }
 
diff --git a/util.c b/util.c
index 9955e62271f3bf987c8f89c8b6afb3e418980499..b7b760ab74598cd5db1903783c45b452a53e3cd0 100644 (file)
--- a/util.c
+++ b/util.c
@@ -46,6 +46,9 @@ static char mtab1[12][4]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep",
 //! The list of the HTTP codes to exclude from the report.
 static char *excludecode=NULL;
 
+//! Directory where the images are stored.
+char ImageDir[MAXLEN]=IMAGEDIR;
+
 extern char *CurrentLocale;
 
 #if USE_GETWORD_BACKTRACE
@@ -1050,7 +1053,6 @@ static void copy_images(void)
 {
        FILE *img_in, *img_ou;
        char images[512];
-       char imgdir[MAXLEN];
        char srcfile[MAXLEN];
        char dstfile[MAXLEN];
        DIR *dirp;
@@ -1070,17 +1072,16 @@ static void copy_images(void)
                }
        }
 
-       strcpy(imgdir,IMAGEDIR);
-       dirp = opendir(imgdir);
+       dirp = opendir(ImageDir);
        if(dirp==NULL) {
-               debuga(_("(util) Can't open directory %s: %s\n"),imgdir,strerror(errno));
+               debuga(_("(util) Can't open directory %s: %s\n"),ImageDir,strerror(errno));
                return;
        }
        while ((direntp = readdir( dirp )) != NULL ){
                if(direntp->d_name[0]=='.')
                        continue;
-               if (snprintf(srcfile,sizeof(srcfile),"%s/%s",imgdir,direntp->d_name)>=sizeof(srcfile)) {
-                       debuga(_("Buffer too small to store %s/%s"),imgdir,direntp->d_name);
+               if (snprintf(srcfile,sizeof(srcfile),"%s/%s",ImageDir,direntp->d_name)>=sizeof(srcfile)) {
+                       debuga(_("Buffer too small to store %s/%s"),ImageDir,direntp->d_name);
                        exit(EXIT_FAILURE);
                }
                if (stat(srcfile,&info)) {