]> git.ipfire.org Git - thirdparty/sarg.git/blob - include/conf.h
Use a global constant instead of the "index.html" file name in the code
[thirdparty/sarg.git] / include / conf.h
1 #include "config.h"
2 #include "info.h"
3 #include "btree_cache.h"
4
5 #ifdef HAVE_WINDOWS_H
6 #include <windows.h>
7 #endif
8 #ifdef HAVE_STDIO_H
9 #include <stdio.h>
10 #endif
11 #ifdef HAVE_STDLIB_H
12 #include <stdlib.h>
13 #endif
14 #ifdef HAVE_STRING_H
15 #include <string.h>
16 #endif
17 #ifdef HAVE_STRINGS_H
18 #include <strings.h>
19 #endif
20 #ifdef HAVE_SYS_TIME_H
21 #include <sys/time.h>
22 #endif
23 #ifdef HAVE_TIME_H
24 #include <time.h>
25 #endif
26 #ifdef HAVE_SYS_RESOURCE_H
27 #include <sys/resource.h>
28 #endif
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif
32 #if defined(HAVE_SYS_DIRENT_H) && !defined(HAVE_DIRENT_H)
33 #include <sys/dirent.h>
34 #endif
35 #ifdef HAVE_DIRENT_H
36 #include <dirent.h>
37 #endif
38 #ifdef HAVE_SYS_SOCKET_H
39 #include <sys/socket.h>
40 #endif
41 #ifdef HAVE_NETDB_H
42 #include <netdb.h>
43 #endif
44 #ifdef HAVE_TYPES_H
45 #include <types.h>
46 #endif
47 #ifdef HAVE_NETINET_IN_H
48 #include <netinet/in.h>
49 #endif
50 #ifdef HAVE_ARPA_INET_H
51 #include <arpa/inet.h>
52 #endif
53 #ifdef HAVE_SYS_STAT_H
54 #include <sys/stat.h>
55 #endif
56 #ifdef HAVE_CTYPE_H
57 #include <ctype.h>
58 #endif
59 #ifdef HAVE_ERRNO_H
60 #include <errno.h>
61 #endif
62 #ifdef HAVE_SYS_WAIT_H
63 #include <sys/wait.h>
64 #endif
65 #ifdef HAVE_GD_H
66 #define HAVE_GD 1
67 #include <gd.h>
68 #endif
69 #ifdef HAVE_GDFONTL_H
70 #include <gdfontl.h>
71 #endif
72 #ifdef HAVE_GDFONTT_H
73 #include <gdfontt.h>
74 #endif
75 #ifdef HAVE_GDFONTS_H
76 #include <gdfonts.h>
77 #endif
78 #ifdef HAVE_GDFONTMB_H
79 #include <gdfontmb.h>
80 #endif
81 #ifdef HAVE_GDFONTG_H
82 #include <gdfontg.h>
83 #endif
84 #ifdef HAVE_STDARG_H
85 #include <stdarg.h>
86 #endif
87 #ifdef HAVE_INTTYPES_H
88 #include <inttypes.h>
89 #endif
90 #ifdef HAVE_LIMITS_H
91 #include <limits.h>
92 #endif
93 #ifdef HAVE_WINSOCK_H
94 #include <winsock.h>
95 #endif
96 #ifdef HAVE_MATH_H
97 #include <math.h>
98 #endif
99 #ifdef HAVE_LOCALE_H
100 #include <locale.h>
101 #endif
102 #ifdef HAVE_EXECINFO_H
103 #include <execinfo.h>
104 #endif
105 #ifdef HAVE_LIBGEN_H
106 #include <libgen.h>
107 #endif
108 #ifdef HAVE_STDBOOL_H
109 #include <stdbool.h>
110 #else
111 typedef int bool;
112 #define true 1
113 #define false 0
114 #endif
115 #ifdef HAVE_FCNTL_H
116 #include <fcntl.h>
117 #endif
118 #ifdef HAVE_FNMATCH_H
119 #include <fnmatch.h>
120 #endif
121
122 #if defined(HAVE_FOPEN64)
123 #define _FILE_OFFSET_BITS 64
124 #define MY_FOPEN fopen64
125 #else
126 #define MY_FOPEN fopen
127 #endif
128
129 #if !defined(HAVE_BZERO)
130 #define bzero(mem,size) memset(mem,0,size)
131 #endif
132
133 #if defined(IBERTY_LIB) && !defined(HAVE_MKSTEMP)
134 int mkstemps(char *template, int suffixlen);
135 #define mkstemp(template) mkstemps(template,0)
136 #endif
137
138 #include "gettext.h"
139 #if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
140 #define _(String) gettext(String)
141 #ifdef gettext_noop
142 #define N_(String) gettext_noop(String)
143 #else
144 #define N_(String) (String)
145 #endif
146 #else /* No NLS */
147 #define _(String) (String)
148 #define N_(String) (String)
149 #endif //NLS
150
151 #if defined(__MINGW32__)
152 #define mkdir(p,m) _mkdir(p)
153
154 #ifndef WIFEXITED
155 #define WIFEXITED(S) 1
156 #endif
157
158 #ifndef WEXITSTATUS
159 #define WEXITSTATUS(S) (S)
160 #endif
161
162 #endif /*__MINGW32__*/
163
164 #ifndef __GNUC__
165 # define __attribute__(x)
166 #endif
167
168 #define MAXLEN 20000
169 #define MAX_URL_LEN 40000
170 #define MAX_TRUNCATED_URL 250
171 #define MAX_USER_LEN 256
172 #define MAX_USER_FNAME_LEN 128
173 #define MAX_IP_LEN 64
174 #define MAX_DATETIME_LEN 32
175 #define MAX_REDIRECTOR_LOGS 64
176 #define MAX_REDIRECTOR_FILELEN 1024
177 /*!
178 Arbitrary limit on the number of days that are accepted in the selected range of the log file.
179 Sarg will complain that there are too many days in the files if this limit is overrun.
180 */
181 #define MAX_DATETIME_DAYS 1000
182
183 #define REPORT_TYPE_USERS_SITES 0x0001UL
184 #define REPORT_TYPE_SITE_USER_TIME_DATE 0x0002UL
185 #define REPORT_TYPE_TOPUSERS 0x0004UL
186 #define REPORT_TYPE_TOPSITES 0x0008UL
187 #define REPORT_TYPE_SITES_USERS 0x0010UL
188 #define REPORT_TYPE_DATE_TIME 0x0020UL
189 #define REPORT_TYPE_DENIED 0x0040UL
190 #define REPORT_TYPE_AUTH_FAILURES 0x0080UL
191 #define REPORT_TYPE_DOWNLOADS 0x0100UL
192
193 #define DATA_FIELD_USER 0x0001UL
194 #define DATA_FIELD_DATE 0x0002UL
195 #define DATA_FIELD_TIME 0x0004UL
196 #define DATA_FIELD_URL 0x0008UL
197 #define DATA_FIELD_CONNECT 0x0010UL
198 #define DATA_FIELD_BYTES 0x0020UL
199 #define DATA_FIELD_IN_CACHE 0x0040UL
200 #define DATA_FIELD_OUT_CACHE 0x0080UL
201 #define DATA_FIELD_ELAPSED 0x0100UL
202
203 #define TOPUSERFIELDS_NUM 0x0001UL
204 #define TOPUSERFIELDS_DATE_TIME 0x0002UL
205 #define TOPUSERFIELDS_USERID 0x0004UL
206 #define TOPUSERFIELDS_CONNECT 0x0008UL
207 #define TOPUSERFIELDS_BYTES 0x0010UL
208 #define TOPUSERFIELDS_SETYB 0x0020UL
209 #define TOPUSERFIELDS_IN_CACHE_OUT 0x0040UL
210 #define TOPUSERFIELDS_USED_TIME 0x0080UL
211 #define TOPUSERFIELDS_MILISEC 0x0100UL
212 #define TOPUSERFIELDS_PTIME 0x0200UL
213 #define TOPUSERFIELDS_TOTAL 0x0400UL
214 #define TOPUSERFIELDS_AVERAGE 0x0800UL
215
216 #define USERREPORTFIELDS_CONNECT 0x0001UL
217 #define USERREPORTFIELDS_BYTES 0x0002UL
218 #define USERREPORTFIELDS_SETYB 0x0004UL
219 #define USERREPORTFIELDS_IN_CACHE_OUT 0x0008UL
220 #define USERREPORTFIELDS_USED_TIME 0x0010UL
221 #define USERREPORTFIELDS_MILISEC 0x0020UL
222 #define USERREPORTFIELDS_PTIME 0x0040UL
223 #define USERREPORTFIELDS_TOTAL 0x0080UL
224 #define USERREPORTFIELDS_AVERAGE 0x0100UL
225
226 #define INDEX_YES 0x0001UL
227 #define INDEX_NO 0x0002UL
228 #define INDEX_ONLY 0x0004UL
229
230 #define INDEX_TREE_DATE 0x0001UL
231 #define INDEX_TREE_FILE 0x0002UL
232
233 #define INDEXFIELDS_DIRSIZE 0x0001UL
234
235 #define NTLMUSERFORMAT_USER 0x0001UL
236 #define NTLMUSERFORMAT_DOMAINUSER 0x0002UL
237
238 #define RECORDWITHOUTUSER_IP 0x0001UL
239 #define RECORDWITHOUTUSER_IGNORE 0x0002UL
240 #define RECORDWITHOUTUSER_EVERYBODY 0x0004UL
241
242 #define DATAFILEURL_IP 0x0001UL
243 #define DATAFILEURL_NAME 0x0002UL
244
245 #define DISPLAY_BYTES 0x0001UL
246 #define DISPLAY_ABBREV 0x0002UL
247
248 #define DATETIME_ELAP 0x0001UL
249 #define DATETIME_BYTE 0x0002UL
250
251 #define REALTIME_UNAUTH_REC_SHOW 0x0001UL
252 #define REALTIME_UNAUTH_REC_IGNORE 0x0002UL
253
254 #define SORT_REVERSE 0x0001
255
256 #define TOPUSER_SORT_REVERSE SORT_REVERSE
257 #define TOPUSER_SORT_BYTES 0x0002UL
258 #define TOPUSER_SORT_USER 0x0004UL
259 #define TOPUSER_SORT_CONNECT 0x0008UL
260 #define TOPUSER_SORT_TIME 0x0010UL
261
262 #define TOPSITE_SORT_REVERSE SORT_REVERSE
263 #define TOPSITE_SORT_BYTES 0x0002UL
264 #define TOPSITE_SORT_CONNECT 0x0004UL
265 #define TOPSITE_SORT_TIME 0x0008UL
266 #define TOPSITE_SORT_USER 0x0010UL
267
268 #define USER_SORT_REVERSE SORT_REVERSE
269 #define USER_SORT_BYTES 0x0002UL
270 #define USER_SORT_SITE 0x0004UL
271 #define USER_SORT_CONNECT 0x0008UL
272 #define USER_SORT_TIME 0x0010UL
273
274 //! Value to exclude all the javascripts from the html page.
275 #define HTML_JS_NONE 0x0000
276 //! Bit to include sorttable.js in the html plage.
277 #define HTML_JS_SORTTABLE 0x0001
278
279 //! The character prefixed in front of the host names that are aliased.
280 #define ALIAS_PREFIX '*'
281
282 //! Maximum number of limit files that can be stored.
283 #define MAX_USER_LIMITS 16
284
285 //! Name of the html file containing the index of a report file.
286 #define INDEX_HTML_FILE "index.html"
287
288 struct periodstruct
289 {
290 //! The first date of the period.
291 struct tm start;
292 //! The last date of the period.
293 struct tm end;
294 //! The textual representation of the date.
295 char text[40];
296 //! The HTML representation of the date.
297 char html[40];
298 };
299
300 char outdir[MAXLEN];
301 char outdirname[MAXLEN];
302 struct periodstruct period;
303 char code[MAXLEN];
304 char code2[MAXLEN];
305 char tmp[MAXLEN];
306 char parse_out[MAXLEN];
307 char html[MAXLEN];
308 char ConfigFile[MAXLEN];
309 char df;
310 int LastLog;
311 bool RemoveTempFiles;
312 char ReplaceIndex[256];
313 unsigned long int Index;
314 bool OverwriteReport;
315 unsigned long int RecordsWithoutUser;
316 bool UseComma;
317 char MailUtility[PATH_MAX];
318 int TopSitesNum;
319 int TopUsersNum;
320 char ExcludeCodes[256];
321 unsigned long int TopsitesSort;
322 unsigned long int ReportType;
323 char UserTabFile[255];
324 char warea[MAXLEN];
325 char name[MAXLEN];
326 bool LongUrl;
327 bool Ip2Name;
328 int AccessLogFromCmdLine;
329 char Title[MAXLEN];
330 char BgColor[MAXLEN];
331 char BgImage[MAXLEN];
332 char TxColor[MAXLEN];
333 char TxBgColor[MAXLEN];
334 char TiColor[MAXLEN];
335 char LogoImage[MAXLEN];
336 char LogoText[MAXLEN];
337 char LogoTextColor[MAXLEN];
338 char Width[MAXLEN];
339 char Height[MAXLEN];
340 char FontFace[MAXLEN];
341 char HeaderColor[MAXLEN];
342 char HeaderBgColor[MAXLEN];
343 char FontSize[MAXLEN];
344 char PasswdFile[MAXLEN];
345 char TempDir[MAXLEN];
346 char OutputDir[MAXLEN];
347 char OutputEmail[MAXLEN];
348 unsigned long int TopuserSort;
349 unsigned long int UserSort;
350 char UserAgentLog[255];
351 char module[255];
352 char ExcludeHosts[255];
353 char ExcludeUsers[255];
354 char DateFormat;
355 bool UserIp;
356 char MaxElapsed[255];
357 unsigned long int datetimeby;
358 char CharSet[255];
359 char UserInvalidChar[255];
360 bool Graphs;
361 char GraphDaysBytesBarColor[255];
362 bool Privacy;
363 char PrivacyString[255];
364 char PrivacyStringColor[30];
365 char IncludeUsers[MAXLEN];
366 char ExcludeString[MAXLEN];
367 bool SuccessfulMsg;
368 unsigned long int TopUserFields;
369 unsigned long int UserReportFields;
370 char DataFile[MAXLEN];
371 char DataFileDelimiter[3];
372 unsigned long int DataFileFields;
373 unsigned long int DataFileUrl;
374 //! if \c true, show the number of lines read from the input log file during the reading of the file.
375 bool ShowReadStatistics;
376 /*!
377 If \c true, the read statistics also includes the percent of the number of lines read.
378
379 Beware that it requires two readings of the input log file. It is not possible if the
380 input log file is stdin or a pipe.
381 */
382 bool ShowReadPercent;
383 char IndexSortOrder[5];
384 char DansGuardianConf[MAXLEN];
385 bool DansguardianFilterOutDate;
386 char SquidGuardConf[MAXLEN];
387 char SquidGuarddbHome[255];
388 char RedirectorLogFormat[4096];
389 int NRedirectorLogs;
390 char RedirectorLogs[MAX_REDIRECTOR_LOGS][MAX_REDIRECTOR_FILELEN];
391 int RedirectorLogFromCmdLine;
392 bool RedirectorFilterOutDate;
393 bool ShowSargInfo;
394 bool BytesInSitesUsersReport;
395 bool ShowSargLogo;
396 char ParsedOutputLog[MAXLEN];
397 char ParsedOutputLogCompress[512];
398 unsigned long int DisplayedValues;
399 char HeaderFontSize[5];
400 char TitleFontSize[5];
401 char wwwDocumentRoot[MAXLEN];
402 char ExternalCSSFile[MAXLEN];
403 char BlockIt[255];
404 unsigned long int NtlmUserFormat;
405 //! How to display the index of the reports.
406 unsigned long int IndexTree;
407 //! The columns to show in the index of the reports.
408 unsigned long int IndexFields;
409 bool UserAuthentication;
410 char AuthUserTemplateFile[1024];
411 //! \c True to use anonymous file and directory names in the report.
412 bool AnonymousOutputFiles;
413 char val1[MAXLEN];
414 char val3[MAXLEN];
415 char val5[MAXLEN];
416 char val6[MAXLEN];
417 char val7[MAXLEN];
418 char val8[MAXLEN];
419 char val9[MAXLEN];
420 char val10[MAXLEN];
421 char val11[MAXLEN];
422 char mask[MAXLEN];
423 char site[MAXLEN];
424 char us[50];
425 char email[MAXLEN];
426 char test[1];
427 char user2[MAXLEN];
428 char wentp[512];
429 char addr[MAXLEN];
430 char Ulimit[6];
431 char RealtimeTypes[1024];
432 char cmd[255];
433 char ImageFile[255];
434 unsigned long int RealtimeUnauthRec;
435 char LDAPHost[255];
436 char LDAPBindDN[512];
437 char LDAPBindPW[255];
438 int LDAPPort;
439 int LDAPProtocolVersion;
440 char LDAPBaseSearch[255];
441 char LDAPFilterSearch[512];
442 char LDAPTargetAttr[64];
443 //! Character set to convert the LDAP returned string to.
444 char LDAPNativeCharset[20];
445 char GraphFont[MAXLEN];
446 //! The full path to sorttable.js if the table in the reports must be dynamicaly sorted.
447 char SortTableJs[256];
448 //! The name of the file containing the host names to replace by an alias in the report.
449 char HostAliasFile[512];
450 //! The name of the file containing the user names to replace by an alias in the report.
451 char UserAliasFile[512];
452 //! The number of consecutive errors allowed in an input log file before the process is interrupted.
453 int NumLogSuccessiveErrors;
454 /*!
455 The total number of errors allowed in an input log file before the process is interrupted. A negative
456 value means the process should never fails irrespective of the number of errors found in the input
457 log files.
458 */
459 int NumLogTotalErrors;
460 //! Count the number of lines read from the input log files.
461 unsigned long int lines_read;
462 //! Count the number of records kept for the processing.
463 unsigned long int records_kept;
464 //! Count the number of users.
465 unsigned long int nusers;
466
467 int idate;
468 int dansguardian_count;
469 int redirector_count;
470 int useragent_count;
471 int z1, z2, z3;
472 int ttopen;
473 int sarglog;
474 int isalog;
475 int dfrom;
476 int duntil;
477 bool dataonly;
478 bool indexonly;
479 bool iprel;
480 int langcode;
481 int debug;
482 int debugz;
483 int debugm;
484 int AuthfailReportLimit;
485 int DeniedReportLimit;
486 int DownloadReportLimit;
487 int SiteUsersReportLimit;
488 int DansGuardianReportLimit;
489 int SquidGuardReportLimit;
490 int UserReportLimit;
491 int realtime_refresh;
492 int realtime_access_log_lines;
493 int rc;
494 int ntopsites;
495 int nrepday;
496 int ntopuser;
497 bool squid24;
498 //! \c True to keep the temporary files for inspection.
499 bool KeepTempLog;
500
501 long long int nocost;
502 float cost;
503
504 typedef struct
505 { int list[ 24 ];
506 int len;
507 } numlist;