MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / encode_node

Function encode_node

modules/cpl_c/cpl_parser.c:1278–1467  ·  view source on GitHub ↗

Returns : -1 - error * >0 - subtree size of the given node */

Source from the content-addressed store, hash-verified

1276 * >0 - subtree size of the given node
1277 */
1278int encode_node( xmlNodePtr node, char *p, char *p_end)
1279{
1280 xmlNodePtr kid;
1281 unsigned short sub_tree_size;
1282 int attr_size;
1283 int kid_size;
1284 int foo;
1285
1286 /* counting the kids */
1287 for(kid=node->children,foo=0;kid;kid=kid->next)
1288 if (kid->type==XML_ELEMENT_NODE) foo++;
1289 check_overflow(p,GET_NODE_SIZE(foo),p_end,error);
1290 NR_OF_KIDS(p) = foo;
1291
1292 /* size of the encoded attributes */
1293 attr_size = 0;
1294
1295 /* init the number of attributes */
1296 NR_OF_ATTR(p) = 0;
1297
1298 /* encode node name */
1299 switch (node->name[0]) {
1300 case 'a':case 'A':
1301 switch (node->name[7]) {
1302 case 0:
1303 NODE_TYPE(p) = ADDRESS_NODE;
1304 attr_size = encode_address_attr( node, p, p_end);
1305 break;
1306 case '-':
1307 NODE_TYPE(p) = ADDRESS_SWITCH_NODE;
1308 attr_size = encode_address_switch_attr( node, p, p_end);
1309 break;
1310 default:
1311 NODE_TYPE(p) = ANCILLARY_NODE;
1312 break;
1313 }
1314 break;
1315 case 'B':case 'b':
1316 NODE_TYPE(p) = BUSY_NODE;
1317 break;
1318 case 'c':case 'C':
1319 NODE_TYPE(p) = CPL_NODE;
1320 break;
1321 case 'd':case 'D':
1322 NODE_TYPE(p) = DEFAULT_NODE;
1323 break;
1324 case 'f':case 'F':
1325 NODE_TYPE(p) = FAILURE_NODE;
1326 break;
1327 case 'i':case 'I':
1328 NODE_TYPE(p) = INCOMING_NODE;
1329 break;
1330 case 'l':case 'L':
1331 switch (node->name[2]) {
1332 case 'g':case 'G':
1333 NODE_TYPE(p) = LOG_NODE;
1334 attr_size = encode_log_attr( node, p, p_end);
1335 break;

Callers 1

encodeCPLFunction · 0.85

Calls 15

encode_address_attrFunction · 0.85
encode_log_attrFunction · 0.85
encode_lookup_attrFunction · 0.85
encode_location_attrFunction · 0.85
encode_lang_attrFunction · 0.85
encode_mail_attrFunction · 0.85
encode_proxy_attrFunction · 0.85
encode_priority_attrFunction · 0.85
encode_reject_attrFunction · 0.85
encode_rmvloc_attrFunction · 0.85
encode_redirect_attrFunction · 0.85

Tested by

no test coverage detected