summaryrefslogtreecommitdiff
path: root/src/examples/helpertest
diff options
context:
space:
mode:
authorAndrew Shadura <andrew@shadura.me>2014-06-17 11:57:32 +0200
committerAndrew Shadura <andrew@shadura.me>2014-06-17 11:57:32 +0200
commitd1e7e16224c881ee3093658fe4cbf14db244cec7 (patch)
tree8850e7a55b4b1589a7a08e2364e9c12dad31962c /src/examples/helpertest
parent246fb6b81eef837f1269073255373bf0a3d5c27a (diff)
Update to the latest upstream snapshot
Diffstat (limited to 'src/examples/helpertest')
-rw-r--r--src/examples/helpertest/helpertest.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/examples/helpertest/helpertest.c b/src/examples/helpertest/helpertest.c
index 9106000..fde9b15 100644
--- a/src/examples/helpertest/helpertest.c
+++ b/src/examples/helpertest/helpertest.c
@@ -25,40 +25,44 @@
int helper_count = 0;
-void timer_oneshot(mowgli_eventloop_helper_proc_t *helper)
+void
+timer_oneshot(mowgli_eventloop_helper_proc_t *helper)
{
- mowgli_writef(helper->out_fd, "oneshot timer hit\n");
+ mowgli_writef(helper->fd, "oneshot timer hit\n");
}
-void timer_tick(mowgli_eventloop_helper_proc_t *helper)
+void
+timer_tick(mowgli_eventloop_helper_proc_t *helper)
{
static int ticks = 0;
- mowgli_writef(helper->out_fd, "tick: %d\n", ++ticks);
+ mowgli_writef(helper->fd, "tick: %d\n", ++ticks);
if (ticks > 10)
mowgli_eventloop_break(helper->eventloop);
}
-void helper_start(mowgli_eventloop_helper_proc_t *helper, void *userdata)
+void
+helper_start(mowgli_eventloop_helper_proc_t *helper, void *userdata)
{
mowgli_eventloop_t *eventloop = helper->eventloop;
- mowgli_writef(helper->out_fd, "hi from pid %d\n", getpid());
+ mowgli_writef(helper->fd, "hi from pid %d\n", getpid());
mowgli_timer_add(eventloop, "timer_tick", (mowgli_event_dispatch_func_t *) timer_tick, helper, 1);
mowgli_timer_add_once(eventloop, "timer_oneshot", (mowgli_event_dispatch_func_t *) timer_oneshot, helper, 5);
mowgli_eventloop_run(eventloop);
- mowgli_writef(helper->out_fd, "eventloop halted\n");
+ mowgli_writef(helper->fd, "eventloop halted\n");
mowgli_eventloop_destroy(eventloop);
}
void helper_read(mowgli_eventloop_t *eventloop, mowgli_eventloop_io_t *io, mowgli_eventloop_io_dir_t dir, void *userdata);
-void helper_spawn(mowgli_eventloop_t *eventloop)
+void
+helper_spawn(mowgli_eventloop_t *eventloop)
{
mowgli_eventloop_helper_proc_t *helper;
@@ -71,17 +75,20 @@ void helper_spawn(mowgli_eventloop_t *eventloop)
helper_count++;
}
-void helper_read(mowgli_eventloop_t *eventloop, mowgli_eventloop_io_t *io, mowgli_eventloop_io_dir_t dir, void *userdata)
+void
+helper_read(mowgli_eventloop_t *eventloop, mowgli_eventloop_io_t *io, mowgli_eventloop_io_dir_t dir, void *userdata)
{
size_t r;
char buf[16384];
mowgli_eventloop_helper_proc_t *helper = mowgli_eventloop_io_helper(io);
bzero(buf, sizeof buf);
- r = read(helper->in_fd, buf, sizeof buf);
+ r = read(helper->fd, buf, sizeof buf);
if (r > 0)
- printf("helper %p [%d/%d]: %s", helper, helper->child->pid, helper->in_fd, buf);
+ {
+ printf("helper %p [%d/%d]: %s", helper, helper->child->pid, helper->fd, buf);
+ }
else if (r <= 0)
{
helper_count--;
@@ -92,7 +99,8 @@ void helper_read(mowgli_eventloop_t *eventloop, mowgli_eventloop_io_t *io, mowgl
helper_spawn(eventloop);
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
mowgli_eventloop_t *base_eventloop;