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