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

Function parse_pv_name_s

modules/sql_cacher/sql_cacher.c:1849–1894  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1847}
1848
1849static int parse_pv_name_s(pv_name_fix_t *pv_name, str *name_s)
1850{
1851 char *p1 = NULL, *p2 = NULL;
1852 char last;
1853
1854#define PARSE_TOKEN(_ptr1, _ptr2, type, delim) \
1855 do { \
1856 (_ptr2) = memchr((_ptr1), (delim), \
1857 name_s->len - ((_ptr1) - name_s->s) + 1); \
1858 if (!(_ptr2)) { \
1859 LM_ERR("Invalid syntax for pvar name\n"); \
1860 return -1; \
1861 } \
1862 int _prev_len = pv_name->type.len; \
1863 pv_name->type.len = (_ptr2) - (_ptr1); \
1864 if (!pv_name->type.s) { \
1865 pv_name->type.s = pkg_malloc(pv_name->type.len); \
1866 if (!pv_name->type.s) { \
1867 LM_ERR("No more pkg memory\n"); \
1868 return -1; \
1869 } \
1870 memcpy(pv_name->type.s, (_ptr1), pv_name->type.len); \
1871 } else if (memcmp(pv_name->type.s, (_ptr1), pv_name->type.len)) { \
1872 if (_prev_len != pv_name->type.len) { \
1873 pv_name->type.s = pkg_realloc(pv_name->type.s, pv_name->type.len); \
1874 if (!pv_name->type.s) { \
1875 LM_ERR("No more pkg memory\n"); \
1876 return -1; \
1877 } \
1878 } \
1879 memcpy(pv_name->type.s, (_ptr1), pv_name->type.len); \
1880 } \
1881 } while (0)
1882
1883 last = name_s->s[name_s->len];
1884 p1 = name_s->s;
1885 PARSE_TOKEN(p1, p2, id, pvar_delimiter.s[0]);
1886 p1 = p2 + 1;
1887 PARSE_TOKEN(p1, p2, col, pvar_delimiter.s[0]);
1888 p1 = p2 + 1;
1889 PARSE_TOKEN(p1, p2, key, last);
1890
1891#undef PARSE_TOKEN
1892
1893 return 0;
1894}
1895
1896int pv_parse_name(pv_spec_p sp, const str *in)
1897{

Callers 2

pv_parse_nameFunction · 0.85
pv_get_sql_cached_valueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected