| 1318 | } |
| 1319 | |
| 1320 | static int w_cache_add(struct sip_msg *msg, str *id, str *attr, |
| 1321 | int *inc, int *expire, pv_spec_t *new_val) |
| 1322 | { |
| 1323 | int ret; |
| 1324 | pv_value_t val; |
| 1325 | int aux_counter; |
| 1326 | |
| 1327 | if (!attr->s || !attr->len) { |
| 1328 | LM_ERR("attribute cannot be empty\n"); |
| 1329 | return E_UNSPEC; |
| 1330 | } |
| 1331 | |
| 1332 | ret = cachedb_add(id, attr, *inc, *expire, &aux_counter); |
| 1333 | |
| 1334 | /* Return the new value */ |
| 1335 | if (ret > 0 && new_val) { |
| 1336 | val.ri = aux_counter; |
| 1337 | val.flags = PV_TYPE_INT|PV_VAL_INT; |
| 1338 | |
| 1339 | if (pv_set_value(msg, new_val, 0, &val) < 0) { |
| 1340 | LM_ERR("cannot set the variable value\n"); |
| 1341 | return -1; |
| 1342 | } |
| 1343 | } |
| 1344 | |
| 1345 | return ret; |
| 1346 | } |
| 1347 | |
| 1348 | static int w_cache_sub(struct sip_msg *msg, str *id, str *attr, |
| 1349 | int *dec, int *expire, pv_spec_t *new_val) |
nothing calls this directly
no test coverage detected