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