mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 13:45:10 +00:00
42 lines
844 B
C
42 lines
844 B
C
#include <Parsee.h>
|
|
|
|
#include <Cytoplasm/Memory.h>
|
|
#include <Cytoplasm/Log.h>
|
|
|
|
#include <Routes.h>
|
|
|
|
ParseeData *
|
|
ParseeInitData(void)
|
|
{
|
|
ParseeData *data;
|
|
if (!ParseeConfigGet())
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
data = Malloc(sizeof(*data));
|
|
data->config = ParseeConfigGet();
|
|
data->router = HttpRouterCreate();
|
|
|
|
#define X_ROUTE(path, func) do {\
|
|
if (!HttpRouterAdd(data->router, path, func))\
|
|
{\
|
|
Log(LOG_ERR, "Can't register %s", path);\
|
|
}\
|
|
}\
|
|
while (0);
|
|
ROUTES
|
|
#undef X_ROUTE
|
|
return data;
|
|
}
|
|
void
|
|
ParseeFreeData(ParseeData *data)
|
|
{
|
|
if (!data)
|
|
{
|
|
return;
|
|
}
|
|
|
|
HttpRouterFree(data->router);
|
|
Free(data);
|
|
}
|