From: Frederic Marchal Date: Thu, 5 Mar 2015 15:34:19 +0000 (+0100) Subject: Configure the images directory in sarg.conf X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=66f507aab5c7bb26f1f77fa7c30ee808adabff60;p=thirdparty%2Fsarg.git Configure the images directory in sarg.conf The directory where the images resides can be changed at run time by setting image_dir in sarg.conf. --- diff --git a/getconf.c b/getconf.c index ddd8830..49f6c88 100644 --- 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 9955e62..b7b760a 100644 --- 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)) {