src/utils_cgi.[ch]: Basically a rewrite of the parameter handling functions.
[collection4.git] / src / utils_cgi.h
1 #ifndef UTILS_CGI_H
2 #define UTILS_CGI_H 1
3
4 #include <time.h>
5
6 typedef int (*page_callback_t) (void *user_data);
7
8 struct page_callbacks_s
9 {
10   page_callback_t top_left;
11   page_callback_t top_center;
12   page_callback_t top_right;
13   page_callback_t middle_left;
14   page_callback_t middle_center;
15   page_callback_t middle_right;
16   page_callback_t bottom_left;
17   page_callback_t bottom_center;
18   page_callback_t bottom_right;
19 };
20 typedef struct page_callbacks_s page_callbacks_t;
21
22 struct param_list_s;
23 typedef struct param_list_s param_list_t;
24
25 #define PAGE_CALLBACKS_INIT \
26 { NULL, NULL, NULL, \
27   NULL, NULL, NULL, \
28   NULL, NULL, NULL }
29
30 int param_init (void);
31 void param_finish (void);
32
33 const char *param (const char *key);
34
35 /* Create a new parameter list from "query_string". If "query_string" is NULL,
36  * the "QUERY_STRING" will be used. */
37 param_list_t *param_create (const char *query_string);
38 param_list_t *param_clone (param_list_t *pl);
39 void param_destroy (param_list_t *pl);
40 const char *param_get (param_list_t *pl, const char *name);
41 int param_set (param_list_t *pl,
42     const char *name, const char *value);
43 const char *param_as_string (param_list_t *pl);
44 int param_print_hidden (param_list_t *pl);
45
46 char *uri_escape (const char *string);
47 char *uri_escape_buffer (char *buffer, size_t buffer_size);
48 char *uri_escape_copy (char *dest, const char *src, size_t n);
49
50 const char *script_name (void);
51
52 int time_to_rfc1123 (time_t t, char *buffer, size_t buffer_size);
53
54 char *html_escape (const char *string);
55 char *html_escape_buffer (char *buffer, size_t buffer_size);
56 char *html_escape_copy (char *dest, const char *src, size_t n);
57
58 int html_print_page (const char *title,
59     const page_callbacks_t *cb, void *user_data);
60
61 int html_print_search_box (void *user_data);
62
63 /* vim: set sw=2 sts=2 et fdm=marker : */
64 #endif /* UTILS_CGI_H */