]> git.ipfire.org Git - thirdparty/sarg.git/blob - include/defs.h
Use a function to safely copy the strings
[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 };
55
56 //! Scan through the known users.
57 typedef struct userscanstruct *userscan;
58
59 /*! \brief Global statistics
60 */
61 struct globalstatstruct
62 {
63 //! Total number of accesses.
64 long long int nacc;
65 //! Total number of bytes.
66 long long int nbytes;
67 //! Total time spent processing the requests.
68 long long int elap;
69 //! Amount of data fetched from the cache.
70 long long int incache;
71 //! Amount of data not fetched from the cache.
72 long long int oucache;
73 };
74
75 // auth.c
76 void htaccess(const struct userinfostruct *uinfo);
77
78 // authfail.c
79 void authfail_report(void);
80
81 // charset.c
82 void ccharset(char *CharSet);
83
84 // convlog.c
85 void convlog(const char *arq, char *df, int dfrom, int duntil);
86
87 // css.c
88 void css_content(FILE *fp_css);
89 void css(FILE *fp_css);
90
91 // dansguardian_log.c
92 void dansguardian_log(void);
93
94 // dansguardian_report.c
95 void dansguardian_report(void);
96
97 // datafile.c
98 void data_file(char *tmp);
99
100 // decomp.c
101 FILE *decomp(const char *arq, bool *pipe);
102
103 // denied.c
104 void gen_denied_report(void);
105
106 // download.c
107 void download_report(void);
108 void free_download(void);
109 void set_download_suffix(const char *list);
110 bool is_download_suffix(const char *url);
111
112 // email.c
113 int geramail(const char *dirname, int debug, const char *outdir, const char *email, const char *TempDir);
114
115 // exclude.c
116 void gethexclude(const char *hexfile, int debug);
117 void getuexclude(const char *uexfile, int debug);
118 int vhexclude(const char *url);
119 int vuexclude(const char *user);
120 bool is_indexonly(void);
121 void free_exclude(void);
122
123 // getconf.c
124 void getconf(void);
125
126 // grepday.c
127 void greport_prepare(void);
128 void greport_day(const struct userinfostruct *user);
129 void greport_cleanup(void);
130
131 // html.c
132 void htmlrel(void);
133
134 // indexonly.c
135 void index_only(const char *dirname,int debug);
136
137 // ip2name.c
138 void ip2name(char *ip,int ip_len);
139 void name2ip(char *name,int name_size);
140
141 // lastlog.c
142 void mklastlog(const char *outdir);
143
144 // longline.c
145 __attribute__((warn_unused_result)) /*@null@*//*@only@*/longline longline_create(void);
146 void longline_reset(longline line);
147 /*@null@*/char *longline_read(FILE *fp_in,/*@null@*/longline line);
148 void longline_destroy(/*@out@*//*@only@*//*@null@*/longline *line_ptr);
149
150 // index.c
151 void make_index(void);
152
153 // realtime.c
154 void realtime(void);
155
156 // redirector.c
157 void redirector_log(void);
158 void redirector_report(void);
159
160 // repday.c
161 void report_day(const struct userinfostruct *user);
162
163 // report.c
164 void gerarel(void);
165 int ger_read(char *buffer,struct generalitemstruct *item,const char *filename);
166 void totalger(FILE *fp_gen,const char *filename);
167
168 // siteuser.c
169 void siteuser(void);
170
171 // smartfilter.c
172 void smartfilter_report(void);
173
174 // sort.c
175 void sort_users_log(const char *tmp, int debug);
176 void tmpsort(void);
177 void sort_labels(const char **label,const char **order);
178
179 // splitlog.c
180 void splitlog(const char *arq, const char *df, int dfrom, int duntil, int convert, const char *splitprefix);
181
182 // topsites.c
183 void topsites(void);
184
185 // topuser.c
186 void topuser(void);
187
188 // totday.c
189 void day_totalize(const char *tmp, const struct userinfostruct *uinfo);
190
191 // url.c
192 void read_hostalias(const char *Filename);
193 void free_hostalias(void);
194 const char *process_url(char *url,bool full_url);
195 void url_hostname(const char *url,char *hostname,int hostsize);
196
197 // usage.c
198 void usage(const char *prog);
199
200 // useragent.c
201 void useragent(void);
202
203 // userinfo.c
204 /*@shared@*/struct userinfostruct *userinfo_create(const char *userid);
205 void userinfo_free(void);
206 /*@shared@*/struct userinfostruct *userinfo_find_from_file(const char *filename);
207 /*@shared@*/struct userinfostruct *userinfo_find_from_id(const char *id);
208 userscan userinfo_startscan(void);
209 void userinfo_stopscan(userscan uscan);
210 struct userinfostruct *userinfo_advancescan(userscan uscan);
211
212 // usertab.c
213 void init_usertab(const char *UserTabFile);
214 void user_find(char *mappedname, int namelen, const char *userlogin);
215 void close_usertab(void);
216
217 // util.c
218 void getword_start(/*@out@*/struct getwordstruct *gwarea, const char *line);
219 void getword_restart(struct getwordstruct *gwarea);
220 __attribute__((warn_unused_result)) int getword(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
221 __attribute__((warn_unused_result)) int getword_limit(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
222 __attribute__((warn_unused_result)) int getword_multisep(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
223 __attribute__((warn_unused_result)) int getword_skip(int limit, struct getwordstruct *gwarea, char stop);
224 __attribute__((warn_unused_result)) int getword_atoll(/*@out@*/long long int *number, struct getwordstruct *gwarea, char stop);
225 __attribute__((warn_unused_result)) int getword_atoi(/*@out@*/int *number, struct getwordstruct *gwarea, char stop);
226 __attribute__((warn_unused_result)) int getword_ptr(char *orig_line,/*@out@*/char **word, struct getwordstruct *gwarea, char stop);
227 long long int my_atoll (const char *nptr);
228 int is_absolute(const char *path);
229 int getnumlist(char *, numlist *, const int, const int);
230 void name_month(char *month,int month_len);
231 int conv_month(const char *month);
232 const char *conv_month_name(int month);
233 void buildymd(const char *dia, const char *mes, const char *ano, char *wdata);
234 void date_from(char *date, int *dfrom, int *duntil);
235 char *fixnum(long long int value, int n);
236 char *fixnum2(long long int value, int n);
237 void fixnone(char *str);
238 char *fixtime(long long int elap);
239 void fixendofline(char *str);
240 void show_info(FILE *fp_ou);
241 void show_sarg(FILE *fp_ou, int depth);
242 void write_logo_image(FILE *fp_ou);
243 void write_html_head(FILE *fp_ou, int depth, const char *page_title,int javascript);
244 void write_html_header(FILE *fp_ou, int depth, const char *title,int javascript);
245 void close_html_header(FILE *fp_ou);
246 __attribute__((warn_unused_result)) int write_html_trailer(FILE *fp_ou);
247 void output_html_string(FILE *fp_ou,const char *str,int maxlen);
248 void output_html_url(FILE *fp_ou,const char *url);
249 void output_html_link(FILE *fp_ou,const char *url,int maxlen);
250 void debuga(const char *msg,...) __attribute__((format(printf,1,2)));
251 void debugaz(const char *msg,...) __attribute__((format(printf,1,2)));
252 void my_lltoa(unsigned long long int n, char *s, int ssize, int len);
253 char *get_size(const char *path, const char *file);
254 void url_module(const char *url, char *w2);
255 void url_to_file(const char *url,char *file,int filesize);
256 void safe_strcpy(char *dest,const char *src,int length);
257 void strip_latin(char *line);
258 char *buildtime(long long int elap);
259 int obtdate(const char *dirname, const char *name, char *data);
260 void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second,int dst);
261 void computedate(int year,int month,int day,struct tm *t);
262 int obtuser(const char *dirname, const char *name);
263 void obttotal(const char *dirname, const char *name, int nuser, long long int *tbytes, long long int *media);
264 void version(void);
265 int vercode(const char *code);
266 void load_excludecodes(const char *ExcludeCodes);
267 void free_excludecodes(void);
268 void my_mkdir(const char *name);
269 int testvaliduserchar(const char *user);
270 char *strlow(char *string);
271 char *strup(char *string);
272 int month2num(const char *month);
273 int builddia(int day, int month, int year);
274 int vrfydir(const struct periodstruct *per1, const char *addr, const char *site, const char *us, const char *form);
275 int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period);
276 void getperiod_fromrange(struct periodstruct *period,int dfrom,int duntil);
277 int getperiod_buildtext(struct periodstruct *period);
278 void removetmp(const char *outdir);
279 void zdate(char *ftime,int ftimesize, const char *DateFormat);
280 char *get_param_value(const char *param,char *line);
281 int compar( const void *, const void * );
282 void unlinkdir(const char *dir,int contentonly);
283 int extract_address_mask(const char *buf,const char **text,unsigned char *ipv4,unsigned short int *ipv6,int *nbits,const char **next);