Commit | Line | Data |
---|---|---|
e015f748 CE |
1 | #ifndef _WEBALIZER_H |
2 | #define _WEBALIZER_H | |
3 | ||
4 | #define PCENT(val,max) ((val)?((double)val/(double)max)*100.0 : 0.0) | |
5 | #define IDX_2C(c1,c2) (((c1-'a'+1)<<7)+(c2-'a'+1) ) | |
6 | #define IDX_3C(c1,c2,c3) (((c1-'a'+1)<<12)+((c2-'a'+1)<<7)+(c3-'a'+1) ) | |
7 | #define IDX_4C(c1,c2,c3,c4) (((c1-'a'+1)<<17)+((c2-'a'+1)<<12)+((c3-'a'+1)<<7)+(c4-'a'+1) ) | |
8 | #define IDX_5C(c1,c2,c3,c4,c5) (((c1-'a'+1)<<22)+((c2-'a'+1)<<17)+((c3-'a'+1)<<12)+((c4-'a'+1)<<7)+(c5-'a'+1) ) | |
9 | #define IDX_6C(c1,c2,c3,c4,c5,c6) (((c1-'a'+1)<<27)+((c2-'a'+1)<<22)+((c3-'a'+1)<<17)+((c4-'a'+1)<<12)+((c5-'a'+1)<<7)+(c6-'a'+1) ) | |
10 | ||
11 | #ifndef MAX | |
12 | #define MAX(a,b) ((a) > (b) ? (a) : (b)) | |
13 | #endif | |
14 | ||
15 | #define MAXHASH 4096 /* Size of our hash tables */ | |
16 | #define BUFSIZE 4096 /* Max buffer size for log record */ | |
17 | #define MAXHOST 128 /* Max hostname buffer size */ | |
18 | #define MAXURL 4096 /* Max HTTP request/URL field size */ | |
19 | #define MAXURLH 512 /* Max URL field size in htab */ | |
20 | #define MAXREF 1024 /* Max referrer field size */ | |
21 | #define MAXREFH 256 /* Max referrer field size in htab */ | |
22 | #define MAXAGENT 128 /* Max user agent field size */ | |
23 | #define MAXCTRY 48 /* Max country name size */ | |
24 | #define MAXSRCH 256 /* Max size of search string buffer */ | |
25 | #define MAXSRCHH 128 /* Max size of search str in htab */ | |
26 | #define MAXIDENT 64 /* Max size of ident string (user) */ | |
27 | #define MAXKWORD 32 /* Max size of config keyword */ | |
28 | #define MAXKVAL 132 /* Max size of config value */ | |
29 | #define HISTSIZE 120 /* Size of history in months */ | |
30 | #define GRAPHMAX 72 /* Max months in index graph */ | |
31 | ||
32 | #define SLOP_VAL 3600 /* out of sequence slop (seconds) */ | |
33 | ||
34 | /* Log types */ | |
35 | #define LOG_CLF 0 /* CLF/combined log type */ | |
36 | #define LOG_FTP 1 /* wu-ftpd xferlog type */ | |
37 | #define LOG_SQUID 2 /* squid proxy log */ | |
38 | #define LOG_W3C 3 /* W3C extended log format */ | |
39 | ||
40 | /* compression */ | |
41 | #define COMP_NONE 0 | |
42 | #define COMP_GZIP 1 | |
43 | #define COMP_BZIP 2 | |
44 | ||
45 | /* Response code defines as per draft ietf HTTP/1.1 rev 6 */ | |
46 | #define RC_CONTINUE 100 | |
47 | #define RC_SWITCHPROTO 101 | |
48 | #define RC_OK 200 | |
49 | #define RC_CREATED 201 | |
50 | #define RC_ACCEPTED 202 | |
51 | #define RC_NONAUTHINFO 203 | |
52 | #define RC_NOCONTENT 204 | |
53 | #define RC_RESETCONTENT 205 | |
54 | #define RC_PARTIALCONTENT 206 | |
55 | #define RC_MULTIPLECHOICES 300 | |
56 | #define RC_MOVEDPERM 301 | |
57 | #define RC_MOVEDTEMP 302 | |
58 | #define RC_SEEOTHER 303 | |
59 | #define RC_NOMOD 304 | |
60 | #define RC_USEPROXY 305 | |
61 | #define RC_MOVEDTEMPORARILY 307 | |
62 | #define RC_BAD 400 | |
63 | #define RC_UNAUTH 401 | |
64 | #define RC_PAYMENTREQ 402 | |
65 | #define RC_FORBIDDEN 403 | |
66 | #define RC_NOTFOUND 404 | |
67 | #define RC_METHODNOTALLOWED 405 | |
68 | #define RC_NOTACCEPTABLE 406 | |
69 | #define RC_PROXYAUTHREQ 407 | |
70 | #define RC_TIMEOUT 408 | |
71 | #define RC_CONFLICT 409 | |
72 | #define RC_GONE 410 | |
73 | #define RC_LENGTHREQ 411 | |
74 | #define RC_PREFAILED 412 | |
75 | #define RC_REQENTTOOLARGE 413 | |
76 | #define RC_REQURITOOLARGE 414 | |
77 | #define RC_UNSUPMEDIATYPE 415 | |
78 | #define RC_RNGNOTSATISFIABLE 416 | |
79 | #define RC_EXPECTATIONFAILED 417 | |
80 | #define RC_SERVERERR 500 | |
81 | #define RC_NOTIMPLEMENTED 501 | |
82 | #define RC_BADGATEWAY 502 | |
83 | #define RC_UNAVAIL 503 | |
84 | #define RC_GATEWAYTIMEOUT 504 | |
85 | #define RC_BADHTTPVER 505 | |
86 | ||
87 | /* Index defines for RC codes */ | |
88 | #define IDX_UNDEFINED 0 | |
89 | #define IDX_CONTINUE 1 | |
90 | #define IDX_SWITCHPROTO 2 | |
91 | #define IDX_OK 3 | |
92 | #define IDX_CREATED 4 | |
93 | #define IDX_ACCEPTED 5 | |
94 | #define IDX_NONAUTHINFO 6 | |
95 | #define IDX_NOCONTENT 7 | |
96 | #define IDX_RESETCONTENT 8 | |
97 | #define IDX_PARTIALCONTENT 9 | |
98 | #define IDX_MULTIPLECHOICES 10 | |
99 | #define IDX_MOVEDPERM 11 | |
100 | #define IDX_MOVEDTEMP 12 | |
101 | #define IDX_SEEOTHER 13 | |
102 | #define IDX_NOMOD 14 | |
103 | #define IDX_USEPROXY 15 | |
104 | #define IDX_MOVEDTEMPORARILY 16 | |
105 | #define IDX_BAD 17 | |
106 | #define IDX_UNAUTH 18 | |
107 | #define IDX_PAYMENTREQ 19 | |
108 | #define IDX_FORBIDDEN 20 | |
109 | #define IDX_NOTFOUND 21 | |
110 | #define IDX_METHODNOTALLOWED 22 | |
111 | #define IDX_NOTACCEPTABLE 23 | |
112 | #define IDX_PROXYAUTHREQ 24 | |
113 | #define IDX_TIMEOUT 25 | |
114 | #define IDX_CONFLICT 26 | |
115 | #define IDX_GONE 27 | |
116 | #define IDX_LENGTHREQ 28 | |
117 | #define IDX_PREFAILED 29 | |
118 | #define IDX_REQENTTOOLARGE 30 | |
119 | #define IDX_REQURITOOLARGE 31 | |
120 | #define IDX_UNSUPMEDIATYPE 32 | |
121 | #define IDX_RNGNOTSATISFIABLE 33 | |
122 | #define IDX_EXPECTATIONFAILED 34 | |
123 | #define IDX_SERVERERR 35 | |
124 | #define IDX_NOTIMPLEMENTED 36 | |
125 | #define IDX_BADGATEWAY 37 | |
126 | #define IDX_UNAVAIL 38 | |
127 | #define IDX_GATEWAYTIMEOUT 39 | |
128 | #define IDX_BADHTTPVER 40 | |
129 | #define TOTAL_RC 41 | |
130 | ||
131 | #ifdef USE_DNS | |
132 | #include <netinet/in.h> /* needed for in_addr structure definition */ | |
133 | #ifndef INADDR_NONE | |
134 | #define INADDR_NONE 0xFFFFFFFF | |
135 | #endif /* INADDR_NONE */ | |
136 | #endif | |
137 | ||
138 | /* Response code structure */ | |
139 | struct response_code { char *desc; /* code description */ | |
140 | u_int64_t count; }; /* hit counter */ | |
141 | ||
142 | /* Country code structure */ | |
143 | struct country_code {u_int64_t idx; /* TLD index number */ | |
144 | char *desc; /* TLD description */ | |
145 | u_int64_t count; /* hit counter */ | |
146 | u_int64_t files; /* file counter */ | |
147 | double xfer; }; /* xfer amt counter */ | |
148 | ||
149 | typedef struct country_code *CLISTPTR; | |
150 | ||
151 | /* log record structure */ | |
152 | struct log_struct { char hostname[MAXHOST]; /* hostname */ | |
153 | char datetime[29]; /* raw timestamp */ | |
154 | char url[MAXURL]; /* raw request field */ | |
155 | int resp_code; /* response code */ | |
156 | u_int64_t xfer_size; /* xfer size in bytes */ | |
157 | char refer[MAXREF]; /* referrer */ | |
158 | char agent[MAXAGENT]; /* user agent (browser) */ | |
159 | char srchstr[MAXSRCH]; /* search string */ | |
160 | char ident[MAXIDENT]; }; /* ident string (user) */ | |
161 | ||
162 | extern struct log_struct log_rec; | |
163 | ||
164 | extern char *version ; /* program version */ | |
165 | extern char *editlvl ; /* edit level */ | |
166 | extern char *moddate ; /* modification date */ | |
167 | extern char *copyright ; | |
168 | ||
169 | extern int verbose ; /* 2=verbose,1=err, 0=none */ | |
170 | extern int debug_mode ; /* debug mode flag */ | |
171 | extern int time_me ; /* timing display flag */ | |
172 | extern int local_time ; /* 1=localtime 0=GMT (UTC) */ | |
173 | extern int hist_gap ; /* hist error, save backup */ | |
174 | extern int ignore_hist ; /* history flag (1=skip) */ | |
175 | extern int ignore_state ; /* state fiag (1=skip) */ | |
176 | extern int hourly_graph ; /* hourly graph display */ | |
177 | extern int hourly_stats ; /* hourly stats table */ | |
178 | extern int daily_graph ; /* daily graph display */ | |
179 | extern int daily_stats ; /* daily stats table */ | |
180 | extern int ctry_graph ; /* country graph display */ | |
181 | extern int shade_groups ; /* Group shading 0=no 1=yes */ | |
182 | extern int hlite_groups ; /* Group hlite 0=no 1=yes */ | |
183 | extern int mangle_agent ; /* mangle user agents */ | |
184 | extern int incremental ; /* incremental mode 1=yes */ | |
185 | extern int use_https ; /* use 'https://' on URLs */ | |
186 | extern int htaccess ; /* create .htaccess? (0=no) */ | |
187 | extern int visit_timeout; /* visit timeout (30 min) */ | |
188 | extern int graph_legend ; /* graph legend (1=yes) */ | |
189 | extern int graph_lines ; /* graph lines (0=none) */ | |
190 | extern int fold_seq_err ; /* fold seq err (0=no) */ | |
191 | extern int log_type ; /* (0=clf, 1=ftp, 2=squid) */ | |
192 | extern int group_domains; /* Group domains 0=none */ | |
193 | extern int hide_sites ; /* Hide ind. sites (0=no) */ | |
194 | extern int graph_mths ; /* # months in index graph */ | |
195 | extern int index_mths ; /* # months in index table */ | |
196 | extern int year_hdrs ; /* Show year headers (0=no) */ | |
197 | extern int year_totals ; /* Show year totals (0=no) */ | |
198 | extern int use_flags ; /* Show flags in ctry table */ | |
199 | extern char *flag_dir ; /* flag directory */ | |
200 | extern char *hname ; /* hostname for reports */ | |
201 | extern char *state_fname ; /* run state file name */ | |
202 | extern char *hist_fname ; /* name of history file */ | |
203 | extern char *html_ext ; /* HTML file prefix */ | |
204 | extern char *dump_ext ; /* Dump file prefix */ | |
205 | extern char *conf_fname ; /* name of config file */ | |
206 | extern char *log_fname ; /* log file pointer */ | |
207 | extern char *out_dir ; /* output directory */ | |
208 | extern char *blank_str ; /* blank string */ | |
209 | extern char *dns_cache ; /* DNS cache file name */ | |
210 | extern int geodb ; /* Use GeoDB flag (0=no) */ | |
211 | extern int dns_children ; /* # of DNS children */ | |
212 | extern int cache_ips ; /* Cache IP addrs (0=no) */ | |
213 | extern int cache_ttl ; /* Cache entry TTL (days) */ | |
214 | extern int link_referrer; /* link referrer (0=no) */ | |
215 | extern int trimsquid ; /* trim squid URLs (0=none) */ | |
216 | extern int searchcasei ; /* case insensitive search */ | |
217 | ||
218 | extern int ntop_sites ; /* top n sites to display */ | |
219 | extern int ntop_sitesK ; /* top n sites (by kbytes) */ | |
220 | extern int ntop_urls ; /* top n url's to display */ | |
221 | extern int ntop_urlsK ; /* top n url's (by kbytes) */ | |
222 | extern int ntop_entry ; /* top n entry url's */ | |
223 | extern int ntop_exit ; /* top n exit url's */ | |
224 | extern int ntop_refs ; /* top n referrers "" */ | |
225 | extern int ntop_agents ; /* top n user agents "" */ | |
226 | extern int ntop_ctrys ; /* top n countries "" */ | |
227 | extern int ntop_search ; /* top n search strings */ | |
228 | extern int ntop_users ; /* top n users to display */ | |
229 | ||
230 | extern int all_sites ; /* List All sites (0=no) */ | |
231 | extern int all_urls ; /* List All URLs (0=no) */ | |
232 | extern int all_refs ; /* List All Referrers */ | |
233 | extern int all_agents ; /* List All User Agents */ | |
234 | extern int all_search ; /* List All Search Strings */ | |
235 | extern int all_users ; /* List All Usernames */ | |
236 | ||
237 | extern int dump_sites ; /* Dump tab delimited sites */ | |
238 | extern int dump_urls ; /* URLs */ | |
239 | extern int dump_refs ; /* Referrers */ | |
240 | extern int dump_agents ; /* User Agents */ | |
241 | extern int dump_users ; /* Usernames */ | |
242 | extern int dump_search ; /* Search strings */ | |
243 | extern int dump_header ; /* Dump header as first rec */ | |
244 | extern char *dump_path ; /* Path for dump files */ | |
245 | ||
246 | extern u_int64_t cur_tstamp; /* Current timestamp */ | |
247 | extern u_int64_t epoch; /* used for timestamp adj. */ | |
248 | extern int check_dup; /* check for dups flag */ | |
249 | ||
250 | extern int cur_year,cur_month, /* year/month/day/hour */ | |
251 | cur_day, cur_hour, /* tracking variables */ | |
252 | cur_min, cur_sec; | |
253 | ||
254 | extern double t_xfer; /* monthly total xfer value */ | |
255 | extern u_int64_t t_hit, t_file, t_site, /* monthly total vars */ | |
256 | t_url, t_ref, t_agent, | |
257 | t_page,t_visit,t_user; | |
258 | ||
259 | extern double tm_xfer[31]; /* daily transfer totals */ | |
260 | ||
261 | extern u_int64_t tm_hit[31], tm_file[31], /* daily total arrays */ | |
262 | tm_site[31],tm_page[31], | |
263 | tm_visit[31]; | |
264 | ||
265 | extern u_int64_t dt_site; /* daily 'sites' total */ | |
266 | ||
267 | extern u_int64_t ht_hit,mh_hit; /* hourly hits totals */ | |
268 | ||
269 | extern u_int64_t th_hit[24], th_file[24], /* hourly total arrays */ | |
270 | th_page[24]; | |
271 | ||
272 | extern double th_xfer[24]; /* hourly xfer array */ | |
273 | ||
274 | extern int f_day,l_day; /* first/last day vars */ | |
275 | extern int gz_log; /* flag for zipped log */ | |
276 | ||
277 | extern CLISTPTR *top_ctrys; /* Top countries table */ | |
278 | ||
279 | extern char hit_color[]; /* graph hit color */ | |
280 | extern char file_color[]; /* graph file color */ | |
281 | extern char site_color[]; /* graph site color */ | |
282 | extern char kbyte_color[]; /* graph kbyte color */ | |
283 | extern char page_color[]; /* graph page color */ | |
284 | extern char visit_color[]; /* graph visit color */ | |
285 | extern char misc_color[]; /* graph misc color */ | |
286 | extern char pie_color1[]; /* pie additionnal color 1 */ | |
287 | extern char pie_color2[]; /* pie additionnal color 2 */ | |
288 | extern char pie_color3[]; /* pie additionnal color 3 */ | |
289 | extern char pie_color4[]; /* pie additionnal color 4 */ | |
290 | ||
291 | /* define our externally visable functions */ | |
292 | ||
293 | extern char *cur_time(); | |
294 | extern u_int64_t ctry_idx(char *); | |
295 | extern char *un_idx(u_int64_t); | |
296 | extern void init_counters(); | |
297 | extern int ispage(char *); | |
298 | extern u_int64_t jdate(int,int,int); | |
299 | extern char from_hex(char); | |
300 | extern int isipaddr(char *); | |
301 | ||
302 | #endif /* _WEBALIZER_H */ |