Get rid of all global variables

This commit is contained in:
Utkarsh Verma
2023-10-25 20:00:08 +05:30
parent bc84d094cd
commit 10f7d9b8db
13 changed files with 121 additions and 69 deletions

View File

@@ -3,11 +3,11 @@
#include <stdbool.h>
#include <sys/poll.h>
#include "block.h"
#include "main.h"
#include "util.h"
typedef enum {
SIGNAL_FD = LEN(blocks),
SIGNAL_FD = BLOCK_COUNT,
WATCHER_FD_COUNT,
} watcher_fd_index;
@@ -15,8 +15,13 @@ typedef struct pollfd watcher_fd;
typedef struct {
watcher_fd fds[WATCHER_FD_COUNT];
const block *const blocks;
const unsigned short block_count;
} watcher;
watcher watcher_new(const block *const blocks,
const unsigned short block_count);
int watcher_init(watcher *const watcher, const int signal_fd);
int watcher_poll(watcher *const watcher, const int timeout_ms);
bool watcher_fd_is_readable(const watcher_fd *const watcher_fd);