[Devel] textops and pseudo-variables

Bogdan-Andrei Iancu bogdan at voice-system.ro
Wed Nov 23 17:22:57 CET 2005


Hi Boris,

this kind of functionality already exists. Print the body header into an 
AVP and then push the AVP as header:
    avp_printf("i:10", "<sip:$avp(s:xxx)@ 
$fd>;party=calling;screen=yes;privacy=off");
    avp_pushto("$Remote-Party-ID","i:10");

anyhow, please submit the patch on the tracker -
    http://sourceforge.net/tracker/?group_id=139143

thanks and regards,
bogdan

Boris Bliznioukov wrote:

> Hello,
>
> I was using textops module and had discovered  that pudo-variables  
> are not extended in textops module. So constriction like this is not  
> working
>
> append_hf("Remote-Party-ID: <sip:$avp(s:xxx)@ 
> $fd>;party=calling;screen=yes;privacy=off\r\n");
>
> I thought it would be good if textops would extend pseudo-variables.
> And here is a small patch for that.
> Right now it is only changes append_hf, if there is an interest I can  
> add pseudo-variables support for the rest of the functions in textops  
> module.
>
> Boris./
>
> *** textops.c.orig      Tue Nov 22 20:09:35 2005
> --- textops.c   Wed Nov 23 18:03:38 2005
> ***************
> *** 94,104 ****
>   static int replace_all_f(struct sip_msg* msg, char* key, char* str);
>   static int search_append_f(struct sip_msg*, char*, char*);
>   static int append_to_reply_f(struct sip_msg* msg, char* key, char*  
> str);
> ! static int append_hf(struct sip_msg* msg, char* str1, char* str2);
>   static int append_urihf(struct sip_msg* msg, char* str1, char* str2);
>   static int append_time_f(struct sip_msg* msg, char* , char *);
>   static int is_method_f(struct sip_msg* msg, char* , char *);
>
>   static int fixup_regex(void**, int);
>   static int fixup_substre(void**, int);
>   static int str_fixup(void** param, int param_no);
> --- 94,105 ----
>   static int replace_all_f(struct sip_msg* msg, char* key, char* str);
>   static int search_append_f(struct sip_msg*, char*, char*);
>   static int append_to_reply_f(struct sip_msg* msg, char* key, char*  
> str);
> ! static int append_hf(struct sip_msg *msg, xl_elem_t *format );
>   static int append_urihf(struct sip_msg* msg, char* str1, char* str2);
>   static int append_time_f(struct sip_msg* msg, char* , char *);
>   static int is_method_f(struct sip_msg* msg, char* , char *);
>
> + static int avp_fixup(void**, int);
>   static int fixup_regex(void**, int);
>   static int fixup_substre(void**, int);
>   static int str_fixup(void** param, int param_no);
> ***************
> *** 119,125 ****
>                         REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE| 
> BRANCH_ROUTE},
>         {"append_to_reply",  append_to_reply_f, 1, 0,
>                         REQUEST_ROUTE|BRANCH_ROUTE},
> !       {"append_hf",        append_hf,         1, str_fixup,
>                         REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE| 
> BRANCH_ROUTE},
>         {"append_urihf",     append_urihf,      2, str_fixup,
>                         REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
> --- 120,126 ----
>                         REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE| 
> BRANCH_ROUTE},
>         {"append_to_reply",  append_to_reply_f, 1, 0,
>                         REQUEST_ROUTE|BRANCH_ROUTE},
> !       {"append_hf",        append_hf,         1, avp_fixup,
>                         REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE| 
> BRANCH_ROUTE},
>         {"append_urihf",     append_urihf,      2, str_fixup,
>                         REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
> ***************
> *** 623,631 ****
>         return 1;
>   }
>
> ! static int append_hf(struct sip_msg *msg, char *str1, char *str2 )
>   {
> !       return append_hf_helper(msg, (str *) str1, (str *) 0);
>   }
>
>   static int append_urihf(struct sip_msg *msg, char *str1, char *str2 )
> --- 624,654 ----
>         return 1;
>   }
>
> ! static int append_hf(struct sip_msg *msg, xl_elem_t *format )
>   {
> !
> !       #define PRINTBUF_SIZE   1024
> !       char printbuf[PRINTBUF_SIZE];
> !       int printbuf_len;
> !       str* s;
> !
> !       s = (str*)pkg_malloc(sizeof(str));
> !       if (!s) {
> !               LOG(L_ERR, "str_fixup(): No memory left\n");
> !               return E_UNSPEC;
> !       }
> !
> !       printbuf_len = PRINTBUF_SIZE-1;
> !       if(xl_printf(msg, format, printbuf, &printbuf_len)<0)
> !       {
> !               LOG(L_ERR, "textops:append_hf: error - cannot print  
> the format\n");
> !               return -1;
> !       }
> !
> !       s->s = printbuf;
> !       s->len = strlen(s->s);
> !
> !       return append_hf_helper(msg, (str *) s, (str *) 0);
>   }
>
>   static int append_urihf(struct sip_msg *msg, char *str1, char *str2 )
> ***************
> *** 679,684 ****
> --- 702,727 ----
>         s->len = strlen(s->s);
>         *param = (void*)s;
>
> +       return 0;
> + }
> +
> + /*
> +  * Convert char* parameter to xl_elem parameter
> +  */
> + static int avp_fixup(void** param, int param_no)
> + {
> +       xl_elem_t *model;
> +
> +       if(*param)
> +       {
> +               if(xl_parse_format((char*)(*param), &model,  
> XL_DISABLE_COLORS)<0)
> +               {
> +                       LOG(L_ERR, "ERROR:textops:avp_fixup: wrong  
> format[%s]\n",
> +                               (char*)(*param));
> +                       return E_UNSPEC;
> +               }
> +               *param = (void*)model;
> +       }
>         return 0;
>   }
>  
>  
>
>
> _______________________________________________
> Devel mailing list
> Devel at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/devel
>




More information about the Devel mailing list