summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authoryangwei <[email protected]>2024-11-05 09:39:10 +0800
committeryangwei <[email protected]>2024-11-05 10:22:22 +0800
commit7f81e465226e60caa516ae82556c9411339e77cd (patch)
tree550872b92d7ac79f8dc9175fe12d42c167a62fc0 /decoders
parenta4157944287874d60378e4e48b9415eb44f0b0e2 (diff)
🦄 refactor(stellar_module to module): simplify stellar module to module
Diffstat (limited to 'decoders')
-rw-r--r--decoders/appid/appid.c14
-rw-r--r--decoders/lpi_plus/lpi_plus.h5
-rw-r--r--decoders/lpi_plus/lpip_module.c27
3 files changed, 23 insertions, 23 deletions
diff --git a/decoders/appid/appid.c b/decoders/appid/appid.c
index 642e8e6..6182dd8 100644
--- a/decoders/appid/appid.c
+++ b/decoders/appid/appid.c
@@ -25,25 +25,25 @@ static void stellar_appid_on_msg_dispatch(int topic_id __unused,
appid_cb(appid_msg->sess, appid_msg->origin, appid_msg->appid, appid_msg->appid_num, on_msg_cb_arg);
}
-int stellar_appid_subscribe(struct stellar_module_manager *mod_mgr, on_appid_callback *cb, void *args)
+int stellar_appid_subscribe(struct module_manager *mod_mgr, on_appid_callback *cb, void *args)
{
if(mod_mgr==NULL)return -1;
- int appid_topic_id=mq_schema_get_topic_id(stellar_module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC);
+ int appid_topic_id=mq_schema_get_topic_id(module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC);
if(appid_topic_id<0)
{
- appid_topic_id=mq_schema_create_topic(stellar_module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC, stellar_appid_on_msg_dispatch, mod_mgr, appid_message_free, NULL);
+ appid_topic_id=mq_schema_create_topic(module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC, stellar_appid_on_msg_dispatch, mod_mgr, appid_message_free, NULL);
}
- return mq_schema_subscribe(stellar_module_manager_get_mq_schema(mod_mgr), appid_topic_id, (on_msg_cb_func *)cb, args);
+ return mq_schema_subscribe(module_manager_get_mq_schema(mod_mgr), appid_topic_id, (on_msg_cb_func *)cb, args);
}
#pragma GCC diagnostic pop
-int stellar_appid_create_topic(struct stellar_module_manager *mod_mgr)
+int stellar_appid_create_topic(struct module_manager *mod_mgr)
{
- int app_topic_id=mq_schema_get_topic_id(stellar_module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC);
+ int app_topic_id=mq_schema_get_topic_id(module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC);
if(app_topic_id < 0)
{
- app_topic_id=mq_schema_create_topic(stellar_module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC, stellar_appid_on_msg_dispatch, NULL,appid_message_free, NULL);
+ app_topic_id=mq_schema_create_topic(module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC, stellar_appid_on_msg_dispatch, NULL,appid_message_free, NULL);
}
return app_topic_id;
} \ No newline at end of file
diff --git a/decoders/lpi_plus/lpi_plus.h b/decoders/lpi_plus/lpi_plus.h
index 72844d2..cb55a5f 100644
--- a/decoders/lpi_plus/lpi_plus.h
+++ b/decoders/lpi_plus/lpi_plus.h
@@ -1,6 +1,7 @@
#pragma once
-#include "stellar/module_manager.h"
+#include "stellar/module.h"
+#define LPI_PLUS_MODULE_NAME "LPI_PLUS"
struct lpi_plus_mapper;
-struct lpi_plus_mapper *stellar_module_get_lpip(struct stellar_module_manager *mod_mgr);
+struct lpi_plus_mapper *module_to_lpip_mapper(struct module *mod);
const char *lpi_plus_appid2name(struct lpi_plus_mapper *mapper, int appid); \ No newline at end of file
diff --git a/decoders/lpi_plus/lpip_module.c b/decoders/lpi_plus/lpip_module.c
index df0e991..5fd4aa4 100644
--- a/decoders/lpi_plus/lpip_module.c
+++ b/decoders/lpi_plus/lpip_module.c
@@ -45,7 +45,7 @@ struct lpi_plus_env
unsigned int max_pkts;
int lpip_session_exdata_idx;
int topic_appid;
- struct stellar_module_manager *mod_mgr;
+ struct module_manager *mod_mgr;
struct lpi_plus_mapper *mapper;
};
@@ -312,7 +312,7 @@ static void lpi_plus_on_session(struct session *sess, enum session_state state,
if(appid>0 && lpi_plus_appid_update(exdata->appid, &(exdata->appid_num), appid))
{
struct appid_message *msg=lpi_plus_message_new(sess, exdata->appid, exdata->appid_num);
- if(0 > mq_runtime_publish_message(stellar_module_manager_get_mq_runtime(env->mod_mgr),
+ if(0 > mq_runtime_publish_message(module_manager_get_mq_runtime(env->mod_mgr),
env->topic_appid,
msg))FREE(msg);
}
@@ -326,30 +326,30 @@ static void lpi_plus_exdata_free(int idx __unused, void *ex_ptr, void *arg __unu
FREE(ex_ptr);
}
-void lpi_plus_exit(struct stellar_module_manager *mod_mgr, struct stellar_module *mod)
+void lpi_plus_exit(struct module_manager *mod_mgr, struct module *mod)
{
if(mod_mgr==NULL)return;
if(mod)
{
- struct lpi_plus_env *env=(struct lpi_plus_env *)stellar_module_get_ctx(mod);
+ struct lpi_plus_env *env=(struct lpi_plus_env *)module_get_ctx(mod);
lpi_free_library();
lpi_plus_mapper_free(env->mapper);
FREE(env);
- stellar_module_free(mod);
+ module_free(mod);
}
}
-struct stellar_module *lpi_plus_init(struct stellar_module_manager *mod_mgr)
+struct module *lpi_plus_init(struct module_manager *mod_mgr)
{
if(mod_mgr==NULL)return NULL;
struct lpi_plus_env *env=CALLOC(struct lpi_plus_env, 1);
- struct stellar_module *mod=stellar_module_new("LPI_PLUS", env);
+ struct module *mod=module_new("LPI_PLUS", env);
env->mod_mgr=mod_mgr;
env->max_pkts=16;//TODO: load from toml
-
- struct session_manager *sess_mgr=stellar_module_get_session_manager(mod_mgr);
- struct mq_schema *mq_s=stellar_module_manager_get_mq_schema(mod_mgr);
+ struct module *sess_mgr_mod=module_manager_get_module(mod_mgr, SESSION_MANAGER_MODULE_NAME);
+ struct session_manager *sess_mgr=module_to_session_manager(sess_mgr_mod);
+ struct mq_schema *mq_s=module_manager_get_mq_schema(mod_mgr);
if(sess_mgr==NULL || mq_s==NULL)
{
@@ -385,12 +385,11 @@ INIT_ERROR:
}
-struct lpi_plus_mapper *stellar_module_get_lpip(struct stellar_module_manager *mod_mgr)
+struct lpi_plus_mapper *module_to_lpip_mapper(struct module *mod)
{
- if(mod_mgr==NULL)return NULL;
- struct stellar_module *mod=stellar_module_manager_get_module(mod_mgr, "LPI_PLUS");
if(mod==NULL)return NULL;
- struct lpi_plus_env *lpi_p=(struct lpi_plus_env *)stellar_module_get_ctx(mod);
+ assert(strcmp(module_get_name(mod), LPI_PLUS_MODULE_NAME) == 0);
+ struct lpi_plus_env *lpi_p=(struct lpi_plus_env *)module_get_ctx(mod);
if(lpi_p==NULL)return NULL;
return lpi_p->mapper;
} \ No newline at end of file