]> git.ipfire.org Git - thirdparty/sarg.git/blame - getconf.c
Remove the u_long that may be incompatible with mini mac
[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
f2ec8c75
FM
114struct param_list ntml_userformat_values[]=
115{
116 {"user",NTLMUSERFORMAT_USER,~NTLMUSERFORMAT_USER},
117 {"domainname+username",NTLMUSERFORMAT_DOMAINUSER,~NTLMUSERFORMAT_DOMAINUSER},
118};
119
120struct param_list recnouser_values[]=
121{
122 {"ip",RECORDWITHOUTUSER_IP,~RECORDWITHOUTUSER_IP},
123 {"ignore",RECORDWITHOUTUSER_IGNORE,~RECORDWITHOUTUSER_IGNORE},
124 {"everybody",RECORDWITHOUTUSER_EVERYBODY,~RECORDWITHOUTUSER_EVERYBODY},
125};
126
f84a35a3
FM
127struct param_list datafileurl_values[]=
128{
129 {"ip",DATAFILEURL_IP,~DATAFILEURL_IP},
130 {"name",DATAFILEURL_NAME,~DATAFILEURL_NAME},
131};
132
6e792ade 133static int is_param(const char *param,const char *buf)
0a4e18e1
FM
134{
135 int plen;
136
137 plen=strlen(param);
138 if (strncmp(buf,param,plen) != 0) return(0);
139 buf+=plen;
140 if ((unsigned char)*buf>' ') return(0);
141 return(1);
142}
143
4af2f8ff
FM
144static int getparam_string(const char *param,char *buf,char *value,int value_size)
145{
146 int plen;
147
148 plen=strlen(param);
149 if (strncmp(buf,param,plen) != 0) return(0);
150 buf+=plen;
151 if ((unsigned char)*buf>' ') return(0);
152 while (*buf && (unsigned char)*buf<=' ') buf++;
153
154 if (strlen(buf)>=value_size) {
248a4787 155 debuga(_("The string value of parameter \"%s\" is too long\n"),param);
4af2f8ff
FM
156 exit(1);
157 }
158 strcpy(value,buf);
159 fixnone(value);
160 return(1);
161}
25697a35 162
4af2f8ff 163static int getparam_quoted(const char *param,char *buf,char *value,int value_size)
25697a35 164{
4af2f8ff
FM
165 int plen;
166 int i;
25697a35 167
4af2f8ff
FM
168 plen=strlen(param);
169 if (strncmp(buf,param,plen) != 0) return(0);
170 buf+=plen;
171 if ((unsigned char)*buf>' ') return(0);
172 while (*buf && (unsigned char)*buf<=' ') buf++;
25697a35 173
4af2f8ff 174 if (*buf != '\"') {
248a4787 175 debuga(_("Missing double quote after parameter \"%s\"\n"),param);
4af2f8ff
FM
176 exit(1);
177 }
178 buf++;
25697a35 179
4af2f8ff
FM
180 value_size--;
181 for (i=0 ; i<value_size && *buf && *buf!='\"' ; i++) {
182 value[i]=*buf++;
183 }
184 value[i]='\0';
25697a35 185
4af2f8ff 186 if (*buf != '\"') {
248a4787 187 debuga(_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size);
4af2f8ff
FM
188 exit(1);
189 }
190 fixnone(value);
191 return(1);
192}
25697a35 193
4af2f8ff
FM
194static int getparam_2words(const char *param,char *buf,char *word1,int word1_size,char *word2,int word2_size)
195{
196 int plen;
197 int i;
198
199 plen=strlen(param);
200 if (strncmp(buf,param,plen) != 0) return(0);
201 buf+=plen;
202 if ((unsigned char)*buf>' ') return(0);
203 while (*buf && (unsigned char)*buf<=' ') buf++;
204
205 for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++)
206 word1[i]=*buf++;
207 if (i>=word1_size) {
248a4787 208 debuga(_("The first word of parameter \"%s\" is more than %d bytes long\n"),param,word1_size-1);
4af2f8ff
FM
209 exit(1);
210 }
211 if (*buf!=' ') {
248a4787 212 debuga(_("Missing second word for parameter \"%s\"\n"),param);
4af2f8ff
FM
213 exit(1);
214 }
215 word1[i]=0;
25697a35 216
4af2f8ff 217 while (*buf && (unsigned char)*buf<=' ') buf++;
25697a35 218
4af2f8ff
FM
219 for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++)
220 word2[i]=*buf++;
221 if (i>=word2_size) {
248a4787 222 debuga(_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1);
4af2f8ff
FM
223 exit(1);
224 }
225 word2[i]=0;
25697a35 226
4af2f8ff
FM
227 fixnone(word1);
228 fixnone(word2);
229 return(1);
230}
25697a35 231
4af2f8ff
FM
232static int getparam_int(const char *param,char *buf,int *value)
233{
234 int plen;
235 int next;
236
237 plen=strlen(param);
238 if (strncmp(buf,param,plen) != 0) return(0);
239 buf+=plen;
240 if ((unsigned char)*buf>' ') return(0);
241 while (*buf && (unsigned char)*buf<=' ') buf++;
242
243 next=0;
244 if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ') {
248a4787 245 debuga(_("The integer value of parameter \"%s\" is invalid\n"),param);
4af2f8ff
FM
246 exit(1);
247 }
248 return(1);
249}
25697a35 250
246c8489
FM
251static int getparam_bool(const char *param,char *buf,int *value)
252{
253 int plen;
246c8489 254 int i;
f6ff06fa 255 const char *bool_str="yes,true,on,1";
246c8489
FM
256
257 plen=strlen(param);
258 if (strncmp(buf,param,plen) != 0) return(0);
259 buf+=plen;
260 if ((unsigned char)*buf>' ') return(0);
261 while (*buf && (unsigned char)*buf<=' ') buf++;
262
263 *value=0;
f6ff06fa
FM
264 for ( ; *bool_str ; bool_str+=i) {
265 for (i=0 ; bool_str[i] && bool_str[i]!=',' ; i++);
266 if (strncasecmp(bool_str,buf,i)==0) {
246c8489
FM
267 *value=1;
268 break;
269 }
f6ff06fa 270 if (bool_str[i]==',') i++;
246c8489
FM
271 }
272 return(1);
273}
274
085c1e1f
FM
275static int getparam_list(const char *param,struct param_list *options,int noptions,char *buf,unsigned long int *value)
276{
277 int plen;
278 char *str;
279 int i;
280
281 plen=strlen(param);
282 if (strncmp(buf,param,plen) != 0) return(0);
283 buf+=plen;
284 if ((unsigned char)*buf>' ') return(0);
285 while (*buf && (unsigned char)*buf<=' ') buf++;
286
287 *value=0UL;
288 while (*buf) {
289 str=buf;
290 while (*str && (unsigned char)*str>' ' && *str!=';') str++;
291 if (*str) {
292 *str++='\0';
293 while (*str && ((unsigned char)*str<=' ' || *str==';')) str++;
294 }
295 for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
296 if (i>=noptions) {
248a4787 297 debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param);
085c1e1f
FM
298 exit(1);
299 }
300 if ((*value & options[i].exclude)!=0) {
248a4787 301 debuga(_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param);
085c1e1f
FM
302 exit(1);
303 }
304 *value|=options[i].value;
305 buf=str;
306 }
307 return(1);
308}
309
4af2f8ff
FM
310static void parmtest(char *buf)
311{
d5d021c5 312 char wbuf[2048];
9c7c6346 313 struct getwordstruct gwarea;
25697a35 314
4af2f8ff 315 while (*buf && (unsigned char)*buf<=' ') buf++;
25697a35 316
4af2f8ff
FM
317 if(*buf == '#' || *buf == '\0')
318 return;
25697a35 319
4af2f8ff 320 if(debugz)
3c567423 321 printf(_("SARG: TAG: %s\n"),buf);
25697a35 322
4af2f8ff 323 if (getparam_string("background_color",buf,BgColor,sizeof(BgColor))>0) return;
25697a35 324
4af2f8ff 325 if (getparam_string("text_color",buf,TxColor,sizeof(TxColor))>0) return;
25697a35 326
4af2f8ff 327 if (getparam_string("text_bgcolor",buf,TxBgColor,sizeof(TxBgColor))>0) return;
25697a35 328
4af2f8ff 329 if (getparam_string("title_color",buf,TiColor,sizeof(TiColor))>0) return;
25697a35 330
4af2f8ff 331 if (getparam_string("logo_image",buf,LogoImage,sizeof(LogoImage))>0) return;
25697a35 332
4af2f8ff 333 if (getparam_quoted("logo_text",buf,LogoText,sizeof(LogoText))>0) return;
25697a35 334
4af2f8ff 335 if (getparam_string("logo_text_color",buf,LogoTextColor,sizeof(LogoTextColor))>0) return;
25697a35 336
4af2f8ff 337 if (getparam_string("background_image",buf,BgImage,sizeof(BgImage))>0) return;
25697a35 338
e6414a9d 339 if (getparam_bool("show_sarg_info",buf,&ShowSargInfo)>0) return;
25697a35 340
e6414a9d 341 if (getparam_bool("show_sarg_logo",buf,&ShowSargLogo)>0) return;
25697a35 342
4af2f8ff 343 if (getparam_string("font_face",buf,FontFace,sizeof(FontFace))>0) return;
25697a35 344
4af2f8ff 345 if (getparam_string("header_color",buf,HeaderColor,sizeof(HeaderColor))>0) return;
25697a35 346
4af2f8ff 347 if (getparam_string("header_bgcolor",buf,HeaderBgColor,sizeof(HeaderBgColor))>0) return;
25697a35 348
4af2f8ff 349 if (getparam_string("font_size",buf,FontSize,sizeof(FontSize))>0) return;
25697a35 350
4af2f8ff 351 if (getparam_string("header_font_size",buf,HeaderFontSize,sizeof(HeaderFontSize))>0) return;
25697a35 352
4af2f8ff 353 if (getparam_string("title_font_size",buf,TitleFontSize,sizeof(TitleFontSize))>0) return;
25697a35 354
4af2f8ff 355 if (getparam_2words("image_size",buf,Width,sizeof(Width),Height,sizeof(Height))>0) return;
25697a35 356
4af2f8ff 357 if (getparam_quoted("title",buf,Title,sizeof(Title))>0) return;
25697a35 358
246c8489 359 if (getparam_bool("resolve_ip",buf,&Ip2Name)>0) return;
25697a35 360
246c8489 361 if (getparam_bool("user_ip",buf,&UserIp)>0) return;
4af2f8ff
FM
362
363 if (getparam_string("max_elapsed",buf,MaxElapsed,sizeof(MaxElapsed))>0) return;
25697a35 364
e6414a9d 365 if (is_param("date_format",buf)) {
9c7c6346
FM
366 getword_start(&gwarea,buf);
367 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
248a4787 368 debuga(_("Maybe you have a broken record or garbage in \"date_format\" parameter\n"));
4af2f8ff 369 exit(1);
25697a35 370 }
9c7c6346 371 strncpy(DateFormat,gwarea.current,1);
4af2f8ff
FM
372 fixnone(DateFormat);
373 return;
374 }
25697a35 375
e6414a9d 376 if (is_param("hours",buf)) {
4af2f8ff 377 if( getnumlist( buf, &hours, 24, 24 ) ) {
248a4787 378 debuga(_("Error: Invalid syntax in hours tag!\n"));
4af2f8ff 379 exit( 1 );
25697a35 380 }
4af2f8ff 381 }
25697a35 382
e6414a9d 383 if (is_param("weekdays",buf)) {
4af2f8ff 384 if( getnumlist( buf, &weekdays, 7, 7 ) ) {
248a4787 385 debuga(_("Error: Invalid syntax in weekdays tag!\n"));
4af2f8ff 386 exit( 1 );
25697a35 387 }
4af2f8ff 388 }
25697a35 389
4af2f8ff 390 if (getparam_2words("topuser_sort_field",buf,TopuserSortField,sizeof(TopuserSortField),TopuserSortOrder,sizeof(TopuserSortOrder))>0) return;
25697a35 391
4af2f8ff 392 if (getparam_2words("user_sort_field",buf,UserSortField,sizeof(UserSortField),UserSortOrder,sizeof(UserSortOrder))>0) return;
25697a35 393
6e792ade 394 if (is_param("access_log",buf)>0) {
0a4e18e1
FM
395 if (AccessLogFromCmdLine==0) {
396 if (NAccessLog>=MAXLOGS) {
248a4787 397 debuga(_("Too many log files in configuration file\n"));
0a4e18e1
FM
398 exit(1);
399 }
400 getparam_string("access_log",buf,AccessLog[NAccessLog],MAXLEN);
401 NAccessLog++;
402 }
403 return;
404 }
25697a35 405
4af2f8ff 406 if (getparam_string("useragent_log",buf,UserAgentLog,sizeof(UserAgentLog))>0) return;
25697a35 407
4af2f8ff 408 if (getparam_string("exclude_hosts",buf,ExcludeHosts,sizeof(ExcludeHosts))>0) return;
25697a35 409
4af2f8ff 410 if (getparam_string("exclude_codes",buf,ExcludeCodes,sizeof(ExcludeCodes))>0) return;
25697a35 411
4af2f8ff 412 if (getparam_string("exclude_users",buf,ExcludeUsers,sizeof(ExcludeUsers))>0) return;
25697a35 413
4af2f8ff 414 if (getparam_string("password",buf,PasswdFile,sizeof(PasswdFile))>0) return;
25697a35 415
4af2f8ff 416 if (getparam_string("temporary_dir",buf,TempDir,sizeof(TempDir))>0) return;
25697a35 417
085c1e1f 418 if (getparam_list("report_type",SET_LIST(report_type_values),buf,&ReportType)>0) return;
25697a35 419
4af2f8ff 420 if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) return;
25697a35 421
4af2f8ff 422 if (getparam_string("output_email",buf,OutputEmail,sizeof(OutputEmail))>0) return;
25697a35 423
e6414a9d
FM
424 if (getparam_2words("per_user_limit",buf,PerUserLimitFile,sizeof(PerUserLimitFile),wbuf,sizeof(wbuf))>0) {
425 PerUserLimit=atoi(wbuf);
426 return;
427 }
25697a35 428
0511cf2d 429 if (getparam_int("lastlog",buf,&LastLog)>0) return;
25697a35 430
e6414a9d 431 if (getparam_bool("remove_temp_files",buf,&RemoveTempFiles)>0) return;
25697a35 432
4af2f8ff 433 if (getparam_string("replace_index",buf,ReplaceIndex,sizeof(ReplaceIndex))>0) return;
25697a35 434
0349fa24 435 if (getparam_list("index_tree",SET_LIST(index_tree_values),buf,&IndexTree)>0) return;
25697a35 436
0349fa24 437 if (getparam_list("index",SET_LIST(index_values),buf,&Index)>0) return;
25697a35 438
e6414a9d 439 if (getparam_bool("overwrite_report",buf,&OverwriteReport)>0) return;
25697a35 440
f2ec8c75 441 if (getparam_list("records_without_userid",SET_LIST(recnouser_values),buf,&RecordsWithoutUser)>0) return;
25697a35 442
e6414a9d 443 if (getparam_bool("use_comma",buf,&UseComma)>0) return;
25697a35 444
4af2f8ff 445 if (getparam_string("mail_utility",buf,MailUtility,sizeof(MailUtility))>0) return;
25697a35 446
c0ec9cc7 447 if (getparam_int("topsites_num",buf,&TopSitesNum)>0) return;
25697a35 448
fb7c5f27 449 if (getparam_int("topuser_num",buf,&TopUsersNum)>0) return;
25697a35 450
4af2f8ff 451 if (getparam_string("usertab",buf,UserTabFile,sizeof(UserTabFile))>0) return;
25697a35 452
4af2f8ff 453 if (getparam_string("index_sort_order",buf,IndexSortOrder,sizeof(IndexSortOrder))>0) return;
25697a35 454
4af2f8ff 455 if (getparam_2words("topsites_sort_order",buf,TopsitesSortField,sizeof(TopsitesSortField),TopsitesSortType,sizeof(TopsitesSortType))>0) return;
25697a35 456
246c8489 457 if (getparam_bool("long_url",buf,&LongUrl)>0) return;
25697a35 458
4af2f8ff 459 if (getparam_string("dansguardian_conf",buf,DansGuardianConf,sizeof(DansGuardianConf))>0) return;
25697a35 460
4af2f8ff 461 if (getparam_string("squidguard_conf",buf,SquidGuardConf,sizeof(SquidGuardConf))>0) return;
25697a35 462
4af2f8ff 463 if (getparam_string("date_time_by",buf,datetimeby,sizeof(datetimeby))>0) return;
25697a35 464
4af2f8ff
FM
465 if (getparam_string("charset",buf,CharSet,sizeof(CharSet))>0) {
466 ccharset(CharSet);
467 return;
468 }
25697a35 469
4af2f8ff 470 if (getparam_quoted("user_invalid_char",buf,UserInvalidChar,sizeof(UserInvalidChar))>0) return;
25697a35 471
4af2f8ff
FM
472 if (getparam_quoted("include_users",buf,IncludeUsers+1,sizeof(IncludeUsers)-2)>0) {
473 IncludeUsers[0]=':';
474 strcat(IncludeUsers,":");
475 return;
476 }
491b862f 477
4af2f8ff 478 if (getparam_quoted("exclude_string",buf,ExcludeString,sizeof(ExcludeString))>0) return;
25697a35 479
e6414a9d 480 if (getparam_bool("privacy",buf,&Privacy)>0) return;
25697a35 481
78015ea0 482 if (getparam_quoted("privacy_string",buf,PrivacyString,sizeof(PrivacyString))>0) return;
25697a35 483
4af2f8ff 484 if (getparam_string("privacy_string_color",buf,PrivacyStringColor,sizeof(PrivacyStringColor))>0) return;
25697a35 485
e6414a9d 486 if (getparam_bool("show_successful_message",buf,&SuccessfulMsg)>0) return;
25697a35 487
e6414a9d 488 if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) return;
25697a35 489
085c1e1f 490 if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&TopUserFields)>0) return;
25697a35 491
e6414a9d 492 if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersReport)>0) return;
25697a35 493
085c1e1f 494 if (getparam_list("user_report_fields",SET_LIST(userreportfields_values),buf,&UserReportFields)>0) return;
25697a35 495
4af2f8ff 496 if (getparam_string("datafile",buf,DataFile,sizeof(DataFile))>0) return;
25697a35 497
4af2f8ff 498 if (getparam_quoted("datafile_delimiter",buf,DataFileDelimiter,sizeof(DataFileDelimiter))>0) return;
25697a35 499
085c1e1f 500 if (getparam_list("datafile_fields",SET_LIST(data_field_values),buf,&DataFileFields)>0) return;
25697a35 501
f84a35a3 502 if (getparam_list("datafile_url",SET_LIST(datafileurl_values),buf,&DataFileUrl)>0) return;
25697a35 503
4af2f8ff 504 if (getparam_string("parsed_output_log",buf,ParsedOutputLog,sizeof(ParsedOutputLog))>0) return;
25697a35 505
4af2f8ff 506 if (getparam_string("parsed_output_log_compress",buf,ParsedOutputLogCompress,sizeof(ParsedOutputLogCompress))>0) return;
25697a35 507
4af2f8ff 508 if (getparam_string("displayed_values",buf,DisplayedValues,sizeof(DisplayedValues))>0) return;
25697a35 509
4af2f8ff 510 if (getparam_int("authfail_report_limit",buf,&AuthfailReportLimit)>0) return;
25697a35 511
4af2f8ff 512 if (getparam_int("denied_report_limit",buf,&DeniedReportLimit)>0) return;
25697a35 513
4af2f8ff 514 if (getparam_int("siteusers_report_limit",buf,&SiteUsersReportLimit)>0) return;
25697a35 515
4af2f8ff 516 if (getparam_int("dansguardian_report_limit",buf,&DansGuardianReportLimit)>0) return;
25697a35 517
4af2f8ff 518 if (getparam_int("squidguard_report_limit",buf,&SquidGuardReportLimit)>0) return;
25697a35 519
4af2f8ff 520 if (getparam_int("user_report_limit",buf,&UserReportLimit)>0) return;
491b862f 521
4af2f8ff 522 if (getparam_int("download_report_limit",buf,&DownloadReportLimit)>0) return;
491b862f 523
4af2f8ff 524 if (getparam_string("www_document_root",buf,wwwDocumentRoot,sizeof(wwwDocumentRoot))>0) return;
25697a35 525
4af2f8ff 526 if (getparam_string("block_it",buf,BlockIt,sizeof(BlockIt))>0) return;
491b862f 527
4af2f8ff 528 if (getparam_string("external_css_file",buf,ExternalCSSFile,sizeof(ExternalCSSFile))>0) return;
491b862f 529
e6414a9d 530 if (getparam_bool("user_authentication",buf,&UserAuthentication)>0) return;
491b862f 531
d5d021c5
FM
532 if (getparam_string("AuthUserTemplateFile",buf,wbuf,sizeof(wbuf))>0) {
533 char dir[MAXLEN];
491b862f 534
d5d021c5
FM
535 if (is_absolute(wbuf)) {
536 if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) {
537 debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
538 exit(1);
539 }
540 strcpy(AuthUserTemplateFile,wbuf);
541 } else {
542 strcpy(dir,ConfigFile);
543 if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplateFile),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) {
544 debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
545 exit(1);
546 }
547 }
548 return;
549 }
4af2f8ff 550
6e792ade
FM
551 if (is_param("download_suffix",buf)) {
552 char warea[MAXLEN];
553
554 getparam_quoted("download_suffix",buf,warea,sizeof(warea));
555 set_download_suffix(warea);
e6414a9d 556 return;
6e792ade 557 }
d6e703cc 558
e6414a9d 559 if (getparam_bool("graphs",buf,&Graphs)>0) return;
4af2f8ff
FM
560
561 if (getparam_string("graph_days_bytes_bar_color",buf,GraphDaysBytesBarColor,sizeof(GraphDaysBytesBarColor))>0) return;
562
563 if (getparam_string("squidguard_log_format",buf,SquidGuardLogFormat,sizeof(SquidGuardLogFormat))>0) return;
564
e6414a9d 565 if (getparam_bool("squidguard_ignore_date",buf,&SquidguardIgnoreDate)>0) return;
4af2f8ff 566
e6414a9d 567 if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianIgnoreDate)>0) return;
4af2f8ff
FM
568
569 if (getparam_string("ulimit",buf,Ulimit,sizeof(Ulimit))>0) return;
570
f2ec8c75 571 if (getparam_list("ntlm_user_format",SET_LIST(ntml_userformat_values),buf,&NtlmUserFormat)>0) return;
4af2f8ff
FM
572
573 if (getparam_string("realtime_types",buf,RealtimeTypes,sizeof(RealtimeTypes))>0) return;
574
575 if (getparam_string("realtime_unauthenticated_records",buf,RealtimeUnauthRec,sizeof(RealtimeUnauthRec))>0) return;
576
577 if (getparam_int("realtime_refresh_time",buf,&realtime_refresh)>0) return;
578
579 if (getparam_int("realtime_access_log_lines",buf,&realtime_access_log_lines)>0) return;
580
e3af0ae9
PO
581 if (getparam_string("LDAPHost",buf,LDAPHost,sizeof(LDAPHost))>0) return;
582
965c4a6f 583 if (getparam_int("LDAPPort",buf,&LDAPPort)>0) return;
e3af0ae9 584
965c4a6f 585 if (getparam_int("LDAPProtocolVersion",buf,&LDAPProtocolVersion)>0) return;
e3af0ae9
PO
586
587 if (getparam_string("LDAPBindDN",buf,LDAPBindDN,sizeof(LDAPBindDN))>0) return;
588
589 if (getparam_string("LDAPBindPW",buf,LDAPBindPW,sizeof(LDAPBindPW))>0) return;
590
591 if (getparam_string("LDAPBaseSearch",buf,LDAPBaseSearch,sizeof(LDAPBaseSearch))>0) return;
592
593 if (getparam_string("LDAPFilterSearch",buf,LDAPFilterSearch,sizeof(LDAPFilterSearch))>0) return;
594
595 if (getparam_string("LDAPTargetAttr",buf,LDAPTargetAttr,sizeof(LDAPTargetAttr))>0) return;
596
3becf85c
FM
597 if (getparam_string("graph_font",buf,GraphFont,sizeof(GraphFont))>0) return;
598
4af2f8ff
FM
599 if(strstr(buf,"squid24") != 0) {
600 squid24++;
601 return;
602 }
603
604 if(strstr(buf,"byte_cost") != 0) {
9c7c6346
FM
605 getword_start(&gwarea,buf);
606 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
248a4787 607 debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
4af2f8ff
FM
608 exit(1);
609 }
9c7c6346
FM
610 cost=atol(gwarea.current);
611 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
248a4787 612 debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
4af2f8ff 613 exit(1);
491b862f 614 }
9c7c6346 615 nocost=my_atoll(gwarea.current);
4af2f8ff
FM
616 return;
617 }
618
3c567423 619 printf(_("SARG: Unknown option %s\n"),buf);
d6e703cc
FM
620}
621
32e71fa4 622void getconf(void)
d6e703cc
FM
623{
624
625 FILE *fp_in;
626 char buf[MAXLEN];
627
d2fe0c32 628 if(debug)
9f70c14e 629 debuga(_("Loading configuration from %s\n"),ConfigFile);
d6e703cc
FM
630
631 if ((fp_in = fopen(ConfigFile, "r")) == NULL) {
9f70c14e 632 debuga(_("(getconf) Cannot open file %s\n"),ConfigFile);
d6e703cc
FM
633 exit(1);
634 }
635
4af2f8ff
FM
636 while (fgets(buf, sizeof(buf), fp_in) != NULL) {
637 fixendofline(buf);
d6e703cc
FM
638
639 if(debugm)
3103300b 640 printf("SYSCONFDIR %s\n",buf);
d6e703cc 641
d6e703cc
FM
642 parmtest(buf);
643
644 }
645
646 fclose(fp_in);
d6e703cc 647 return;
25697a35 648}