| 694 | |
| 695 | |
| 696 | int pv_parse_name(pv_spec_p sp, const str *in) |
| 697 | { |
| 698 | stat_var *stat; |
| 699 | pv_elem_t *format; |
| 700 | |
| 701 | if(in==NULL || in->s==NULL || sp==NULL) |
| 702 | return -1; |
| 703 | |
| 704 | LM_DBG("name %p with name <%.*s>\n", &sp->pvp.pvn, in->len, in->s); |
| 705 | if (pv_parse_format( in, &format)!=0) { |
| 706 | LM_ERR("failed to parse statistic name format <%.*s> \n", |
| 707 | in->len,in->s); |
| 708 | return -1; |
| 709 | } |
| 710 | |
| 711 | /* text only ? */ |
| 712 | if (format->next==NULL && format->spec.type==PVT_NONE) { |
| 713 | |
| 714 | /* search for the statistic */ |
| 715 | stat = get_stat( &format->text ); |
| 716 | |
| 717 | if (stat==NULL) { |
| 718 | /* statistic does not exist (yet) -> fill in the string name */ |
| 719 | sp->pvp.pvn.type = PV_NAME_INTSTR; |
| 720 | sp->pvp.pvn.u.isname.type = AVP_NAME_STR; |
| 721 | if (clone_pv_stat_name( in, &sp->pvp.pvn.u.isname.name.s )!=0) { |
| 722 | LM_ERR("failed to clone name of statistic \n"); |
| 723 | return -1; |
| 724 | } |
| 725 | LM_DBG("name %p, name cloned (in=%p, out=%p)\n", |
| 726 | &sp->pvp.pvn, in->s, sp->pvp.pvn.u.isname.name.s.s); |
| 727 | } else { |
| 728 | /* link the stat pointer directly as dynamic name */ |
| 729 | sp->pvp.pvn.type = PV_NAME_PVAR; |
| 730 | sp->pvp.pvn.u.dname = (void*)stat; |
| 731 | LM_DBG("name %p, stat found\n", &sp->pvp.pvn); |
| 732 | } |
| 733 | |
| 734 | } else { |
| 735 | |
| 736 | sp->pvp.pvn.type = PV_NAME_INTSTR; |
| 737 | sp->pvp.pvn.u.isname.type = 0; /* not string */ |
| 738 | sp->pvp.pvn.u.isname.name.s.s = (char*)(void*)format; |
| 739 | sp->pvp.pvn.u.isname.name.s.len = 0; |
| 740 | LM_DBG("name %p, stat name is FMT\n", &sp->pvp.pvn); |
| 741 | |
| 742 | } |
| 743 | |
| 744 | return 0; |
| 745 | } |
| 746 | |
| 747 | |
| 748 | static inline int get_stat_name(struct sip_msg* msg, pv_name_t *name, |
nothing calls this directly
no test coverage detected