]>
git.ipfire.org Git - thirdparty/sarg.git/blob - include/defs.h
2 \brief Declaration of the structures and functions.
10 const char *beginning
;
14 typedef struct longlinestruct
*longline
;
16 struct generalitemstruct
18 //! \c True if the entry is for the total of the file or \c false if it is a single line.
20 //! The user to which the entry apply. The length is limited to ::MAX_USER_LEN.
22 //! The number of accesses performed by the user.
24 //! The number of bytes transfered.
26 //! The URL accessed by the user. The length is not limited.
28 //! The source IP address of the user. The length is limited to ::MAX_IP_LEN.
30 //! The time of the access. The length is limited to ::MAX_DATETIME_LEN.
32 //! The date of the access. The length is limited to ::MAX_DATETIME_LEN.
34 //! The number of milliseconds spend processing the request.
36 //! The number of bytes fetched from the cache of the proxy (cache hit).
38 //! The number of bytes fetched from the site (cache miss).
42 /*! \brief What is known about a user.
46 //! The ID of the user as found in the input file.
47 char id
[MAX_USER_LEN
];
48 //! \c True if the ID is in fact the IP address from which the user connected.
50 //! \c True if the user doesn't have a report file.
52 //! The name of the user to display in the report.
53 char label
[MAX_USER_LEN
];
54 //! The mangled name to use in file names of that user.
55 char filename
[MAX_USER_FNAME_LEN
];
56 //! \c True if this user is in the topuser list.
58 //! A general purpose flag that can be set when scanning the user's list.
60 #ifdef ENABLE_DOUBLE_CHECK_DATA
61 //! Total number of bytes.
63 //! Total time spent processing the requests.
68 //! Scan through the known users.
69 typedef struct userscanstruct
*userscan
;
71 /*! \brief Global statistics
73 struct globalstatstruct
75 //! Total number of accesses.
77 //! Total number of bytes.
79 //! Total time spent processing the requests.
81 //! Amount of data fetched from the cache.
82 long long int incache
;
83 //! Amount of data not fetched from the cache.
84 long long int oucache
;
85 //! The number of users in the topuser list.
89 //! The object to store the daily statistics.
90 typedef struct DayStruct
*DayObject
;
93 \brief Log filtering criterion.
95 struct ReadLogDataStruct
97 //! The filtering date range.
99 //! \c True to filter on hosts.
101 //! \c True to filter on users.
103 //! Maximum elpased time allowed. Any time greater than this value is set to zero.
104 long int max_elapsed
;
105 //! \c True to restrict the log to the system users.
107 //! The start time to include in the report(H*100+M). Set to -1 to disable.
109 //! The end time to include in the report(H*100+M). Set to -1 to disable.
114 void htaccess(const struct userinfostruct
*uinfo
);
117 void authfail_open(void);
118 void authfail_write(const struct ReadLogStruct
*log_entry
);
119 void authfail_close(void);
120 bool is_authfail(void);
121 void authfail_report(void);
122 void authfail_cleanup(void);
125 void ccharset(char *CharSet
);
128 void convlog(const char* arq
, char df
, int dfrom
, int duntil
);
131 void css_content(FILE *fp_css
);
132 void css(FILE *fp_css
);
134 // dansguardian_log.c
135 void dansguardian_log(void);
137 // dansguardian_report.c
138 void dansguardian_report(void);
141 void data_file(char *tmp
);
144 FILE *decomp(const char *arq
, bool *pipe
);
147 void denied_open(void);
148 void denied_write(const struct ReadLogStruct
*log_entry
);
149 void denied_close(void);
150 bool is_denied(void);
151 void gen_denied_report(void);
152 void denied_cleanup(void);
155 void download_report(void);
156 void free_download(void);
157 void set_download_suffix(const char *list
);
158 bool is_download_suffix(const char *url
);
161 int geramail(const char *dirname
, int debug
, const char *outdir
, const char *email
, const char *TempDir
);
164 void gethexclude(const char *hexfile
, int debug
);
165 void getuexclude(const char *uexfile
, int debug
);
166 int vhexclude(const char *url
);
167 int vuexclude(const char *user
);
168 bool is_indexonly(void);
169 void free_exclude(void);
175 void greport_prepare(void);
176 void greport_day(const struct userinfostruct
*user
);
177 void greport_cleanup(void);
183 void index_only(const char *dirname
,int debug
);
186 int ip2name_config(const char *param
);
187 void ip2name_forcedns(void);
188 void ip2name(char *ip
,int ip_len
);
189 void ip2name_cleanup(void);
190 void name2ip(char *name
,int name_size
);
193 void mklastlog(const char *outdir
);
196 __attribute__((warn_unused_result
)) /*@null@*//*@only@*/longline
longline_create(void);
197 void longline_reset(longline line
);
198 /*@null@*/char *longline_read(FILE *fp_in
,/*@null@*/longline line
);
199 void longline_destroy(/*@out@*//*@only@*//*@null@*/longline
*line_ptr
);
202 void make_index(void);
205 int ReadLogFile(struct ReadLogDataStruct
*Filter
);
211 void redirector_log(void);
212 void redirector_report(void);
215 void report_day(const struct userinfostruct
*user
);
219 int ger_read(char *buffer
,struct generalitemstruct
*item
,const char *filename
);
220 void totalger(FILE *fp_gen
,const char *filename
);
226 void smartfilter_report(void);
229 void sort_users_log(const char *tmp
, int debug
,struct userinfostruct
*uinfo
);
230 void tmpsort(const struct userinfostruct
*uinfo
);
231 void sort_labels(const char **label
,const char **order
);
234 void splitlog(const char *arq
, char df
, int dfrom
, int duntil
, int convert
, const char *splitprefix
);
243 DayObject
day_prepare(void);
244 void day_cleanup(DayObject ddata
);
245 void day_newuser(DayObject ddata
);
246 void day_addpoint(DayObject ddata
,const char *date
, const char *time
, long long int elap
, long long int bytes
);
247 void day_totalize(DayObject ddata
,const char *tmp
, const struct userinfostruct
*uinfo
);
250 void read_hostalias(const char *Filename
);
251 void free_hostalias(void);
252 const char *skip_scheme(const char *url
);
253 const char *process_url(const char *url
,bool full_url
);
254 void url_hostname(const char *url
,char *hostname
,int hostsize
);
257 void usage(const char *prog
);
260 void useragent(void);
263 /*@shared@*/struct userinfostruct
*userinfo_create(const char *userid
);
264 void userinfo_free(void);
265 /*@shared@*/struct userinfostruct
*userinfo_find_from_file(const char *filename
);
266 /*@shared@*/struct userinfostruct
*userinfo_find_from_id(const char *id
);
267 userscan
userinfo_startscan(void);
268 void userinfo_stopscan(userscan uscan
);
269 struct userinfostruct
*userinfo_advancescan(userscan uscan
);
270 void userinfo_clearflag(void);
273 void init_usertab(const char *UserTabFile
);
274 void user_find(char *mappedname
, int namelen
, const char *userlogin
);
275 void close_usertab(void);
278 void getword_start(/*@out@*/struct getwordstruct
*gwarea
, const char *line
);
279 void getword_restart(struct getwordstruct
*gwarea
);
280 __attribute__((warn_unused_result
)) int getword(/*@out@*/char *word
, int limit
, struct getwordstruct
*gwarea
, char stop
);
281 __attribute__((warn_unused_result
)) int getword_limit(/*@out@*/char *word
, int limit
, struct getwordstruct
*gwarea
, char stop
);
282 __attribute__((warn_unused_result
)) int getword_multisep(/*@out@*/char *word
, int limit
, struct getwordstruct
*gwarea
, char stop
);
283 __attribute__((warn_unused_result
)) int getword_skip(int limit
, struct getwordstruct
*gwarea
, char stop
);
284 __attribute__((warn_unused_result
)) int getword_atoll(/*@out@*/long long int *number
, struct getwordstruct
*gwarea
, char stop
);
285 __attribute__((warn_unused_result
)) int getword_atoi(/*@out@*/int *number
, struct getwordstruct
*gwarea
, char stop
);
286 __attribute__((warn_unused_result
)) int getword_atol(long int *number
, struct getwordstruct
*gwarea
, char stop
);
287 __attribute__((warn_unused_result
)) int getword_atolu(unsigned long int *number
, struct getwordstruct
*gwarea
, char stop
);
288 __attribute__((warn_unused_result
)) int getword_ptr(char *orig_line
,/*@out@*/char **word
, struct getwordstruct
*gwarea
, char stop
);
289 long long int my_atoll (const char *nptr
);
290 int is_absolute(const char *path
);
291 int getnumlist(char *, numlist
*, const int, const int);
292 void name_month(char *month
,int month_len
);
293 int conv_month(const char *month
);
294 const char *conv_month_name(int month
);
295 void buildymd(const char *dia
, const char *mes
, const char *ano
, char *wdata
);
296 void date_from(char *date
, int *dfrom
, int *duntil
);
297 char *fixnum(long long int value
, int n
);
298 char *fixnum2(long long int value
, int n
);
299 void fixnone(char *str
);
300 char *fixtime(long long int elap
);
301 void fixendofline(char *str
);
302 void show_info(FILE *fp_ou
);
303 void show_sarg(FILE *fp_ou
, int depth
);
304 void write_logo_image(FILE *fp_ou
);
305 void write_html_head(FILE *fp_ou
, int depth
, const char *page_title
,int javascript
);
306 void write_html_header(FILE *fp_ou
, int depth
, const char *title
,int javascript
);
307 void close_html_header(FILE *fp_ou
);
308 __attribute__((warn_unused_result
)) int write_html_trailer(FILE *fp_ou
);
309 void output_html_string(FILE *fp_ou
,const char *str
,int maxlen
);
310 void output_html_url(FILE *fp_ou
,const char *url
);
311 void output_html_link(FILE *fp_ou
,const char *url
,int maxlen
);
312 void debuga(const char *msg
,...) __attribute__((format(printf
,1,2)));
313 void debugaz(const char *msg
,...) __attribute__((format(printf
,1,2)));
314 void my_lltoa(unsigned long long int n
, char *s
, int ssize
, int len
);
315 char *get_size(const char *path
, const char *file
);
316 void url_module(const char *url
, char *w2
);
317 void url_to_file(const char *url
,char *file
,int filesize
);
318 void safe_strcpy(char *dest
,const char *src
,int length
);
319 void strip_latin(char *line
);
320 char *buildtime(long long int elap
);
321 int obtdate(const char *dirname
, const char *name
, char *data
);
322 void formatdate(char *date
,int date_size
,int year
,int month
,int day
,int hour
,int minute
,int second
,int dst
);
323 void computedate(int year
,int month
,int day
,struct tm
*t
);
324 int obtuser(const char *dirname
, const char *name
);
325 void obttotal(const char *dirname
, const char *name
, int nuser
, long long int *tbytes
, long long int *media
);
327 int vercode(const char *code
);
328 void load_excludecodes(const char *ExcludeCodes
);
329 void free_excludecodes(void);
330 void my_mkdir(const char *name
);
331 int testvaliduserchar(const char *user
);
332 char *strlow(char *string
);
333 char *strup(char *string
);
334 int month2num(const char *month
);
335 int builddia(int day
, int month
, int year
);
336 int vrfydir(const struct periodstruct
*per1
, const char *addr
, const char *site
, const char *us
, const char *form
);
337 int getperiod_fromsarglog(const char *arqtt
,struct periodstruct
*period
);
338 void getperiod_fromrange(struct periodstruct
*period
,int dfrom
,int duntil
);
339 void getperiod_merge(struct periodstruct
*main
,struct periodstruct
*candidate
);
340 int getperiod_buildtext(struct periodstruct
*period
);
341 void removetmp(const char *outdir
);
342 void zdate(char *ftime
,int ftimesize
, char DateFormat
);
343 char *get_param_value(const char *param
,char *line
);
344 int compar( const void *, const void * );
345 void unlinkdir(const char *dir
,bool contentonly
);
346 void emptytmpdir(const char *dir
);
347 int extract_address_mask(const char *buf
,const char **text
,unsigned char *ipv4
,unsigned short int *ipv6
,int *nbits
,const char **next
);