Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
d68a1218
提交
d68a1218
authored
9月 02, 2010
作者:
Brian West
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FSCORE-662
上级
f8daa112
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
122 行增加
和
0 行删除
+122
-0
switch_loadable_module.h
src/include/switch_loadable_module.h
+19
-0
switch_types.h
src/include/switch_types.h
+2
-0
mod_commands.c
src/mod/applications/mod_commands/mod_commands.c
+3
-0
switch_console.c
src/switch_console.c
+42
-0
switch_loadable_module.c
src/switch_loadable_module.c
+56
-0
没有找到文件。
src/include/switch_loadable_module.h
浏览文件 @
d68a1218
...
...
@@ -120,6 +120,25 @@ SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_inte
*/
SWITCH_DECLARE
(
switch_dialplan_interface_t
*
)
switch_loadable_module_get_dialplan_interface
(
const
char
*
name
);
/*!
\brief Enumerates a list of all modules discovered in a directory
\param the directory to look for modules in
\param memory pool
\param callback function to call for each module found
\param user data argument to pass to the callback function
\return the resulting status
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_loadable_module_enumerate_available
(
const
char
*
dir_path
,
switch_modulename_callback_func_t
callback
,
void
*
user_data
);
/*!
\brief Enumerates a list of all currently loaded modules
\param callback function to call for each module found
\param user data argument to pass to the callback function
\return the resulting status
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_loadable_module_enumerate_loaded
(
switch_modulename_callback_func_t
callback
,
void
*
user_data
);
/*!
\brief build a dynamic module object and register it (for use in double embeded modules)
\param filename the name of the modules source file
...
...
src/include/switch_types.h
浏览文件 @
d68a1218
...
...
@@ -1731,6 +1731,8 @@ typedef struct switch_loadable_module_function_table {
switch_module_flag_t
flags
;
}
switch_loadable_module_function_table_t
;
typedef
int
(
*
switch_modulename_callback_func_t
)
(
void
*
user_data
,
const
char
*
module_name
);
#define SWITCH_MODULE_DEFINITION_EX(name, load, shutdown, runtime, flags) \
static const char modname[] = #name ; \
SWITCH_MOD_DECLARE_DATA switch_loadable_module_function_table_t name##_module_interface = { \
...
...
src/mod/applications/mod_commands/mod_commands.c
浏览文件 @
d68a1218
...
...
@@ -4651,9 +4651,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
switch_console_set_complete
(
"add fsctl flush_db_handles"
);
switch_console_set_complete
(
"add fsctl min_idle_cpu"
);
switch_console_set_complete
(
"add fsctl send_sighup"
);
switch_console_set_complete
(
"add load ::console::list_available_modules"
);
switch_console_set_complete
(
"add nat_map reinit"
);
switch_console_set_complete
(
"add nat_map republish"
);
switch_console_set_complete
(
"add nat_map status"
);
switch_console_set_complete
(
"add reload ::console::list_loaded_modules"
);
switch_console_set_complete
(
"add reloadacl reloadxml"
);
switch_console_set_complete
(
"add show aliases"
);
switch_console_set_complete
(
"add show api"
);
...
...
@@ -4678,6 +4680,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
switch_console_set_complete
(
"add show timer"
);
switch_console_set_complete
(
"add shutdown"
);
switch_console_set_complete
(
"add sql_escape"
);
switch_console_set_complete
(
"add unload ::console::list_loaded_modules"
);
switch_console_set_complete
(
"add uuid_audio ::console::list_uuid start read mute"
);
switch_console_set_complete
(
"add uuid_audio ::console::list_uuid start read level"
);
switch_console_set_complete
(
"add uuid_audio ::console::list_uuid start write mute"
);
...
...
src/switch_console.c
浏览文件 @
d68a1218
...
...
@@ -553,6 +553,46 @@ struct match_helper {
switch_console_callback_match_t
*
my_matches
;
};
static
int
modulename_callback
(
void
*
pArg
,
const
char
*
module_name
)
{
struct
match_helper
*
h
=
(
struct
match_helper
*
)
pArg
;
switch_console_push_match
(
&
h
->
my_matches
,
module_name
);
return
0
;
}
SWITCH_DECLARE_NONSTD
(
switch_status_t
)
switch_console_list_available_modules
(
const
char
*
line
,
const
char
*
cursor
,
switch_console_callback_match_t
**
matches
)
{
struct
match_helper
h
=
{
0
};
if
(
switch_loadable_module_enumerate_available
(
SWITCH_GLOBAL_dirs
.
mod_dir
,
modulename_callback
,
&
h
)
!=
SWITCH_STATUS_SUCCESS
)
{
return
SWITCH_STATUS_GENERR
;
}
if
(
h
.
my_matches
)
{
*
matches
=
h
.
my_matches
;
return
SWITCH_STATUS_SUCCESS
;
}
return
SWITCH_STATUS_FALSE
;
}
SWITCH_DECLARE_NONSTD
(
switch_status_t
)
switch_console_list_loaded_modules
(
const
char
*
line
,
const
char
*
cursor
,
switch_console_callback_match_t
**
matches
)
{
struct
match_helper
h
=
{
0
};
if
(
switch_loadable_module_enumerate_loaded
(
modulename_callback
,
&
h
)
!=
SWITCH_STATUS_SUCCESS
)
{
return
SWITCH_STATUS_GENERR
;
}
if
(
h
.
my_matches
)
{
*
matches
=
h
.
my_matches
;
return
SWITCH_STATUS_SUCCESS
;
}
return
SWITCH_STATUS_FALSE
;
}
static
int
uuid_callback
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
columnNames
)
{
struct
match_helper
*
h
=
(
struct
match_helper
*
)
pArg
;
...
...
@@ -1542,6 +1582,8 @@ SWITCH_DECLARE(switch_status_t) switch_console_init(switch_memory_pool_t *pool)
{
switch_mutex_init
(
&
globals
.
func_mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_core_hash_init
(
&
globals
.
func_hash
,
pool
);
switch_console_add_complete_func
(
"::console::list_available_modules"
,
(
switch_console_complete_callback_t
)
switch_console_list_available_modules
);
switch_console_add_complete_func
(
"::console::list_loaded_modules"
,
(
switch_console_complete_callback_t
)
switch_console_list_loaded_modules
);
switch_console_add_complete_func
(
"::console::list_uuid"
,
(
switch_console_complete_callback_t
)
switch_console_list_uuid
);
return
SWITCH_STATUS_SUCCESS
;
}
...
...
src/switch_loadable_module.c
浏览文件 @
d68a1218
...
...
@@ -1068,6 +1068,62 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_unload_module(char *dir,
}
SWITCH_DECLARE
(
switch_status_t
)
switch_loadable_module_enumerate_available
(
const
char
*
dir_path
,
switch_modulename_callback_func_t
callback
,
void
*
user_data
)
{
switch_dir_t
*
dir
=
NULL
;
switch_status_t
status
;
char
buffer
[
PATH_MAX
];
const
char
*
fname
;
const
char
*
fname_ext
;
char
*
fname_base
;
#ifdef WIN32
const
char
*
ext
=
".dll"
;
#else
const
char
*
ext
=
".so"
;
#endif
if
((
status
=
switch_dir_open
(
&
dir
,
dir_path
,
loadable_modules
.
pool
))
!=
SWITCH_STATUS_SUCCESS
)
{
return
status
;
}
while
((
fname
=
switch_dir_next_file
(
dir
,
buffer
,
sizeof
(
buffer
))))
{
if
((
fname_ext
=
strrchr
(
fname
,
'.'
)))
{
if
(
!
strcmp
(
fname_ext
,
ext
))
{
if
(
!
(
fname_base
=
switch_mprintf
(
"%.*s"
,
(
int
)(
fname_ext
-
fname
),
fname
)))
{
status
=
SWITCH_STATUS_GENERR
;
goto
end
;
}
callback
(
user_data
,
fname_base
);
switch_safe_free
(
fname_base
)
}
}
}
end
:
switch_dir_close
(
dir
);
return
status
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_loadable_module_enumerate_loaded
(
switch_modulename_callback_func_t
callback
,
void
*
user_data
)
{
switch_hash_index_t
*
hi
;
void
*
val
;
switch_loadable_module_t
*
module
;
switch_mutex_lock
(
loadable_modules
.
mutex
);
for
(
hi
=
switch_hash_first
(
NULL
,
loadable_modules
.
module_hash
);
hi
;
hi
=
switch_hash_next
(
hi
))
{
switch_hash_this
(
hi
,
NULL
,
NULL
,
&
val
);
module
=
(
switch_loadable_module_t
*
)
val
;
callback
(
user_data
,
module
->
module_interface
->
module_name
);
}
switch_mutex_unlock
(
loadable_modules
.
mutex
);
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_loadable_module_build_dynamic
(
char
*
filename
,
switch_module_load_t
switch_module_load
,
switch_module_runtime_t
switch_module_runtime
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论