Files
libuev/tests/api.c
T
Joachim Nilsson 99ef6eb884 Remove __attribute__ ((unused)), use -Wno-unused-parameter instead
The __attribute__ ((unused)) is useful sometimes to declare variables as
intended to be unused, e.g. in callback functions.  However, they tend
to clutter up the code making hard to read.  We therefore remove all
uses of it and instead set -Wno-unused-parameter.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-25 23:19:02 +02:00

35 lines
563 B
C

#include "check.h"
uev_t timer, file;
int counter = 10;
static void cb(uev_t *w, void *arg, int events)
{
if (UEV_ERROR == events)
fprintf(stderr, "timer watcher failed, ignoring ...\n");
if (counter--)
return;
uev_exit(w->ctx);
}
int main(void)
{
uev_ctx_t ctx;
FILE *fp;
uev_init(&ctx);
uev_timer_init(&ctx, &timer, cb, NULL, 100, 100);
fp = fopen("/dev/one", "r");
if (fp)
uev_io_init(&ctx, &file, cb, NULL, fileno(fp), UEV_READ);
uev_run(&ctx, 0);
uev_exit(&ctx); /* Should not hang event loop, troglobit/uftpd#16 */
return 0;
}