]>
git.ipfire.org Git - thirdparty/sarg.git/blob - include/defs.h
cd181e66db093389b32fbd83a8770c85f74ae511
2 \brief Declaration of the structures and functions.
6 #define __attribute__(a)
9 //! \brief Constants to compare the log level to display messages
12 //! Process informational messages.
14 //! Debug level messages.
16 //! Display the source file name and line number along with the message.
18 //! Display data about what is processed
22 struct ReadLogStruct
;//forward declaration
27 const char *beginning
;
31 typedef struct longlinestruct
*longline
;
33 struct generalitemstruct
35 //! \c True if the entry is for the total of the file or \c false if it is a single line.
37 //! The user to which the entry apply. The length is limited to ::MAX_USER_LEN.
39 //! The number of accesses performed by the user.
41 //! The number of bytes transfered.
43 //! The URL accessed by the user. The length is not limited.
45 //! The source IP address of the user. The length is limited to ::MAX_IP_LEN.
47 //! The time of the access. The length is limited to ::MAX_DATETIME_LEN.
49 //! The date of the access. The length is limited to ::MAX_DATETIME_LEN.
51 //! The number of milliseconds spend processing the request.
53 //! The number of bytes fetched from the cache of the proxy (cache hit).
55 //! The number of bytes fetched from the site (cache miss).
59 /*! \brief What is known about a user.
63 //! The ID of the user as found in the input file.
65 //! The user's IP address.
67 //! \c True if the ID is in fact the IP address from which the user connected.
69 //! \c True if the user doesn't have a report file.
71 //! The name of the user to display in the report.
73 //! The mangled name to use in file names of that user.
75 //! \c True if this user is in the topuser list.
77 //! A general purpose flag that can be set when scanning the user's list.
79 #ifdef ENABLE_DOUBLE_CHECK_DATA
80 //! Total number of bytes.
82 //! Total time spent processing the requests.
87 //! Scan through the known users.
88 typedef struct userscanstruct
*userscan
;
90 /*! \brief Global statistics
92 struct globalstatstruct
94 //! Total number of accesses.
96 //! Total number of bytes.
98 //! Total time spent processing the requests.
100 //! Amount of data fetched from the cache.
101 long long int incache
;
102 //! Amount of data not fetched from the cache.
103 long long int oucache
;
104 //! The number of users in the topuser list.
108 //! The object to store the daily statistics.
109 typedef struct DayStruct
*DayObject
;
112 \brief Log filtering criterion.
114 struct ReadLogDataStruct
116 //! The filtering date range.
118 //! \c True to filter on hosts.
120 //! \c True to filter on users.
122 //! Maximum elpased time allowed. Any time greater than this value is set to zero.
123 long int max_elapsed
;
124 //! \c True to restrict the log to the system users.
126 //! The start time to include in the report(H*100+M). Set to -1 to disable.
128 //! The end time to include in the report(H*100+M). Set to -1 to disable.
133 \brief How to handle the per_user_limit file creation.
135 enum PerUserFileCreationEnum
137 //! Purge the file if it exists or create an empty file.
139 //! Delete old files and don't create a new file unless necessary.
144 \brief What to write into the per_user_limit file.
146 enum PerUserOutputEnum
153 \brief How to log every user crossing the download limit.
155 struct PerUserLimitStruct
157 //! File to save the user's IP or ID to.
159 //! Limit above which the user is reported.
161 //! What to write into the file.
162 enum PerUserOutputEnum Output
;
166 void htaccess(const struct userinfostruct
*uinfo
);
169 void authfail_open(void);
170 void authfail_write(const struct ReadLogStruct
*log_entry
);
171 void authfail_close(void);
172 bool is_authfail(void);
173 void authfail_report(void);
174 void authfail_cleanup(void);
177 void convlog(const char* arq
, char df
, int dfrom
, int duntil
);
180 void css_content(FILE *fp_css
);
181 void css(FILE *fp_css
);
183 // dansguardian_log.c
184 void dansguardian_log(void);
186 // dansguardian_report.c
187 void dansguardian_report(void);
190 void data_file(char *tmp
);
193 FILE *decomp(const char *arq
, bool *pipe
);
196 void denied_open(void);
197 void denied_write(const struct ReadLogStruct
*log_entry
);
198 void denied_close(void);
199 bool is_denied(void);
200 void gen_denied_report(void);
201 void denied_cleanup(void);
204 void download_open(void);
205 void download_write(const struct ReadLogStruct
*log_entry
,const char *url
);
206 void download_close(void);
207 bool is_download(void);
208 void download_report(void);
209 void free_download(void);
210 void set_download_suffix(const char *list
);
211 bool is_download_suffix(const char *url
);
212 void download_cleanup(void);
215 int geramail(const char *dirname
, int debug
, const char *outdir
, const char *email
, const char *TempDir
);
218 void gethexclude(const char *hexfile
, int debug
);
219 void getuexclude(const char *uexfile
, int debug
);
220 int vhexclude(const char *url
);
221 int vuexclude(const char *user
);
222 bool is_indexonly(void);
223 void free_exclude(void);
227 int fnmatch(const char *pattern
,const char *string
,int flags
);
234 void greport_prepare(void);
235 void greport_day(const struct userinfostruct
*user
);
236 void greport_cleanup(void);
242 void index_only(const char *dirname
,int debug
);
245 int ip2name_config(const char *param
);
246 void ip2name_forcedns(void);
247 void ip2name(char *ip
,int ip_len
);
248 void ip2name_cleanup(void);
249 void name2ip(char *name
,int name_size
);
252 void mklastlog(const char *outdir
);
255 __attribute__((warn_unused_result
)) /*@null@*//*@only@*/longline
longline_create(void);
256 void longline_reset(longline line
);
257 /*@null@*/char *longline_read(FILE *fp_in
,/*@null@*/longline line
);
258 void longline_destroy(/*@out@*//*@only@*//*@null@*/longline
*line_ptr
);
261 void make_index(void);
264 int ReadLogFile(struct ReadLogDataStruct
*Filter
);
265 void GetLogPeriod(struct tm
*Start
,struct tm
*End
);
271 void redirector_log(void);
272 void redirector_report(void);
275 void report_day(const struct userinfostruct
*user
);
279 int ger_read(char *buffer
,struct generalitemstruct
*item
,const char *filename
);
280 void totalger(FILE *fp_gen
,const char *filename
);
286 void smartfilter_report(void);
289 void sort_users_log(const char *tmp
, int debug
,struct userinfostruct
*uinfo
);
290 void tmpsort(const struct userinfostruct
*uinfo
);
291 void sort_labels(const char **label
,const char **order
);
294 void splitlog(const char *arq
, char df
, int dfrom
, int duntil
, int convert
, const char *splitprefix
);
303 DayObject
day_prepare(void);
304 void day_cleanup(DayObject ddata
);
305 void day_newuser(DayObject ddata
);
306 void day_addpoint(DayObject ddata
,const char *date
, const char *time
, long long int elap
, long long int bytes
);
307 void day_totalize(DayObject ddata
,const char *tmp
, const struct userinfostruct
*uinfo
);
308 void day_deletefile(const struct userinfostruct
*uinfo
);
311 void read_hostalias(const char *Filename
);
312 void free_hostalias(void);
313 const char *skip_scheme(const char *url
);
314 const char *process_url(const char *url
,bool full_url
);
315 void url_hostname(const char *url
,char *hostname
,int hostsize
);
318 void usage(const char *prog
);
321 void useragent(void);
324 /*@shared@*/struct userinfostruct
*userinfo_create(const char *userid
, const char *ip
);
325 void userinfo_free(void);
326 void userinfo_label(struct userinfostruct
*uinfo
,const char *label
);
327 /*@shared@*/struct userinfostruct
*userinfo_find_from_file(const char *filename
);
328 /*@shared@*/struct userinfostruct
*userinfo_find_from_id(const char *id
);
329 /*@shared@*/struct userinfostruct
*userinfo_find_from_ip(const char *ip
);
330 userscan
userinfo_startscan(void);
331 void userinfo_stopscan(userscan uscan
);
332 struct userinfostruct
*userinfo_advancescan(userscan uscan
);
333 void userinfo_clearflag(void);
334 void read_useralias(const char *Filename
);
335 void free_useralias(void);
336 const char *process_user(const char *user
);
339 void init_usertab(const char *UserTabFile
);
340 void user_find(char *mappedname
, int namelen
, const char *userlogin
);
341 void close_usertab(void);
344 void getword_start(/*@out@*/struct getwordstruct
*gwarea
, const char *line
);
345 void getword_restart(struct getwordstruct
*gwarea
);
346 __attribute__((warn_unused_result
)) int getword(/*@out@*/char *word
, int limit
, struct getwordstruct
*gwarea
, char stop
);
347 __attribute__((warn_unused_result
)) int getword_limit(/*@out@*/char *word
, int limit
, struct getwordstruct
*gwarea
, char stop
);
348 __attribute__((warn_unused_result
)) int getword_multisep(/*@out@*/char *word
, int limit
, struct getwordstruct
*gwarea
, char stop
);
349 __attribute__((warn_unused_result
)) int getword_skip(int limit
, struct getwordstruct
*gwarea
, char stop
);
350 __attribute__((warn_unused_result
)) int getword_atoll(/*@out@*/long long int *number
, struct getwordstruct
*gwarea
, char stop
);
351 __attribute__((warn_unused_result
)) int getword_atoi(/*@out@*/int *number
, struct getwordstruct
*gwarea
, char stop
);
352 __attribute__((warn_unused_result
)) int getword_atol(long int *number
, struct getwordstruct
*gwarea
, char stop
);
353 __attribute__((warn_unused_result
)) int getword_atolu(unsigned long int *number
, struct getwordstruct
*gwarea
, char stop
);
354 __attribute__((warn_unused_result
)) int getword_ptr(char *orig_line
,/*@out@*/char **word
, struct getwordstruct
*gwarea
, char stop
);
355 long long int my_atoll (const char *nptr
);
356 int is_absolute(const char *path
);
357 int getnumlist(char *, numlist
*, const int, const int);
358 int conv_month(const char *month
);
359 const char *conv_month_name(int month
);
360 void buildymd(const char *dia
, const char *mes
, const char *ano
, char *wdata
,int wdata_size
);
361 void date_from(char *date
,int date_size
, int *dfrom
, int *duntil
);
362 char *fixnum(long long int value
, int n
);
363 char *fixnum2(long long int value
, int n
);
364 void fixnone(char *str
);
365 char *fixtime(long long int elap
);
366 void fixendofline(char *str
);
367 void show_info(FILE *fp_ou
);
368 void show_sarg(FILE *fp_ou
, int depth
);
369 void write_logo_image(FILE *fp_ou
);
370 void write_html_head(FILE *fp_ou
, int depth
, const char *page_title
,int javascript
);
371 void write_html_header(FILE *fp_ou
, int depth
, const char *title
,int javascript
);
372 void close_html_header(FILE *fp_ou
);
373 void write_html_trailer(FILE *fp_ou
);
374 void output_html_string(FILE *fp_ou
,const char *str
,int maxlen
);
375 void output_html_url(FILE *fp_ou
,const char *url
);
376 void output_html_link(FILE *fp_ou
,const char *url
,int maxlen
);
377 void debuga(const char *msg
,...) __attribute__((format(printf
,1,2)));
378 void debuga_more(const char *msg
,...) __attribute__((format(printf
,1,2)));
379 void debugaz(const char *msg
,...) __attribute__((format(printf
,1,2)));
380 void my_lltoa(unsigned long long int n
, char *s
, int ssize
, int len
);
381 void url_module(const char *url
, char *w2
);
382 void url_to_anchor(const char *url
,char *anchor
,int size
);
383 void safe_strcpy(char *dest
,const char *src
,int length
);
384 void strip_latin(char *line
);
385 char *buildtime(long long int elap
);
386 int obtdate(const char *dirname
, const char *name
, char *data
);
387 void formatdate(char *date
,int date_size
,int year
,int month
,int day
,int hour
,int minute
,int second
,int dst
);
388 void computedate(int year
,int month
,int day
,struct tm
*t
);
389 int obtuser(const char *dirname
, const char *name
);
390 void obttotal(const char *dirname
, const char *name
, int nuser
, long long int *tbytes
, long long int *media
);
392 int vercode(const char *code
);
393 void load_excludecodes(const char *ExcludeCodes
);
394 void free_excludecodes(void);
395 int PortableMkDir(const char *path
,int mode
);
396 void my_mkdir(const char *name
);
397 int testvaliduserchar(const char *user
);
398 char *strlow(char *string
);
399 char *strup(char *string
);
400 int month2num(const char *month
);
401 int builddia(int day
, int month
, int year
);
402 int compare_date(struct tm
*date1
,struct tm
*date2
);
403 bool IsTreeFileDirName(const char *Name
);
404 bool IsTreeYearFileName(const char *Name
);
405 bool IsTreeMonthFileName(const char *Name
);
406 bool IsTreeDayFileName(const char *Name
);
407 int vrfydir(const struct periodstruct
*per1
, const char *addr
, const char *site
, const char *us
, const char *form
);
408 int getperiod_fromsarglog(const char *arqtt
,struct periodstruct
*period
);
409 void getperiod_fromrange(struct periodstruct
*period
,int dfrom
,int duntil
);
410 void getperiod_merge(struct periodstruct
*main
,struct periodstruct
*candidate
);
411 int getperiod_buildtext(struct periodstruct
*period
);
412 void removetmp(const char *outdir
);
413 void zdate(char *ftime
,int ftimesize
, char DateFormat
);
414 char *get_param_value(const char *param
,char *line
);
415 int compar( const void *, const void * );
416 void unlinkdir(const char *dir
,bool contentonly
);
417 void emptytmpdir(const char *dir
);
418 int extract_address_mask(const char *buf
,const char **text
,unsigned char *ipv4
,unsigned short int *ipv6
,int *nbits
,const char **next
);