NetSurf
url.h
Go to the documentation of this file.
1/*
2 * Copyright 2005 James Bursa <bursa@users.sourceforge.net>
3 * Copyright 2005 John M Bell <jmb202@ecs.soton.ac.uk>
4 *
5 * This file is part of NetSurf, http://www.netsurf-browser.org/
6 *
7 * NetSurf is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * NetSurf is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20/**
21 * \file utils/url.h
22 * \brief Interface to URL parsing and joining operations.
23 */
24
25#ifndef _NETSURF_UTILS_URL_H_
26#define _NETSURF_UTILS_URL_H_
27
28#include "utils/errors.h"
29
30
31/**
32 * Escape a string suitable for inclusion in an URL.
33 *
34 * \param[in] unescaped the unescaped string
35 * \param[in] sptoplus true iff spaces should be converted to +
36 * \param[in] escexceptions NULL or a string of characters to be excluded
37 * from escaping.
38 * \param[out] result Returns pointer to buffer to escaped string.
39 * Returned string is '\0' terminated.
40 * \return NSERROR_OK on success
41 */
42nserror url_escape(const char *unescaped, bool sptoplus,
43 const char *escexceptions, char **result);
44
45
46/**
47 * Convert an escaped string to plain.
48 *
49 * \param[in] str String to unescape.
50 * \param[in] length Length of string or 0 to use strlen.
51 * \param[out] length_out Iff non-NULL, value updated to length of returned
52 * result_out string (excluding trailing '\0'`).
53 * \param[out] result_out Returns unescaped string, owned by caller.
54 * Must be freed with free().
55 * Returned string has trailing '\0'.
56 * \return NSERROR_OK on success
57 */
58nserror url_unescape(const char *str, size_t length,
59 size_t *length_out, char **result_out);
60
61#endif
STATIC char result[100]
Definition: arexx.c:77
Error codes.
nserror
Enumeration of error codes.
Definition: errors.h:29
nserror url_escape(const char *unescaped, bool sptoplus, const char *escexceptions, char **result)
Escape a string suitable for inclusion in an URL.
Definition: url.c:131
nserror url_unescape(const char *str, size_t length, size_t *length_out, char **result_out)
Convert an escaped string to plain.
Definition: url.c:67