]>
Commit | Line | Data |
---|---|---|
f2ec8c75 FM |
1 | /*!\file |
2 | \brief Declaration of the structures and functions. | |
3 | */ | |
9c7c6346 | 4 | |
f83d7b44 | 5 | struct ReadLogStruct;//forward declaration |
8e53b2e7 | 6 | |
9c7c6346 FM |
7 | struct getwordstruct |
8 | { | |
9 | const char *current; | |
10 | const char *beginning; | |
e5b2c6f0 | 11 | int modified; |
9c7c6346 FM |
12 | }; |
13 | ||
afaa3b67 | 14 | typedef struct longlinestruct *longline; |
ac422f9b | 15 | |
2240dcea FM |
16 | struct generalitemstruct |
17 | { | |
18 | //! \c True if the entry is for the total of the file or \c false if it is a single line. | |
19 | int total; | |
20 | //! The user to which the entry apply. The length is limited to ::MAX_USER_LEN. | |
21 | char *user; | |
22 | //! The number of accesses performed by the user. | |
23 | long long nacc; | |
24 | //! The number of bytes transfered. | |
25 | long long nbytes; | |
26 | //! The URL accessed by the user. The length is not limited. | |
27 | char *url; | |
28 | //! The source IP address of the user. The length is limited to ::MAX_IP_LEN. | |
29 | char *ip; | |
30 | //! The time of the access. The length is limited to ::MAX_DATETIME_LEN. | |
31 | char *time; | |
32 | //! The date of the access. The length is limited to ::MAX_DATETIME_LEN. | |
33 | char *date; | |
34 | //! The number of milliseconds spend processing the request. | |
35 | long long nelap; | |
36 | //! The number of bytes fetched from the cache of the proxy (cache hit). | |
37 | long long incache; | |
38 | //! The number of bytes fetched from the site (cache miss). | |
39 | long long oucache; | |
40 | }; | |
41 | ||
93551487 FM |
42 | /*! \brief What is known about a user. |
43 | */ | |
f2ec8c75 FM |
44 | struct userinfostruct |
45 | { | |
93551487 | 46 | //! The ID of the user as found in the input file. |
b6b6cb8c | 47 | const char *id; |
aa6ac9f2 FM |
48 | //! The user's IP address. |
49 | const char *ip; | |
93551487 FM |
50 | //! \c True if the ID is in fact the IP address from which the user connected. |
51 | bool id_is_ip; | |
52 | //! \c True if the user doesn't have a report file. | |
53 | bool no_report; | |
54 | //! The name of the user to display in the report. | |
b6b6cb8c | 55 | const char *label; |
93551487 | 56 | //! The mangled name to use in file names of that user. |
b6b6cb8c | 57 | const char *filename; |
a58e6d54 FM |
58 | //! \c True if this user is in the topuser list. |
59 | int topuser; | |
aa6ac9f2 FM |
60 | //! \c True if the user's limit has been reached. |
61 | int user_limit; | |
a58e6d54 FM |
62 | //! A general purpose flag that can be set when scanning the user's list. |
63 | int flag; | |
d91457d2 FM |
64 | #ifdef ENABLE_DOUBLE_CHECK_DATA |
65 | //! Total number of bytes. | |
66 | long long int nbytes; | |
67 | //! Total time spent processing the requests. | |
68 | long long int elap; | |
69 | #endif | |
f2ec8c75 FM |
70 | }; |
71 | ||
93551487 FM |
72 | //! Scan through the known users. |
73 | typedef struct userscanstruct *userscan; | |
74 | ||
9dc20988 FM |
75 | /*! \brief Global statistics |
76 | */ | |
77 | struct globalstatstruct | |
78 | { | |
79 | //! Total number of accesses. | |
80 | long long int nacc; | |
81 | //! Total number of bytes. | |
82 | long long int nbytes; | |
83 | //! Total time spent processing the requests. | |
84 | long long int elap; | |
85 | //! Amount of data fetched from the cache. | |
86 | long long int incache; | |
87 | //! Amount of data not fetched from the cache. | |
88 | long long int oucache; | |
e5b3a129 FM |
89 | //! The number of users in the topuser list. |
90 | int totuser; | |
9dc20988 FM |
91 | }; |
92 | ||
026ddd8b FM |
93 | //! The object to store the daily statistics. |
94 | typedef struct DayStruct *DayObject; | |
95 | ||
27d1fa35 FM |
96 | /*! |
97 | \brief Log filtering criterion. | |
98 | */ | |
99 | struct ReadLogDataStruct | |
100 | { | |
101 | //! The filtering date range. | |
102 | char DateRange[255]; | |
103 | //! \c True to filter on hosts. | |
104 | bool HostFilter; | |
105 | //! \c True to filter on users. | |
106 | bool UserFilter; | |
107 | //! Maximum elpased time allowed. Any time greater than this value is set to zero. | |
108 | long int max_elapsed; | |
109 | //! \c True to restrict the log to the system users. | |
110 | bool SysUsers; | |
111 | //! The start time to include in the report(H*100+M). Set to -1 to disable. | |
112 | int StartTime; | |
113 | //! The end time to include in the report(H*100+M). Set to -1 to disable. | |
114 | int EndTime; | |
115 | }; | |
116 | ||
5f3cfd1d | 117 | // auth.c |
d25d4e6a | 118 | void htaccess(const struct userinfostruct *uinfo); |
5f3cfd1d FM |
119 | |
120 | // authfail.c | |
16b013cc FM |
121 | void authfail_open(void); |
122 | void authfail_write(const struct ReadLogStruct *log_entry); | |
123 | void authfail_close(void); | |
124 | bool is_authfail(void); | |
5f3cfd1d | 125 | void authfail_report(void); |
16b013cc | 126 | void authfail_cleanup(void); |
5f3cfd1d FM |
127 | |
128 | // charset.c | |
129 | void ccharset(char *CharSet); | |
130 | ||
131 | // convlog.c | |
81a022d8 | 132 | void convlog(const char* arq, char df, int dfrom, int duntil); |
5f3cfd1d FM |
133 | |
134 | // css.c | |
d183fb7f | 135 | void css_content(FILE *fp_css); |
5f3cfd1d FM |
136 | void css(FILE *fp_css); |
137 | ||
138 | // dansguardian_log.c | |
139 | void dansguardian_log(void); | |
140 | ||
141 | // dansguardian_report.c | |
142 | void dansguardian_report(void); | |
143 | ||
144 | // datafile.c | |
145 | void data_file(char *tmp); | |
146 | ||
147 | // decomp.c | |
d2855b39 | 148 | FILE *decomp(const char *arq, bool *pipe); |
5f3cfd1d FM |
149 | |
150 | // denied.c | |
8e53b2e7 FM |
151 | void denied_open(void); |
152 | void denied_write(const struct ReadLogStruct *log_entry); | |
153 | void denied_close(void); | |
154 | bool is_denied(void); | |
5f3cfd1d | 155 | void gen_denied_report(void); |
60b48ae5 | 156 | void denied_cleanup(void); |
5f3cfd1d FM |
157 | |
158 | // download.c | |
11284535 FM |
159 | void download_open(void); |
160 | void download_write(const struct ReadLogStruct *log_entry,const char *url); | |
161 | void download_close(void); | |
162 | bool is_download(void); | |
5f3cfd1d | 163 | void download_report(void); |
6e792ade FM |
164 | void free_download(void); |
165 | void set_download_suffix(const char *list); | |
2824ec9b | 166 | bool is_download_suffix(const char *url); |
11284535 | 167 | void download_cleanup(void); |
5f3cfd1d FM |
168 | |
169 | // email.c | |
2824ec9b | 170 | int geramail(const char *dirname, int debug, const char *outdir, const char *email, const char *TempDir); |
5f3cfd1d FM |
171 | |
172 | // exclude.c | |
43f18f45 FM |
173 | void gethexclude(const char *hexfile, int debug); |
174 | void getuexclude(const char *uexfile, int debug); | |
175 | int vhexclude(const char *url); | |
176 | int vuexclude(const char *user); | |
2824ec9b | 177 | bool is_indexonly(void); |
43f18f45 | 178 | void free_exclude(void); |
5f3cfd1d | 179 | |
6068ae56 FM |
180 | #ifndef HAVE_FNMATCH |
181 | // fnmtach.c | |
182 | int fnmatch(const char *pattern,const char *string,int flags); | |
183 | #endif | |
184 | ||
5f3cfd1d FM |
185 | // getconf.c |
186 | void getconf(void); | |
187 | ||
188 | // grepday.c | |
1f482a8d | 189 | void greport_prepare(void); |
f2ec8c75 | 190 | void greport_day(const struct userinfostruct *user); |
c274f011 | 191 | void greport_cleanup(void); |
5f3cfd1d FM |
192 | |
193 | // html.c | |
194 | void htmlrel(void); | |
195 | ||
196 | // indexonly.c | |
197 | void index_only(const char *dirname,int debug); | |
198 | ||
199 | // ip2name.c | |
51b166d4 FM |
200 | int ip2name_config(const char *param); |
201 | void ip2name_forcedns(void); | |
5f3cfd1d | 202 | void ip2name(char *ip,int ip_len); |
0326d73b | 203 | void ip2name_cleanup(void); |
4afbb7a5 | 204 | void name2ip(char *name,int name_size); |
5f3cfd1d | 205 | |
5f3cfd1d FM |
206 | // lastlog.c |
207 | void mklastlog(const char *outdir); | |
208 | ||
afaa3b67 | 209 | // longline.c |
fa6552b0 | 210 | __attribute__((warn_unused_result)) /*@null@*//*@only@*/longline longline_create(void); |
afaa3b67 FM |
211 | void longline_reset(longline line); |
212 | /*@null@*/char *longline_read(FILE *fp_in,/*@null@*/longline line); | |
213 | void longline_destroy(/*@out@*//*@only@*//*@null@*/longline *line_ptr); | |
214 | ||
5f3cfd1d FM |
215 | // index.c |
216 | void make_index(void); | |
217 | ||
27d1fa35 FM |
218 | // readlog.c |
219 | int ReadLogFile(struct ReadLogDataStruct *Filter); | |
220 | ||
5f3cfd1d FM |
221 | // realtime.c |
222 | void realtime(void); | |
223 | ||
330b1c52 FM |
224 | // redirector.c |
225 | void redirector_log(void); | |
226 | void redirector_report(void); | |
227 | ||
5f3cfd1d | 228 | // repday.c |
f2ec8c75 | 229 | void report_day(const struct userinfostruct *user); |
5f3cfd1d FM |
230 | |
231 | // report.c | |
5f3cfd1d | 232 | void gerarel(void); |
2240dcea | 233 | int ger_read(char *buffer,struct generalitemstruct *item,const char *filename); |
9dc20988 | 234 | void totalger(FILE *fp_gen,const char *filename); |
5f3cfd1d FM |
235 | |
236 | // siteuser.c | |
237 | void siteuser(void); | |
238 | ||
239 | // smartfilter.c | |
240 | void smartfilter_report(void); | |
241 | ||
242 | // sort.c | |
461b479d | 243 | void sort_users_log(const char *tmp, int debug,struct userinfostruct *uinfo); |
e5b3a129 | 244 | void tmpsort(const struct userinfostruct *uinfo); |
15d5372b | 245 | void sort_labels(const char **label,const char **order); |
5f3cfd1d FM |
246 | |
247 | // splitlog.c | |
81a022d8 | 248 | void splitlog(const char *arq, char df, int dfrom, int duntil, int convert, const char *splitprefix); |
5f3cfd1d | 249 | |
5f3cfd1d FM |
250 | // topsites.c |
251 | void topsites(void); | |
252 | ||
253 | // topuser.c | |
254 | void topuser(void); | |
255 | ||
256 | // totday.c | |
026ddd8b FM |
257 | DayObject day_prepare(void); |
258 | void day_cleanup(DayObject ddata); | |
259 | void day_newuser(DayObject ddata); | |
260 | void day_addpoint(DayObject ddata,const char *date, const char *time, long long int elap, long long int bytes); | |
261 | void day_totalize(DayObject ddata,const char *tmp, const struct userinfostruct *uinfo); | |
5f3cfd1d | 262 | |
22715352 FM |
263 | // url.c |
264 | void read_hostalias(const char *Filename); | |
265 | void free_hostalias(void); | |
6fa33a32 | 266 | const char *skip_scheme(const char *url); |
e2379f05 | 267 | const char *process_url(const char *url,bool full_url); |
22715352 FM |
268 | void url_hostname(const char *url,char *hostname,int hostsize); |
269 | ||
5f3cfd1d FM |
270 | // usage.c |
271 | void usage(const char *prog); | |
272 | ||
273 | // useragent.c | |
274 | void useragent(void); | |
275 | ||
f2ec8c75 | 276 | // userinfo.c |
aa6ac9f2 | 277 | /*@shared@*/struct userinfostruct *userinfo_create(const char *userid, const char *ip); |
f2ec8c75 | 278 | void userinfo_free(void); |
b6b6cb8c | 279 | void userinfo_label(struct userinfostruct *uinfo,const char *label); |
4ca814cc FM |
280 | /*@shared@*/struct userinfostruct *userinfo_find_from_file(const char *filename); |
281 | /*@shared@*/struct userinfostruct *userinfo_find_from_id(const char *id); | |
93551487 FM |
282 | userscan userinfo_startscan(void); |
283 | void userinfo_stopscan(userscan uscan); | |
284 | struct userinfostruct *userinfo_advancescan(userscan uscan); | |
a58e6d54 | 285 | void userinfo_clearflag(void); |
c4f0ea8f FM |
286 | void read_useralias(const char *Filename); |
287 | void free_useralias(void); | |
288 | const char *process_user(const char *user); | |
f2ec8c75 | 289 | |
965c4a6f FM |
290 | // usertab.c |
291 | void init_usertab(const char *UserTabFile); | |
292 | void user_find(char *mappedname, int namelen, const char *userlogin); | |
293 | void close_usertab(void); | |
294 | ||
5f3cfd1d | 295 | // util.c |
06b39c87 | 296 | void getword_start(/*@out@*/struct getwordstruct *gwarea, const char *line); |
9c7c6346 | 297 | void getword_restart(struct getwordstruct *gwarea); |
d5a1c7f9 FM |
298 | __attribute__((warn_unused_result)) int getword(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop); |
299 | __attribute__((warn_unused_result)) int getword_limit(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop); | |
300 | __attribute__((warn_unused_result)) int getword_multisep(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop); | |
301 | __attribute__((warn_unused_result)) int getword_skip(int limit, struct getwordstruct *gwarea, char stop); | |
302 | __attribute__((warn_unused_result)) int getword_atoll(/*@out@*/long long int *number, struct getwordstruct *gwarea, char stop); | |
bd8b7715 | 303 | __attribute__((warn_unused_result)) int getword_atoi(/*@out@*/int *number, struct getwordstruct *gwarea, char stop); |
2c4bc22b FM |
304 | __attribute__((warn_unused_result)) int getword_atol(long int *number, struct getwordstruct *gwarea, char stop); |
305 | __attribute__((warn_unused_result)) int getword_atolu(unsigned long int *number, struct getwordstruct *gwarea, char stop); | |
d5a1c7f9 | 306 | __attribute__((warn_unused_result)) int getword_ptr(char *orig_line,/*@out@*/char **word, struct getwordstruct *gwarea, char stop); |
e6414a9d FM |
307 | long long int my_atoll (const char *nptr); |
308 | int is_absolute(const char *path); | |
e3af0ae9 | 309 | int getnumlist(char *, numlist *, const int, const int); |
5f3cfd1d | 310 | void name_month(char *month,int month_len); |
fa6552b0 FM |
311 | int conv_month(const char *month); |
312 | const char *conv_month_name(int month); | |
5f3cfd1d | 313 | void buildymd(const char *dia, const char *mes, const char *ano, char *wdata); |
42b117e3 | 314 | void date_from(char *date, int *dfrom, int *duntil); |
5f3cfd1d FM |
315 | char *fixnum(long long int value, int n); |
316 | char *fixnum2(long long int value, int n); | |
317 | void fixnone(char *str); | |
324ba7f3 | 318 | char *fixtime(long long int elap); |
2357ef77 | 319 | void fixendofline(char *str); |
5f3cfd1d | 320 | void show_info(FILE *fp_ou); |
c0ec9cc7 | 321 | void show_sarg(FILE *fp_ou, int depth); |
dfb337be | 322 | void write_logo_image(FILE *fp_ou); |
2e96438d FM |
323 | void write_html_head(FILE *fp_ou, int depth, const char *page_title,int javascript); |
324 | void write_html_header(FILE *fp_ou, int depth, const char *title,int javascript); | |
c0ec9cc7 | 325 | void close_html_header(FILE *fp_ou); |
fa6552b0 | 326 | __attribute__((warn_unused_result)) int write_html_trailer(FILE *fp_ou); |
ac422f9b FM |
327 | void output_html_string(FILE *fp_ou,const char *str,int maxlen); |
328 | void output_html_url(FILE *fp_ou,const char *url); | |
6fa33a32 | 329 | void output_html_link(FILE *fp_ou,const char *url,int maxlen); |
f0126186 | 330 | void debuga(const char *msg,...) __attribute__((format(printf,1,2))); |
9f93fec3 | 331 | void debugaz(const char *msg,...) __attribute__((format(printf,1,2))); |
e5b2c6f0 | 332 | void my_lltoa(unsigned long long int n, char *s, int ssize, int len); |
5f3cfd1d | 333 | char *get_size(const char *path, const char *file); |
48864d28 | 334 | void url_module(const char *url, char *w2); |
f72b484a | 335 | void url_to_anchor(const char *url,char *anchor,int size); |
a87d4d11 | 336 | void safe_strcpy(char *dest,const char *src,int length); |
5f3cfd1d FM |
337 | void strip_latin(char *line); |
338 | char *buildtime(long long int elap); | |
15d3cb5c | 339 | int obtdate(const char *dirname, const char *name, char *data); |
a1de61fe | 340 | void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second,int dst); |
fa6552b0 | 341 | void computedate(int year,int month,int day,struct tm *t); |
d25d4e6a | 342 | int obtuser(const char *dirname, const char *name); |
ea275279 | 343 | void obttotal(const char *dirname, const char *name, int nuser, long long int *tbytes, long long int *media); |
5f3cfd1d FM |
344 | void version(void); |
345 | int vercode(const char *code); | |
48864d28 FM |
346 | void load_excludecodes(const char *ExcludeCodes); |
347 | void free_excludecodes(void); | |
5f3cfd1d FM |
348 | void my_mkdir(const char *name); |
349 | int testvaliduserchar(const char *user); | |
350 | char *strlow(char *string); | |
351 | char *strup(char *string); | |
fa6552b0 FM |
352 | int month2num(const char *month); |
353 | int builddia(int day, int month, int year); | |
944cf283 | 354 | int compare_date(struct tm *date1,struct tm *date2); |
fa6552b0 FM |
355 | int vrfydir(const struct periodstruct *per1, const char *addr, const char *site, const char *us, const char *form); |
356 | int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period); | |
42b117e3 | 357 | void getperiod_fromrange(struct periodstruct *period,int dfrom,int duntil); |
cc6af460 | 358 | void getperiod_merge(struct periodstruct *main,struct periodstruct *candidate); |
fa6552b0 | 359 | int getperiod_buildtext(struct periodstruct *period); |
5f3cfd1d | 360 | void removetmp(const char *outdir); |
81a022d8 | 361 | void zdate(char *ftime,int ftimesize, char DateFormat); |
5f3cfd1d | 362 | char *get_param_value(const char *param,char *line); |
48864d28 | 363 | int compar( const void *, const void * ); |
170a77ea FM |
364 | void unlinkdir(const char *dir,bool contentonly); |
365 | void emptytmpdir(const char *dir); | |
7819e0d5 | 366 | int extract_address_mask(const char *buf,const char **text,unsigned char *ipv4,unsigned short int *ipv6,int *nbits,const char **next); |