]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - getconf.c
Rename configure.in as configure.ac
[thirdparty/sarg.git] / getconf.c
index 67fdf389f16647463b01ecf831ea4b1875084ff6..8454e5d549b82e6dd4ec50d4de02ee6bffda3579 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -1,6 +1,6 @@
 /*
  * SARG Squid Analysis Report Generator      http://sarg.sourceforge.net
- *                                                            1998, 2013
+ *                                                            1998, 2015
  *
  * SARG donations:
  *      please look at http://sarg.sourceforge.net/donations.php
@@ -228,7 +228,7 @@ static int getparam_string(const char *param,char *buf,char *value,int value_siz
        while (*buf && (unsigned char)*buf<=' ') buf++;
 
        if (strlen(buf)>=value_size) {
-               debuga(_("The string value of parameter \"%s\" is too long\n"),param);
+               debuga(__FILE__,__LINE__,_("The string value of parameter \"%s\" is too long\n"),param);
                exit(EXIT_FAILURE);
        }
        strcpy(value,buf);
@@ -273,7 +273,7 @@ static int getparam_quoted(const char *param,char *buf,char *value,int value_siz
        while (*buf && (unsigned char)*buf<=' ') 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);
        }
        buf++;
@@ -285,7 +285,7 @@ static int getparam_quoted(const char *param,char *buf,char *value,int value_siz
        value[i]='\0';
 
        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);
        }
        fixnone(value);
@@ -306,11 +306,11 @@ static int getparam_2words(const char *param,char *buf,char *word1,int word1_siz
        for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++)
                word1[i]=*buf++;
        if (i>=word1_size) {
-               debuga(_("The first word of parameter \"%s\" is more than %d bytes 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);
        }
        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);
        }
        word1[i]=0;
@@ -320,7 +320,7 @@ static int getparam_2words(const char *param,char *buf,char *word1,int word1_siz
        for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++)
                word2[i]=*buf++;
        if (i>=word2_size) {
-               debuga(_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1);
+               debuga(__FILE__,__LINE__,_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1);
                exit(EXIT_FAILURE);
        }
        word2[i]=0;
@@ -343,7 +343,7 @@ static int getparam_int(const char *param,char *buf,int *value)
 
        next=0;
        if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ') {
-               debuga(_("The integer value of parameter \"%s\" is invalid\n"),param);
+               debuga(__FILE__,__LINE__,_("The integer value of parameter \"%s\" is invalid\n"),param);
                exit(EXIT_FAILURE);
        }
        return(1);
@@ -395,11 +395,11 @@ static int getparam_list(const char *param,struct param_list *options,int noptio
                }
                for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
                if (i>=noptions) {
-                       debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param);
+                       debuga(__FILE__,__LINE__,_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param);
                        exit(EXIT_FAILURE);
                }
                if ((*value & options[i].exclude)!=0) {
-                       debuga(_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param);
+                       debuga(__FILE__,__LINE__,_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param);
                        exit(EXIT_FAILURE);
                }
                *value|=options[i].value;
@@ -430,7 +430,7 @@ static int getparam_sort(const char *param,struct sort_list *options,int noption
        }
        for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
        if (i>=noptions) {
-               debuga(_("Unknown sort criterion \"%s\" for parameter \"%s\"\n"),buf,param);
+               debuga(__FILE__,__LINE__,_("Unknown sort criterion \"%s\" for parameter \"%s\"\n"),buf,param);
                exit(EXIT_FAILURE);
        }
        *value=options[i].value;
@@ -445,7 +445,7 @@ static int getparam_sort(const char *param,struct sort_list *options,int noption
                if (strcasecmp(order,"reverse")==0 || strcasecmp(order,"D")==0) {
                        *value|=SORT_REVERSE;
                } 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);
                }
        }
@@ -471,7 +471,7 @@ static int getparam_select(const char *param,struct select_list *options,int nop
        *buf='\0';
        for (i=0 ; i<noptions && strcasecmp(str,options[i].name) ; i++);
        if (i>=noptions) {
-               debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),str,param);
+               debuga(__FILE__,__LINE__,_("Unknown value \"%s\" for parameter \"%s\"\n"),str,param);
                exit(EXIT_FAILURE);
        }
        *value=options[i].value;
@@ -512,7 +512,7 @@ static int getparam_userlimit(const char *param,char *buf)
        do {
                while (*buf && (unsigned char)*buf>' ') buf++;
                if (*buf!=' ') {
-                       debuga(_("Missing limit in per_user_limit\n"));
+                       debuga(__FILE__,__LINE__,_("Missing limit in per_user_limit\n"));
                        exit(EXIT_FAILURE);
                }
                file_end=buf;
@@ -538,13 +538,13 @@ static int getparam_userlimit(const char *param,char *buf)
                                break;
                        }
                if (i<0) {
-                       debuga(_("Invalid output type in per_user_limit\n"));
+                       debuga(__FILE__,__LINE__,_("Invalid output type in per_user_limit\n"));
                        exit(EXIT_FAILURE);
                }
        }
 
        if (PerUserLimitsNumber>=MAX_USER_LIMITS) {
-               debuga(_("Too many per_user_limit\n"));
+               debuga(__FILE__,__LINE__,_("Too many per_user_limit\n"));
                exit(EXIT_FAILURE);
        }
        *file_end='\0';
@@ -636,7 +636,7 @@ static void parmtest(char *buf)
        if (is_param("date_format",buf)) {
                getword_start(&gwarea,buf);
                if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
-                       debuga(_("Maybe you have a broken record or garbage in \"date_format\" parameter\n"));
+                       debuga(__FILE__,__LINE__,_("Invalid record in \"date_format\" parameter\n"));
                        exit(EXIT_FAILURE);
                }
                DateFormat=gwarea.current[0];
@@ -645,7 +645,7 @@ static void parmtest(char *buf)
 
        if (is_param("hours",buf)) {
                if( getnumlist( buf, &hours, 24, 24 ) ) {
-                       debuga(_("Error: Invalid syntax in hours tag!\n"));
+                       debuga(__FILE__,__LINE__,_("Error: Invalid syntax in hours tag!\n"));
                        exit( 1 );
                }
                return;
@@ -653,7 +653,7 @@ static void parmtest(char *buf)
 
        if (is_param("weekdays",buf)) {
                if( getnumlist( buf, &weekdays, 7, 7 ) ) {
-                       debuga(_("Error: Invalid syntax in weekdays tag!\n"));
+                       debuga(__FILE__,__LINE__,_("Error: Invalid syntax in weekdays tag!\n"));
                        exit( 1 );
                }
                return;
@@ -669,7 +669,7 @@ static void parmtest(char *buf)
                        if (!AccessLog)
                                AccessLog=FileList_Create();
                        if (!FileList_AddFile(AccessLog,FileName)) {
-                               debuga(_("Not enough memory to store the input log file names\n"));
+                               debuga(__FILE__,__LINE__,_("Not enough memory to store the input log file names\n"));
                                exit(EXIT_FAILURE);
                        }
                }
@@ -679,7 +679,7 @@ static void parmtest(char *buf)
        if (is_param("redirector_log",buf)>0) {
                if (RedirectorLogFromCmdLine==0) {
                        if (NRedirectorLogs>=MAX_REDIRECTOR_LOGS) {
-                               debuga(_("Too many redirector log files in configuration file\n"));
+                               debuga(__FILE__,__LINE__,_("Too many redirector log files in configuration file\n"));
                                exit(EXIT_FAILURE);
                        }
                        getparam_string("redirector_log",buf,RedirectorLogs[NRedirectorLogs],MAX_REDIRECTOR_FILELEN);
@@ -827,14 +827,14 @@ static void parmtest(char *buf)
 
                if (is_absolute(wbuf)) {
                        if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) {
-                               debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
+                               debuga(__FILE__,__LINE__,_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
                                exit(EXIT_FAILURE);
                        }
                        safe_strcpy(AuthUserTemplateFile,wbuf,sizeof(AuthUserTemplateFile));
                } else {
                        safe_strcpy(dir,ConfigFile,sizeof(dir));
                        if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplateFile),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) {
-                               debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
+                               debuga(__FILE__,__LINE__,_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
                                exit(EXIT_FAILURE);
                        }
                }
@@ -852,7 +852,7 @@ static void parmtest(char *buf)
        if (getparam_bool("graphs",buf,&Graphs)>0) {
 #ifndef HAVE_GD
                if (Graphs)
-                       debugaz(_("No graphs available as sarg was not compiled with libgd. Set \"graphs\" to \"no\" in %s to disable this warning\n"),
+                       debugaz(__FILE__,__LINE__,_("No graphs available as sarg was not compiled with libgd. Set \"graphs\" to \"no\" in %s to disable this warning\n"),
                                ConfigFile);
 #endif
                return;
@@ -862,7 +862,7 @@ static void parmtest(char *buf)
 
        if (getparam_string("redirector_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) return;
        if (getparam_string("squidguard_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) {
-               debuga(_("squidguard_log_format is deprecated and has been replaced by redirector_log_format. Please update your configuration file.\n"));
+               debuga(__FILE__,__LINE__,_("squidguard_log_format is deprecated and has been replaced by redirector_log_format. Please update your configuration file.\n"));
                return;
        }
 
@@ -871,19 +871,19 @@ static void parmtest(char *buf)
                /*
                Due to an old bug in sarg before version 2.3, the option was having the opposite action than implied by the name.
                */
-               debuga(_("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 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 configuration file.\n"));
                RedirectorFilterOutDate=!RedirectorFilterOutDate;
                return;
        }
        if (getparam_bool("squidguard_ignore_date",buf,&RedirectorFilterOutDate)>0) {
-               debuga(_("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 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 configuration file.\n"));
                RedirectorFilterOutDate=!RedirectorFilterOutDate;
                return;
        }
 
        if (getparam_bool("dansguardian_filter_out_date",buf,&DansguardianFilterOutDate)>0) return;
        if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianFilterOutDate)>0) {
-               debuga(_("dansguardian_ignore_date is deprecated and has been replaced by dansguardian_filter_out_date that does the action implied by its name as opposed to dansguardian_ignore_date. Please update your configuration file.\n"));
+               debuga(__FILE__,__LINE__,_("dansguardian_ignore_date is deprecated and has been replaced by dansguardian_filter_out_date that does the action implied by its name as opposed to dansguardian_ignore_date. Please update your configuration file.\n"));
                DansguardianFilterOutDate=!DansguardianFilterOutDate;
                return;
        }
@@ -940,12 +940,12 @@ static void parmtest(char *buf)
        if(strstr(buf,"byte_cost") != 0) {
                getword_start(&gwarea,buf);
                if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
-                       debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
+                       debuga(__FILE__,__LINE__,_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
                        exit(EXIT_FAILURE);
                }
                cost=atol(gwarea.current);
                if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
-                       debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
+                       debuga(__FILE__,__LINE__,_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
                        exit(EXIT_FAILURE);
                }
                nocost=my_atoll(gwarea.current);
@@ -963,10 +963,10 @@ void getconf(void)
        char buf[MAXLEN];
 
        if(debug)
-               debuga(_("Loading configuration from %s\n"),ConfigFile);
+               debuga(__FILE__,__LINE__,_("Loading configuration from \"%s\"\n"),ConfigFile);
 
        if ((fp_in = fopen(ConfigFile, "r")) == NULL) {
-               debuga(_("Cannot open file \"%s\": %s\n"),ConfigFile,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),ConfigFile,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -981,7 +981,7 @@ void getconf(void)
        }
 
        if (fclose(fp_in)==EOF) {
-               debuga(_("Read error in \"%s\": %s\n"),ConfigFile,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),ConfigFile,strerror(errno));
                exit(EXIT_FAILURE);
        }
        return;