summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorniubinghui <[email protected]>2024-08-06 10:12:56 +0800
committerniubinghui <[email protected]>2024-08-06 10:12:56 +0800
commit4f7a98d2ddc8f25d04dc89bce080dcb508293688 (patch)
tree3da99efaa66db7267f15318767b4f8c71a253b4a
parentc637bb388a8fceb8b263451c174931415ee79a81 (diff)
【修改】修改外部接口,对外仅暴露创建和退出两个接口
-rw-r--r--include/lua_plugin_manage.h135
1 files changed, 12 insertions, 123 deletions
diff --git a/include/lua_plugin_manage.h b/include/lua_plugin_manage.h
index f38b7d5..3801922 100644
--- a/include/lua_plugin_manage.h
+++ b/include/lua_plugin_manage.h
@@ -1,136 +1,25 @@
/*************************************************************************
> File Name: lua_plugin_manage.h
- > Author:
- > Created Time: 2024-07
+ > Author:
+ > Created Time: 2024-08
> Encoding : UTF-8
************************************************************************/
/*************************************************************************
* version
* [ v0.1 ]
- * 07-31
- * 1. 新增数据结构
- * enum LPM_DATATYPE
- * struct lpm_cdata
- * struct lpm_ctable
- * typedef int (*lpm_cbinding_function)(struct lpm_state *)
- * 2. 新增接口函数
- * lpm_cdata_clean
- * lpm_state_instance_create
- * lpm_state_instance_free
- * lpm_state_instance_init
- * lpm_cbinding_get_params_count
- * lpm_cbinding_get_params
- * lpm_cbinding_push_return
- * lpm_cbinding_function_register
- * lpm_cbinding_function_remove
- * lpm_cdata_register
- * lpm_cdata_remove
- * lpm_plugin_load
- * lpm_plugin_unload
- * lpm_ctx_new_func
- * lpm_ctx_free_func
- * lpm_on_session_msg_func
- * lpm_trans_data_luatoc
- * lpm_trans_data_ctolua
+ * 08-01
+ * 1. 修改外部暴露接口
+ * lua_plugin_manage_init
+ * lua_plugin_manage_exit
+ * 2. 声明数据结构
+ * struct lua_plugin_manage_schema
************************************************************************/
-#ifndef LUA_PLUGIN_MANAGE_INCLUDE_H
-#define LUA_PLUGIN_MANAGE_INCLUDE_H
+#pragma once
#include "stellar.h"
-struct lpm_state;
+struct lua_plugin_manage_schema;
-enum LPM_DATATYPE
-{
- LPM_DATATYPE_NULL = 0,
- LPM_DATATYPE_NIL,
- LPM_DATATYPE_BOOL,
- LPM_DATATYPE_NUM,
- LPM_DATATYPE_INT,
- LPM_DATATYPE_CSTRING,
- LPM_DATATYPE_CTABLE,
- LPM_DATATYPE_CUSER,
- LPM_DATATYPE_CONTEXT,
- LPM_DATATYPE_END
-};
-
-struct lpm_cdata;
-struct lpm_ctable;
-
-struct lpm_cdata {
- enum LPM_DATATYPE data_type;
- int data_length;
- union {
- int data_bool;
- double data_num;
- int data_int;
- char * data_string;
- struct lpm_ctable * data_table;
- void * data_user;
- void * data_context;
- };
-};
-
-void lpm_cdata_clean(struct lpm_cdata * data);
-
-/* 创建一个lua plugin manage状态机实例 */
-/* return lpm_state instance */
-struct lpm_state * lpm_state_instance_create(void);
-/* 释放一个lua plugin manage状态机实例 */
-/* 在plugin_manager使用过程中应该将所有已经加载的插件卸载后再调用此函数 */
-/* return 0 - success, other - failed */
-int lpm_state_instance_free(struct lpm_state * state);
-/* 根据一个配置文件加载所有配置需要加载的插件 */
-/* return 0 - success, other - failed */
-int lpm_state_instance_init(struct stellar * st, struct lpm_state * state, const char * filename);
-
-/* 可以注册至lua状态机实例中的C函数原型 */
-/* return 1 - lua调用完成后需要处理返回值, 0 - lua调用完后不需要处理返回值 */
-typedef int (*lpm_cbinding_function)(struct lpm_state *);
-
-/* 供注册的C函数使用 */
-/* 获取传入的参数数量 */
-/* return 参数数量 */
-int lpm_cbinding_get_params_count(struct lpm_state * state);
-/* 获取传入的参数, index为参数的下标, 多个参数只能逐个获取 */
-/* return 0 - success, other - failed */
-int lpm_cbinding_get_params(struct lpm_state * state, int index, struct lpm_cdata * data);
-/* 将返回值传入lua, count为返回值数量, data为数据的数组 */
-/* return 0 - success, other - failed */
-int lpm_cbinding_push_return(struct lpm_state * state, int count, struct lpm_cdata * data);
-
-/* 注册一个C函数function至lua中, 调用方式为space_name.func_name格式, space_name可以为空 */
-/* return 0 - success, other - failed */
-int lpm_cbinding_function_register(struct lpm_state * state, lpm_cbinding_function function, const char * func_name, const char * space_name);
-/* 将一个已经注册的function从lua中移除 */
-/* return 0 - success, other - failed */
-int lpm_cbinding_function_remove(struct lpm_state * state, const char * func_name, const char * space_name);
-
-/* 将一个数据注册至lua中, 作为lua中的全局变量使用 */
-/* return 0 - success, other - failed */
-int lpm_cdata_register(struct lpm_state * state, struct lpm_cdata * data, const char * data_name, const char * space_name);
-/* 将一个全局变量从lua中移除 */
-/* return 0 - success, other - failed */
-int lpm_cdata_remove(struct lpm_state * state, const char * data_name, const char * space_name);
-
-/*
-解决方案:
-1. 在stellar或状态机中新增一个列表, 调用该函数时每次按顺序从列表中取一个进行调用, 加载完成后每次从列表中删除一个结点
-2. 增加一个参数, 函数原型修改为
-void * lpm_plugin_load(struct stellar * st, int id)
-*/
-void * lpm_plugin_load(struct stellar * st);
-void lpm_plugin_unload(void * plugin_env);
-
-void * lpm_ctx_new_func(struct session * sess, void * plugin_env);
-void lpm_ctx_free_func(struct session * sess, void * sess_ctx, void * plugin_env);
-
-void lpm_on_session_msg_func(struct session * sess, int topic_id, const void * msg, void * sess_ctx, void * plugin_env);
-
-/* 将lua栈顶的一个数据转为一个lpm_cdata结构的数据 */
-int lpm_trans_data_luatoc(struct lpm_state * state, struct lpm_cdata * data);
-/* 将一个lpm_cdata结构的数据转为一个lua数据并入栈至栈顶 */
-int lpm_trans_data_ctolua(struct lpm_state * state, struct lpm_cdata * data);
-
-#endif \ No newline at end of file
+struct lua_plugin_manage_schema * lua_plugin_manage_init(struct stellar * st, const char * config_file_path);
+void lua_plugin_manage_exit(struct lua_plugin_manage_schema * lua_plug_mgr); \ No newline at end of file