Asterisk - The Open Source Telephony Project GIT-master-f36a736
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 <mmichelson@digium.com>
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 */
63void 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 * \param notify_early_inuse_ringing
74 */
75void ast_sip_presence_exten_state_to_str(int state, char **statestring,
76 char **pidfstate, char **pidfnote, enum ast_sip_pidf_state *local_state,
77 unsigned int notify_early_inuse_ringing);
78
79/*!
80 * \brief Create XML attribute
81 *
82 * \param pool Allocation pool
83 * \param node Node to add attribute to
84 * \param name The attribute name
85 * \param value The attribute value
86 *
87 * \return The created attribute
88 */
89pj_xml_attr *ast_sip_presence_xml_create_attr(pj_pool_t *pool,
90 pj_xml_node *node, const char *name, const char *value);
91
92/*!
93 * \brief Create XML node
94 *
95 * \param pool Allocation pool
96 * \param parent Optional node that will be parent to the created node
97 * \param name The name for the new node
98 * \return The created node
99 */
100pj_xml_node *ast_sip_presence_xml_create_node(pj_pool_t *pool,
101 pj_xml_node *parent, const char* name);
102
103/*!
104 * \brief Find an attribute within a given node
105 *
106 * Given a starting node, this will find an attribute that belongs
107 * to a specific node. If the node does not exist, it will be created
108 * under the passed-in parent. If the attribute does not exist, then
109 * it will be created on the node with an empty string as its value.
110 *
111 * \param pool Allocation pool
112 * \param parent Starting node for search
113 * \param node_name Name of node where to find attribute
114 * \param attr_name Name of attribute to find
115 * \param[out] node Node that was found or created
116 * \param[out] attr Attribute that was found or created
117 */
118void ast_sip_presence_xml_find_node_attr(pj_pool_t* pool,
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 */
static int input(yyscan_t yyscanner)
Definition: ast_expr2f.c:1570
static const char name[]
Definition: format_mp3.c:68
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
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
@ NOTIFY_CLOSED
@ NOTIFY_INUSE
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
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
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
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
Definition: test_heap.c:38
int value
Definition: syslog.c:37