3 #include "btree_cache.h"
20 #ifdef HAVE_SYS_TIME_H
26 #ifdef HAVE_SYS_RESOURCE_H
27 #include <sys/resource.h>
32 #if defined(HAVE_SYS_DIRENT_H) && !defined(HAVE_DIRENT_H)
33 #include <sys/dirent.h>
38 #ifdef HAVE_SYS_SOCKET_H
39 #include <sys/socket.h>
47 #ifdef HAVE_NETINET_IN_H
48 #include <netinet/in.h>
50 #ifdef HAVE_ARPA_INET_H
51 #include <arpa/inet.h>
53 #ifdef HAVE_SYS_STAT_H
62 #ifdef HAVE_SYS_WAIT_H
78 #ifdef HAVE_GDFONTMB_H
87 #ifdef HAVE_INTTYPES_H
102 #ifdef HAVE_EXECINFO_H
103 #include <execinfo.h>
108 #ifdef HAVE_STDBOOL_H
118 #ifdef HAVE_FNMATCH_H
122 #if defined(HAVE_FOPEN64)
123 #define _FILE_OFFSET_BITS 64
124 #define MY_FOPEN fopen64
126 #define MY_FOPEN fopen
129 #if !defined(HAVE_BZERO)
130 #define bzero(mem,size) memset(mem,0,size)
133 #if defined(IBERTY_LIB) && !defined(HAVE_MKSTEMP)
134 int mkstemps(char *template, int suffixlen
);
135 #define mkstemp(template) mkstemps(template,0)
139 #if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
140 #define _(String) gettext(String)
142 #define N_(String) gettext_noop(String)
144 #define N_(String) (String)
147 #define _(String) (String)
148 #define N_(String) (String)
151 #if defined(__MINGW32__)
152 #define mkdir(p,m) _mkdir(p)
155 #define WIFEXITED(S) 1
159 #define WEXITSTATUS(S) (S)
162 #endif /*__MINGW32__*/
165 # define __attribute__(x)
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
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.
181 #define MAX_DATETIME_DAYS 1000
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
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
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
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
226 #define INDEX_YES 0x0001UL
227 #define INDEX_NO 0x0002UL
228 #define INDEX_ONLY 0x0004UL
230 #define INDEX_TREE_DATE 0x0001UL
231 #define INDEX_TREE_FILE 0x0002UL
233 #define INDEXFIELDS_DIRSIZE 0x0001UL
235 #define NTLMUSERFORMAT_USER 0x0001UL
236 #define NTLMUSERFORMAT_DOMAINUSER 0x0002UL
238 #define RECORDWITHOUTUSER_IP 0x0001UL
239 #define RECORDWITHOUTUSER_IGNORE 0x0002UL
240 #define RECORDWITHOUTUSER_EVERYBODY 0x0004UL
242 #define DATAFILEURL_IP 0x0001UL
243 #define DATAFILEURL_NAME 0x0002UL
245 #define DISPLAY_BYTES 0x0001UL
246 #define DISPLAY_ABBREV 0x0002UL
248 #define DATETIME_ELAP 0x0001UL
249 #define DATETIME_BYTE 0x0002UL
251 #define REALTIME_UNAUTH_REC_SHOW 0x0001UL
252 #define REALTIME_UNAUTH_REC_IGNORE 0x0002UL
254 #define SORT_REVERSE 0x0001
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
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
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
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
279 //! The character prefixed in front of the host names that are aliased.
280 #define ALIAS_PREFIX '*'
282 //! Maximum number of limit files that can be stored.
283 #define MAX_USER_LIMITS 16
285 //! Name of the html file containing the index of a report file.
286 #define INDEX_HTML_FILE "index.html"
290 //! The first date of the period.
292 //! The last date of the period.
294 //! The textual representation of the date.
296 //! The HTML representation of the date.
301 char outdirname
[MAXLEN
];
302 struct periodstruct period
;
306 char parse_out
[MAXLEN
];
308 char ConfigFile
[MAXLEN
];
311 bool RemoveTempFiles
;
312 char ReplaceIndex
[256];
313 unsigned long int Index
;
314 bool OverwriteReport
;
315 unsigned long int RecordsWithoutUser
;
317 char MailUtility
[PATH_MAX
];
320 char ExcludeCodes
[256];
321 unsigned long int TopsitesSort
;
322 unsigned long int ReportType
;
323 char UserTabFile
[255];
328 int AccessLogFromCmdLine
;
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
];
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];
352 char ExcludeHosts
[255];
353 char ExcludeUsers
[255];
356 char MaxElapsed
[255];
357 unsigned long int datetimeby
;
359 char UserInvalidChar
[255];
361 char GraphDaysBytesBarColor
[255];
363 char PrivacyString
[255];
364 char PrivacyStringColor
[30];
365 char IncludeUsers
[MAXLEN
];
366 char ExcludeString
[MAXLEN
];
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
;
377 If \c true, the read statistics also includes the percent of the number of lines read.
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.
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];
390 char RedirectorLogs
[MAX_REDIRECTOR_LOGS
][MAX_REDIRECTOR_FILELEN
];
391 int RedirectorLogFromCmdLine
;
392 bool RedirectorFilterOutDate
;
394 bool BytesInSitesUsersReport
;
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
];
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
;
431 char RealtimeTypes
[1024];
434 unsigned long int RealtimeUnauthRec
;
436 char LDAPBindDN
[512];
437 char LDAPBindPW
[255];
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
;
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
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
;
468 int dansguardian_count
;
469 int redirector_count
;
484 int AuthfailReportLimit
;
485 int DeniedReportLimit
;
486 int DownloadReportLimit
;
487 int SiteUsersReportLimit
;
488 int DansGuardianReportLimit
;
489 int SquidGuardReportLimit
;
491 int realtime_refresh
;
492 int realtime_access_log_lines
;
498 //! \c True to keep the temporary files for inspection.
501 long long int nocost
;