src/data_provider.[ch]: Implement "data_provider_get_ident_data".
[collection4.git] / src / utils_cgi.h
1 /**
2  * collection4 - utils_cgi.h
3  * Copyright (C) 2010  Florian octo Forster
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  * 
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA  02110-1301  USA
19  *
20  * Authors:
21  *   Florian octo Forster <ff at octo.it>
22  **/
23
24 #ifndef UTILS_CGI_H
25 #define UTILS_CGI_H 1
26
27 #include <time.h>
28
29 typedef int (*page_callback_t) (void *user_data);
30
31 struct page_callbacks_s
32 {
33   page_callback_t top_left;
34   page_callback_t top_center;
35   page_callback_t top_right;
36   page_callback_t middle_left;
37   page_callback_t middle_center;
38   page_callback_t middle_right;
39   page_callback_t bottom_left;
40   page_callback_t bottom_center;
41   page_callback_t bottom_right;
42 };
43 typedef struct page_callbacks_s page_callbacks_t;
44
45 struct param_list_s;
46 typedef struct param_list_s param_list_t;
47
48 #define PAGE_CALLBACKS_INIT \
49 { NULL, NULL, NULL, \
50   NULL, NULL, NULL, \
51   NULL, NULL, NULL }
52
53 int param_init (void);
54 void param_finish (void);
55
56 const char *param (const char *key);
57
58 /* Create a new parameter list from "query_string". If "query_string" is NULL,
59  * the "QUERY_STRING" will be used. */
60 param_list_t *param_create (const char *query_string);
61 param_list_t *param_clone (param_list_t *pl);
62 void param_destroy (param_list_t *pl);
63 const char *param_get (param_list_t *pl, const char *name);
64 int param_set (param_list_t *pl,
65     const char *name, const char *value);
66 char *param_as_string (param_list_t *pl);
67 int param_print_hidden (param_list_t *pl);
68
69 char *uri_escape (const char *string);
70 char *uri_escape_buffer (char *buffer, size_t buffer_size);
71 char *uri_escape_copy (char *dest, const char *src, size_t n);
72
73 char *json_escape (const char *string);
74 char *json_escape_buffer (char *buffer, size_t buffer_size);
75 char *json_escape_copy (char *dest, const char *src, size_t n);
76
77 const char *script_name (void);
78
79 int time_to_rfc1123 (time_t t, char *buffer, size_t buffer_size);
80
81 char *html_escape (const char *string);
82 char *html_escape_buffer (char *buffer, size_t buffer_size);
83 char *html_escape_copy (char *dest, const char *src, size_t n);
84
85 int html_print_page (const char *title,
86     const page_callbacks_t *cb, void *user_data);
87
88 int html_print_logo (void *user_data);
89
90 int html_print_search_box (void *user_data);
91
92 /* vim: set sw=2 sts=2 et fdm=marker : */
93 #endif /* UTILS_CGI_H */