pv_shv.h

00001 /*
00002  * $Id$
00003  *
00004  * Copyright (C) 2007 Elena-Ramona Modroiu
00005  *
00006  * This file is part of Kamailio, a free SIP server.
00007  *
00008  * Kamailio is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * Kamailio is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License 
00019  * along with this program; if not, write to the Free Software 
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 
00024 #ifndef _SHVAR_H_
00025 #define _SHVAR_H_
00026 
00027 #include "../../sr_module.h"
00028 #include "../../locking.h"
00029 #include "../../lib/kmi/mi.h"
00030 #include "pv_svar.h"
00031 
00032 typedef struct sh_var {
00033         int n;                  /* Index of the variable */
00034         str name;               /* Name of the variable */
00035         script_val_t v;         /* Value of the variable */
00036 #ifdef GEN_LOCK_T_PREFERED
00037         gen_lock_t *lock;       /* Lock for hash entry - fastlock */
00038 #else
00039         int lockidx;            /* Lock index for hash entry - the rest*/
00040 #endif
00041         struct sh_var *next;
00042 } sh_var_t, *sh_var_p;
00043 
00044 sh_var_t* set_shvar_value(sh_var_t *shv, int_str *value, int flags);
00045 sh_var_t* get_shvar_by_name(str *name);
00046 
00047 void reset_shvars(void);
00048 void destroy_shvars(void);
00049 
00050 #ifndef GEN_LOCK_T_PREFERED
00051 void shvar_lock_idx(int idx);
00052 void shvar_release_idx(int idx);
00053 #endif
00054 
00055 void lock_shvar(sh_var_t *shv);
00056 void unlock_shvar(sh_var_t *shv);
00057 
00058 int pv_parse_shvar_name(pv_spec_p sp, str *in);
00059 int pv_get_shvar(struct sip_msg *msg,  pv_param_t *param, pv_value_t *res);
00060 int pv_set_shvar(struct sip_msg* msg, pv_param_t *param, int op,
00061                 pv_value_t *val);
00062 
00063 int shvar_init_locks(void);
00064 void shvar_destroy_locks(void);
00065 
00066 struct mi_root* mi_shvar_get(struct mi_root* cmd_tree, void* param);
00067 struct mi_root* mi_shvar_set(struct mi_root* cmd_tree, void* param);
00068 
00069 int param_set_var( modparam_t type, void* val);
00070 int param_set_shvar( modparam_t type, void* val);
00071 
00072 #endif
00073