]>
git.ipfire.org Git - thirdparty/sarg.git/blob - include/defs.h
b0802ab87d0105dfde8091391c0025e4abfe6a3b
2 \brief Declaration of the structures and functions.
6 #define __attribute__(a)
9 struct ReadLogStruct
;//forward declaration
14 const char *beginning
;
18 typedef struct longlinestruct
*longline
;
20 struct generalitemstruct
22 //! \c True if the entry is for the total of the file or \c false if it is a single line.
24 //! The user to which the entry apply. The length is limited to ::MAX_USER_LEN.
26 //! The number of accesses performed by the user.
28 //! The number of bytes transfered.
30 //! The URL accessed by the user. The length is not limited.
32 //! The source IP address of the user. The length is limited to ::MAX_IP_LEN.
34 //! The time of the access. The length is limited to ::MAX_DATETIME_LEN.
36 //! The date of the access. The length is limited to ::MAX_DATETIME_LEN.
38 //! The number of milliseconds spend processing the request.
40 //! The number of bytes fetched from the cache of the proxy (cache hit).
42 //! The number of bytes fetched from the site (cache miss).
46 /*! \brief What is known about a user.
50 //! The ID of the user as found in the input file.
52 //! The user's IP address.
54 //! \c True if the ID is in fact the IP address from which the user connected.
56 //! \c True if the user doesn't have a report file.
58 //! The name of the user to display in the report.
60 //! The mangled name to use in file names of that user.
62 //! \c True if this user is in the topuser list.
64 //! A general purpose flag that can be set when scanning the user's list.
66 #ifdef ENABLE_DOUBLE_CHECK_DATA
67 //! Total number of bytes.
69 //! Total time spent processing the requests.
74 //! Scan through the known users.
75 typedef struct userscanstruct
*userscan
;
77 /*! \brief Global statistics
79 struct globalstatstruct
81 //! Total number of accesses.
83 //! Total number of bytes.
85 //! Total time spent processing the requests.
87 //! Amount of data fetched from the cache.
88 long long int incache
;
89 //! Amount of data not fetched from the cache.
90 long long int oucache
;
91 //! The number of users in the topuser list.
95 //! The object to store the daily statistics.
96 typedef struct DayStruct
*DayObject
;
99 \brief Log filtering criterion.
101 struct ReadLogDataStruct
103 //! The filtering date range.
105 //! \c True to filter on hosts.
107 //! \c True to filter on users.
109 //! Maximum elpased time allowed. Any time greater than this value is set to zero.
110 long int max_elapsed
;
111 //! \c True to restrict the log to the system users.
113 //! The start time to include in the report(H*100+M). Set to -1 to disable.
115 //! The end time to include in the report(H*100+M). Set to -1 to disable.
120 \brief How to handle the per_user_limit file creation.
122 enum PerUserFileCreationEnum
124 //! Purge the file if it exists or create an empty file.
126 //! Delete old files and don't create a new file unless necessary.
131 \brief How to log every user crossing the download limit.
133 struct PerUserLimitStruct
135 //! File to save the user's IP or ID to.
137 //! Limit above which the user is reported.
139 //! \c True to report the user's ID or \c false to report the user's IP.
144 void htaccess(const struct userinfostruct
*uinfo
);
147 void authfail_open(void);
148 void authfail_write(const struct ReadLogStruct
*log_entry
);
149 void authfail_close(void);
150 bool is_authfail(void);
151 void authfail_report(void);
152 void authfail_cleanup(void);
155 void ccharset(char *CharSet
);
158 void convlog(const char* arq
, char df
, int dfrom
, int duntil
);
161 void css_content(FILE *fp_css
);
162 void css(FILE *fp_css
);
164 // dansguardian_log.c
165 void dansguardian_log(void);
167 // dansguardian_report.c
168 void dansguardian_report(void);
171 void data_file(char *tmp
);
174 FILE *decomp(const char *arq
, bool *pipe
);
177 void denied_open(void);
178 void denied_write(const struct ReadLogStruct
*log_entry
);
179 void denied_close(void);
180 bool is_denied(void);
181 void gen_denied_report(void);
182 void denied_cleanup(void);
185 void download_open(void);
186 void download_write(const struct ReadLogStruct
*log_entry
,const char *url
);
187 void download_close(void);
188 bool is_download(void);
189 void download_report(void);
190 void free_download(void);
191 void set_download_suffix(const char *list
);
192 bool is_download_suffix(const char *url
);
193 void download_cleanup(void);
196 int geramail(const char *dirname
, int debug
, const char *outdir
, const char *email
, const char *TempDir
);
199 void gethexclude(const char *hexfile
, int debug
);
200 void getuexclude(const char *uexfile
, int debug
);
201 int vhexclude(const char *url
);
202 int vuexclude(const char *user
);
203 bool is_indexonly(void);
204 void free_exclude(void);
208 int fnmatch(const char *pattern
,const char *string
,int flags
);
215 void greport_prepare(void);
216 void greport_day(const struct userinfostruct
*user
);
217 void greport_cleanup(void);
223 void index_only(const char *dirname
,int debug
);
226 int ip2name_config(const char *param
);
227 void ip2name_forcedns(void);
228 void ip2name(char *ip
,int ip_len
);
229 void ip2name_cleanup(void);
230 void name2ip(char *name
,int name_size
);
233 void mklastlog(const char *outdir
);
236 __attribute__((warn_unused_result
)) /*@null@*//*@only@*/longline
longline_create(void);
237 void longline_reset(longline line
);
238 /*@null@*/char *longline_read(FILE *fp_in
,/*@null@*/longline line
);
239 void longline_destroy(/*@out@*//*@only@*//*@null@*/longline
*line_ptr
);
242 void make_index(void);
245 int ReadLogFile(struct ReadLogDataStruct
*Filter
);
251 void redirector_log(void);
252 void redirector_report(void);
255 void report_day(const struct userinfostruct
*user
);
259 int ger_read(char *buffer
,struct generalitemstruct
*item
,const char *filename
);
260 void totalger(FILE *fp_gen
,const char *filename
);
266 void smartfilter_report(void);
269 void sort_users_log(const char *tmp
, int debug
,struct userinfostruct
*uinfo
);
270 void tmpsort(const struct userinfostruct
*uinfo
);
271 void sort_labels(const char **label
,const char **order
);
274 void splitlog(const char *arq
, char df
, int dfrom
, int duntil
, int convert
, const char *splitprefix
);
283 DayObject
day_prepare(void);
284 void day_cleanup(DayObject ddata
);
285 void day_newuser(DayObject ddata
);
286 void day_addpoint(DayObject ddata
,const char *date
, const char *time
, long long int elap
, long long int bytes
);
287 void day_totalize(DayObject ddata
,const char *tmp
, const struct userinfostruct
*uinfo
);
288 void day_deletefile(const struct userinfostruct
*uinfo
);
291 void read_hostalias(const char *Filename
);
292 void free_hostalias(void);
293 const char *skip_scheme(const char *url
);
294 const char *process_url(const char *url
,bool full_url
);
295 void url_hostname(const char *url
,char *hostname
,int hostsize
);
298 void usage(const char *prog
);
301 void useragent(void);
304 /*@shared@*/struct userinfostruct
*userinfo_create(const char *userid
, const char *ip
);
305 void userinfo_free(void);
306 void userinfo_label(struct userinfostruct
*uinfo
,const char *label
);
307 /*@shared@*/struct userinfostruct
*userinfo_find_from_file(const char *filename
);
308 /*@shared@*/struct userinfostruct
*userinfo_find_from_id(const char *id
);
309 /*@shared@*/struct userinfostruct
*userinfo_find_from_ip(const char *ip
);
310 userscan
userinfo_startscan(void);
311 void userinfo_stopscan(userscan uscan
);
312 struct userinfostruct
*userinfo_advancescan(userscan uscan
);
313 void userinfo_clearflag(void);
314 void read_useralias(const char *Filename
);
315 void free_useralias(void);
316 const char *process_user(const char *user
);
319 void init_usertab(const char *UserTabFile
);
320 void user_find(char *mappedname
, int namelen
, const char *userlogin
);
321 void close_usertab(void);
324 void getword_start(/*@out@*/struct getwordstruct
*gwarea
, const char *line
);
325 void getword_restart(struct getwordstruct
*gwarea
);
326 __attribute__((warn_unused_result
)) int getword(/*@out@*/char *word
, int limit
, struct getwordstruct
*gwarea
, char stop
);
327 __attribute__((warn_unused_result
)) int getword_limit(/*@out@*/char *word
, int limit
, struct getwordstruct
*gwarea
, char stop
);
328 __attribute__((warn_unused_result
)) int getword_multisep(/*@out@*/char *word
, int limit
, struct getwordstruct
*gwarea
, char stop
);
329 __attribute__((warn_unused_result
)) int getword_skip(int limit
, struct getwordstruct
*gwarea
, char stop
);
330 __attribute__((warn_unused_result
)) int getword_atoll(/*@out@*/long long int *number
, struct getwordstruct
*gwarea
, char stop
);
331 __attribute__((warn_unused_result
)) int getword_atoi(/*@out@*/int *number
, struct getwordstruct
*gwarea
, char stop
);
332 __attribute__((warn_unused_result
)) int getword_atol(long int *number
, struct getwordstruct
*gwarea
, char stop
);
333 __attribute__((warn_unused_result
)) int getword_atolu(unsigned long int *number
, struct getwordstruct
*gwarea
, char stop
);
334 __attribute__((warn_unused_result
)) int getword_ptr(char *orig_line
,/*@out@*/char **word
, struct getwordstruct
*gwarea
, char stop
);
335 long long int my_atoll (const char *nptr
);
336 int is_absolute(const char *path
);
337 int getnumlist(char *, numlist
*, const int, const int);
338 void name_month(char *month
,int month_len
);
339 int conv_month(const char *month
);
340 const char *conv_month_name(int month
);
341 void buildymd(const char *dia
, const char *mes
, const char *ano
, char *wdata
);
342 void date_from(char *date
, int *dfrom
, int *duntil
);
343 char *fixnum(long long int value
, int n
);
344 char *fixnum2(long long int value
, int n
);
345 void fixnone(char *str
);
346 char *fixtime(long long int elap
);
347 void fixendofline(char *str
);
348 void show_info(FILE *fp_ou
);
349 void show_sarg(FILE *fp_ou
, int depth
);
350 void write_logo_image(FILE *fp_ou
);
351 void write_html_head(FILE *fp_ou
, int depth
, const char *page_title
,int javascript
);
352 void write_html_header(FILE *fp_ou
, int depth
, const char *title
,int javascript
);
353 void close_html_header(FILE *fp_ou
);
354 __attribute__((warn_unused_result
)) int write_html_trailer(FILE *fp_ou
);
355 void output_html_string(FILE *fp_ou
,const char *str
,int maxlen
);
356 void output_html_url(FILE *fp_ou
,const char *url
);
357 void output_html_link(FILE *fp_ou
,const char *url
,int maxlen
);
358 void debuga(const char *msg
,...) __attribute__((format(printf
,1,2)));
359 void debugaz(const char *msg
,...) __attribute__((format(printf
,1,2)));
360 void my_lltoa(unsigned long long int n
, char *s
, int ssize
, int len
);
361 char *get_size(const char *path
, const char *file
);
362 void url_module(const char *url
, char *w2
);
363 void url_to_anchor(const char *url
,char *anchor
,int size
);
364 void safe_strcpy(char *dest
,const char *src
,int length
);
365 void strip_latin(char *line
);
366 char *buildtime(long long int elap
);
367 int obtdate(const char *dirname
, const char *name
, char *data
);
368 void formatdate(char *date
,int date_size
,int year
,int month
,int day
,int hour
,int minute
,int second
,int dst
);
369 void computedate(int year
,int month
,int day
,struct tm
*t
);
370 int obtuser(const char *dirname
, const char *name
);
371 void obttotal(const char *dirname
, const char *name
, int nuser
, long long int *tbytes
, long long int *media
);
373 int vercode(const char *code
);
374 void load_excludecodes(const char *ExcludeCodes
);
375 void free_excludecodes(void);
376 void my_mkdir(const char *name
);
377 int testvaliduserchar(const char *user
);
378 char *strlow(char *string
);
379 char *strup(char *string
);
380 int month2num(const char *month
);
381 int builddia(int day
, int month
, int year
);
382 int compare_date(struct tm
*date1
,struct tm
*date2
);
383 int vrfydir(const struct periodstruct
*per1
, const char *addr
, const char *site
, const char *us
, const char *form
);
384 int getperiod_fromsarglog(const char *arqtt
,struct periodstruct
*period
);
385 void getperiod_fromrange(struct periodstruct
*period
,int dfrom
,int duntil
);
386 void getperiod_merge(struct periodstruct
*main
,struct periodstruct
*candidate
);
387 int getperiod_buildtext(struct periodstruct
*period
);
388 void removetmp(const char *outdir
);
389 void zdate(char *ftime
,int ftimesize
, char DateFormat
);
390 char *get_param_value(const char *param
,char *line
);
391 int compar( const void *, const void * );
392 void unlinkdir(const char *dir
,bool contentonly
);
393 void emptytmpdir(const char *dir
);
394 int extract_address_mask(const char *buf
,const char **text
,unsigned char *ipv4
,unsigned short int *ipv6
,int *nbits
,const char **next
);