3 * Parsing and construction of url-encoded name/value pairs
5 * (c) 1999 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
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.
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.
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,
35 /*----- Header files ------------------------------------------------------*/
41 /*----- Data structures ---------------------------------------------------*/
43 typedef struct url_ectx {
48 typedef struct url_dctx {
54 #define URLF_STRICT 2u
58 /*----- Functions provided ------------------------------------------------*/
60 /* --- @url_initenc@ --- *
62 * Arguments: @url_ectx *ctx@ = pointer to context block
66 * Use: Initializes a URL encoding context.
69 extern void url_initenc(url_ectx */*ctx*/);
71 /* --- @url_enc@ --- *
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
80 * Use: Writes an assignment between @name@ and @value@ to the
81 * output string, encoding the values properly.
84 extern void url_enc(url_ectx */*ctx*/, dstr */*d*/,
85 const char */*name*/, const char */*value*/);
87 /* --- @url_initdec@ --- *
89 * Arguments: @url_dctx *ctx@ = pointer to context block
90 * @const char *p@ = string to read data from
94 * Use: Initializes a URL decoding context.
97 extern void url_initdec(url_dctx */*ctx*/, const char */*p*/);
99 /* --- @url_dec@ --- *
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
105 * Returns: Nonzero if it read something, zero if there's nothing left
107 * Use: Decodes the next name/value pair from a urlencoded string.
110 extern int url_dec(url_dctx */*ctx*/, dstr */*n*/, dstr */*v*/);
112 /*----- That's all, folks -------------------------------------------------*/