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