| 
         Documentation  | 
      
        
Documentation.Development-Manual-API-Transformations-3-6 HistoryHide minor edits - Show changes to markup December 11, 2019, at 06:53 PM 
        by  -  
        Added lines 1-92: 
        Documentation -> Development Manual 3.6 -> Transformations APIThis page has been visited 492 times. (:title OpenSIPS Development - Transformations API:) (:allVersions Development-Manual-API-Transformations 3.6:) 
 
 (:toc-float Table of Content:) Transformations are functions which can operate directly on any OpenSIPS pseudo-variable.  A transformation takes as input the value of the pseudo-variable and processes it, outputting a transformed version.
 
 
 
 $var(tutorial) = “OpenSIPSDevel”; xlog("Our variable has $(var(tutorial){s.len}) characters\n"); 
 (:sourceend:)
 Note that transformations can be chained together, so make sure to take this into account when implementing new ones! 
     {str_init("uri"), tr_parse_uri, tr_eval_uri},
...
(:sourceend:)
Notice that we supply a parsing function and an evaluation function.     char *p;
    str name;
    tr_param_t *tp = NULL;
    if(in==NULL || in->s==NULL || t==NULL)
        return -1;
    p = in->s;
    name.s = in->s;
...
(:sourceend:)
         if(parse_uri(_tr_uri.s, _tr_uri.len, &_tr_parsed_uri)!=0)
        {
            LM_ERR("invalid uri [%.*s]\n", val->rs.len,
                    val->rs.s);
... /* zero out the output val */ memset(val, 0, sizeof(pv_value_t)); /* the output pvar will be a string */ val->flags = PV_VAL_STR; switch(subtype) {       case TR_URI_USER:
            val->rs = (_tr_parsed_uri.user.s)?_tr_parsed_uri.user:_tr_empty;
            break;
... (:sourceend:)  | 
