Commit | Line | Data |
---|---|---|
460b9539 | 1 | /* |
2 | * This file is part of DisOrder. | |
5aff007d | 3 | * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell |
460b9539 | 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 | ||
5b708e0c RK |
21 | #ifndef SERVER_CGI_H |
22 | #define SERVER_CGI_H | |
460b9539 | 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 | ||
3dddcfa4 RK |
68 | void cgi_define(const char *name, |
69 | int nargs, | |
70 | char **args, | |
71 | const char *value); | |
72 | ||
460b9539 | 73 | void cgi_expand(const char *name, |
74 | const struct cgi_expansion *expansions, | |
75 | size_t nexpansions, | |
76 | cgi_sink *output, | |
77 | void *u); | |
78 | /* find @name@ and substitute for expansions */ | |
79 | ||
80 | void cgi_expand_string(const char *name, | |
81 | const char *template, | |
82 | const struct cgi_expansion *expansions, | |
83 | size_t nexpansions, | |
84 | cgi_sink *output, | |
85 | void *u); | |
86 | /* same but @template@ is text of template */ | |
87 | ||
88 | char *cgi_makeurl(const char *url, ...); | |
89 | /* make up a URL */ | |
90 | ||
91 | const char *cgi_label(const char *key); | |
92 | /* look up the translated label @key@ */ | |
93 | ||
8f9616f1 RK |
94 | int cgi_label_exists(const char *key); |
95 | ||
460b9539 | 96 | char **cgi_columns(const char *name, int *nheadings); |
97 | /* return the list of columns for @name@ */ | |
98 | ||
99 | const char *cgi_transform(const char *type, | |
100 | const char *track, | |
101 | const char *context); | |
102 | /* transform a track or directory name for display */ | |
103 | ||
104 | void cgi_set_option(const char *name, const char *value); | |
105 | /* set an option */ | |
106 | ||
5b708e0c | 107 | #endif /* SERVER_CGI_H */ |
460b9539 | 108 | |
109 | /* | |
110 | Local Variables: | |
111 | c-basic-offset:2 | |
112 | comment-column:40 | |
113 | End: | |
114 | */ |