chiark / gitweb /
Distribute unihash manpage.
[mLib] / url.h
CommitLineData
0f2a8846 1/* -*-c-*-
2 *
393cf1d9 3 * $Id: url.h,v 1.3 2001/01/20 12:06:01 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
30/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: url.h,v $
393cf1d9 33 * Revision 1.3 2001/01/20 12:06:01 mdw
34 * Define flags with macros, to ensure unsignedness.
35 *
c6e0eaf0 36 * Revision 1.2 1999/12/10 23:42:04 mdw
37 * Change header file guard names.
38 *
0f2a8846 39 * Revision 1.1 1999/06/01 09:49:48 mdw
40 * New files for url-encoding and decoding.
41 *
42 */
43
c6e0eaf0 44#ifndef MLIB_URL_H
45#define MLIB_URL_H
0f2a8846 46
47#ifdef __cplusplus
48 extern "C" {
49#endif
50
51/*----- Header files ------------------------------------------------------*/
52
c6e0eaf0 53#ifndef MLIB_DSTR_H
0f2a8846 54# include "dstr.h"
55#endif
56
57/*----- Data structures ---------------------------------------------------*/
58
59typedef struct url_ectx {
60 unsigned f;
61} url_ectx;
62
393cf1d9 63#define URLF_SEP 1u
0f2a8846 64
65typedef struct url_dctx {
66 const char *p;
67} url_dctx;
68
69/*----- Functions provided ------------------------------------------------*/
70
71/* --- @url_initenc@ --- *
72 *
73 * Arguments: @url_ectx *ctx@ = pointer to context block
74 *
75 * Returns: ---
76 *
77 * Use: Initializes a URL encoding context.
78 */
79
80extern void url_initenc(url_ectx */*ctx*/);
81
82/* --- @url_enc@ --- *
83 *
84 * Arguments: @url_ectx *ctx@ = pointer to encoding context
85 * @dstr *d@ = pointer to output string
86 * @const char *name@ = pointer to name
87 * @const char *value@ = pointer to value
88 *
89 * Returns: ---
90 *
91 * Use: Writes an assignment between @name@ and @value@ to the
92 * output string, encoding the values properly.
93 */
94
95extern void url_enc(url_ectx */*ctx*/, dstr */*d*/,
96 const char */*name*/, const char */*value*/);
97
98/* --- @url_initdec@ --- *
99 *
100 * Arguments: @url_dctx *ctx@ = pointer to context block
101 * @const char *p@ = string to read data from
102 *
103 * Returns: ---
104 *
105 * Use: Initializes a URL decoding context.
106 */
107
108extern void url_initdec(url_dctx */*ctx*/, const char */*p*/);
109
110/* --- @url_dec@ --- *
111 *
112 * Arguments: @url_dctx *ctx@ = pointer to decode context
113 * @dstr *n@ = pointer to output string for name
114 * @dstr *v@ = pointer to output string for value
115 *
116 * Returns: Nonzero if it read something, zero if there's nothing left
117 *
118 * Use: Decodes the next name/value pair from a urlencoded string.
119 */
120
121extern int url_dec(url_dctx */*ctx*/, dstr */*n*/, dstr */*v*/);
122
123/*----- That's all, folks -------------------------------------------------*/
124
125#ifdef __cplusplus
126 }
127#endif
128
129#endif