]> git.ipfire.org Git - thirdparty/sarg.git/blob - include/defs.h
Write the access times in one html page
[thirdparty/sarg.git] / include / defs.h
1 /*!\file
2 \brief Declaration of the structures and functions.
3 */
4
5 #include "readlog.h"
6
7 struct getwordstruct
8 {
9 const char *current;
10 const char *beginning;
11 int modified;
12 };
13
14 typedef struct longlinestruct *longline;
15
16 struct generalitemstruct
17 {
18 //! \c True if the entry is for the total of the file or \c false if it is a single line.
19 int total;
20 //! The user to which the entry apply. The length is limited to ::MAX_USER_LEN.
21 char *user;
22 //! The number of accesses performed by the user.
23 long long nacc;
24 //! The number of bytes transfered.
25 long long nbytes;
26 //! The URL accessed by the user. The length is not limited.
27 char *url;
28 //! The source IP address of the user. The length is limited to ::MAX_IP_LEN.
29 char *ip;
30 //! The time of the access. The length is limited to ::MAX_DATETIME_LEN.
31 char *time;
32 //! The date of the access. The length is limited to ::MAX_DATETIME_LEN.
33 char *date;
34 //! The number of milliseconds spend processing the request.
35 long long nelap;
36 //! The number of bytes fetched from the cache of the proxy (cache hit).
37 long long incache;
38 //! The number of bytes fetched from the site (cache miss).
39 long long oucache;
40 };
41
42 /*! \brief What is known about a user.
43 */
44 struct userinfostruct
45 {
46 //! The ID of the user as found in the input file.
47 const char *id;
48 //! \c True if the ID is in fact the IP address from which the user connected.
49 bool id_is_ip;
50 //! \c True if the user doesn't have a report file.
51 bool no_report;
52 //! The name of the user to display in the report.
53 const char *label;
54 //! The mangled name to use in file names of that user.
55 const char *filename;
56 //! \c True if this user is in the topuser list.
57 int topuser;
58 //! A general purpose flag that can be set when scanning the user's list.
59 int flag;
60 #ifdef ENABLE_DOUBLE_CHECK_DATA
61 //! Total number of bytes.
62 long long int nbytes;
63 //! Total time spent processing the requests.
64 long long int elap;
65 #endif
66 };
67
68 //! Scan through the known users.
69 typedef struct userscanstruct *userscan;
70
71 /*! \brief Global statistics
72 */
73 struct globalstatstruct
74 {
75 //! Total number of accesses.
76 long long int nacc;
77 //! Total number of bytes.
78 long long int nbytes;
79 //! Total time spent processing the requests.
80 long long int elap;
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.
86 int totuser;
87 };
88
89 //! The object to store the daily statistics.
90 typedef struct DayStruct *DayObject;
91
92 /*!
93 \brief Log filtering criterion.
94 */
95 struct ReadLogDataStruct
96 {
97 //! The filtering date range.
98 char DateRange[255];
99 //! \c True to filter on hosts.
100 bool HostFilter;
101 //! \c True to filter on users.
102 bool UserFilter;
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.
106 bool SysUsers;
107 //! The start time to include in the report(H*100+M). Set to -1 to disable.
108 int StartTime;
109 //! The end time to include in the report(H*100+M). Set to -1 to disable.
110 int EndTime;
111 };
112
113 // auth.c
114 void htaccess(const struct userinfostruct *uinfo);
115
116 // authfail.c
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);
123
124 // charset.c
125 void ccharset(char *CharSet);
126
127 // convlog.c
128 void convlog(const char* arq, char df, int dfrom, int duntil);
129
130 // css.c
131 void css_content(FILE *fp_css);
132 void css(FILE *fp_css);
133
134 // dansguardian_log.c
135 void dansguardian_log(void);
136
137 // dansguardian_report.c
138 void dansguardian_report(void);
139
140 // datafile.c
141 void data_file(char *tmp);
142
143 // decomp.c
144 FILE *decomp(const char *arq, bool *pipe);
145
146 // denied.c
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);
153
154 // download.c
155 void download_open(void);
156 void download_write(const struct ReadLogStruct *log_entry,const char *url);
157 void download_close(void);
158 bool is_download(void);
159 void download_report(void);
160 void free_download(void);
161 void set_download_suffix(const char *list);
162 bool is_download_suffix(const char *url);
163 void download_cleanup(void);
164
165 // email.c
166 int geramail(const char *dirname, int debug, const char *outdir, const char *email, const char *TempDir);
167
168 // exclude.c
169 void gethexclude(const char *hexfile, int debug);
170 void getuexclude(const char *uexfile, int debug);
171 int vhexclude(const char *url);
172 int vuexclude(const char *user);
173 bool is_indexonly(void);
174 void free_exclude(void);
175
176 #ifndef HAVE_FNMATCH
177 // fnmtach.c
178 int fnmatch(const char *pattern,const char *string,int flags);
179 #endif
180
181 // getconf.c
182 void getconf(void);
183
184 // grepday.c
185 void greport_prepare(void);
186 void greport_day(const struct userinfostruct *user);
187 void greport_cleanup(void);
188
189 // html.c
190 void htmlrel(void);
191
192 // indexonly.c
193 void index_only(const char *dirname,int debug);
194
195 // ip2name.c
196 int ip2name_config(const char *param);
197 void ip2name_forcedns(void);
198 void ip2name(char *ip,int ip_len);
199 void ip2name_cleanup(void);
200 void name2ip(char *name,int name_size);
201
202 // lastlog.c
203 void mklastlog(const char *outdir);
204
205 // longline.c
206 __attribute__((warn_unused_result)) /*@null@*//*@only@*/longline longline_create(void);
207 void longline_reset(longline line);
208 /*@null@*/char *longline_read(FILE *fp_in,/*@null@*/longline line);
209 void longline_destroy(/*@out@*//*@only@*//*@null@*/longline *line_ptr);
210
211 // index.c
212 void make_index(void);
213
214 // readlog.c
215 int ReadLogFile(struct ReadLogDataStruct *Filter);
216
217 // realtime.c
218 void realtime(void);
219
220 // redirector.c
221 void redirector_log(void);
222 void redirector_report(void);
223
224 // repday.c
225 void report_day(const struct userinfostruct *user);
226
227 // report.c
228 void gerarel(void);
229 int ger_read(char *buffer,struct generalitemstruct *item,const char *filename);
230 void totalger(FILE *fp_gen,const char *filename);
231
232 // siteuser.c
233 void siteuser(void);
234
235 // smartfilter.c
236 void smartfilter_report(void);
237
238 // sort.c
239 void sort_users_log(const char *tmp, int debug,struct userinfostruct *uinfo);
240 void tmpsort(const struct userinfostruct *uinfo);
241 void sort_labels(const char **label,const char **order);
242
243 // splitlog.c
244 void splitlog(const char *arq, char df, int dfrom, int duntil, int convert, const char *splitprefix);
245
246 // topsites.c
247 void topsites(void);
248
249 // topuser.c
250 void topuser(void);
251
252 // totday.c
253 DayObject day_prepare(void);
254 void day_cleanup(DayObject ddata);
255 void day_newuser(DayObject ddata);
256 void day_addpoint(DayObject ddata,const char *date, const char *time, long long int elap, long long int bytes);
257 void day_totalize(DayObject ddata,const char *tmp, const struct userinfostruct *uinfo);
258
259 // url.c
260 void read_hostalias(const char *Filename);
261 void free_hostalias(void);
262 const char *skip_scheme(const char *url);
263 const char *process_url(const char *url,bool full_url);
264 void url_hostname(const char *url,char *hostname,int hostsize);
265
266 // usage.c
267 void usage(const char *prog);
268
269 // useragent.c
270 void useragent(void);
271
272 // userinfo.c
273 /*@shared@*/struct userinfostruct *userinfo_create(const char *userid);
274 void userinfo_free(void);
275 void userinfo_label(struct userinfostruct *uinfo,const char *label);
276 /*@shared@*/struct userinfostruct *userinfo_find_from_file(const char *filename);
277 /*@shared@*/struct userinfostruct *userinfo_find_from_id(const char *id);
278 userscan userinfo_startscan(void);
279 void userinfo_stopscan(userscan uscan);
280 struct userinfostruct *userinfo_advancescan(userscan uscan);
281 void userinfo_clearflag(void);
282
283 // usertab.c
284 void init_usertab(const char *UserTabFile);
285 void user_find(char *mappedname, int namelen, const char *userlogin);
286 void close_usertab(void);
287
288 // util.c
289 void getword_start(/*@out@*/struct getwordstruct *gwarea, const char *line);
290 void getword_restart(struct getwordstruct *gwarea);
291 __attribute__((warn_unused_result)) int getword(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
292 __attribute__((warn_unused_result)) int getword_limit(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
293 __attribute__((warn_unused_result)) int getword_multisep(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
294 __attribute__((warn_unused_result)) int getword_skip(int limit, struct getwordstruct *gwarea, char stop);
295 __attribute__((warn_unused_result)) int getword_atoll(/*@out@*/long long int *number, struct getwordstruct *gwarea, char stop);
296 __attribute__((warn_unused_result)) int getword_atoi(/*@out@*/int *number, struct getwordstruct *gwarea, char stop);
297 __attribute__((warn_unused_result)) int getword_atol(long int *number, struct getwordstruct *gwarea, char stop);
298 __attribute__((warn_unused_result)) int getword_atolu(unsigned long int *number, struct getwordstruct *gwarea, char stop);
299 __attribute__((warn_unused_result)) int getword_ptr(char *orig_line,/*@out@*/char **word, struct getwordstruct *gwarea, char stop);
300 long long int my_atoll (const char *nptr);
301 int is_absolute(const char *path);
302 int getnumlist(char *, numlist *, const int, const int);
303 void name_month(char *month,int month_len);
304 int conv_month(const char *month);
305 const char *conv_month_name(int month);
306 void buildymd(const char *dia, const char *mes, const char *ano, char *wdata);
307 void date_from(char *date, int *dfrom, int *duntil);
308 char *fixnum(long long int value, int n);
309 char *fixnum2(long long int value, int n);
310 void fixnone(char *str);
311 char *fixtime(long long int elap);
312 void fixendofline(char *str);
313 void show_info(FILE *fp_ou);
314 void show_sarg(FILE *fp_ou, int depth);
315 void write_logo_image(FILE *fp_ou);
316 void write_html_head(FILE *fp_ou, int depth, const char *page_title,int javascript);
317 void write_html_header(FILE *fp_ou, int depth, const char *title,int javascript);
318 void close_html_header(FILE *fp_ou);
319 __attribute__((warn_unused_result)) int write_html_trailer(FILE *fp_ou);
320 void output_html_string(FILE *fp_ou,const char *str,int maxlen);
321 void output_html_url(FILE *fp_ou,const char *url);
322 void output_html_link(FILE *fp_ou,const char *url,int maxlen);
323 void debuga(const char *msg,...) __attribute__((format(printf,1,2)));
324 void debugaz(const char *msg,...) __attribute__((format(printf,1,2)));
325 void my_lltoa(unsigned long long int n, char *s, int ssize, int len);
326 char *get_size(const char *path, const char *file);
327 void url_module(const char *url, char *w2);
328 void url_to_anchor(const char *url,char *anchor,int size);
329 void safe_strcpy(char *dest,const char *src,int length);
330 void strip_latin(char *line);
331 char *buildtime(long long int elap);
332 int obtdate(const char *dirname, const char *name, char *data);
333 void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second,int dst);
334 void computedate(int year,int month,int day,struct tm *t);
335 int obtuser(const char *dirname, const char *name);
336 void obttotal(const char *dirname, const char *name, int nuser, long long int *tbytes, long long int *media);
337 void version(void);
338 int vercode(const char *code);
339 void load_excludecodes(const char *ExcludeCodes);
340 void free_excludecodes(void);
341 void my_mkdir(const char *name);
342 int testvaliduserchar(const char *user);
343 char *strlow(char *string);
344 char *strup(char *string);
345 int month2num(const char *month);
346 int builddia(int day, int month, int year);
347 int compare_date(struct tm *date1,struct tm *date2);
348 int vrfydir(const struct periodstruct *per1, const char *addr, const char *site, const char *us, const char *form);
349 int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period);
350 void getperiod_fromrange(struct periodstruct *period,int dfrom,int duntil);
351 void getperiod_merge(struct periodstruct *main,struct periodstruct *candidate);
352 int getperiod_buildtext(struct periodstruct *period);
353 void removetmp(const char *outdir);
354 void zdate(char *ftime,int ftimesize, char DateFormat);
355 char *get_param_value(const char *param,char *line);
356 int compar( const void *, const void * );
357 void unlinkdir(const char *dir,bool contentonly);
358 void emptytmpdir(const char *dir);
359 int extract_address_mask(const char *buf,const char **text,unsigned char *ipv4,unsigned short int *ipv6,int *nbits,const char **next);