diff options
| author | 2024-12-24 14:38:53 -0500 | |
|---|---|---|
| committer | 2024-12-24 14:38:53 -0500 | |
| commit | 822e754cafdc5a32c80c97ca015cd6f9008329c3 (patch) | |
| tree | aa8831eca4f896928e9c3ba78446ca95762fccac /src/fs_event | |
| parent | dcc43df0a40cbb2126505396cac4db26008d49b1 (diff) | |
| download | libnaunet-822e754cafdc5a32c80c97ca015cd6f9008329c3.tar.gz libnaunet-822e754cafdc5a32c80c97ca015cd6f9008329c3.tar.bz2 libnaunet-822e754cafdc5a32c80c97ca015cd6f9008329c3.zip | |
Rename, cleanup and pass on readability
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/fs_event')
| -rw-r--r-- | src/fs_event/fs_event.h | 16 | ||||
| -rw-r--r-- | src/fs_event/fs_event_inotify.c | 20 |
2 files changed, 18 insertions, 18 deletions
diff --git a/src/fs_event/fs_event.h b/src/fs_event/fs_event.h index d4983d4..1e99b62 100644 --- a/src/fs_event/fs_event.h +++ b/src/fs_event/fs_event.h @@ -4,27 +4,27 @@ #ifndef _WIN32 #include <sys/inotify.h> -#define AKI_CLOSE_WRITE IN_CLOSE_WRITE +#define NNWT_CLOSE_WRITE IN_CLOSE_WRITE #else struct inotify_event {}; -#define AKI_CLOSE_WRITE 0 +#define NNWT_CLOSE_WRITE 0 #endif #include "../loop.h" -struct aki_fs_event { +struct nn_fs_event { s32 fd; u32 mask; char *path; s32 wd; ev_io event; - struct aki_event_loop *loop; + struct nn_event_loop *loop; void (*callback)(void *, struct inotify_event *); void *userdata; }; -void aki_fs_event_init(struct aki_fs_event *fs, str *path, u32 mask, +void nn_fs_event_init(struct nn_fs_event *fs, str *path, u32 mask, void (*callback)(void *, struct inotify_event *), void *userdata); -bool aki_fs_event_start(struct aki_fs_event *fs, struct aki_event_loop *loop); -void aki_fs_event_stop(struct aki_fs_event *fs); -void aki_fs_event_free(struct aki_fs_event *fs); +bool nn_fs_event_start(struct nn_fs_event *fs, struct nn_event_loop *loop); +void nn_fs_event_stop(struct nn_fs_event *fs); +void nn_fs_event_free(struct nn_fs_event *fs); diff --git a/src/fs_event/fs_event_inotify.c b/src/fs_event/fs_event_inotify.c index 0c0dd01..c0862c7 100644 --- a/src/fs_event/fs_event_inotify.c +++ b/src/fs_event/fs_event_inotify.c @@ -8,22 +8,22 @@ static void event_callback(struct ev_loop *loop, ev_io *w, s32 revents) { (void)loop; - struct aki_fs_event *fs = (struct aki_fs_event *)w->data; + struct nn_fs_event *fs = (struct nn_fs_event *)w->data; (void)revents; + struct inotify_event event = { 0 }; - ssize_t ret = aki_read(fs->fd, &event, sizeof(struct inotify_event)); + ssize_t ret = nn_read(fs->fd, &event, sizeof(struct inotify_event)); if (ret == sizeof(struct inotify_event)) { - al_assert(event.wd == fs->wd); - al_assert(event.len == 0); + al_assert(event.wd == fs->wd && event.len == 0); fs->callback(fs->userdata, &event); } } -void aki_fs_event_init(struct aki_fs_event *fs, str *path, u32 mask, +void nn_fs_event_init(struct nn_fs_event *fs, str *path, u32 mask, void (*callback)(void *, struct inotify_event *), void *userdata) { fs->fd = inotify_init(); - aki_fd_set_blocking(fs->fd, true); + nn_fd_set_blocking(fs->fd, true); fs->path = al_str_to_c_str(path); fs->mask = mask; fs->callback = callback; @@ -32,25 +32,25 @@ void aki_fs_event_init(struct aki_fs_event *fs, str *path, u32 mask, ev_io_init(&fs->event, event_callback, fs->fd, EV_READ); } -bool aki_fs_event_start(struct aki_fs_event *fs, struct aki_event_loop *loop) +bool nn_fs_event_start(struct nn_fs_event *fs, struct nn_event_loop *loop) { fs->loop = loop; fs->wd = inotify_add_watch(fs->fd, fs->path, fs->mask); if (fs->wd == -1) { - al_log_error("fs_event", "inotify_add_watch(%s) failed (%s)", fs->path, aki_strerror(errno)); + al_log_error("fs_event", "inotify_add_watch(%s) failed (%s)", fs->path, nn_strerror(errno)); return false; } ev_io_start(fs->loop->ev, &fs->event); return true; } -void aki_fs_event_stop(struct aki_fs_event *fs) +void nn_fs_event_stop(struct nn_fs_event *fs) { inotify_rm_watch(fs->fd, fs->wd); ev_io_stop(fs->loop->ev, &fs->event); } -void aki_fs_event_free(struct aki_fs_event *fs) +void nn_fs_event_free(struct nn_fs_event *fs) { close(fs->fd); al_free(fs->path); |