9ac641fefb3be469894d05a11beaec4ba851bfd1
[strongswan.git] / src / libfast / 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 * $Id$
16 */
17
18 /**
19 * @defgroup controller_i controller
20 * @{ @ingroup libfast
21 */
22
23 #ifndef CONTROLLER_H_
24 #define CONTROLLER_H_
25
26 #include "request.h"
27 #include "context.h"
28
29 typedef struct controller_t controller_t;
30
31 /**
32 * Constructor function for a controller.
33 *
34 * @param context session specific context, implements context_t
35 * @param param user supplied param, as registered to the dispatcher
36 */
37 typedef controller_t *(*controller_constructor_t)(context_t* context, void *param);
38
39 /**
40 * Controller interface, to be implemented by users controllers.
41 *
42 * Controller instances get created per session, so each session has an
43 * associated set of private controller instances.
44 * The controller handle function is called for each incoming request.
45 */
46 struct controller_t {
47
48 /**
49 * Get the name of the controller.
50 *
51 * @return name of the controller
52 */
53 char* (*get_name)(controller_t *this);
54
55 /**
56 * Handle a HTTP request for that controller.
57 *
58 * Request URLs are parsed in the form
59 * controller_name/p1/p2/p3/p4/p5 with a maximum of 5 parameters. Each
60 * parameter not found in the request URL is set to NULL.
61 *
62 * @param request HTTP request
63 * @param p1 first parameter
64 * @param p2 second parameter
65 * @param p3 third parameter
66 * @param p4 forth parameter
67 * @param p5 fifth parameter
68 * @return
69 */
70 void (*handle)(controller_t *this, request_t *request,
71 char *p1, char *p2, char *p3, char *p4, char *p5);
72
73 /**
74 * Destroy the controller instance.
75 */
76 void (*destroy) (controller_t *this);
77 };
78
79 #endif /* CONTROLLER_H_ @} */