#include <dirent.h>#include <stdarg.h>#include <stdint.h>#include <limits.h>#include <sys/time.h>Go to the source code of this file.
Classes | |
| union | pn_resource_id |
| struct | pnotify_watch |
Defines | |
| #define | NOTE_TRUNCATE 0 |
Enumerations | |
| enum | pn_watch_type { WATCH_VNODE = 0, WATCH_FD, WATCH_TIMER, WATCH_SIGNAL, WATCH_FUNCTION } |
| enum | pn_event_bitmask { PN_DEFAULT = 0, PN_ATTRIB = 0x1 << 0, PN_CREATE = 0x1 << 1, PN_DELETE = 0x1 << 2, PN_MODIFY = 0x1 << 3, PN_READ = 0x1 << 4, PN_WRITE = 0x1 << 5, PN_CLOSE = 0x1 << 6, PN_TIMEOUT = 0x1 << 7, PN_SIGNAL = 0x1 << 8, PN_ONESHOT = 0x1 << 30, PN_ERROR = 0x1 << 31 } |
Functions | |
| pnotify_ctx * | pnotify_init () |
| int | pnotify_add_watch (struct pnotify_watch *watch) |
| int | pnotify_rm_watch (int wd) |
| int | pnotify_get_event (struct pnotify_event *, struct pnotify_ctx *) |
| int | pnotify_dispatch () |
| int | pnotify_print_event (struct pnotify_event *) |
| void | pnotify_dump (struct pnotify_ctx *) |
| void | pnotify_free (struct pnotify_ctx *ctx) |
| int | pnotify_trap_signal (int signum, void(*cb)(), void *arg) |
| int | pnotify_watch_vnode (const char *path, int mask, void(*cb)(), void *arg) |
| int | pnotify_watch_fd (int fd, int mask, void(*cb)(), void *arg) |
| int | pnotify_set_timer (int interval, int mask, void(*cb)(), void *arg) |
Definition in file pnotify.h.
| enum pn_event_bitmask |
The bitmask of events to monitor
| enum pn_watch_type |
| int pnotify_add_watch | ( | struct pnotify_watch * | watch | ) |
Add a watch.
| watch | a watch structure |
Definition at line 164 of file pnotify.c.
References pnotify_vtable::add_watch, pnotify_watch::arg, pnotify_watch::cb, pnotify_watch::ctx, CTX_GET, pnotify_watch::ident, pnotify_watch::mask, pn_resource_id::path, pn_resource_id::signum, sys, pnotify_watch::type, WATCH_FD, WATCH_SIGNAL, WATCH_TIMER, and WATCH_VNODE.
Referenced by pnotify_set_timer(), pnotify_trap_signal(), pnotify_watch_fd(), and pnotify_watch_vnode().
| int pnotify_dispatch | ( | ) |
Wait for events and dispatch callbacks.
Definition at line 481 of file pnotify.c.
References pn_watch::arg, pn_watch::cb, pnotify_event::mask, pnotify_get_event(), pn_watch::type, pnotify_event::watch, WATCH_TIMER, and WATCH_VNODE.
| void pnotify_dump | ( | struct pnotify_ctx * | ) |
Print the context to standard output.
Definition at line 337 of file pnotify.c.
References pnotify_print_event().
| void pnotify_free | ( | struct pnotify_ctx * | ctx | ) |
Free all resources associated with an event queue.
All internal data structures will be freed.
| ctx | a context returned by pnotify_init() or NULL for the current context |
Definition at line 355 of file pnotify.c.
References pnotify_vtable::cleanup, pnotify_ctx::event_count, pnotify_ctx::mutex, pnotify_rm_watch(), sys, pnotify_event::watch, and pn_watch::wd.
| int pnotify_get_event | ( | struct pnotify_event * | , | |
| struct pnotify_ctx * | ||||
| ) |
Wait for an event to occur.
| evt | an event structure that will store the result | |
| ctx | a context returned by pnotify_init() or NULL for the current context |
Definition at line 286 of file pnotify.c.
References CTX_GET, and pnotify_ctx::event_count.
Referenced by pnotify_dispatch().
| struct pnotify_ctx* pnotify_init | ( | ) |
Initialize a pnotify event queue.
Before adding watches, the queue must be initialized via a call to pnotify_init().
Definition at line 122 of file pnotify.c.
References pnotify_init_once().
| int pnotify_print_event | ( | struct pnotify_event * | ) |
Print debugging information about an event to standard output.
| evt | an event to be printed |
Definition at line 321 of file pnotify.c.
References pnotify_event::mask, pnotify_event::name, PN_ATTRIB, PN_CREATE, PN_DELETE, PN_ERROR, PN_MODIFY, pnotify_event::watch, and pn_watch::wd.
Referenced by pnotify_dump().
| int pnotify_rm_watch | ( | int | wd | ) |
Remove a watch.
| wd | watch descriptor |
Definition at line 247 of file pnotify.c.
References pn_watch::parent_wd, pn_rm_timer(), pnotify_vtable::rm_watch, sys, WATCH_TIMER, and pn_watch::wd.
Referenced by pnotify_free().
| int pnotify_set_timer | ( | int | interval, | |
| int | mask, | |||
| void(*)() | cb, | |||
| void * | arg | |||
| ) |
Set a timer to fire after specific number of seconds
If the mask is set to PN_ONESHOT, the timer will be automatically deleted after one occurrance. If the mask is PN_DEFAULT, the timer will repeat forever.
| interval | the number of seconds between timer events | |
| mask | either PN_DEFAULT or PN_ONESHOT |
Definition at line 429 of file pnotify.c.
References pnotify_watch::arg, pnotify_watch::cb, pnotify_watch::ident, pn_resource_id::interval, pnotify_watch::mask, pn_add_timer(), pnotify_add_watch(), pnotify_watch::type, and WATCH_TIMER.
| int pnotify_trap_signal | ( | int | signum, | |
| void(*)() | cb, | |||
| void * | arg | |||
| ) |
Trap a specific signal and generate an event when it is received.
When a signal is trapped, it is no longer delivered to the program and is converted into an event instead.
| signum | the signal to be trapped |
Definition at line 455 of file pnotify.c.
References pnotify_watch::arg, pnotify_watch::cb, CTX_GET, pnotify_watch::ident, pnotify_watch::mask, PN_SIGNAL, pn_trap_signal(), pnotify_add_watch(), pn_resource_id::signum, pnotify_watch::type, and WATCH_SIGNAL.
| int pnotify_watch_fd | ( | int | fd, | |
| int | mask, | |||
| void(*)() | cb, | |||
| void * | arg | |||
| ) |
Watch for changes to a file descriptor
Definition at line 415 of file pnotify.c.
References pnotify_watch::arg, pnotify_watch::cb, pn_resource_id::fd, pnotify_watch::ident, pnotify_watch::mask, pnotify_add_watch(), pnotify_watch::type, and WATCH_FD.
| int pnotify_watch_vnode | ( | const char * | path, | |
| int | mask, | |||
| void(*)() | cb, | |||
| void * | arg | |||
| ) |
Watch for changes to a vnode
| path | the path to a file or directory to be monitored | |
| mask | a bitmask of events to monitor |
Definition at line 400 of file pnotify.c.
References pnotify_watch::arg, pnotify_watch::cb, pnotify_watch::ident, pnotify_watch::mask, pn_resource_id::path, pnotify_add_watch(), pnotify_watch::type, and WATCH_VNODE.
1.5.1