* replaced __thread with pthread_key_t/pthread_setspecific
[strongswan.git] / src / manager / lib / controller.h
1 /**
2 * @file controller.h
3 *
4 * @brief Interface controller_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 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 * @brief Controller action handle function
33 *
34 * @param request http request
35 * @param response http response
36 */
37 typedef void *(*controller_handler_t)(controller_t *this, request_t *request);
38
39 /**
40 * @brief Constructor function for a controller
41 *
42 * @param context session specific context
43 * @param param user supplied param
44 */
45 typedef controller_t *(*controller_constructor_t)(context_t* context, void *param);
46
47 /**
48 * @brief Controller interface, to be implemented by users controllers.
49 *
50 */
51 struct controller_t {
52
53 /**
54 * @brief Get the name of the controller.
55 *
56 * @return name of the controller
57 */
58 char* (*get_name)(controller_t *this);
59
60 /**
61 * @brief Handle a HTTP request for that controller.
62 *
63 * Request URLs are parsed in the form
64 * controller_name/p1/p2/p3/p4/p5 with a maximum of 5 parameters. Each
65 * parameter not found in the request URL is set to NULL.
66 *
67 * @param request HTTP request
68 * @param p1 first parameter
69 * @param p2 second parameter
70 * @param p3 third parameter
71 * @param p4 forth parameter
72 * @param p5 fifth parameter
73 * @return
74 */
75 void (*handle)(controller_t *this, request_t *request,
76 char *a1, char *a2, char *a3, char *a4, char *a5);
77
78 /**
79 * @brief Destroy the controller instance.
80 */
81 void (*destroy) (controller_t *this);
82 };
83
84 #endif /* CONTROLLER_H_ */