chiark / gitweb /
First step towards user rights
[disorder] / server / cgi.h
CommitLineData
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
21#ifndef CGI_H
22#define CGI_H
23
24extern struct kvp *cgi_args;
25
26typedef struct {
27 int quote;
28 struct sink *sink;
29} cgi_sink;
30
31void cgi_parse(void);
32/* parse CGI args */
33
34const char *cgi_get(const char *name);
35/* get an argument */
36
37void cgi_header(struct sink *output, const char *name, const char *value);
38/* output a header. @name@ and @value@ are ASCII. */
39
40void cgi_body(struct sink *output);
41/* indicate the start of the body */
42
43void 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
47char *cgi_sgmlquote(const char *s, int raw);
48/* SGML-quote multibyte string @s@ */
49
50void cgi_attr(struct sink *output, const char *name, const char *value);
51/* write an attribute */
52
53void cgi_opentag(struct sink *output, const char *name, ...);
54/* write an open tag, including attribute name-value pairs terminate
55 * by (char *)0 */
56
57void cgi_closetag(struct sink *output, const char *name);
58/* write a close tag */
59
60struct 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
68void 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
75void 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
83char *cgi_makeurl(const char *url, ...);
84/* make up a URL */
85
86const char *cgi_label(const char *key);
87/* look up the translated label @key@ */
88
8f9616f1
RK
89int cgi_label_exists(const char *key);
90
460b9539 91char **cgi_columns(const char *name, int *nheadings);
92/* return the list of columns for @name@ */
93
94const char *cgi_transform(const char *type,
95 const char *track,
96 const char *context);
97/* transform a track or directory name for display */
98
99void cgi_set_option(const char *name, const char *value);
100/* set an option */
101
102#endif /* CGI_H */
103
104/*
105Local Variables:
106c-basic-offset:2
107comment-column:40
108End:
109*/