]>
git.ipfire.org Git - thirdparty/sarg.git/blob - getconf.c
ac953d52efad052a7e2f86948fa46f81f95f7194
2 * AUTHOR: Pedro Lineu Orso orso@penguintech.com.br
4 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
7 * please look at http://sarg.sourceforge.net/donations.php
8 * ---------------------------------------------------------------------
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.
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.
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.
26 #include "include/conf.h"
28 extern numlist hours
, weekdays
;
40 sprintf(Msg
,"Loading configuration from: %s",ConfigFile
);
44 if ((fp_in
= fopen(ConfigFile
, "r")) == NULL
) {
45 fprintf(stderr
, "SARG: (getconf) Cannot open file: %s\n",ConfigFile
);
49 while (fgets(buf
, MAXLEN
, fp_in
) != NULL
) {
50 if(strstr(buf
,"\n") != 0)
51 buf
[strlen(buf
)-1]='\n';
54 printf("SYSCONFDIR %s",buf
);
56 if(strncmp(buf
,"#",1) == 0)
64 language_load(language
);
69 int parmtest(char *buf
)
72 if(strstr(buf
,"background_color") != 0) {
73 getword(wbuf
,buf
,' ');
79 if(strstr(buf
,"text_color") != 0) {
80 if(strstr(buf
,"logo_text_color") == 0) {
81 getword(wbuf
,buf
,' ');
88 if(strstr(buf
,"text_bgcolor") != 0) {
89 getword(wbuf
,buf
,' ');
90 strcpy(TxBgColor
,buf
);
95 if(strstr(buf
,"title_color") != 0) {
96 getword(wbuf
,buf
,' ');
102 if(strstr(buf
,"logo_image") != 0) {
103 getword(wbuf
,buf
,' ');
104 strcpy(LogoImage
,buf
);
109 if(strstr(buf
,"logo_text") != 0) {
110 if(strstr(buf
,"logo_text_color") == 0) {
111 getword(wbuf
,buf
,'"');
112 getword(LogoText
,buf
,'"');
118 if(strstr(buf
,"logo_text_color") != 0) {
119 getword(wbuf
,buf
,' ');
120 strcpy(LogoTextColor
,buf
);
121 fixnone(LogoTextColor
);
125 if(strstr(buf
,"background_image") != 0) {
126 getword(wbuf
,buf
,' ');
132 if(strstr(buf
,"show_sarg_info") != 0) {
133 getword(wbuf
,buf
,' ');
134 strcpy(ShowSargInfo
,buf
);
135 fixnone(ShowSargInfo
);
139 if(strstr(buf
,"show_sarg_logo") != 0) {
140 getword(wbuf
,buf
,' ');
141 strcpy(ShowSargLogo
,buf
);
142 fixnone(ShowSargLogo
);
146 if(strstr(buf
,"font_face") != 0) {
147 getword(wbuf
,buf
,' ');
148 strcpy(FontFace
,buf
);
153 if(strstr(buf
,"header_color") != 0) {
154 getword(wbuf
,buf
,' ');
155 strcpy(HeaderColor
,buf
);
156 fixnone(HeaderColor
);
160 if(strstr(buf
,"header_bgcolor") != 0) {
161 getword(wbuf
,buf
,' ');
162 strcpy(HeaderBgColor
,buf
);
163 fixnone(HeaderBgColor
);
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
);
176 if(strstr(buf
,"header_font_size") != 0) {
177 getword(wbuf
,buf
,' ');
178 strcpy(HeaderFontSize
,buf
);
179 fixnone(HeaderFontSize
);
183 if(strstr(buf
,"title_font_size") != 0) {
184 getword(wbuf
,buf
,' ');
185 strcpy(TitleFontSize
,buf
);
186 fixnone(TitleFontSize
);
190 if(strstr(buf
,"image_size") != 0) {
191 getword(wbuf
,buf
,' ');
192 getword(Width
,buf
,' ');
199 if(strstr(buf
,"title") != 0) {
200 getword(wbuf
,buf
,'"');
201 getword(Title
,buf
,'"');
206 if(strstr(buf
,"resolve_ip") != 0) {
207 getword(wbuf
,buf
,' ');
213 if(strstr(buf
,"user_ip") != 0) {
214 getword(wbuf
,buf
,' ');
220 if(strstr(buf
,"max_elapsed") != 0) {
221 getword(wbuf
,buf
,' ');
222 strcpy(MaxElapsed
,buf
);
227 if(strstr(buf
,"date_format") != 0) {
228 getword(wbuf
,buf
,' ');
229 strcpy(DateFormat
,buf
);
234 if( strstr( buf
, "hours" ) != 0 ) {
235 if( getnumlist( buf
, &hours
, 24, 24 ) ) {
236 fprintf( stderr
, "Error: Invalid syntax in hours tag!\n" );
241 if( strstr( buf
, "weekdays" ) != 0 ) {
242 if( getnumlist( buf
, &weekdays
, 7, 7 ) ) {
243 fprintf( stderr
, "Error: Invalid syntax in weekdays tag!\n" );
248 if(strstr(buf
,"topuser_sort_field") != 0) {
249 getword(wbuf
,buf
,' ');
250 getword(TopuserSortField
,buf
,' ');
251 strcpy(TopuserSortOrder
,buf
);
252 fixnone(TopuserSortOrder
);
256 if(strstr(buf
,"user_sort_field") != 0) {
257 getword(wbuf
,buf
,' ');
258 getword(UserSortField
,buf
,' ');
259 strcpy(UserSortOrder
,buf
);
260 fixnone(UserSortOrder
);
264 if(strstr(buf
,"access_log") != 0) {
265 getword(wbuf
,buf
,' ');
266 strcpy(AccessLog
,buf
);
271 if(strstr(buf
,"useragent_log") != 0) {
272 getword(wbuf
,buf
,' ');
273 strcpy(UserAgentLog
,buf
);
274 fixnone(UserAgentLog
);
278 if(strstr(buf
,"exclude_hosts") != 0) {
279 getword(wbuf
,buf
,' ');
280 strcpy(ExcludeHosts
,buf
);
281 fixnone(ExcludeHosts
);
285 if(strstr(buf
,"exclude_codes") != 0) {
286 getword(wbuf
,buf
,' ');
287 strcpy(ExcludeCodes
,buf
);
288 fixnone(ExcludeCodes
);
292 if(strstr(buf
,"exclude_users") != 0) {
293 getword(wbuf
,buf
,' ');
294 strcpy(ExcludeUsers
,buf
);
295 fixnone(ExcludeUsers
);
299 if(strstr(buf
,"password") != 0) {
300 getword(wbuf
,buf
,' ');
301 strcpy(PasswdFile
,buf
);
306 if(strstr(buf
,"temporary_dir") != 0) {
307 getword(wbuf
,buf
,' ');
313 if(strstr(buf
,"report_type") != 0) {
314 getword(wbuf
,buf
,' ');
315 strcpy(ReportType
,buf
);
320 if(strstr(buf
,"output_dir") != 0) {
321 if(strstr(buf
,"output_dir_form") == 0) {
322 getword(wbuf
,buf
,' ');
323 strcpy(OutputDir
,buf
);
329 if(strstr(buf
,"output_email") != 0) {
330 getword(wbuf
,buf
,' ');
331 strcpy(OutputEmail
,buf
);
332 fixnone(OutputEmail
);
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
);
346 if(strstr(buf
,"lastlog") != 0) {
347 getword(wbuf
,buf
,' ');
353 if(strstr(buf
,"remove_temp_files") != 0) {
354 getword(wbuf
,buf
,' ');
355 strcpy(RemoveTempFiles
,buf
);
356 fixnone(RemoveTempFiles
);
360 if(strstr(buf
,"replace_index") != 0) {
361 getword(wbuf
,buf
,' ');
362 strcpy(ReplaceIndex
,buf
);
363 fixnone(ReplaceIndex
);
367 if(strstr(buf
,"index") != 0) {
368 if(strstr(buf
,"index_sort_order") == 0) {
369 getword(wbuf
,buf
,' ');
376 if(strstr(buf
,"overwrite_report") != 0) {
377 getword(wbuf
,buf
,' ');
378 strcpy(OverwriteReport
,buf
);
379 fixnone(OverwriteReport
);
383 if(strstr(buf
,"records_without_userid") != 0) {
384 getword(wbuf
,buf
,' ');
385 strcpy(RecordsWithoutUser
,buf
);
386 fixnone(RecordsWithoutUser
);
390 if(strstr(buf
,"use_comma") != 0) {
391 getword(wbuf
,buf
,' ');
392 strcpy(UseComma
,buf
);
397 if(strstr(buf
,"mail_utility") != 0) {
398 getword(wbuf
,buf
,' ');
399 strcpy(MailUtility
,buf
);
400 fixnone(MailUtility
);
404 if(strstr(buf
,"topsites_num") != 0) {
405 getword(wbuf
,buf
,' ');
406 strcpy(TopSitesNum
,buf
);
407 fixnone(TopSitesNum
);
411 if(strstr(buf
,"topuser_num") != 0) {
412 getword(wbuf
,buf
,' ');
413 strcpy(TopUsersNum
,buf
);
414 fixnone(TopUsersNum
);
418 if(strstr(buf
,"usertab") != 0) {
419 getword(wbuf
,buf
,' ');
420 strcpy(UserTabFile
,buf
);
421 fixnone(UserTabFile
);
425 if(strstr(buf
,"index_sort_order") != 0) {
426 getword(wbuf
,buf
,' ');
427 strcpy(IndexSortOrder
,buf
);
428 fixnone(IndexSortOrder
);
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
);
441 if(strstr(buf
,"long_url") != 0) {
442 getword(wbuf
,buf
,' ');
448 if(strstr(buf
,"language") != 0) {
449 getword(wbuf
,buf
,' ');
450 strcpy(language
,buf
);
455 if(strstr(buf
,"dansguardian_conf") != 0) {
456 getword(wbuf
,buf
,' ');
457 strcpy(DansGuardianConf
,buf
);
458 fixnone(DansGuardianConf
);
462 if(strstr(buf
,"squidguard_conf") != 0) {
463 getword(wbuf
,buf
,' ');
464 strcpy(SquidGuardConf
,buf
);
465 fixnone(SquidGuardConf
);
469 if(strstr(buf
,"date_time_by") != 0) {
470 getword(wbuf
,buf
,' ');
471 strcpy(datetimeby
,buf
);
476 if(strstr(buf
,"charset") != 0) {
477 getword(wbuf
,buf
,' ');
484 if(strstr(buf
,"user_invalid_char") != 0) {
485 getword(wbuf
,buf
,'"');
486 getword(UserInvalidChar
,buf
,'"');
487 fixnone(UserInvalidChar
);
491 if(strstr(buf
,"include_users") != 0) {
492 getword(wbuf
,buf
,'"');
493 getword(wbuf
,buf
,'"');
494 sprintf(IncludeUsers
,":%s:",wbuf
);
495 fixnone(IncludeUsers
);
499 if(strstr(buf
,"exclude_string") != 0) {
500 getword(wbuf
,buf
,'"');
501 getword(ExcludeString
,buf
,'"');
502 fixnone(ExcludeString
);
506 if(strstr(buf
,"privacy") != 0) {
507 if(strstr(buf
,"privacy_string") == 0 && \
508 strstr(buf
,"privacy_string_color") == 0) {
509 getword(wbuf
,buf
,' ');
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
);
525 if(strstr(buf
,"privacy_string_color") != 0) {
526 getword(wbuf
,buf
,' ');
527 strcpy(PrivacyStringColor
,buf
);
528 fixnone(PrivacyStringColor
);
532 if(strstr(buf
,"show_successful_message") != 0) {
533 getword(wbuf
,buf
,' ');
534 strcpy(SuccessfulMsg
,buf
);
535 fixnone(SuccessfulMsg
);
539 if(strstr(buf
,"show_read_statistics") != 0) {
540 getword(wbuf
,buf
,' ');
541 strcpy(ShowReadStatistics
,buf
);
542 fixnone(ShowReadStatistics
);
546 if(strstr(buf
,"topuser_fields") != 0) {
547 getword(wbuf
,buf
,' ');
548 strcpy(TopUserFields
,buf
);
549 fixnone(TopUserFields
);
553 if(strstr(buf
,"user_report_fields") != 0) {
554 getword(wbuf
,buf
,' ');
555 strcpy(UserReportFields
,buf
);
556 fixnone(UserReportFields
);
560 if(strstr(buf
,"site_user_time_date_type") != 0) {
561 getword(wbuf
,buf
,' ');
562 strcpy(SiteUserTimeDateType
,buf
);
563 fixnone(SiteUserTimeDateType
);
567 if(strstr(buf
,"datafile ") != 0) {
568 getword(wbuf
,buf
,' ');
569 strcpy(DataFile
,buf
);
574 if(strstr(buf
,"datafile_delimiter") != 0) {
575 getword(wbuf
,buf
,' ');
576 getword(wbuf
,buf
,'"');
577 getword(DataFileDelimiter
,buf
,'"');
578 fixnone(DataFileDelimiter
);
582 if(strstr(buf
,"datafile_fields") != 0) {
583 getword(wbuf
,buf
,' ');
584 strcpy(DataFileFields
,buf
);
585 fixnone(DataFileFields
);
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
);
598 if(strstr(buf
,"parsed_output_log_compress") != 0) {
599 getword(wbuf
,buf
,' ');
600 strcpy(ParsedOutputLogCompress
,buf
);
601 fixnone(ParsedOutputLogCompress
);
605 if(strstr(buf
,"displayed_values") != 0) {
606 getword(wbuf
,buf
,' ');
607 strcpy(DisplayedValues
,buf
);
608 fixnone(DisplayedValues
);
612 if(strstr(buf
,"authfail_report_limit") != 0) {
613 getword(wbuf
,buf
,' ');
614 AuthfailReportLimit
=atoi(buf
);
618 if(strstr(buf
,"denied_report_limit") != 0) {
619 getword(wbuf
,buf
,' ');
620 DeniedReportLimit
=atoi(buf
);
624 if(strstr(buf
,"siteusers_report_limit") != 0) {
625 getword(wbuf
,buf
,' ');
626 SiteUsersReportLimit
=atoi(buf
);
630 if(strstr(buf
,"dansguardian_report_limit") != 0) {
631 getword(wbuf
,buf
,' ');
632 DansGuardianReportLimit
=atoi(buf
);
636 if(strstr(buf
,"squidguard_report_limit") != 0) {
637 getword(wbuf
,buf
,' ');
638 SquidGuardReportLimit
=atoi(buf
);
642 if(strstr(buf
,"user_report_limit") != 0) {
643 getword(wbuf
,buf
,' ');
644 UserReportLimit
=atoi(buf
);
648 if(strstr(buf
,"download_report_limit") != 0) {
649 getword(wbuf
,buf
,' ');
650 DownloadReportLimit
=atoi(buf
);
654 if(strstr(buf
,"www_document_root") != 0) {
655 getword(wbuf
,buf
,' ');
656 strcpy(wwwDocumentRoot
,buf
);
657 fixnone(wwwDocumentRoot
);
661 if(strstr(buf
,"block_it") != 0) {
662 getword(wbuf
,buf
,' ');
668 if(strstr(buf
,"external_css_file") != 0) {
669 getword(wbuf
,buf
,' ');
670 strcpy(ExternalCSSFile
,buf
);
671 fixnone(ExternalCSSFile
);
675 if(strstr(buf
,"user_authentication") != 0) {
676 getword(wbuf
,buf
,' ');
677 strcpy(UserAuthentication
,buf
);
678 fixnone(UserAuthentication
);
682 if(strstr(buf
,"AuthUserFile") != 0) {
683 getword(wbuf
,buf
,' ');
684 strcpy(AuthUserFile
,buf
);
685 fixnone(AuthUserFile
);
689 if(strstr(buf
,"AuthName") != 0) {
690 getword(wbuf
,buf
,' ');
691 strcpy(AuthName
,buf
);
696 if(strstr(buf
,"AuthType") != 0) {
697 getword(wbuf
,buf
,' ');
698 strcpy(AuthType
,buf
);
703 if(strstr(buf
,"Require") != 0) {
704 getword(wbuf
,buf
,' ');
710 if(strstr(buf
,"download_suffix") != 0) {
711 getword(wbuf
,buf
,'"');
712 getword(DownloadSuffix
,buf
,'"');
713 fixnone(DownloadSuffix
);
717 if(strstr(buf
,"graphs") != 0) {
718 getword(wbuf
,buf
,' ');
724 if(strstr(buf
,"graph_days_bytes_bar_color") != 0) {
725 getword(wbuf
,buf
,' ');
726 strcpy(GraphDaysBytesBarColor
,buf
);
727 fixnone(GraphDaysBytesBarColor
);
731 if(strstr(buf
,"squidguard_log_format") != 0) {
732 getword(wbuf
,buf
,' ');
733 strcpy(SquidGuardLogFormat
,buf
);
734 fixnone(SquidGuardLogFormat
);
738 if(strstr(buf
,"ulimit") != 0) {
739 getword(wbuf
,buf
,' ');
745 if(strstr(buf
,"ntlm_user_format") != 0) {
746 getword(wbuf
,buf
,' ');
747 strcpy(NtlmUserFormat
,buf
);
748 fixnone(NtlmUserFormat
);