"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "getconf.c" between
sarg-2.3.11.tar.gz and sarg-2.4.0.tar.gz

About: SARG ia a Squid Analysis Report Generator.

getconf.c  (sarg-2.3.11):getconf.c  (sarg-2.4.0)
/* /*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
* 1998, 2013 * 1998, 2015
* *
* SARG donations: * SARG donations:
* please look at http://sarg.sourceforge.net/donations.php * please look at http://sarg.sourceforge.net/donations.php
* Support: * Support:
* http://sourceforge.net/projects/sarg/forums/forum/363374 * http://sourceforge.net/projects/sarg/forums/forum/363374
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
skipping to change at line 29 skipping to change at line 29
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
* *
*/ */
#include "include/conf.h" #include "include/conf.h"
#include "include/defs.h" #include "include/defs.h"
#include "include/filelist.h"
#define SET_LIST(list) list,sizeof(list)/sizeof(list[0]) #define SET_LIST(list) list,sizeof(list)/sizeof(list[0])
extern numlist hours, weekdays; //! The configuration file from which the graph option was loaded
char GraphConfigFile[MAXLEN]="";
//! How many include directives were followed.
static int IncludeLevel=0;
extern int hours[24], weekdays[7];
extern FileListObject AccessLog;
extern int PerUserLimitsNumber;
extern struct PerUserLimitStruct PerUserLimits[MAX_USER_LIMITS];
extern enum PerUserFileCreationEnum PerUserFileCreation;
extern char ImageDir[MAXLEN];
extern FileListObject UserAgentLog;
extern bool UserAgentFromCmdLine;
extern char StripUserSuffix[MAX_USER_LEN];
extern int StripSuffixLen;
struct param_list struct param_list
{ {
//! The name of the value of the parameter. //! The name of the value of the parameter.
const char *name; const char *name;
//! The bit to set if the value is found. //! The bit to set if the value is found.
unsigned long int value; unsigned long int value;
//! The value is invalid if any bit of this mask is set in the parameter. //! The value is invalid if any bit of this mask is set in the parameter.
unsigned long int exclude; unsigned long int exclude;
}; };
struct sort_list struct sort_list
{ {
//! The name of the value of the parameter. //! The name of the value of the parameter.
const char *name; const char *name;
//! The bit to set if the value is found. //! The bit to set if the value is found.
unsigned long int value; unsigned long int value;
}; };
struct select_list
{
//! The name of the value of the parameter.
const char *name;
//! The value to assign when the name is selected.
int value;
};
static struct param_list report_type_values[]= static struct param_list report_type_values[]=
{ {
{"users_sites",REPORT_TYPE_USERS_SITES,0}, {"users_sites",REPORT_TYPE_USERS_SITES,0},
{"topusers",REPORT_TYPE_TOPUSERS,0}, {"topusers",REPORT_TYPE_TOPUSERS,0},
{"topsites",REPORT_TYPE_TOPSITES,0}, {"topsites",REPORT_TYPE_TOPSITES,0},
{"sites_users",REPORT_TYPE_SITES_USERS,0}, {"sites_users",REPORT_TYPE_SITES_USERS,0},
{"date_time",REPORT_TYPE_DATE_TIME,0}, {"date_time",REPORT_TYPE_DATE_TIME,0},
{"denied",REPORT_TYPE_DENIED,0}, {"denied",REPORT_TYPE_DENIED,0},
{"auth_failures",REPORT_TYPE_AUTH_FAILURES,0}, {"auth_failures",REPORT_TYPE_AUTH_FAILURES,0},
{"site_user_time_date",REPORT_TYPE_SITE_USER_TIME_DATE,0}, {"site_user_time_date",REPORT_TYPE_SITE_USER_TIME_DATE,0},
{"downloads",REPORT_TYPE_DOWNLOADS,0}, {"downloads",REPORT_TYPE_DOWNLOADS,0},
{"user_agent",REPORT_TYPE_USERAGENT,0},
}; };
static struct param_list data_field_values[]= static struct param_list data_field_values[]=
{ {
{"user",DATA_FIELD_USER,0}, {"user",DATA_FIELD_USER,0},
{"date",DATA_FIELD_DATE,0}, {"date",DATA_FIELD_DATE,0},
{"time",DATA_FIELD_TIME,0}, {"time",DATA_FIELD_TIME,0},
{"url",DATA_FIELD_URL,0}, {"url",DATA_FIELD_URL,0},
{"connect",DATA_FIELD_CONNECT,0}, {"connect",DATA_FIELD_CONNECT,0},
{"bytes",DATA_FIELD_BYTES,0}, {"bytes",DATA_FIELD_BYTES,0},
{"in_cache",DATA_FIELD_IN_CACHE,0}, {"in_cache",DATA_FIELD_IN_CACHE,0},
{"out_cache",DATA_FIELD_OUT_CACHE,0}, {"out_cache",DATA_FIELD_OUT_CACHE,0},
{"elapsed",DATA_FIELD_ELAPSED,0}, {"elapsed",DATA_FIELD_ELAPSED,0},
}; };
static struct param_list topuserfields_values[]= static struct param_list topuserfields_values[]=
{ {
{"NUM",TOPUSERFIELDS_NUM,0}, {"NUM",TOPUSERFIELDS_NUM,0},
{"DATE_TIME",TOPUSERFIELDS_DATE_TIME,0}, {"DATE_TIME",TOPUSERFIELDS_DATE_TIME,0},
{"USERID",TOPUSERFIELDS_USERID,0}, {"USERID",TOPUSERFIELDS_USERID,0},
{"USERIP",TOPUSERFIELDS_USERIP,0},
{"CONNECT",TOPUSERFIELDS_CONNECT,0}, {"CONNECT",TOPUSERFIELDS_CONNECT,0},
{"BYTES",TOPUSERFIELDS_BYTES,0}, {"BYTES",TOPUSERFIELDS_BYTES,0},
{"%BYTES",TOPUSERFIELDS_SETYB,0}, {"%BYTES",TOPUSERFIELDS_SETYB,0},
{"SETYB",TOPUSERFIELDS_SETYB,0}, {"SETYB",TOPUSERFIELDS_SETYB,0},
{"IN-CACHE-OUT",TOPUSERFIELDS_IN_CACHE_OUT,0}, {"IN-CACHE-OUT",TOPUSERFIELDS_IN_CACHE_OUT,0},
{"USED_TIME",TOPUSERFIELDS_USED_TIME,0}, {"USED_TIME",TOPUSERFIELDS_USED_TIME,0},
{"MILISEC",TOPUSERFIELDS_MILISEC,0}, {"MILISEC",TOPUSERFIELDS_MILISEC,0},
{"%TIME",TOPUSERFIELDS_PTIME,0}, {"%TIME",TOPUSERFIELDS_PTIME,0},
{"TOTAL",TOPUSERFIELDS_TOTAL,0}, {"TOTAL",TOPUSERFIELDS_TOTAL,0},
{"AVERAGE",TOPUSERFIELDS_AVERAGE,0}, {"AVERAGE",TOPUSERFIELDS_AVERAGE,0},
skipping to change at line 188 skipping to change at line 214
}; };
struct sort_list user_sort[]= struct sort_list user_sort[]=
{ {
{"BYTES",USER_SORT_BYTES}, {"BYTES",USER_SORT_BYTES},
{"SITE",USER_SORT_SITE}, {"SITE",USER_SORT_SITE},
{"CONNECT",USER_SORT_CONNECT}, {"CONNECT",USER_SORT_CONNECT},
{"TIME",USER_SORT_TIME}, {"TIME",USER_SORT_TIME},
}; };
static struct select_list per_user_limit_create_file[]=
{
{"always",PUFC_Always}, //always create an empty file
{"as_required",PUFC_AsRequired}, //create the file if necessary (no empty
file is created)
};
static int is_param(const char *param,const char *buf) static int is_param(const char *param,const char *buf)
{ {
int plen; int plen;
plen=strlen(param); plen=strlen(param);
if (strncmp(buf,param,plen) != 0) return(0); if (strncmp(buf,param,plen) != 0) return(0);
buf+=plen; buf+=plen;
if ((unsigned char)*buf>' ') return(0); if ((unsigned char)*buf>' ') return(0);
return(1); return(1);
} }
skipping to change at line 210 skipping to change at line 242
{ {
int plen; int plen;
plen=strlen(param); plen=strlen(param);
if (strncmp(buf,param,plen) != 0) return(0); if (strncmp(buf,param,plen) != 0) return(0);
buf+=plen; buf+=plen;
if ((unsigned char)*buf>' ') return(0); if ((unsigned char)*buf>' ') return(0);
while (*buf && (unsigned char)*buf<=' ') buf++; while (*buf && (unsigned char)*buf<=' ') buf++;
if (strlen(buf)>=value_size) { if (strlen(buf)>=value_size) {
debuga(_("The string value of parameter \"%s\" is too long\n"),pa ram); debuga(__FILE__,__LINE__,_("The string value of parameter \"%s\" is too long\n"),param);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
strcpy(value,buf); strcpy(value,buf);
fixnone(value); fixnone(value);
return(1); return(1);
} }
/*!
* Get a pointer to the beginning of the string value defined by the
* parameter. The returned value is NULL if the buffer doesn't contain
* the parameter.
*
* \param param The parameter to look for.
* \param buf The buffer containing the line read from the configuration
* file.
*
* \return A pointer to the beginning of the parameter value or NULL if
* the line is not for the requested parameter.
*/
static char *getparam_stringptr(const char *param,char *buf)
{
int plen;
plen=strlen(param);
if (strncmp(buf,param,plen) != 0) return(NULL);
buf+=plen;
if ((unsigned char)*buf>' ') return(NULL);
while (*buf && (unsigned char)*buf<=' ') buf++;
return(buf);
}
static int getparam_quoted(const char *param,char *buf,char *value,int value_siz e) static int getparam_quoted(const char *param,char *buf,char *value,int value_siz e)
{ {
int plen; int plen;
int i; int i;
plen=strlen(param); plen=strlen(param);
if (strncmp(buf,param,plen) != 0) return(0); if (strncmp(buf,param,plen) != 0) return(0);
buf+=plen; buf+=plen;
if ((unsigned char)*buf>' ') return(0); if ((unsigned char)*buf>' ') return(0);
while (*buf && (unsigned char)*buf<=' ') buf++; while (*buf && (unsigned char)*buf<=' ') buf++;
if (*buf != '\"') { if (*buf != '\"') {
debuga(_("Missing double quote after parameter \"%s\"\n"),param); debuga(__FILE__,__LINE__,_("Missing double quote after parameter \"%s\"\n"),param);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
buf++; buf++;
value_size--; value_size--;
for (i=0 ; i<value_size && *buf && *buf!='\"' ; i++) { for (i=0 ; i<value_size && *buf && *buf!='\"' ; i++) {
value[i]=*buf++; value[i]=*buf++;
} }
value[i]='\0'; value[i]='\0';
if (*buf != '\"') { if (*buf != '\"') {
debuga(_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size); debuga(__FILE__,__LINE__,_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fixnone(value); fixnone(value);
return(1); return(1);
} }
static int getparam_2words(const char *param,char *buf,char *word1,int word1_siz e,char *word2,int word2_size) static int getparam_2words(const char *param,char *buf,char *word1,int word1_siz e,char *word2,int word2_size)
{ {
int plen; int plen;
int i; int i;
plen=strlen(param); plen=strlen(param);
if (strncmp(buf,param,plen) != 0) return(0); if (strncmp(buf,param,plen) != 0) return(0);
buf+=plen; buf+=plen;
if ((unsigned char)*buf>' ') return(0); if ((unsigned char)*buf>' ') return(0);
while (*buf && (unsigned char)*buf<=' ') buf++; while (*buf && (unsigned char)*buf<=' ') buf++;
for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++) for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++)
word1[i]=*buf++; word1[i]=*buf++;
if (i>=word1_size) { if (i>=word1_size) {
debuga(_("The first word of parameter \"%s\" is more than %d byte s long\n"),param,word1_size-1); debuga(__FILE__,__LINE__,_("The first word of parameter \"%s\" is more than %d bytes long\n"),param,word1_size-1);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (*buf!=' ') { if (*buf!=' ') {
debuga(_("Missing second word for parameter \"%s\"\n"),param); debuga(__FILE__,__LINE__,_("Missing second word for parameter \"% s\"\n"),param);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
word1[i]=0; word1[i]=0;
while (*buf && (unsigned char)*buf<=' ') buf++; while (*buf && (unsigned char)*buf<=' ') buf++;
for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++) for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++)
word2[i]=*buf++; word2[i]=*buf++;
if (i>=word2_size) { if (i>=word2_size) {
debuga(_("The second word of parameter \"%s\" is more than %d byt es long\n"),param,word2_size-1); debuga(__FILE__,__LINE__,_("The second word of parameter \"%s\" i s more than %d bytes long\n"),param,word2_size-1);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
word2[i]=0; word2[i]=0;
fixnone(word1); fixnone(word1);
fixnone(word2); fixnone(word2);
return(1); return(1);
} }
static int getparam_int(const char *param,char *buf,int *value) static int getparam_int(const char *param,char *buf,int *value)
skipping to change at line 300 skipping to change at line 357
int next; int next;
plen=strlen(param); plen=strlen(param);
if (strncmp(buf,param,plen) != 0) return(0); if (strncmp(buf,param,plen) != 0) return(0);
buf+=plen; buf+=plen;
if ((unsigned char)*buf>' ') return(0); if ((unsigned char)*buf>' ') return(0);
while (*buf && (unsigned char)*buf<=' ') buf++; while (*buf && (unsigned char)*buf<=' ') buf++;
next=0; next=0;
if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ' ) { if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ' ) {
debuga(_("The integer value of parameter \"%s\" is invalid\n"),pa ram); debuga(__FILE__,__LINE__,_("The integer value of parameter \"%s\" is invalid\n"),param);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return(1); return(1);
} }
static int getparam_bool(const char *param,char *buf,bool *value) static int getparam_bool(const char *param,char *buf,bool *value)
{ {
int plen; int plen;
int i; int i;
const char *bool_str="yes,true,on,1"; const char *bool_str="yes,true,on,1";
skipping to change at line 352 skipping to change at line 409
*value=0UL; *value=0UL;
while (*buf) { while (*buf) {
str=buf; str=buf;
while (*str && (unsigned char)*str>' ' && *str!=';') str++; while (*str && (unsigned char)*str>' ' && *str!=';') str++;
if (*str) { if (*str) {
*str++='\0'; *str++='\0';
while (*str && ((unsigned char)*str<=' ' || *str==';')) s tr++; while (*str && ((unsigned char)*str<=' ' || *str==';')) s tr++;
} }
for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++); for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
if (i>=noptions) { if (i>=noptions) {
debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),b uf,param); debuga(__FILE__,__LINE__,_("Unknown value \"%s\" for para meter \"%s\"\n"),buf,param);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if ((*value & options[i].exclude)!=0) { if ((*value & options[i].exclude)!=0) {
debuga(_("Value \"%s\" conflicts with other selected valu es for parameter \"%s\"\n"),buf,param); debuga(__FILE__,__LINE__,_("Value \"%s\" conflicts with o ther selected values for parameter \"%s\"\n"),buf,param);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
*value|=options[i].value; *value|=options[i].value;
buf=str; buf=str;
} }
return(1); return(1);
} }
static int getparam_sort(const char *param,struct sort_list *options,int noption s,char *buf,unsigned long int *value) static int getparam_sort(const char *param,struct sort_list *options,int noption s,char *buf,unsigned long int *value)
{ {
skipping to change at line 387 skipping to change at line 444
str=buf; str=buf;
order=NULL; order=NULL;
while (*str && (unsigned char)*str>' ') str++; while (*str && (unsigned char)*str>' ') str++;
if (*str) { if (*str) {
*str++='\0'; *str++='\0';
while (*str && (unsigned char)*str<=' ') str++; while (*str && (unsigned char)*str<=' ') str++;
order=str; order=str;
} }
for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++); for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
if (i>=noptions) { if (i>=noptions) {
debuga(_("Unknown sort criterion \"%s\" for parameter \"%s\"\n"), buf,param); debuga(__FILE__,__LINE__,_("Unknown sort criterion \"%s\" for par ameter \"%s\"\n"),buf,param);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
*value=options[i].value; *value=options[i].value;
if (order) { if (order) {
str=order; str=order;
while (*str && (unsigned char)*str>' ') str++; while (*str && (unsigned char)*str>' ') str++;
if (*str) { if (*str) {
*str++='\0'; *str++='\0';
while (*str && (unsigned char)*str<=' ') str++; while (*str && (unsigned char)*str<=' ') str++;
} }
if (strcasecmp(order,"reverse")==0 || strcasecmp(order,"D")==0) { if (strcasecmp(order,"reverse")==0 || strcasecmp(order,"D")==0) {
*value|=SORT_REVERSE; *value|=SORT_REVERSE;
} else if (strcasecmp(order,"normal")!=0 && strcasecmp(order,"A") !=0) { } else if (strcasecmp(order,"normal")!=0 && strcasecmp(order,"A") !=0) {
debuga(_("Unknown sort order \"%s\" for parameter \"%s\"\ n"),order,param); debuga(__FILE__,__LINE__,_("Unknown sort order \"%s\" for parameter \"%s\"\n"),order,param);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
buf=str; buf=str;
return(1); return(1);
} }
static void parmtest(char *buf) static int getparam_select(const char *param,struct select_list *options,int nop
tions,char *buf,int *value)
{
int plen;
char *str;
int i;
plen=strlen(param);
if (strncmp(buf,param,plen) != 0) return(0);
buf+=plen;
if ((unsigned char)*buf>' ') return(0);
while (*buf && (unsigned char)*buf<=' ') buf++;
str=buf;
while (*buf && (unsigned char)*buf>' ' && *buf!=';') buf++;
*buf='\0';
for (i=0 ; i<noptions && strcasecmp(str,options[i].name) ; i++);
if (i>=noptions) {
debuga(__FILE__,__LINE__,_("Unknown value \"%s\" for parameter \"
%s\"\n"),str,param);
exit(EXIT_FAILURE);
}
*value=options[i].value;
return(1);
}
static int getparam_userlimit(const char *param,char *buf)
{
int plen;
char *file_begin,*file_end;
int limit;
int digit;
char *str;
int i;
enum PerUserOutputEnum output;
const struct
{
const char *name;
enum PerUserOutputEnum value;
} output_types[]=
{
{"id",PUOE_UserId},
{"ip",PUOE_UserIp},
};
plen=strlen(param);
if (strncmp(buf,param,plen) != 0) return(0);
buf+=plen;
if ((unsigned char)*buf>' ') return(0);
while (*buf && (unsigned char)*buf<=' ') buf++;
/*
options are made of a file name, an integer limit and an optional
integer flag. The file name may contain spaces. We keep searching
until a valid number is found after a space.
*/
file_begin=buf;
do {
while (*buf && (unsigned char)*buf>' ') buf++;
if (*buf!=' ') {
debuga(__FILE__,__LINE__,_("Missing limit in per_user_lim
it\n"));
exit(EXIT_FAILURE);
}
file_end=buf;
while (*buf && (unsigned char)*buf<=' ') buf++;
limit=0;
while (*buf && isdigit(*buf)) {
digit=*buf-'0';
if (limit>=(INT_MAX-digit)/10) break;
limit=limit*10+digit;
buf++;
}
} while (*buf && *buf!=' ');
output=PUOE_UserId;
if (*buf==' ') {
while (*buf && (unsigned char)*buf<=' ') buf++;
str=buf;
while (*buf && (unsigned char)*buf>' ') buf++;
*buf='\0';
for (i=sizeof(output_types)/sizeof(output_types[0])-1 ; i>=0 ; i-
-)
if (strcasecmp(output_types[i].name,str)==0) {
output=output_types[i].value;
break;
}
if (i<0) {
debuga(__FILE__,__LINE__,_("Invalid output type in per_us
er_limit\n"));
exit(EXIT_FAILURE);
}
}
if (PerUserLimitsNumber>=MAX_USER_LIMITS) {
debuga(__FILE__,__LINE__,_("Too many per_user_limit\n"));
exit(EXIT_FAILURE);
}
*file_end='\0';
safe_strcpy(PerUserLimits[PerUserLimitsNumber].File,file_begin,sizeof(Per
UserLimits[PerUserLimitsNumber].File));
PerUserLimits[PerUserLimitsNumber].Limit=limit;
PerUserLimits[PerUserLimitsNumber].Output=output;
PerUserLimitsNumber++;
return(1);
}
static void ccharset(char *CharSet)
{
if (strcmp(CharSet,"Latin2") == 0) strcpy(CharSet,"ISO-8859-2");
else if (strcmp(CharSet,"Latin3") == 0) strcpy(CharSet,"ISO-8859-3");
else if (strcmp(CharSet,"Latin4") == 0) strcpy(CharSet,"ISO-8859-4");
else if (strcmp(CharSet,"Cyrillic") == 0) strcpy(CharSet,"ISO-8859-5");
else if (strcmp(CharSet,"Arabic") == 0) strcpy(CharSet,"ISO-8859-6");
else if (strcmp(CharSet,"Greek") == 0) strcpy(CharSet,"ISO-8859-7");
else if (strcmp(CharSet,"Hebrew") == 0) strcpy(CharSet,"ISO-8859-8");
else if (strcmp(CharSet,"Latin5") == 0) strcpy(CharSet,"ISO-8859-9");
else if (strcmp(CharSet,"Latin6") == 0) strcpy(CharSet,"ISO-8859-10");
else if (strcmp(CharSet,"Japan") == 0) strcpy(CharSet,"EUC-JP");
else if (strcmp(CharSet,"Koi8-r") == 0) strcpy(CharSet,"KOI8-R");
/*
* Any other encoding name is left unchanged.
*/
return;
}
static void parmtest(char *buf,const char *File)
{ {
char wbuf[2048]; char wbuf[2048];
struct getwordstruct gwarea; struct getwordstruct gwarea;
int iVal;
while (*buf && (unsigned char)*buf<=' ') buf++; while (*buf && (unsigned char)*buf<=' ') buf++;
if(*buf == '#' || *buf == '\0') if (*buf == '#' || *buf == '\0')
return; return;
if(debugz) if (debugz>=LogLevel_Process)
printf(_("SARG: TAG: %s\n"),buf); printf(_("SARG: TAG: %s\n"),buf);
if (getparam_string("background_color",buf,BgColor,sizeof(BgColor))>0) re turn; if (getparam_string("background_color",buf,BgColor,sizeof(BgColor))>0) re turn;
if (getparam_string("text_color",buf,TxColor,sizeof(TxColor))>0) return; if (getparam_string("text_color",buf,TxColor,sizeof(TxColor))>0) return;
if (getparam_string("text_bgcolor",buf,TxBgColor,sizeof(TxBgColor))>0) re turn; if (getparam_string("text_bgcolor",buf,TxBgColor,sizeof(TxBgColor))>0) re turn;
if (getparam_string("title_color",buf,TiColor,sizeof(TiColor))>0) return; if (getparam_string("title_color",buf,TiColor,sizeof(TiColor))>0) return;
skipping to change at line 471 skipping to change at line 650
if (ip2name_config(buf+10)>0) return; if (ip2name_config(buf+10)>0) return;
} }
if (getparam_bool("user_ip",buf,&UserIp)>0) return; if (getparam_bool("user_ip",buf,&UserIp)>0) return;
if (getparam_string("max_elapsed",buf,MaxElapsed,sizeof(MaxElapsed))>0) r eturn; if (getparam_string("max_elapsed",buf,MaxElapsed,sizeof(MaxElapsed))>0) r eturn;
if (is_param("date_format",buf)) { if (is_param("date_format",buf)) {
getword_start(&gwarea,buf); getword_start(&gwarea,buf);
if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
debuga(_("Invalid value in the \"date_format\" parameter\ n")); debuga(__FILE__,__LINE__,_("Invalid record in \"date_form at\" parameter\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
strncpy(DateFormat,gwarea.current,1); DateFormat=gwarea.current[0];
fixnone(DateFormat);
return; return;
} }
if (is_param("hours",buf)) { if (is_param("hours",buf)) {
if( getnumlist( buf, &hours, 24, 24 ) ) { getnumlist("hours", buf, hours, 24);
debuga(_("Error: Invalid syntax in hours tag!\n"));
exit( 1 );
}
return;
} }
if (is_param("weekdays",buf)) { if (is_param("weekdays",buf)) {
if( getnumlist( buf, &weekdays, 7, 7 ) ) { getnumlist("weekdays", buf, weekdays, 7);
debuga(_("Error: Invalid syntax in weekdays tag!\n"));
exit( 1 );
}
return;
} }
if (getparam_sort("topuser_sort_field",SET_LIST(topuser_sort),buf,&Topuse rSort)>0) return; if (getparam_sort("topuser_sort_field",SET_LIST(topuser_sort),buf,&Topuse rSort)>0) return;
if (getparam_sort("user_sort_field",SET_LIST(user_sort),buf,&UserSort)>0) return; if (getparam_sort("user_sort_field",SET_LIST(user_sort),buf,&UserSort)>0) return;
if (is_param("access_log",buf)>0) { if (is_param("access_log",buf)>0) {
if (AccessLogFromCmdLine==0) { if (AccessLogFromCmdLine==0) {
if (NAccessLog>=MAXLOGS) { char *FileName=getparam_stringptr("access_log",buf);
debuga(_("Too many log files in configuration fil if (!AccessLog)
e\n")); AccessLog=FileList_Create();
if (!FileList_AddFile(AccessLog,FileName)) {
debuga(__FILE__,__LINE__,_("Not enough memory to
store the input log file names\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
getparam_string("access_log",buf,AccessLog[NAccessLog],MA
X_LOG_FILELEN);
NAccessLog++;
} }
return; return;
} }
if (is_param("redirector_log",buf)>0) { if (is_param("redirector_log",buf)>0) {
if (RedirectorLogFromCmdLine==0) { if (RedirectorLogFromCmdLine==0) {
if (NRedirectorLogs>=MAX_REDIRECTOR_LOGS) { if (NRedirectorLogs>=MAX_REDIRECTOR_LOGS) {
debuga(_("Too many redirector log files in config uration file\n")); debuga(__FILE__,__LINE__,_("Too many redirector l og files in configuration file\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
getparam_string("redirector_log",buf,RedirectorLogs[NRedi rectorLogs],MAX_REDIRECTOR_FILELEN); getparam_string("redirector_log",buf,RedirectorLogs[NRedi rectorLogs],MAX_REDIRECTOR_FILELEN);
NRedirectorLogs++; NRedirectorLogs++;
} }
return; return;
} }
if (getparam_string("useragent_log",buf,UserAgentLog,sizeof(UserAgentLog) if (is_param("useragent_log",buf)>0) {
)>0) return; if (!UserAgentFromCmdLine) {
if (!UserAgentLog)
UserAgentLog=FileList_Create();
char *FileName=getparam_stringptr("useragent_log",buf);
if (!FileList_AddFile(UserAgentLog,FileName)) {
debuga(__FILE__,__LINE__,_("Not enough memory to
store a user agent file name\n"));
exit(EXIT_FAILURE);
}
}
return;
}
if (getparam_string("exclude_hosts",buf,ExcludeHosts,sizeof(ExcludeHosts) )>0) return; if (getparam_string("exclude_hosts",buf,ExcludeHosts,sizeof(ExcludeHosts) )>0) return;
if (getparam_string("exclude_codes",buf,ExcludeCodes,sizeof(ExcludeCodes) )>0) return; if (getparam_string("exclude_codes",buf,ExcludeCodes,sizeof(ExcludeCodes) )>0) return;
if (getparam_string("exclude_users",buf,ExcludeUsers,sizeof(ExcludeUsers) )>0) return; if (getparam_string("exclude_users",buf,ExcludeUsers,sizeof(ExcludeUsers) )>0) return;
if (getparam_string("password",buf,PasswdFile,sizeof(PasswdFile))>0) retu rn; if (getparam_string("password",buf,PasswdFile,sizeof(PasswdFile))>0) retu rn;
if (getparam_string("temporary_dir",buf,TempDir,sizeof(TempDir))>0) retur n; if (getparam_string("temporary_dir",buf,TempDir,sizeof(TempDir))>0) retur n;
if (getparam_string("temporary_dir_path",buf,TempDirPath,sizeof(TempDirPa
th))>0) return;
if (getparam_list("report_type",SET_LIST(report_type_values),buf,&ReportT ype)>0) return; if (getparam_list("report_type",SET_LIST(report_type_values),buf,&ReportT ype)>0) return;
if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) retu rn; if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) retu rn;
if (getparam_bool("anonymous_output_files",buf,&AnonymousOutputFiles)>0) return; if (getparam_bool("anonymous_output_files",buf,&AnonymousOutputFiles)>0) return;
if (getparam_string("output_email",buf,OutputEmail,sizeof(OutputEmail))>0 ) return; if (getparam_string("output_email",buf,OutputEmail,sizeof(OutputEmail))>0 ) return;
if (getparam_2words("per_user_limit",buf,PerUserLimitFile,sizeof(PerUserL if (getparam_userlimit("per_user_limit",buf)>0) return;
imitFile),wbuf,sizeof(wbuf))>0) {
PerUserLimit=atoi(wbuf); if (getparam_select("per_user_limit_file_create",SET_LIST(per_user_limit_
create_file),buf,&iVal)>0) {
PerUserFileCreation=(enum PerUserFileCreationEnum)iVal;
return; return;
} }
if (getparam_int("lastlog",buf,&LastLog)>0) return; if (getparam_int("lastlog",buf,&LastLog)>0) return;
if (getparam_bool("remove_temp_files",buf,&RemoveTempFiles)>0) return; if (getparam_bool("remove_temp_files",buf,&RemoveTempFiles)>0) return;
if (getparam_string("replace_index",buf,ReplaceIndex,sizeof(ReplaceIndex) )>0) return; if (getparam_string("replace_index",buf,ReplaceIndex,sizeof(ReplaceIndex) )>0) return;
if (getparam_list("index_tree",SET_LIST(index_tree_values),buf,&IndexTree )>0) return; if (getparam_list("index_tree",SET_LIST(index_tree_values),buf,&IndexTree )>0) return;
skipping to change at line 611 skipping to change at line 797
if (getparam_bool("privacy",buf,&Privacy)>0) return; if (getparam_bool("privacy",buf,&Privacy)>0) return;
if (getparam_quoted("privacy_string",buf,PrivacyString,sizeof(PrivacyStri ng))>0) return; if (getparam_quoted("privacy_string",buf,PrivacyString,sizeof(PrivacyStri ng))>0) return;
if (getparam_string("privacy_string_color",buf,PrivacyStringColor,sizeof( PrivacyStringColor))>0) return; if (getparam_string("privacy_string_color",buf,PrivacyStringColor,sizeof( PrivacyStringColor))>0) return;
if (getparam_bool("show_successful_message",buf,&SuccessfulMsg)>0) return ; if (getparam_bool("show_successful_message",buf,&SuccessfulMsg)>0) return ;
if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) retu rn; if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) retu rn;
if (getparam_bool("show_read_percent",buf,&ShowReadPercent)>0) return;
if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&To pUserFields)>0) return; if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&To pUserFields)>0) return;
if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersRep ort)>0) return; if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersRep ort)>0) return;
if (getparam_list("user_report_fields",SET_LIST(userreportfields_values), buf,&UserReportFields)>0) return; if (getparam_list("user_report_fields",SET_LIST(userreportfields_values), buf,&UserReportFields)>0) return;
if (getparam_string("datafile",buf,DataFile,sizeof(DataFile))>0) return; if (getparam_string("datafile",buf,DataFile,sizeof(DataFile))>0) return;
if (getparam_quoted("datafile_delimiter",buf,DataFileDelimiter,sizeof(Dat aFileDelimiter))>0) return; if (getparam_quoted("datafile_delimiter",buf,DataFileDelimiter,sizeof(Dat aFileDelimiter))>0) return;
skipping to change at line 654 skipping to change at line 842
if (getparam_string("www_document_root",buf,wwwDocumentRoot,sizeof(wwwDoc umentRoot))>0) return; if (getparam_string("www_document_root",buf,wwwDocumentRoot,sizeof(wwwDoc umentRoot))>0) return;
if (getparam_string("block_it",buf,BlockIt,sizeof(BlockIt))>0) return; if (getparam_string("block_it",buf,BlockIt,sizeof(BlockIt))>0) return;
if (getparam_string("external_css_file",buf,ExternalCSSFile,sizeof(Extern alCSSFile))>0) return; if (getparam_string("external_css_file",buf,ExternalCSSFile,sizeof(Extern alCSSFile))>0) return;
if (getparam_bool("user_authentication",buf,&UserAuthentication)>0) retur n; if (getparam_bool("user_authentication",buf,&UserAuthentication)>0) retur n;
if (getparam_string("AuthUserTemplateFile",buf,wbuf,sizeof(wbuf))>0) { if (getparam_string("AuthUserTemplateFile",buf,wbuf,sizeof(wbuf))>0) {
char dir[MAXLEN];
if (is_absolute(wbuf)) { if (is_absolute(wbuf)) {
if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) { if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) {
debuga(_("Template file name is too long in param eter \"AuthUserTemplateFile\"\n")); debuga(__FILE__,__LINE__,_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
safe_strcpy(AuthUserTemplateFile,wbuf,sizeof(AuthUserTemp lateFile)); safe_strcpy(AuthUserTemplateFile,wbuf,sizeof(AuthUserTemp lateFile));
} else { } else {
safe_strcpy(dir,ConfigFile,sizeof(dir)); char dir[MAXLEN];
safe_strcpy(dir,File,sizeof(dir));
if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplate File),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) { if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplate File),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) {
debuga(_("Template file name is too long in param eter \"AuthUserTemplateFile\"\n")); debuga(__FILE__,__LINE__,_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
return; return;
} }
if (is_param("download_suffix",buf)) { if (is_param("download_suffix",buf)) {
char warea[MAXLEN]; char warea[MAXLEN];
getparam_quoted("download_suffix",buf,warea,sizeof(warea)); getparam_quoted("download_suffix",buf,warea,sizeof(warea));
set_download_suffix(warea); set_download_suffix(warea);
return; return;
} }
if (getparam_bool("graphs",buf,&Graphs)>0) { if (getparam_bool("graphs",buf,&Graphs)>0) {
#ifndef HAVE_GD #ifndef HAVE_GD
if (Graphs) if (Graphs)
debugaz(_("No graphs available as sarg was not compiled w debugaz(__FILE__,__LINE__,_("No graphs available as sarg
ith libgd. Set \"graphs\" to \"no\" in %s to disable this warning\n"), was not compiled with libgd. Set \"graphs\" to \"no\" in %s to disable this warn
ConfigFile); ing\n"),
File);
#endif #endif
safe_strcpy(GraphConfigFile,File,sizeof(GraphConfigFile));
return; return;
} }
if (getparam_string("graph_days_bytes_bar_color",buf,GraphDaysBytesBarCol or,sizeof(GraphDaysBytesBarColor))>0) return; if (getparam_string("graph_days_bytes_bar_color",buf,GraphDaysBytesBarCol or,sizeof(GraphDaysBytesBarColor))>0) return;
if (getparam_string("redirector_log_format",buf,RedirectorLogFormat,sizeo f(RedirectorLogFormat))>0) return; if (getparam_string("redirector_log_format",buf,RedirectorLogFormat,sizeo f(RedirectorLogFormat))>0) return;
if (getparam_string("squidguard_log_format",buf,RedirectorLogFormat,sizeo f(RedirectorLogFormat))>0) { if (getparam_string("squidguard_log_format",buf,RedirectorLogFormat,sizeo f(RedirectorLogFormat))>0) {
debuga(_("squidguard_log_format is deprecated and has been replac ed by redirector_log_format. Please update your configuration file.\n")); debuga(__FILE__,__LINE__,_("squidguard_log_format is deprecated a nd has been replaced by redirector_log_format. Please update your configuration file.\n"));
return; return;
} }
if (getparam_bool("redirector_filter_out_date",buf,&RedirectorFilterOutDa te)>0) return; if (getparam_bool("redirector_filter_out_date",buf,&RedirectorFilterOutDa te)>0) return;
if (getparam_bool("redirector_ignore_date",buf,&RedirectorFilterOutDate)> 0) { if (getparam_bool("redirector_ignore_date",buf,&RedirectorFilterOutDate)> 0) {
/* /*
Due to an old bug in sarg before version 2.3, the option was havi ng the opposite action than implied by the name. Due to an old bug in sarg before version 2.3, the option was havi ng the opposite action than implied by the name.
*/ */
debuga(_("redirector_ignore_date is deprecated and has been repla ced by redirector_filter_out_date that does the action implied by its name as op posed to redirector_ignore_date. Please update your configuration file.\n")); debuga(__FILE__,__LINE__,_("redirector_ignore_date is deprecated and has been replaced by redirector_filter_out_date that does the action implied by its name as opposed to redirector_ignore_date. Please update your configurat ion file.\n"));
RedirectorFilterOutDate=!RedirectorFilterOutDate; RedirectorFilterOutDate=!RedirectorFilterOutDate;
return; return;
} }
if (getparam_bool("squidguard_ignore_date",buf,&RedirectorFilterOutDate)> 0) { if (getparam_bool("squidguard_ignore_date",buf,&RedirectorFilterOutDate)> 0) {
debuga(_("squidguard_ignore_date is deprecated and has been repla ced by redirector_filter_out_date that does the action implied by its name as op posed to squidguard_ignore_date. Please update your configuration file.\n")); debuga(__FILE__,__LINE__,_("squidguard_ignore_date is deprecated and has been replaced by redirector_filter_out_date that does the action implied by its name as opposed to squidguard_ignore_date. Please update your configurat ion file.\n"));
RedirectorFilterOutDate=!RedirectorFilterOutDate; RedirectorFilterOutDate=!RedirectorFilterOutDate;
return; return;
} }
if (getparam_bool("dansguardian_filter_out_date",buf,&DansguardianFilterO utDate)>0) return; if (getparam_bool("dansguardian_filter_out_date",buf,&DansguardianFilterO utDate)>0) return;
if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianFilterOutDa te)>0) { if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianFilterOutDa te)>0) {
debuga(_("dansguardian_ignore_date is deprecated and has been rep laced by dansguardian_filter_out_date that does the action implied by its name a s opposed to dansguardian_ignore_date. Please update your configuration file.\n" )); debuga(__FILE__,__LINE__,_("dansguardian_ignore_date is deprecate d and has been replaced by dansguardian_filter_out_date that does the action imp lied by its name as opposed to dansguardian_ignore_date. Please update your conf iguration file.\n"));
DansguardianFilterOutDate=!DansguardianFilterOutDate; DansguardianFilterOutDate=!DansguardianFilterOutDate;
return; return;
} }
if (getparam_string("ulimit",buf,Ulimit,sizeof(Ulimit))>0) return; if (getparam_string("ulimit",buf,Ulimit,sizeof(Ulimit))>0) return;
if (getparam_list("ntlm_user_format",SET_LIST(ntml_userformat_values),buf ,&NtlmUserFormat)>0) return; if (getparam_list("ntlm_user_format",SET_LIST(ntml_userformat_values),buf ,&NtlmUserFormat)>0) return;
if (getparam_string("strip_user_suffix",buf,StripUserSuffix,sizeof(StripU
serSuffix))>0) {
StripSuffixLen=strlen(StripUserSuffix);
return;
}
if (getparam_string("realtime_types",buf,RealtimeTypes,sizeof(RealtimeTyp es))>0) return; if (getparam_string("realtime_types",buf,RealtimeTypes,sizeof(RealtimeTyp es))>0) return;
if (getparam_list("realtime_unauthenticated_records",SET_LIST(realtime_un auth_values),buf,&RealtimeUnauthRec)>0) return; if (getparam_list("realtime_unauthenticated_records",SET_LIST(realtime_un auth_values),buf,&RealtimeUnauthRec)>0) return;
if (getparam_int("realtime_refresh_time",buf,&realtime_refresh)>0) return ; if (getparam_int("realtime_refresh_time",buf,&realtime_refresh)>0) return ;
if (getparam_int("realtime_access_log_lines",buf,&realtime_access_log_lin es)>0) return; if (getparam_int("realtime_access_log_lines",buf,&realtime_access_log_lin es)>0) return;
if (getparam_string("LDAPHost",buf,LDAPHost,sizeof(LDAPHost))>0) return; if (getparam_string("LDAPHost",buf,LDAPHost,sizeof(LDAPHost))>0) return;
skipping to change at line 747 skipping to change at line 941
if (getparam_string("LDAPBindDN",buf,LDAPBindDN,sizeof(LDAPBindDN))>0) re turn; if (getparam_string("LDAPBindDN",buf,LDAPBindDN,sizeof(LDAPBindDN))>0) re turn;
if (getparam_string("LDAPBindPW",buf,LDAPBindPW,sizeof(LDAPBindPW))>0) re turn; if (getparam_string("LDAPBindPW",buf,LDAPBindPW,sizeof(LDAPBindPW))>0) re turn;
if (getparam_string("LDAPBaseSearch",buf,LDAPBaseSearch,sizeof(LDAPBaseSe arch))>0) return; if (getparam_string("LDAPBaseSearch",buf,LDAPBaseSearch,sizeof(LDAPBaseSe arch))>0) return;
if (getparam_string("LDAPFilterSearch",buf,LDAPFilterSearch,sizeof(LDAPFi lterSearch))>0) return; if (getparam_string("LDAPFilterSearch",buf,LDAPFilterSearch,sizeof(LDAPFi lterSearch))>0) return;
if (getparam_string("LDAPTargetAttr",buf,LDAPTargetAttr,sizeof(LDAPTarget Attr))>0) return; if (getparam_string("LDAPTargetAttr",buf,LDAPTargetAttr,sizeof(LDAPTarget Attr))>0) return;
if (getparam_string("LDAPNativeCharset",buf,LDAPNativeCharset,sizeof(LDAP
NativeCharset))>0) return;
if (getparam_string("graph_font",buf,GraphFont,sizeof(GraphFont))>0) retu rn; if (getparam_string("graph_font",buf,GraphFont,sizeof(GraphFont))>0) retu rn;
if (getparam_string("sorttable",buf,SortTableJs,sizeof(SortTableJs))>0) r eturn; if (getparam_string("sorttable",buf,SortTableJs,sizeof(SortTableJs))>0) r eturn;
if (getparam_string("hostalias",buf,HostAliasFile,sizeof(HostAliasFile))> 0) return; if (getparam_string("hostalias",buf,HostAliasFile,sizeof(HostAliasFile))> 0) return;
if (getparam_string("useralias",buf,UserAliasFile,sizeof(UserAliasFile))>
0) return;
if (getparam_bool("keep_temp_log",buf,&KeepTempLog)>0) return; if (getparam_bool("keep_temp_log",buf,&KeepTempLog)>0) return;
if(strstr(buf,"squid24") != 0) { if (getparam_int("max_successive_log_errors",buf,&NumLogSuccessiveErrors)
>0) return;
if (getparam_int("max_total_log_errors",buf,&NumLogTotalErrors)>0) return
;
if (strstr(buf,"squid24") != 0) {
squid24=true; squid24=true;
return; return;
} }
if(strstr(buf,"byte_cost") != 0) { if (strstr(buf,"byte_cost") != 0) {
getword_start(&gwarea,buf); getword_start(&gwarea,buf);
if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
debuga(_("The \"byte_cost\" parameter of the configuratio n file is invalid\n")); debuga(__FILE__,__LINE__,_("The \"byte_cost\" parameter o f the configuration file is invalid\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
cost=atol(gwarea.current); cost=atol(gwarea.current);
if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
debuga(_("The \"byte_cost\" parameter of the configuratio n file is invalid\n")); debuga(__FILE__,__LINE__,_("The \"byte_cost\" parameter o f the configuration file is invalid\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
nocost=my_atoll(gwarea.current); nocost=my_atoll(gwarea.current);
return; return;
} }
if (getparam_string("image_dir",buf,ImageDir,sizeof(ImageDir))>0) return;
printf(_("SARG: Unknown option %s\n"),buf); printf(_("SARG: Unknown option %s\n"),buf);
} }
void getconf(void) void getconf(const char *File)
{ {
FILE *fp_in; FILE *fp_in;
char buf[MAXLEN]; char buf[MAXLEN];
char IncludeFile[MAXLEN];
if(debug) IncludeLevel++;
debuga(_("Loading configuration from %s\n"),ConfigFile); if (debug) {
if (IncludeLevel<=1)
debuga(__FILE__,__LINE__,_("Loading configuration file \"
%s\"\n"),File);
else
debuga(__FILE__,__LINE__,_("Including configuration file
\"%s\"\n"),File);
}
// stop if include files are producing a loop
if (IncludeLevel>5) {
debuga(__FILE__,__LINE__,_("Too many nested configuration files i
ncluded in \"%s\""),ConfigFile);
exit(EXIT_FAILURE);
}
if ((fp_in = fopen(ConfigFile, "r")) == NULL) { if ((fp_in = fopen(File, "r")) == NULL) {
debugapos("getconf",_("Cannot open file \"%s\": %s\n"),ConfigFile debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),File,
,strerror(errno)); strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
while (fgets(buf, sizeof(buf), fp_in) != NULL) { while (fgets(buf, sizeof(buf), fp_in) != NULL) {
fixendofline(buf); fixendofline(buf);
if(debugm) if (getparam_string("include",buf,IncludeFile,sizeof(IncludeFile)
printf("SYSCONFDIR %s\n",buf); )>0) {
getconf(IncludeFile);
continue;
}
parmtest(buf); if (debugz>=LogLevel_Data)
printf("SYSCONFDIR %s\n",buf);
parmtest(buf,File);
} }
fclose(fp_in); if (fclose(fp_in)==EOF) {
return; debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),File,str
error(errno));
exit(EXIT_FAILURE);
}
IncludeLevel--;
} }
 End of changes. 60 change blocks. 
68 lines changed or deleted 309 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)