3 #include "btree_cache.h"
23 #ifdef HAVE_SYS_TIME_H
29 #ifdef HAVE_SYS_RESOURCE_H
30 #include <sys/resource.h>
35 #if defined(HAVE_SYS_DIRENT_H) && !defined(HAVE_DIRENT_H)
36 #include <sys/dirent.h>
41 #ifdef HAVE_SYS_SOCKET_H
42 #include <sys/socket.h>
50 #ifdef HAVE_NETINET_IN_H
51 #include <netinet/in.h>
53 #ifdef HAVE_ARPA_INET_H
54 #include <arpa/inet.h>
56 #ifdef HAVE_SYS_STAT_H
65 #ifdef HAVE_SYS_WAIT_H
81 #ifdef HAVE_GDFONTMB_H
90 #ifdef HAVE_INTTYPES_H
105 #ifdef HAVE_EXECINFO_H
106 #include <execinfo.h>
111 #ifdef HAVE_STDBOOL_H
121 #ifdef HAVE_FNMATCH_H
125 #if defined(HAVE_FOPEN64)
126 #define _FILE_OFFSET_BITS 64
127 #define MY_FOPEN fopen64
129 #define MY_FOPEN fopen
132 #if !defined(HAVE_BZERO)
133 #define bzero(mem,size) memset(mem,0,size)
136 #if defined(IBERTY_LIB) && !defined(HAVE_MKSTEMP)
137 int mkstemps(char *template, int suffixlen
);
138 #define mkstemp(template) mkstemps(template,0)
142 #define pgettext(msgctxt,msgid) (msgid)
143 #define ngettext(singular,plural,number) (plural)
147 #if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
148 #define _(String) gettext(String)
150 #define N_(String) gettext_noop(String)
152 #define N_(String) (String)
155 #define _(String) (String)
156 #define N_(String) (String)
159 #if defined(__MINGW32__)
160 #define mkdir(p,m) _mkdir(p)
163 #define WIFEXITED(S) 1
167 #define WEXITSTATUS(S) (S)
170 #endif /*__MINGW32__*/
173 # define __attribute__(x)
177 #define MAX_URL_LEN 40000
178 #define MAX_TRUNCATED_URL 250
179 #define MAX_USER_LEN 256
180 #define MAX_USER_FNAME_LEN 128
181 #define MAX_IP_LEN 64
182 #define MAX_DATETIME_LEN 32
183 #define MAX_REDIRECTOR_LOGS 64
184 #define MAX_REDIRECTOR_FILELEN 1024
186 Arbitrary limit on the number of days that are accepted in the selected range of the log file.
187 Sarg will complain that there are too many days in the files if this limit is overrun.
189 #define MAX_DATETIME_DAYS 1000
191 #define REPORT_TYPE_USERS_SITES 0x0001UL
192 #define REPORT_TYPE_SITE_USER_TIME_DATE 0x0002UL
193 #define REPORT_TYPE_TOPUSERS 0x0004UL
194 #define REPORT_TYPE_TOPSITES 0x0008UL
195 #define REPORT_TYPE_SITES_USERS 0x0010UL
196 #define REPORT_TYPE_DATE_TIME 0x0020UL
197 #define REPORT_TYPE_DENIED 0x0040UL
198 #define REPORT_TYPE_AUTH_FAILURES 0x0080UL
199 #define REPORT_TYPE_DOWNLOADS 0x0100UL
200 #define REPORT_TYPE_USERAGENT 0x0200UL
202 #define DATA_FIELD_USER 0x0001UL
203 #define DATA_FIELD_DATE 0x0002UL
204 #define DATA_FIELD_TIME 0x0004UL
205 #define DATA_FIELD_URL 0x0008UL
206 #define DATA_FIELD_CONNECT 0x0010UL
207 #define DATA_FIELD_BYTES 0x0020UL
208 #define DATA_FIELD_IN_CACHE 0x0040UL
209 #define DATA_FIELD_OUT_CACHE 0x0080UL
210 #define DATA_FIELD_ELAPSED 0x0100UL
212 #define TOPUSERFIELDS_NUM 0x0001UL
213 #define TOPUSERFIELDS_DATE_TIME 0x0002UL
214 #define TOPUSERFIELDS_USERID 0x0004UL
215 #define TOPUSERFIELDS_CONNECT 0x0008UL
216 #define TOPUSERFIELDS_BYTES 0x0010UL
217 #define TOPUSERFIELDS_SETYB 0x0020UL
218 #define TOPUSERFIELDS_IN_CACHE_OUT 0x0040UL
219 #define TOPUSERFIELDS_USED_TIME 0x0080UL
220 #define TOPUSERFIELDS_MILISEC 0x0100UL
221 #define TOPUSERFIELDS_PTIME 0x0200UL
222 #define TOPUSERFIELDS_TOTAL 0x0400UL
223 #define TOPUSERFIELDS_AVERAGE 0x0800UL
224 #define TOPUSERFIELDS_USERIP 0x1000UL
226 #define USERREPORTFIELDS_CONNECT 0x0001UL
227 #define USERREPORTFIELDS_BYTES 0x0002UL
228 #define USERREPORTFIELDS_SETYB 0x0004UL
229 #define USERREPORTFIELDS_IN_CACHE_OUT 0x0008UL
230 #define USERREPORTFIELDS_USED_TIME 0x0010UL
231 #define USERREPORTFIELDS_MILISEC 0x0020UL
232 #define USERREPORTFIELDS_PTIME 0x0040UL
233 #define USERREPORTFIELDS_TOTAL 0x0080UL
234 #define USERREPORTFIELDS_AVERAGE 0x0100UL
236 #define INDEX_YES 0x0001UL
237 #define INDEX_NO 0x0002UL
238 #define INDEX_ONLY 0x0004UL
240 #define INDEX_TREE_DATE 0x0001UL
241 #define INDEX_TREE_FILE 0x0002UL
243 #define INDEXFIELDS_DIRSIZE 0x0001UL
245 #define NTLMUSERFORMAT_USER 0x0001UL
246 #define NTLMUSERFORMAT_DOMAINUSER 0x0002UL
248 #define RECORDWITHOUTUSER_IP 0x0001UL
249 #define RECORDWITHOUTUSER_IGNORE 0x0002UL
250 #define RECORDWITHOUTUSER_EVERYBODY 0x0004UL
252 #define DATAFILEURL_IP 0x0001UL
253 #define DATAFILEURL_NAME 0x0002UL
255 #define DISPLAY_BYTES 0x0001UL
256 #define DISPLAY_ABBREV 0x0002UL
258 #define DATETIME_ELAP 0x0001UL
259 #define DATETIME_BYTE 0x0002UL
261 #define REALTIME_UNAUTH_REC_SHOW 0x0001UL
262 #define REALTIME_UNAUTH_REC_IGNORE 0x0002UL
264 #define SORT_REVERSE 0x0001
266 #define TOPUSER_SORT_REVERSE SORT_REVERSE
267 #define TOPUSER_SORT_BYTES 0x0002UL
268 #define TOPUSER_SORT_USER 0x0004UL
269 #define TOPUSER_SORT_CONNECT 0x0008UL
270 #define TOPUSER_SORT_TIME 0x0010UL
272 #define TOPSITE_SORT_REVERSE SORT_REVERSE
273 #define TOPSITE_SORT_BYTES 0x0002UL
274 #define TOPSITE_SORT_CONNECT 0x0004UL
275 #define TOPSITE_SORT_TIME 0x0008UL
276 #define TOPSITE_SORT_USER 0x0010UL
278 #define USER_SORT_REVERSE SORT_REVERSE
279 #define USER_SORT_BYTES 0x0002UL
280 #define USER_SORT_SITE 0x0004UL
281 #define USER_SORT_CONNECT 0x0008UL
282 #define USER_SORT_TIME 0x0010UL
284 //! Value to exclude all the javascripts from the html page.
285 #define HTML_JS_NONE 0x0000
286 //! Bit to include sorttable.js in the html plage.
287 #define HTML_JS_SORTTABLE 0x0001
289 //! The character prefixed in front of the host names that are aliased.
290 #define ALIAS_PREFIX '*'
292 //! Maximum number of limit files that can be stored.
293 #define MAX_USER_LIMITS 16
295 //! Name of the html file containing the index of a report file.
296 #define INDEX_HTML_FILE "index.html"
300 //! The first date of the period.
302 //! The last date of the period.
304 //! The textual representation of the date.
306 //! The HTML representation of the date.
311 char outdirname
[MAXLEN
];
312 struct periodstruct period
;
316 char parse_out
[MAXLEN
];
318 char ConfigFile
[MAXLEN
];
321 bool RemoveTempFiles
;
322 char ReplaceIndex
[256];
323 unsigned long int Index
;
324 bool OverwriteReport
;
325 unsigned long int RecordsWithoutUser
;
327 char MailUtility
[PATH_MAX
];
330 char ExcludeCodes
[256];
331 unsigned long int TopsitesSort
;
332 unsigned long int ReportType
;
333 char UserTabFile
[255];
338 int AccessLogFromCmdLine
;
340 char BgColor
[MAXLEN
];
341 char BgImage
[MAXLEN
];
342 char TxColor
[MAXLEN
];
343 char TxBgColor
[MAXLEN
];
344 char TiColor
[MAXLEN
];
345 char LogoImage
[MAXLEN
];
346 char LogoText
[MAXLEN
];
347 char LogoTextColor
[MAXLEN
];
350 char FontFace
[MAXLEN
];
351 char HeaderColor
[MAXLEN
];
352 char HeaderBgColor
[MAXLEN
];
353 char FontSize
[MAXLEN
];
354 char PasswdFile
[MAXLEN
];
355 char TempDir
[MAXLEN
];
356 char OutputDir
[MAXLEN
];
357 char OutputEmail
[MAXLEN
];
358 unsigned long int TopuserSort
;
359 unsigned long int UserSort
;
361 char ExcludeHosts
[255];
362 char ExcludeUsers
[255];
365 char MaxElapsed
[255];
366 unsigned long int datetimeby
;
368 char UserInvalidChar
[255];
370 char GraphDaysBytesBarColor
[255];
372 char PrivacyString
[255];
373 char PrivacyStringColor
[30];
374 char IncludeUsers
[MAXLEN
];
375 char ExcludeString
[MAXLEN
];
377 unsigned long int TopUserFields
;
378 unsigned long int UserReportFields
;
379 char DataFile
[MAXLEN
];
380 char DataFileDelimiter
[3];
381 unsigned long int DataFileFields
;
382 unsigned long int DataFileUrl
;
383 //! if \c true, show the number of lines read from the input log file during the reading of the file.
384 bool ShowReadStatistics
;
386 If \c true, the read statistics also includes the percent of the number of lines read.
388 Beware that it requires two readings of the input log file. It is not possible if the
389 input log file is stdin or a pipe.
391 bool ShowReadPercent
;
392 char IndexSortOrder
[5];
393 char DansGuardianConf
[MAXLEN
];
394 bool DansguardianFilterOutDate
;
395 char SquidGuardConf
[MAXLEN
];
396 char SquidGuarddbHome
[255];
397 char RedirectorLogFormat
[4096];
399 char RedirectorLogs
[MAX_REDIRECTOR_LOGS
][MAX_REDIRECTOR_FILELEN
];
400 int RedirectorLogFromCmdLine
;
401 bool RedirectorFilterOutDate
;
403 bool BytesInSitesUsersReport
;
405 char ParsedOutputLog
[MAXLEN
];
406 char ParsedOutputLogCompress
[512];
407 unsigned long int DisplayedValues
;
408 char HeaderFontSize
[5];
409 char TitleFontSize
[5];
410 char wwwDocumentRoot
[MAXLEN
];
411 char ExternalCSSFile
[MAXLEN
];
413 unsigned long int NtlmUserFormat
;
414 //! How to display the index of the reports.
415 unsigned long int IndexTree
;
416 //! The columns to show in the index of the reports.
417 unsigned long int IndexFields
;
418 bool UserAuthentication
;
419 char AuthUserTemplateFile
[1024];
420 //! \c True to use anonymous file and directory names in the report.
421 bool AnonymousOutputFiles
;
440 char RealtimeTypes
[1024];
443 unsigned long int RealtimeUnauthRec
;
445 char LDAPBindDN
[512];
446 char LDAPBindPW
[255];
448 int LDAPProtocolVersion
;
449 char LDAPBaseSearch
[255];
450 char LDAPFilterSearch
[512];
451 char LDAPTargetAttr
[64];
452 //! Character set to convert the LDAP returned string to.
453 char LDAPNativeCharset
[20];
454 char GraphFont
[MAXLEN
];
455 //! The full path to sorttable.js if the table in the reports must be dynamicaly sorted.
456 char SortTableJs
[256];
457 //! The name of the file containing the host names to replace by an alias in the report.
458 char HostAliasFile
[512];
459 //! The name of the file containing the user names to replace by an alias in the report.
460 char UserAliasFile
[512];
461 //! The number of consecutive errors allowed in an input log file before the process is interrupted.
462 int NumLogSuccessiveErrors
;
464 The total number of errors allowed in an input log file before the process is interrupted. A negative
465 value means the process should never fails irrespective of the number of errors found in the input
468 int NumLogTotalErrors
;
469 //! Count the number of lines read from the input log files.
470 unsigned long int lines_read
;
471 //! Count the number of records kept for the processing.
472 unsigned long int records_kept
;
473 //! Count the number of users.
474 unsigned long int nusers
;
477 int dansguardian_count
;
478 int redirector_count
;
492 int AuthfailReportLimit
;
493 int DeniedReportLimit
;
494 int DownloadReportLimit
;
495 int SiteUsersReportLimit
;
496 int DansGuardianReportLimit
;
497 int SquidGuardReportLimit
;
499 int realtime_refresh
;
500 int realtime_access_log_lines
;
505 //! \c True to keep the temporary files for inspection.
508 long long int nocost
;