chiark / gitweb /
Infrastructure: Split the files into subdirectories.
[mLib] / codec / url.h
CommitLineData
0f2a8846 1/* -*-c-*-
0f2a8846 2 *
3 * Parsing and construction of url-encoded name/value pairs
4 *
5 * (c) 1999 Straylight/Edgeware
6 */
7
d4efbcd9 8/*----- Licensing notice --------------------------------------------------*
0f2a8846 9 *
10 * This file is part of the mLib utilities library.
11 *
12 * mLib is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
d4efbcd9 16 *
0f2a8846 17 * mLib is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
d4efbcd9 21 *
0f2a8846 22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 * MA 02111-1307, USA.
26 */
27
c6e0eaf0 28#ifndef MLIB_URL_H
29#define MLIB_URL_H
0f2a8846 30
31#ifdef __cplusplus
32 extern "C" {
33#endif
34
35/*----- Header files ------------------------------------------------------*/
36
c6e0eaf0 37#ifndef MLIB_DSTR_H
0f2a8846 38# include "dstr.h"
39#endif
40
41/*----- Data structures ---------------------------------------------------*/
42
43typedef struct url_ectx {
44 unsigned f;
45} url_ectx;
46
0f2a8846 47
48typedef struct url_dctx {
49 const char *p;
9dc511e4 50 unsigned f;
0f2a8846 51} url_dctx;
52
9dc511e4
MW
53#define URLF_SEP 1u
54#define URLF_STRICT 2u
55#define URLF_LAX 4u
56#define URLF_SEMI 8u
57
0f2a8846 58/*----- Functions provided ------------------------------------------------*/
59
60/* --- @url_initenc@ --- *
61 *
62 * Arguments: @url_ectx *ctx@ = pointer to context block
63 *
64 * Returns: ---
65 *
66 * Use: Initializes a URL encoding context.
67 */
68
69extern void url_initenc(url_ectx */*ctx*/);
70
71/* --- @url_enc@ --- *
72 *
73 * Arguments: @url_ectx *ctx@ = pointer to encoding context
74 * @dstr *d@ = pointer to output string
75 * @const char *name@ = pointer to name
76 * @const char *value@ = pointer to value
77 *
78 * Returns: ---
79 *
80 * Use: Writes an assignment between @name@ and @value@ to the
81 * output string, encoding the values properly.
82 */
83
84extern void url_enc(url_ectx */*ctx*/, dstr */*d*/,
85 const char */*name*/, const char */*value*/);
86
87/* --- @url_initdec@ --- *
88 *
89 * Arguments: @url_dctx *ctx@ = pointer to context block
90 * @const char *p@ = string to read data from
91 *
92 * Returns: ---
93 *
94 * Use: Initializes a URL decoding context.
95 */
96
97extern void url_initdec(url_dctx */*ctx*/, const char */*p*/);
98
99/* --- @url_dec@ --- *
100 *
101 * Arguments: @url_dctx *ctx@ = pointer to decode context
102 * @dstr *n@ = pointer to output string for name
103 * @dstr *v@ = pointer to output string for value
104 *
105 * Returns: Nonzero if it read something, zero if there's nothing left
106 *
107 * Use: Decodes the next name/value pair from a urlencoded string.
108 */
109
110extern int url_dec(url_dctx */*ctx*/, dstr */*n*/, dstr */*v*/);
111
112/*----- That's all, folks -------------------------------------------------*/
113
114#ifdef __cplusplus
115 }
116#endif
117
118#endif