Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
44f78e9e
提交
44f78e9e
authored
10月 05, 2012
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-4650 --resolve
上级
a6602206
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
103 行增加
和
20 行删除
+103
-20
mod_commands.c
src/mod/applications/mod_commands/mod_commands.c
+103
-20
没有找到文件。
src/mod/applications/mod_commands/mod_commands.c
浏览文件 @
44f78e9e
...
...
@@ -181,20 +181,57 @@ SWITCH_STANDARD_API(say_string_function)
}
static
void
dump_user
(
const
char
*
dname
,
const
char
*
gname
,
switch_xml_t
x_user_tag
,
switch_stream_handle_t
*
stream
,
const
char
*
_context
)
struct
user_struct
{
char
*
dname
;
char
*
gname
;
char
*
effective_caller_id_name
;
char
*
effective_caller_id_number
;
char
*
callgroup
;
switch_xml_t
x_user_tag
;
switch_stream_handle_t
*
stream
;
char
*
search_context
;
char
*
context
;
switch_xml_t
x_domain_tag
;
};
static
void
dump_user
(
struct
user_struct
*
us
)
{
switch_xml_t
x_vars
,
x_var
;
switch_xml_t
x_vars
,
x_var
,
ux
,
x_user_tag
,
x_domain_tag
;
switch_status_t
status
;
switch_stream_handle_t
apistream
=
{
0
};
char
*
user_context
=
NULL
;
switch_stream_handle_t
apistream
=
{
0
}
,
*
stream
;
char
*
user_context
=
NULL
,
*
search_context
=
NULL
,
*
context
=
NULL
;
char
*
effective_caller_id_name
=
NULL
;
char
*
effective_caller_id_number
=
NULL
;
char
*
callgroup
=
NULL
;
char
*
dname
=
NULL
,
*
gname
=
NULL
,
*
callgroup
=
NULL
;
char
*
utype
=
NULL
,
*
uname
=
NULL
;
char
*
apip
=
NULL
;
x_user_tag
=
us
->
x_user_tag
;
x_domain_tag
=
us
->
x_domain_tag
;
effective_caller_id_name
=
us
->
effective_caller_id_name
;
effective_caller_id_number
=
us
->
effective_caller_id_number
;
callgroup
=
us
->
callgroup
;
dname
=
us
->
dname
;
gname
=
us
->
gname
;
stream
=
us
->
stream
;
context
=
us
->
context
;
search_context
=
us
->
search_context
;
if
(
!
x_user_tag
)
{
return
;
}
utype
=
(
char
*
)
switch_xml_attr_soft
(
us
->
x_user_tag
,
"type"
);
uname
=
(
char
*
)
switch_xml_attr_soft
(
us
->
x_user_tag
,
"id"
);
if
(
!
strcasecmp
(
utype
,
"pointer"
))
{
if
(
switch_xml_locate_user_in_domain
(
uname
,
x_domain_tag
,
&
ux
,
NULL
)
==
SWITCH_STATUS_SUCCESS
)
{
x_user_tag
=
ux
;
}
}
user_context
=
(
char
*
)
context
;
if
((
x_vars
=
switch_xml_child
(
x_user_tag
,
"variables"
)))
{
for
(
x_var
=
switch_xml_child
(
x_vars
,
"variable"
);
x_var
;
x_var
=
x_var
->
next
)
{
const
char
*
key
=
switch_xml_attr_soft
(
x_var
,
"name"
);
...
...
@@ -214,19 +251,28 @@ static void dump_user(const char *dname, const char* gname, switch_xml_t x_user_
}
}
if
(
_context
)
{
if
(
zstr
(
user_context
)
||
strcasecmp
(
_context
,
user_context
))
{
if
(
search
_context
)
{
if
(
zstr
(
user_context
)
||
strcasecmp
(
search
_context
,
user_context
))
{
return
;
}
}
if
(
zstr
(
dname
))
{
apip
=
switch_mprintf
(
"%s"
,
switch_xml_attr_soft
(
x_user_tag
,
"id"
));
}
else
{
apip
=
switch_mprintf
(
"%s@%s"
,
switch_xml_attr_soft
(
x_user_tag
,
"id"
),
dname
);
}
SWITCH_STANDARD_STREAM
(
apistream
);
if
((
status
=
switch_api_execute
(
"sofia_contact"
,
switch_xml_attr_soft
(
x_user_tag
,
"id"
)
,
NULL
,
&
apistream
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_
safe_free
(
apistream
.
data
);
return
;
if
((
status
=
switch_api_execute
(
"sofia_contact"
,
apip
,
NULL
,
&
apistream
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_
log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"sofia_contact '%s' failed. status: %d
\n
"
,
apip
,
status
);
goto
end
;
}
stream
->
write_function
(
stream
,
"%s|%s|%s|%s|%s|%s|%s|%s
\n
"
,
switch_xml_attr_soft
(
x_user_tag
,
"id"
),
user_context
,
dname
,
gname
,
apistream
.
data
,
callgroup
,
effective_caller_id_name
,
effective_caller_id_number
);
end:
switch_safe_free
(
apistream
.
data
);
switch_safe_free
(
apip
);
return
;
}
...
...
@@ -239,7 +285,7 @@ SWITCH_STANDARD_API(list_users_function)
int32_t
arg
=
0
;
switch_xml_t
xml_root
,
x_domains
,
x_domain_tag
;
switch_xml_t
gts
,
gt
,
uts
,
ut
;
char
*
_user
=
NULL
,
*
_domain
=
NULL
,
*
_context
=
NULL
,
*
_group
=
NULL
;
char
*
_user
=
NULL
,
*
_domain
=
NULL
,
*
_
search_
context
=
NULL
,
*
_group
=
NULL
;
if
((
pdata
=
strdup
(
cmd
)))
{
...
...
@@ -258,7 +304,7 @@ SWITCH_STANDARD_API(list_users_function)
_domain
=
argv
[
arg
+
1
];
}
if
(
!
strcasecmp
(
argv
[
arg
],
"context"
))
{
_context
=
argv
[
arg
+
1
];
_
search_
context
=
argv
[
arg
+
1
];
}
if
(
!
strcasecmp
(
argv
[
arg
],
"group"
))
{
_group
=
argv
[
arg
+
1
];
...
...
@@ -269,30 +315,64 @@ SWITCH_STANDARD_API(list_users_function)
stream
->
write_function
(
stream
,
"userid|context|domain|group|contact|callgroup|effective_caller_id_name|effective_caller_id_number
\n
"
);
if
(
switch_xml_locate
(
"directory"
,
NULL
,
NULL
,
NULL
,
&
xml_root
,
&
x_domains
,
NULL
,
SWITCH_FALSE
)
==
SWITCH_STATUS_SUCCESS
)
{
const
char
*
dname
=
NULL
;
const
char
*
gname
=
NULL
;
struct
user_struct
us
=
{
0
};
for
(
x_domain_tag
=
switch_xml_child
(
x_domains
,
"domain"
);
x_domain_tag
;
x_domain_tag
=
x_domain_tag
->
next
)
{
dname
=
switch_xml_attr_soft
(
x_domain_tag
,
"name"
);
switch_xml_t
x_vars
,
x_var
;
us
.
dname
=
(
char
*
)
switch_xml_attr_soft
(
x_domain_tag
,
"name"
);
if
(
_domain
&&
strcasecmp
(
_domain
,
dname
))
{
if
(
_domain
&&
strcasecmp
(
_domain
,
us
.
dname
))
{
continue
;
}
if
((
x_vars
=
switch_xml_child
(
x_domain_tag
,
"variables"
)))
{
if
((
x_var
=
switch_xml_find_child_multi
(
x_vars
,
"variable"
,
"name"
,
"user_context"
,
NULL
)))
{
us
.
context
=
(
char
*
)
switch_xml_attr_soft
(
x_var
,
"value"
);
}
if
((
x_var
=
switch_xml_find_child_multi
(
x_vars
,
"variable"
,
"name"
,
"callgroup"
,
NULL
)))
{
us
.
callgroup
=
(
char
*
)
switch_xml_attr_soft
(
x_var
,
"value"
);
}
if
((
x_var
=
switch_xml_find_child_multi
(
x_vars
,
"variable"
,
"name"
,
"effective_caller_id_name"
,
NULL
)))
{
us
.
effective_caller_id_name
=
(
char
*
)
switch_xml_attr_soft
(
x_var
,
"value"
);
}
if
((
x_var
=
switch_xml_find_child_multi
(
x_vars
,
"variable"
,
"name"
,
"effective_caller_id_number"
,
NULL
)))
{
us
.
effective_caller_id_number
=
(
char
*
)
switch_xml_attr_soft
(
x_var
,
"value"
);
}
}
if
((
gts
=
switch_xml_child
(
x_domain_tag
,
"groups"
)))
{
for
(
gt
=
switch_xml_child
(
gts
,
"group"
);
gt
;
gt
=
gt
->
next
)
{
gname
=
switch_xml_attr_soft
(
gt
,
"name"
);
us
.
gname
=
(
char
*
)
switch_xml_attr_soft
(
gt
,
"name"
);
if
(
_group
&&
strcasecmp
(
_group
,
gname
))
{
if
(
_group
&&
strcasecmp
(
_group
,
us
.
gname
))
{
continue
;
}
if
((
x_vars
=
switch_xml_child
(
gt
,
"variables"
)))
{
if
((
x_var
=
switch_xml_find_child_multi
(
x_vars
,
"variable"
,
"name"
,
"user_context"
,
NULL
)))
{
us
.
context
=
(
char
*
)
switch_xml_attr_soft
(
x_var
,
"value"
);
}
if
((
x_var
=
switch_xml_find_child_multi
(
x_vars
,
"variable"
,
"name"
,
"callgroup"
,
NULL
)))
{
us
.
callgroup
=
(
char
*
)
switch_xml_attr_soft
(
x_var
,
"value"
);
}
if
((
x_var
=
switch_xml_find_child_multi
(
x_vars
,
"variable"
,
"name"
,
"effective_caller_id_name"
,
NULL
)))
{
us
.
effective_caller_id_name
=
(
char
*
)
switch_xml_attr_soft
(
x_var
,
"value"
);
}
if
((
x_var
=
switch_xml_find_child_multi
(
x_vars
,
"variable"
,
"name"
,
"effective_caller_id_number"
,
NULL
)))
{
us
.
effective_caller_id_number
=
(
char
*
)
switch_xml_attr_soft
(
x_var
,
"value"
);
}
}
for
(
uts
=
switch_xml_child
(
gt
,
"users"
);
uts
;
uts
=
uts
->
next
)
{
for
(
ut
=
switch_xml_child
(
uts
,
"user"
);
ut
;
ut
=
ut
->
next
)
{
if
(
_user
&&
strcasecmp
(
_user
,
switch_xml_attr_soft
(
ut
,
"id"
)))
{
continue
;
}
dump_user
(
dname
,
gname
,
ut
,
stream
,
_context
);
us
.
x_user_tag
=
ut
;
us
.
x_domain_tag
=
x_domain_tag
;
us
.
stream
=
stream
;
dump_user
(
&
us
);
}
}
}
...
...
@@ -302,7 +382,10 @@ SWITCH_STANDARD_API(list_users_function)
if
(
_user
&&
strcasecmp
(
_user
,
switch_xml_attr_soft
(
ut
,
"id"
)))
{
continue
;
}
dump_user
(
dname
,
gname
,
ut
,
stream
,
_context
);
us
.
x_user_tag
=
ut
;
us
.
x_domain_tag
=
x_domain_tag
;
us
.
stream
=
stream
;
dump_user
(
&
us
);
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论