aisl-sdk/mods/module.c

56 lines
1.2 KiB
C
Raw Normal View History

/******************************************************************************
*
* Copyright (c) 2017-2019 by Löwenware Ltd
* Please, refer LICENSE file for legal information
*
******************************************************************************/
/**
* @file interface.c
* @author Ilja Kartašov <ik@lowenware.com>
* @brief Interface source file for AISL SDK modules
*
* @see https://lowenware.com/
*/
#include <stdlib.h>
#include <string.h>
#include <components/log.h>
#include "module.h"
#include "context.h"
AislStatus
ax_module_on_event(AxModule mod, const struct aisl_evt *evt)
{
AxContext ctx;
struct aisl_evt_open *so_evt;
switch(evt->code)
{
case AISL_EVENT_STREAM_OPEN:
so_evt = (struct aisl_evt_open *)evt;
if (strncmp(so_evt->path, mod->end_point, mod->ep_length))
return AISL_IDLE;
break;
case AISL_EVENT_STREAM_HEADER:
case AISL_EVENT_STREAM_INPUT:
case AISL_EVENT_STREAM_REQUEST:
case AISL_EVENT_STREAM_OUTPUT:
case AISL_EVENT_STREAM_CLOSE:
if (!(ctx = aisl_get_context((AislStream)evt->source)))
return AISL_SUCCESS;
if (ctx->mod == mod)
break;
/* go through default */
default:
return AISL_IDLE;
}
return mod->on_event(mod, evt);
}