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