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