]> git.ipfire.org Git - thirdparty/sarg.git/blame - include/defs.h
Don't blindly delete /tmp/sarg
[thirdparty/sarg.git] / include / defs.h
CommitLineData
f2ec8c75
FM
1/*!\file
2\brief Declaration of the structures and functions.
3*/
9c7c6346
FM
4
5struct getwordstruct
6{
7 const char *current;
8 const char *beginning;
e5b2c6f0 9 int modified;
9c7c6346
FM
10};
11
afaa3b67 12typedef struct longlinestruct *longline;
ac422f9b 13
2240dcea
FM
14struct 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
93551487
FM
40/*! \brief What is known about a user.
41*/
f2ec8c75
FM
42struct userinfostruct
43{
93551487
FM
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];
a58e6d54
FM
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;
d91457d2
FM
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
f2ec8c75
FM
64};
65
93551487
FM
66//! Scan through the known users.
67typedef struct userscanstruct *userscan;
68
9dc20988
FM
69/*! \brief Global statistics
70*/
71struct 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;
e5b3a129
FM
83 //! The number of users in the topuser list.
84 int totuser;
9dc20988
FM
85};
86
026ddd8b
FM
87//! The object to store the daily statistics.
88typedef struct DayStruct *DayObject;
89
5f3cfd1d 90// auth.c
d25d4e6a 91void htaccess(const struct userinfostruct *uinfo);
5f3cfd1d
FM
92
93// authfail.c
94void authfail_report(void);
95
96// charset.c
97void ccharset(char *CharSet);
98
99// convlog.c
100void convlog(const char *arq, char *df, int dfrom, int duntil);
101
102// css.c
d183fb7f 103void css_content(FILE *fp_css);
5f3cfd1d
FM
104void css(FILE *fp_css);
105
106// dansguardian_log.c
107void dansguardian_log(void);
108
109// dansguardian_report.c
110void dansguardian_report(void);
111
112// datafile.c
113void data_file(char *tmp);
114
115// decomp.c
d2855b39 116FILE *decomp(const char *arq, bool *pipe);
5f3cfd1d
FM
117
118// denied.c
119void gen_denied_report(void);
120
121// download.c
122void download_report(void);
6e792ade
FM
123void free_download(void);
124void set_download_suffix(const char *list);
2824ec9b 125bool is_download_suffix(const char *url);
5f3cfd1d
FM
126
127// email.c
2824ec9b 128int geramail(const char *dirname, int debug, const char *outdir, const char *email, const char *TempDir);
5f3cfd1d
FM
129
130// exclude.c
43f18f45
FM
131void gethexclude(const char *hexfile, int debug);
132void getuexclude(const char *uexfile, int debug);
133int vhexclude(const char *url);
134int vuexclude(const char *user);
2824ec9b 135bool is_indexonly(void);
43f18f45 136void free_exclude(void);
5f3cfd1d
FM
137
138// getconf.c
139void getconf(void);
140
141// grepday.c
1f482a8d 142void greport_prepare(void);
f2ec8c75 143void greport_day(const struct userinfostruct *user);
c274f011 144void greport_cleanup(void);
5f3cfd1d
FM
145
146// html.c
147void htmlrel(void);
148
149// indexonly.c
150void index_only(const char *dirname,int debug);
151
152// ip2name.c
51b166d4
FM
153int ip2name_config(const char *param);
154void ip2name_forcedns(void);
5f3cfd1d 155void ip2name(char *ip,int ip_len);
0326d73b 156void ip2name_cleanup(void);
4afbb7a5 157void name2ip(char *name,int name_size);
5f3cfd1d 158
5f3cfd1d
FM
159// lastlog.c
160void mklastlog(const char *outdir);
161
afaa3b67 162// longline.c
fa6552b0 163__attribute__((warn_unused_result)) /*@null@*//*@only@*/longline longline_create(void);
afaa3b67
FM
164void longline_reset(longline line);
165/*@null@*/char *longline_read(FILE *fp_in,/*@null@*/longline line);
166void longline_destroy(/*@out@*//*@only@*//*@null@*/longline *line_ptr);
167
5f3cfd1d
FM
168// index.c
169void make_index(void);
170
171// realtime.c
172void realtime(void);
173
330b1c52
FM
174// redirector.c
175void redirector_log(void);
176void redirector_report(void);
177
5f3cfd1d 178// repday.c
f2ec8c75 179void report_day(const struct userinfostruct *user);
5f3cfd1d
FM
180
181// report.c
5f3cfd1d 182void gerarel(void);
2240dcea 183int ger_read(char *buffer,struct generalitemstruct *item,const char *filename);
9dc20988 184void totalger(FILE *fp_gen,const char *filename);
5f3cfd1d
FM
185
186// siteuser.c
187void siteuser(void);
188
189// smartfilter.c
190void smartfilter_report(void);
191
192// sort.c
461b479d 193void sort_users_log(const char *tmp, int debug,struct userinfostruct *uinfo);
e5b3a129 194void tmpsort(const struct userinfostruct *uinfo);
15d5372b 195void sort_labels(const char **label,const char **order);
5f3cfd1d
FM
196
197// splitlog.c
2c7e8c23 198void splitlog(const char *arq, const char *df, int dfrom, int duntil, int convert, const char *splitprefix);
5f3cfd1d 199
5f3cfd1d
FM
200// topsites.c
201void topsites(void);
202
203// topuser.c
204void topuser(void);
205
206// totday.c
026ddd8b
FM
207DayObject day_prepare(void);
208void day_cleanup(DayObject ddata);
209void day_newuser(DayObject ddata);
210void day_addpoint(DayObject ddata,const char *date, const char *time, long long int elap, long long int bytes);
211void day_totalize(DayObject ddata,const char *tmp, const struct userinfostruct *uinfo);
5f3cfd1d 212
22715352
FM
213// url.c
214void read_hostalias(const char *Filename);
215void free_hostalias(void);
6fa33a32 216const char *skip_scheme(const char *url);
1a2609b0 217const char *process_url(char *url,bool full_url);
22715352
FM
218void url_hostname(const char *url,char *hostname,int hostsize);
219
5f3cfd1d
FM
220// usage.c
221void usage(const char *prog);
222
223// useragent.c
224void useragent(void);
225
f2ec8c75 226// userinfo.c
4ca814cc 227/*@shared@*/struct userinfostruct *userinfo_create(const char *userid);
f2ec8c75 228void userinfo_free(void);
4ca814cc
FM
229/*@shared@*/struct userinfostruct *userinfo_find_from_file(const char *filename);
230/*@shared@*/struct userinfostruct *userinfo_find_from_id(const char *id);
93551487
FM
231userscan userinfo_startscan(void);
232void userinfo_stopscan(userscan uscan);
233struct userinfostruct *userinfo_advancescan(userscan uscan);
a58e6d54 234void userinfo_clearflag(void);
f2ec8c75 235
965c4a6f
FM
236// usertab.c
237void init_usertab(const char *UserTabFile);
238void user_find(char *mappedname, int namelen, const char *userlogin);
239void close_usertab(void);
240
5f3cfd1d 241// util.c
06b39c87 242void getword_start(/*@out@*/struct getwordstruct *gwarea, const char *line);
9c7c6346 243void getword_restart(struct getwordstruct *gwarea);
d5a1c7f9
FM
244__attribute__((warn_unused_result)) int getword(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
245__attribute__((warn_unused_result)) int getword_limit(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
246__attribute__((warn_unused_result)) int getword_multisep(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
247__attribute__((warn_unused_result)) int getword_skip(int limit, struct getwordstruct *gwarea, char stop);
248__attribute__((warn_unused_result)) int getword_atoll(/*@out@*/long long int *number, struct getwordstruct *gwarea, char stop);
bd8b7715 249__attribute__((warn_unused_result)) int getword_atoi(/*@out@*/int *number, struct getwordstruct *gwarea, char stop);
d5a1c7f9 250__attribute__((warn_unused_result)) int getword_ptr(char *orig_line,/*@out@*/char **word, struct getwordstruct *gwarea, char stop);
e6414a9d
FM
251long long int my_atoll (const char *nptr);
252int is_absolute(const char *path);
e3af0ae9 253int getnumlist(char *, numlist *, const int, const int);
5f3cfd1d 254void name_month(char *month,int month_len);
fa6552b0
FM
255int conv_month(const char *month);
256const char *conv_month_name(int month);
5f3cfd1d 257void buildymd(const char *dia, const char *mes, const char *ano, char *wdata);
42b117e3 258void date_from(char *date, int *dfrom, int *duntil);
5f3cfd1d
FM
259char *fixnum(long long int value, int n);
260char *fixnum2(long long int value, int n);
261void fixnone(char *str);
324ba7f3 262char *fixtime(long long int elap);
2357ef77 263void fixendofline(char *str);
5f3cfd1d 264void show_info(FILE *fp_ou);
c0ec9cc7 265void show_sarg(FILE *fp_ou, int depth);
dfb337be 266void write_logo_image(FILE *fp_ou);
2e96438d
FM
267void write_html_head(FILE *fp_ou, int depth, const char *page_title,int javascript);
268void write_html_header(FILE *fp_ou, int depth, const char *title,int javascript);
c0ec9cc7 269void close_html_header(FILE *fp_ou);
fa6552b0 270__attribute__((warn_unused_result)) int write_html_trailer(FILE *fp_ou);
ac422f9b
FM
271void output_html_string(FILE *fp_ou,const char *str,int maxlen);
272void output_html_url(FILE *fp_ou,const char *url);
6fa33a32 273void output_html_link(FILE *fp_ou,const char *url,int maxlen);
f0126186 274void debuga(const char *msg,...) __attribute__((format(printf,1,2)));
9f93fec3 275void debugaz(const char *msg,...) __attribute__((format(printf,1,2)));
e5b2c6f0 276void my_lltoa(unsigned long long int n, char *s, int ssize, int len);
5f3cfd1d 277char *get_size(const char *path, const char *file);
48864d28 278void url_module(const char *url, char *w2);
e5b2c6f0 279void url_to_file(const char *url,char *file,int filesize);
a87d4d11 280void safe_strcpy(char *dest,const char *src,int length);
5f3cfd1d
FM
281void strip_latin(char *line);
282char *buildtime(long long int elap);
15d3cb5c 283int obtdate(const char *dirname, const char *name, char *data);
a1de61fe 284void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second,int dst);
fa6552b0 285void computedate(int year,int month,int day,struct tm *t);
d25d4e6a 286int obtuser(const char *dirname, const char *name);
ea275279 287void obttotal(const char *dirname, const char *name, int nuser, long long int *tbytes, long long int *media);
5f3cfd1d
FM
288void version(void);
289int vercode(const char *code);
48864d28
FM
290void load_excludecodes(const char *ExcludeCodes);
291void free_excludecodes(void);
5f3cfd1d
FM
292void my_mkdir(const char *name);
293int testvaliduserchar(const char *user);
294char *strlow(char *string);
295char *strup(char *string);
fa6552b0
FM
296int month2num(const char *month);
297int builddia(int day, int month, int year);
298int vrfydir(const struct periodstruct *per1, const char *addr, const char *site, const char *us, const char *form);
299int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period);
42b117e3 300void getperiod_fromrange(struct periodstruct *period,int dfrom,int duntil);
fa6552b0 301int getperiod_buildtext(struct periodstruct *period);
5f3cfd1d 302void removetmp(const char *outdir);
120d768c 303void zdate(char *ftime,int ftimesize, const char *DateFormat);
5f3cfd1d 304char *get_param_value(const char *param,char *line);
48864d28 305int compar( const void *, const void * );
170a77ea
FM
306void unlinkdir(const char *dir,bool contentonly);
307void emptytmpdir(const char *dir);
7819e0d5 308int extract_address_mask(const char *buf,const char **text,unsigned char *ipv4,unsigned short int *ipv6,int *nbits,const char **next);