]> git.ipfire.org Git - thirdparty/sarg.git/blame - getconf.c
All the sprintf/fputs have been replaced by fprintf to avoid an intermediary buffer...
[thirdparty/sarg.git] / getconf.c
CommitLineData
25697a35 1/*
c37945ed
FM
2 * AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
3 * 1998, 2008
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"
27
28extern numlist hours, weekdays;
29
30char wbuf[MAXLEN];
31char Msg[255];
32
d6e703cc 33void parmtest(char *buf)
25697a35
GS
34{
35
36 if(strstr(buf,"background_color") != 0) {
4bcb77cf
FM
37 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
38 printf("SARG: Maybe you have a broken record or garbage in background_color parameter.\n");
39 exit(1);
40 }
25697a35
GS
41 strcpy(BgColor,buf);
42 fixnone(BgColor);
43 return;
44 }
45
46 if(strstr(buf,"text_color") != 0) {
47 if(strstr(buf,"logo_text_color") == 0) {
4bcb77cf
FM
48 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
49 printf("SARG: Maybe you have a broken record or garbage in text_color parameter.\n");
50 exit(1);
51 }
25697a35
GS
52 strcpy(TxColor,buf);
53 fixnone(TxColor);
54 return;
55 }
56 }
57
58 if(strstr(buf,"text_bgcolor") != 0) {
4bcb77cf
FM
59 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
60 printf("SARG: Maybe you have a broken record or garbage in text_bgcolor parameter.\n");
61 exit(1);
62 }
25697a35
GS
63 strcpy(TxBgColor,buf);
64 fixnone(TxBgColor);
65 return;
66 }
67
68 if(strstr(buf,"title_color") != 0) {
4bcb77cf
FM
69 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
70 printf("SARG: Maybe you have a broken record or garbage in title_color parameter.\n");
71 exit(1);
72 }
25697a35
GS
73 strcpy(TiColor,buf);
74 fixnone(TiColor);
75 return;
76 }
77
78 if(strstr(buf,"logo_image") != 0) {
4bcb77cf
FM
79 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
80 printf("SARG: Maybe you have a broken record or garbage in logo_image parameter.\n");
81 exit(1);
82 }
25697a35
GS
83 strcpy(LogoImage,buf);
84 fixnone(LogoImage);
85 return;
86 }
87
88 if(strstr(buf,"logo_text") != 0) {
89 if(strstr(buf,"logo_text_color") == 0) {
4bcb77cf
FM
90 if (getword(wbuf,sizeof(wbuf),buf,'"')<0) {
91 printf("SARG: Maybe you have a broken record or garbage in logo_text parameter.\n");
92 exit(1);
93 }
94 if (getword(LogoText,sizeof(LogoText),buf,'"')<0) {
95 printf("SARG: Maybe you have a broken record or garbage in logo_text parameter.\n");
96 exit(1);
97 }
25697a35
GS
98 fixnone(LogoText);
99 return;
100 }
101 }
102
103 if(strstr(buf,"logo_text_color") != 0) {
4bcb77cf
FM
104 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
105 printf("SARG: Maybe you have a broken record or garbage in logo_text_color parameter.\n");
106 exit(1);
107 }
25697a35
GS
108 strcpy(LogoTextColor,buf);
109 fixnone(LogoTextColor);
110 return;
111 }
112
113 if(strstr(buf,"background_image") != 0) {
4bcb77cf
FM
114 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
115 printf("SARG: Maybe you have a broken record or garbage in background_image parameter.\n");
116 exit(1);
117 }
25697a35
GS
118 strcpy(BgImage,buf);
119 fixnone(BgImage);
120 return;
121 }
122
123 if(strstr(buf,"show_sarg_info") != 0) {
4bcb77cf
FM
124 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
125 printf("SARG: Maybe you have a broken record or garbage in show_sarg_info parameter.\n");
126 exit(1);
127 }
25697a35
GS
128 strcpy(ShowSargInfo,buf);
129 fixnone(ShowSargInfo);
130 return;
131 }
132
133 if(strstr(buf,"show_sarg_logo") != 0) {
4bcb77cf
FM
134 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
135 printf("SARG: Maybe you have a broken record or garbage in show_sarg_logo parameter.\n");
136 exit(1);
137 }
25697a35
GS
138 strcpy(ShowSargLogo,buf);
139 fixnone(ShowSargLogo);
140 return;
141 }
142
143 if(strstr(buf,"font_face") != 0) {
4bcb77cf
FM
144 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
145 printf("SARG: Maybe you have a broken record or garbage in font_face parameter.\n");
146 exit(1);
147 }
25697a35
GS
148 strcpy(FontFace,buf);
149 fixnone(FontFace);
150 return;
151 }
152
153 if(strstr(buf,"header_color") != 0) {
4bcb77cf
FM
154 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
155 printf("SARG: Maybe you have a broken record or garbage in header_color parameter.\n");
156 exit(1);
157 }
25697a35
GS
158 strcpy(HeaderColor,buf);
159 fixnone(HeaderColor);
160 return;
161 }
162
163 if(strstr(buf,"header_bgcolor") != 0) {
4bcb77cf
FM
164 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
165 printf("SARG: Maybe you have a broken record or garbage in header_bgcolor parameter.\n");
166 exit(1);
167 }
25697a35
GS
168 strcpy(HeaderBgColor,buf);
169 fixnone(HeaderBgColor);
170 return;
171 }
172
173 if(strstr(buf,"font_size") != 0) {
174 if(strstr(buf,"header_font_size") == 0 && strstr(buf,"title_font_size") == 0) {
4bcb77cf
FM
175 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
176 printf("SARG: Maybe you have a broken record or garbage in font_size parameter.\n");
177 exit(1);
178 }
25697a35
GS
179 strcpy(FontSize,buf);
180 fixnone(FontSize);
181 return;
182 }
183 }
184
185 if(strstr(buf,"header_font_size") != 0) {
4bcb77cf
FM
186 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
187 printf("SARG: Maybe you have a broken record or garbage in header_font_size parameter.\n");
188 exit(1);
189 }
25697a35
GS
190 strcpy(HeaderFontSize,buf);
191 fixnone(HeaderFontSize);
192 return;
193 }
194
195 if(strstr(buf,"title_font_size") != 0) {
4bcb77cf
FM
196 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
197 printf("SARG: Maybe you have a broken record or garbage in title_font_size parameter.\n");
198 exit(1);
199 }
25697a35
GS
200 strcpy(TitleFontSize,buf);
201 fixnone(TitleFontSize);
202 return;
203 }
204
205 if(strstr(buf,"image_size") != 0) {
4bcb77cf
FM
206 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0 || getword_multisep(Width,sizeof(Width),buf,' ')<0 || getword_multisep(Height,sizeof(Height),Height,0)<0) {
207 printf("SARG: Maybe you have a broken record or garbage in image_size parameter.\n");
208 exit(1);
209 }
25697a35
GS
210 fixnone(Width);
211 fixnone(Height);
212 return;
213 }
214
215 if(strstr(buf,"title") != 0) {
4bcb77cf
FM
216 if (getword(wbuf,sizeof(wbuf),buf,'"')<0 || getword(Title,sizeof(Title),buf,'"')<0) {
217 printf("SARG: Maybe you have a broken record or garbage in title parameter.\n");
218 exit(1);
219 }
25697a35
GS
220 fixnone(Title);
221 return;
222 }
223
224 if(strstr(buf,"resolve_ip") != 0) {
4bcb77cf
FM
225 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
226 printf("SARG: Maybe you have a broken record or garbage in resolve_ip parameter.\n");
227 exit(1);
228 }
25697a35
GS
229 strcpy(Ip2Name,buf);
230 fixnone(Ip2Name);
231 return;
232 }
233
234 if(strstr(buf,"user_ip") != 0) {
4bcb77cf
FM
235 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
236 printf("SARG: Maybe you have a broken record or garbage in user_ip parameter.\n");
237 exit(1);
238 }
25697a35
GS
239 strcpy(UserIp,buf);
240 fixnone(UserIp);
241 return;
242 }
243
244 if(strstr(buf,"max_elapsed") != 0) {
4bcb77cf
FM
245 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
246 printf("SARG: Maybe you have a broken record or garbage in max_elapsed parameter.\n");
247 exit(1);
248 }
25697a35
GS
249 strcpy(MaxElapsed,buf);
250 fixnone(MaxElapsed);
251 return;
252 }
253
254 if(strstr(buf,"date_format") != 0) {
4bcb77cf
FM
255 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
256 printf("SARG: Maybe you have a broken record or garbage in date_format parameter.\n");
257 exit(1);
258 }
d6e703cc 259 strncpy(DateFormat,buf,1);
25697a35
GS
260 fixnone(DateFormat);
261 return;
262 }
263
264 if( strstr( buf, "hours" ) != 0 ) {
265 if( getnumlist( buf, &hours, 24, 24 ) ) {
266 fprintf( stderr, "Error: Invalid syntax in hours tag!\n" );
267 exit( 1 );
268 }
269 }
270
271 if( strstr( buf, "weekdays" ) != 0 ) {
272 if( getnumlist( buf, &weekdays, 7, 7 ) ) {
273 fprintf( stderr, "Error: Invalid syntax in weekdays tag!\n" );
274 exit( 1 );
275 }
276 }
277
278 if(strstr(buf,"topuser_sort_field") != 0) {
4bcb77cf
FM
279 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0 || getword_multisep(TopuserSortField,sizeof(TopuserSortField),buf,' ')<0) {
280 printf("SARG: Maybe you have a broken record or garbage in topuser_sort_field parameter.\n");
281 exit(1);
282 }
25697a35
GS
283 strcpy(TopuserSortOrder,buf);
284 fixnone(TopuserSortOrder);
285 return;
286 }
287
288 if(strstr(buf,"user_sort_field") != 0) {
4bcb77cf
FM
289 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0 || getword_multisep(UserSortField,sizeof(UserSortField),buf,' ')<0) {
290 printf("SARG: Maybe you have a broken record or garbage in user_sort_field parameter.\n");
291 exit(1);
292 }
25697a35
GS
293 strcpy(UserSortOrder,buf);
294 fixnone(UserSortOrder);
295 return;
296 }
297
298 if(strstr(buf,"access_log") != 0) {
d6e703cc 299 if(strstr(buf,"realtime_access_log_lines") == 0) {
4bcb77cf
FM
300 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
301 printf("SARG: Maybe you have a broken record or garbage in access_log parameter.\n");
302 exit(1);
303 }
d6e703cc
FM
304 strcpy(AccessLog,buf);
305 fixnone(AccessLog);
306 return;
307 }
25697a35
GS
308 }
309
310 if(strstr(buf,"useragent_log") != 0) {
4bcb77cf
FM
311 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
312 printf("SARG: Maybe you have a broken record or garbage in useragent_log parameter.\n");
313 exit(1);
314 }
25697a35
GS
315 strcpy(UserAgentLog,buf);
316 fixnone(UserAgentLog);
317 return;
318 }
319
320 if(strstr(buf,"exclude_hosts") != 0) {
4bcb77cf
FM
321 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
322 printf("SARG: Maybe you have a broken record or garbage in exclude_hosts parameter.\n");
323 exit(1);
324 }
25697a35
GS
325 strcpy(ExcludeHosts,buf);
326 fixnone(ExcludeHosts);
327 return;
328 }
329
330 if(strstr(buf,"exclude_codes") != 0) {
4bcb77cf
FM
331 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
332 printf("SARG: Maybe you have a broken record or garbage in exclude_codes parameter.\n");
333 exit(1);
334 }
25697a35
GS
335 strcpy(ExcludeCodes,buf);
336 fixnone(ExcludeCodes);
337 return;
338 }
339
340 if(strstr(buf,"exclude_users") != 0) {
4bcb77cf
FM
341 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
342 printf("SARG: Maybe you have a broken record or garbage in exclude_users parameter.\n");
343 exit(1);
344 }
25697a35
GS
345 strcpy(ExcludeUsers,buf);
346 fixnone(ExcludeUsers);
347 return;
348 }
349
350 if(strstr(buf,"password") != 0) {
4bcb77cf
FM
351 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
352 printf("SARG: Maybe you have a broken record or garbage in password parameter.\n");
353 exit(1);
354 }
25697a35
GS
355 strcpy(PasswdFile,buf);
356 fixnone(PasswdFile);
357 return;
358 }
359
360 if(strstr(buf,"temporary_dir") != 0) {
4bcb77cf
FM
361 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
362 printf("SARG: Maybe you have a broken record or garbage in temporary_dir parameter.\n");
363 exit(1);
364 }
25697a35
GS
365 strcpy(TempDir,buf);
366 fixnone(TempDir);
367 return;
368 }
369
370 if(strstr(buf,"report_type") != 0) {
4bcb77cf
FM
371 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
372 printf("SARG: Maybe you have a broken record or garbage in report_type parameter.\n");
373 exit(1);
374 }
25697a35
GS
375 strcpy(ReportType,buf);
376 fixnone(ReportType);
377 return;
378 }
379
380 if(strstr(buf,"output_dir") != 0) {
381 if(strstr(buf,"output_dir_form") == 0) {
4bcb77cf
FM
382 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
383 printf("SARG: Maybe you have a broken record or garbage in output_dir parameter.\n");
384 exit(1);
385 }
25697a35
GS
386 strcpy(OutputDir,buf);
387 fixnone(OutputDir);
388 return;
389 }
390 }
391
392 if(strstr(buf,"output_email") != 0) {
4bcb77cf
FM
393 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
394 printf("SARG: Maybe you have a broken record or garbage in output_email parameter.\n");
395 exit(1);
396 }
25697a35
GS
397 strcpy(OutputEmail,buf);
398 fixnone(OutputEmail);
399 return;
400 }
401
402 if(strstr(buf,"per_user_limit") != 0) {
4bcb77cf
FM
403 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0 || getword_multisep(PerUserLimitFile,sizeof(PerUserLimitFile),buf,' ')<0) {
404 printf("SARG: Maybe you have a broken record or garbage in per_user_limit parameter.\n");
405 exit(1);
406 }
25697a35
GS
407 strcpy(PerUserLimit,buf);
408 fixnone(PerUserLimitFile);
409 fixnone(PerUserLimit);
410 return;
411 }
412
413
414 if(strstr(buf,"lastlog") != 0) {
4bcb77cf
FM
415 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
416 printf("SARG: Maybe you have a broken record or garbage in lastlog parameter.\n");
417 exit(1);
418 }
25697a35
GS
419 strcpy(LastLog,buf);
420 fixnone(LastLog);
421 return;
422 }
423
424 if(strstr(buf,"remove_temp_files") != 0) {
4bcb77cf
FM
425 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
426 printf("SARG: Maybe you have a broken record or garbage in remove_temp_files parameter.\n");
427 exit(1);
428 }
25697a35
GS
429 strcpy(RemoveTempFiles,buf);
430 fixnone(RemoveTempFiles);
431 return;
432 }
433
434 if(strstr(buf,"replace_index") != 0) {
4bcb77cf
FM
435 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
436 printf("SARG: Maybe you have a broken record or garbage in replace_index parameter.\n");
437 exit(1);
438 }
25697a35
GS
439 strcpy(ReplaceIndex,buf);
440 fixnone(ReplaceIndex);
441 return;
442 }
443
491b862f 444 if(strstr(buf,"index_tree") != 0) {
4bcb77cf
FM
445 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
446 printf("SARG: Maybe you have a broken record or garbage in index_tree parameter.\n");
447 exit(1);
448 }
491b862f
GS
449 strcpy(IndexTree,buf);
450 fixnone(IndexTree);
451 return;
452 }
453
25697a35
GS
454 if(strstr(buf,"index") != 0) {
455 if(strstr(buf,"index_sort_order") == 0) {
4bcb77cf
FM
456 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
457 printf("SARG: Maybe you have a broken record or garbage in index parameter.\n");
458 exit(1);
459 }
25697a35
GS
460 strcpy(Index,buf);
461 fixnone(Index);
462 return;
463 }
464 }
465
466 if(strstr(buf,"overwrite_report") != 0) {
4bcb77cf
FM
467 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
468 printf("SARG: Maybe you have a broken record or garbage in overwrite_report parameter.\n");
469 exit(1);
470 }
25697a35
GS
471 strcpy(OverwriteReport,buf);
472 fixnone(OverwriteReport);
473 return;
474 }
475
476 if(strstr(buf,"records_without_userid") != 0) {
4bcb77cf
FM
477 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
478 printf("SARG: Maybe you have a broken record or garbage in records_without_userid parameter.\n");
479 exit(1);
480 }
25697a35
GS
481 strcpy(RecordsWithoutUser,buf);
482 fixnone(RecordsWithoutUser);
483 return;
484 }
485
486 if(strstr(buf,"use_comma") != 0) {
4bcb77cf
FM
487 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
488 printf("SARG: Maybe you have a broken record or garbage in use_comma parameter.\n");
489 exit(1);
490 }
25697a35
GS
491 strcpy(UseComma,buf);
492 fixnone(UseComma);
493 return;
494 }
495
496 if(strstr(buf,"mail_utility") != 0) {
4bcb77cf
FM
497 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
498 printf("SARG: Maybe you have a broken record or garbage in mail_utility parameter.\n");
499 exit(1);
500 }
25697a35
GS
501 strcpy(MailUtility,buf);
502 fixnone(MailUtility);
503 return;
504 }
505
506 if(strstr(buf,"topsites_num") != 0) {
4bcb77cf
FM
507 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
508 printf("SARG: Maybe you have a broken record or garbage in topsites_num parameter.\n");
509 exit(1);
510 }
25697a35
GS
511 strcpy(TopSitesNum,buf);
512 fixnone(TopSitesNum);
513 return;
514 }
515
516 if(strstr(buf,"topuser_num") != 0) {
4bcb77cf
FM
517 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
518 printf("SARG: Maybe you have a broken record or garbage in topuser_num parameter.\n");
519 exit(1);
520 }
25697a35
GS
521 strcpy(TopUsersNum,buf);
522 fixnone(TopUsersNum);
523 return;
524 }
525
526 if(strstr(buf,"usertab") != 0) {
4bcb77cf
FM
527 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
528 printf("SARG: Maybe you have a broken record or garbage in usertab parameter.\n");
529 exit(1);
530 }
25697a35
GS
531 strcpy(UserTabFile,buf);
532 fixnone(UserTabFile);
533 return;
534 }
535
536 if(strstr(buf,"index_sort_order") != 0) {
4bcb77cf
FM
537 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
538 printf("SARG: Maybe you have a broken record or garbage in index_sort_order parameter.\n");
539 exit(1);
540 }
25697a35
GS
541 strcpy(IndexSortOrder,buf);
542 fixnone(IndexSortOrder);
543 return;
544 }
545
546 if(strstr(buf,"topsites_sort_order") != 0) {
4bcb77cf
FM
547 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0 || getword_multisep(TopsitesSortField,sizeof(TopsitesSortField),buf,' ')<0) {
548 printf("SARG: Maybe you have a broken record or garbage in topsites_sort_order parameter.\n");
549 exit(1);
550 }
25697a35
GS
551 strcpy(TopsitesSortType,buf);
552 fixnone(TopsitesSortField);
553 fixnone(TopsitesSortType);
554 return;
555 }
556
557 if(strstr(buf,"long_url") != 0) {
4bcb77cf
FM
558 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
559 printf("SARG: Maybe you have a broken record or garbage in long_url parameter.\n");
560 exit(1);
561 }
25697a35
GS
562 strcpy(LongUrl,buf);
563 fixnone(LongUrl);
564 return;
565 }
566
567 if(strstr(buf,"language") != 0) {
4bcb77cf
FM
568 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
569 printf("SARG: Maybe you have a broken record or garbage in language parameter.\n");
570 exit(1);
571 }
25697a35
GS
572 strcpy(language,buf);
573 fixnone(language);
574 return;
575 }
576
577 if(strstr(buf,"dansguardian_conf") != 0) {
4bcb77cf
FM
578 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
579 printf("SARG: Maybe you have a broken record or garbage in dansguardian_conf parameter.\n");
580 exit(1);
581 }
25697a35
GS
582 strcpy(DansGuardianConf,buf);
583 fixnone(DansGuardianConf);
584 return;
585 }
586
587 if(strstr(buf,"squidguard_conf") != 0) {
4bcb77cf
FM
588 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
589 printf("SARG: Maybe you have a broken record or garbage in squidguard_conf parameter.\n");
590 exit(1);
591 }
25697a35
GS
592 strcpy(SquidGuardConf,buf);
593 fixnone(SquidGuardConf);
594 return;
595 }
596
597 if(strstr(buf,"date_time_by") != 0) {
4bcb77cf
FM
598 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
599 printf("SARG: Maybe you have a broken record or garbage in date_time_by parameter.\n");
600 exit(1);
601 }
25697a35
GS
602 strcpy(datetimeby,buf);
603 fixnone(datetimeby);
604 return;
605 }
606
607 if(strstr(buf,"charset") != 0) {
4bcb77cf
FM
608 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
609 printf("SARG: Maybe you have a broken record or garbage in charset parameter.\n");
610 exit(1);
611 }
25697a35
GS
612 strcpy(CharSet,buf);
613 fixnone(CharSet);
614 ccharset(CharSet);
615 return;
616 }
617
618 if(strstr(buf,"user_invalid_char") != 0) {
4bcb77cf
FM
619 if (getword_multisep(wbuf,sizeof(wbuf),buf,'"')<0 || getword_multisep(UserInvalidChar,sizeof(UserInvalidChar),buf,'"')<0) {
620 printf("SARG: Maybe you have a broken record or garbage in user_invalid_char parameter.\n");
621 exit(1);
622 }
25697a35
GS
623 fixnone(UserInvalidChar);
624 return;
625 }
626
627 if(strstr(buf,"include_users") != 0) {
4bcb77cf
FM
628 if (getword_multisep(wbuf,sizeof(wbuf),buf,'"')<0 || getword_multisep(wbuf,sizeof(wbuf),buf,'"')<0) {
629 printf("SARG: Maybe you have a broken record or garbage in include_users parameter.\n");
630 exit(1);
631 }
25697a35
GS
632 sprintf(IncludeUsers,":%s:",wbuf);
633 fixnone(IncludeUsers);
634 return;
635 }
636
637 if(strstr(buf,"exclude_string") != 0) {
4bcb77cf
FM
638 if (getword_multisep(wbuf,sizeof(wbuf),buf,'"')<0 || getword_multisep(ExcludeString,sizeof(ExcludeString),buf,'"')<0) {
639 printf("SARG: Maybe you have a broken record or garbage in exclude_string parameter.\n");
640 exit(1);
641 }
25697a35
GS
642 fixnone(ExcludeString);
643 return;
644 }
645
646 if(strstr(buf,"privacy") != 0) {
647 if(strstr(buf,"privacy_string") == 0 && \
648 strstr(buf,"privacy_string_color") == 0) {
4bcb77cf
FM
649 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
650 printf("SARG: Maybe you have a broken record or garbage in privacy parameter.\n");
651 exit(1);
652 }
25697a35
GS
653 strcpy(Privacy,buf);
654 fixnone(Privacy);
655 return;
656 }
657 }
658
659 if(strstr(buf,"privacy_string") != 0) {
660 if(strstr(buf,"privacy_string_color") == 0) {
4bcb77cf
FM
661 if (getword_multisep(wbuf,sizeof(wbuf),buf,'"')<0 || getword_multisep(PrivacyString,sizeof(PrivacyString),buf,'"')<0) {
662 printf("SARG: Maybe you have a broken record or garbage in privacy_string parameter.\n");
663 exit(1);
664 }
25697a35
GS
665 fixnone(PrivacyString);
666 return;
667 }
668 }
669
670 if(strstr(buf,"privacy_string_color") != 0) {
4bcb77cf
FM
671 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
672 printf("SARG: Maybe you have a broken record or garbage in privacy_string_color parameter.\n");
673 exit(1);
674 }
25697a35
GS
675 strcpy(PrivacyStringColor,buf);
676 fixnone(PrivacyStringColor);
677 return;
678 }
679
680 if(strstr(buf,"show_successful_message") != 0) {
4bcb77cf
FM
681 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
682 printf("SARG: Maybe you have a broken record or garbage in show_successful_message parameter.\n");
683 exit(1);
684 }
25697a35
GS
685 strcpy(SuccessfulMsg,buf);
686 fixnone(SuccessfulMsg);
687 return;
688 }
689
690 if(strstr(buf,"show_read_statistics") != 0) {
4bcb77cf
FM
691 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
692 printf("SARG: Maybe you have a broken record or garbage in show_read_statistics parameter.\n");
693 exit(1);
694 }
25697a35
GS
695 strcpy(ShowReadStatistics,buf);
696 fixnone(ShowReadStatistics);
697 return;
698 }
699
700 if(strstr(buf,"topuser_fields") != 0) {
4bcb77cf
FM
701 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
702 printf("SARG: Maybe you have a broken record or garbage in topuser_fields parameter.\n");
703 exit(1);
704 }
25697a35
GS
705 strcpy(TopUserFields,buf);
706 fixnone(TopUserFields);
707 return;
708 }
709
d6e703cc 710 if(strstr(buf,"bytes_in_sites_users_report") != 0) {
4bcb77cf
FM
711 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
712 printf("SARG: Maybe you have a broken record or garbage in bytes_in_sites_users_report parameter.\n");
713 exit(1);
714 }
d6e703cc
FM
715 strcpy(BytesInSitesUsersReport,buf);
716 fixnone(BytesInSitesUsersReport);
717 return;
718 }
719
25697a35 720 if(strstr(buf,"user_report_fields") != 0) {
4bcb77cf
FM
721 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
722 printf("SARG: Maybe you have a broken record or garbage in user_report_fields parameter.\n");
723 exit(1);
724 }
25697a35
GS
725 strcpy(UserReportFields,buf);
726 fixnone(UserReportFields);
727 return;
728 }
729
d6e703cc 730 if(strstr(buf,"bytes_in_sites_users_report") != 0) {
4bcb77cf
FM
731 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
732 printf("SARG: Maybe you have a broken record or garbage in site_user_time_date_type parameter.\n");
733 exit(1);
734 }
d6e703cc
FM
735 strcpy(BytesInSitesUsersReport,buf);
736 fixnone(BytesInSitesUsersReport);
25697a35
GS
737 return;
738 }
739
740 if(strstr(buf,"datafile ") != 0) {
4bcb77cf
FM
741 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
742 printf("SARG: Maybe you have a broken record or garbage in datafile parameter.\n");
743 exit(1);
744 }
25697a35
GS
745 strcpy(DataFile,buf);
746 fixnone(DataFile);
747 return;
748 }
749
750 if(strstr(buf,"datafile_delimiter") != 0) {
4bcb77cf
FM
751 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0 || getword(wbuf,sizeof(wbuf),buf,'"')<0 ||
752 getword(DataFileDelimiter,sizeof(DataFileDelimiter),buf,'"')<0) {
753 printf("SARG: Maybe you have a broken record or garbage in datafile_delimiter parameter.\n");
754 exit(1);
755 }
25697a35
GS
756 fixnone(DataFileDelimiter);
757 return;
758 }
759
760 if(strstr(buf,"datafile_fields") != 0) {
4bcb77cf
FM
761 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
762 printf("SARG: Maybe you have a broken record or garbage in datafile_fields parameter.\n");
763 exit(1);
764 }
25697a35
GS
765 strcpy(DataFileFields,buf);
766 fixnone(DataFileFields);
767 return;
768 }
769
491b862f 770 if(strstr(buf,"datafile_url") != 0) {
4bcb77cf
FM
771 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
772 printf("SARG: Maybe you have a broken record or garbage in datafile_url parameter.\n");
773 exit(1);
774 }
491b862f
GS
775 strcpy(DataFileUrl,buf);
776 fixnone(DataFileUrl);
777 return;
778 }
779
25697a35
GS
780 if(strstr(buf,"parsed_output_log") != 0) {
781 if(strstr(buf,"parsed_output_log_compress") == 0) {
4bcb77cf
FM
782 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
783 printf("SARG: Maybe you have a broken record or garbage in parsed_output_log parameter.\n");
784 exit(1);
785 }
25697a35
GS
786 strcpy(ParsedOutputLog,buf);
787 fixnone(ParsedOutputLog);
788 return;
789 }
790 }
791
792 if(strstr(buf,"parsed_output_log_compress") != 0) {
4bcb77cf
FM
793 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
794 printf("SARG: Maybe you have a broken record or garbage in parsed_output_log_compress parameter.\n");
795 exit(1);
796 }
25697a35
GS
797 strcpy(ParsedOutputLogCompress,buf);
798 fixnone(ParsedOutputLogCompress);
799 return;
800 }
801
802 if(strstr(buf,"displayed_values") != 0) {
4bcb77cf
FM
803 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
804 printf("SARG: Maybe you have a broken record or garbage in displayed_values parameter.\n");
805 exit(1);
806 }
25697a35
GS
807 strcpy(DisplayedValues,buf);
808 fixnone(DisplayedValues);
809 return;
810 }
811
812 if(strstr(buf,"authfail_report_limit") != 0) {
4bcb77cf
FM
813 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
814 printf("SARG: Maybe you have a broken record or garbage in authfail_report_limit parameter.\n");
815 exit(1);
816 }
25697a35
GS
817 AuthfailReportLimit=atoi(buf);
818 return;
819 }
820
821 if(strstr(buf,"denied_report_limit") != 0) {
4bcb77cf
FM
822 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
823 printf("SARG: Maybe you have a broken record or garbage in denied_report_limit parameter.\n");
824 exit(1);
825 }
25697a35
GS
826 DeniedReportLimit=atoi(buf);
827 return;
828 }
829
830 if(strstr(buf,"siteusers_report_limit") != 0) {
4bcb77cf
FM
831 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
832 printf("SARG: Maybe you have a broken record or garbage in siteusers_report_limit parameter.\n");
833 exit(1);
834 }
25697a35
GS
835 SiteUsersReportLimit=atoi(buf);
836 return;
837 }
838
839 if(strstr(buf,"dansguardian_report_limit") != 0) {
4bcb77cf
FM
840 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
841 printf("SARG: Maybe you have a broken record or garbage in dansguardian_report_limit parameter.\n");
842 exit(1);
843 }
25697a35
GS
844 DansGuardianReportLimit=atoi(buf);
845 return;
846 }
847
848 if(strstr(buf,"squidguard_report_limit") != 0) {
4bcb77cf
FM
849 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
850 printf("SARG: Maybe you have a broken record or garbage in squidguard_report_limit parameter.\n");
851 exit(1);
852 }
25697a35
GS
853 SquidGuardReportLimit=atoi(buf);
854 return;
855 }
856
857 if(strstr(buf,"user_report_limit") != 0) {
4bcb77cf
FM
858 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
859 printf("SARG: Maybe you have a broken record or garbage in user_report_limit parameter.\n");
860 exit(1);
861 }
25697a35
GS
862 UserReportLimit=atoi(buf);
863 return;
864 }
865
94ff9470 866 if(strstr(buf,"download_report_limit") != 0) {
4bcb77cf
FM
867 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
868 printf("SARG: Maybe you have a broken record or garbage in download_report_limit parameter.\n");
869 exit(1);
870 }
94ff9470
GS
871 DownloadReportLimit=atoi(buf);
872 return;
873 }
874
25697a35 875 if(strstr(buf,"www_document_root") != 0) {
4bcb77cf
FM
876 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
877 printf("SARG: Maybe you have a broken record or garbage in www_document_root parameter.\n");
878 exit(1);
879 }
25697a35
GS
880 strcpy(wwwDocumentRoot,buf);
881 fixnone(wwwDocumentRoot);
882 return;
883 }
884
885 if(strstr(buf,"block_it") != 0) {
4bcb77cf
FM
886 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
887 printf("SARG: Maybe you have a broken record or garbage in block_it parameter.\n");
888 exit(1);
889 }
25697a35
GS
890 strcpy(BlockIt,buf);
891 fixnone(BlockIt);
892 return;
893 }
894
895 if(strstr(buf,"external_css_file") != 0) {
4bcb77cf
FM
896 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
897 printf("SARG: Maybe you have a broken record or garbage in external_css_file parameter.\n");
898 exit(1);
899 }
25697a35
GS
900 strcpy(ExternalCSSFile,buf);
901 fixnone(ExternalCSSFile);
902 return;
903 }
904
905 if(strstr(buf,"user_authentication") != 0) {
4bcb77cf
FM
906 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
907 printf("SARG: Maybe you have a broken record or garbage in user_authentication parameter.\n");
908 exit(1);
909 }
25697a35
GS
910 strcpy(UserAuthentication,buf);
911 fixnone(UserAuthentication);
912 return;
913 }
914
915 if(strstr(buf,"AuthUserFile") != 0) {
4bcb77cf
FM
916 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
917 printf("SARG: Maybe you have a broken record or garbage in AuthUserFile parameter.\n");
918 exit(1);
919 }
25697a35
GS
920 strcpy(AuthUserFile,buf);
921 fixnone(AuthUserFile);
922 return;
923 }
924
925 if(strstr(buf,"AuthName") != 0) {
4bcb77cf
FM
926 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
927 printf("SARG: Maybe you have a broken record or garbage in AuthName parameter.\n");
928 exit(1);
929 }
25697a35
GS
930 strcpy(AuthName,buf);
931 fixnone(AuthName);
932 return;
933 }
934
935 if(strstr(buf,"AuthType") != 0) {
4bcb77cf
FM
936 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
937 printf("SARG: Maybe you have a broken record or garbage in AuthType parameter.\n");
938 exit(1);
939 }
25697a35
GS
940 strcpy(AuthType,buf);
941 fixnone(AuthType);
942 return;
943 }
944
945 if(strstr(buf,"Require") != 0) {
4bcb77cf
FM
946 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
947 printf("SARG: Maybe you have a broken record or garbage in Require parameter.\n");
948 exit(1);
949 }
25697a35
GS
950 strcpy(Require,buf);
951 fixnone(Require);
952 return;
953 }
954
955 if(strstr(buf,"download_suffix") != 0) {
4bcb77cf
FM
956 if (getword_multisep(wbuf,sizeof(wbuf),buf,'"')<0 || getword_multisep(DownloadSuffix,sizeof(DownloadSuffix),buf,'"')<0) {
957 printf("SARG: Maybe you have a broken record or garbage in download_suffix parameter.\n");
958 exit(1);
959 }
25697a35
GS
960 fixnone(DownloadSuffix);
961 return;
962 }
963
964 if(strstr(buf,"graphs") != 0) {
4bcb77cf
FM
965 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
966 printf("SARG: Maybe you have a broken record or garbage in graphs parameter.\n");
967 exit(1);
968 }
25697a35
GS
969 strcpy(Graphs,buf);
970 fixnone(Graphs);
971 return;
972 }
973
974 if(strstr(buf,"graph_days_bytes_bar_color") != 0) {
4bcb77cf
FM
975 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
976 printf("SARG: Maybe you have a broken record or garbage in graph_days_bytes_bar_color parameter.\n");
977 exit(1);
978 }
25697a35
GS
979 strcpy(GraphDaysBytesBarColor,buf);
980 fixnone(GraphDaysBytesBarColor);
981 return;
982 }
983
984 if(strstr(buf,"squidguard_log_format") != 0) {
4bcb77cf
FM
985 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
986 printf("SARG: Maybe you have a broken record or garbage in squidguard_log_format parameter.\n");
987 exit(1);
988 }
25697a35
GS
989 strcpy(SquidGuardLogFormat,buf);
990 fixnone(SquidGuardLogFormat);
991 return;
992 }
993
491b862f 994 if(strstr(buf,"squidguard_ignore_date") != 0) {
4bcb77cf
FM
995 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
996 printf("SARG: Maybe you have a broken record or garbage in squidguard_ignore_date parameter.\n");
997 exit(1);
998 }
491b862f
GS
999 strcpy(SquidguardIgnoreDate,buf);
1000 fixnone(SquidguardIgnoreDate);
1001 return;
1002 }
1003
1004 if(strstr(buf,"dansguardian_ignore_date") != 0) {
4bcb77cf
FM
1005 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
1006 printf("SARG: Maybe you have a broken record or garbage in dansguardian_ignore_date parameter.\n");
1007 exit(1);
1008 }
491b862f
GS
1009 strcpy(DansguardianIgnoreDate,buf);
1010 fixnone(DansguardianIgnoreDate);
1011 return;
1012 }
1013
25697a35 1014 if(strstr(buf,"ulimit") != 0) {
4bcb77cf
FM
1015 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
1016 printf("SARG: Maybe you have a broken record or garbage in ulimit parameter.\n");
1017 exit(1);
1018 }
25697a35
GS
1019 strcpy(Ulimit,buf);
1020 fixnone(Ulimit);
1021 return;
1022 }
1023
1024 if(strstr(buf,"ntlm_user_format") != 0) {
4bcb77cf
FM
1025 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
1026 printf("SARG: Maybe you have a broken record or garbage in ntlm_user_format parameter.\n");
1027 exit(1);
1028 }
25697a35
GS
1029 strcpy(NtlmUserFormat,buf);
1030 fixnone(NtlmUserFormat);
1031 return;
1032 }
491b862f
GS
1033
1034 if(strstr(buf,"realtime_types") != 0) {
4bcb77cf
FM
1035 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
1036 printf("SARG: Maybe you have a broken record or garbage in realtime_types parameter.\n");
1037 exit(1);
1038 }
491b862f
GS
1039 strcpy(RealtimeTypes,buf);
1040 fixnone(RealtimeTypes);
1041 return;
1042 }
1043
1044 if(strstr(buf,"realtime_unauthenticated_records") != 0) {
4bcb77cf
FM
1045 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
1046 printf("SARG: Maybe you have a broken record or garbage in realtime_unauthenticated_records parameter.\n");
1047 exit(1);
1048 }
491b862f
GS
1049 strcpy(RealtimeUnauthRec,buf);
1050 fixnone(RealtimeUnauthRec);
1051 return;
1052 }
1053
1054 if(strstr(buf,"realtime_refresh_time") != 0) {
4bcb77cf
FM
1055 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
1056 printf("SARG: Maybe you have a broken record or garbage in realtime_refresh_time parameter.\n");
1057 exit(1);
1058 }
491b862f
GS
1059 realtime_refresh=atoi(buf);
1060 return;
1061 }
1062
1063 if(strstr(buf,"realtime_access_log_lines") != 0) {
4bcb77cf
FM
1064 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
1065 printf("SARG: Maybe you have a broken record or garbage in realtime_access_log_lines parameter.\n");
1066 exit(1);
1067 }
491b862f
GS
1068 realtime_access_log_lines=atoi(buf);
1069 return;
1070 }
1071
d6e703cc
FM
1072 if(strstr(buf,"squid24") != 0) {
1073 squid24++;
1074 return;
1075 }
1076
491b862f 1077 if(strstr(buf,"byte_cost") != 0) {
4bcb77cf
FM
1078 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
1079 printf("SARG: Maybe you have a broken record or garbage in byte_cost parameter.\n");
1080 exit(1);
1081 }
491b862f 1082 cost=atol(buf);
4bcb77cf
FM
1083 if (getword_multisep(wbuf,sizeof(wbuf),buf,' ')<0) {
1084 printf("SARG: Maybe you have a broken record or garbage in byte_cost parameter.\n");
1085 exit(1);
1086 }
491b862f
GS
1087 nocost=my_atoll(buf);
1088 return;
1089 }
d6e703cc
FM
1090}
1091
32e71fa4 1092void getconf(void)
d6e703cc
FM
1093{
1094
1095 FILE *fp_in;
1096 char buf[MAXLEN];
1097
1098 if(debug) {
1099 sprintf(Msg,"Loading configuration from: %s",ConfigFile);
1100 debuga(Msg);
1101 }
1102
1103 if ((fp_in = fopen(ConfigFile, "r")) == NULL) {
1104 fprintf(stderr, "SARG: (getconf) Cannot open file: %s\n",ConfigFile);
1105 exit(1);
1106 }
1107
1108 while (fgets(buf, MAXLEN, fp_in) != NULL) {
1109 if(strstr(buf,"\n") != 0)
1110 buf[strlen(buf)-1]='\0';
1111
1112 if(debugm)
1113 printf("SYSCONFDIR %s",buf);
1114
1115 if(strncmp(buf,"#",1) == 0 || strlen(buf) < 1)
1116 continue;
1117
1118 if(debugz)
1119 printf("SARG: TAG: %s\n",buf);
1120
1121 parmtest(buf);
1122
1123 }
1124
1125 fclose(fp_in);
1126 language_load(language);
1127 return;
25697a35 1128}