pvapi.c File Reference

PV API specification. More...

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "mem/mem.h"
#include "mem/shm_mem.h"
#include "ut.h"
#include "dprint.h"
#include "route.h"
#include "hash_func.h"
#include "pvar.h"

Include dependency graph for pvapi.c:

Go to the source code of this file.

Data Structures

struct  _pv_item
struct  _tr_item

Defines

#define is_in_str(p, in)   (p<in->s+in->len && *p)
#define PV_PRINT_BUF_NO   3
#define PV_PRINT_BUF_SIZE   1024
#define PV_TABLE_SIZE   16
#define TR_TABLE_SIZE   4

Typedefs

typedef struct _pv_itempv_item_p
typedef struct _pv_item pv_item_t
typedef struct _tr_itemtr_item_p
typedef struct _tr_item tr_item_t

Functions

static int is_pv_valid_char (char c)
pvname_list_tparse_pvname_list (str *in, unsigned int type)
void pv_api_destroy (void)
int pv_elem_free_all (pv_elem_p log)
int pv_get_avp_name (struct sip_msg *msg, pv_param_p ip, int_str *avp_name, unsigned short *name_type)
int pv_get_intstrval (struct sip_msg *msg, pv_param_t *param, pv_value_t *res, int ival, str *sval)
static int pv_get_marker (struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
int pv_get_null (struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
 PV helper functions.
int pv_get_sintval (struct sip_msg *msg, pv_param_t *param, pv_value_t *res, int sival)
int pv_get_spec_index (struct sip_msg *msg, pv_param_p ip, int *idx, int *flags)
int pv_get_spec_name (struct sip_msg *msg, pv_param_p ip, pv_value_t *name)
int pv_get_spec_value (struct sip_msg *msg, pv_spec_p sp, pv_value_t *value)
int pv_get_strintval (struct sip_msg *msg, pv_param_t *param, pv_value_t *res, str *sval, int ival)
int pv_get_strval (struct sip_msg *msg, pv_param_t *param, pv_value_t *res, str *sval)
int pv_get_uintval (struct sip_msg *msg, pv_param_t *param, pv_value_t *res, unsigned int uival)
int pv_init_iname (pv_spec_p sp, int param)
void pv_init_table (void)
pv_export_tpv_lookup_spec_name (str *pvname, pv_spec_p e)
int pv_parse_format (str *in, pv_elem_p *el)
int pv_parse_index (pv_spec_p sp, str *in)
char * pv_parse_spec (str *in, pv_spec_p e)
int pv_printf (struct sip_msg *msg, pv_elem_p list, char *buf, int *len)
int pv_printf_s (struct sip_msg *msg, pv_elem_p list, str *s)
int pv_set_spec_value (struct sip_msg *msg, pv_spec_p sp, int op, pv_value_t *value)
void pv_spec_free (pv_spec_t *spec)
int pv_table_add (pv_export_t *e)
int pv_table_free (void)
void pv_value_destroy (pv_value_t *val)
int register_pvars_mod (char *mod_name, pv_export_t *items)
int register_trans_mod (char *mod_name, tr_export_t *items)
void tr_destroy (trans_t *t)
 Destroy transformation including eventual parameter.
int tr_exec (struct sip_msg *msg, trans_t *t, pv_value_t *v)
 Exec transformation on a pseudo-variable value.
void tr_free (trans_t *t)
 Free allocated memory of transformation list.
static char * tr_get_class (str *in, char *p, str *tclass)
void tr_init_table (void)
char * tr_lookup (str *in, trans_t **tr)
tr_export_ttr_lookup_class (str *tclass)
static trans_ttr_new (void)
void tr_param_free (tr_param_t *tp)
 Free transformation parameter list.
int tr_table_add (tr_export_t *e)
int tr_table_free (void)

Variables

static pv_item_t_pv_table [PV_TABLE_SIZE]
static int _pv_table_set = 0
static tr_item_t_tr_table [TR_TABLE_SIZE]
static int _tr_table_set = 0
static str pv_str_empty = { "", 0 }
static str pv_str_marker = { PV_MARKER_STR, 1 }
static str pv_str_null = { "<null>", 6 }


Detailed Description

PV API specification.

Definition in file pvapi.c.


Define Documentation

#define is_in_str ( p,
in   )     (p<in->s+in->len && *p)

#define PV_PRINT_BUF_NO   3

Definition at line 1096 of file pvapi.c.

Referenced by pv_printf_s().

#define PV_PRINT_BUF_SIZE   1024

Definition at line 1095 of file pvapi.c.

Referenced by pv_printf_s().

#define PV_TABLE_SIZE   16

Definition at line 43 of file pvapi.c.

Referenced by pv_init_table(), pv_lookup_spec_name(), pv_table_add(), and pv_table_free().

#define TR_TABLE_SIZE   4

Definition at line 44 of file pvapi.c.

Referenced by tr_init_table(), tr_lookup_class(), tr_table_add(), and tr_table_free().


Typedef Documentation

typedef struct _pv_item * pv_item_p

typedef struct _pv_item pv_item_t

typedef struct _tr_item * tr_item_p

typedef struct _tr_item tr_item_t


Function Documentation

static int is_pv_valid_char ( char  c  )  [static]

Definition at line 73 of file pvapi.c.

Referenced by pv_parse_spec(), and pv_table_add().

pvname_list_t* parse_pvname_list ( str in,
unsigned int  type 
)

void pv_api_destroy ( void   ) 

Definition at line 1469 of file pvapi.c.

Referenced by cleanup().

int pv_elem_free_all ( pv_elem_p  log  ) 

Definition at line 1072 of file pvapi.c.

References _pv_elem::next, and pkg_free.

Referenced by fixup_spve(), and pv_parse_format().

int pv_get_avp_name ( struct sip_msg msg,
pv_param_p  ip,
int_str avp_name,
unsigned short *  name_type 
)

int pv_get_intstrval ( struct sip_msg msg,
pv_param_t param,
pv_value_t res,
int  ival,
str sval 
)

convert int-str to pv_value_t (type is int)

Definition at line 281 of file pvapi.c.

References _pv_value::flags, NULL, PV_TYPE_INT, PV_VAL_INT, PV_VAL_STR, _pv_value::ri, and _pv_value::rs.

static int pv_get_marker ( struct sip_msg msg,
pv_param_t param,
pv_value_t res 
) [static]

Definition at line 295 of file pvapi.c.

References pv_get_strintval(), and _str::s.

Referenced by pv_parse_spec().

int pv_get_null ( struct sip_msg msg,
pv_param_t param,
pv_value_t res 
)

int pv_get_sintval ( struct sip_msg msg,
pv_param_t param,
pv_value_t res,
int  sival 
)

convert signed int to pv_value_t

Definition at line 231 of file pvapi.c.

References _pv_value::flags, _str::len, NULL, PV_TYPE_INT, PV_VAL_INT, PV_VAL_STR, _pv_value::ri, _pv_value::rs, _str::s, and sint2str().

Referenced by bm_get_time_diff(), and pv_get_ulc().

int pv_get_spec_index ( struct sip_msg msg,
pv_param_p  ip,
int *  idx,
int *  flags 
)

int pv_get_spec_name ( struct sip_msg msg,
pv_param_p  ip,
pv_value_t name 
)

int pv_get_spec_value ( struct sip_msg msg,
pv_spec_p  sp,
pv_value_t value 
)

int pv_get_strintval ( struct sip_msg msg,
pv_param_t param,
pv_value_t res,
str sval,
int  ival 
)

convert str-int to pv_value_t (type is str)

Definition at line 266 of file pvapi.c.

References _pv_value::flags, NULL, PV_VAL_INT, PV_VAL_STR, _pv_value::ri, and _pv_value::rs.

Referenced by pv_get_marker().

int pv_get_strval ( struct sip_msg msg,
pv_param_t param,
pv_value_t res,
str sval 
)

convert str to pv_value_t

Definition at line 252 of file pvapi.c.

References _pv_value::flags, NULL, PV_VAL_STR, and _pv_value::rs.

Referenced by pv_get_color(), pv_get_dlg(), pv_get_uac_req(), and pv_get_ulc().

int pv_get_uintval ( struct sip_msg msg,
pv_param_t param,
pv_value_t res,
unsigned int  uival 
)

convert unsigned int to pv_value_t

Definition at line 210 of file pvapi.c.

References _pv_value::flags, int2str(), _str::len, NULL, PV_TYPE_INT, PV_VAL_INT, PV_VAL_STR, _pv_value::ri, _pv_value::rs, and _str::s.

Referenced by pv_get_dlg(), pv_get_dlg_ctx(), pv_get_uac_req(), and pv_get_ulc().

int pv_init_iname ( pv_spec_p  sp,
int  param 
)

void pv_init_table ( void   ) 

Definition at line 64 of file pvapi.c.

References _pv_table_set, and PV_TABLE_SIZE.

Referenced by pv_table_add().

pv_export_t* pv_lookup_spec_name ( str pvname,
pv_spec_p  e 
)

int pv_parse_format ( str in,
pv_elem_p el 
)

int pv_parse_index ( pv_spec_p  sp,
str in 
)

char* pv_parse_spec ( str in,
pv_spec_p  e 
)

int pv_printf ( struct sip_msg msg,
pv_elem_p  list,
char *  buf,
int *  len 
)

int pv_printf_s ( struct sip_msg msg,
pv_elem_p  list,
str s 
)

int pv_set_spec_value ( struct sip_msg msg,
pv_spec_p  sp,
int  op,
pv_value_t value 
)

Definition at line 979 of file pvapi.c.

References LOCAL_ROUTE, NULL, pv_alter_context, pv_is_w, _pv_spec::pvp, route_type, and _pv_spec::setf.

Referenced by do_assign().

void pv_spec_free ( pv_spec_t spec  ) 

Definition at line 1060 of file pvapi.c.

References pkg_free, tr_free(), and _pv_spec::trans.

Referenced by fixup_free_pvar(), get_gid_fixup(), pv_parse_index(), and tr_param_free().

int pv_table_add ( pv_export_t e  ) 

int pv_table_free ( void   ) 

Definition at line 184 of file pvapi.c.

References _pv_table_set, _pv_item::next, pkg_free, and PV_TABLE_SIZE.

void pv_value_destroy ( pv_value_t val  ) 

int register_pvars_mod ( char *  mod_name,
pv_export_t items 
)

Definition at line 163 of file pvapi.c.

References LM_ERR, _pv_export::name, pv_table_add(), and _str::s.

Referenced by register_module().

int register_trans_mod ( char *  mod_name,
tr_export_t items 
)

Definition at line 1400 of file pvapi.c.

References LM_ERR, _str::s, _tr_export::tclass, and tr_table_add().

Referenced by mod_register().

void tr_destroy ( trans_t t  ) 

Destroy transformation including eventual parameter.

Parameters:
t transformation

Definition at line 1227 of file pvapi.c.

References _tr_param::next, NULL, _trans::params, and tr_param_free().

Referenced by tr_free(), and tr_lookup().

int tr_exec ( struct sip_msg msg,
trans_t t,
pv_value_t v 
)

Exec transformation on a pseudo-variable value.

Parameters:
msg SIP message
tr one or more transformations
val pseudo-variable value
Returns:
0 on success, -1 on error

Definition at line 1251 of file pvapi.c.

References LM_DBG, _trans::next, NULL, _trans::params, _trans::subtype, and _trans::trf.

Referenced by pv_get_spec_value().

void tr_free ( trans_t t  ) 

Free allocated memory of transformation list.

Parameters:
t transformation list

Definition at line 1275 of file pvapi.c.

References _trans::next, pkg_free, and tr_destroy().

Referenced by pv_spec_free().

static char* tr_get_class ( str in,
char *  p,
str tclass 
) [inline, static]

Definition at line 1120 of file pvapi.c.

References is_in_str, _str::len, LM_ERR, NULL, _str::s, and TR_CLASS_MARKER.

Referenced by tr_lookup().

void tr_init_table ( void   ) 

Definition at line 1322 of file pvapi.c.

References _tr_table_set, and TR_TABLE_SIZE.

Referenced by tr_table_add().

char* tr_lookup ( str in,
trans_t **  tr 
)

tr_export_t* tr_lookup_class ( str tclass  ) 

static trans_t* tr_new ( void   )  [inline, static]

Definition at line 1138 of file pvapi.c.

References LM_ERR, NULL, and pkg_malloc.

Referenced by tr_lookup().

void tr_param_free ( tr_param_t tp  ) 

Free transformation parameter list.

Parameters:
tp transformation list

Definition at line 1293 of file pvapi.c.

References _tr_param::data, _tr_param::next, NULL, pkg_free, pv_spec_free(), TR_PARAM_SPEC, _tr_param::type, and _tr_param::v.

Referenced by tr_destroy().

int tr_table_add ( tr_export_t e  ) 

int tr_table_free ( void   ) 

Definition at line 1421 of file pvapi.c.

References _tr_table_set, _tr_item::next, pkg_free, and TR_TABLE_SIZE.


Variable Documentation

pv_item_t* _pv_table[PV_TABLE_SIZE] [static]

Definition at line 57 of file pvapi.c.

int _pv_table_set = 0 [static]

Definition at line 58 of file pvapi.c.

Referenced by pv_init_table(), pv_table_add(), and pv_table_free().

tr_item_t* _tr_table[TR_TABLE_SIZE] [static]

Definition at line 1315 of file pvapi.c.

int _tr_table_set = 0 [static]

Definition at line 1316 of file pvapi.c.

Referenced by tr_init_table(), tr_table_add(), and tr_table_free().

str pv_str_empty = { "", 0 } [static]

Definition at line 302 of file pvapi.c.

str pv_str_marker = { PV_MARKER_STR, 1 } [static]

Definition at line 294 of file pvapi.c.

str pv_str_null = { "<null>", 6 } [static]

Definition at line 303 of file pvapi.c.


Generated on Thu May 24 08:01:16 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6