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

Function parse_reply_codes

ut.c:127–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125
126
127int parse_reply_codes( str *options_reply_codes_str,
128 int **options_reply_codes, int *options_codes_no)
129{
130 str code_str;
131 unsigned int code;
132 int index= 0;
133 char* sep1, *sep2, *aux;
134
135 *options_reply_codes = (int*)pkg_malloc(
136 options_reply_codes_str->len/3 * sizeof(int));
137
138 if(*options_reply_codes== NULL) {
139 LM_ERR("no more memory\n");
140 return -1;
141 }
142
143 sep1 = options_reply_codes_str->s;
144 sep2 = strchr(options_reply_codes_str->s, ',');
145
146 while(sep2 != NULL) {
147
148 aux = sep2;
149 while(*sep1 == ' ')
150 sep1++;
151
152 sep2--;
153 while(*sep2 == ' ')
154 sep2--;
155
156 code_str.s = sep1;
157 code_str.len = sep2-sep1+1;
158
159 if(str2int(&code_str, &code)< 0) {
160 LM_ERR("Bad format - not am integer [%.*s]\n",
161 code_str.len, code_str.s);
162 return -1;
163 }
164 if(code<100 ||code > 700) {
165 LM_ERR("Wrong number [%d]- must be a valid SIP reply code\n",code);
166 return -1;
167 }
168 (*options_reply_codes)[index] = code;
169 index++;
170
171 sep1 = aux +1;
172 sep2 = strchr(sep1, ',');
173 }
174
175 while(*sep1 == ' ')
176 sep1++;
177 sep2 = options_reply_codes_str->s+options_reply_codes_str->len -1;
178 while(*sep2 == ' ')
179 sep2--;
180
181 code_str.s = sep1;
182 code_str.len = sep2 -sep1 +1;
183 if(str2int(&code_str, &code)< 0) {
184 LM_ERR("Bad format - not am integer [%.*s]\n",

Callers 3

mod_initFunction · 0.85
mod_initFunction · 0.85
dr_initFunction · 0.85

Calls 1

str2intFunction · 0.85

Tested by

no test coverage detected