yambar/module.c
Daniel Eklöf acdeff3b6e module: remove ready_fd
All modules are expected to handle a call to content() after having
been instantiated.

I.e. modules *cannot* even expect run() to have started running.
2019-01-13 15:25:39 +01:00

36 lines
703 B
C

#include "module.h"
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
struct module *
module_common_new(void)
{
struct module *mod = malloc(sizeof(*mod));
mod->bar = NULL;
mtx_init(&mod->lock, mtx_plain);
mod->private = NULL;
mod->destroy = &module_default_destroy;
/* No defaults for these; must be provided by implementation */
mod->run = NULL;
mod->content = NULL;
mod->refresh_in = NULL;
return mod;
}
void
module_default_destroy(struct module *mod)
{
mtx_destroy(&mod->lock);
free(mod);
}
struct exposable *
module_begin_expose(struct module *mod)
{
struct exposable *e = mod->content(mod);
e->begin_expose(e);
return e;
}