osip_uri.h

Go to the documentation of this file.
00001 /*
00002   The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
00003   Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Aymeric MOIZARD jack@atosc.org
00004   
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009   
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014   
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 #ifndef _URLS_H_
00021 #define _URLS_H_
00022 
00023 #include <osipparser2/osip_const.h>
00024 #include <osipparser2/osip_list.h>
00025 
00041 #ifdef __cplusplus
00042 extern "C"
00043 {
00044 #endif
00045 
00050   typedef struct osip_uri_param osip_uri_param_t;
00051 
00056   struct osip_uri_param
00057   {
00058     char *gname;    
00059     char *gvalue;   
00060   };
00061 
00066   typedef osip_uri_param_t osip_uri_header_t;
00067 
00072   int osip_uri_param_init (osip_uri_param_t ** url_param);
00077   void osip_uri_param_free (osip_uri_param_t * url_param);
00084   int osip_uri_param_set (osip_uri_param_t * url_param, char *name, char *value);
00090   int osip_uri_param_clone (const osip_uri_param_t * url_param,
00091                             osip_uri_param_t ** dest);
00092 #ifndef DOXYGEN
00093 /*
00094  * Free a list of a url parameter element.
00095  * @param url_params The list of url parameter element to free.
00096  */
00097   void osip_uri_param_freelist (osip_list_t * url_params);
00098 #endif
00099 
00105   int osip_uri_param_add (osip_list_t * url_params, char *name, char *value);
00112   int osip_uri_param_get_byname (osip_list_t * url_params, char *name,
00113                                  osip_uri_param_t ** dest);
00114 
00119 #define osip_uri_header_init(url_header) osip_uri_param_init(url_header)
00120 
00124 #define osip_uri_header_free(url_header) osip_uri_param_free(url_header)
00125 
00131 #define osip_uri_header_set(url_header, name, value)  osip_uri_param_set(url_header, name, value)
00132 
00137 #define osip_uri_header_clone(url_header,dest)    osip_uri_param_clone(url_header,dest)
00138 #ifndef DOXYGEN
00139 /*
00140  * Free a list of a generic parameter element.
00141  * @param LIST The list of generic parameter element to free.
00142  */
00143 #define osip_uri_header_freelist(LIST)       osip_uri_param_freelist(LIST)
00144 #endif
00145 
00151 #define osip_uri_header_add(url_headers,name,value)        osip_uri_param_add(url_headers,name,value)
00152 
00158 #define osip_uri_header_get_byname(url_headers,name,dest) osip_uri_param_get_byname(url_headers,name,dest)
00159 
00164   typedef struct osip_uri osip_uri_t;
00165 
00170   struct osip_uri
00171   {
00172     char *scheme;              
00173     char *username;            
00174     char *password;            
00175     char *host;                
00176     char *port;                
00177     osip_list_t url_params;    
00178     osip_list_t url_headers;   
00180     char *string;  
00181   };
00182 
00187   int osip_uri_init (osip_uri_t ** url);
00192   void osip_uri_free (osip_uri_t * url);
00198   int osip_uri_parse (osip_uri_t * url, const char *buf);
00199 #ifndef DOXYGEN
00200 
00205   int osip_uri_parse_headers (osip_uri_t * url, const char *buf);
00211   int osip_uri_parse_params (osip_uri_t * url, const char *buf);
00212 #endif
00213 
00218   int osip_uri_to_str (const osip_uri_t * url, char **dest);
00224   int osip_uri_clone (const osip_uri_t * url, osip_uri_t ** dest);
00231   int osip_uri_to_str_canonical (const osip_uri_t * url, char **dest);
00232 
00238   void osip_uri_set_scheme (osip_uri_t * url, char *value);
00243   char *osip_uri_get_scheme (osip_uri_t * url);
00249   void osip_uri_set_host (osip_uri_t * url, char *value);
00254   char *osip_uri_get_host (osip_uri_t * url);
00260   void osip_uri_set_username (osip_uri_t * url, char *value);
00265   char *osip_uri_get_username (osip_uri_t * url);
00271   void osip_uri_set_password (osip_uri_t * url, char *value);
00276   char *osip_uri_get_password (osip_uri_t * url);
00282   void osip_uri_set_port (osip_uri_t * url, char *value);
00287   char *osip_uri_get_port (osip_uri_t * url);
00288 
00289 
00290 
00295 #define osip_uri_set_transport_udp(url)   osip_uri_param_add((&(url)->url_params), osip_strdup("transport"), osip_strdup("udp"))
00296 
00300 #define osip_uri_set_transport_tcp(url)   osip_uri_param_add((&(url)->url_params), osip_strdup("transport"), osip_strdup("tcp"))
00301 
00305 #define osip_uri_set_transport_sctp(url)  osip_uri_param_add((&(url)->url_params), osip_strdup("transport"), osip_strdup("sctp"))
00306 
00310 #define osip_uri_set_transport_tls(url)   osip_uri_param_add((&(url)->url_params), osip_strdup("transport"), osip_strdup("tls"))
00311 
00316 #define osip_uri_set_transport(url,value) osip_uri_param_add((&(url)->url_params), osip_strdup("transport"), value)
00317 
00322 #define osip_uri_set_user_phone(url)   osip_uri_param_add((&(url)->url_params), osip_strdup("user"), osip_strdup("phone"))
00323 
00327 #define osip_uri_set_user_ip(url)      osip_uri_param_add((&(url)->url_params), osip_strdup("user"), osip_strdup("ip"))
00328 
00332 #define osip_uri_set_method_invite(url)  osip_uri_param_add((&(url)->url_params), osip_strdup("method"), osip_strdup("INVITE"))
00333 
00337 #define osip_uri_set_method_ack(url)     osip_uri_param_add((&(url)->url_params), osip_strdup("method"), osip_strdup("ACK"))
00338 
00342 #define osip_uri_set_method_options(url) osip_uri_param_add((&(url)->url_params), osip_strdup("method"), osip_strdup("OPTIONS"))
00343 
00347 #define osip_uri_set_method_bye(url)     osip_uri_param_add((&(url)->url_params), osip_strdup("method"), osip_strdup("BYE"))
00348 
00352 #define osip_uri_set_method_cancel(url)  osip_uri_param_add((&(url)->url_params), osip_strdup("method"), osip_strdup("CANCEL"))
00353 
00357 #define osip_uri_set_method_register(url) osip_uri_param_add((&(url)->url_params),osip_strdup("method"), osip_strdup("REGISTER"))
00358 
00363 #define osip_uri_set_method(url, value) osip_uri_param_add((&(url)->url_params), osip_strdup("method"), value)
00364 
00369 #define osip_uri_set_ttl(url, value)    osip_uri_param_add((&(url)->url_params), osip_strdup("ttl"), value)
00370 
00375 #define osip_uri_set_maddr(url, value)  osip_uri_param_add((&(url)->url_params), osip_strdup("maddr"), value)
00376 
00383 #define osip_uri_uparam_add(url,name,value) osip_uri_param_add((&(url)->url_params),name,value)
00384 
00390 #define osip_uri_uparam_get_byname(url,name,dest)  osip_uri_param_get_byname((&(url)->url_params),name,dest)
00391 
00398 #define osip_uri_uheader_add(url,name,value)    osip_uri_header_add((&(url)->url_headers),name,value)
00399 
00405 #define osip_uri_uheader_get_byname(url,name,dest) osip_uri_header_get_byname((&(url)->url_headers),name,dest)
00406 
00407 #ifndef DOXYGEN
00408 /* internal method */
00409   char *next_separator (const char *ch, int separator_osip_to_find,
00410                         int before_separator);
00411 
00412   char *__osip_uri_escape_nonascii_and_nondef (const char *string,
00413                                                const char *def);
00414   char *__osip_uri_escape_userinfo (const char *string);
00415   char *__osip_uri_escape_password (const char *string);
00416   char *__osip_uri_escape_uri_param (char *string);
00417   char *__osip_uri_escape_header_param (char *string);
00418   void __osip_uri_unescape (char *string);
00419 
00420 #endif
00421 
00424 #ifdef __cplusplus
00425 }
00426 #endif
00427 
00428 #endif                          /*  _URLS_H_ */

Generated on Wed Feb 13 01:03:29 2008 for libosip by  doxygen 1.5.4