Attr. encoding for PRIORITY node: * | attr1_t(2) attr1_val(2) | LESS/GREATER/EQUAL attr * [| attr2_t(2) attr2_len(2) attr_val(2*x) |]? PRIOSTR attr (NT) */
| 468 | * [| attr2_t(2) attr2_len(2) attr_val(2*x) |]? PRIOSTR attr (NT) |
| 469 | */ |
| 470 | static inline int encode_priority_attr(xmlNodePtr node, char *node_ptr, char *buf_end) |
| 471 | { |
| 472 | xmlAttrPtr attr; |
| 473 | char *p, *p_orig; |
| 474 | unsigned char *nr_attr; |
| 475 | str val; |
| 476 | |
| 477 | nr_attr = &(NR_OF_ATTR(node_ptr)); |
| 478 | *nr_attr = 0; |
| 479 | p = p_orig = ATTR_PTR(node_ptr); |
| 480 | |
| 481 | FOR_ALL_ATTR(node,attr) { |
| 482 | (*nr_attr)++; |
| 483 | /* attribute's name */ |
| 484 | switch(attr->name[0]) { |
| 485 | case 'L': case 'l': |
| 486 | set_attr_type(p, LESS_ATTR, buf_end, error); |
| 487 | break; |
| 488 | case 'G': case 'g': |
| 489 | set_attr_type(p, GREATER_ATTR, buf_end, error); |
| 490 | break; |
| 491 | case 'E': case 'e': |
| 492 | set_attr_type(p, EQUAL_ATTR, buf_end, error); |
| 493 | break; |
| 494 | default: |
| 495 | LM_ERR("unknown attribute <%s>\n",attr->name); |
| 496 | goto error; |
| 497 | } |
| 498 | /* attribute's encoded value */ |
| 499 | get_attr_val( attr->name , val, error); |
| 500 | if ( val.len==EMERGENCY_STR_LEN && |
| 501 | !strncasecmp(val.s,EMERGENCY_STR,val.len) ) { |
| 502 | append_short_attr(p, EMERGENCY_VAL, buf_end, error); |
| 503 | } else if ( val.len==URGENT_STR_LEN && |
| 504 | !strncasecmp(val.s,URGENT_STR,val.len) ) { |
| 505 | append_short_attr(p, URGENT_VAL, buf_end, error); |
| 506 | } else if ( val.len==NORMAL_STR_LEN && |
| 507 | !strncasecmp(val.s,NORMAL_STR,val.len) ) { |
| 508 | append_short_attr(p, NORMAL_VAL, buf_end, error); |
| 509 | } else if ( val.len==NON_URGENT_STR_LEN && |
| 510 | !strncasecmp(val.s,NON_URGENT_STR,val.len) ) { |
| 511 | append_short_attr(p, NON_URGENT_VAL, buf_end, error); |
| 512 | } else { |
| 513 | append_short_attr(p, UNKNOWN_PRIO_VAL, buf_end, error); |
| 514 | set_attr_type(p, PRIOSTR_ATTR, buf_end, error); |
| 515 | val.len++; /* append \0 also */ |
| 516 | append_str_attr(p, val, buf_end, error); |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | return p-p_orig; |
| 521 | error: |