Asterisk - The Open Source Telephony Project  18.5.0
res_pjsip_presence_xml.h
Go to the documentation of this file.
1 /*
2  * asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2014, Digium, Inc.
5  *
6  * Mark Michelson <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*!
20  * \brief Length of the XML prolog when printing presence or other XML in PJSIP.
21  *
22  * When calling any variant of pj_xml_print(), the documentation
23  * claims that it will return -1 if the provided buffer is not
24  * large enough. However, if the XML prolog is requested to be
25  * printed and the buffer is not large enough, then it will
26  * return -1 only if the buffer is not large enough to hold the
27  * XML prolog or return the length of the XML prolog on failure
28  * instead of -1.
29  *
30  * This constant is useful to check against when trying to determine
31  * if printing XML succeeded or failed.
32  */
33 #ifndef ASTERISK_PJSIP_PRESENCE_XML_H
34 #define ASTERISK_PJSIP_PRESENCE_XML_H
35 
36 #define AST_PJSIP_XML_PROLOG_LEN 39
37 
38 /*!
39  * PIDF state
40  */
42  /*! Device is not in use */
44  /*! Device is in use or ringing */
46  /*! Device is unavailable, on hold, or busy */
48 };
49 
50 /*!
51  * \brief Replace offensive XML characters with XML entities
52  *
53  * " = &quot;
54  * < = &lt;
55  * > = &gt;
56  * ' = &apos;
57  * & = &amp;
58  *
59  * \param input String to sanitize
60  * \param[out] output Sanitized string
61  * \param len Size of output buffer
62  */
63 void ast_sip_sanitize_xml(const char *input, char *output, size_t len);
64 
65 /*!
66  * \brief Convert extension state to relevant PIDF strings
67  *
68  * \param state The extension state
69  * \param[out] statestring
70  * \param[out] pidfstate
71  * \param[out] pidfnote
72  * \param[out] local_state
73  */
74 void ast_sip_presence_exten_state_to_str(int state, char **statestring,
75  char **pidfstate, char **pidfnote, enum ast_sip_pidf_state *local_state,
76  unsigned int notify_early_inuse_ringing);
77 
78 /*!
79  * \brief Create XML attribute
80  *
81  * \param pool Allocation pool
82  * \param node Node to add attribute to
83  * \param name The attribute name
84  * \param value The attribute value
85  *
86  * \return The created attribute
87  */
88 pj_xml_attr *ast_sip_presence_xml_create_attr(pj_pool_t *pool,
89  pj_xml_node *node, const char *name, const char *value);
90 
91 /*!
92  * \brief Create XML node
93  *
94  * \param pool Allocation pool
95  * \param parent Optional node that will be parent to the created node
96  * \param name The name for the new node
97  * \return The created node
98  */
99 pj_xml_node *ast_sip_presence_xml_create_node(pj_pool_t *pool,
100  pj_xml_node *parent, const char* name);
101 
102 /*!
103  * \brief Find an attribute within a given node
104  *
105  * Given a starting node, this will find an attribute that belongs
106  * to a specific node. If the node does not exist, it will be created
107  * under the passed-in parent. If the attribute does not exist, then
108  * it will be created on the node with an empty string as its value.
109  *
110  * \param pool Allocation pool
111  * \param parent Starting node for search
112  * \param node_name Name of node where to find attribute
113  * \param attr_name Name of attribute to find
114  * \param[out] node Node that was found or created
115  * \param[out] attr Attribute that was found or created
116  * \return The found attribute
117  */
119  pj_xml_node *parent, const char *node_name, const char *attr_name,
120  pj_xml_node **node, pj_xml_attr **attr);
121 
122 #endif /* ASTERISK_PJSIP_PRESENCE_XML_H */
Definition: test_heap.c:38
static pj_pool_t * pool
Global memory pool for configuration and timers.
pj_xml_attr * ast_sip_presence_xml_create_attr(pj_pool_t *pool, pj_xml_node *node, const char *name, const char *value)
Create XML attribute.
Definition: presence_xml.c:140
int value
Definition: syslog.c:37
static int input(yyscan_t yyscanner)
Definition: ast_expr2f.c:1584
void ast_sip_presence_exten_state_to_str(int state, char **statestring, char **pidfstate, char **pidfnote, enum ast_sip_pidf_state *local_state, unsigned int notify_early_inuse_ringing)
Convert extension state to relevant PIDF strings.
Definition: presence_xml.c:84
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static const char name[]
Definition: cdr_mysql.c:74
pj_xml_node * ast_sip_presence_xml_create_node(pj_pool_t *pool, pj_xml_node *parent, const char *name)
Create XML node.
Definition: presence_xml.c:152
void ast_sip_sanitize_xml(const char *input, char *output, size_t len)
Replace offensive XML characters with XML entities.
Definition: presence_xml.c:29
ast_sip_pidf_state
void ast_sip_presence_xml_find_node_attr(pj_pool_t *pool, pj_xml_node *parent, const char *node_name, const char *attr_name, pj_xml_node **node, pj_xml_attr **attr)
Find an attribute within a given node.
Definition: presence_xml.c:172