SIP Witch 1.9.15
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
osip_uri.h
Go to the documentation of this file.
1 /*
2  The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3  Copyright (C) 2001-2015 Aymeric MOIZARD amoizard@antisip.com
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
20 #ifndef _URLS_H_
21 #define _URLS_H_
22 
23 #include <osipparser2/osip_const.h>
24 #include <osipparser2/osip_list.h>
25 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
50 
55  struct osip_uri_param {
56  char *gname;
57  char *gvalue;
59  };
60 
66 
71  int osip_uri_param_init (osip_uri_param_t ** url_param);
76  void osip_uri_param_free (osip_uri_param_t * url_param);
83  int osip_uri_param_set (osip_uri_param_t * url_param, char *name, char *value);
89  int osip_uri_param_clone (const osip_uri_param_t * url_param, osip_uri_param_t ** dest);
90 #ifndef DOXYGEN
91 /*
92  * Free a list of a url parameter element.
93  * @param url_params The list of url parameter element to free.
94  */
95  void osip_uri_param_freelist (osip_list_t * url_params);
96 #endif
97 
103  int osip_uri_param_add (osip_list_t * url_params, char *name, char *value);
110  int osip_uri_param_get_byname (osip_list_t * url_params, char *name, osip_uri_param_t ** dest);
111 
116 #define osip_uri_header_init(url_header) osip_uri_param_init(url_header)
117 
121 #define osip_uri_header_free(url_header) osip_uri_param_free(url_header)
122 
128 #define osip_uri_header_set(url_header, name, value) osip_uri_param_set(url_header, name, value)
129 
134 #define osip_uri_header_clone(url_header,dest) osip_uri_param_clone(url_header,dest)
135 #ifndef DOXYGEN
136 /*
137  * Free a list of a generic parameter element.
138  * @param LIST The list of generic parameter element to free.
139  */
140 #define osip_uri_header_freelist(LIST) osip_uri_param_freelist(LIST)
141 #endif
142 
148 #define osip_uri_header_add(url_headers,name,value) osip_uri_param_add(url_headers,name,value)
149 
155 #define osip_uri_header_get_byname(url_headers,name,dest) osip_uri_param_get_byname(url_headers,name,dest)
156 
161  typedef struct osip_uri osip_uri_t;
162 
167  struct osip_uri {
168  char *scheme;
169  char *username;
170  char *password;
171  char *host;
172  char *port;
177  char *string;
179  };
180 
185  int osip_uri_init (osip_uri_t ** url);
190  void osip_uri_free (osip_uri_t * url);
196  int osip_uri_parse (osip_uri_t * url, const char *buf);
197 #ifndef DOXYGEN
198 
203  int osip_uri_parse_headers (osip_uri_t * url, const char *buf);
209  int osip_uri_parse_params (osip_uri_t * url, const char *buf);
210 #endif
211 
216  int osip_uri_to_str (const osip_uri_t * url, char **dest);
222  int osip_uri_clone (const osip_uri_t * url, osip_uri_t ** dest);
229  int osip_uri_to_str_canonical (const osip_uri_t * url, char **dest);
230 
236  void osip_uri_set_scheme (osip_uri_t * url, char *value);
241  char *osip_uri_get_scheme (osip_uri_t * url);
247  void osip_uri_set_host (osip_uri_t * url, char *value);
252  char *osip_uri_get_host (osip_uri_t * url);
258  void osip_uri_set_username (osip_uri_t * url, char *value);
263  char *osip_uri_get_username (osip_uri_t * url);
269  void osip_uri_set_password (osip_uri_t * url, char *value);
274  char *osip_uri_get_password (osip_uri_t * url);
280  void osip_uri_set_port (osip_uri_t * url, char *value);
285  char *osip_uri_get_port (osip_uri_t * url);
286 
287 
288 
293 #define osip_uri_set_transport_udp(url) osip_uri_param_add((&(url)->url_params), osip_strdup("transport"), osip_strdup("udp"))
294 
298 #define osip_uri_set_transport_tcp(url) osip_uri_param_add((&(url)->url_params), osip_strdup("transport"), osip_strdup("tcp"))
299 
303 #define osip_uri_set_transport_sctp(url) osip_uri_param_add((&(url)->url_params), osip_strdup("transport"), osip_strdup("sctp"))
304 
308 #define osip_uri_set_transport_tls(url) osip_uri_param_add((&(url)->url_params), osip_strdup("transport"), osip_strdup("tls"))
309 
314 #define osip_uri_set_transport(url,value) osip_uri_param_add((&(url)->url_params), osip_strdup("transport"), value)
315 
320 #define osip_uri_set_user_phone(url) osip_uri_param_add((&(url)->url_params), osip_strdup("user"), osip_strdup("phone"))
321 
325 #define osip_uri_set_user_ip(url) osip_uri_param_add((&(url)->url_params), osip_strdup("user"), osip_strdup("ip"))
326 
330 #define osip_uri_set_method_invite(url) osip_uri_param_add((&(url)->url_params), osip_strdup("method"), osip_strdup("INVITE"))
331 
335 #define osip_uri_set_method_ack(url) osip_uri_param_add((&(url)->url_params), osip_strdup("method"), osip_strdup("ACK"))
336 
340 #define osip_uri_set_method_options(url) osip_uri_param_add((&(url)->url_params), osip_strdup("method"), osip_strdup("OPTIONS"))
341 
345 #define osip_uri_set_method_bye(url) osip_uri_param_add((&(url)->url_params), osip_strdup("method"), osip_strdup("BYE"))
346 
350 #define osip_uri_set_method_cancel(url) osip_uri_param_add((&(url)->url_params), osip_strdup("method"), osip_strdup("CANCEL"))
351 
355 #define osip_uri_set_method_register(url) osip_uri_param_add((&(url)->url_params),osip_strdup("method"), osip_strdup("REGISTER"))
356 
361 #define osip_uri_set_method(url, value) osip_uri_param_add((&(url)->url_params), osip_strdup("method"), value)
362 
367 #define osip_uri_set_ttl(url, value) osip_uri_param_add((&(url)->url_params), osip_strdup("ttl"), value)
368 
373 #define osip_uri_set_maddr(url, value) osip_uri_param_add((&(url)->url_params), osip_strdup("maddr"), value)
374 
381 #define osip_uri_uparam_add(url,name,value) osip_uri_param_add((&(url)->url_params),name,value)
382 
388 #define osip_uri_uparam_get_byname(url,name,dest) osip_uri_param_get_byname((&(url)->url_params),name,dest)
389 
396 #define osip_uri_uheader_add(url,name,value) osip_uri_header_add((&(url)->url_headers),name,value)
397 
403 #define osip_uri_uheader_get_byname(url,name,dest) osip_uri_header_get_byname((&(url)->url_headers),name,dest)
404 
405 #ifndef DOXYGEN
406 /* internal method */
407  const char *next_separator (const char *ch, int separator_osip_to_find, int before_separator);
408 
409  char *__osip_uri_escape_nonascii_and_nondef (const char *string, const char *def);
410  char *__osip_uri_escape_userinfo (const char *string);
411  char *__osip_uri_escape_password (const char *string);
412  char *__osip_uri_escape_uri_param (char *string);
413  char *__osip_uri_escape_header_param (char *string);
414  void __osip_uri_unescape (char *string);
415 
416 #endif
417 
420 #ifdef __cplusplus
421 }
422 #endif
423 #endif /* _URLS_H_ */
Structure for referencing a list of elements.
Definition: osip_list.h:82
int osip_uri_to_str(const osip_uri_t *url, char **dest)
Get a string representation of a url element.
char * port
Port number.
Definition: osip_uri.h:172
osip_list_t url_params
Uri parameters.
Definition: osip_uri.h:173
void osip_uri_set_scheme(osip_uri_t *url, char *value)
Set the scheme of a url element.
int osip_uri_parse_params(osip_uri_t *url, const char *buf)
Parse the parameter part of a url.
int osip_uri_init(osip_uri_t **url)
Allocate a url element.
void osip_uri_set_password(osip_uri_t *url, char *value)
Set the password of a url element.
int osip_uri_param_add(osip_list_t *url_params, char *name, char *value)
Allocate and add a url parameter element in a list.
void osip_uri_free(osip_uri_t *url)
Free a url element.
void osip_uri_param_free(osip_uri_param_t *url_param)
Free a url parameter element.
void osip_uri_set_username(osip_uri_t *url, char *value)
Set the username of a url element.
int osip_uri_param_set(osip_uri_param_t *url_param, char *name, char *value)
Set values of a url parameter element.
int osip_uri_to_str_canonical(const osip_uri_t *url, char **dest)
Get a canonical string representation of a url element.
char * __osip_uri_escape_uri_param(char *string)
char * osip_uri_get_scheme(osip_uri_t *url)
Get the scheme of a url element.
char * gname
uri parameter name
Definition: osip_uri.h:56
oSIP list Routines
void osip_uri_param_freelist(osip_list_t *url_params)
char * username
Username.
Definition: osip_uri.h:169
char * osip_uri_get_port(osip_uri_t *url)
Get the port of a url element.
osip_uri_param_t osip_uri_header_t
Structure for referencing url headers.
Definition: osip_uri.h:65
osip_list_t url_headers
Uri headers.
Definition: osip_uri.h:174
char * gvalue
uri parameter value
Definition: osip_uri.h:57
void __osip_uri_unescape(char *string)
int osip_uri_param_get_byname(osip_list_t *url_params, char *name, osip_uri_param_t **dest)
Find in a url parameter element in a list.
int osip_uri_parse_headers(osip_uri_t *url, const char *buf)
Parse the header part of a url.
char * password
Password.
Definition: osip_uri.h:170
char * __osip_uri_escape_header_param(char *string)
char * string
Space for other url schemes.
Definition: osip_uri.h:177
char * osip_uri_get_password(osip_uri_t *url)
Get the password of a url element.
char * name[96]
Definition: cgiserver.cpp:88
char * value[96]
Definition: cgiserver.cpp:90
char * __osip_uri_escape_nonascii_and_nondef(const char *string, const char *def)
int osip_uri_parse(osip_uri_t *url, const char *buf)
Parse a url.
char * scheme
Uri Scheme (sip or sips)
Definition: osip_uri.h:168
int osip_uri_param_init(osip_uri_param_t **url_param)
Allocate a url parameter element.
Structure for referencing url parameters.
Definition: osip_uri.h:55
Structure for referencing SIP urls.
Definition: osip_uri.h:167
const char * next_separator(const char *ch, int separator_osip_to_find, int before_separator)
char * __osip_uri_escape_userinfo(const char *string)
char * osip_uri_get_host(osip_uri_t *url)
Get the host of a url element.
void osip_uri_set_port(osip_uri_t *url, char *value)
Set the port of a url element.
char * osip_uri_get_username(osip_uri_t *url)
Get the username of a url element.
char * __osip_uri_escape_password(const char *string)
int osip_uri_clone(const osip_uri_t *url, osip_uri_t **dest)
Clone a url element.
void osip_uri_set_host(osip_uri_t *url, char *value)
Set the host of a url element.
int osip_uri_param_clone(const osip_uri_param_t *url_param, osip_uri_param_t **dest)
Clone a url parameter element.
char * host
Domain.
Definition: osip_uri.h:171