460b9539 |
1 | /* |
2 | * This file is part of DisOrder. |
3 | * Copyright (C) 2004, 2005 Richard Kettlewell |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, but |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
18 | * USA |
19 | */ |
20 | |
21 | #ifndef CGI_H |
22 | #define CGI_H |
23 | |
24 | extern struct kvp *cgi_args; |
25 | |
26 | typedef struct { |
27 | int quote; |
28 | struct sink *sink; |
29 | } cgi_sink; |
30 | |
31 | void cgi_parse(void); |
32 | /* parse CGI args */ |
33 | |
34 | const char *cgi_get(const char *name); |
35 | /* get an argument */ |
36 | |
37 | void cgi_header(struct sink *output, const char *name, const char *value); |
38 | /* output a header. @name@ and @value@ are ASCII. */ |
39 | |
40 | void cgi_body(struct sink *output); |
41 | /* indicate the start of the body */ |
42 | |
43 | void cgi_output(cgi_sink *output, const char *fmt, ...) |
44 | attribute((format (printf, 2, 3))); |
45 | /* SGML-quote formatted UTF-8 data and write it. Checks errors. */ |
46 | |
47 | char *cgi_sgmlquote(const char *s, int raw); |
48 | /* SGML-quote multibyte string @s@ */ |
49 | |
50 | void cgi_attr(struct sink *output, const char *name, const char *value); |
51 | /* write an attribute */ |
52 | |
53 | void cgi_opentag(struct sink *output, const char *name, ...); |
54 | /* write an open tag, including attribute name-value pairs terminate |
55 | * by (char *)0 */ |
56 | |
57 | void cgi_closetag(struct sink *output, const char *name); |
58 | /* write a close tag */ |
59 | |
60 | struct cgi_expansion { |
61 | const char *name; |
62 | int minargs, maxargs; |
63 | unsigned flags; |
64 | #define EXP_MAGIC 0x0001 |
65 | void (*handler)(int nargs, char **args, cgi_sink *output, void *u); |
66 | }; |
67 | |
68 | void cgi_expand(const char *name, |
69 | const struct cgi_expansion *expansions, |
70 | size_t nexpansions, |
71 | cgi_sink *output, |
72 | void *u); |
73 | /* find @name@ and substitute for expansions */ |
74 | |
75 | void cgi_expand_string(const char *name, |
76 | const char *template, |
77 | const struct cgi_expansion *expansions, |
78 | size_t nexpansions, |
79 | cgi_sink *output, |
80 | void *u); |
81 | /* same but @template@ is text of template */ |
82 | |
83 | char *cgi_makeurl(const char *url, ...); |
84 | /* make up a URL */ |
85 | |
86 | const char *cgi_label(const char *key); |
87 | /* look up the translated label @key@ */ |
88 | |
89 | char **cgi_columns(const char *name, int *nheadings); |
90 | /* return the list of columns for @name@ */ |
91 | |
92 | const char *cgi_transform(const char *type, |
93 | const char *track, |
94 | const char *context); |
95 | /* transform a track or directory name for display */ |
96 | |
97 | void cgi_set_option(const char *name, const char *value); |
98 | /* set an option */ |
99 | |
100 | #endif /* CGI_H */ |
101 | |
102 | /* |
103 | Local Variables: |
104 | c-basic-offset:2 |
105 | comment-column:40 |
106 | End: |
107 | */ |