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