* get first RR header and print comma separated bodies in oroute * - order = 0 normal; order = 1 reverse * - no_change = 1 do not perform any change/linking over the input hdr list * (all parsing is localy done with no effect over the hdrs) * - nb_recs - input=skip number of rr; output=number of printed rrs */
| 359 | * - nb_recs - input=skip number of rr; output=number of printed rrs |
| 360 | */ |
| 361 | int print_rr_body(struct hdr_field *iroute, str *oroute, int order, |
| 362 | int no_change, unsigned int * nb_recs) |
| 363 | { |
| 364 | rr_t *p; |
| 365 | int n = 0, nr=0; |
| 366 | int i = 0; |
| 367 | int route_len; |
| 368 | #define MAX_RR_HDRS 64 |
| 369 | static str route[MAX_RR_HDRS]; |
| 370 | char *cp, *start; |
| 371 | struct hdr_field tmp, *hdr; |
| 372 | |
| 373 | if(iroute==NULL) |
| 374 | return 0; |
| 375 | |
| 376 | route_len= 0; |
| 377 | memset(route, 0, MAX_RR_HDRS*sizeof(str)); |
| 378 | |
| 379 | while (iroute!=NULL) |
| 380 | { |
| 381 | if (no_change) { |
| 382 | memcpy( &tmp, iroute, sizeof(tmp)); |
| 383 | tmp.parsed = NULL; |
| 384 | hdr=&tmp; |
| 385 | }else{ |
| 386 | hdr=iroute; |
| 387 | } |
| 388 | if (parse_rr(hdr) < 0) |
| 389 | { |
| 390 | LM_ERR("failed to parse RR\n"); |
| 391 | goto error; |
| 392 | } |
| 393 | |
| 394 | p =(rr_t*)hdr->parsed; |
| 395 | while (p) |
| 396 | { |
| 397 | route[n].s = p->nameaddr.name.s; |
| 398 | route[n].len = p->len; |
| 399 | LM_DBG("current rr is %.*s\n", route[n].len, route[n].s); |
| 400 | |
| 401 | n++; |
| 402 | if(n==MAX_RR_HDRS) |
| 403 | { |
| 404 | LM_ERR("too many RR\n"); |
| 405 | goto error; |
| 406 | } |
| 407 | p = p->next; |
| 408 | } |
| 409 | if (no_change) |
| 410 | free_rr( (rr_t**)&tmp.parsed ); |
| 411 | iroute = iroute->sibling; |
| 412 | } |
| 413 | |
| 414 | for(i=0;i<n;i++){ |
| 415 | if(!nb_recs || (nb_recs && |
| 416 | ( (!order&& (i>=*nb_recs)) || (order && (i<=(n-*nb_recs)) )) ) ) |
| 417 | { |
| 418 | route_len+= route[i].len; |
no test coverage detected