Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
0564d81e
提交
0564d81e
authored
4月 23, 2008
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@8176
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
1fb841bf
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
105 行增加
和
44 行删除
+105
-44
switch_core.h
src/include/switch_core.h
+1
-0
mod_commands.c
src/mod/applications/mod_commands/mod_commands.c
+4
-33
switch_console.c
src/switch_console.c
+89
-9
switch_core_sqldb.c
src/switch_core_sqldb.c
+11
-2
没有找到文件。
src/include/switch_core.h
浏览文件 @
0564d81e
...
...
@@ -1600,6 +1600,7 @@ SWITCH_DECLARE(switch_bool_t) switch_check_network_list_ip(const char *ip_str, c
SWITCH_DECLARE
(
void
)
switch_time_set_monotonic
(
switch_bool_t
enable
);
SWITCH_DECLARE
(
uint32_t
)
switch_core_max_dtmf_duration
(
uint32_t
duration
);
SWITCH_DECLARE
(
uint32_t
)
switch_core_default_dtmf_duration
(
uint32_t
duration
);
SWITCH_DECLARE
(
switch_status_t
)
switch_console_set_complete
(
const
char
*
string
);
///\}
...
...
src/mod/applications/mod_commands/mod_commands.c
浏览文件 @
0564d81e
...
...
@@ -1888,45 +1888,16 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames)
#define COMPLETE_SYNTAX "add <word>|del [<word>|all]"
SWITCH_STANDARD_API
(
complete_function
)
{
char
*
mydata
=
NULL
,
*
argv
[
2
]
=
{
0
};
int
fail
=
1
,
argc
;
char
sql
[
1024
]
=
""
;
if
(
cmd
&&
(
mydata
=
strdup
(
cmd
)))
{
if
((
argc
=
switch_separate_string
(
mydata
,
' '
,
argv
,
(
sizeof
(
argv
)
/
sizeof
(
argv
[
0
])))))
{
switch_core_db_t
*
db
=
switch_core_db_handle
();
if
(
!
strcasecmp
(
argv
[
0
],
"add"
))
{
switch_snprintf
(
sql
,
sizeof
(
sql
),
"delete from complete where name = '%s'"
,
argv
[
1
]);
switch_core_db_persistant_execute
(
db
,
sql
,
1
);
switch_snprintf
(
sql
,
sizeof
(
sql
),
"insert into complete values ('%s')"
,
argv
[
1
]);
switch_core_db_persistant_execute
(
db
,
sql
,
1
);
stream
->
write_function
(
stream
,
"+OK
\n
"
);
fail
=
0
;
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"del"
))
{
char
*
what
=
argv
[
1
];
if
(
!
strcasecmp
(
what
,
"*"
))
{
switch_snprintf
(
sql
,
sizeof
(
sql
),
"delete from complete"
);
}
else
{
switch_snprintf
(
sql
,
sizeof
(
sql
),
"delete from complete where name = '%s'"
,
what
);
}
switch_core_db_persistant_execute
(
db
,
sql
,
1
);
stream
->
write_function
(
stream
,
"+OK
\n
"
);
fail
=
0
;
}
switch_core_db_close
(
db
);
}
}
switch_safe_free
(
mydata
);
switch_status_t
status
;
if
(
fail
)
{
if
((
status
=
switch_console_set_complete
(
cmd
))
==
SWITCH_STATUS_SUCCESS
)
{
stream
->
write_function
(
stream
,
"+OK
\n
"
);
}
else
{
stream
->
write_function
(
stream
,
"-USAGE: %s
\n
"
,
COMPLETE_SYNTAX
);
}
return
SWITCH_STATUS_SUCCESS
;
}
#define SHOW_SYNTAX "codec|application|api|dialplan|file|timer|calls|channels"
...
...
src/switch_console.c
浏览文件 @
0564d81e
...
...
@@ -371,6 +371,7 @@ struct helper {
EditLine
*
el
;
int
len
;
int
hits
;
int
words
;
char
last
[
512
];
FILE
*
out
;
};
...
...
@@ -378,10 +379,17 @@ struct helper {
static
int
comp_callback
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
columnNames
)
{
struct
helper
*
h
=
(
struct
helper
*
)
pArg
;
char
*
target
=
NULL
;
target
=
argv
[
0
];
if
(
!
target
)
{
return
-
1
;
}
fprintf
(
h
->
out
,
"%20s
\t
"
,
argv
[
0
]
);
fprintf
(
h
->
out
,
"%20s
\t
"
,
target
);
switch_copy_string
(
h
->
last
,
argv
[
0
]
,
sizeof
(
h
->
last
));
switch_copy_string
(
h
->
last
,
target
,
sizeof
(
h
->
last
));
if
((
++
h
->
hits
%
4
)
==
0
)
{
fprintf
(
h
->
out
,
"
\n
"
);
...
...
@@ -400,7 +408,6 @@ static unsigned char complete(EditLine *el, int ch)
char
*
p
,
*
lp
=
NULL
;
char
*
errmsg
=
NULL
;
struct
helper
h
=
{
el
};
int
words
=
0
;
unsigned
char
ret
=
CC_REDISPLAY
;
h
.
out
=
switch_core_get_console
();
...
...
@@ -416,7 +423,7 @@ static unsigned char complete(EditLine *el, int ch)
for
(
p
=
buf
;
p
&&
*
p
;
p
++
)
{
if
(
*
p
==
' '
)
{
lp
=
p
;
words
++
;
h
.
words
++
;
}
}
...
...
@@ -428,7 +435,7 @@ static unsigned char complete(EditLine *el, int ch)
fprintf
(
h
.
out
,
"
\n\n
"
);
if
(
words
==
0
)
{
if
(
h
.
words
==
0
)
{
sql
=
switch_mprintf
(
"select distinct name from interfaces where type='api' and name like '%s%%' order by name"
,
buf
);
}
else
{
sql
=
switch_mprintf
(
"select distinct uuid from channels where uuid like '%s%%' order by uuid"
,
buf
);
...
...
@@ -444,14 +451,42 @@ static unsigned char complete(EditLine *el, int ch)
}
if
(
h
.
hits
!=
1
)
{
switch_safe_free
(
sql
);
sql
=
switch_mprintf
(
"select distinct name from complete where name like '%s%%' order by name"
,
buf
);
switch_core_db_exec
(
db
,
sql
,
comp_callback
,
&
h
,
&
errmsg
);
char
*
dupdup
=
strdup
(
dup
);
switch_assert
(
dupdup
);
int
x
,
argc
=
0
;
char
*
argv
[
10
]
=
{
0
};
switch_stream_handle_t
stream
=
{
0
};
SWITCH_STANDARD_STREAM
(
stream
);
argc
=
switch_separate_string
(
dupdup
,
' '
,
argv
,
(
sizeof
(
argv
)
/
sizeof
(
argv
[
0
])));
if
(
h
.
words
==
0
)
{
stream
.
write_function
(
&
stream
,
"select distinct a1 from complete where "
"a1 not in (select name from interfaces) and "
);
}
else
{
stream
.
write_function
(
&
stream
,
"select distinct a%d from complete where "
,
h
.
words
+
1
);
}
for
(
x
=
0
;
x
<
argc
;
x
++
)
{
stream
.
write_function
(
&
stream
,
"(a%d = '' or a%d like '%s%%')%s"
,
x
+
1
,
x
+
1
,
switch_str_nil
(
argv
[
x
]),
x
==
argc
-
1
?
""
:
" and "
);
}
switch_core_db_exec
(
db
,
stream
.
data
,
comp_callback
,
&
h
,
&
errmsg
);
if
(
errmsg
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"error [%s][%s]
\n
"
,
sql
,
errmsg
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"error [%s][%s]
\n
"
,
(
char
*
)
stream
.
data
,
errmsg
);
free
(
errmsg
);
ret
=
CC_ERROR
;
}
switch_safe_free
(
dupdup
);
switch_safe_free
(
stream
.
data
);
if
(
ret
==
CC_ERROR
)
{
goto
end
;
}
}
...
...
@@ -475,6 +510,51 @@ static unsigned char complete(EditLine *el, int ch)
return
(
ret
);
}
SWITCH_DECLARE
(
switch_status_t
)
switch_console_set_complete
(
const
char
*
string
)
{
char
*
mydata
=
NULL
,
*
argv
[
11
]
=
{
0
};
int
argc
,
x
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
if
(
string
&&
(
mydata
=
strdup
(
string
)))
{
if
((
argc
=
switch_separate_string
(
mydata
,
' '
,
argv
,
(
sizeof
(
argv
)
/
sizeof
(
argv
[
0
])))))
{
switch_core_db_t
*
db
=
switch_core_db_handle
();
switch_stream_handle_t
mystream
=
{
0
};
SWITCH_STANDARD_STREAM
(
mystream
);
if
(
!
strcasecmp
(
argv
[
0
],
"add"
))
{
mystream
.
write_function
(
&
mystream
,
"insert into complete values ("
);
for
(
x
=
0
;
x
<
10
;
x
++
)
{
mystream
.
write_function
(
&
mystream
,
"'%s'%s"
,
switch_str_nil
(
argv
[
x
+
1
]),
x
==
9
?
")"
:
", "
);
}
switch_core_db_persistant_execute
(
db
,
mystream
.
data
,
1
);
status
=
SWITCH_STATUS_SUCCESS
;
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"del"
))
{
char
*
what
=
argv
[
1
];
if
(
!
strcasecmp
(
what
,
"*"
))
{
switch_core_db_persistant_execute
(
db
,
"delete from complete"
,
1
);
}
else
{
mystream
.
write_function
(
&
mystream
,
"delete from complete where "
);
for
(
x
=
0
;
x
<
argc
-
1
;
x
++
)
{
mystream
.
write_function
(
&
mystream
,
"a%d = '%s'%s"
,
x
+
1
,
switch_str_nil
(
argv
[
x
+
1
]),
x
==
argc
-
2
?
""
:
" and "
);
}
switch_core_db_persistant_execute
(
db
,
mystream
.
data
,
1
);
}
status
=
SWITCH_STATUS_SUCCESS
;
}
switch_safe_free
(
mystream
.
data
);
switch_core_db_close
(
db
);
}
}
switch_safe_free
(
mydata
);
return
status
;
}
SWITCH_DECLARE
(
void
)
switch_console_loop
(
void
)
{
switch_thread_t
*
thread
;
...
...
src/switch_core_sqldb.c
浏览文件 @
0564d81e
...
...
@@ -368,7 +368,16 @@ void switch_core_sqldb_start(switch_memory_pool_t *pool)
}
else
{
char
create_complete_sql
[]
=
"CREATE TABLE complete (
\n
"
" name VARCHAR(255)
\n
"
" a1 VARCHAR(255),
\n
"
" a2 VARCHAR(255),
\n
"
" a3 VARCHAR(255),
\n
"
" a4 VARCHAR(255),
\n
"
" a5 VARCHAR(255),
\n
"
" a6 VARCHAR(255),
\n
"
" a7 VARCHAR(255),
\n
"
" a8 VARCHAR(255),
\n
"
" a9 VARCHAR(255),
\n
"
" a10 VARCHAR(255)
\n
"
");
\n
"
;
char
create_channels_sql
[]
=
...
...
@@ -430,7 +439,7 @@ void switch_core_sqldb_start(switch_memory_pool_t *pool)
switch_core_db_exec
(
sql_manager
.
db
,
"PRAGMA cache_size=8000"
,
NULL
,
NULL
,
NULL
);
switch_core_db_exec
(
sql_manager
.
db
,
"PRAGMA temp_store=MEMORY;"
,
NULL
,
NULL
,
NULL
);
switch_core_db_
exec
(
sql_manager
.
db
,
create_complete_sql
,
NULL
,
NULL
,
NULL
);
switch_core_db_
test_reactive
(
sql_manager
.
db
,
"select a1 from complete"
,
"DROP TABLE complete"
,
create_complete_sql
);
switch_core_db_exec
(
sql_manager
.
db
,
create_channels_sql
,
NULL
,
NULL
,
NULL
);
switch_core_db_exec
(
sql_manager
.
db
,
create_calls_sql
,
NULL
,
NULL
,
NULL
);
switch_core_db_exec
(
sql_manager
.
db
,
create_interfaces_sql
,
NULL
,
NULL
,
NULL
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论