]>
git.ipfire.org Git - thirdparty/sarg.git/blob - include/defs.h
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 What to write into the per_user_limit file.
133 enum PerUserOutputEnum
140 \brief How to log every user crossing the download limit.
142 struct PerUserLimitStruct
144 //! File to save the user's IP or ID to.
146 //! Limit above which the user is reported.
148 //! What to write into the file.
149 enum PerUserOutputEnum Output
;
153 void htaccess(const struct userinfostruct
*uinfo
);
156 void authfail_open(void);
157 void authfail_write(const struct ReadLogStruct
*log_entry
);
158 void authfail_close(void);
159 bool is_authfail(void);
160 void authfail_report(void);
161 void authfail_cleanup(void);
164 void ccharset(char *CharSet
);
167 void convlog(const char* arq
, char df
, int dfrom
, int duntil
);
170 void css_content(FILE *fp_css
);
171 void css(FILE *fp_css
);
173 // dansguardian_log.c
174 void dansguardian_log(void);
176 // dansguardian_report.c
177 void dansguardian_report(void);
180 void data_file(char *tmp
);
183 FILE *decomp(const char *arq
, bool *pipe
);
186 void denied_open(void);
187 void denied_write(const struct ReadLogStruct
*log_entry
);
188 void denied_close(void);
189 bool is_denied(void);
190 void gen_denied_report(void);
191 void denied_cleanup(void);
194 void download_open(void);
195 void download_write(const struct ReadLogStruct
*log_entry
,const char *url
);
196 void download_close(void);
197 bool is_download(void);
198 void download_report(void);
199 void free_download(void);
200 void set_download_suffix(const char *list
);
201 bool is_download_suffix(const char *url
);
202 void download_cleanup(void);
205 int geramail(const char *dirname
, int debug
, const char *outdir
, const char *email
, const char *TempDir
);
208 void gethexclude(const char *hexfile
, int debug
);
209 void getuexclude(const char *uexfile
, int debug
);
210 int vhexclude(const char *url
);
211 int vuexclude(const char *user
);
212 bool is_indexonly(void);
213 void free_exclude(void);
217 int fnmatch(const char *pattern
,const char *string
,int flags
);
224 void greport_prepare(void);
225 void greport_day(const struct userinfostruct
*user
);
226 void greport_cleanup(void);
232 void index_only(const char *dirname
,int debug
);
235 int ip2name_config(const char *param
);
236 void ip2name_forcedns(void);
237 void ip2name(char *ip
,int ip_len
);
238 void ip2name_cleanup(void);
239 void name2ip(char *name
,int name_size
);
242 void mklastlog(const char *outdir
);
245 __attribute__((warn_unused_result
)) /*@null@*//*@only@*/longline
longline_create(void);
246 void longline_reset(longline line
);
247 /*@null@*/char *longline_read(FILE *fp_in
,/*@null@*/longline line
);
248 void longline_destroy(/*@out@*//*@only@*//*@null@*/longline
*line_ptr
);
251 void make_index(void);
254 int ReadLogFile(struct ReadLogDataStruct
*Filter
);
255 void GetLogPeriod(struct tm
*Start
,struct tm
*End
);
261 void redirector_log(void);
262 void redirector_report(void);
265 void report_day(const struct userinfostruct
*user
);
269 int ger_read(char *buffer
,struct generalitemstruct
*item
,const char *filename
);
270 void totalger(FILE *fp_gen
,const char *filename
);
276 void smartfilter_report(void);
279 void sort_users_log(const char *tmp
, int debug
,struct userinfostruct
*uinfo
);
280 void tmpsort(const struct userinfostruct
*uinfo
);
281 void sort_labels(const char **label
,const char **order
);
284 void splitlog(const char *arq
, char df
, int dfrom
, int duntil
, int convert
, const char *splitprefix
);
293 DayObject
day_prepare(void);
294 void day_cleanup(DayObject ddata
);
295 void day_newuser(DayObject ddata
);
296 void day_addpoint(DayObject ddata
,const char *date
, const char *time
, long long int elap
, long long int bytes
);
297 void day_totalize(DayObject ddata
,const char *tmp
, const struct userinfostruct
*uinfo
);
298 void day_deletefile(const struct userinfostruct
*uinfo
);
301 void read_hostalias(const char *Filename
);
302 void free_hostalias(void);
303 const char *skip_scheme(const char *url
);
304 const char *process_url(const char *url
,bool full_url
);
305 void url_hostname(const char *url
,char *hostname
,int hostsize
);
308 void usage(const char *prog
);
311 void useragent(void);
314 /*@shared@*/struct userinfostruct
*userinfo_create(const char *userid
, const char *ip
);
315 void userinfo_free(void);
316 void userinfo_label(struct userinfostruct
*uinfo
,const char *label
);
317 /*@shared@*/struct userinfostruct
*userinfo_find_from_file(const char *filename
);
318 /*@shared@*/struct userinfostruct
*userinfo_find_from_id(const char *id
);
319 /*@shared@*/struct userinfostruct
*userinfo_find_from_ip(const char *ip
);
320 userscan
userinfo_startscan(void);
321 void userinfo_stopscan(userscan uscan
);
322 struct userinfostruct
*userinfo_advancescan(userscan uscan
);
323 void userinfo_clearflag(void);
324 void read_useralias(const char *Filename
);
325 void free_useralias(void);
326 const char *process_user(const char *user
);
329 void init_usertab(const char *UserTabFile
);
330 void user_find(char *mappedname
, int namelen
, const char *userlogin
);
331 void close_usertab(void);
334 void getword_start(/*@out@*/struct getwordstruct
*gwarea
, const char *line
);
335 void getword_restart(struct getwordstruct
*gwarea
);
336 __attribute__((warn_unused_result
)) int getword(/*@out@*/char *word
, int limit
, struct getwordstruct
*gwarea
, char stop
);
337 __attribute__((warn_unused_result
)) int getword_limit(/*@out@*/char *word
, int limit
, struct getwordstruct
*gwarea
, char stop
);
338 __attribute__((warn_unused_result
)) int getword_multisep(/*@out@*/char *word
, int limit
, struct getwordstruct
*gwarea
, char stop
);
339 __attribute__((warn_unused_result
)) int getword_skip(int limit
, struct getwordstruct
*gwarea
, char stop
);
340 __attribute__((warn_unused_result
)) int getword_atoll(/*@out@*/long long int *number
, struct getwordstruct
*gwarea
, char stop
);
341 __attribute__((warn_unused_result
)) int getword_atoi(/*@out@*/int *number
, struct getwordstruct
*gwarea
, char stop
);
342 __attribute__((warn_unused_result
)) int getword_atol(long int *number
, struct getwordstruct
*gwarea
, char stop
);
343 __attribute__((warn_unused_result
)) int getword_atolu(unsigned long int *number
, struct getwordstruct
*gwarea
, char stop
);
344 __attribute__((warn_unused_result
)) int getword_ptr(char *orig_line
,/*@out@*/char **word
, struct getwordstruct
*gwarea
, char stop
);
345 long long int my_atoll (const char *nptr
);
346 int is_absolute(const char *path
);
347 int getnumlist(char *, numlist
*, const int, const int);
348 int conv_month(const char *month
);
349 const char *conv_month_name(int month
);
350 void buildymd(const char *dia
, const char *mes
, const char *ano
, char *wdata
,int wdata_size
);
351 void date_from(char *date
,int date_size
, int *dfrom
, int *duntil
);
352 char *fixnum(long long int value
, int n
);
353 char *fixnum2(long long int value
, int n
);
354 void fixnone(char *str
);
355 char *fixtime(long long int elap
);
356 void fixendofline(char *str
);
357 void show_info(FILE *fp_ou
);
358 void show_sarg(FILE *fp_ou
, int depth
);
359 void write_logo_image(FILE *fp_ou
);
360 void write_html_head(FILE *fp_ou
, int depth
, const char *page_title
,int javascript
);
361 void write_html_header(FILE *fp_ou
, int depth
, const char *title
,int javascript
);
362 void close_html_header(FILE *fp_ou
);
363 __attribute__((warn_unused_result
)) int write_html_trailer(FILE *fp_ou
);
364 void output_html_string(FILE *fp_ou
,const char *str
,int maxlen
);
365 void output_html_url(FILE *fp_ou
,const char *url
);
366 void output_html_link(FILE *fp_ou
,const char *url
,int maxlen
);
367 void debuga(const char *msg
,...) __attribute__((format(printf
,1,2)));
368 void debugaz(const char *msg
,...) __attribute__((format(printf
,1,2)));
369 void my_lltoa(unsigned long long int n
, char *s
, int ssize
, int len
);
370 void url_module(const char *url
, char *w2
);
371 void url_to_anchor(const char *url
,char *anchor
,int size
);
372 void safe_strcpy(char *dest
,const char *src
,int length
);
373 void strip_latin(char *line
);
374 char *buildtime(long long int elap
);
375 int obtdate(const char *dirname
, const char *name
, char *data
);
376 void formatdate(char *date
,int date_size
,int year
,int month
,int day
,int hour
,int minute
,int second
,int dst
);
377 void computedate(int year
,int month
,int day
,struct tm
*t
);
378 int obtuser(const char *dirname
, const char *name
);
379 void obttotal(const char *dirname
, const char *name
, int nuser
, long long int *tbytes
, long long int *media
);
381 int vercode(const char *code
);
382 void load_excludecodes(const char *ExcludeCodes
);
383 void free_excludecodes(void);
384 void my_mkdir(const char *name
);
385 int testvaliduserchar(const char *user
);
386 char *strlow(char *string
);
387 char *strup(char *string
);
388 int month2num(const char *month
);
389 int builddia(int day
, int month
, int year
);
390 int compare_date(struct tm
*date1
,struct tm
*date2
);
391 bool IsTreeFileDirName(const char *Name
);
392 bool IsTreeYearFileName(const char *Name
);
393 bool IsTreeMonthFileName(const char *Name
);
394 bool IsTreeDayFileName(const char *Name
);
395 int vrfydir(const struct periodstruct
*per1
, const char *addr
, const char *site
, const char *us
, const char *form
);
396 int getperiod_fromsarglog(const char *arqtt
,struct periodstruct
*period
);
397 void getperiod_fromrange(struct periodstruct
*period
,int dfrom
,int duntil
);
398 void getperiod_merge(struct periodstruct
*main
,struct periodstruct
*candidate
);
399 int getperiod_buildtext(struct periodstruct
*period
);
400 void removetmp(const char *outdir
);
401 void zdate(char *ftime
,int ftimesize
, char DateFormat
);
402 char *get_param_value(const char *param
,char *line
);
403 int compar( const void *, const void * );
404 void unlinkdir(const char *dir
,bool contentonly
);
405 void emptytmpdir(const char *dir
);
406 int extract_address_mask(const char *buf
,const char **text
,unsigned char *ipv4
,unsigned short int *ipv6
,int *nbits
,const char **next
);