1 #include "config.h"
2 
3 
4 #define _XOPEN_SOURCE		600
5 #define _ISOC99_SOURCE
6 
7 /* Large file support */
8 #ifdef LARGEFILE
9 # define _FILE_OFFSET_BITS	64	/* POSIX large file support for fopen/fstat		*/
10 # define _LARGEFILE_SOURCE	1	/* Linux/xBSD/HP-UX/Solaris support for fseeko/ftello	*/
11 # define _LARGE_FILES 		1	/* AIX large file and fseeko/ftello support		*/
12 #endif
13 
14 
15 #include <stdarg.h>
16 #include <stddef.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <unistd.h>
20 #include <string.h>
21 #include <strings.h>
22 #include <ctype.h>
23 #include <locale.h>
24 #include <langinfo.h>
25 #include <errno.h>
26 #include <netdb.h>
27 #include <arpa/inet.h>
28 #include <netinet/in.h>
29 #include <sys/socket.h>
30 #include <sys/stat.h>
31 #include <sys/types.h>
32 #include <sys/wait.h>
33 #include <time.h>
34 #include <math.h>
35 #include <dirent.h>
36 #include <regex.h>
37 
38 
39 #define RECORDSIZE		9216L
40 #define RECORDLEN		"9215"
41 #define URLSIZE			8192L
42 #define URLLEN			"8191"
43 #define FILENAMESIZE		512L
44 #define DATETIMESIZE		128L
45 #define USERNAMELEN		"127"
46 #define USERNAMESIZE		128
47 #define USERDESCSIZE		256L
48 #define CHARSETSIZE		18
49 #define IPSIZE			16
50 #define IPLEN			"15"
51 #define ARGSCOUNT		32
52 #define CODESSIZE		1024		/* must be 1 more than required, increased for strange squid codes */
53 #define SAMAXTIMET		1555555555L
54 #define SALONGDATE		1135976400L	/* 31.12.2005 - hope it's longest date in any locale */
55 #define SYSLOGYEAR		2008
56 #define MAXLFCOUNT		16		/* to increase this value 'short int' must be replaced by 'int' */
57 #define MAXLFCSSCOUNT		8		/* number of classes in CSS for local filters */
58 
59 #define SAHOUR			 60L * 60L
60 #define SADAY			 24L * SAHOUR
61 #define SAWEEK			  7L * SADAY
62 #define SAMONTH			 30L * SADAY
63 #define SAQUARTER		  3L * SAMONTH
64 #define SAYEAR			365L * SADAY
65 
66 #define CMDSH			"/bin/sh"
67 #define CMDRM			"/bin/rm"
68 #define CMDMAILX		"/usr/bin/mailx"
69 
70 #define SAsetbit(src, bitnr)	( (src) |=  (0x01 << (bitnr) ))
71 #define SAgetbit(src, bitnr)	( (src) &   (0x01 << (bitnr) ))
72 #define SAclrbit(src, bitnr)	( (src) &= ~(0x01 << (bitnr) ))
73 #define SAmin(a, b)		( (a) < (b) ? (a) : (b) )
74 #define SAmax(a, b)		( (a) > (b) ? (a) : (b) )
75 #define SAnumcmp(x, y)		( (x) == (y) ? 0 : ( (x) < (y) ? 1 : -1 ) )
76 #define SAisxdigit(x)		(isxdigit((int)((unsigned char)(x))))
77 #define SADMTOSM(x)		#x
78 #define _(x)			SADMTOSM(x)
79 
80 #if DEBUG >= 1
81 #	define __SAINFO__	__FILE__ ":" _(__LINE__)
82 #else
83 #	define __SAINFO__	__func__
84 #endif
85 
86 
87 #include "work/w_config.h"
88 #include "work/w_system.h"
89 #include "work/w_fs.h"
90 #include "work/w_internal.h"
91 #include "work/w_log_operations.h"
92 #include "work/w_svg.h"
93 
94 #include "reports/r_efficiency.h"
95 #include "reports/r_users.h"
96 #include "reports/r_topsites.h"
97 #include "reports/r_topusers.h"
98 #include "reports/r_reports.h"
99 #include "reports/r_localfilter.h"
100 #include "reports/r_usergraphs.h"
101 #include "reports/r_userdatetime.h"
102 #include "reports/r_email.h"
103 #include "reports/r_list.h"
104 #include "reports/r_index.h"
105 #include "reports/r_privacy.h"
106 
107 #include "logformats/l_squid_native.h"
108 #include "logformats/l_clf_native.h"
109 #include "logformats/l_combined_native.h"
110 #include "logformats/l_postfix_syslog.h"
111 #include "logformats/l_qmail_syslog.h"
112 #include "logformats/l_cgp_native.h"
113 #include "logformats/l_logformats.h"
114