]>
Commit | Line | Data |
---|---|---|
27d1fa35 FM |
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, | |
1c91da07 FM |
11 | //! Line is known and should be ignored. |
12 | RLRC_Ignore, | |
27d1fa35 FM |
13 | //! Unknown line format. |
14 | RLRC_Unknown, | |
1c91da07 FM |
15 | //! Error encountered during the parsing of the file. |
16 | RLRC_InternalError, | |
b902df7e | 17 | |
27d1fa35 FM |
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. | |
cb53374b | 27 | struct tm EntryTime; |
1c91da07 | 28 | //! The IP address connecting to internet. |
f83d7b44 | 29 | const char *Ip; |
27d1fa35 | 30 | //! The user's name. |
7799ec8d | 31 | const char *User; |
1c91da07 FM |
32 | /*! |
33 | The URL of the visited site. | |
b902df7e | 34 | |
1c91da07 FM |
35 | The pointer may be NULL if the URL doesn't exists in the log file. |
36 | */ | |
27d1fa35 FM |
37 | char *Url; |
38 | //! Time necessary to process the user's request. | |
2c4bc22b | 39 | long int ElapsedTime; |
27d1fa35 | 40 | //! Number of transfered bytes. |
2c4bc22b | 41 | long long int DataSize; |
27d1fa35 FM |
42 | //! HTTP code returned to the user for the entry. |
43 | char *HttpCode; | |
8b4e9578 FM |
44 | //! HTTP method or NULL if the information is not stored in the log. |
45 | char *HttpMethod; | |
27d1fa35 FM |
46 | }; |
47 | ||
1c91da07 FM |
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 | ||
8b4e9578 FM |
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 | ||
27d1fa35 | 80 | #endif //READLOG_HEADER |