dialplan.h

Go to the documentation of this file.
00001 
00002 /*
00003  * $Id$
00004  *
00005  * Copyright (C)  2007-2008 Voice Sistem SRL
00006  *
00007  * This file is part of SIP-router, a free SIP server.
00008  *
00009  * SIP-router is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version
00013  *
00014  * SIP-router is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License 
00020  * along with this program; if not, write to the Free Software 
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  *
00023  * History:
00024  * --------
00025  *  2007-08-01 initial version (ancuta onofrei)
00026  */
00027 
00036 #ifndef _DP_DIALPLAN_H
00037 #define _DP_DIALPLAN_H
00038 
00039 #include <pcre.h>
00040 #include "../../pvar.h"
00041 #include "../../parser/msg_parser.h"
00042 
00043 #define DP_EQUAL_OP             0
00044 #define DP_REGEX_OP             1
00045 #define DP_FNMATCH_OP   2
00046 
00047 #define MAX_REPLACE_WITH        10
00048 
00049 typedef struct dpl_node{
00050         int dpid;
00051         int pr;
00052         int matchop;
00053         int matchlen;
00054         str match_exp, subst_exp, repl_exp; /*keeping the original strings*/
00055         pcre *match_comp, *subst_comp; /*compiled patterns*/
00056         struct subst_expr * repl_comp; 
00057         str attrs;
00058 
00059         struct dpl_node * next; /*next rule*/
00060 }dpl_node_t, *dpl_node_p;
00061 
00062 /*For every distinct length of a matching string*/
00063 typedef struct dpl_index{
00064         int len;
00065         dpl_node_t * first_rule;
00066         dpl_node_t * last_rule;
00067 
00068         struct dpl_index * next; 
00069 }dpl_index_t, *dpl_index_p;
00070 
00071 /*For every DPID*/
00072 typedef struct dpl_id{
00073         int dp_id;
00074         dpl_index_t* first_index;/*fast access :rules with specific length*/
00075         struct dpl_id * next;
00076 }dpl_id_t,*dpl_id_p;
00077 
00078 
00079 #define DP_VAL_INT              0
00080 #define DP_VAL_SPEC             1
00081 
00082 typedef struct dp_param{
00083         int type;
00084         union {
00085                 int id;
00086                 pv_spec_t sp[2];
00087         } v;
00088 }dp_param_t, *dp_param_p;
00089 
00090 int init_data();
00091 void destroy_data();
00092 int dp_load_db();
00093 
00094 dpl_id_p select_dpid(int id);
00095 
00096 struct subst_expr* repl_exp_parse(str subst);
00097 void repl_expr_free(struct subst_expr *se);
00098 int translate(struct sip_msg *msg, str user_name, str* repl_user, dpl_id_p idp, str *);
00099 int rule_translate(struct sip_msg *msg, str , dpl_node_t * rule,  str *);
00100 #endif