e6fd71e714411d61b5df7334749df6d53d87f10e
[strongswan.git] / src / manager / lib / request.h
1 /**
2 * @file request.h
3 *
4 * @brief Interface of request_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef REQUEST_H_
24 #define REQUEST_H_
25
26 #include <fcgiapp.h>
27 #include <library.h>
28
29 typedef struct request_t request_t;
30
31 /**
32 * @brief A HTTP request, encapsulates FCGX_Request.
33 *
34 */
35 struct request_t {
36
37 /**
38 * @brief Add a cookie to the reply (Set-Cookie header).
39 *
40 * @param name name of the cookie to set
41 * @param value value of the cookie
42 */
43 void (*add_cookie)(request_t *this, char *name, char *value);
44
45 /**
46 * @brief Get a cookie the client sent in the request.
47 *
48 * @param name name of the cookie
49 * @return cookie value, NULL if no such cookie found
50 */
51 char* (*get_cookie)(request_t *this, char *name);
52
53 /**
54 * @brief Get the request path relative to the application.
55 *
56 * @return path
57 */
58 char* (*get_path)(request_t *this);
59
60 /**
61 * @brief Get the base path of the application.
62 *
63 * @return base path
64 */
65 char* (*get_base)(request_t *this);
66
67 /**
68 * @brief Get a post/get variable included in the request.
69 *
70 * @param name name of the POST/GET variable
71 * @return value, NULL if not found
72 */
73 char* (*get_query_data)(request_t *this, char *name);
74
75 /**
76 * @brief Redirect the client to another location.
77 *
78 * @param location location to redirect to
79 */
80 void (*redirect)(request_t *this, char *location);
81
82 /**
83 * @brief Set a template value.
84 *
85 * @param key key to set
86 * @param value value to set key to
87 */
88 void (*set)(request_t *this, char *key, char *value);
89
90 /**
91 * @brief Set a template value using format strings.
92 *
93 * Format string is in the form "key=value", where printf like format
94 * substitution occurs over the whole string.
95 *
96 * @param format printf like format string
97 * @param ... variable argument list
98 */
99 void (*setf)(request_t *this, char *format, ...);
100
101 /**
102 * @brief Render a template.
103 *
104 * The render() function additionally sets a HDF variable "base"
105 * which points to the root of the web application and allows to point to
106 * other targets without to worry about path location.
107 *
108 * @param template clearsilver template file location
109 * @return rendered template string
110 */
111 void (*render)(request_t *this, char *template);
112
113 /**
114 * @brief Destroy the request_t.
115 */
116 void (*destroy) (request_t *this);
117 };
118
119 /**
120 * @brief Create a request from the fastcgi struct.
121 *
122 * @param request the FCGI request
123 * @param debug no stripping, no compression, timing information
124 */
125 request_t *request_create(FCGX_Request *request, bool debug);
126
127 #endif /* REQUEST_H_ */