parse_param.h

Go to the documentation of this file.
00001 /* 
00002  * Generic Parameter Parser
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  *
00006  * This file is part of ser, a free SIP server.
00007  *
00008  * ser 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  * For a license to use the ser software under conditions
00014  * other than those described here, or to purchase support for this
00015  * software, please contact iptel.org by e-mail at the following addresses:
00016  *    info@iptel.org
00017  *
00018  * ser is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License 
00024  * along with this program; if not, write to the Free Software 
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  *
00027  * History:
00028  * -------
00029  * 2003-03-24 Created by janakj
00030  * 2003-04-07 shm duplication support (janakj)
00031  * 2003-04-07 URI class added (janakj)
00032  */
00033 
00041 #ifndef PARSE_PARAM_H
00042 #define PARSE_PARAM_H
00043 
00044 #include <stdio.h>
00045 
00046 #include "../str.h"
00047 
00051 typedef enum ptype {
00052         P_OTHER = 0, 
00053         P_Q,         
00054         P_EXPIRES,   
00055         P_METHODS,   
00056         P_RECEIVED,  
00057         P_TRANSPORT, 
00058         P_LR,        
00059         P_R2,        
00060         P_MADDR,     
00061         P_TTL,       
00062         P_DSTIP,     
00063         P_DSTPORT,   
00064         P_INSTANCE,  
00065         P_REG_ID,    
00066         P_FTAG,      
00067         P_CALL_ID,   
00068         P_FROM_TAG,  
00069         P_TO_TAG,    
00070         P_ISD,       
00071         P_SLA,       
00072         P_MA         
00073 } ptype_t;
00074 
00075 
00079 typedef enum pclass {
00080         CLASS_ANY = 0,      
00081         CLASS_CONTACT,      
00082         CLASS_URI,          
00083         CLASS_EVENT_DIALOG  
00084 } pclass_t;
00085 
00086 
00090 typedef struct param {
00091         ptype_t type;         
00092         str name;             
00093         str body;             
00094         int len;              
00095         struct param* next;   
00096 } param_t;
00097 
00098 
00102 struct contact_hooks {
00103         struct param* expires;  
00104         struct param* q;        
00105         struct param* methods;  
00106         struct param* received; 
00107         struct param* instance; 
00108         struct param* reg_id;   
00109 };
00110 
00111 
00115 struct uri_hooks {
00116         struct param* transport; 
00117         struct param* lr;        
00118         struct param* r2;        
00119         struct param* maddr;     
00120         struct param* ttl;       
00121         struct param* dstip;     
00122         struct param* dstport;   
00123         struct param* ftag;      
00124 };
00125 
00126 
00127 struct event_dialog_hooks {
00128         struct param* call_id;
00129         struct param* from_tag;
00130         struct param* to_tag;
00131         struct param* include_session_description;
00132         struct param* sla;
00133         struct param* ma;
00134 };
00135 
00139 typedef union param_hooks {
00140         struct contact_hooks contact; 
00141         struct uri_hooks uri;         
00142         struct event_dialog_hooks event_dialog;
00143 } param_hooks_t;
00144 
00153 inline int parse_param(str *_s, pclass_t _c, param_hooks_t *_h, param_t *t);
00154 
00155 
00165 int parse_params(str* _s, pclass_t _c, param_hooks_t* _h, param_t** _p);
00166 
00167 
00171 void free_params(param_t* _p);
00172 
00173 
00177 void shm_free_params(param_t* _p);
00178 
00179 
00183 void print_params(FILE* _o, param_t* _p);
00184 
00185 
00189 int duplicate_params(param_t** _n, param_t* _p);
00190 
00191 
00195 int shm_duplicate_params(param_t** _n, param_t* _p);
00196 
00197 
00198 #endif /* PARSE_PARAM_H */