Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
8977778b
提交
8977778b
authored
5月 10, 2006
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dox
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@1426
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
29542454
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
174 行增加
和
58 行删除
+174
-58
Doxygen.conf
docs/Doxygen.conf
+3
-3
switch_xml.h
src/include/switch_xml.h
+171
-55
没有找到文件。
docs/Doxygen.conf
浏览文件 @
8977778b
...
@@ -186,14 +186,14 @@ RTF_EXTENSIONS_FILE =
...
@@ -186,14 +186,14 @@ RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# configuration options related to the man page output
# configuration options related to the man page output
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
GENERATE_MAN
=
YES
GENERATE_MAN
=
NO
MAN_OUTPUT
=
man
MAN_OUTPUT
=
man
MAN_EXTENSION
= .
3
MAN_EXTENSION
= .
3
MAN_LINKS
=
NO
MAN_LINKS
=
NO
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# configuration options related to the XML output
# configuration options related to the XML output
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
GENERATE_XML
=
YES
GENERATE_XML
=
NO
XML_OUTPUT
=
xml
XML_OUTPUT
=
xml
XML_SCHEMA
=
XML_SCHEMA
=
XML_DTD
=
XML_DTD
=
...
@@ -205,7 +205,7 @@ GENERATE_AUTOGEN_DEF = NO
...
@@ -205,7 +205,7 @@ GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
GENERATE_PERLMOD
=
YES
GENERATE_PERLMOD
=
NO
PERLMOD_LATEX
=
NO
PERLMOD_LATEX
=
NO
PERLMOD_PRETTY
=
YES
PERLMOD_PRETTY
=
YES
PERLMOD_MAKEVAR_PREFIX
=
PERLMOD_MAKEVAR_PREFIX
=
...
...
src/include/switch_xml.h
浏览文件 @
8977778b
...
@@ -61,6 +61,10 @@
...
@@ -61,6 +61,10 @@
#include <stdarg.h>
#include <stdarg.h>
#include <fcntl.h>
#include <fcntl.h>
///\defgroup xml1 XML Library Functions
///\ingroup core1
///\{
BEGIN_EXTERN_C
BEGIN_EXTERN_C
#define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers
#define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers
...
@@ -72,125 +76,226 @@ typedef enum {
...
@@ -72,125 +76,226 @@ typedef enum {
SWITCH_XML_DUP
=
(
1
<<
3
)
// attribute name and value are strduped
SWITCH_XML_DUP
=
(
1
<<
3
)
// attribute name and value are strduped
}
switch_xml_flag_t
;
}
switch_xml_flag_t
;
/*! \brief A representation of an XML tree */
struct
switch_xml
{
struct
switch_xml
{
char
*
name
;
// tag name
/*! tag name */
char
**
attr
;
// tag attributes { name, value, name, value, ... NULL }
char
*
name
;
char
*
txt
;
// tag character content, empty string if none
/*! tag attributes { name, value, name, value, ... NULL } */
switch_size_t
off
;
// tag offset from start of parent tag character content
char
**
attr
;
switch_xml_t
next
;
// next tag with same name in this section at this depth
/*! tag character content, empty string if none */
switch_xml_t
sibling
;
// next tag with different name in same section and depth
char
*
txt
;
switch_xml_t
ordered
;
// next tag, same section and depth, in original order
/*! tag offset from start of parent tag character content */
switch_xml_t
child
;
// head of sub tag list, NULL if none
switch_size_t
off
;
switch_xml_t
parent
;
// parent tag, NULL if current tag is root tag
/*! next tag with same name in this section at this depth */
uint32_t
flags
;
// additional information
switch_xml_t
next
;
/*! next tag with different name in same section and depth*/
switch_xml_t
sibling
;
/*! next tag, same section and depth, in original order */
switch_xml_t
ordered
;
/*! head of sub tag list, NULL if none*/
switch_xml_t
child
;
/*! parent tag, NULL if current tag is root tag*/
switch_xml_t
parent
;
/*! flags */
uint32_t
flags
;
};
};
// Given a string of xml data and its length, parses it and creates an switch_xml
///\brief Given a string of xml data and its length, parses it and creates an switch_xml
// structure. For efficiency, modifies the data by adding null terminators
///\ structure. For efficiency, modifies the data by adding null terminators
// and decoding ampersand sequences. If you don't want this, copy the data and
///\ and decoding ampersand sequences. If you don't want this, copy the data and
// pass in the copy. Returns NULL on failure.
///\ pass in the copy. Returns NULL on failure.
///\param s a string
///\param len the length of the string
///\return a formated xml node or NULL
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_parse_str
(
char
*
s
,
switch_size_t
len
);
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_parse_str
(
char
*
s
,
switch_size_t
len
);
// A wrapper for switch_xml_parse_str() that accepts a file descriptor. First
///\brief A wrapper for switch_xml_parse_str() that accepts a file descriptor. First
// attempts to mem map the file. Failing that, reads the file into memory.
///\ attempts to mem map the file. Failing that, reads the file into memory.
// Returns NULL on failure.
///\ Returns NULL on failure.
///\param fd
///\return a formated xml node or NULL
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_parse_fd
(
int
fd
);
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_parse_fd
(
int
fd
);
// a wrapper for switch_xml_parse_fd() that accepts a file name
///\brief a wrapper for switch_xml_parse_fd() that accepts a file name
///\param file a file to parse
///\return a formated xml node or NULL
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_parse_file
(
const
char
*
file
);
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_parse_file
(
const
char
*
file
);
// Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire
///\brief Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire
// stream into memory and then parses it. For xml files, use switch_xml_parse_file()
///\ stream into memory and then parses it. For xml files, use switch_xml_parse_file()
// or switch_xml_parse_fd()
///\ or switch_xml_parse_fd()
///\param fp a FILE pointer to parse
///\return an xml node or NULL
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_parse_fp
(
FILE
*
fp
);
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_parse_fp
(
FILE
*
fp
);
// returns the first child tag (one level deeper) with the given name or NULL
///\brief returns the first child tag (one level deeper) with the given name or NULL
// if not found
///\ if not found
///\param xml an xml node
///\param name the name of the child tag
///\return an xml node or NULL
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_child
(
switch_xml_t
xml
,
const
char
*
name
);
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_child
(
switch_xml_t
xml
,
const
char
*
name
);
///\brief find a child tag in a node called 'childname' with an attribute 'attrname' which equals 'value'
///\param node the xml node
///\param childname the child tag name
///\param attrname the attribute name
///\param value the value
///\return an xml node or NULL
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_find_child
(
switch_xml_t
node
,
char
*
childname
,
char
*
attrname
,
char
*
value
);
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_find_child
(
switch_xml_t
node
,
char
*
childname
,
char
*
attrname
,
char
*
value
);
// returns the next tag of the same name in the same section and depth or NULL
///\brief returns the next tag of the same name in the same section and depth or NULL
// if not found
///\ if not found
///\param xml an xml node
///\return an xml node or NULL
#define switch_xml_next(xml) ((xml) ? xml->next : NULL)
#define switch_xml_next(xml) ((xml) ? xml->next : NULL)
// Returns the Nth tag with the same name in the same section at the same depth
///\brief Returns the Nth tag with the same name in the same section at the same depth
// or NULL if not found. An index of 0 returns the tag given.
///\ or NULL if not found. An index of 0 returns the tag given.
///\param xml the xml node
///\param idx the index
///\return an xml node or NULL
switch_xml_t
switch_xml_idx
(
switch_xml_t
xml
,
int
idx
);
switch_xml_t
switch_xml_idx
(
switch_xml_t
xml
,
int
idx
);
// returns the name of the given tag
///\brief returns the name of the given tag
///\param xml the xml node
///\return the name
#define switch_xml_name(xml) ((xml) ? xml->name : NULL)
#define switch_xml_name(xml) ((xml) ? xml->name : NULL)
// returns the given tag's character content or empty string if none
///\brief returns the given tag's character content or empty string if none
///\param xml the xml node
///\return the content
#define switch_xml_txt(xml) ((xml) ? xml->txt : "")
#define switch_xml_txt(xml) ((xml) ? xml->txt : "")
// returns the value of the requested tag attribute, or NULL if not found
///\brief returns the value of the requested tag attribute, or NULL if not found
///\param xml the xml node
///\param attr the attribute
///\return the value
SWITCH_DECLARE
(
const
char
*
)
switch_xml_attr
(
switch_xml_t
xml
,
const
char
*
attr
);
SWITCH_DECLARE
(
const
char
*
)
switch_xml_attr
(
switch_xml_t
xml
,
const
char
*
attr
);
// Traverses the switch_xml sturcture to retrieve a specific subtag. Takes a
///\brief Traverses the switch_xml sturcture to retrieve a specific subtag. Takes a
// variable length list of tag names and indexes. The argument list must be
///\ variable length list of tag names and indexes. The argument list must be
// terminated by either an index of -1 or an empty string tag name. Example:
///\ terminated by either an index of -1 or an empty string tag name. Example:
// title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1);
///\ title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1);
// This retrieves the title of the 3rd book on the 1st shelf of library.
///\ This retrieves the title of the 3rd book on the 1st shelf of library.
// Returns NULL if not found.
///\ Returns NULL if not found.
///\param xml the xml node
///\return an xml node or NULL
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_get
(
switch_xml_t
xml
,
...);
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_get
(
switch_xml_t
xml
,
...);
// Converts an switch_xml structure back to xml. Returns a string of xml data that
///\brief Converts an switch_xml structure back to xml. Returns a string of xml data that
// must be freed.
///\ must be freed.
///\param xml the xml node
///\return the xml text string
SWITCH_DECLARE
(
char
*
)
switch_xml_toxml
(
switch_xml_t
xml
);
SWITCH_DECLARE
(
char
*
)
switch_xml_toxml
(
switch_xml_t
xml
);
// returns a NULL terminated array of processing instructions for the given
///\brief returns a NULL terminated array of processing instructions for the given
// target
///\ target
///\param xml the xml node
///\param target the instructions
///\return the array
SWITCH_DECLARE
(
const
char
**
)
switch_xml_pi
(
switch_xml_t
xml
,
const
char
*
target
);
SWITCH_DECLARE
(
const
char
**
)
switch_xml_pi
(
switch_xml_t
xml
,
const
char
*
target
);
// frees the memory allocated for an switch_xml structure
///\brief frees the memory allocated for an switch_xml structure
///\param xml the xml node
///\note in the case of the root node the readlock will be lifted
SWITCH_DECLARE
(
void
)
switch_xml_free
(
switch_xml_t
xml
);
SWITCH_DECLARE
(
void
)
switch_xml_free
(
switch_xml_t
xml
);
// returns parser error message or empty string if none
///\brief returns parser error message or empty string if none
///\param xml the xml node
///\return the error string or nothing
SWITCH_DECLARE
(
const
char
*
)
switch_xml_error
(
switch_xml_t
xml
);
SWITCH_DECLARE
(
const
char
*
)
switch_xml_error
(
switch_xml_t
xml
);
// returns a new empty switch_xml structure with the given root tag name
///\brief returns a new empty switch_xml structure with the given root tag name
///\param name the name of the new root tag
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_new
(
const
char
*
name
);
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_new
(
const
char
*
name
);
// wrapper for switch_xml_new() that strdup()s name
///\brief wrapper for switch_xml_new() that strdup()s name
///\param name the name of the root
///\return an xml node or NULL
#define switch_xml_new_d(name) switch_xml_set_flag(switch_xml_new(strdup(name)), SWITCH_XML_NAMEM)
#define switch_xml_new_d(name) switch_xml_set_flag(switch_xml_new(strdup(name)), SWITCH_XML_NAMEM)
// Adds a child tag. off is the offset of the child tag relative to the start
///\brief Adds a child tag. off is the offset of the child tag relative to the start
// of the parent tag's character content. Returns the child tag.
///\ of the parent tag's character content. Returns the child tag.
///\param xml the xml node
///\param name the name of the tag
///\param off the offset
///\return an xml node or NULL
switch_xml_t
switch_xml_add_child
(
switch_xml_t
xml
,
const
char
*
name
,
switch_size_t
off
);
switch_xml_t
switch_xml_add_child
(
switch_xml_t
xml
,
const
char
*
name
,
switch_size_t
off
);
// wrapper for switch_xml_add_child() that strdup()s name
///\brief wrapper for switch_xml_add_child() that strdup()s name
///\param xml the xml node
///\param name the name of the child
///\param off the offset
#define switch_xml_add_child_d(xml, name, off) \
#define switch_xml_add_child_d(xml, name, off) \
switch_xml_set_flag(switch_xml_add_child(xml, strdup(name), off), SWITCH_XML_NAMEM)
switch_xml_set_flag(switch_xml_add_child(xml, strdup(name), off), SWITCH_XML_NAMEM)
// sets the character content for the given tag and returns the tag
///\brief sets the character content for the given tag and returns the tag
///\param xml the xml node
///\param txt the text
///\return an xml node or NULL
switch_xml_t
switch_xml_set_txt
(
switch_xml_t
xml
,
const
char
*
txt
);
switch_xml_t
switch_xml_set_txt
(
switch_xml_t
xml
,
const
char
*
txt
);
// wrapper for switch_xml_set_txt() that strdup()s txt
///\brief wrapper for switch_xml_set_txt() that strdup()s txt
///\ sets the character content for the given tag and returns the tag
///\param xml the xml node
///\param txt the text
///\return an xml node or NULL
#define switch_xml_set_txt_d(xml, txt) \
#define switch_xml_set_txt_d(xml, txt) \
switch_xml_set_flag(switch_xml_set_txt(xml, strdup(txt)), SWITCH_XML_TXTM)
switch_xml_set_flag(switch_xml_set_txt(xml, strdup(txt)), SWITCH_XML_TXTM)
// Sets the given tag attribute or adds a new attribute if not found. A value
///\brief Sets the given tag attribute or adds a new attribute if not found. A value
// of NULL will remove the specified attribute.
///\ of NULL will remove the specified attribute.
///\param xml the xml node
///\param name the attribute name
///\param value the attribute value
SWITCH_DECLARE
(
void
)
switch_xml_set_attr
(
switch_xml_t
xml
,
const
char
*
name
,
const
char
*
value
);
SWITCH_DECLARE
(
void
)
switch_xml_set_attr
(
switch_xml_t
xml
,
const
char
*
name
,
const
char
*
value
);
// Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL
///\ Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL
///\param xml the xml node
///\param name the attribute name
///\param value the attribute value
///\return an xml node or NULL
#define switch_xml_set_attr_d(xml, name, value) \
#define switch_xml_set_attr_d(xml, name, value) \
switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(value))
switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(value))
// sets a flag for the given tag and returns the tag
///\brief sets a flag for the given tag and returns the tag
///\param xml the xml node
///\param flag the flag to set
///\return an xml node or NULL
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_set_flag
(
switch_xml_t
xml
,
switch_xml_flag_t
flag
);
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_set_flag
(
switch_xml_t
xml
,
switch_xml_flag_t
flag
);
// removes a tag along with all its subtags
///\brief removes a tag along with all its subtags
///\param xml the xml node
SWITCH_DECLARE
(
void
)
switch_xml_remove
(
switch_xml_t
xml
);
SWITCH_DECLARE
(
void
)
switch_xml_remove
(
switch_xml_t
xml
);
///\brief open the Core xml root
///\param reload if it's is already open close it and open it again as soon as permissable (blocking)
///\return the xml root node or NULL
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_open_root
(
uint8_t
reload
);
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_open_root
(
uint8_t
reload
);
///\brief initilize the core XML backend
///\param pool a memory pool to use
///\return SWITCH_STATUS_SUCCESS if successful
SWITCH_DECLARE
(
switch_status_t
)
switch_xml_init
(
switch_memory_pool_t
*
pool
);
SWITCH_DECLARE
(
switch_status_t
)
switch_xml_init
(
switch_memory_pool_t
*
pool
);
SWITCH_DECLARE
(
switch_status_t
)
switch_xml_destroy
(
void
);
SWITCH_DECLARE
(
switch_status_t
)
switch_xml_destroy
(
void
);
///\brief retrieve the core XML root node
///\return the xml root node
///\note this will cause a readlock on the root until it's released with \see switch_xml_free
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_root
(
void
);
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_root
(
void
);
///\brief locate an xml pointer in the core registry
///\param section the section to look in
///\param tag_name the type of tag in that section
///\param key_name the name of the key
///\param key_value the value of the key
///\param root a pointer to point at the root node
///\param node a pointer to the requested node
///\param params optional URL formatted params to pass to external gateways
///\return SWITCH_STATUS_SUCCESS if successful root and node will be assigned
SWITCH_DECLARE
(
switch_status_t
)
switch_xml_locate
(
char
*
section
,
SWITCH_DECLARE
(
switch_status_t
)
switch_xml_locate
(
char
*
section
,
char
*
tag_name
,
char
*
tag_name
,
char
*
key_name
,
char
*
key_name
,
...
@@ -199,10 +304,21 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate(char *section,
...
@@ -199,10 +304,21 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate(char *section,
switch_xml_t
*
node
,
switch_xml_t
*
node
,
char
*
params
);
char
*
params
);
///\brief open a config in the core registry
///\param file_path the name of the config section e.g. modules.conf
///\param node a pointer to point to the node if it is found
///\param params optional URL formatted params to pass to external gateways
///\return the root xml node associated with the current request or NULL
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_open_cfg
(
char
*
file_path
,
switch_xml_t
*
node
,
char
*
params
);
SWITCH_DECLARE
(
switch_xml_t
)
switch_xml_open_cfg
(
char
*
file_path
,
switch_xml_t
*
node
,
char
*
params
);
///\brief bind a search function to an external gateway
///\param function the search function to bind
///\return SWITCH_STATUS_SUCCESS if successful
///\note gateway functions will be executed in the order they were binded until a success is found else the root registry will be used
SWITCH_DECLARE
(
switch_status_t
)
switch_xml_bind_search_function
(
switch_xml_search_function_t
function
);
SWITCH_DECLARE
(
switch_status_t
)
switch_xml_bind_search_function
(
switch_xml_search_function_t
function
);
END_EXTERN_C
END_EXTERN_C
///\}
#endif // _SWITCH_XML_H
#endif // _SWITCH_XML_H
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论