]> git.ipfire.org Git - thirdparty/sarg.git/blame - getconf.c
Exclude the configuration script from svn as it is the result of a build process...
[thirdparty/sarg.git] / getconf.c
CommitLineData
25697a35 1/*
c37945ed 2 * AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
dfc336d1 3 * 1998, 2010
94ff9470 4 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
25697a35
GS
5 *
6 * SARG donations:
7 * please look at http://sarg.sourceforge.net/donations.php
8 * ---------------------------------------------------------------------
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
23 *
24 */
25
26#include "include/conf.h"
5f3cfd1d 27#include "include/defs.h"
25697a35 28
085c1e1f
FM
29#define SET_LIST(list) list,sizeof(list)/sizeof(list[0])
30
25697a35
GS
31extern numlist hours, weekdays;
32
085c1e1f
FM
33struct param_list
34{
35 //! The name of the value of the parameter.
36 const char *name;
37 //! The bit to set if the value is found.
38 unsigned long int value;
39 //! The value is invalid if any bit of this mask is set in the parameter.
40 unsigned long int exclude;
41};
42
43struct param_list report_type_values[]=
44{
45 {"users_sites",REPORT_TYPE_USERS_SITES,0},
46 {"topusers",REPORT_TYPE_TOPUSERS,0},
47 {"topsites",REPORT_TYPE_TOPSITES,0},
48 {"sites_users",REPORT_TYPE_SITES_USERS,0},
49 {"date_time",REPORT_TYPE_DATE_TIME,0},
50 {"denied",REPORT_TYPE_DENIED,0},
51 {"auth_failures",REPORT_TYPE_AUTH_FAILURES,0},
52 {"site_user_time_date",REPORT_TYPE_SITE_USER_TIME_DATE,0},
53 {"downloads",REPORT_TYPE_DOWNLOADS,0},
54};
55
56struct param_list data_field_values[]=
57{
58 {"user",DATA_FIELD_USER,0},
59 {"date",DATA_FIELD_DATE,0},
60 {"time",DATA_FIELD_TIME,0},
61 {"url",DATA_FIELD_URL,0},
62 {"connect",DATA_FIELD_CONNECT,0},
63 {"bytes",DATA_FIELD_BYTES,0},
64 {"in_cache",DATA_FIELD_IN_CACHE,0},
65 {"out_cache",DATA_FIELD_OUT_CACHE,0},
66 {"elapsed",DATA_FIELD_ELAPSED,0},
67};
68
69struct param_list topuserfields_values[]=
70{
71 {"NUM",TOPUSERFIELDS_NUM,0},
72 {"DATE_TIME",TOPUSERFIELDS_DATE_TIME,0},
73 {"USERID",TOPUSERFIELDS_USERID,0},
74 {"CONNECT",TOPUSERFIELDS_CONNECT,0},
75 {"BYTES",TOPUSERFIELDS_BYTES,0},
76 {"%BYTES",TOPUSERFIELDS_SETYB,0},
77 {"SETYB",TOPUSERFIELDS_SETYB,0},
78 {"IN-CACHE-OUT",TOPUSERFIELDS_IN_CACHE_OUT,0},
79 {"USED_TIME",TOPUSERFIELDS_USED_TIME,0},
80 {"MILISEC",TOPUSERFIELDS_MILISEC,0},
81 {"%TIME",TOPUSERFIELDS_PTIME,0},
82 {"TOTAL",TOPUSERFIELDS_TOTAL,0},
83 {"AVERAGE",TOPUSERFIELDS_AVERAGE,0},
84};
85
86struct param_list userreportfields_values[]=
87{
88 {"CONNECT",USERREPORTFIELDS_CONNECT,0},
89 {"BYTES",USERREPORTFIELDS_BYTES,0},
90 {"%BYTES",USERREPORTFIELDS_SETYB,0},
91 {"SETYB",USERREPORTFIELDS_SETYB,0},
92 {"IN-CACHE-OUT",USERREPORTFIELDS_IN_CACHE_OUT,0},
93 {"USED_TIME",USERREPORTFIELDS_USED_TIME,0},
94 {"MILISEC",USERREPORTFIELDS_MILISEC,0},
95 {"%TIME",USERREPORTFIELDS_PTIME,0},
96 {"TOTAL",USERREPORTFIELDS_TOTAL,0},
97 {"AVERAGE",USERREPORTFIELDS_AVERAGE,0},
98};
99
6e792ade 100static int is_param(const char *param,const char *buf)
0a4e18e1
FM
101{
102 int plen;
103
104 plen=strlen(param);
105 if (strncmp(buf,param,plen) != 0) return(0);
106 buf+=plen;
107 if ((unsigned char)*buf>' ') return(0);
108 return(1);
109}
110
4af2f8ff
FM
111static int getparam_string(const char *param,char *buf,char *value,int value_size)
112{
113 int plen;
114
115 plen=strlen(param);
116 if (strncmp(buf,param,plen) != 0) return(0);
117 buf+=plen;
118 if ((unsigned char)*buf>' ') return(0);
119 while (*buf && (unsigned char)*buf<=' ') buf++;
120
121 if (strlen(buf)>=value_size) {
122 printf("SARG: Maybe you have a broken record or garbage in %s parameter.\n",param);
123 exit(1);
124 }
125 strcpy(value,buf);
126 fixnone(value);
127 return(1);
128}
25697a35 129
4af2f8ff 130static int getparam_quoted(const char *param,char *buf,char *value,int value_size)
25697a35 131{
4af2f8ff
FM
132 int plen;
133 int i;
25697a35 134
4af2f8ff
FM
135 plen=strlen(param);
136 if (strncmp(buf,param,plen) != 0) return(0);
137 buf+=plen;
138 if ((unsigned char)*buf>' ') return(0);
139 while (*buf && (unsigned char)*buf<=' ') buf++;
25697a35 140
4af2f8ff 141 if (*buf != '\"') {
f29e90f8 142 printf("SARG: %s %s.\n",text[139],param);
4af2f8ff
FM
143 exit(1);
144 }
145 buf++;
25697a35 146
4af2f8ff
FM
147 value_size--;
148 for (i=0 ; i<value_size && *buf && *buf!='\"' ; i++) {
149 value[i]=*buf++;
150 }
151 value[i]='\0';
25697a35 152
4af2f8ff
FM
153 if (*buf != '\"') {
154 printf("SARG: Missing double quote after parameter %s or value is more than %d bytes long.\n",param,value_size);
155 exit(1);
156 }
157 fixnone(value);
158 return(1);
159}
25697a35 160
4af2f8ff
FM
161static int getparam_2words(const char *param,char *buf,char *word1,int word1_size,char *word2,int word2_size)
162{
163 int plen;
164 int i;
165
166 plen=strlen(param);
167 if (strncmp(buf,param,plen) != 0) return(0);
168 buf+=plen;
169 if ((unsigned char)*buf>' ') return(0);
170 while (*buf && (unsigned char)*buf<=' ') buf++;
171
172 for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++)
173 word1[i]=*buf++;
174 if (i>=word1_size) {
175 printf("SARG: The first word of parameter %s is more than %d bytes long.\n",param,word1_size-1);
176 exit(1);
177 }
178 if (*buf!=' ') {
179 printf("SARG: Missing second word for parameter %s.\n",param);
180 exit(1);
181 }
182 word1[i]=0;
25697a35 183
4af2f8ff 184 while (*buf && (unsigned char)*buf<=' ') buf++;
25697a35 185
4af2f8ff
FM
186 for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++)
187 word2[i]=*buf++;
188 if (i>=word2_size) {
189 printf("SARG: The second word of parameter %s is more than %d bytes long.\n",param,word2_size-1);
190 exit(1);
191 }
192 word2[i]=0;
25697a35 193
4af2f8ff
FM
194 fixnone(word1);
195 fixnone(word2);
196 return(1);
197}
25697a35 198
4af2f8ff
FM
199static int getparam_int(const char *param,char *buf,int *value)
200{
201 int plen;
202 int next;
203
204 plen=strlen(param);
205 if (strncmp(buf,param,plen) != 0) return(0);
206 buf+=plen;
207 if ((unsigned char)*buf>' ') return(0);
208 while (*buf && (unsigned char)*buf<=' ') buf++;
209
210 next=0;
211 if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ') {
212 printf("SARG: Maybe you have a broken record or garbage in %s parameter.\n",param);
213 exit(1);
214 }
215 return(1);
216}
25697a35 217
246c8489
FM
218static int getparam_bool(const char *param,char *buf,int *value)
219{
220 int plen;
246c8489 221 int i;
f6ff06fa 222 const char *bool_str="yes,true,on,1";
246c8489
FM
223
224 plen=strlen(param);
225 if (strncmp(buf,param,plen) != 0) return(0);
226 buf+=plen;
227 if ((unsigned char)*buf>' ') return(0);
228 while (*buf && (unsigned char)*buf<=' ') buf++;
229
230 *value=0;
f6ff06fa
FM
231 for ( ; *bool_str ; bool_str+=i) {
232 for (i=0 ; bool_str[i] && bool_str[i]!=',' ; i++);
233 if (strncasecmp(bool_str,buf,i)==0) {
246c8489
FM
234 *value=1;
235 break;
236 }
f6ff06fa 237 if (bool_str[i]==',') i++;
246c8489
FM
238 }
239 return(1);
240}
241
085c1e1f
FM
242static int getparam_list(const char *param,struct param_list *options,int noptions,char *buf,unsigned long int *value)
243{
244 int plen;
245 char *str;
246 int i;
247
248 plen=strlen(param);
249 if (strncmp(buf,param,plen) != 0) return(0);
250 buf+=plen;
251 if ((unsigned char)*buf>' ') return(0);
252 while (*buf && (unsigned char)*buf<=' ') buf++;
253
254 *value=0UL;
255 while (*buf) {
256 str=buf;
257 while (*str && (unsigned char)*str>' ' && *str!=';') str++;
258 if (*str) {
259 *str++='\0';
260 while (*str && ((unsigned char)*str<=' ' || *str==';')) str++;
261 }
262 for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
263 if (i>=noptions) {
264 fprintf(stderr,"SARG: Unknown value %s for parameter %s\n",buf,param);
265 exit(1);
266 }
267 if ((*value & options[i].exclude)!=0) {
268 fprintf(stderr,"SARG: Value %s conflicts with other selected values of parameter %s\n",buf,param);
269 exit(1);
270 }
271 *value|=options[i].value;
272 buf=str;
273 }
274 return(1);
275}
276
4af2f8ff
FM
277static void parmtest(char *buf)
278{
279 char wbuf[50];
9c7c6346 280 struct getwordstruct gwarea;
25697a35 281
4af2f8ff 282 while (*buf && (unsigned char)*buf<=' ') buf++;
25697a35 283
4af2f8ff
FM
284 if(*buf == '#' || *buf == '\0')
285 return;
25697a35 286
4af2f8ff
FM
287 if(debugz)
288 printf("SARG: TAG: %s\n",buf);
25697a35 289
4af2f8ff 290 if (getparam_string("background_color",buf,BgColor,sizeof(BgColor))>0) return;
25697a35 291
4af2f8ff 292 if (getparam_string("text_color",buf,TxColor,sizeof(TxColor))>0) return;
25697a35 293
4af2f8ff 294 if (getparam_string("text_bgcolor",buf,TxBgColor,sizeof(TxBgColor))>0) return;
25697a35 295
4af2f8ff 296 if (getparam_string("title_color",buf,TiColor,sizeof(TiColor))>0) return;
25697a35 297
4af2f8ff 298 if (getparam_string("logo_image",buf,LogoImage,sizeof(LogoImage))>0) return;
25697a35 299
4af2f8ff 300 if (getparam_quoted("logo_text",buf,LogoText,sizeof(LogoText))>0) return;
25697a35 301
4af2f8ff 302 if (getparam_string("logo_text_color",buf,LogoTextColor,sizeof(LogoTextColor))>0) return;
25697a35 303
4af2f8ff 304 if (getparam_string("background_image",buf,BgImage,sizeof(BgImage))>0) return;
25697a35 305
e6414a9d 306 if (getparam_bool("show_sarg_info",buf,&ShowSargInfo)>0) return;
25697a35 307
e6414a9d 308 if (getparam_bool("show_sarg_logo",buf,&ShowSargLogo)>0) return;
25697a35 309
4af2f8ff 310 if (getparam_string("font_face",buf,FontFace,sizeof(FontFace))>0) return;
25697a35 311
4af2f8ff 312 if (getparam_string("header_color",buf,HeaderColor,sizeof(HeaderColor))>0) return;
25697a35 313
4af2f8ff 314 if (getparam_string("header_bgcolor",buf,HeaderBgColor,sizeof(HeaderBgColor))>0) return;
25697a35 315
4af2f8ff 316 if (getparam_string("font_size",buf,FontSize,sizeof(FontSize))>0) return;
25697a35 317
4af2f8ff 318 if (getparam_string("header_font_size",buf,HeaderFontSize,sizeof(HeaderFontSize))>0) return;
25697a35 319
4af2f8ff 320 if (getparam_string("title_font_size",buf,TitleFontSize,sizeof(TitleFontSize))>0) return;
25697a35 321
4af2f8ff 322 if (getparam_2words("image_size",buf,Width,sizeof(Width),Height,sizeof(Height))>0) return;
25697a35 323
4af2f8ff 324 if (getparam_quoted("title",buf,Title,sizeof(Title))>0) return;
25697a35 325
246c8489 326 if (getparam_bool("resolve_ip",buf,&Ip2Name)>0) return;
25697a35 327
246c8489 328 if (getparam_bool("user_ip",buf,&UserIp)>0) return;
4af2f8ff
FM
329
330 if (getparam_string("max_elapsed",buf,MaxElapsed,sizeof(MaxElapsed))>0) return;
25697a35 331
e6414a9d 332 if (is_param("date_format",buf)) {
9c7c6346
FM
333 getword_start(&gwarea,buf);
334 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
4af2f8ff
FM
335 printf("SARG: Maybe you have a broken record or garbage in date_format parameter.\n");
336 exit(1);
25697a35 337 }
9c7c6346 338 strncpy(DateFormat,gwarea.current,1);
4af2f8ff
FM
339 fixnone(DateFormat);
340 return;
341 }
25697a35 342
e6414a9d 343 if (is_param("hours",buf)) {
4af2f8ff
FM
344 if( getnumlist( buf, &hours, 24, 24 ) ) {
345 fprintf( stderr, "Error: Invalid syntax in hours tag!\n" );
346 exit( 1 );
25697a35 347 }
4af2f8ff 348 }
25697a35 349
e6414a9d 350 if (is_param("weekdays",buf)) {
4af2f8ff
FM
351 if( getnumlist( buf, &weekdays, 7, 7 ) ) {
352 fprintf( stderr, "Error: Invalid syntax in weekdays tag!\n" );
353 exit( 1 );
25697a35 354 }
4af2f8ff 355 }
25697a35 356
4af2f8ff 357 if (getparam_2words("topuser_sort_field",buf,TopuserSortField,sizeof(TopuserSortField),TopuserSortOrder,sizeof(TopuserSortOrder))>0) return;
25697a35 358
4af2f8ff 359 if (getparam_2words("user_sort_field",buf,UserSortField,sizeof(UserSortField),UserSortOrder,sizeof(UserSortOrder))>0) return;
25697a35 360
6e792ade 361 if (is_param("access_log",buf)>0) {
0a4e18e1
FM
362 if (AccessLogFromCmdLine==0) {
363 if (NAccessLog>=MAXLOGS) {
364 fprintf(stderr,"SARG: Too many log files.\n");
365 exit(1);
366 }
367 getparam_string("access_log",buf,AccessLog[NAccessLog],MAXLEN);
368 NAccessLog++;
369 }
370 return;
371 }
25697a35 372
4af2f8ff 373 if (getparam_string("useragent_log",buf,UserAgentLog,sizeof(UserAgentLog))>0) return;
25697a35 374
4af2f8ff 375 if (getparam_string("exclude_hosts",buf,ExcludeHosts,sizeof(ExcludeHosts))>0) return;
25697a35 376
4af2f8ff 377 if (getparam_string("exclude_codes",buf,ExcludeCodes,sizeof(ExcludeCodes))>0) return;
25697a35 378
4af2f8ff 379 if (getparam_string("exclude_users",buf,ExcludeUsers,sizeof(ExcludeUsers))>0) return;
25697a35 380
4af2f8ff 381 if (getparam_string("password",buf,PasswdFile,sizeof(PasswdFile))>0) return;
25697a35 382
4af2f8ff 383 if (getparam_string("temporary_dir",buf,TempDir,sizeof(TempDir))>0) return;
25697a35 384
085c1e1f 385 if (getparam_list("report_type",SET_LIST(report_type_values),buf,&ReportType)>0) return;
25697a35 386
4af2f8ff 387 if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) return;
25697a35 388
4af2f8ff 389 if (getparam_string("output_email",buf,OutputEmail,sizeof(OutputEmail))>0) return;
25697a35 390
e6414a9d
FM
391 if (getparam_2words("per_user_limit",buf,PerUserLimitFile,sizeof(PerUserLimitFile),wbuf,sizeof(wbuf))>0) {
392 PerUserLimit=atoi(wbuf);
393 return;
394 }
25697a35 395
0511cf2d 396 if (getparam_int("lastlog",buf,&LastLog)>0) return;
25697a35 397
e6414a9d 398 if (getparam_bool("remove_temp_files",buf,&RemoveTempFiles)>0) return;
25697a35 399
4af2f8ff 400 if (getparam_string("replace_index",buf,ReplaceIndex,sizeof(ReplaceIndex))>0) return;
25697a35 401
4af2f8ff 402 if (getparam_string("index_tree",buf,IndexTree,sizeof(IndexTree))>0) return;
25697a35 403
4af2f8ff 404 if (getparam_string("index",buf,Index,sizeof(Index))>0) return;
25697a35 405
e6414a9d 406 if (getparam_bool("overwrite_report",buf,&OverwriteReport)>0) return;
25697a35 407
4af2f8ff 408 if (getparam_string("records_without_userid",buf,RecordsWithoutUser,sizeof(RecordsWithoutUser))>0) return;
25697a35 409
e6414a9d 410 if (getparam_bool("use_comma",buf,&UseComma)>0) return;
25697a35 411
4af2f8ff 412 if (getparam_string("mail_utility",buf,MailUtility,sizeof(MailUtility))>0) return;
25697a35 413
4af2f8ff 414 if (getparam_string("topsites_num",buf,TopSitesNum,sizeof(TopSitesNum))>0) return;
25697a35 415
fb7c5f27 416 if (getparam_int("topuser_num",buf,&TopUsersNum)>0) return;
25697a35 417
4af2f8ff 418 if (getparam_string("usertab",buf,UserTabFile,sizeof(UserTabFile))>0) return;
25697a35 419
4af2f8ff 420 if (getparam_string("index_sort_order",buf,IndexSortOrder,sizeof(IndexSortOrder))>0) return;
25697a35 421
4af2f8ff 422 if (getparam_2words("topsites_sort_order",buf,TopsitesSortField,sizeof(TopsitesSortField),TopsitesSortType,sizeof(TopsitesSortType))>0) return;
25697a35 423
246c8489 424 if (getparam_bool("long_url",buf,&LongUrl)>0) return;
25697a35 425
4af2f8ff 426 if (getparam_string("language",buf,language,sizeof(language))>0) return;
d6e703cc 427
4af2f8ff 428 if (getparam_string("dansguardian_conf",buf,DansGuardianConf,sizeof(DansGuardianConf))>0) return;
25697a35 429
4af2f8ff 430 if (getparam_string("squidguard_conf",buf,SquidGuardConf,sizeof(SquidGuardConf))>0) return;
25697a35 431
4af2f8ff 432 if (getparam_string("date_time_by",buf,datetimeby,sizeof(datetimeby))>0) return;
25697a35 433
4af2f8ff
FM
434 if (getparam_string("charset",buf,CharSet,sizeof(CharSet))>0) {
435 ccharset(CharSet);
436 return;
437 }
25697a35 438
4af2f8ff 439 if (getparam_quoted("user_invalid_char",buf,UserInvalidChar,sizeof(UserInvalidChar))>0) return;
25697a35 440
4af2f8ff
FM
441 if (getparam_quoted("include_users",buf,IncludeUsers+1,sizeof(IncludeUsers)-2)>0) {
442 IncludeUsers[0]=':';
443 strcat(IncludeUsers,":");
444 return;
445 }
491b862f 446
4af2f8ff 447 if (getparam_quoted("exclude_string",buf,ExcludeString,sizeof(ExcludeString))>0) return;
25697a35 448
e6414a9d 449 if (getparam_bool("privacy",buf,&Privacy)>0) return;
25697a35 450
78015ea0 451 if (getparam_quoted("privacy_string",buf,PrivacyString,sizeof(PrivacyString))>0) return;
25697a35 452
4af2f8ff 453 if (getparam_string("privacy_string_color",buf,PrivacyStringColor,sizeof(PrivacyStringColor))>0) return;
25697a35 454
e6414a9d 455 if (getparam_bool("show_successful_message",buf,&SuccessfulMsg)>0) return;
25697a35 456
e6414a9d 457 if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) return;
25697a35 458
085c1e1f 459 if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&TopUserFields)>0) return;
25697a35 460
e6414a9d 461 if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersReport)>0) return;
25697a35 462
085c1e1f 463 if (getparam_list("user_report_fields",SET_LIST(userreportfields_values),buf,&UserReportFields)>0) return;
25697a35 464
4af2f8ff 465 if (getparam_string("datafile",buf,DataFile,sizeof(DataFile))>0) return;
25697a35 466
4af2f8ff 467 if (getparam_quoted("datafile_delimiter",buf,DataFileDelimiter,sizeof(DataFileDelimiter))>0) return;
25697a35 468
085c1e1f 469 if (getparam_list("datafile_fields",SET_LIST(data_field_values),buf,&DataFileFields)>0) return;
25697a35 470
4af2f8ff 471 if (getparam_string("datafile_url",buf,DataFileUrl,sizeof(DataFileUrl))>0) return;
25697a35 472
4af2f8ff 473 if (getparam_string("parsed_output_log",buf,ParsedOutputLog,sizeof(ParsedOutputLog))>0) return;
25697a35 474
4af2f8ff 475 if (getparam_string("parsed_output_log_compress",buf,ParsedOutputLogCompress,sizeof(ParsedOutputLogCompress))>0) return;
25697a35 476
4af2f8ff 477 if (getparam_string("displayed_values",buf,DisplayedValues,sizeof(DisplayedValues))>0) return;
25697a35 478
4af2f8ff 479 if (getparam_int("authfail_report_limit",buf,&AuthfailReportLimit)>0) return;
25697a35 480
4af2f8ff 481 if (getparam_int("denied_report_limit",buf,&DeniedReportLimit)>0) return;
25697a35 482
4af2f8ff 483 if (getparam_int("siteusers_report_limit",buf,&SiteUsersReportLimit)>0) return;
25697a35 484
4af2f8ff 485 if (getparam_int("dansguardian_report_limit",buf,&DansGuardianReportLimit)>0) return;
25697a35 486
4af2f8ff 487 if (getparam_int("squidguard_report_limit",buf,&SquidGuardReportLimit)>0) return;
25697a35 488
4af2f8ff 489 if (getparam_int("user_report_limit",buf,&UserReportLimit)>0) return;
491b862f 490
4af2f8ff 491 if (getparam_int("download_report_limit",buf,&DownloadReportLimit)>0) return;
491b862f 492
4af2f8ff 493 if (getparam_string("www_document_root",buf,wwwDocumentRoot,sizeof(wwwDocumentRoot))>0) return;
25697a35 494
4af2f8ff 495 if (getparam_string("block_it",buf,BlockIt,sizeof(BlockIt))>0) return;
491b862f 496
4af2f8ff 497 if (getparam_string("external_css_file",buf,ExternalCSSFile,sizeof(ExternalCSSFile))>0) return;
491b862f 498
e6414a9d 499 if (getparam_bool("user_authentication",buf,&UserAuthentication)>0) return;
491b862f 500
4af2f8ff 501 if (getparam_string("AuthUserFile",buf,AuthUserFile,sizeof(AuthUserFile))>0) return;
491b862f 502
4af2f8ff 503 if (getparam_string("AuthName",buf,AuthName,sizeof(AuthName))>0) return;
491b862f 504
4af2f8ff
FM
505 if (getparam_string("AuthType",buf,AuthType,sizeof(AuthType))>0) return;
506
507 if (getparam_string("Require",buf,Require,sizeof(Require))>0) return;
508
6e792ade
FM
509 if (is_param("download_suffix",buf)) {
510 char warea[MAXLEN];
511
512 getparam_quoted("download_suffix",buf,warea,sizeof(warea));
513 set_download_suffix(warea);
e6414a9d 514 return;
6e792ade 515 }
d6e703cc 516
e6414a9d 517 if (getparam_bool("graphs",buf,&Graphs)>0) return;
4af2f8ff
FM
518
519 if (getparam_string("graph_days_bytes_bar_color",buf,GraphDaysBytesBarColor,sizeof(GraphDaysBytesBarColor))>0) return;
520
521 if (getparam_string("squidguard_log_format",buf,SquidGuardLogFormat,sizeof(SquidGuardLogFormat))>0) return;
522
e6414a9d 523 if (getparam_bool("squidguard_ignore_date",buf,&SquidguardIgnoreDate)>0) return;
4af2f8ff 524
e6414a9d 525 if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianIgnoreDate)>0) return;
4af2f8ff
FM
526
527 if (getparam_string("ulimit",buf,Ulimit,sizeof(Ulimit))>0) return;
528
529 if (getparam_string("ntlm_user_format",buf,NtlmUserFormat,sizeof(NtlmUserFormat))>0) return;
530
531 if (getparam_string("realtime_types",buf,RealtimeTypes,sizeof(RealtimeTypes))>0) return;
532
533 if (getparam_string("realtime_unauthenticated_records",buf,RealtimeUnauthRec,sizeof(RealtimeUnauthRec))>0) return;
534
535 if (getparam_int("realtime_refresh_time",buf,&realtime_refresh)>0) return;
536
537 if (getparam_int("realtime_access_log_lines",buf,&realtime_access_log_lines)>0) return;
538
e3af0ae9
PO
539 if (getparam_string("LDAPHost",buf,LDAPHost,sizeof(LDAPHost))>0) return;
540
965c4a6f 541 if (getparam_int("LDAPPort",buf,&LDAPPort)>0) return;
e3af0ae9 542
965c4a6f 543 if (getparam_int("LDAPProtocolVersion",buf,&LDAPProtocolVersion)>0) return;
e3af0ae9
PO
544
545 if (getparam_string("LDAPBindDN",buf,LDAPBindDN,sizeof(LDAPBindDN))>0) return;
546
547 if (getparam_string("LDAPBindPW",buf,LDAPBindPW,sizeof(LDAPBindPW))>0) return;
548
549 if (getparam_string("LDAPBaseSearch",buf,LDAPBaseSearch,sizeof(LDAPBaseSearch))>0) return;
550
551 if (getparam_string("LDAPFilterSearch",buf,LDAPFilterSearch,sizeof(LDAPFilterSearch))>0) return;
552
553 if (getparam_string("LDAPTargetAttr",buf,LDAPTargetAttr,sizeof(LDAPTargetAttr))>0) return;
554
4af2f8ff
FM
555 if(strstr(buf,"squid24") != 0) {
556 squid24++;
557 return;
558 }
559
560 if(strstr(buf,"byte_cost") != 0) {
9c7c6346
FM
561 getword_start(&gwarea,buf);
562 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
4af2f8ff
FM
563 printf("SARG: Maybe you have a broken record or garbage in byte_cost parameter.\n");
564 exit(1);
565 }
9c7c6346
FM
566 cost=atol(gwarea.current);
567 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
4af2f8ff
FM
568 printf("SARG: Maybe you have a broken record or garbage in byte_cost parameter.\n");
569 exit(1);
491b862f 570 }
9c7c6346 571 nocost=my_atoll(gwarea.current);
4af2f8ff
FM
572 return;
573 }
574
f29e90f8 575 printf("SARG: %s %s\n",text[140],buf);
d6e703cc
FM
576}
577
32e71fa4 578void getconf(void)
d6e703cc
FM
579{
580
581 FILE *fp_in;
582 char buf[MAXLEN];
583
d2fe0c32
FM
584 if(debug)
585 debuga("Loading configuration from: %s",ConfigFile);
d6e703cc
FM
586
587 if ((fp_in = fopen(ConfigFile, "r")) == NULL) {
588 fprintf(stderr, "SARG: (getconf) Cannot open file: %s\n",ConfigFile);
589 exit(1);
590 }
591
4af2f8ff
FM
592 while (fgets(buf, sizeof(buf), fp_in) != NULL) {
593 fixendofline(buf);
d6e703cc
FM
594
595 if(debugm)
3103300b 596 printf("SYSCONFDIR %s\n",buf);
d6e703cc 597
d6e703cc
FM
598 parmtest(buf);
599
600 }
601
602 fclose(fp_in);
603 language_load(language);
604 return;
25697a35 605}