22 #include <pjsip_simple.h>
27 #include "asterisk/res_pjsip_presence_xml.h"
29 void ast_sip_sanitize_xml(
const char *input,
char *output,
size_t len)
33 size_t remaining = len - 1;
37 while ((break_point = strpbrk(copy,
"<>\"&'\n\r")) && remaining) {
38 char to_escape = *break_point;
41 strncat(output, copy, remaining);
48 remaining = len - strlen(output) - 1;
52 strncat(output,
"<", remaining);
55 strncat(output,
">", remaining);
58 strncat(output,
""", remaining);
61 strncat(output,
"&", remaining);
64 strncat(output,
"'", remaining);
67 strncat(output,
" ", remaining);
70 strncat(output,
" ", remaining);
74 copy = break_point + 1;
75 remaining = len - strlen(output) - 1;
79 if (*copy && remaining) {
80 strncat(output, copy, remaining);
84 void ast_sip_presence_exten_state_to_str(
int state,
char **statestring,
char **pidfstate,
85 char **pidfnote,
enum ast_sip_pidf_state *local_state,
86 unsigned int notify_early_inuse_ringing)
90 *statestring =
"early";
91 *local_state = NOTIFY_INUSE;
92 *pidfstate =
"on-the-phone";
93 *pidfnote =
"Ringing";
96 if (notify_early_inuse_ringing) {
97 *statestring =
"early";
99 *statestring =
"confirmed";
101 *local_state = NOTIFY_INUSE;
102 *pidfstate =
"on-the-phone";
103 *pidfnote =
"Ringing";
106 *statestring =
"confirmed";
107 *local_state = NOTIFY_INUSE;
108 *pidfstate =
"on-the-phone";
109 *pidfnote =
"On the phone";
112 *statestring =
"confirmed";
113 *local_state = NOTIFY_INUSE;
114 *pidfstate =
"on-the-phone";
115 *pidfnote =
"On the phone";
118 *statestring =
"terminated";
119 *local_state = NOTIFY_CLOSED;
121 *pidfnote =
"Unavailable";
124 *statestring =
"confirmed";
125 *local_state = NOTIFY_INUSE;
126 *pidfstate =
"on-the-phone";
127 *pidfnote =
"On hold";
132 *statestring =
"terminated";
133 *local_state = NOTIFY_OPEN;
140 pj_xml_attr *ast_sip_presence_xml_create_attr(pj_pool_t *
pool,
141 pj_xml_node *
node,
const char *name,
const char *value)
143 pj_xml_attr *attr = PJ_POOL_ALLOC_T(pool, pj_xml_attr);
145 pj_strdup2(pool, &attr->name, name);
146 pj_strdup2(pool, &attr->value, value);
148 pj_xml_add_attr(node, attr);
152 pj_xml_node *ast_sip_presence_xml_create_node(pj_pool_t *
pool,
153 pj_xml_node *parent,
const char* name)
155 pj_xml_node *
node = PJ_POOL_ALLOC_T(pool, pj_xml_node);
157 pj_list_init(&node->attr_head);
158 pj_list_init(&node->node_head);
160 pj_strdup2(pool, &node->name, name);
162 node->content.ptr = NULL;
163 node->content.slen = 0;
166 pj_xml_add_node(parent, node);
172 void ast_sip_presence_xml_find_node_attr(pj_pool_t* pool,
173 pj_xml_node *parent,
const char *node_name,
const char *attr_name,
174 pj_xml_node **node, pj_xml_attr **attr)
178 if (!(*node = pj_xml_find_node(parent, pj_cstr(&name, node_name)))) {
179 *node = ast_sip_presence_xml_create_node(pool, parent, node_name);
182 if (!(*attr = pj_xml_find_attr(*node, pj_cstr(&name, attr_name), NULL))) {
183 *attr = ast_sip_presence_xml_create_attr(pool, *node, attr_name,
"");
Asterisk main include file. File version handling, generic pbx functions.
static pj_pool_t * pool
Global memory pool for configuration and timers.
static int copy(char *infile, char *outfile)
Utility function to copy a file.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Core PBX routines and definitions.
Asterisk module definitions.