libfast: cancel thread if it fails to accept fcgi sessions
[strongswan.git] / src / libfast / fast_controller.h
1 /*
2 * Copyright (C) 2007 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup fast_controller fast_controller
18 * @{ @ingroup libfast
19 */
20
21 #ifndef FAST_CONTROLLER_H_
22 #define FAST_CONTROLLER_H_
23
24 #include "fast_request.h"
25 #include "fast_context.h"
26
27 typedef struct fast_controller_t fast_controller_t;
28
29 /**
30 * Constructor function for a controller.
31 *
32 * @param context session specific context, implements context_t
33 * @param param user supplied param, as registered to the dispatcher
34 */
35 typedef fast_controller_t *(*fast_controller_constructor_t)(
36 fast_context_t* context, void *param);
37
38 /**
39 * Controller interface, to be implemented by users controllers.
40 *
41 * Controller instances get created per session, so each session has an
42 * associated set of private controller instances.
43 * The controller handle function is called for each incoming request.
44 */
45 struct fast_controller_t {
46
47 /**
48 * Get the name of the controller.
49 *
50 * @return name of the controller
51 */
52 char* (*get_name)(fast_controller_t *this);
53
54 /**
55 * Handle a HTTP request for that controller.
56 *
57 * Request URLs are parsed in the form
58 * controller_name/p1/p2/p3/p4/p5 with a maximum of 5 parameters. Each
59 * parameter not found in the request URL is set to NULL.
60 *
61 * @param request HTTP request
62 * @param p1 first parameter
63 * @param p2 second parameter
64 * @param p3 third parameter
65 * @param p4 forth parameter
66 * @param p5 fifth parameter
67 * @return
68 */
69 void (*handle)(fast_controller_t *this, fast_request_t *request,
70 char *p1, char *p2, char *p3, char *p4, char *p5);
71
72 /**
73 * Destroy the controller instance.
74 */
75 void (*destroy) (fast_controller_t *this);
76 };
77
78 #endif /** FAST_CONTROLLER_H_ @}*/