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