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

Function encode_log_attr

modules/cpl_c/cpl_parser.c:1127–1160  ·  view source on GitHub ↗

Attr. encoding for LOG node: * [| attr1_t(2) attr1_len(2) attr1_val(2*x) |]? NAME attr (NT) * [| attr2_t(2) attr2_len(2) attr2_val(2*x) |]? COMMENT attr (NT) */

Source from the content-addressed store, hash-verified

1125 * [| attr2_t(2) attr2_len(2) attr2_val(2*x) |]? COMMENT attr (NT)
1126 */
1127static inline int encode_log_attr(xmlNodePtr node, char *node_ptr, char *buf_end)
1128{
1129 xmlAttrPtr attr;
1130 char *p, *p_orig;
1131 unsigned char *nr_attr;
1132 str val;
1133
1134 nr_attr = &(NR_OF_ATTR(node_ptr));
1135 *nr_attr = 0;
1136 p = p_orig = ATTR_PTR(node_ptr);
1137
1138 FOR_ALL_ATTR(node,attr) {
1139 (*nr_attr)++;
1140 /* get the value of the attribute */
1141 get_attr_val( attr->name , val, error);
1142 switch (attr->name[0] ) {
1143 case 'n': case 'N':
1144 if (val.len>MAX_NAME_SIZE) val.len=MAX_NAME_SIZE;
1145 set_attr_type(p, NAME_ATTR, buf_end, error);
1146 break;
1147 case 'c': case 'C':
1148 if (val.len>MAX_COMMENT_SIZE) val.len=MAX_COMMENT_SIZE;
1149 set_attr_type(p, COMMENT_ATTR, buf_end, error);
1150 break;
1151 default:
1152 LM_ERR("unknown attribute <%s>\n",attr->name);
1153 goto error;
1154 }
1155 /* be sure there is a \0 at the end of string */
1156 val.s[val.len++]=0;
1157
1158 /* coverity[overflow_sink: FALSE] */
1159 append_str_attr(p,val, buf_end, error);
1160 }
1161
1162 return p-p_orig;
1163error:

Callers 1

encode_nodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected