-
Notifications
You must be signed in to change notification settings - Fork 0
mod_logic_c
Category: Logic & Scripting | Version: v1.0.0 | Source: modules/mod_logic_c/mod_logic_c.c
C scripting engine. Compiles .c files with gcc at load time, produces .so, and dlopens them. Native speed with hot-reload capability. Uses portal.h directly.
#define LOGIC_C_MAX_APPS 32typedef int (*app_load_fn)(portal_core_t *core);
typedef int (*app_unload_fn)(portal_core_t *core);
typedef int (*app_handle_fn)(portal_core_t *core,
const portal_msg_t *msg,
portal_resp_t *resp);// /var/lib/portal/apps/fast_handler/main.c
#include "portal/portal.h"
static portal_core_t *g_core = NULL;
int app_load(portal_core_t *core) {
g_core = core;
core->route_add(core, "/myapp/fast", "fast_handler");
core->log(core, LOG_INFO, "fast_handler loaded");
return 0;
}
int app_handle(portal_core_t *core,
const portal_msg_t *msg,
portal_resp_t *resp) {
resp->status = 200;
snprintf(resp->body, sizeof(resp->body), "Fast C handler: %s", msg->path);
return 0;
}
int app_unload(portal_core_t *core) {
core->log(core, LOG_INFO, "fast_handler unloaded");
return 0;
}- Native speed: Compiled C, zero overhead
- Hot-reload: Recompile + dlopen on reload
- Direct API: Uses portal_core_t function pointers directly
- Compile errors: Reported as load failures with gcc output
Top Level System — GPL-2.0 | Website | Repository
mod_cli · mod_web · mod_node · mod_ssh · mod_config_sqlite · mod_config_psql
mod_cache · mod_kv · mod_shm · mod_queue · mod_websocket · mod_mqtt · mod_email · mod_file
mod_logic · mod_logic_lua · mod_logic_python · mod_logic_c · mod_logic_pascal
mod_metrics · mod_health · mod_sysinfo · mod_process · mod_log · mod_audit · mod_cron · mod_scheduler · mod_worker · mod_backup
mod_proxy · mod_dns · mod_http_client · mod_webhook · mod_api_gateway · mod_tunnel · mod_acme
mod_firewall · mod_crypto · mod_ldap · mod_validator
mod_iot · mod_gpio · mod_serial
mod_xz · mod_gzip · mod_template · mod_admin