/usr/include/sofia-sip-1.12/sofia-sip/url.h is in libsofia-sip-ua-dev 1.12.11+20110422.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | /*
* This file is part of the Sofia-SIP package
*
* Copyright (C) 2005 Nokia Corporation.
*
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
/**@file sofia-sip/url.h
*
* URL struct and helper functions.
*
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
*
* @date Created: Thu Jun 8 19:28:55 2000 ppessi
*/
#ifndef URL_H_TYPES
#define URL_H_TYPES
/** Recognized URL schemes (value of url_t.url_type).
*
* @sa <<a href="http://www.iana.org/assignments/uri-schemes.html">http://www.iana.org/assignments/uri-schemes.html</a>>
*/
enum url_type_e {
url_invalid = -2, /**< Invalid url. */
url_unknown = -1, /**< Unknown scheme. */
url_any = 0, /**< "*" */
url_sip, /**< "sip:". @sa @RFC3261 */
url_sips, /**< "sips:". @sa @RFC3261 */
url_tel, /**< "tel:" @sa RFC3966 */
url_fax, /**< "fax:". @note Obsolete. @sa @RFC2806 */
url_modem, /**< "modem:". @note Obsolete. @sa @RFC2806 */
url_http, /**< "http:". @sa @RFC2616, @RFC3986 */
url_https, /**< "https:". @sa @RFC2618, @RFC3986 */
url_ftp, /**< "ftp:". @sa @RFC1738 */
url_file, /**< "file:" @sa @RFC1738 */
url_rtsp, /**< "rtsp:" @sa @RFC2326 */
url_rtspu, /**< "rtspu:" @sa @RFC2326 */
url_mailto, /**< "mailto:" @sa @RFC2368 */
url_im, /**< "im:" (simple instant messaging). @sa @RFC3860 */
url_pres, /**< "pres:" (simple presence). @sa @RFC3859 */
url_cid, /**< "cid:" (Content-ID). @sa @RFC2392 */
url_msrp, /**< "msrp:" (message session relay) */
url_msrps, /**< "msrps:" (new in @VERSION_1_12_2) */
url_wv, /**< "wv:" (Wireless village) */
_url_none
};
/** URL structure.
*
* This structure is used to present a parsed URL.
*/
typedef struct {
char url_pad[sizeof(void *) - 2];
/**< Zero pad for URL_STRING_P(). */
signed char url_type; /**< URL type (url_type_e). */
char url_root; /**< Nonzero if root "//" */
char const *url_scheme; /**< URL type as string. */
char const *url_user; /**< User part */
char const *url_password; /**< Password */
char const *url_host; /**< Host part */
char const *url_port; /**< Port */
char const *url_path; /**< Path part, starts with "/" */
char const *url_params; /**< Parameters (separated by ;) */
char const *url_headers; /**< Headers (separated by ? and &) */
char const *url_fragment; /**< Fragment (separated by #) */
} url_t;
enum {
/** Maximum size of a URL. */
URL_MAXLEN = 65536
};
/** Type to present either a parsed URL or string.
*
* The union type url_string_t is used to pass a parsed URL or string as a
* parameter. The URL_STRING_P() checks if a passed pointer points to a
* string or a parsed URL. Testing requires that the first character of the
* string is nonzero. Use URL_STRING_MAKE() to properly cast a string
* pointer as a pointer to url_string_t.
*/
typedef union {
char us_str[URL_MAXLEN]; /**< URL as a string. */
url_t us_url[1]; /**< Parsed URL. */
} url_string_t;
#endif
#ifndef URL_H
/** Defined when <sofia-sip/url.h> has been included. */
#define URL_H
#ifndef SU_ALLOC_H
#include <sofia-sip/su_alloc.h>
#endif
SOFIA_BEGIN_DECLS
/** Convert a string to a url struct. */
SOFIAPUBFUN url_t *url_make(su_home_t *h, char const *str);
/** Convert a string formatting result to a url struct. */
SOFIAPUBFUN url_t *url_format(su_home_t *h, char const *fmt, ...);
/** Convert #url_t to a string allocated from @a home */
SOFIAPUBFUN char *url_as_string(su_home_t *home, url_t const *url);
/** Duplicate the url to memory allocated via home */
SOFIAPUBFUN url_t *url_hdup(su_home_t *h, url_t const *src);
/** Sanitize a URL. */
SOFIAPUBFUN int url_sanitize(url_t *u);
/** Get URL scheme by type. */
SOFIAPUBFUN char const *url_scheme(enum url_type_e type);
/* ---------------------------------------------------------------------- */
/* URL comparison */
/** Compare two URLs lazily. */
SOFIAPUBFUN int url_cmp(url_t const *a, url_t const *b);
/** Compare two URLs conservatively. */
SOFIAPUBFUN int url_cmp_all(url_t const *a, url_t const *b);
/* ---------------------------------------------------------------------- */
/* Parameter handling */
/** Search for a parameter. */
SOFIAPUBFUN isize_t url_param(char const *params, char const *tag,
char value[], isize_t vlen);
/** Check for a parameter. */
SOFIAPUBFUN int url_has_param(url_t const *url, char const *name);
/** Check for a presence of a parameter in string. */
SOFIAPUBFUN isize_t url_have_param(char const *params, char const *tag);
/** Add a parameter. */
SOFIAPUBFUN int url_param_add(su_home_t *h, url_t *url, char const *param);
/** Strip transport-specific stuff away from URI. */
SOFIAPUBFUN int url_strip_transport(url_t *u);
/** Strip parameter away from URI. */
SOFIAPUBFUN char *url_strip_param_string(char *params, char const *name);
/** Test if url has any transport-specific stuff. */
SOFIAPUBFUN int url_have_transport(url_t const *u);
/* ---------------------------------------------------------------------- */
/* Query handling */
/** Convert a URL query to a header string. */
SOFIAPUBFUN char *url_query_as_header_string(su_home_t *home,
char const *query);
/* ---------------------------------------------------------------------- */
/* Handling url-escque strings */
/** Test if string contains url-reserved characters. */
SOFIAPUBFUN int url_reserved_p(char const *s);
/** Escape a string. */
SOFIAPUBFUN char *url_escape(char *d, char const *s, char const reserved[]);
/** Calculate length of string when escaped. */
SOFIAPUBFUN isize_t url_esclen(char const *s, char const reserved[]);
/** Unescape characters from string */
SOFIAPUBFUN size_t url_unescape_to(char *d, char const *s, size_t n);
/** Unescape a string */
SOFIAPUBFUN char *url_unescape(char *d, char const *s);
#define URL_RESERVED_CHARS ";/?:@&=+$,"
/* ---------------------------------------------------------------------- */
/* Initializing */
/** Initializer for an #url_t structure. @HI
*
* The macro URL_INIT_AS() is used to initialize a #url_t structure with a
* known url type:
* @code
* url_t urls[2] = { URL_INIT_AS(sip), URL_INIT_AS(http) };
* @endcode
*/
#define URL_INIT_AS(type) \
{ "\0", url_##type, 0, url_##type != url_any ? #type : "*" }
/** Init a url structure as given type */
SOFIAPUBFUN void url_init(url_t *url, enum url_type_e type);
/* ---------------------------------------------------------------------- */
/* Resolving helpers */
/** Return default port number corresponding to the url type. */
SOFIAPUBFUN char const *url_port_default(enum url_type_e url_type);
/** Return default transport name corresponding to the url type */
SOFIAPUBFUN char const *url_tport_default(enum url_type_e url_type);
/** Return the URL port string, using default port if not present. */
SOFIAPUBFUN char const *url_port(url_t const *u);
/** Return the URL port string, using default port if none present. */
#define URL_PORT(u) \
((u) && (u)->url_port ? (u)->url_port : \
url_port_default((u) ? (enum url_type_e)(u)->url_type : url_any))
/* ---------------------------------------------------------------------- */
/* url_string_t handling */
/** Test if a pointer to #url_string_t is a string
* (not a pointer to a #url_t structure). */
#define URL_STRING_P(u) ((u) && *((url_string_t*)(u))->us_str != 0)
/** Test if a pointer to #url_string_t is a string
* (not a pointer to a #url_t structure). */
#define URL_IS_STRING(u) ((u) && *((url_string_t*)(u))->us_str != 0)
/** Test if a pointer to #url_string_t is a string
* (not a pointer to a #url_t structure). */
SOFIAPUBFUN int url_string_p(url_string_t const * url);
/** Test if a pointer to #url_string_t is a string
* (not a pointer to a #url_t structure). */
SOFIAPUBFUN int url_is_string(url_string_t const * url);
/** Cast a string to a #url_string_t. @HI */
#define URL_STRING_MAKE(s) \
((url_string_t *)((s) && *((char *)(s)) ? (s) : NULL))
/* ---------------------------------------------------------------------- */
/* Printing URL */
/** Format string used when printing url with printf(). @HI */
#define URL_PRINT_FORMAT "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
#define URL_FORMAT_STRING URL_PRINT_FORMAT
/** Argument list used when printing url with printf(). @HI */
#define URL_PRINT_ARGS(u) \
(u)->url_scheme ? (u)->url_scheme : "", \
(u)->url_type != url_any && (u)->url_scheme && (u)->url_scheme[0] \
? ":" : "", \
(u)->url_root && ((u)->url_host || (u)->url_user) ? "//" : "", \
(u)->url_user ? (u)->url_user : "", \
(u)->url_user && (u)->url_password ? ":" : "", \
(u)->url_user && (u)->url_password ? (u)->url_password : "", \
(u)->url_user && (u)->url_host ? "@" : "", \
(u)->url_host ? (u)->url_host : "", \
(u)->url_host && (u)->url_port ? ":" : "", \
(u)->url_host && (u)->url_port ? (u)->url_port : "", \
(u)->url_root && (u)->url_path ? "/" : "", \
(u)->url_path ? (u)->url_path : "", \
(u)->url_params ? ";" : "", (u)->url_params ? (u)->url_params : "", \
(u)->url_headers ? "?" : "", (u)->url_headers ? (u)->url_headers : "", \
(u)->url_fragment ? "#" : "", (u)->url_fragment ? (u)->url_fragment : ""
/* ---------------------------------------------------------------------- */
/* URL digests */
struct su_md5_t;
/** Update MD5 sum with URL contents. */
SOFIAPUBFUN void url_update(struct su_md5_t *md5, url_t const *url);
/** Calculate a digest from URL contents. */
SOFIAPUBFUN void url_digest(void *hash, int hsize,
url_t const *, char const *key);
/* ---------------------------------------------------------------------- */
/* Parsing and manipulating URLs */
/** Decode a URL. */
SOFIAPUBFUN int url_d(url_t *url, char *s);
/** Calculate the encoding length of URL. */
SOFIAPUBFUN isize_t url_len(url_t const * url);
/** Encode a URL. */
SOFIAPUBFUN issize_t url_e(char buffer[], isize_t n, url_t const *url);
/** Encode a URL: use @a buf up to @a end. @HI */
#define URL_E(buf, end, url) \
(buf) += url_e((buf), (buf) < (end) ? (end) - (buf) : 0, (url))
/** Calculate the size of srings attached to the url. */
SOFIAPUBFUN isize_t url_xtra(url_t const * url);
/** Duplicate the url in the provided memory area. */
SOFIAPUBFUN issize_t url_dup(char *, isize_t , url_t *dst, url_t const *src);
/** Duplicate the url: use @a buf up to @a end. @HI */
#define URL_DUP(buf, end, dst, src) \
(buf) += url_dup((buf), (isize_t)((buf) < (end) ? (end) - (buf) : 0), (dst), (src))
SOFIA_END_DECLS
#endif
|