-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.h
58 lines (43 loc) · 1.13 KB
/
event.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef __event_h__
#define __event_h__
#include <sys/inotify.h>
#include <limits.h>
#include "nodesync.h"
#define INOTIFY_MASK (IN_OPEN | IN_CREATE | \
IN_MODIFY | IN_DELETE | \
IN_ACCESS | IN_MODIFY | \
IN_CLOSE_WRITE | IN_CLOSE_NOWRITE | IN_Q_OVERFLOW )
#define EVENT_SIZE (sizeof(struct inotify_event))
#define BUF_LEN_E (EVENT_SIZE + NAME_MAX + 1)*10
struct q_watch_event {
struct q_watch_event *next;
struct inotify_event ievent;
};
typedef struct q_watch_event * q_wevent_t;
struct q_watch_list {
q_wevent_t head;
q_wevent_t tail;
};
typedef struct q_watch_list * q_watch_list_t;
static q_watch_list_t q_watch_list_p;
typedef enum events{
O_OPEN,
O_MODIFY,
O_DELETE,
O_CLOSE,
O_NONE
}event_t;
static int event_open(watch_t w);
static int event_modify(watch_t w);
static int event_delete(watch_t w);
static int event_close(watch_t w);
struct event_op_table {
const char *name;
int (*event_triggered)(watch_t watch);
} events_op[] = {
{"open", event_open},
{"modify", event_modify},
{"delete", event_delete},
{"close", event_close}
};
#endif