forked from wazuh/wazuh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotify_op.h
More file actions
56 lines (42 loc) · 1.24 KB
/
notify_op.h
File metadata and controls
56 lines (42 loc) · 1.24 KB
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
/*
* Event notification
* Copyright (C) 2015-2019, Wazuh Inc.
* May 4, 2018
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License (version 2) as published by the FSF - Free Software
* Foundation.
*/
#ifndef NOTIFY_OP_H
#define NOTIFY_OP_H
#if defined(__linux__)
#include <sys/epoll.h>
typedef struct wnotify_t {
int fd;
int size;
struct epoll_event * events;
} wnotify_t;
static inline int wnotify_get(const wnotify_t * notify, int index) {
return notify->events[index].data.fd;
}
#elif defined(__MACH__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/types.h>
#include <sys/event.h>
typedef struct wnotify_t {
int fd;
int size;
struct kevent * events;
} wnotify_t;
static inline int wnotify_get(const wnotify_t * notify, int index) {
return notify->events[index].ident;
}
#endif /* __linux__ */
#if defined(__linux__) || defined(__MACH__) || defined(__FreeBSD__) || defined(__OpenBSD__)
wnotify_t * wnotify_init(int size);
int wnotify_add(wnotify_t * notify, int fd);
int wnotify_delete(wnotify_t * notify, int fd);
int wnotify_wait(wnotify_t * notify, int timeout);
void wnotify_close(wnotify_t * notify);
#endif
#endif