dect
/
asterisk
Archived
13
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
asterisk/include/asterisk/xml.h

217 lines
6.3 KiB
C
Raw Permalink Normal View History

/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2008, Eliel C. Sardanons (LU1ALY) <eliels@gmail.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
#ifndef _ASTERISK_XML_H
#define _ASTERISK_XML_H
/*! \file
* \brief Asterisk XML abstraction layer
*/
struct ast_xml_node;
struct ast_xml_doc;
/*!
* \brief Initialize the XML library implementation.
* This function is used to setup everything needed
* to start working with the xml implementation.
* \retval 0 On success.
* \retval 1 On error.
*/
int ast_xml_init(void);
/*!
* \brief Cleanup library allocated global data.
* \retval 0 On success.
* \retval 1 On error.
*/
int ast_xml_finish(void);
/*!
* \brief Open an XML document.
* \param filename Document path.
* \retval NULL on error.
* \retval The ast_xml_doc reference to the open document.
*/
struct ast_xml_doc *ast_xml_open(char *filename);
/*!
* \brief Create a XML document.
* \retval NULL on error.
* \retval non-NULL The allocated document structure.
*/
struct ast_xml_doc *ast_xml_new(void);
/*!
* \brief Create a XML node.
* \param name The name of the node to be created.
* \retval NULL on error.
* \retval non-NULL The allocated node structe.
*/
struct ast_xml_node *ast_xml_new_node(const char *name);
/*!
* \brief Add a child node inside a passed parent node.
* \param parent The pointer of the parent node.
* \param child_name The name of the child node to add.
* \retval NULL on error.
* \retval non-NULL The created child node pointer.
*/
struct ast_xml_node *ast_xml_new_child(struct ast_xml_node *parent, const char *child_name);
/*!
* \brief Add a child node, to a specified parent node.
* \param parent Where to add the child node.
* \param child The child node to add.
* \retval NULL on error.
* \retval non-NULL The add child node on success.
*/
struct ast_xml_node *ast_xml_add_child(struct ast_xml_node *parent, struct ast_xml_node *child);
/*!
* \brief Close an already open document and free the used
* structure.
* \retval doc The document reference.
*/
void ast_xml_close(struct ast_xml_doc *doc);
Merge Call completion support into trunk. From Reviewboard: CCSS stands for Call Completion Supplementary Services. An admittedly out-of-date overview of the architecture can be found in the file doc/CCSS_architecture.pdf in the CCSS branch. Off the top of my head, the big differences between what is implemented and what is in the document are as follows: 1. We did not end up modifying the Hangup application at all. 2. The document states that a single call completion monitor may be used across multiple calls to the same device. This proved to not be such a good idea when implementing protocol-specific monitors, and so we ended up using one monitor per-device per-call. 3. There are some configuration options which were conceived after the document was written. These are documented in the ccss.conf.sample that is on this review request. For some basic understanding of terminology used throughout this code, see the ccss.tex document that is on this review. This implements CCBS and CCNR in several flavors. First up is a "generic" implementation, which can work over any channel technology provided that the channel technology can accurately report device state. Call completion is requested using the dialplan application CallCompletionRequest and can be canceled using CallCompletionCancel. Device state subscriptions are used in order to monitor the state of called parties. Next, there is a SIP-specific implementation of call completion. This method uses the methods outlined in draft-ietf-bliss-call-completion-06 to implement call completion using SIP signaling. There are a few things to note here: * The agent/monitor terminology used throughout Asterisk sometimes is the reverse of what is defined in the referenced draft. * Implementation of the draft required support for SIP PUBLISH. I attempted to write this in a generic-enough fashion such that if someone were to want to write PUBLISH support for other event packages, such as dialog-state or presence, most of the effort would be in writing callbacks specific to the event package. * A subportion of supporting PUBLISH reception was that we had to implement a PIDF parser. The PIDF support added is a bit minimal. I first wrote a validation routine to ensure that the PIDF document is formatted properly. The rest of the PIDF reading is done in-line in the call-completion-specific PUBLISH-handling code. In other words, while there is PIDF support here, it is not in any state where it could easily be applied to other event packages as is. Finally, there are a variety of ISDN-related call completion protocols supported. These were written by Richard Mudgett, and as such I can't really say much about their implementation. There are notes in the CHANGES file that indicate the ISDN protocols over which call completion is supported. Review: https://reviewboard.asterisk.org/r/523 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@256528 f38db490-d61c-443f-a65b-d21fe96a405b
2010-04-09 15:31:32 +00:00
/*! \brief Open an XML document that resides in memory.
* \param buffer The address where the document is stored
* \param size The number of bytes in the document
Merge Call completion support into trunk. From Reviewboard: CCSS stands for Call Completion Supplementary Services. An admittedly out-of-date overview of the architecture can be found in the file doc/CCSS_architecture.pdf in the CCSS branch. Off the top of my head, the big differences between what is implemented and what is in the document are as follows: 1. We did not end up modifying the Hangup application at all. 2. The document states that a single call completion monitor may be used across multiple calls to the same device. This proved to not be such a good idea when implementing protocol-specific monitors, and so we ended up using one monitor per-device per-call. 3. There are some configuration options which were conceived after the document was written. These are documented in the ccss.conf.sample that is on this review request. For some basic understanding of terminology used throughout this code, see the ccss.tex document that is on this review. This implements CCBS and CCNR in several flavors. First up is a "generic" implementation, which can work over any channel technology provided that the channel technology can accurately report device state. Call completion is requested using the dialplan application CallCompletionRequest and can be canceled using CallCompletionCancel. Device state subscriptions are used in order to monitor the state of called parties. Next, there is a SIP-specific implementation of call completion. This method uses the methods outlined in draft-ietf-bliss-call-completion-06 to implement call completion using SIP signaling. There are a few things to note here: * The agent/monitor terminology used throughout Asterisk sometimes is the reverse of what is defined in the referenced draft. * Implementation of the draft required support for SIP PUBLISH. I attempted to write this in a generic-enough fashion such that if someone were to want to write PUBLISH support for other event packages, such as dialog-state or presence, most of the effort would be in writing callbacks specific to the event package. * A subportion of supporting PUBLISH reception was that we had to implement a PIDF parser. The PIDF support added is a bit minimal. I first wrote a validation routine to ensure that the PIDF document is formatted properly. The rest of the PIDF reading is done in-line in the call-completion-specific PUBLISH-handling code. In other words, while there is PIDF support here, it is not in any state where it could easily be applied to other event packages as is. Finally, there are a variety of ISDN-related call completion protocols supported. These were written by Richard Mudgett, and as such I can't really say much about their implementation. There are notes in the CHANGES file that indicate the ISDN protocols over which call completion is supported. Review: https://reviewboard.asterisk.org/r/523 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@256528 f38db490-d61c-443f-a65b-d21fe96a405b
2010-04-09 15:31:32 +00:00
* \retval NULL on error.
* \retval The ast_xml_doc reference to the open document.
*/
struct ast_xml_doc *ast_xml_read_memory(char *buffer, size_t size);
/*!
* \brief Specify the root node of a XML document.
* \param doc The document pointer.
* \param node A pointer to the node we want to set as root node.
*/
void ast_xml_set_root(struct ast_xml_doc *doc, struct ast_xml_node *node);
/*!
* \brief Get the document root node.
* \param doc Document reference
* \retval NULL on error
* \retval The root node on success.
*/
struct ast_xml_node *ast_xml_get_root(struct ast_xml_doc *doc);
/*!
* \brief Free node
* \param node Node to be released.
*/
void ast_xml_free_node(struct ast_xml_node *node);
/*!
* \brief Free an attribute returned by ast_xml_get_attribute()
* \param attribute pointer to be freed.
*/
void ast_xml_free_attr(const char *attribute);
/*!
* \brief Get the document based on a node.
* \param node A node that is part of the dom.
* \returns The dom pointer where this node resides.
*/
struct ast_xml_doc *ast_xml_get_doc(struct ast_xml_node *node);
/*!
* \brief Free a content element that was returned by ast_xml_get_text()
* \param text text to be freed.
*/
void ast_xml_free_text(const char *text);
/*!
* \brief Get a node attribute by name
* \param node Node where to search the attribute.
* \param attrname Attribute name.
* \retval NULL on error
* \retval The attribute value on success.
*/
const char *ast_xml_get_attribute(struct ast_xml_node *node, const char *attrname);
/*!
* \brief Set an attribute to a node.
* \param node In which node we want to insert the attribute.
* \param name The attribute name.
* \param value The attribute value.
* \retval 0 on success.
* \retval -1 on error.
*/
int ast_xml_set_attribute(struct ast_xml_node *node, const char *name, const char *value);
/*!
* \brief Find a node element by name.
* \param root_node This is the node starting point.
* \param name Node name to find.
* \param attrname attribute name to match (if NULL it won't be matched).
* \param attrvalue attribute value to match (if NULL it won't be matched).
* \retval NULL if not found.
* \retval The node on success.
*/
struct ast_xml_node *ast_xml_find_element(struct ast_xml_node *root_node, const char *name, const char *attrname, const char *attrvalue);
Merge Call completion support into trunk. From Reviewboard: CCSS stands for Call Completion Supplementary Services. An admittedly out-of-date overview of the architecture can be found in the file doc/CCSS_architecture.pdf in the CCSS branch. Off the top of my head, the big differences between what is implemented and what is in the document are as follows: 1. We did not end up modifying the Hangup application at all. 2. The document states that a single call completion monitor may be used across multiple calls to the same device. This proved to not be such a good idea when implementing protocol-specific monitors, and so we ended up using one monitor per-device per-call. 3. There are some configuration options which were conceived after the document was written. These are documented in the ccss.conf.sample that is on this review request. For some basic understanding of terminology used throughout this code, see the ccss.tex document that is on this review. This implements CCBS and CCNR in several flavors. First up is a "generic" implementation, which can work over any channel technology provided that the channel technology can accurately report device state. Call completion is requested using the dialplan application CallCompletionRequest and can be canceled using CallCompletionCancel. Device state subscriptions are used in order to monitor the state of called parties. Next, there is a SIP-specific implementation of call completion. This method uses the methods outlined in draft-ietf-bliss-call-completion-06 to implement call completion using SIP signaling. There are a few things to note here: * The agent/monitor terminology used throughout Asterisk sometimes is the reverse of what is defined in the referenced draft. * Implementation of the draft required support for SIP PUBLISH. I attempted to write this in a generic-enough fashion such that if someone were to want to write PUBLISH support for other event packages, such as dialog-state or presence, most of the effort would be in writing callbacks specific to the event package. * A subportion of supporting PUBLISH reception was that we had to implement a PIDF parser. The PIDF support added is a bit minimal. I first wrote a validation routine to ensure that the PIDF document is formatted properly. The rest of the PIDF reading is done in-line in the call-completion-specific PUBLISH-handling code. In other words, while there is PIDF support here, it is not in any state where it could easily be applied to other event packages as is. Finally, there are a variety of ISDN-related call completion protocols supported. These were written by Richard Mudgett, and as such I can't really say much about their implementation. There are notes in the CHANGES file that indicate the ISDN protocols over which call completion is supported. Review: https://reviewboard.asterisk.org/r/523 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@256528 f38db490-d61c-443f-a65b-d21fe96a405b
2010-04-09 15:31:32 +00:00
struct ast_xml_ns *ast_xml_find_namespace(struct ast_xml_doc *doc, struct ast_xml_node *node, const char *ns_name);
const char *ast_xml_get_ns_href(struct ast_xml_ns *ns);
/*!
* \brief Get an element content string.
* \param node Node from where to get the string.
* \retval NULL on error.
* \retval The text content of node.
*/
const char *ast_xml_get_text(struct ast_xml_node *node);
/*!
* \brief Set an element content string.
* \param node Node from where to set the content string.
* \param content The text to insert in the node.
*/
void ast_xml_set_text(struct ast_xml_node *node, const char *content);
/*!
* \brief Get the name of a node. */
const char *ast_xml_node_get_name(struct ast_xml_node *node);
/*!
* \brief Get the node's children. */
struct ast_xml_node *ast_xml_node_get_children(struct ast_xml_node *node);
/*!
* \brief Get the next node in the same level. */
struct ast_xml_node *ast_xml_node_get_next(struct ast_xml_node *node);
/*!
* \brief Get the previous node in the same leve. */
struct ast_xml_node *ast_xml_node_get_prev(struct ast_xml_node *node);
/*!
* \brief Get the parent of a specified node. */
struct ast_xml_node *ast_xml_node_get_parent(struct ast_xml_node *node);
/*!
* \brief Dump the specified document to a file. */
int ast_xml_doc_dump_file(FILE *output, struct ast_xml_doc *doc);
/* Features using ast_xml_ */
#ifdef HAVE_LIBXML2
#define AST_XML_DOCS
#endif
#endif /* _ASTERISK_XML_H */