Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
70d215ef
提交
70d215ef
authored
7月 22, 2010
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add -R to reconnect
上级
09c1815c
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
26 行增加
和
9 行删除
+26
-9
fs_cli.c
libs/esl/fs_cli.c
+26
-9
没有找到文件。
libs/esl/fs_cli.c
浏览文件 @
70d215ef
...
...
@@ -566,6 +566,8 @@ static int usage(char *name){
printf
(
" -x, --execute=command Execute Command and Exit
\n
"
);
printf
(
" -l, --loglevel=command Log Level
\n
"
);
printf
(
" -q, --quiet Disable logging
\n
"
);
printf
(
" -r, --retry Retry connection on failure
\n
"
);
printf
(
" -R, --reconnect Reconnect if disconnected
\n
"
);
printf
(
" -d, --debug=level Debug Level (0 - 7)
\n\n
"
);
return
1
;
}
...
...
@@ -581,7 +583,7 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)
esl_status_t
status
=
esl_recv_event_timed
(
handle
,
10
,
1
,
NULL
);
if
(
status
==
ESL_FAIL
)
{
esl_log
(
ESL_LOG_WARNING
,
"Disconnected.
\n
"
);
running
=
thread_running
=
0
;
running
=
-
1
;
thread_running
=
0
;
}
else
if
(
status
==
ESL_SUCCESS
)
{
if
(
handle
->
last_event
)
{
const
char
*
type
=
esl_event_get_header
(
handle
->
last_event
,
"content-type"
);
...
...
@@ -613,7 +615,7 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)
}
known
++
;
}
else
if
(
!
strcasecmp
(
type
,
"text/disconnect-notice"
))
{
running
=
thread_running
=
0
;
running
=
-
1
;
thread_running
=
0
;
known
++
;
}
else
if
(
!
strcasecmp
(
type
,
"text/event-plain"
))
{
char
*
foo
;
...
...
@@ -718,7 +720,7 @@ static int process_command(esl_handle_t *handle, const char *cmd)
snprintf
(
cmd_str
,
sizeof
(
cmd_str
),
"api %s
\n
console_execute: true
\n\n
"
,
cmd
);
if
(
esl_send_recv
(
handle
,
cmd_str
))
{
printf
(
"Socket interrupted, bye!
\n
"
);
return
1
;
return
-
1
;
}
if
(
handle
->
last_sr_event
)
{
if
(
handle
->
last_sr_event
->
body
)
{
...
...
@@ -987,6 +989,8 @@ int main(int argc, char *argv[])
{
"execute"
,
1
,
0
,
'x'
},
{
"loglevel"
,
1
,
0
,
'l'
},
{
"quiet"
,
0
,
0
,
'q'
},
{
"retry"
,
0
,
0
,
'r'
},
{
"reconnect"
,
0
,
0
,
'R'
},
{
0
,
0
,
0
,
0
}
};
...
...
@@ -1004,7 +1008,7 @@ int main(int argc, char *argv[])
char
argv_command
[
256
]
=
""
;
char
argv_loglevel
[
128
]
=
""
;
int
argv_quiet
=
0
;
int
loops
=
2
;
int
loops
=
2
,
reconnect
=
0
;
strncpy
(
internal_profile
.
host
,
"127.0.0.1"
,
sizeof
(
internal_profile
.
host
));
strncpy
(
internal_profile
.
pass
,
"ClueCon"
,
sizeof
(
internal_profile
.
pass
));
...
...
@@ -1026,7 +1030,7 @@ int main(int argc, char *argv[])
for
(;;)
{
int
option_index
=
0
;
opt
=
getopt_long
(
argc
,
argv
,
"H:U:P:S:u:p:d:x:l:qrh?"
,
options
,
&
option_index
);
opt
=
getopt_long
(
argc
,
argv
,
"H:U:P:S:u:p:d:x:l:qr
R
h?"
,
options
,
&
option_index
);
if
(
opt
==
-
1
)
break
;
switch
(
opt
)
{
...
...
@@ -1073,6 +1077,9 @@ int main(int argc, char *argv[])
case
'r'
:
loops
+=
120
;
break
;
case
'R'
:
reconnect
=
1
;
break
;
case
'h'
:
case
'?'
:
print_banner
(
stdout
);
...
...
@@ -1190,6 +1197,8 @@ int main(int argc, char *argv[])
snprintf
(
prompt_str
,
sizeof
(
prompt_str
),
"freeswitch@%s> "
,
profile
->
name
);
}
connect:
while
(
--
loops
>
0
)
{
memset
(
&
handle
,
0
,
sizeof
(
handle
));
if
(
esl_connect
(
&
handle
,
profile
->
host
,
profile
->
port
,
profile
->
user
,
profile
->
pass
))
{
...
...
@@ -1314,7 +1323,8 @@ int main(int argc, char *argv[])
esl_log
(
ESL_LOG_INFO
,
"FS CLI Ready.
\n
enter /help for a list of commands.
\n
"
);
printf
(
"%s
\n
"
,
handle
.
last_sr_reply
);
while
(
running
)
{
while
(
running
>
0
)
{
int
r
;
#ifdef HAVE_EDITLINE
line
=
el_gets
(
el
,
&
count
);
...
...
@@ -1341,8 +1351,8 @@ int main(int argc, char *argv[])
history
(
myhistory
,
&
ev
,
H_ENTER
,
line
);
#endif
if
(
process_command
(
&
handle
,
cmd
))
{
running
=
0
;
if
(
(
r
=
process_command
(
&
handle
,
cmd
)
))
{
running
=
r
;
}
#ifdef HAVE_EDITLINE
...
...
@@ -1357,6 +1367,13 @@ int main(int argc, char *argv[])
}
if
(
running
<
0
&&
reconnect
)
{
running
=
1
;
loops
=
120
;
goto
connect
;
}
#ifdef HAVE_EDITLINE
done:
history
(
myhistory
,
&
ev
,
H_SAVE
,
hfile
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论