]> git.ipfire.org Git - thirdparty/sarg.git/blame - getconf.c
Delete unused files from the directory containing the user report
[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
15d5372b
FM
44struct sort_list
45{
46 //! The name of the value of the parameter.
47 const char *name;
48 //! The bit to set if the value is found.
49 unsigned long int value;
50};
51
e43854ef 52static struct param_list report_type_values[]=
085c1e1f
FM
53{
54 {"users_sites",REPORT_TYPE_USERS_SITES,0},
55 {"topusers",REPORT_TYPE_TOPUSERS,0},
56 {"topsites",REPORT_TYPE_TOPSITES,0},
57 {"sites_users",REPORT_TYPE_SITES_USERS,0},
58 {"date_time",REPORT_TYPE_DATE_TIME,0},
59 {"denied",REPORT_TYPE_DENIED,0},
60 {"auth_failures",REPORT_TYPE_AUTH_FAILURES,0},
61 {"site_user_time_date",REPORT_TYPE_SITE_USER_TIME_DATE,0},
62 {"downloads",REPORT_TYPE_DOWNLOADS,0},
63};
64
e43854ef 65static struct param_list data_field_values[]=
085c1e1f
FM
66{
67 {"user",DATA_FIELD_USER,0},
68 {"date",DATA_FIELD_DATE,0},
69 {"time",DATA_FIELD_TIME,0},
70 {"url",DATA_FIELD_URL,0},
71 {"connect",DATA_FIELD_CONNECT,0},
72 {"bytes",DATA_FIELD_BYTES,0},
73 {"in_cache",DATA_FIELD_IN_CACHE,0},
74 {"out_cache",DATA_FIELD_OUT_CACHE,0},
75 {"elapsed",DATA_FIELD_ELAPSED,0},
76};
77
e43854ef 78static struct param_list topuserfields_values[]=
085c1e1f
FM
79{
80 {"NUM",TOPUSERFIELDS_NUM,0},
81 {"DATE_TIME",TOPUSERFIELDS_DATE_TIME,0},
82 {"USERID",TOPUSERFIELDS_USERID,0},
83 {"CONNECT",TOPUSERFIELDS_CONNECT,0},
84 {"BYTES",TOPUSERFIELDS_BYTES,0},
85 {"%BYTES",TOPUSERFIELDS_SETYB,0},
86 {"SETYB",TOPUSERFIELDS_SETYB,0},
87 {"IN-CACHE-OUT",TOPUSERFIELDS_IN_CACHE_OUT,0},
88 {"USED_TIME",TOPUSERFIELDS_USED_TIME,0},
89 {"MILISEC",TOPUSERFIELDS_MILISEC,0},
90 {"%TIME",TOPUSERFIELDS_PTIME,0},
91 {"TOTAL",TOPUSERFIELDS_TOTAL,0},
92 {"AVERAGE",TOPUSERFIELDS_AVERAGE,0},
93};
94
e43854ef 95static struct param_list userreportfields_values[]=
085c1e1f
FM
96{
97 {"CONNECT",USERREPORTFIELDS_CONNECT,0},
98 {"BYTES",USERREPORTFIELDS_BYTES,0},
99 {"%BYTES",USERREPORTFIELDS_SETYB,0},
100 {"SETYB",USERREPORTFIELDS_SETYB,0},
101 {"IN-CACHE-OUT",USERREPORTFIELDS_IN_CACHE_OUT,0},
102 {"USED_TIME",USERREPORTFIELDS_USED_TIME,0},
103 {"MILISEC",USERREPORTFIELDS_MILISEC,0},
104 {"%TIME",USERREPORTFIELDS_PTIME,0},
105 {"TOTAL",USERREPORTFIELDS_TOTAL,0},
106 {"AVERAGE",USERREPORTFIELDS_AVERAGE,0},
107};
108
e43854ef 109static struct param_list index_values[]=
0349fa24
FM
110{
111 {"yes",INDEX_YES,~INDEX_YES},
112 {"no",INDEX_NO,~INDEX_NO},
113 {"only",INDEX_ONLY,~INDEX_ONLY},
114};
115
e43854ef 116static struct param_list index_tree_values[]=
0349fa24
FM
117{
118 {"date",INDEX_TREE_DATE,~INDEX_TREE_DATE},
119 {"file",INDEX_TREE_FILE,~INDEX_TREE_FILE},
120};
121
e43854ef 122static struct param_list ntml_userformat_values[]=
f2ec8c75
FM
123{
124 {"user",NTLMUSERFORMAT_USER,~NTLMUSERFORMAT_USER},
125 {"domainname+username",NTLMUSERFORMAT_DOMAINUSER,~NTLMUSERFORMAT_DOMAINUSER},
126};
127
e43854ef 128static struct param_list recnouser_values[]=
f2ec8c75
FM
129{
130 {"ip",RECORDWITHOUTUSER_IP,~RECORDWITHOUTUSER_IP},
131 {"ignore",RECORDWITHOUTUSER_IGNORE,~RECORDWITHOUTUSER_IGNORE},
132 {"everybody",RECORDWITHOUTUSER_EVERYBODY,~RECORDWITHOUTUSER_EVERYBODY},
133};
134
e43854ef 135static struct param_list datafileurl_values[]=
f84a35a3
FM
136{
137 {"ip",DATAFILEURL_IP,~DATAFILEURL_IP},
138 {"name",DATAFILEURL_NAME,~DATAFILEURL_NAME},
139};
140
e43854ef
FM
141static struct param_list displayvalue_values[]=
142{
143 {"bytes",DISPLAY_BYTES,~DISPLAY_BYTES},
144 {"abbreviation",DISPLAY_ABBREV,~DISPLAY_ABBREV},
145};
146
43cc1649
FM
147static struct param_list datetime_values[]=
148{
324ba7f3
FM
149 {"elap",DATETIME_ELAP,0},
150 {"bytes",DATETIME_BYTE,0},
43cc1649
FM
151};
152
71d78774
FM
153static struct param_list realtime_unauth_values[]=
154{
155 {"show",REALTIME_UNAUTH_REC_SHOW,~REALTIME_UNAUTH_REC_SHOW},
156 {"ignore",REALTIME_UNAUTH_REC_IGNORE,~REALTIME_UNAUTH_REC_IGNORE},
157};
158
15d5372b
FM
159struct sort_list topuser_sort[]=
160{
161 {"BYTES",TOPUSER_SORT_BYTES},
162 {"USER",TOPUSER_SORT_USER},
163 {"CONNECT",TOPUSER_SORT_CONNECT},
164 {"TIME",TOPUSER_SORT_TIME},
165};
166
167struct sort_list topsite_sort[]=
168{
169 {"BYTES",TOPSITE_SORT_BYTES},
170 {"CONNECT",TOPSITE_SORT_CONNECT},
70cab1a4 171 {"TIME",TOPSITE_SORT_TIME},
15d5372b
FM
172};
173
174struct sort_list user_sort[]=
175{
176 {"BYTES",USER_SORT_BYTES},
177 {"SITE",USER_SORT_SITE},
178 {"CONNECT",USER_SORT_CONNECT},
179 {"TIME",USER_SORT_TIME},
180};
181
6e792ade 182static int is_param(const char *param,const char *buf)
0a4e18e1
FM
183{
184 int plen;
185
186 plen=strlen(param);
187 if (strncmp(buf,param,plen) != 0) return(0);
188 buf+=plen;
189 if ((unsigned char)*buf>' ') return(0);
190 return(1);
191}
192
4af2f8ff
FM
193static int getparam_string(const char *param,char *buf,char *value,int value_size)
194{
195 int plen;
196
197 plen=strlen(param);
198 if (strncmp(buf,param,plen) != 0) return(0);
199 buf+=plen;
200 if ((unsigned char)*buf>' ') return(0);
201 while (*buf && (unsigned char)*buf<=' ') buf++;
202
203 if (strlen(buf)>=value_size) {
248a4787 204 debuga(_("The string value of parameter \"%s\" is too long\n"),param);
06b39c87 205 exit(EXIT_FAILURE);
4af2f8ff
FM
206 }
207 strcpy(value,buf);
208 fixnone(value);
209 return(1);
210}
25697a35 211
4af2f8ff 212static int getparam_quoted(const char *param,char *buf,char *value,int value_size)
25697a35 213{
4af2f8ff
FM
214 int plen;
215 int i;
25697a35 216
4af2f8ff
FM
217 plen=strlen(param);
218 if (strncmp(buf,param,plen) != 0) return(0);
219 buf+=plen;
220 if ((unsigned char)*buf>' ') return(0);
221 while (*buf && (unsigned char)*buf<=' ') buf++;
25697a35 222
4af2f8ff 223 if (*buf != '\"') {
248a4787 224 debuga(_("Missing double quote after parameter \"%s\"\n"),param);
06b39c87 225 exit(EXIT_FAILURE);
4af2f8ff
FM
226 }
227 buf++;
25697a35 228
4af2f8ff
FM
229 value_size--;
230 for (i=0 ; i<value_size && *buf && *buf!='\"' ; i++) {
231 value[i]=*buf++;
232 }
233 value[i]='\0';
25697a35 234
4af2f8ff 235 if (*buf != '\"') {
248a4787 236 debuga(_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size);
06b39c87 237 exit(EXIT_FAILURE);
4af2f8ff
FM
238 }
239 fixnone(value);
240 return(1);
241}
25697a35 242
4af2f8ff
FM
243static int getparam_2words(const char *param,char *buf,char *word1,int word1_size,char *word2,int word2_size)
244{
245 int plen;
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 for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++)
255 word1[i]=*buf++;
256 if (i>=word1_size) {
248a4787 257 debuga(_("The first word of parameter \"%s\" is more than %d bytes long\n"),param,word1_size-1);
06b39c87 258 exit(EXIT_FAILURE);
4af2f8ff
FM
259 }
260 if (*buf!=' ') {
248a4787 261 debuga(_("Missing second word for parameter \"%s\"\n"),param);
06b39c87 262 exit(EXIT_FAILURE);
4af2f8ff
FM
263 }
264 word1[i]=0;
25697a35 265
4af2f8ff 266 while (*buf && (unsigned char)*buf<=' ') buf++;
25697a35 267
4af2f8ff
FM
268 for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++)
269 word2[i]=*buf++;
270 if (i>=word2_size) {
248a4787 271 debuga(_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1);
06b39c87 272 exit(EXIT_FAILURE);
4af2f8ff
FM
273 }
274 word2[i]=0;
25697a35 275
4af2f8ff
FM
276 fixnone(word1);
277 fixnone(word2);
278 return(1);
279}
25697a35 280
4af2f8ff
FM
281static int getparam_int(const char *param,char *buf,int *value)
282{
283 int plen;
284 int next;
285
286 plen=strlen(param);
287 if (strncmp(buf,param,plen) != 0) return(0);
288 buf+=plen;
289 if ((unsigned char)*buf>' ') return(0);
290 while (*buf && (unsigned char)*buf<=' ') buf++;
291
292 next=0;
293 if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ') {
248a4787 294 debuga(_("The integer value of parameter \"%s\" is invalid\n"),param);
06b39c87 295 exit(EXIT_FAILURE);
4af2f8ff
FM
296 }
297 return(1);
298}
25697a35 299
06b39c87 300static int getparam_bool(const char *param,char *buf,bool *value)
246c8489
FM
301{
302 int plen;
246c8489 303 int i;
f6ff06fa 304 const char *bool_str="yes,true,on,1";
246c8489
FM
305
306 plen=strlen(param);
307 if (strncmp(buf,param,plen) != 0) return(0);
308 buf+=plen;
309 if ((unsigned char)*buf>' ') return(0);
310 while (*buf && (unsigned char)*buf<=' ') buf++;
311
06b39c87 312 *value=false;
f6ff06fa
FM
313 for ( ; *bool_str ; bool_str+=i) {
314 for (i=0 ; bool_str[i] && bool_str[i]!=',' ; i++);
315 if (strncasecmp(bool_str,buf,i)==0) {
06b39c87 316 *value=true;
246c8489
FM
317 break;
318 }
f6ff06fa 319 if (bool_str[i]==',') i++;
246c8489
FM
320 }
321 return(1);
322}
323
085c1e1f
FM
324static int getparam_list(const char *param,struct param_list *options,int noptions,char *buf,unsigned long int *value)
325{
326 int plen;
327 char *str;
328 int i;
329
330 plen=strlen(param);
331 if (strncmp(buf,param,plen) != 0) return(0);
332 buf+=plen;
333 if ((unsigned char)*buf>' ') return(0);
334 while (*buf && (unsigned char)*buf<=' ') buf++;
335
336 *value=0UL;
337 while (*buf) {
338 str=buf;
339 while (*str && (unsigned char)*str>' ' && *str!=';') str++;
340 if (*str) {
341 *str++='\0';
342 while (*str && ((unsigned char)*str<=' ' || *str==';')) str++;
343 }
344 for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
345 if (i>=noptions) {
248a4787 346 debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param);
06b39c87 347 exit(EXIT_FAILURE);
085c1e1f
FM
348 }
349 if ((*value & options[i].exclude)!=0) {
248a4787 350 debuga(_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param);
06b39c87 351 exit(EXIT_FAILURE);
085c1e1f
FM
352 }
353 *value|=options[i].value;
354 buf=str;
355 }
356 return(1);
357}
358
15d5372b
FM
359static int getparam_sort(const char *param,struct sort_list *options,int noptions,char *buf,unsigned long int *value)
360{
361 int plen;
362 char *str, *order;
363 int i;
364
365 plen=strlen(param);
366 if (strncmp(buf,param,plen) != 0) return(0);
367 buf+=plen;
368 if ((unsigned char)*buf>' ') return(0);
369 while (*buf && (unsigned char)*buf<=' ') buf++;
370
371 str=buf;
372 order=NULL;
373 while (*str && (unsigned char)*str>' ') str++;
374 if (*str) {
375 *str++='\0';
376 while (*str && (unsigned char)*str<=' ') str++;
377 order=str;
378 }
379 for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
380 if (i>=noptions) {
381 debuga(_("Unknown sort criterion \"%s\" for parameter \"%s\"\n"),buf,param);
382 exit(EXIT_FAILURE);
383 }
b06cc9aa 384 *value=options[i].value;
15d5372b
FM
385
386 if (order) {
387 str=order;
388 while (*str && (unsigned char)*str>' ') str++;
389 if (*str) {
390 *str++='\0';
391 while (*str && (unsigned char)*str<=' ') str++;
392 }
393 if (strcasecmp(order,"reverse")==0 || strcasecmp(order,"D")==0) {
394 *value|=SORT_REVERSE;
395 } else if (strcasecmp(order,"normal")!=0 && strcasecmp(order,"A")!=0) {
396 debuga(_("Unknown sort order \"%s\" for parameter \"%s\"\n"),order,param);
397 exit(EXIT_FAILURE);
398 }
399 }
400
401 buf=str;
402 return(1);
403}
404
4af2f8ff
FM
405static void parmtest(char *buf)
406{
d5d021c5 407 char wbuf[2048];
9c7c6346 408 struct getwordstruct gwarea;
25697a35 409
4af2f8ff 410 while (*buf && (unsigned char)*buf<=' ') buf++;
25697a35 411
4af2f8ff
FM
412 if(*buf == '#' || *buf == '\0')
413 return;
25697a35 414
4af2f8ff 415 if(debugz)
3c567423 416 printf(_("SARG: TAG: %s\n"),buf);
25697a35 417
4af2f8ff 418 if (getparam_string("background_color",buf,BgColor,sizeof(BgColor))>0) return;
25697a35 419
4af2f8ff 420 if (getparam_string("text_color",buf,TxColor,sizeof(TxColor))>0) return;
25697a35 421
4af2f8ff 422 if (getparam_string("text_bgcolor",buf,TxBgColor,sizeof(TxBgColor))>0) return;
25697a35 423
4af2f8ff 424 if (getparam_string("title_color",buf,TiColor,sizeof(TiColor))>0) return;
25697a35 425
4af2f8ff 426 if (getparam_string("logo_image",buf,LogoImage,sizeof(LogoImage))>0) return;
25697a35 427
4af2f8ff 428 if (getparam_quoted("logo_text",buf,LogoText,sizeof(LogoText))>0) return;
25697a35 429
4af2f8ff 430 if (getparam_string("logo_text_color",buf,LogoTextColor,sizeof(LogoTextColor))>0) return;
25697a35 431
4af2f8ff 432 if (getparam_string("background_image",buf,BgImage,sizeof(BgImage))>0) return;
25697a35 433
e6414a9d 434 if (getparam_bool("show_sarg_info",buf,&ShowSargInfo)>0) return;
25697a35 435
e6414a9d 436 if (getparam_bool("show_sarg_logo",buf,&ShowSargLogo)>0) return;
25697a35 437
4af2f8ff 438 if (getparam_string("font_face",buf,FontFace,sizeof(FontFace))>0) return;
25697a35 439
4af2f8ff 440 if (getparam_string("header_color",buf,HeaderColor,sizeof(HeaderColor))>0) return;
25697a35 441
4af2f8ff 442 if (getparam_string("header_bgcolor",buf,HeaderBgColor,sizeof(HeaderBgColor))>0) return;
25697a35 443
4af2f8ff 444 if (getparam_string("font_size",buf,FontSize,sizeof(FontSize))>0) return;
25697a35 445
4af2f8ff 446 if (getparam_string("header_font_size",buf,HeaderFontSize,sizeof(HeaderFontSize))>0) return;
25697a35 447
4af2f8ff 448 if (getparam_string("title_font_size",buf,TitleFontSize,sizeof(TitleFontSize))>0) return;
25697a35 449
4af2f8ff 450 if (getparam_2words("image_size",buf,Width,sizeof(Width),Height,sizeof(Height))>0) return;
25697a35 451
4af2f8ff 452 if (getparam_quoted("title",buf,Title,sizeof(Title))>0) return;
25697a35 453
246c8489 454 if (getparam_bool("resolve_ip",buf,&Ip2Name)>0) return;
25697a35 455
246c8489 456 if (getparam_bool("user_ip",buf,&UserIp)>0) return;
4af2f8ff
FM
457
458 if (getparam_string("max_elapsed",buf,MaxElapsed,sizeof(MaxElapsed))>0) return;
25697a35 459
e6414a9d 460 if (is_param("date_format",buf)) {
9c7c6346
FM
461 getword_start(&gwarea,buf);
462 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
248a4787 463 debuga(_("Maybe you have a broken record or garbage in \"date_format\" parameter\n"));
06b39c87 464 exit(EXIT_FAILURE);
25697a35 465 }
9c7c6346 466 strncpy(DateFormat,gwarea.current,1);
4af2f8ff
FM
467 fixnone(DateFormat);
468 return;
469 }
25697a35 470
e6414a9d 471 if (is_param("hours",buf)) {
4af2f8ff 472 if( getnumlist( buf, &hours, 24, 24 ) ) {
248a4787 473 debuga(_("Error: Invalid syntax in hours tag!\n"));
4af2f8ff 474 exit( 1 );
25697a35 475 }
3bd75b91 476 return;
4af2f8ff 477 }
25697a35 478
e6414a9d 479 if (is_param("weekdays",buf)) {
4af2f8ff 480 if( getnumlist( buf, &weekdays, 7, 7 ) ) {
248a4787 481 debuga(_("Error: Invalid syntax in weekdays tag!\n"));
4af2f8ff 482 exit( 1 );
25697a35 483 }
3bd75b91 484 return;
4af2f8ff 485 }
25697a35 486
15d5372b 487 if (getparam_sort("topuser_sort_field",SET_LIST(topuser_sort),buf,&TopuserSort)>0) return;
25697a35 488
15d5372b 489 if (getparam_sort("user_sort_field",SET_LIST(user_sort),buf,&UserSort)>0) return;
25697a35 490
6e792ade 491 if (is_param("access_log",buf)>0) {
0a4e18e1
FM
492 if (AccessLogFromCmdLine==0) {
493 if (NAccessLog>=MAXLOGS) {
248a4787 494 debuga(_("Too many log files in configuration file\n"));
06b39c87 495 exit(EXIT_FAILURE);
0a4e18e1 496 }
1f482a8d 497 getparam_string("access_log",buf,AccessLog[NAccessLog],MAX_LOG_FILELEN);
0a4e18e1
FM
498 NAccessLog++;
499 }
500 return;
501 }
25697a35 502
1f482a8d
FM
503 if (is_param("redirector_log",buf)>0) {
504 if (RedirectorLogFromCmdLine==0) {
505 if (NRedirectorLogs>=MAX_REDIRECTOR_LOGS) {
506 debuga(_("Too many redirector log files in configuration file\n"));
507 exit(EXIT_FAILURE);
508 }
509 getparam_string("redirector_log",buf,RedirectorLogs[NRedirectorLogs],MAX_REDIRECTOR_FILELEN);
510 NRedirectorLogs++;
511 }
512 return;
513 }
514
4af2f8ff 515 if (getparam_string("useragent_log",buf,UserAgentLog,sizeof(UserAgentLog))>0) return;
25697a35 516
4af2f8ff 517 if (getparam_string("exclude_hosts",buf,ExcludeHosts,sizeof(ExcludeHosts))>0) return;
25697a35 518
4af2f8ff 519 if (getparam_string("exclude_codes",buf,ExcludeCodes,sizeof(ExcludeCodes))>0) return;
25697a35 520
4af2f8ff 521 if (getparam_string("exclude_users",buf,ExcludeUsers,sizeof(ExcludeUsers))>0) return;
25697a35 522
4af2f8ff 523 if (getparam_string("password",buf,PasswdFile,sizeof(PasswdFile))>0) return;
25697a35 524
4af2f8ff 525 if (getparam_string("temporary_dir",buf,TempDir,sizeof(TempDir))>0) return;
25697a35 526
085c1e1f 527 if (getparam_list("report_type",SET_LIST(report_type_values),buf,&ReportType)>0) return;
25697a35 528
4af2f8ff 529 if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) return;
25697a35 530
4af2f8ff 531 if (getparam_string("output_email",buf,OutputEmail,sizeof(OutputEmail))>0) return;
25697a35 532
e6414a9d
FM
533 if (getparam_2words("per_user_limit",buf,PerUserLimitFile,sizeof(PerUserLimitFile),wbuf,sizeof(wbuf))>0) {
534 PerUserLimit=atoi(wbuf);
535 return;
536 }
25697a35 537
0511cf2d 538 if (getparam_int("lastlog",buf,&LastLog)>0) return;
25697a35 539
e6414a9d 540 if (getparam_bool("remove_temp_files",buf,&RemoveTempFiles)>0) return;
25697a35 541
4af2f8ff 542 if (getparam_string("replace_index",buf,ReplaceIndex,sizeof(ReplaceIndex))>0) return;
25697a35 543
0349fa24 544 if (getparam_list("index_tree",SET_LIST(index_tree_values),buf,&IndexTree)>0) return;
25697a35 545
0349fa24 546 if (getparam_list("index",SET_LIST(index_values),buf,&Index)>0) return;
25697a35 547
e6414a9d 548 if (getparam_bool("overwrite_report",buf,&OverwriteReport)>0) return;
25697a35 549
f2ec8c75 550 if (getparam_list("records_without_userid",SET_LIST(recnouser_values),buf,&RecordsWithoutUser)>0) return;
25697a35 551
e6414a9d 552 if (getparam_bool("use_comma",buf,&UseComma)>0) return;
25697a35 553
4af2f8ff 554 if (getparam_string("mail_utility",buf,MailUtility,sizeof(MailUtility))>0) return;
25697a35 555
c0ec9cc7 556 if (getparam_int("topsites_num",buf,&TopSitesNum)>0) return;
25697a35 557
fb7c5f27 558 if (getparam_int("topuser_num",buf,&TopUsersNum)>0) return;
25697a35 559
4af2f8ff 560 if (getparam_string("usertab",buf,UserTabFile,sizeof(UserTabFile))>0) return;
25697a35 561
4af2f8ff 562 if (getparam_string("index_sort_order",buf,IndexSortOrder,sizeof(IndexSortOrder))>0) return;
25697a35 563
15d5372b 564 if (getparam_sort("topsites_sort_order",SET_LIST(topsite_sort),buf,&TopsitesSort)>0) return;
25697a35 565
246c8489 566 if (getparam_bool("long_url",buf,&LongUrl)>0) return;
25697a35 567
4af2f8ff 568 if (getparam_string("dansguardian_conf",buf,DansGuardianConf,sizeof(DansGuardianConf))>0) return;
25697a35 569
4af2f8ff 570 if (getparam_string("squidguard_conf",buf,SquidGuardConf,sizeof(SquidGuardConf))>0) return;
25697a35 571
43cc1649 572 if (getparam_list("date_time_by",SET_LIST(datetime_values),buf,&datetimeby)>0) return;
25697a35 573
4af2f8ff
FM
574 if (getparam_string("charset",buf,CharSet,sizeof(CharSet))>0) {
575 ccharset(CharSet);
576 return;
577 }
25697a35 578
4af2f8ff 579 if (getparam_quoted("user_invalid_char",buf,UserInvalidChar,sizeof(UserInvalidChar))>0) return;
25697a35 580
4af2f8ff
FM
581 if (getparam_quoted("include_users",buf,IncludeUsers+1,sizeof(IncludeUsers)-2)>0) {
582 IncludeUsers[0]=':';
583 strcat(IncludeUsers,":");
584 return;
585 }
491b862f 586
4af2f8ff 587 if (getparam_quoted("exclude_string",buf,ExcludeString,sizeof(ExcludeString))>0) return;
25697a35 588
e6414a9d 589 if (getparam_bool("privacy",buf,&Privacy)>0) return;
25697a35 590
78015ea0 591 if (getparam_quoted("privacy_string",buf,PrivacyString,sizeof(PrivacyString))>0) return;
25697a35 592
4af2f8ff 593 if (getparam_string("privacy_string_color",buf,PrivacyStringColor,sizeof(PrivacyStringColor))>0) return;
25697a35 594
e6414a9d 595 if (getparam_bool("show_successful_message",buf,&SuccessfulMsg)>0) return;
25697a35 596
e6414a9d 597 if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) return;
25697a35 598
085c1e1f 599 if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&TopUserFields)>0) return;
25697a35 600
e6414a9d 601 if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersReport)>0) return;
25697a35 602
085c1e1f 603 if (getparam_list("user_report_fields",SET_LIST(userreportfields_values),buf,&UserReportFields)>0) return;
25697a35 604
4af2f8ff 605 if (getparam_string("datafile",buf,DataFile,sizeof(DataFile))>0) return;
25697a35 606
4af2f8ff 607 if (getparam_quoted("datafile_delimiter",buf,DataFileDelimiter,sizeof(DataFileDelimiter))>0) return;
25697a35 608
085c1e1f 609 if (getparam_list("datafile_fields",SET_LIST(data_field_values),buf,&DataFileFields)>0) return;
25697a35 610
f84a35a3 611 if (getparam_list("datafile_url",SET_LIST(datafileurl_values),buf,&DataFileUrl)>0) return;
25697a35 612
4af2f8ff 613 if (getparam_string("parsed_output_log",buf,ParsedOutputLog,sizeof(ParsedOutputLog))>0) return;
25697a35 614
4af2f8ff 615 if (getparam_string("parsed_output_log_compress",buf,ParsedOutputLogCompress,sizeof(ParsedOutputLogCompress))>0) return;
25697a35 616
e43854ef 617 if (getparam_list("displayed_values",SET_LIST(displayvalue_values),buf,&DisplayedValues)>0) return;
25697a35 618
4af2f8ff 619 if (getparam_int("authfail_report_limit",buf,&AuthfailReportLimit)>0) return;
25697a35 620
4af2f8ff 621 if (getparam_int("denied_report_limit",buf,&DeniedReportLimit)>0) return;
25697a35 622
4af2f8ff 623 if (getparam_int("siteusers_report_limit",buf,&SiteUsersReportLimit)>0) return;
25697a35 624
4af2f8ff 625 if (getparam_int("dansguardian_report_limit",buf,&DansGuardianReportLimit)>0) return;
25697a35 626
4af2f8ff 627 if (getparam_int("squidguard_report_limit",buf,&SquidGuardReportLimit)>0) return;
25697a35 628
4af2f8ff 629 if (getparam_int("user_report_limit",buf,&UserReportLimit)>0) return;
491b862f 630
4af2f8ff 631 if (getparam_int("download_report_limit",buf,&DownloadReportLimit)>0) return;
491b862f 632
4af2f8ff 633 if (getparam_string("www_document_root",buf,wwwDocumentRoot,sizeof(wwwDocumentRoot))>0) return;
25697a35 634
4af2f8ff 635 if (getparam_string("block_it",buf,BlockIt,sizeof(BlockIt))>0) return;
491b862f 636
4af2f8ff 637 if (getparam_string("external_css_file",buf,ExternalCSSFile,sizeof(ExternalCSSFile))>0) return;
491b862f 638
e6414a9d 639 if (getparam_bool("user_authentication",buf,&UserAuthentication)>0) return;
491b862f 640
d5d021c5
FM
641 if (getparam_string("AuthUserTemplateFile",buf,wbuf,sizeof(wbuf))>0) {
642 char dir[MAXLEN];
491b862f 643
d5d021c5
FM
644 if (is_absolute(wbuf)) {
645 if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) {
646 debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
06b39c87 647 exit(EXIT_FAILURE);
d5d021c5
FM
648 }
649 strcpy(AuthUserTemplateFile,wbuf);
650 } else {
651 strcpy(dir,ConfigFile);
652 if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplateFile),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) {
653 debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
06b39c87 654 exit(EXIT_FAILURE);
d5d021c5
FM
655 }
656 }
657 return;
658 }
4af2f8ff 659
6e792ade
FM
660 if (is_param("download_suffix",buf)) {
661 char warea[MAXLEN];
662
663 getparam_quoted("download_suffix",buf,warea,sizeof(warea));
664 set_download_suffix(warea);
e6414a9d 665 return;
6e792ade 666 }
d6e703cc 667
e6414a9d 668 if (getparam_bool("graphs",buf,&Graphs)>0) return;
4af2f8ff
FM
669
670 if (getparam_string("graph_days_bytes_bar_color",buf,GraphDaysBytesBarColor,sizeof(GraphDaysBytesBarColor))>0) return;
671
1f482a8d 672 if (getparam_string("redirector_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) return;
69fa7b48
FM
673 if (getparam_string("squidguard_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) {
674 debuga(_("squidguard_log_format is deprecated and has been replaced by redirector_log_format. Please update your configuration file.\n"));
675 return;
676 }
4af2f8ff 677
64dfb824
FM
678 if (getparam_bool("redirector_filter_out_date",buf,&RedirectorFilterOutDate)>0) return;
679 if (getparam_bool("redirector_ignore_date",buf,&RedirectorFilterOutDate)>0) {
680 /*
681 Due to an old bug in sarg before version 2.3, the option was having the opposite action than implied by the name.
682 */
683 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"));
684 RedirectorFilterOutDate=!RedirectorFilterOutDate;
685 return;
686 }
687 if (getparam_bool("squidguard_ignore_date",buf,&RedirectorFilterOutDate)>0) {
688 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"));
689 RedirectorFilterOutDate=!RedirectorFilterOutDate;
69fa7b48
FM
690 return;
691 }
4af2f8ff 692
64dfb824
FM
693 if (getparam_bool("dansguardian_filter_out_date",buf,&DansguardianFilterOutDate)>0) return;
694 if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianFilterOutDate)>0) {
695 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"));
696 DansguardianFilterOutDate=!DansguardianFilterOutDate;
697 return;
698 }
4af2f8ff
FM
699
700 if (getparam_string("ulimit",buf,Ulimit,sizeof(Ulimit))>0) return;
701
f2ec8c75 702 if (getparam_list("ntlm_user_format",SET_LIST(ntml_userformat_values),buf,&NtlmUserFormat)>0) return;
4af2f8ff
FM
703
704 if (getparam_string("realtime_types",buf,RealtimeTypes,sizeof(RealtimeTypes))>0) return;
705
71d78774 706 if (getparam_list("realtime_unauthenticated_records",SET_LIST(realtime_unauth_values),buf,&RealtimeUnauthRec)>0) return;
4af2f8ff
FM
707
708 if (getparam_int("realtime_refresh_time",buf,&realtime_refresh)>0) return;
709
710 if (getparam_int("realtime_access_log_lines",buf,&realtime_access_log_lines)>0) return;
711
e3af0ae9
PO
712 if (getparam_string("LDAPHost",buf,LDAPHost,sizeof(LDAPHost))>0) return;
713
965c4a6f 714 if (getparam_int("LDAPPort",buf,&LDAPPort)>0) return;
e3af0ae9 715
965c4a6f 716 if (getparam_int("LDAPProtocolVersion",buf,&LDAPProtocolVersion)>0) return;
e3af0ae9
PO
717
718 if (getparam_string("LDAPBindDN",buf,LDAPBindDN,sizeof(LDAPBindDN))>0) return;
719
720 if (getparam_string("LDAPBindPW",buf,LDAPBindPW,sizeof(LDAPBindPW))>0) return;
721
722 if (getparam_string("LDAPBaseSearch",buf,LDAPBaseSearch,sizeof(LDAPBaseSearch))>0) return;
723
724 if (getparam_string("LDAPFilterSearch",buf,LDAPFilterSearch,sizeof(LDAPFilterSearch))>0) return;
725
726 if (getparam_string("LDAPTargetAttr",buf,LDAPTargetAttr,sizeof(LDAPTargetAttr))>0) return;
727
3becf85c
FM
728 if (getparam_string("graph_font",buf,GraphFont,sizeof(GraphFont))>0) return;
729
ea275279
FM
730 if (getparam_string("sorttable",buf,SortTableJs,sizeof(SortTableJs))>0) return;
731
4af2f8ff 732 if(strstr(buf,"squid24") != 0) {
2824ec9b 733 squid24=true;
4af2f8ff
FM
734 return;
735 }
736
737 if(strstr(buf,"byte_cost") != 0) {
9c7c6346
FM
738 getword_start(&gwarea,buf);
739 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
248a4787 740 debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
06b39c87 741 exit(EXIT_FAILURE);
4af2f8ff 742 }
9c7c6346
FM
743 cost=atol(gwarea.current);
744 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
248a4787 745 debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
06b39c87 746 exit(EXIT_FAILURE);
491b862f 747 }
9c7c6346 748 nocost=my_atoll(gwarea.current);
4af2f8ff
FM
749 return;
750 }
751
3c567423 752 printf(_("SARG: Unknown option %s\n"),buf);
d6e703cc
FM
753}
754
32e71fa4 755void getconf(void)
d6e703cc
FM
756{
757
758 FILE *fp_in;
759 char buf[MAXLEN];
760
d2fe0c32 761 if(debug)
9f70c14e 762 debuga(_("Loading configuration from %s\n"),ConfigFile);
d6e703cc
FM
763
764 if ((fp_in = fopen(ConfigFile, "r")) == NULL) {
9f70c14e 765 debuga(_("(getconf) Cannot open file %s\n"),ConfigFile);
06b39c87 766 exit(EXIT_FAILURE);
d6e703cc
FM
767 }
768
4af2f8ff
FM
769 while (fgets(buf, sizeof(buf), fp_in) != NULL) {
770 fixendofline(buf);
d6e703cc
FM
771
772 if(debugm)
3103300b 773 printf("SYSCONFDIR %s\n",buf);
d6e703cc 774
d6e703cc
FM
775 parmtest(buf);
776
777 }
778
779 fclose(fp_in);
d6e703cc 780 return;
25697a35 781}