diff options
-rw-r--r-- | include/libumumble.h | 34 | ||||
-rw-r--r-- | src/ctx.c | 15 |
2 files changed, 49 insertions, 0 deletions
diff --git a/include/libumumble.h b/include/libumumble.h new file mode 100644 index 0000000..2605688 --- /dev/null +++ b/include/libumumble.h @@ -0,0 +1,34 @@ +#ifndef LIBUMUMBLE_H +#define LIBUMUMBLE_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <uv.h> + +typedef struct mumble_ctx { + uv_loop_t uv_loop; +} mumble_ctx_t; + +/* Initializes a mumble context object. + * This function will allocate initial memory needed for storing e.g. the channel layout. + * Make sure to call mumble_free_ctx() when you're done! + * + * \param ctx the context object to initialize. + * \return int indicating success + * \retval 1 error + */ +int mumble_init_ctx(mumble_ctx_t ctx); + +/* Free a mumble context. + * + * \param ctx the context object to free. + */ +void mumble_free_ctx(mumble_ctx_t ctx); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LIBUMUMBLE_H */ diff --git a/src/ctx.c b/src/ctx.c new file mode 100644 index 0000000..efa9101 --- /dev/null +++ b/src/ctx.c @@ -0,0 +1,15 @@ +#include <libumumble.h> +#include <uv.h> + +int mumble_init_ctx(mumble_ctx_t ctx) +{ + int result; + + result = uv_loop_init(&ctx.uv_loop); + return result; +} + +void mumble_free_ctx(mumble_ctx_t ctx) +{ + uv_loop_close(&ctx.uv_loop); +} |