]> git.ipfire.org Git - thirdparty/sarg.git/blame - include/defs.h
Fails if no file names can be found when file globbing is on
[thirdparty/sarg.git] / include / defs.h
CommitLineData
f2ec8c75
FM
1/*!\file
2\brief Declaration of the structures and functions.
3*/
9c7c6346 4
3c3ae3bd
FM
5#ifdef __MINGW32__
6#define __attribute__(a)
7#endif
8
cb59dc47
FM
9//! \brief Constants to compare the log level to display messages
10enum DebugLogLevel
11{
12 //! Process informational messages.
13 LogLevel_Process=1,
14 //! Debug level messages.
15 LogLevel_Debug,
16 //! Display the source file name and line number along with the message.
4246ae8d
FM
17 LogLevel_Source,
18 //! Display data about what is processed
19 LogLevel_Data
cb59dc47
FM
20};
21
f83d7b44 22struct ReadLogStruct;//forward declaration
8e53b2e7 23
9c7c6346
FM
24struct getwordstruct
25{
26 const char *current;
27 const char *beginning;
e5b2c6f0 28 int modified;
9c7c6346
FM
29};
30
afaa3b67 31typedef struct longlinestruct *longline;
ac422f9b 32
2240dcea
FM
33struct generalitemstruct
34{
35 //! \c True if the entry is for the total of the file or \c false if it is a single line.
36 int total;
37 //! The user to which the entry apply. The length is limited to ::MAX_USER_LEN.
38 char *user;
39 //! The number of accesses performed by the user.
40 long long nacc;
41 //! The number of bytes transfered.
42 long long nbytes;
43 //! The URL accessed by the user. The length is not limited.
44 char *url;
45 //! The source IP address of the user. The length is limited to ::MAX_IP_LEN.
46 char *ip;
47 //! The time of the access. The length is limited to ::MAX_DATETIME_LEN.
48 char *time;
49 //! The date of the access. The length is limited to ::MAX_DATETIME_LEN.
50 char *date;
51 //! The number of milliseconds spend processing the request.
52 long long nelap;
53 //! The number of bytes fetched from the cache of the proxy (cache hit).
54 long long incache;
55 //! The number of bytes fetched from the site (cache miss).
56 long long oucache;
57};
58
93551487
FM
59/*! \brief What is known about a user.
60*/
f2ec8c75
FM
61struct userinfostruct
62{
93551487 63 //! The ID of the user as found in the input file.
b6b6cb8c 64 const char *id;
aa6ac9f2
FM
65 //! The user's IP address.
66 const char *ip;
93551487
FM
67 //! \c True if the ID is in fact the IP address from which the user connected.
68 bool id_is_ip;
69 //! \c True if the user doesn't have a report file.
70 bool no_report;
71 //! The name of the user to display in the report.
b6b6cb8c 72 const char *label;
93551487 73 //! The mangled name to use in file names of that user.
b6b6cb8c 74 const char *filename;
a58e6d54
FM
75 //! \c True if this user is in the topuser list.
76 int topuser;
77 //! A general purpose flag that can be set when scanning the user's list.
78 int flag;
d91457d2
FM
79#ifdef ENABLE_DOUBLE_CHECK_DATA
80 //! Total number of bytes.
81 long long int nbytes;
82 //! Total time spent processing the requests.
83 long long int elap;
84#endif
f2ec8c75
FM
85};
86
93551487
FM
87//! Scan through the known users.
88typedef struct userscanstruct *userscan;
89
9dc20988
FM
90/*! \brief Global statistics
91*/
92struct globalstatstruct
93{
94 //! Total number of accesses.
95 long long int nacc;
96 //! Total number of bytes.
97 long long int nbytes;
98 //! Total time spent processing the requests.
99 long long int elap;
100 //! Amount of data fetched from the cache.
101 long long int incache;
102 //! Amount of data not fetched from the cache.
103 long long int oucache;
e5b3a129
FM
104 //! The number of users in the topuser list.
105 int totuser;
9dc20988
FM
106};
107
026ddd8b
FM
108//! The object to store the daily statistics.
109typedef struct DayStruct *DayObject;
110
27d1fa35
FM
111/*!
112\brief Log filtering criterion.
113*/
114struct ReadLogDataStruct
115{
116 //! The filtering date range.
117 char DateRange[255];
118 //! \c True to filter on hosts.
119 bool HostFilter;
120 //! \c True to filter on users.
121 bool UserFilter;
122 //! Maximum elpased time allowed. Any time greater than this value is set to zero.
123 long int max_elapsed;
124 //! \c True to restrict the log to the system users.
125 bool SysUsers;
126 //! The start time to include in the report(H*100+M). Set to -1 to disable.
127 int StartTime;
128 //! The end time to include in the report(H*100+M). Set to -1 to disable.
129 int EndTime;
130};
131
0b5356bb
FM
132/*!
133\brief How to handle the per_user_limit file creation.
134*/
135enum PerUserFileCreationEnum
136{
137 //! Purge the file if it exists or create an empty file.
138 PUFC_Always,
139 //! Delete old files and don't create a new file unless necessary.
140 PUFC_AsRequired
141};
142
3877d630
FM
143/*!
144\brief What to write into the per_user_limit file.
145*/
146enum PerUserOutputEnum
147{
148 PUOE_UserId,
149 PUOE_UserIp
150};
151
2e29ae23
FM
152/*!
153\brief How to log every user crossing the download limit.
154*/
155struct PerUserLimitStruct
156{
157 //! File to save the user's IP or ID to.
158 char File[255];
159 //! Limit above which the user is reported.
160 int Limit;
3877d630
FM
161 //! What to write into the file.
162 enum PerUserOutputEnum Output;
2e29ae23
FM
163};
164
5f3cfd1d 165// auth.c
d25d4e6a 166void htaccess(const struct userinfostruct *uinfo);
5f3cfd1d
FM
167
168// authfail.c
16b013cc
FM
169void authfail_open(void);
170void authfail_write(const struct ReadLogStruct *log_entry);
171void authfail_close(void);
172bool is_authfail(void);
5f3cfd1d 173void authfail_report(void);
16b013cc 174void authfail_cleanup(void);
5f3cfd1d 175
5f3cfd1d 176// convlog.c
81a022d8 177void convlog(const char* arq, char df, int dfrom, int duntil);
5f3cfd1d
FM
178
179// css.c
d183fb7f 180void css_content(FILE *fp_css);
5f3cfd1d
FM
181void css(FILE *fp_css);
182
183// dansguardian_log.c
184void dansguardian_log(void);
185
186// dansguardian_report.c
187void dansguardian_report(void);
188
189// datafile.c
190void data_file(char *tmp);
191
192// decomp.c
d2855b39 193FILE *decomp(const char *arq, bool *pipe);
5f3cfd1d
FM
194
195// denied.c
8e53b2e7
FM
196void denied_open(void);
197void denied_write(const struct ReadLogStruct *log_entry);
198void denied_close(void);
199bool is_denied(void);
5f3cfd1d 200void gen_denied_report(void);
60b48ae5 201void denied_cleanup(void);
5f3cfd1d
FM
202
203// download.c
11284535
FM
204void download_open(void);
205void download_write(const struct ReadLogStruct *log_entry,const char *url);
206void download_close(void);
207bool is_download(void);
5f3cfd1d 208void download_report(void);
6e792ade
FM
209void free_download(void);
210void set_download_suffix(const char *list);
2824ec9b 211bool is_download_suffix(const char *url);
11284535 212void download_cleanup(void);
5f3cfd1d
FM
213
214// email.c
2824ec9b 215int geramail(const char *dirname, int debug, const char *outdir, const char *email, const char *TempDir);
5f3cfd1d
FM
216
217// exclude.c
43f18f45
FM
218void gethexclude(const char *hexfile, int debug);
219void getuexclude(const char *uexfile, int debug);
220int vhexclude(const char *url);
221int vuexclude(const char *user);
2824ec9b 222bool is_indexonly(void);
43f18f45 223void free_exclude(void);
5f3cfd1d 224
6068ae56
FM
225#ifndef HAVE_FNMATCH
226// fnmtach.c
227int fnmatch(const char *pattern,const char *string,int flags);
228#endif
229
5f3cfd1d
FM
230// getconf.c
231void getconf(void);
232
233// grepday.c
1f482a8d 234void greport_prepare(void);
f2ec8c75 235void greport_day(const struct userinfostruct *user);
c274f011 236void greport_cleanup(void);
5f3cfd1d
FM
237
238// html.c
239void htmlrel(void);
240
241// indexonly.c
242void index_only(const char *dirname,int debug);
243
244// ip2name.c
51b166d4
FM
245int ip2name_config(const char *param);
246void ip2name_forcedns(void);
5f3cfd1d 247void ip2name(char *ip,int ip_len);
0326d73b 248void ip2name_cleanup(void);
4afbb7a5 249void name2ip(char *name,int name_size);
5f3cfd1d 250
5f3cfd1d
FM
251// lastlog.c
252void mklastlog(const char *outdir);
253
afaa3b67 254// longline.c
fa6552b0 255__attribute__((warn_unused_result)) /*@null@*//*@only@*/longline longline_create(void);
afaa3b67
FM
256void longline_reset(longline line);
257/*@null@*/char *longline_read(FILE *fp_in,/*@null@*/longline line);
258void longline_destroy(/*@out@*//*@only@*//*@null@*/longline *line_ptr);
259
5f3cfd1d
FM
260// index.c
261void make_index(void);
262
27d1fa35
FM
263// readlog.c
264int ReadLogFile(struct ReadLogDataStruct *Filter);
b6fb8c79 265bool GetLogPeriod(struct tm *Start,struct tm *End);
27d1fa35 266
5f3cfd1d
FM
267// realtime.c
268void realtime(void);
269
330b1c52
FM
270// redirector.c
271void redirector_log(void);
272void redirector_report(void);
273
5f3cfd1d 274// repday.c
f2ec8c75 275void report_day(const struct userinfostruct *user);
5f3cfd1d
FM
276
277// report.c
5f3cfd1d 278void gerarel(void);
2240dcea 279int ger_read(char *buffer,struct generalitemstruct *item,const char *filename);
9dc20988 280void totalger(FILE *fp_gen,const char *filename);
5f3cfd1d
FM
281
282// siteuser.c
283void siteuser(void);
284
285// smartfilter.c
286void smartfilter_report(void);
287
288// sort.c
461b479d 289void sort_users_log(const char *tmp, int debug,struct userinfostruct *uinfo);
e5b3a129 290void tmpsort(const struct userinfostruct *uinfo);
15d5372b 291void sort_labels(const char **label,const char **order);
5f3cfd1d
FM
292
293// splitlog.c
81a022d8 294void splitlog(const char *arq, char df, int dfrom, int duntil, int convert, const char *splitprefix);
5f3cfd1d 295
5f3cfd1d
FM
296// topsites.c
297void topsites(void);
298
299// topuser.c
300void topuser(void);
301
302// totday.c
026ddd8b
FM
303DayObject day_prepare(void);
304void day_cleanup(DayObject ddata);
305void day_newuser(DayObject ddata);
306void day_addpoint(DayObject ddata,const char *date, const char *time, long long int elap, long long int bytes);
307void day_totalize(DayObject ddata,const char *tmp, const struct userinfostruct *uinfo);
e3e6aef4 308void day_deletefile(const struct userinfostruct *uinfo);
5f3cfd1d 309
22715352
FM
310// url.c
311void read_hostalias(const char *Filename);
312void free_hostalias(void);
6fa33a32 313const char *skip_scheme(const char *url);
e2379f05 314const char *process_url(const char *url,bool full_url);
22715352
FM
315void url_hostname(const char *url,char *hostname,int hostsize);
316
5f3cfd1d
FM
317// usage.c
318void usage(const char *prog);
319
320// useragent.c
321void useragent(void);
322
f2ec8c75 323// userinfo.c
aa6ac9f2 324/*@shared@*/struct userinfostruct *userinfo_create(const char *userid, const char *ip);
f2ec8c75 325void userinfo_free(void);
b6b6cb8c 326void userinfo_label(struct userinfostruct *uinfo,const char *label);
4ca814cc
FM
327/*@shared@*/struct userinfostruct *userinfo_find_from_file(const char *filename);
328/*@shared@*/struct userinfostruct *userinfo_find_from_id(const char *id);
05fea6e7 329/*@shared@*/struct userinfostruct *userinfo_find_from_ip(const char *ip);
93551487
FM
330userscan userinfo_startscan(void);
331void userinfo_stopscan(userscan uscan);
332struct userinfostruct *userinfo_advancescan(userscan uscan);
a58e6d54 333void userinfo_clearflag(void);
c4f0ea8f
FM
334void read_useralias(const char *Filename);
335void free_useralias(void);
336const char *process_user(const char *user);
f2ec8c75 337
965c4a6f
FM
338// usertab.c
339void init_usertab(const char *UserTabFile);
340void user_find(char *mappedname, int namelen, const char *userlogin);
341void close_usertab(void);
342
5f3cfd1d 343// util.c
06b39c87 344void getword_start(/*@out@*/struct getwordstruct *gwarea, const char *line);
9c7c6346 345void getword_restart(struct getwordstruct *gwarea);
d5a1c7f9
FM
346__attribute__((warn_unused_result)) int getword(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
347__attribute__((warn_unused_result)) int getword_limit(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
348__attribute__((warn_unused_result)) int getword_multisep(/*@out@*/char *word, int limit, struct getwordstruct *gwarea, char stop);
349__attribute__((warn_unused_result)) int getword_skip(int limit, struct getwordstruct *gwarea, char stop);
350__attribute__((warn_unused_result)) int getword_atoll(/*@out@*/long long int *number, struct getwordstruct *gwarea, char stop);
bd8b7715 351__attribute__((warn_unused_result)) int getword_atoi(/*@out@*/int *number, struct getwordstruct *gwarea, char stop);
2c4bc22b
FM
352__attribute__((warn_unused_result)) int getword_atol(long int *number, struct getwordstruct *gwarea, char stop);
353__attribute__((warn_unused_result)) int getword_atolu(unsigned long int *number, struct getwordstruct *gwarea, char stop);
d5a1c7f9 354__attribute__((warn_unused_result)) int getword_ptr(char *orig_line,/*@out@*/char **word, struct getwordstruct *gwarea, char stop);
e6414a9d
FM
355long long int my_atoll (const char *nptr);
356int is_absolute(const char *path);
e3af0ae9 357int getnumlist(char *, numlist *, const int, const int);
fa6552b0
FM
358int conv_month(const char *month);
359const char *conv_month_name(int month);
60ec7f09
FM
360void buildymd(const char *dia, const char *mes, const char *ano, char *wdata,int wdata_size);
361void date_from(char *date,int date_size, int *dfrom, int *duntil);
5f3cfd1d
FM
362char *fixnum(long long int value, int n);
363char *fixnum2(long long int value, int n);
364void fixnone(char *str);
324ba7f3 365char *fixtime(long long int elap);
2357ef77 366void fixendofline(char *str);
5f3cfd1d 367void show_info(FILE *fp_ou);
c0ec9cc7 368void show_sarg(FILE *fp_ou, int depth);
dfb337be 369void write_logo_image(FILE *fp_ou);
2e96438d
FM
370void write_html_head(FILE *fp_ou, int depth, const char *page_title,int javascript);
371void write_html_header(FILE *fp_ou, int depth, const char *title,int javascript);
c0ec9cc7 372void close_html_header(FILE *fp_ou);
342bd723 373void write_html_trailer(FILE *fp_ou);
ac422f9b
FM
374void output_html_string(FILE *fp_ou,const char *str,int maxlen);
375void output_html_url(FILE *fp_ou,const char *url);
6fa33a32 376void output_html_link(FILE *fp_ou,const char *url,int maxlen);
af961877 377void debuga(const char *File, int Line, const char *msg,...) __attribute__((format(printf,3,4)));
2ef286b6 378void debuga_more(const char *msg,...) __attribute__((format(printf,1,2)));
af961877 379void debugaz(const char *File,int Line,const char *msg,...) __attribute__((format(printf,3,4)));
e5b2c6f0 380void my_lltoa(unsigned long long int n, char *s, int ssize, int len);
48864d28 381void url_module(const char *url, char *w2);
f72b484a 382void url_to_anchor(const char *url,char *anchor,int size);
a87d4d11 383void safe_strcpy(char *dest,const char *src,int length);
5f3cfd1d
FM
384void strip_latin(char *line);
385char *buildtime(long long int elap);
15d3cb5c 386int obtdate(const char *dirname, const char *name, char *data);
a1de61fe 387void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second,int dst);
fa6552b0 388void computedate(int year,int month,int day,struct tm *t);
d25d4e6a 389int obtuser(const char *dirname, const char *name);
ea275279 390void obttotal(const char *dirname, const char *name, int nuser, long long int *tbytes, long long int *media);
5f3cfd1d
FM
391void version(void);
392int vercode(const char *code);
48864d28
FM
393void load_excludecodes(const char *ExcludeCodes);
394void free_excludecodes(void);
7a9d0965 395int PortableMkDir(const char *path,int mode);
5f3cfd1d
FM
396void my_mkdir(const char *name);
397int testvaliduserchar(const char *user);
398char *strlow(char *string);
399char *strup(char *string);
fa6552b0
FM
400int month2num(const char *month);
401int builddia(int day, int month, int year);
944cf283 402int compare_date(struct tm *date1,struct tm *date2);
0971b2d6 403bool IsTreeFileDirName(const char *Name);
16c12388
FM
404bool IsTreeYearFileName(const char *Name);
405bool IsTreeMonthFileName(const char *Name);
406bool IsTreeDayFileName(const char *Name);
fa6552b0
FM
407int vrfydir(const struct periodstruct *per1, const char *addr, const char *site, const char *us, const char *form);
408int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period);
42b117e3 409void getperiod_fromrange(struct periodstruct *period,int dfrom,int duntil);
cc6af460 410void getperiod_merge(struct periodstruct *main,struct periodstruct *candidate);
fa6552b0 411int getperiod_buildtext(struct periodstruct *period);
5f3cfd1d 412void removetmp(const char *outdir);
81a022d8 413void zdate(char *ftime,int ftimesize, char DateFormat);
5f3cfd1d 414char *get_param_value(const char *param,char *line);
48864d28 415int compar( const void *, const void * );
170a77ea
FM
416void unlinkdir(const char *dir,bool contentonly);
417void emptytmpdir(const char *dir);
7819e0d5 418int extract_address_mask(const char *buf,const char **text,unsigned char *ipv4,unsigned short int *ipv6,int *nbits,const char **next);