00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _PNOTIFY_H
00020 #define _PNOTIFY_H
00021
00028 #include <dirent.h>
00029 #include <stdarg.h>
00030 #include <stdint.h>
00031 #include <limits.h>
00032 #include <sys/time.h>
00033 #include <stdarg.h>
00034
00035
00036 #ifndef NOTE_TRUNCATE
00037 # define NOTE_TRUNCATE 0
00038 #endif
00039
00040
00041 struct pnotify_event;
00042 struct pnotify_ctx;
00043
00044
00046 enum pn_watch_type {
00048 WATCH_VNODE = 0,
00049
00051 WATCH_FD,
00052
00054 WATCH_TIMER,
00055
00057 WATCH_SIGNAL,
00058
00060 WATCH_FUNCTION
00061 };
00062
00063
00065 union pn_resource_id {
00070 int fd;
00071
00077 int signum;
00078
00084 int interval;
00085
00092 char *path;
00093 };
00094
00095
00097 enum pn_event_bitmask {
00098
00100 PN_DEFAULT = 0,
00101
00103 PN_ATTRIB = 0x1 << 0,
00104
00106 PN_CREATE = 0x1 << 1,
00107
00109 PN_DELETE = 0x1 << 2,
00110
00112 PN_MODIFY = 0x1 << 3,
00113
00115 PN_READ = 0x1 << 4,
00116
00118 PN_WRITE = 0x1 << 5,
00119
00121 PN_CLOSE = 0x1 << 6,
00122
00124 PN_TIMEOUT = 0x1 << 7,
00125
00127 PN_SIGNAL = 0x1 << 8,
00128
00130 PN_ONESHOT = 0x1 << 30,
00131
00133 PN_ERROR = 0x1 << 31,
00134
00135 };
00136
00137
00143 struct pnotify_watch {
00144
00146 enum pn_watch_type type;
00147
00149 enum pn_event_bitmask mask;
00150
00152 union pn_resource_id ident;
00153
00161 void (*cb)();
00162 void *arg;
00163
00165 struct pnotify_ctx *ctx;
00166 };
00167
00168
00177 struct pnotify_ctx * pnotify_init();
00178
00185 int pnotify_add_watch(struct pnotify_watch *watch);
00186
00193 int pnotify_rm_watch(int wd);
00194
00195
00203 int pnotify_get_event(struct pnotify_event *, struct pnotify_ctx *);
00204
00210 int pnotify_dispatch();
00211
00216 int pnotify_print_event(struct pnotify_event *);
00217
00218
00222 void pnotify_dump(struct pnotify_ctx *);
00223
00232 void pnotify_free(struct pnotify_ctx *ctx);
00233
00242 int pnotify_trap_signal(int signum, void (*cb)(), void *arg);
00243
00250 int pnotify_watch_vnode(const char *path, int mask, void (*cb)(), void *arg);
00251
00253 int pnotify_watch_fd(int fd, int mask, void (*cb)(), void *arg);
00254
00264 int pnotify_set_timer(int interval, int mask, void (*cb)(), void *arg);
00265
00266 #if TODO
00267
00268
00270 #define PNOTIFY_ARG_MAX 12
00271
00272 struct pnotify_func {
00273
00275 void (*symbol)();
00276
00278 size_t argc;
00279
00281 void *argv[PNOTIFY_ARG_MAX + 1];
00282
00284 void (*cb)();
00286 void *cbarg;
00287
00288
00289
00291 union {
00292 int rv_int;
00293 void *rv_ptr;
00294 } retval;
00295
00297 int ret_errno;
00298 };
00299
00300 #define pnotify_set_function(pf, sym,
00301
00305 int pnotify_call_function(struct );
00306 #endif
00307
00308 #endif