Attr. encoding for REJECT node: * | attr1_t(2) attr1_val(2) | STATUS attr * [| attr2_t(2) attr2_len(2) attr2_val(2*x)|]? REASON attr (NT) */
| 1017 | * [| attr2_t(2) attr2_len(2) attr2_val(2*x)|]? REASON attr (NT) |
| 1018 | */ |
| 1019 | static inline int encode_reject_attr(xmlNodePtr node, char *node_ptr, char *buf_end) |
| 1020 | { |
| 1021 | xmlAttrPtr attr; |
| 1022 | char *p, *p_orig; |
| 1023 | unsigned char *nr_attr; |
| 1024 | unsigned int nr; |
| 1025 | str val; |
| 1026 | |
| 1027 | nr_attr = &(NR_OF_ATTR(node_ptr)); |
| 1028 | *nr_attr = 0; |
| 1029 | p = p_orig = ATTR_PTR(node_ptr); |
| 1030 | |
| 1031 | FOR_ALL_ATTR(node,attr) { |
| 1032 | (*nr_attr)++; |
| 1033 | /* get the value of the attribute */ |
| 1034 | get_attr_val( attr->name , val, error); |
| 1035 | switch(attr->name[0]) { |
| 1036 | case 'R': case 'r': |
| 1037 | set_attr_type(p, REASON_ATTR, buf_end, error); |
| 1038 | val.len++; /* grab also the /0 */ |
| 1039 | append_str_attr(p, val, buf_end, error); |
| 1040 | break; |
| 1041 | case 'S': case 's': |
| 1042 | set_attr_type(p, STATUS_ATTR, buf_end, error); |
| 1043 | if (str2int(&val,&nr)==-1) { |
| 1044 | /*it was a non numeric value */ |
| 1045 | if (val.len==BUSY_STR_LEN && |
| 1046 | !strncasecmp(val.s,BUSY_STR,val.len)) { |
| 1047 | append_short_attr(p, BUSY_VAL, buf_end, error); |
| 1048 | } else if (val.len==NOTFOUND_STR_LEN && |
| 1049 | !strncasecmp(val.s,NOTFOUND_STR,val.len)) { |
| 1050 | append_short_attr(p, NOTFOUND_VAL, buf_end, error); |
| 1051 | } else if (val.len==ERROR_STR_LEN && |
| 1052 | !strncasecmp(val.s,ERROR_STR,val.len)) { |
| 1053 | append_short_attr(p, ERROR_VAL, buf_end, error); |
| 1054 | } else if (val.len==REJECT_STR_LEN && |
| 1055 | !strncasecmp(val.s,REJECT_STR,val.len)) { |
| 1056 | append_short_attr(p, REJECT_VAL, buf_end, error); |
| 1057 | } else { |
| 1058 | LM_ERR("bad val. <%s> for STATUS\n",val.s); |
| 1059 | goto error; |
| 1060 | } |
| 1061 | } else if (nr<400 || nr>700) { |
| 1062 | LM_ERR("bad code <%d> for STATUS\n",nr); |
| 1063 | goto error; |
| 1064 | } else { |
| 1065 | append_short_attr(p, nr, buf_end, error); |
| 1066 | } |
| 1067 | break; |
| 1068 | default: |
| 1069 | LM_ERR("unknown attribute <%s>\n",attr->name); |
| 1070 | goto error; |
| 1071 | } |
| 1072 | } |
| 1073 | |
| 1074 | return p-p_orig; |
| 1075 | error: |
no test coverage detected