]> git.ipfire.org Git - thirdparty/sarg.git/blame - getconf.c
Imported sarg 2.0.9
[thirdparty/sarg.git] / getconf.c
CommitLineData
25697a35 1/*
94ff9470 2 * AUTHOR: Pedro Lineu Orso orso@penguintech.com.br
25697a35 3 * 1998, 2005
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
33void getconf()
34{
35
36 FILE *fp_in;
37 char buf[MAXLEN];
38
39 if(debug) {
40 sprintf(Msg,"Loading configuration from: %s",ConfigFile);
41 debuga(Msg);
42 }
43
44 if ((fp_in = fopen(ConfigFile, "r")) == NULL) {
45 fprintf(stderr, "SARG: (getconf) Cannot open file: %s\n",ConfigFile);
46 exit(1);
47 }
48
49 while (fgets(buf, MAXLEN, fp_in) != NULL) {
50 if(strstr(buf,"\n") != 0)
51 buf[strlen(buf)-1]='\n';
52
53 if(debugm)
54 printf("SYSCONFDIR %s",buf);
55
56 if(strncmp(buf,"#",1) == 0)
57 continue;
58
59 parmtest(buf);
60
61 }
62
63 fclose(fp_in);
64 language_load(language);
65 return;
66}
67
68
69int parmtest(char *buf)
70{
71
72 if(strstr(buf,"background_color") != 0) {
73 getword(wbuf,buf,' ');
74 strcpy(BgColor,buf);
75 fixnone(BgColor);
76 return;
77 }
78
79 if(strstr(buf,"text_color") != 0) {
80 if(strstr(buf,"logo_text_color") == 0) {
81 getword(wbuf,buf,' ');
82 strcpy(TxColor,buf);
83 fixnone(TxColor);
84 return;
85 }
86 }
87
88 if(strstr(buf,"text_bgcolor") != 0) {
89 getword(wbuf,buf,' ');
90 strcpy(TxBgColor,buf);
91 fixnone(TxBgColor);
92 return;
93 }
94
95 if(strstr(buf,"title_color") != 0) {
96 getword(wbuf,buf,' ');
97 strcpy(TiColor,buf);
98 fixnone(TiColor);
99 return;
100 }
101
102 if(strstr(buf,"logo_image") != 0) {
103 getword(wbuf,buf,' ');
104 strcpy(LogoImage,buf);
105 fixnone(LogoImage);
106 return;
107 }
108
109 if(strstr(buf,"logo_text") != 0) {
110 if(strstr(buf,"logo_text_color") == 0) {
111 getword(wbuf,buf,'"');
112 getword(LogoText,buf,'"');
113 fixnone(LogoText);
114 return;
115 }
116 }
117
118 if(strstr(buf,"logo_text_color") != 0) {
119 getword(wbuf,buf,' ');
120 strcpy(LogoTextColor,buf);
121 fixnone(LogoTextColor);
122 return;
123 }
124
125 if(strstr(buf,"background_image") != 0) {
126 getword(wbuf,buf,' ');
127 strcpy(BgImage,buf);
128 fixnone(BgImage);
129 return;
130 }
131
132 if(strstr(buf,"show_sarg_info") != 0) {
133 getword(wbuf,buf,' ');
134 strcpy(ShowSargInfo,buf);
135 fixnone(ShowSargInfo);
136 return;
137 }
138
139 if(strstr(buf,"show_sarg_logo") != 0) {
140 getword(wbuf,buf,' ');
141 strcpy(ShowSargLogo,buf);
142 fixnone(ShowSargLogo);
143 return;
144 }
145
146 if(strstr(buf,"font_face") != 0) {
147 getword(wbuf,buf,' ');
148 strcpy(FontFace,buf);
149 fixnone(FontFace);
150 return;
151 }
152
153 if(strstr(buf,"header_color") != 0) {
154 getword(wbuf,buf,' ');
155 strcpy(HeaderColor,buf);
156 fixnone(HeaderColor);
157 return;
158 }
159
160 if(strstr(buf,"header_bgcolor") != 0) {
161 getword(wbuf,buf,' ');
162 strcpy(HeaderBgColor,buf);
163 fixnone(HeaderBgColor);
164 return;
165 }
166
167 if(strstr(buf,"font_size") != 0) {
168 if(strstr(buf,"header_font_size") == 0 && strstr(buf,"title_font_size") == 0) {
169 getword(wbuf,buf,' ');
170 strcpy(FontSize,buf);
171 fixnone(FontSize);
172 return;
173 }
174 }
175
176 if(strstr(buf,"header_font_size") != 0) {
177 getword(wbuf,buf,' ');
178 strcpy(HeaderFontSize,buf);
179 fixnone(HeaderFontSize);
180 return;
181 }
182
183 if(strstr(buf,"title_font_size") != 0) {
184 getword(wbuf,buf,' ');
185 strcpy(TitleFontSize,buf);
186 fixnone(TitleFontSize);
187 return;
188 }
189
190 if(strstr(buf,"image_size") != 0) {
191 getword(wbuf,buf,' ');
192 getword(Width,buf,' ');
193 strcpy(Height,buf);
194 fixnone(Width);
195 fixnone(Height);
196 return;
197 }
198
199 if(strstr(buf,"title") != 0) {
200 getword(wbuf,buf,'"');
201 getword(Title,buf,'"');
202 fixnone(Title);
203 return;
204 }
205
206 if(strstr(buf,"resolve_ip") != 0) {
207 getword(wbuf,buf,' ');
208 strcpy(Ip2Name,buf);
209 fixnone(Ip2Name);
210 return;
211 }
212
213 if(strstr(buf,"user_ip") != 0) {
214 getword(wbuf,buf,' ');
215 strcpy(UserIp,buf);
216 fixnone(UserIp);
217 return;
218 }
219
220 if(strstr(buf,"max_elapsed") != 0) {
221 getword(wbuf,buf,' ');
222 strcpy(MaxElapsed,buf);
223 fixnone(MaxElapsed);
224 return;
225 }
226
227 if(strstr(buf,"date_format") != 0) {
228 getword(wbuf,buf,' ');
229 strcpy(DateFormat,buf);
230 fixnone(DateFormat);
231 return;
232 }
233
234 if( strstr( buf, "hours" ) != 0 ) {
235 if( getnumlist( buf, &hours, 24, 24 ) ) {
236 fprintf( stderr, "Error: Invalid syntax in hours tag!\n" );
237 exit( 1 );
238 }
239 }
240
241 if( strstr( buf, "weekdays" ) != 0 ) {
242 if( getnumlist( buf, &weekdays, 7, 7 ) ) {
243 fprintf( stderr, "Error: Invalid syntax in weekdays tag!\n" );
244 exit( 1 );
245 }
246 }
247
248 if(strstr(buf,"topuser_sort_field") != 0) {
249 getword(wbuf,buf,' ');
250 getword(TopuserSortField,buf,' ');
251 strcpy(TopuserSortOrder,buf);
252 fixnone(TopuserSortOrder);
253 return;
254 }
255
256 if(strstr(buf,"user_sort_field") != 0) {
257 getword(wbuf,buf,' ');
258 getword(UserSortField,buf,' ');
259 strcpy(UserSortOrder,buf);
260 fixnone(UserSortOrder);
261 return;
262 }
263
264 if(strstr(buf,"access_log") != 0) {
265 getword(wbuf,buf,' ');
266 strcpy(AccessLog,buf);
267 fixnone(AccessLog);
268 return;
269 }
270
271 if(strstr(buf,"useragent_log") != 0) {
272 getword(wbuf,buf,' ');
273 strcpy(UserAgentLog,buf);
274 fixnone(UserAgentLog);
275 return;
276 }
277
278 if(strstr(buf,"exclude_hosts") != 0) {
279 getword(wbuf,buf,' ');
280 strcpy(ExcludeHosts,buf);
281 fixnone(ExcludeHosts);
282 return;
283 }
284
285 if(strstr(buf,"exclude_codes") != 0) {
286 getword(wbuf,buf,' ');
287 strcpy(ExcludeCodes,buf);
288 fixnone(ExcludeCodes);
289 return;
290 }
291
292 if(strstr(buf,"exclude_users") != 0) {
293 getword(wbuf,buf,' ');
294 strcpy(ExcludeUsers,buf);
295 fixnone(ExcludeUsers);
296 return;
297 }
298
299 if(strstr(buf,"password") != 0) {
300 getword(wbuf,buf,' ');
301 strcpy(PasswdFile,buf);
302 fixnone(PasswdFile);
303 return;
304 }
305
306 if(strstr(buf,"temporary_dir") != 0) {
307 getword(wbuf,buf,' ');
308 strcpy(TempDir,buf);
309 fixnone(TempDir);
310 return;
311 }
312
313 if(strstr(buf,"report_type") != 0) {
314 getword(wbuf,buf,' ');
315 strcpy(ReportType,buf);
316 fixnone(ReportType);
317 return;
318 }
319
320 if(strstr(buf,"output_dir") != 0) {
321 if(strstr(buf,"output_dir_form") == 0) {
322 getword(wbuf,buf,' ');
323 strcpy(OutputDir,buf);
324 fixnone(OutputDir);
325 return;
326 }
327 }
328
329 if(strstr(buf,"output_email") != 0) {
330 getword(wbuf,buf,' ');
331 strcpy(OutputEmail,buf);
332 fixnone(OutputEmail);
333 return;
334 }
335
336 if(strstr(buf,"per_user_limit") != 0) {
337 getword(wbuf,buf,' ');
338 getword(PerUserLimitFile,buf,' ');
339 strcpy(PerUserLimit,buf);
340 fixnone(PerUserLimitFile);
341 fixnone(PerUserLimit);
342 return;
343 }
344
345
346 if(strstr(buf,"lastlog") != 0) {
347 getword(wbuf,buf,' ');
348 strcpy(LastLog,buf);
349 fixnone(LastLog);
350 return;
351 }
352
353 if(strstr(buf,"remove_temp_files") != 0) {
354 getword(wbuf,buf,' ');
355 strcpy(RemoveTempFiles,buf);
356 fixnone(RemoveTempFiles);
357 return;
358 }
359
360 if(strstr(buf,"replace_index") != 0) {
361 getword(wbuf,buf,' ');
362 strcpy(ReplaceIndex,buf);
363 fixnone(ReplaceIndex);
364 return;
365 }
366
367 if(strstr(buf,"index") != 0) {
368 if(strstr(buf,"index_sort_order") == 0) {
369 getword(wbuf,buf,' ');
370 strcpy(Index,buf);
371 fixnone(Index);
372 return;
373 }
374 }
375
376 if(strstr(buf,"overwrite_report") != 0) {
377 getword(wbuf,buf,' ');
378 strcpy(OverwriteReport,buf);
379 fixnone(OverwriteReport);
380 return;
381 }
382
383 if(strstr(buf,"records_without_userid") != 0) {
384 getword(wbuf,buf,' ');
385 strcpy(RecordsWithoutUser,buf);
386 fixnone(RecordsWithoutUser);
387 return;
388 }
389
390 if(strstr(buf,"use_comma") != 0) {
391 getword(wbuf,buf,' ');
392 strcpy(UseComma,buf);
393 fixnone(UseComma);
394 return;
395 }
396
397 if(strstr(buf,"mail_utility") != 0) {
398 getword(wbuf,buf,' ');
399 strcpy(MailUtility,buf);
400 fixnone(MailUtility);
401 return;
402 }
403
404 if(strstr(buf,"topsites_num") != 0) {
405 getword(wbuf,buf,' ');
406 strcpy(TopSitesNum,buf);
407 fixnone(TopSitesNum);
408 return;
409 }
410
411 if(strstr(buf,"topuser_num") != 0) {
412 getword(wbuf,buf,' ');
413 strcpy(TopUsersNum,buf);
414 fixnone(TopUsersNum);
415 return;
416 }
417
418 if(strstr(buf,"usertab") != 0) {
419 getword(wbuf,buf,' ');
420 strcpy(UserTabFile,buf);
421 fixnone(UserTabFile);
422 return;
423 }
424
425 if(strstr(buf,"index_sort_order") != 0) {
426 getword(wbuf,buf,' ');
427 strcpy(IndexSortOrder,buf);
428 fixnone(IndexSortOrder);
429 return;
430 }
431
432 if(strstr(buf,"topsites_sort_order") != 0) {
433 getword(wbuf,buf,' ');
434 getword(TopsitesSortField,buf,' ');
435 strcpy(TopsitesSortType,buf);
436 fixnone(TopsitesSortField);
437 fixnone(TopsitesSortType);
438 return;
439 }
440
441 if(strstr(buf,"long_url") != 0) {
442 getword(wbuf,buf,' ');
443 strcpy(LongUrl,buf);
444 fixnone(LongUrl);
445 return;
446 }
447
448 if(strstr(buf,"language") != 0) {
449 getword(wbuf,buf,' ');
450 strcpy(language,buf);
451 fixnone(language);
452 return;
453 }
454
455 if(strstr(buf,"dansguardian_conf") != 0) {
456 getword(wbuf,buf,' ');
457 strcpy(DansGuardianConf,buf);
458 fixnone(DansGuardianConf);
459 return;
460 }
461
462 if(strstr(buf,"squidguard_conf") != 0) {
463 getword(wbuf,buf,' ');
464 strcpy(SquidGuardConf,buf);
465 fixnone(SquidGuardConf);
466 return;
467 }
468
469 if(strstr(buf,"date_time_by") != 0) {
470 getword(wbuf,buf,' ');
471 strcpy(datetimeby,buf);
472 fixnone(datetimeby);
473 return;
474 }
475
476 if(strstr(buf,"charset") != 0) {
477 getword(wbuf,buf,' ');
478 strcpy(CharSet,buf);
479 fixnone(CharSet);
480 ccharset(CharSet);
481 return;
482 }
483
484 if(strstr(buf,"user_invalid_char") != 0) {
485 getword(wbuf,buf,'"');
486 getword(UserInvalidChar,buf,'"');
487 fixnone(UserInvalidChar);
488 return;
489 }
490
491 if(strstr(buf,"include_users") != 0) {
492 getword(wbuf,buf,'"');
493 getword(wbuf,buf,'"');
494 sprintf(IncludeUsers,":%s:",wbuf);
495 fixnone(IncludeUsers);
496 return;
497 }
498
499 if(strstr(buf,"exclude_string") != 0) {
500 getword(wbuf,buf,'"');
501 getword(ExcludeString,buf,'"');
502 fixnone(ExcludeString);
503 return;
504 }
505
506 if(strstr(buf,"privacy") != 0) {
507 if(strstr(buf,"privacy_string") == 0 && \
508 strstr(buf,"privacy_string_color") == 0) {
509 getword(wbuf,buf,' ');
510 strcpy(Privacy,buf);
511 fixnone(Privacy);
512 return;
513 }
514 }
515
516 if(strstr(buf,"privacy_string") != 0) {
517 if(strstr(buf,"privacy_string_color") == 0) {
518 getword(wbuf,buf,'"');
519 getword(PrivacyString,buf,'"');
520 fixnone(PrivacyString);
521 return;
522 }
523 }
524
525 if(strstr(buf,"privacy_string_color") != 0) {
526 getword(wbuf,buf,' ');
527 strcpy(PrivacyStringColor,buf);
528 fixnone(PrivacyStringColor);
529 return;
530 }
531
532 if(strstr(buf,"show_successful_message") != 0) {
533 getword(wbuf,buf,' ');
534 strcpy(SuccessfulMsg,buf);
535 fixnone(SuccessfulMsg);
536 return;
537 }
538
539 if(strstr(buf,"show_read_statistics") != 0) {
540 getword(wbuf,buf,' ');
541 strcpy(ShowReadStatistics,buf);
542 fixnone(ShowReadStatistics);
543 return;
544 }
545
546 if(strstr(buf,"topuser_fields") != 0) {
547 getword(wbuf,buf,' ');
548 strcpy(TopUserFields,buf);
549 fixnone(TopUserFields);
550 return;
551 }
552
553 if(strstr(buf,"user_report_fields") != 0) {
554 getword(wbuf,buf,' ');
555 strcpy(UserReportFields,buf);
556 fixnone(UserReportFields);
557 return;
558 }
559
560 if(strstr(buf,"site_user_time_date_type") != 0) {
561 getword(wbuf,buf,' ');
562 strcpy(SiteUserTimeDateType,buf);
563 fixnone(SiteUserTimeDateType);
564 return;
565 }
566
567 if(strstr(buf,"datafile ") != 0) {
568 getword(wbuf,buf,' ');
569 strcpy(DataFile,buf);
570 fixnone(DataFile);
571 return;
572 }
573
574 if(strstr(buf,"datafile_delimiter") != 0) {
575 getword(wbuf,buf,' ');
576 getword(wbuf,buf,'"');
577 getword(DataFileDelimiter,buf,'"');
578 fixnone(DataFileDelimiter);
579 return;
580 }
581
582 if(strstr(buf,"datafile_fields") != 0) {
583 getword(wbuf,buf,' ');
584 strcpy(DataFileFields,buf);
585 fixnone(DataFileFields);
586 return;
587 }
588
589 if(strstr(buf,"parsed_output_log") != 0) {
590 if(strstr(buf,"parsed_output_log_compress") == 0) {
591 getword(wbuf,buf,' ');
592 strcpy(ParsedOutputLog,buf);
593 fixnone(ParsedOutputLog);
594 return;
595 }
596 }
597
598 if(strstr(buf,"parsed_output_log_compress") != 0) {
599 getword(wbuf,buf,' ');
600 strcpy(ParsedOutputLogCompress,buf);
601 fixnone(ParsedOutputLogCompress);
602 return;
603 }
604
605 if(strstr(buf,"displayed_values") != 0) {
606 getword(wbuf,buf,' ');
607 strcpy(DisplayedValues,buf);
608 fixnone(DisplayedValues);
609 return;
610 }
611
612 if(strstr(buf,"authfail_report_limit") != 0) {
613 getword(wbuf,buf,' ');
614 AuthfailReportLimit=atoi(buf);
615 return;
616 }
617
618 if(strstr(buf,"denied_report_limit") != 0) {
619 getword(wbuf,buf,' ');
620 DeniedReportLimit=atoi(buf);
621 return;
622 }
623
624 if(strstr(buf,"siteusers_report_limit") != 0) {
625 getword(wbuf,buf,' ');
626 SiteUsersReportLimit=atoi(buf);
627 return;
628 }
629
630 if(strstr(buf,"dansguardian_report_limit") != 0) {
631 getword(wbuf,buf,' ');
632 DansGuardianReportLimit=atoi(buf);
633 return;
634 }
635
636 if(strstr(buf,"squidguard_report_limit") != 0) {
637 getword(wbuf,buf,' ');
638 SquidGuardReportLimit=atoi(buf);
639 return;
640 }
641
642 if(strstr(buf,"user_report_limit") != 0) {
643 getword(wbuf,buf,' ');
644 UserReportLimit=atoi(buf);
645 return;
646 }
647
94ff9470
GS
648 if(strstr(buf,"download_report_limit") != 0) {
649 getword(wbuf,buf,' ');
650 DownloadReportLimit=atoi(buf);
651 return;
652 }
653
25697a35
GS
654 if(strstr(buf,"www_document_root") != 0) {
655 getword(wbuf,buf,' ');
656 strcpy(wwwDocumentRoot,buf);
657 fixnone(wwwDocumentRoot);
658 return;
659 }
660
661 if(strstr(buf,"block_it") != 0) {
662 getword(wbuf,buf,' ');
663 strcpy(BlockIt,buf);
664 fixnone(BlockIt);
665 return;
666 }
667
668 if(strstr(buf,"external_css_file") != 0) {
669 getword(wbuf,buf,' ');
670 strcpy(ExternalCSSFile,buf);
671 fixnone(ExternalCSSFile);
672 return;
673 }
674
675 if(strstr(buf,"user_authentication") != 0) {
676 getword(wbuf,buf,' ');
677 strcpy(UserAuthentication,buf);
678 fixnone(UserAuthentication);
679 return;
680 }
681
682 if(strstr(buf,"AuthUserFile") != 0) {
683 getword(wbuf,buf,' ');
684 strcpy(AuthUserFile,buf);
685 fixnone(AuthUserFile);
686 return;
687 }
688
689 if(strstr(buf,"AuthName") != 0) {
690 getword(wbuf,buf,' ');
691 strcpy(AuthName,buf);
692 fixnone(AuthName);
693 return;
694 }
695
696 if(strstr(buf,"AuthType") != 0) {
697 getword(wbuf,buf,' ');
698 strcpy(AuthType,buf);
699 fixnone(AuthType);
700 return;
701 }
702
703 if(strstr(buf,"Require") != 0) {
704 getword(wbuf,buf,' ');
705 strcpy(Require,buf);
706 fixnone(Require);
707 return;
708 }
709
710 if(strstr(buf,"download_suffix") != 0) {
711 getword(wbuf,buf,'"');
712 getword(DownloadSuffix,buf,'"');
713 fixnone(DownloadSuffix);
714 return;
715 }
716
717 if(strstr(buf,"graphs") != 0) {
718 getword(wbuf,buf,' ');
719 strcpy(Graphs,buf);
720 fixnone(Graphs);
721 return;
722 }
723
724 if(strstr(buf,"graph_days_bytes_bar_color") != 0) {
725 getword(wbuf,buf,' ');
726 strcpy(GraphDaysBytesBarColor,buf);
727 fixnone(GraphDaysBytesBarColor);
728 return;
729 }
730
731 if(strstr(buf,"squidguard_log_format") != 0) {
732 getword(wbuf,buf,' ');
733 strcpy(SquidGuardLogFormat,buf);
734 fixnone(SquidGuardLogFormat);
735 return;
736 }
737
738 if(strstr(buf,"ulimit") != 0) {
739 getword(wbuf,buf,' ');
740 strcpy(Ulimit,buf);
741 fixnone(Ulimit);
742 return;
743 }
744
745 if(strstr(buf,"ntlm_user_format") != 0) {
746 getword(wbuf,buf,' ');
747 strcpy(NtlmUserFormat,buf);
748 fixnone(NtlmUserFormat);
749 return;
750 }
751
752 return;
753}