Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
6b6198e9
提交
6b6198e9
authored
1月 22, 2013
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-5027
上级
b9a8ce56
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
32 行增加
和
34 行删除
+32
-34
freeswitch_lua.cpp
src/mod/languages/mod_lua/freeswitch_lua.cpp
+32
-34
没有找到文件。
src/mod/languages/mod_lua/freeswitch_lua.cpp
浏览文件 @
6b6198e9
...
...
@@ -331,61 +331,53 @@ switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t ityp
return
SWITCH_STATUS_SUCCESS
;
}
Dbh
::
Dbh
(
char
*
dsn
,
char
*
user
,
char
*
pass
)
{
switch_cache_db_connection_options_t
options
=
{
{
0
}
};
const
char
*
prefix
=
"core:"
;
switch_cache_db_handle_type_t
type
;
m_connected
=
false
;
if
(
strstr
(
dsn
,
prefix
)
==
dsn
)
{
options
.
core_db_options
.
db_path
=
&
dsn
[
strlen
(
prefix
)];
if
(
switch_cache_db_get_db_handle
(
&
dbh
,
SCDB_TYPE_CORE_DB
,
&
options
)
==
SWITCH_STATUS_SUCCESS
)
{
m_connected
=
true
;
}
}
else
if
(
!
strncasecmp
(
dsn
,
"pgsql://"
,
8
))
{
type
=
SCDB_TYPE_PGSQL
;
options
.
pgsql_options
.
dsn
=
(
char
*
)(
dsn
+
8
);
if
(
switch_cache_db_get_db_handle
(
&
dbh
,
SCDB_TYPE_PGSQL
,
&
options
)
==
SWITCH_STATUS_SUCCESS
)
{
m_connected
=
true
;
}
}
else
{
options
.
odbc_options
.
dsn
=
dsn
;
options
.
odbc_options
.
user
=
user
;
options
.
odbc_options
.
pass
=
pass
;
if
(
switch_cache_db_get_db_handle
(
&
dbh
,
SCDB_TYPE_ODBC
,
&
options
)
==
SWITCH_STATUS_SUCCESS
)
{
m_connected
=
true
;
}
}
dbh
=
NULL
;
if
(
!
zstr
(
user
)
||
!
zstr
(
pass
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"user and pass params have been removed. Please specify the user and pass in the DSN.
\n
"
);
}
if
(
switch_cache_db_get_db_handle_dsn
(
&
dbh
,
dsn
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"DBH handle %p Connected.
\n
"
,
(
void
*
)
dbh
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Connection failed. DBH NOT Connected.
\n
"
);
}
}
Dbh
::~
Dbh
()
{
release
();
if
(
dbh
)
release
();
}
bool
Dbh
::
release
()
{
if
(
m_connected
)
{
switch_cache_db_release_db_handle
(
&
dbh
);
m_connected
=
false
;
return
true
;
if
(
dbh
)
{
switch_cache_db_release_db_handle
(
&
dbh
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"DBH handle %p released.
\n
"
,
(
void
*
)
dbh
)
;
return
true
;
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"DBH NOT Connected.
\n
"
);
return
false
;
}
bool
Dbh
::
connected
()
{
return
m_connected
;
return
dbh
?
true
:
false
;
}
bool
Dbh
::
test_reactive
(
char
*
test_sql
,
char
*
drop_sql
,
char
*
reactive_sql
)
{
if
(
m_connected
)
{
if
(
dbh
)
{
if
(
switch_cache_db_test_reactive
(
dbh
,
test_sql
,
drop_sql
,
reactive_sql
)
==
SWITCH_TRUE
)
{
return
true
;
}
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"DBH NOT Connected.
\n
"
);
return
false
;
}
...
...
@@ -417,7 +409,7 @@ int Dbh::query_callback(void *pArg, int argc, char **argv, char **cargv)
bool
Dbh
::
query
(
char
*
sql
,
SWIGLUA_FN
lua_fun
)
{
if
(
m_connected
)
{
if
(
dbh
)
{
if
(
lua_fun
.
L
)
{
if
(
switch_cache_db_execute_sql_callback
(
dbh
,
sql
,
query_callback
,
&
lua_fun
,
NULL
)
==
SWITCH_STATUS_SUCCESS
)
{
return
true
;
...
...
@@ -428,21 +420,27 @@ bool Dbh::query(char *sql, SWIGLUA_FN lua_fun)
}
}
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"DBH NOT Connected.
\n
"
);
return
false
;
}
int
Dbh
::
affected_rows
()
{
if
(
m_connected
)
{
if
(
dbh
)
{
return
switch_cache_db_affected_rows
(
dbh
);
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"DBH NOT Connected.
\n
"
);
return
0
;
}
int
Dbh
::
load_extension
(
const
char
*
extension
)
{
if
(
m_connected
)
{
if
(
dbh
)
{
return
switch_cache_db_load_extension
(
dbh
,
extension
);
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"DBH NOT Connected.
\n
"
);
return
0
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论