| 2271 | static int _rld_ver; |
| 2272 | static struct sip_msg *_sip_msg; |
| 2273 | static int decode_kv2avps(const str *key, const str *value) |
| 2274 | { |
| 2275 | static pv_value_t val_null = {str_init("<null>"), 0, PV_VAL_STR}; |
| 2276 | const pv_name_fix_t *col; |
| 2277 | pvname_list_t *avp; |
| 2278 | pv_value_t val; |
| 2279 | str str_res; |
| 2280 | int rc, int_res; |
| 2281 | |
| 2282 | LM_DBG("called for key %.*s, val: %.*s\n", key->len, key->s, value->len, value->s); |
| 2283 | |
| 2284 | /* skip internal keys (not part of the SQL table dataset) */ |
| 2285 | if (key->s[_selected_cols->c_entry->id.len] == '_') |
| 2286 | return -1; |
| 2287 | |
| 2288 | /* each column offset is pre-computed; fill in the AVPs ASAP! */ |
| 2289 | for (col = _selected_cols, avp = _out_avps; col->c_entry; |
| 2290 | col++, avp = avp->next) { |
| 2291 | |
| 2292 | str_res = STR_NULL; |
| 2293 | int_res = 0; |
| 2294 | rc = cdb_val_decode(col, value, _rld_ver, &str_res, &int_res); |
| 2295 | switch (rc) { |
| 2296 | case 0: |
| 2297 | if (is_str_column(col)) { |
| 2298 | val.rs = str_res; |
| 2299 | val.flags = PV_VAL_STR; |
| 2300 | } else { |
| 2301 | val.ri = int_res; |
| 2302 | val.flags = PV_VAL_INT|PV_TYPE_INT; |
| 2303 | } |
| 2304 | break; |
| 2305 | |
| 2306 | case 1: |
| 2307 | val = val_null; |
| 2308 | break; |
| 2309 | |
| 2310 | default: |
| 2311 | LM_ERR("failed to decode key: '%.*s', val: '%.*s' (%d)\n", |
| 2312 | key->len, key->s, value->len, value->s, rc); |
| 2313 | return -1; |
| 2314 | } |
| 2315 | |
| 2316 | if (avp->sname.setf(_sip_msg, &avp->sname.pvp, 0, &val) != 0) { |
| 2317 | LM_ERR("failed to set AVP\n"); |
| 2318 | return -1; |
| 2319 | } |
| 2320 | } |
| 2321 | |
| 2322 | return 0; |
| 2323 | } |
| 2324 | |
| 2325 | static int sql_cache_dump(struct sip_msg *msg, db_handlers_t *dbh, |
| 2326 | pv_name_fix_t *cols, pvname_list_t *dst_avps) |
nothing calls this directly
no test coverage detected