]> git.ipfire.org Git - thirdparty/sarg.git/blob - include/readlog.h
Fix an error introduced when stripping the user domain
[thirdparty/sarg.git] / include / readlog.h
1 #ifndef READLOG_HEADER
2 #define READLOG_HEADER
3
4 /*!
5 \brief Possible return codes for the functions parsing the input log.
6 */
7 enum ReadLogReturnCodeEnum
8 {
9 //! Line successfuly read.
10 RLRC_NoError,
11 //! Line is known and should be ignored.
12 RLRC_Ignore,
13 //! Unknown line format.
14 RLRC_Unknown,
15 //! Error encountered during the parsing of the file.
16 RLRC_InternalError,
17
18 RLRC_LastRetCode //!< last entry of the list.
19 };
20
21 /*!
22 \brief Data read from an input log file.
23 */
24 struct ReadLogStruct
25 {
26 //! The time corresponding to the entry.
27 struct tm EntryTime;
28 //! The IP address connecting to internet.
29 const char *Ip;
30 //! The user's name.
31 const char *User;
32 /*!
33 The URL of the visited site.
34
35 The pointer may be NULL if the URL doesn't exists in the log file.
36 */
37 char *Url;
38 //! Time necessary to process the user's request.
39 long int ElapsedTime;
40 //! Number of transfered bytes.
41 long long int DataSize;
42 //! HTTP code returned to the user for the entry.
43 char *HttpCode;
44 //! HTTP method or NULL if the information is not stored in the log.
45 char *HttpMethod;
46 };
47
48 /*!
49 \brief Functions to read a log file.
50 */
51 struct ReadLogProcessStruct
52 {
53 //! The name of the log file processed by this object.
54 const char *Name;
55 //! Inform the module about the reading of a new file.
56 void (*NewFile)(const char *FileName);
57 //! Funtion to read one entry from the log.
58 enum ReadLogReturnCodeEnum (*ReadEntry)(char *Line,struct ReadLogStruct *Entry);
59 };
60
61 /*!
62 * \brief Persistant data to parse a log line.
63 */
64 struct LogLineStruct
65 {
66 const struct ReadLogProcessStruct *current_format;
67 int current_format_idx;
68 int successive_errors;
69 int total_errors;
70 const char *file_name;
71 };
72
73 //! Opaque object used to parse a log line.
74 typedef struct LogLineStruct *LogLineObject;
75
76 void LogLine_Init(struct LogLineStruct *log_line);
77 void LogLine_File(struct LogLineStruct *log_line,const char *file_name);
78 enum ReadLogReturnCodeEnum LogLine_Parse(struct LogLineStruct *log_line,struct ReadLogStruct *log_entry,char *linebuf);
79
80 #endif //READLOG_HEADER