Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
26f2e095
提交
26f2e095
authored
9月 07, 2010
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MODLANG-174
上级
68d1c32a
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
132 行增加
和
17 行删除
+132
-17
freeswitch.i
src/mod/languages/mod_lua/freeswitch.i
+17
-3
freeswitch_lua.cpp
src/mod/languages/mod_lua/freeswitch_lua.cpp
+66
-0
freeswitch_lua.h
src/mod/languages/mod_lua/freeswitch_lua.h
+22
-0
hack.diff
src/mod/languages/mod_lua/hack.diff
+14
-14
my_swigable_cpp.h
src/mod/languages/mod_lua/my_swigable_cpp.h
+13
-0
没有找到文件。
src/mod/languages/mod_lua/freeswitch.i
浏览文件 @
26f2e095
...
...
@@ -18,6 +18,10 @@
%}
/* Lua function typemap */
%typemap(in,checkfn="lua_isfunction") SWIGLUA_FN
%{ $1.L=L; $1.idx=$input; %}
%ignore SwitchToMempool;
%newobject EventConsumer::pop;
...
...
@@ -25,6 +29,7 @@
%newobject CoreSession;
%newobject Event;
%newobject Stream;
%newobject Dbh;
/**
* tell swig to grok everything defined in these header files and
...
...
@@ -66,9 +71,18 @@ class Session : public CoreSession {
void setLUA(lua_State *state);
};
}
class Dbh {
private:
switch_cache_db_handle_t *dbh;
bool connected;
static int query_callback(void *pArg, int argc, char **argv, char **cargv);
public:
Dbh(char *dsn, char *user = NULL, char *pass = NULL);
~Dbh();
bool release();
bool query(char *sql, SWIGLUA_FN lua_fun);
};
}
src/mod/languages/mod_lua/freeswitch_lua.cpp
浏览文件 @
26f2e095
...
...
@@ -308,3 +308,69 @@ 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
}
};
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
)
{
connected
=
true
;
}
else
{
connected
=
false
;
}
}
Dbh
::~
Dbh
()
{
release
();
}
bool
Dbh
::
release
()
{
if
(
connected
)
{
switch_cache_db_release_db_handle
(
&
dbh
);
connected
=
false
;
return
true
;
}
return
false
;
}
int
Dbh
::
query_callback
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
cargv
)
{
SWIGLUA_FN
*
lua_fun
=
(
SWIGLUA_FN
*
)
pArg
;
lua_pushvalue
(
lua_fun
->
L
,
lua_fun
->
idx
);
/* get the lua callback function onto the stack */
lua_newtable
(
lua_fun
->
L
);
/* push a row (table) */
for
(
int
i
=
0
;
i
<
argc
;
i
++
)
{
lua_pushstring
(
lua_fun
->
L
,
switch_str_nil
(
cargv
[
i
]));
lua_pushstring
(
lua_fun
->
L
,
switch_str_nil
(
argv
[
i
]));
lua_settable
(
lua_fun
->
L
,
-
3
);
}
lua_call
(
lua_fun
->
L
,
1
,
1
);
/* 1 in, 1 out */
if
(
lua_isnumber
(
lua_fun
->
L
,
-
1
))
{
if
(
lua_tonumber
(
lua_fun
->
L
,
-
1
)
!=
0
)
{
return
1
;
}
}
return
0
;
/* 0 to continue with next row */
}
bool
Dbh
::
query
(
char
*
sql
,
SWIGLUA_FN
lua_fun
)
{
if
(
connected
)
{
if
(
switch_cache_db_execute_sql_callback
(
dbh
,
sql
,
query_callback
,
&
lua_fun
,
NULL
)
==
SWITCH_STATUS_SUCCESS
)
{
return
true
;
}
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"no workie workie :(
\n
"
);
return
false
;
}
src/mod/languages/mod_lua/freeswitch_lua.h
浏览文件 @
26f2e095
...
...
@@ -8,6 +8,16 @@ extern "C" {
#include "mod_lua_extra.h"
}
#include <switch_cpp.h>
typedef
struct
{
lua_State
*
L
;
int
idx
;
}
SWIGLUA_FN
;
#define SWIGLUA_FN_GET(fn) {lua_pushvalue(fn.L,fn.idx);}
namespace
LUA
{
class
Session
:
public
CoreSession
{
private
:
...
...
@@ -41,5 +51,17 @@ namespace LUA {
void
setLUA
(
lua_State
*
state
);
};
class
Dbh
{
protected
:
switch_cache_db_handle_t
*
dbh
;
bool
connected
;
static
int
query_callback
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
cargv
);
public
:
Dbh
(
char
*
dsn
,
char
*
user
=
NULL
,
char
*
pass
=
NULL
);
~
Dbh
();
bool
release
();
bool
query
(
char
*
sql
,
SWIGLUA_FN
lua_fun
);
};
}
#endif
src/mod/languages/mod_lua/hack.diff
浏览文件 @
26f2e095
--- mod_lua_wrap.cpp
2008-07-16 16:58:58.000000000 -04
00
+++
old.cpp 2008-07-16 16:58:42.000000000 -04
00
@@ -
6731,7 +6731
,7 @@
SWIG_check_num_args("LUA::Session",0,0)
--- mod_lua_wrap.cpp
.orig 2010-09-05 16:39:26.000000000 +02
00
+++
mod_lua_wrap.cpp 2010-09-05 16:39:44.000000000 +02
00
@@ -
4913,7 +4913
,7 @@
result = (LUA::Session *)new LUA::Session();
SWIG_arg=0;
- SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++;
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; result->setLUA(L);
return SWIG_arg;
if(0) SWIG_fail;
@@ -
6759,7 +6759
,7 @@
fail:
@@ -
4934,7 +4934
,7 @@
arg2=(CoreSession *)SWIG_MustGetPtr(L,2,SWIGTYPE_p_CoreSession,0,2,"new_Session");
result = (LUA::Session *)new LUA::Session(arg1,arg2);
SWIG_arg=0;
- SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++;
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; result->setLUA(L);
return SWIG_arg;
if(0) SWIG_fail;
@@ -
6780,7 +6780
,7 @@
arg1 = (char
*)lua_tostring(L, 1);
fail:
@@ -
4952,7 +4952
,7 @@
arg1 = (char*)lua_tostring(L, 1);
result = (LUA::Session *)new LUA::Session(arg1);
SWIG_arg=0;
- SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++;
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; result->setLUA(L);
return SWIG_arg;
if(0) SWIG_fail;
@@ -
6805,7 +6805
,7 @@
fail:
@@ -
4970,7 +4970
,7 @@
arg1=(switch_core_session_t *)SWIG_MustGetPtr(L,1,SWIGTYPE_p_switch_core_session_t,0,1,"new_Session");
result = (LUA::Session *)new LUA::Session(arg1);
SWIG_arg=0;
- SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++;
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; result->setLUA(L);
return SWIG_arg;
if(0) SWIG_fail;
fail:
src/mod/languages/mod_lua/my_swigable_cpp.h
浏览文件 @
26f2e095
...
...
@@ -49,6 +49,19 @@ class Event {
};
class
Dbh
{
protected
:
switch_cache_db_handle_t
*
dbh
;
bool
connected
;
static
int
query_callback
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
cargv
);
public
:
Dbh
(
char
*
dsn
,
char
*
user
=
NULL
,
char
*
pass
=
NULL
);
~
Dbh
();
bool
release
();
bool
query
(
char
*
sql
,
SWIGLUA_FN
lua_fun
);
};
class
CoreSession
{
protected
:
switch_input_args_t
args
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论