105 lines
2.7 KiB
C
105 lines
2.7 KiB
C
#include <Void/Plugin/CAbi.h>
|
|
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#ifndef DEP_MODE
|
|
#define DEP_MODE 1
|
|
#endif
|
|
|
|
struct void_module_handle {
|
|
int dummy;
|
|
};
|
|
|
|
#if DEP_MODE == 2
|
|
static const void_dependency_v1 kDeps[] = {
|
|
{.module_id = "cabi.dep.a", .version_range = "^1.0.0", .optional_dep = 0},
|
|
};
|
|
#elif DEP_MODE == 3
|
|
static const void_dependency_v1 kDeps[] = {
|
|
{.module_id = "cabi.cyc.b", .version_range = "^1.0.0", .optional_dep = 0},
|
|
};
|
|
#elif DEP_MODE == 4
|
|
static const void_dependency_v1 kDeps[] = {
|
|
{.module_id = "cabi.cyc.a", .version_range = "^1.0.0", .optional_dep = 0},
|
|
};
|
|
#endif
|
|
|
|
static int32_t dep_get_info(void_module_info_v1* out)
|
|
{
|
|
if (out == NULL) return VOID_STATUS_INVALID_ARGUMENT;
|
|
memset(out, 0, sizeof(*out));
|
|
out->struct_size = (uint32_t)sizeof(void_module_info_v1);
|
|
#if DEP_MODE == 1
|
|
out->module_id = "cabi.dep.a";
|
|
out->version = "1.0.0";
|
|
out->activation_policy = VOID_POLICY_RESTART_REQUIRED;
|
|
#elif DEP_MODE == 2
|
|
out->module_id = "cabi.dep.b";
|
|
out->version = "1.0.0";
|
|
out->activation_policy = VOID_POLICY_RELOADABLE;
|
|
out->dependencies = kDeps;
|
|
out->dependency_count = 1u;
|
|
#elif DEP_MODE == 3
|
|
out->module_id = "cabi.cyc.a";
|
|
out->version = "1.0.0";
|
|
out->dependencies = kDeps;
|
|
out->dependency_count = 1u;
|
|
#elif DEP_MODE == 4
|
|
out->module_id = "cabi.cyc.b";
|
|
out->version = "1.0.0";
|
|
out->dependencies = kDeps;
|
|
out->dependency_count = 1u;
|
|
#endif
|
|
return VOID_STATUS_OK;
|
|
}
|
|
|
|
static int32_t dep_create(const void_host_api_v1* h, void_module_handle** out)
|
|
{
|
|
(void)h;
|
|
*out = (struct void_module_handle*)calloc(1, sizeof(struct void_module_handle));
|
|
return *out ? VOID_STATUS_OK : VOID_STATUS_EXHAUSTED;
|
|
}
|
|
|
|
static int32_t dep_activate(void_module_handle* h, void_bytes_v1 c, void_error_detail_v1* e)
|
|
{
|
|
(void)h; (void)c; (void)e;
|
|
return VOID_STATUS_OK;
|
|
}
|
|
|
|
static int32_t dep_readiness(void_module_handle* h, uint32_t* r, void_error_detail_v1* e)
|
|
{
|
|
(void)h; (void)e;
|
|
*r = 1u;
|
|
return VOID_STATUS_OK;
|
|
}
|
|
|
|
static int32_t dep_stop(void_module_handle* h)
|
|
{
|
|
(void)h;
|
|
return VOID_STATUS_OK;
|
|
}
|
|
|
|
static void dep_destroy(void_module_handle* h) { free(h); }
|
|
|
|
int32_t void_module_query_v1(uint32_t host_struct_size,
|
|
void_module_api_v1* out_api)
|
|
{
|
|
if (out_api == NULL || host_struct_size < VOID_MODULE_API_V1_MIN_SIZE) {
|
|
return VOID_STATUS_INVALID_ARGUMENT;
|
|
}
|
|
memset(out_api, 0, sizeof(*out_api));
|
|
out_api->struct_size = (uint32_t)sizeof(void_module_api_v1);
|
|
out_api->abi_major = VOID_CABI_MAJOR_V1;
|
|
out_api->abi_minor = VOID_CABI_MINOR_V1;
|
|
out_api->get_info = dep_get_info;
|
|
out_api->create = dep_create;
|
|
out_api->activate = dep_activate;
|
|
out_api->readiness = dep_readiness;
|
|
out_api->request_stop = dep_stop;
|
|
out_api->deactivate = dep_stop;
|
|
out_api->destroy = dep_destroy;
|
|
return VOID_STATUS_OK;
|
|
}
|