Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
log_reader.h
Go to the documentation of this file.
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 
7 /*
8  * File: log_reader.h
9  * Author: Kirill Scherba <kirill@scherba.ru>
10  *
11  * Created on February 16, 2019, 1:34 AM
12  */
13 
14 #ifndef LOG_READER_H
15 #define LOG_READER_H
16 
17 typedef uint32_t teoLogReaderFlag;
18 typedef enum _teoLogReaderFlag {
19  READ_FROM_BEGIN, // 000 Read log file from the beginning
20  READ_FROM_END = 0b001, // 001 Read new strings only (after current end)
21  SKIP_EMPTY = 0b010 // 010 Skip empty strings
23 
24 typedef struct teoLogReaderClass {
25 
26  void *ke; // Pointer to ksnEvMgrClass
27  void *buffer; // Pointer to read buffer
28  size_t buf_size; // Size of current allocated read buffer size
29  void *line_buffer; // Pointer to read line buffer
30  size_t line_buf_size; // Size of current allocated read line buffer size
31 
33 
35 
36 typedef void (*teoLogReaderCallback) (void* data, size_t data_length, teoLogReaderWatcher *wd);
37 
38 typedef struct teoLogReaderWatcher {
42  const char *file_name;
43  const char *name;
44  void *user_data;
45  ev_stat *w;
46  int fd;
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
55 teoLogReaderWatcher *teoLogReaderOpen(teoLogReaderClass *lr, const char *name, const char *file_name, teoLogReaderFlag flags);
56 teoLogReaderWatcher *teoLogReaderOpenCb(teoLogReaderClass *lr, const char *name, const char *file_name, teoLogReaderFlag flags, teoLogReaderCallback cb);
57 teoLogReaderWatcher *teoLogReaderOpenCbPP(teoLogReaderClass *lr, const char *name, const char *file_name, teoLogReaderFlag flags, teoLogReaderCallback cb, void *user_data);
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 
64 #endif /* LOG_READER_H */
Definition: log_reader.h:38
int fd
Definition: log_reader.h:46
teoLogReaderClass * teoLogReaderInit(void *ke)
Definition: log_reader.c:25
size_t line_buf_size
Definition: log_reader.h:30
const char data[]
Make it with: gcc -o post-callback post-callback.c -lcurl.
Definition: post-callback.c:23
teoLogReaderWatcher * teoLogReaderOpen(teoLogReaderClass *lr, const char *name, const char *file_name, teoLogReaderFlag flags)
Definition: log_reader.c:150
void * user_data
Definition: log_reader.h:44
_teoLogReaderFlag
Definition: log_reader.h:18
teoLogReaderWatcher * teoLogReaderOpenCbPP(teoLogReaderClass *lr, const char *name, const char *file_name, teoLogReaderFlag flags, teoLogReaderCallback cb, void *user_data)
Definition: log_reader.c:116
int teoLogReaderClose(teoLogReaderWatcher *wd)
Definition: log_reader.c:155
void(* teoLogReaderCallback)(void *data, size_t data_length, teoLogReaderWatcher *wd)
Definition: log_reader.h:36
teoLogReaderClass * lr
Definition: log_reader.h:41
const char * name
Definition: log_reader.h:43
const char * file_name
Definition: log_reader.h:42
Definition: log_reader.h:20
teoLogReaderWatcher * teoLogReaderOpenCb(teoLogReaderClass *lr, const char *name, const char *file_name, teoLogReaderFlag flags, teoLogReaderCallback cb)
Definition: log_reader.c:144
void teoLogReaderDestroy(teoLogReaderClass *lr)
Definition: log_reader.c:38
teoLogReaderCallback cb
Definition: log_reader.h:39
uint32_t teoLogReaderFlag
Definition: log_reader.h:17
#define ke
void * ke
Definition: log_reader.h:26
teoLogReaderFlag flags
Definition: log_reader.h:40
struct teoLogReaderClass teoLogReaderClass
void * buffer
Definition: log_reader.h:27
Definition: log_reader.h:19
ev_stat * w
Definition: log_reader.h:45
void * line_buffer
Definition: log_reader.h:29
struct teoLogReaderWatcher teoLogReaderWatcher
Definition: log_reader.h:34
size_t buf_size
Definition: log_reader.h:28
Definition: log_reader.h:24
Definition: log_reader.h:21