Add to git.
[rws.git] / rws_request.h
1 /* RWS request object, passed to shared object scripts.
2  * - by Richard W.M. Jones <rich@annexia.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the Free
16  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  *
18  * $Id: rws_request.h,v 1.4 2002/12/01 14:58:02 rich Exp $
19  */
20
21 #ifndef RWS_REQUEST_H
22 #define RWS_REQUEST_H
23
24 #include <pool.h>
25 #include <pthr_pseudothread.h>
26 #include <pthr_http.h>
27 #include <pthr_iolib.h>
28
29 struct rws_request;
30 typedef struct rws_request *rws_request;
31
32 /* This is the private interface to building a new rws_request object. It
33  * is called inside rwsd. Shared object scripts will never need to call
34  * this. Use the public interface below only.
35  */
36 extern rws_request new_rws_request (pool, http_request, io_handle, const char *host_header, const char *canonical_path, const char *file_path, void *host, void *alias, const char * (*cfg_get_string) (void *, void *, const char *, const char *), int (*cfg_get_int) (void *, void *, const char *, int), int (*cfg_get_bool) (void *, void *, const char *, int));
37
38 /* Function: rws_request_http_request - retrieve fields in rws_request object
39  * Function: rws_request_io
40  * Function: rws_request_host_header
41  * Function: rws_request_canonical_path
42  * Function: rws_request_file_path
43  * Function: rws_request_cfg_get_string
44  * Function: rws_request_cfg_get_int
45  * Function: rws_request_cfg_get_bool
46  *
47  * These functions retrieve the fields in an @code{rws_request} object.
48  * This object is passed to shared object scripts when they are invoked
49  * by rws as:
50  *
51  * @code{int handle_request (rws_request rq)}
52  *
53  * @code{rws_request_http_request} returns the current HTTP request
54  * (see @ref{new_http_request(3)}). To parse the CGI parameters, you
55  * need to call @code{new_cgi} (see @ref{new_cgi(3)}).
56  *
57  * @code{rws_request_io} returns the IO handle connected to the
58  * browser.
59  *
60  * @code{rws_request_host_header} returns the contents of the
61  * HTTP @code{Host:} header, or the string @code{default} if none was given.
62  *
63  * @code{rws_request_canonical_path} returns the canonical path
64  * requested by the browser (after removing @code{..}, @code{//}, etc.),
65  * eg. @code{/so-bin/file.so}.
66  *
67  * @code{rws_request_file_path} returns the actual path to the
68  * SO file being requested, eg. @code{/usr/share/rws/so-bin/file.so}.
69  *
70  * @code{rws_request_cfg_get_string} returns the configuration file
71  * string for @code{key}. If there is no entry in the configuration
72  * file, this returns @code{default_value}.
73  *
74  * @code{rws_request_cfg_get_int} returns the string converted to
75  * an integer.
76  *
77  * @code{rws_request_cfg_get_bool} returns the string converted to
78  * a boolean.
79  *
80  * See also: @ref{new_cgi(3)}, @ref{new_http_response(3)},
81  * @ref{new_http_request(3)}, pthrlib tutorial, rws @code{examples/}
82  * directory.
83  */
84 extern http_request rws_request_http_request (rws_request);
85 extern io_handle rws_request_io (rws_request);
86 extern const char *rws_request_host_header (rws_request);
87 extern const char *rws_request_canonical_path (rws_request);
88 extern const char *rws_request_file_path (rws_request);
89 extern const char *rws_request_cfg_get_string (rws_request, const char *key, const char *default_value);
90 extern int rws_request_cfg_get_int (rws_request, const char *key, int default_value);
91 extern int rws_request_cfg_get_bool (rws_request, const char *key, int default_value);
92
93 #endif /* RWS_REQUEST_H */