libgcgi.h - libgcgi - REST library for Gopher | |
git clone git://bitreich.org/libgcgi/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinw… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
libgcgi.h (1554B) | |
--- | |
1 #include <stddef.h> | |
2 | |
3 #ifndef LIBGCGI_H | |
4 #define LIBGCGI_H | |
5 | |
6 /* | |
7 * Gopher CGI library to use in CGI scripts | |
8 * | |
9 * See libgcgi(3) or the README for usage and examples. | |
10 */ | |
11 | |
12 /* maps glob pattern */ | |
13 struct gcgi_handler { | |
14 char const *glob; | |
15 void (*fn)(char **matches); | |
16 }; | |
17 | |
18 /* storage for key-value pair */ | |
19 struct gcgi_var_list { | |
20 struct gcgi_var { | |
21 char *key, *val; | |
22 } *list; | |
23 size_t len; | |
24 char *buf; | |
25 }; | |
26 | |
27 /* main loop executing h->fn() if h->glob is matching */ | |
28 void gcgi_handle_request(struct gcgi_handler h[], char **argv, int argc); | |
29 | |
30 /* abort the program with an error message sent to the client */ | |
31 void gcgi_fatal(char *fmt, ...); | |
32 | |
33 /* print a template with every "{{name}}" looked up in `vars` */ | |
34 void gcgi_template(char const *path, struct gcgi_var_list *vars); | |
35 | |
36 /* manage a `key`-`val` pair storage `vars`, as used with gcgi_template … | |
37 void gcgi_set_var(struct gcgi_var_list *vars, char *key, char *val); | |
38 char *gcgi_get_var(struct gcgi_var_list *vars, char *key); | |
39 void gcgi_free_var_list(struct gcgi_var_list *vars); | |
40 | |
41 /* store and read a list of variables onto a simple RFC822-like format */ | |
42 void gcgi_read_var_list(struct gcgi_var_list *vars, char *path); | |
43 int gcgi_write_var_list(struct gcgi_var_list *vars, char *path); | |
44 | |
45 /* components of the gopher request */ | |
46 extern char *gcgi_gopher_search; | |
47 extern char *gcgi_gopher_path; | |
48 extern struct gcgi_var_list gcgi_gopher_query; | |
49 extern char *gcgi_gopher_host; | |
50 extern char *gcgi_gopher_port; | |
51 | |
52 /* need to be provided if not present in libc, which is rare */ | |
53 char *strsep(char **s, const char *delims); | |
54 | |
55 #endif |