source: trunk/include/sh_log_check.h@ 183

Last change on this file since 183 was 183, checked in by katerina, 16 years ago

Support for logfile monitoring (ticket #122). Also improved some configure error messages.

File size: 2.6 KB
RevLine 
[183]1#ifndef SH_LOGCHECK_H
2#define SH_LOGCHECK_H
3
4#include <sys/types.h>
5#include <time.h>
6
7/* Convert a struct tm to unix timestamp with caching
8 */
9time_t conv_timestamp (struct tm * btime,
10 struct tm * old_tm, time_t * old_time);
11
12/* Definition of a log record entry, to be returned from parsing function.
13 */
14#define PID_INVALID 0
15struct sh_logrecord
16{
17 char * filename;
18 sh_string * prefix; /* actually a string to group messages */
19 sh_string * host;
20 sh_string * timestr;
21 pid_t pid;
22 time_t timestamp;
23 sh_string * message;
24};
25
26#define SH_LOGFILE_MOVED (1<<0)
27#define SH_LOGFILE_REWIND (1<<1)
28
29struct sh_logfile
30{
31 FILE * fp;
32 int flags;
33 char * filename;
34 dev_t device_id;
35 ino_t inode;
36 fpos_t offset;
37
38 /* Info for the parser, e.g. a regular expression
39 */
40 void * fileinfo;
41
42 /* Callback function to read the next record
43 */
44 sh_string * (*get_record) (sh_string * record,
45 struct sh_logfile * logfile);
46
47 /* Callback function to parse the record into standard format
48 */
49 struct sh_logrecord * (*parse_record)(sh_string * logline, void * fileinfo);
50
51 struct sh_logfile * next;
52};
53
54/****************************************************************
55 **
56 ** Parsing and reading functions
57 **/
58
59/* Open file, position at stored offset. */
60int sh_open_for_reader (struct sh_logfile * logfile);
61
62/* Simple line reader. */
63sh_string * sh_default_reader (sh_string * record,
64 struct sh_logfile * logfile);
65
66/* Binary reader */
67sh_string * sh_binary_reader (void * s, size_t size, struct sh_logfile * logfile);
68
69/* Parses a syslog-style line. */
70struct sh_logrecord * sh_parse_syslog (sh_string * logline, void * fileinfo);
71
72/* Format info for apache log. */
73void * sh_eval_fileinfo_apache(char * str);
74
75/* Parses a apache-style line. */
76struct sh_logrecord * sh_parse_apache (sh_string * logline, void * fileinfo);
77
78/* Get a pacct record */
79sh_string * sh_read_pacct (sh_string * record, struct sh_logfile * logfile);
80
81/* Parses a pacct record. */
82struct sh_logrecord * sh_parse_pacct (sh_string * logline, void * fileinfo);
83
84/**
85*****************************************************************/
86
87int sh_get_hidepid();
88int sh_set_hidepid(const char *s);
89
90#define SH_MAX_LCODE_SIZE 16
91
92struct sh_logfile_type
93{
94 char code[SH_MAX_LCODE_SIZE];
95
96 /* read callback */
97 /*@null@*/sh_string * (*get_record) (sh_string * record,
98 struct sh_logfile * logfile);
99 /* parsing callback */
100 struct sh_logrecord * (*parse_record)(sh_string * logline, void * fileinfo);
101
102 /* evaluate fileinfo */
103 void * (*eval_fileinfo)(char * str);
104};
105
106
107#endif
Note: See TracBrowser for help on using the repository browser.