Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
41557506
提交
41557506
authored
4月 26, 2010
作者:
Michael Jerris
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add xml error checking
上级
a44e6c08
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
27 行增加
和
4 行删除
+27
-4
switch_xml.c
src/switch_xml.c
+27
-4
没有找到文件。
src/switch_xml.c
浏览文件 @
41557506
...
...
@@ -403,6 +403,10 @@ SWITCH_DECLARE(const char *) switch_xml_attr(switch_xml_t xml, const char *attr)
return
NULL
;
}
if
(
!
root
->
attr
)
{
return
NULL
;
}
for
(
i
=
0
;
root
->
attr
[
i
]
&&
xml
->
name
&&
strcmp
(
xml
->
name
,
root
->
attr
[
i
][
0
]);
i
++
);
if
(
!
root
->
attr
[
i
])
return
NULL
;
/* no matching default attributes */
...
...
@@ -451,6 +455,9 @@ SWITCH_DECLARE(const char **) switch_xml_pi(switch_xml_t xml, const char *target
return
(
const
char
**
)
SWITCH_XML_NIL
;
while
(
root
->
xml
.
parent
)
root
=
(
switch_xml_root_t
)
root
->
xml
.
parent
;
/* root tag */
if
(
!
root
||
!
root
->
pi
)
{
return
(
const
char
**
)
SWITCH_XML_NIL
;
}
while
(
root
->
pi
[
i
]
&&
strcmp
(
target
,
root
->
pi
[
i
][
0
]))
i
++
;
/* find target */
return
(
const
char
**
)
((
root
->
pi
[
i
])
?
root
->
pi
[
i
]
+
1
:
SWITCH_XML_NIL
);
...
...
@@ -463,6 +470,10 @@ static switch_xml_t switch_xml_err(switch_xml_root_t root, char *s, const char *
int
line
=
1
;
char
*
t
,
fmt
[
SWITCH_XML_ERRL
];
if
(
!
root
||
!
root
->
s
)
{
return
NULL
;
}
for
(
t
=
root
->
s
;
t
&&
t
<
s
;
t
++
)
if
(
*
t
==
'\n'
)
line
++
;
...
...
@@ -578,7 +589,13 @@ static char *switch_xml_decode(char *s, char **ent, char t)
/* called when parser finds start of new tag */
static
void
switch_xml_open_tag
(
switch_xml_root_t
root
,
char
*
name
,
char
**
attr
)
{
switch_xml_t
xml
=
root
->
cur
;
switch_xml_t
xml
;
if
(
!
root
||
!
root
->
cur
)
{
return
;
}
xml
=
root
->
cur
;
if
(
xml
->
name
)
xml
=
switch_xml_add_child
(
xml
,
name
,
strlen
(
xml
->
txt
));
...
...
@@ -592,10 +609,16 @@ static void switch_xml_open_tag(switch_xml_root_t root, char *name, char **attr)
/* called when parser finds character content between open and closing tag */
static
void
switch_xml_char_content
(
switch_xml_root_t
root
,
char
*
s
,
switch_size_t
len
,
char
t
)
{
switch_xml_t
xml
=
root
->
cur
;
switch_xml_t
xml
;
char
*
m
=
s
;
switch_size_t
l
;
if
(
!
root
||
!
root
->
cur
)
{
return
;
}
xml
=
root
->
cur
;
if
(
!
xml
||
!
xml
->
name
||
!
len
)
return
;
/* sanity check */
...
...
@@ -632,7 +655,7 @@ static void switch_xml_char_content(switch_xml_root_t root, char *s, switch_size
/* called when parser finds closing tag */
static
switch_xml_t
switch_xml_close_tag
(
switch_xml_root_t
root
,
char
*
name
,
char
*
s
)
{
if
(
!
root
->
cur
||
!
root
->
cur
->
name
||
strcmp
(
name
,
root
->
cur
->
name
))
if
(
!
root
||
!
root
->
cur
||
!
root
->
cur
->
name
||
strcmp
(
name
,
root
->
cur
->
name
))
return
switch_xml_err
(
root
,
s
,
"unexpected closing tag </%s>"
,
name
);
root
->
cur
=
root
->
cur
->
parent
;
...
...
@@ -681,7 +704,7 @@ static void switch_xml_proc_inst(switch_xml_root_t root, char *s, switch_size_t
return
;
}
if
(
!
root
->
pi
[
0
])
{
if
(
!
root
->
pi
||
!
root
->
pi
[
0
])
{
root
->
pi
=
(
char
***
)
malloc
(
sizeof
(
char
**
));
if
(
!
root
->
pi
)
return
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论