sofia-sip/url.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of the Sofia-SIP package
00003  *
00004  * Copyright (C) 2005 Nokia Corporation.
00005  *
00006  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation; either version 2.1 of
00011  * the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA
00022  *
00023  */
00024 
00034 #ifndef URL_H_TYPES
00035 #define URL_H_TYPES
00036 
00038 enum url_type_e {
00039   url_invalid = -2,             
00040   url_unknown = -1,             
00041   url_any = 0,                  
00042   url_sip,                      
00043   url_sips,                     
00044   url_tel,                      
00045   url_fax,                      
00046   url_modem,                    
00047   url_http,                     
00048   url_https,                    
00049   url_ftp,                      
00050   url_file,                     
00051   url_rtsp,                     
00052   url_rtspu,                    
00053   url_mailto,                   
00054   url_im,                       
00055   url_pres,                     
00056   url_cid,                      
00057   url_msrp,                     
00058   url_wv,                       
00059   _url_none
00060 };
00061 
00066 typedef struct {
00067   char                url_pad[sizeof(void *) - 2];   
00069   signed char         url_type;     
00070   char                url_root;     
00071   char const         *url_scheme;   
00072   char const         *url_user;     
00073   char const         *url_password; 
00074   char const         *url_host;     
00075   char const         *url_port;     
00076   char const         *url_path;     
00077   char const         *url_params;   
00078   char const         *url_headers;  
00079   char const         *url_fragment; 
00080 } url_t;
00081 
00082 enum { 
00084   URL_MAXLEN = 65536
00085 };
00086 
00095 typedef union {
00096   char  us_str[URL_MAXLEN];     
00097   url_t us_url[1];              
00098 } url_string_t;
00099 
00100 #endif
00101 
00102 #ifndef URL_H
00103 
00104 #define URL_H
00105 
00106 #ifndef SU_ALLOC_H
00107 #include <sofia-sip/su_alloc.h>
00108 #endif
00109 
00110 SOFIA_BEGIN_DECLS
00111 
00120 #define URL_INIT_AS(type)  \
00121   { "\0\0", url_##type, 0, url_##type != url_any ? #type : "*" }
00122 
00124 SOFIAPUBFUN void url_init(url_t *url, enum url_type_e type);
00125 
00127 SOFIAPUBFUN char const *url_scheme(enum url_type_e type);
00128 
00130 SOFIAPUBFUN int url_d(url_t *url, char *s);
00131 
00133 SOFIAPUBFUN int url_len(url_t const * url);
00134 
00136 SOFIAPUBFUN int url_e(char buffer[], int n, url_t const *url);
00137 
00139 #define URL_E(buf, end, url) \
00140   (buf) += url_e((buf), (buf) < (end) ? (end) - (buf) : 0, (url))
00141 
00143 SOFIAPUBFUN int url_xtra(url_t const * url);
00144 
00146 SOFIAPUBFUN int url_dup(char *buf, int bufsize, url_t *dst, url_t const *src);
00147 
00149 #define URL_DUP(buf, end, dst, src) \
00150   (buf) += url_dup((buf), (buf) < (end) ? (end) - (buf) : 0, (dst), (src))
00151 
00153 SOFIAPUBFUN url_t *url_hdup(su_home_t *h, url_t const *src);
00154 
00156 SOFIAPUBFUN url_t *url_make(su_home_t *h, char const *str);
00157 
00159 url_t *url_format(su_home_t *h, char const *fmt, ...);
00160 
00162 SOFIAPUBFUN char *url_as_string(su_home_t *home, url_t const *url);
00163 
00165 SOFIAPUBFUN int url_reserved_p(char const *s);
00166 
00168 SOFIAPUBFUN char *url_escape(char *d, char const *s, char const reserved[]);
00169 
00171 SOFIAPUBFUN int url_esclen(char const *s, char const reserved[]);
00172 
00174 SOFIAPUBFUN char *url_unescape(char *d, char const *s);
00175 
00177 SOFIAPUBFUN int url_param(char const *params, char const *tag,
00178                           char value[], int vlen);
00179 
00181 SOFIAPUBFUN int url_has_param(url_t const *url, char const *name);
00182 
00184 SOFIAPUBFUN int url_have_param(char const *params, char const *tag);
00185 
00187 SOFIAPUBFUN int url_param_add(su_home_t *h, url_t *url, char const *param);
00188 
00190 SOFIAPUBFUN int url_cmp(url_t const *a, url_t const *b);
00191 
00193 SOFIAPUBFUN int url_cmp_all(url_t const *a, url_t const *b);
00194 
00196 SOFIAPUBFUN int url_strip_transport(url_t *u);
00197 
00199 SOFIAPUBFUN int url_have_transport(url_t const *u);
00200 
00202 SOFIAPUBFUN char const *url_port_default(enum url_type_e url_type);
00203 
00205 SOFIAPUBFUN char const *url_tport_default(enum url_type_e url_type);
00206 
00208 SOFIAPUBFUN char const *url_port(url_t const *u);
00209 
00211 #define URL_PORT(u) \
00212   ((u) && (u)->url_port ? (u)->url_port : \
00213   url_port_default((u) ? (u)->url_type : url_any))
00214 
00217 #define URL_STRING_P(u) ((u) && *((url_string_t*)(u))->us_str != 0)
00218 
00221 #define URL_IS_STRING(u) ((u) && *((url_string_t*)(u))->us_str != 0)
00222 
00225 SOFIAPUBFUN int url_string_p(url_string_t const * url);
00226 
00229 SOFIAPUBFUN int url_is_string(url_string_t const * url);
00230 
00232 #define URL_STRING_MAKE(s) \
00233   ((url_string_t *)((s) && *((char *)(s)) ? (s) : NULL))
00234 
00236 SOFIAPUBFUN int url_sanitize(url_t *u);
00237 
00239 #define URL_PRINT_FORMAT "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
00240 #define URL_FORMAT_STRING URL_PRINT_FORMAT
00241 
00243 #define URL_PRINT_ARGS(u) \
00244   (u)->url_scheme ? (u)->url_scheme : "",       \
00245   (u)->url_type != url_any && (u)->url_scheme && (u)->url_scheme[0] \
00246     ? ":" : "", \
00247   (u)->url_root && ((u)->url_host || (u)->url_user) ? "//" : "", \
00248   (u)->url_user ? (u)->url_user : "", \
00249   (u)->url_user && (u)->url_password ? ":" : "", \
00250   (u)->url_user && (u)->url_password ? (u)->url_password : "", \
00251   (u)->url_user && (u)->url_host ? "@" : "", \
  (u)->url_host ? (u)->url_host : "", \
  (u)->url_host && (u)->url_port ? ":" : "", \
00252   (u)->url_host && (u)->url_port ? (u)->url_port : "", \
00253   (u)->url_root && (u)->url_path ? "/" : "", \
00254   (u)->url_path ? (u)->url_path : "", \
00255   (u)->url_params ? ";" : "", (u)->url_params ? (u)->url_params : "", \
00256   (u)->url_headers ? "?" : "", (u)->url_headers ? (u)->url_headers : "", \
00257   (u)->url_fragment ? "#" : "", (u)->url_fragment ? (u)->url_fragment : ""
00258 
00259 struct su_md5_t;
00260 
00262 SOFIAPUBFUN void url_update(struct su_md5_t *md5, url_t const *url);
00263 
00265 SOFIAPUBFUN void url_digest(void *hash, int hsize,
00266                             url_t const *, char const *key);
00267 
00268 
00269 SOFIA_END_DECLS
00270 #endif
00271 
00272 

Sofia-SIP 1.12.1 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.