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

Function read_pair

modules/dialog/dlg_db_handler.c:335–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333
334
335static inline char* read_pair(char *b, char *end, str *name, int_str *val,
336 int *type)
337{
338 str vals;
339
340 /* read name */
341 name->s = b;
342 while (b<end) {
343 if (*b=='|' || *b=='#')
344 break;
345 else if (*b == '\\')
346 b++;
347 b++;
348 }
349 if (b>=end) return NULL;
350 if (*b=='|') goto skip;
351 name->len = b - name->s;
352 if (name->len==0) goto skip;
353 strip_esc(name);
354 LM_DBG("-----read name <%.*s>(%d)\n",name->len,name->s,name->len);
355
356 /* read # */
357 b++;
358
359 if (b>=end) return NULL;
360
361 if ((*b != '0' + DLG_VAL_TYPE_STR) && (*b != '0' + DLG_VAL_TYPE_INT))
362 /* unexpected type char */
363 return NULL;
364 *type = *b - '0';
365
366 /* read type char */
367 b++;
368
369 if (b>=end) return NULL;
370 if (*b!='#') return NULL;
371
372 /* read # */
373 b++;
374
375 /* read value */
376 vals.s = b;
377 while (b<end) {
378 if (*b=='|' || *b=='#')
379 break;
380 else if (*b == '\\')
381 b++;
382 b++;
383 }
384
385 vals.len = b - vals.s;
386 if (vals.len==0) vals.s = 0;
387
388 if (b>=end) return NULL;
389 if (*b=='#') goto skip;
390
391 if (*type == DLG_VAL_TYPE_STR) {
392 strip_esc(&vals);

Callers 2

read_dialog_varsFunction · 0.85
read_dialog_profilesFunction · 0.85

Calls 2

strip_escFunction · 0.85
str2sintFunction · 0.85

Tested by

no test coverage detected