diff options
Diffstat (limited to 'src/manager/controller')
-rw-r--r-- | src/manager/controller/auth_controller.c | 39 | ||||
-rw-r--r-- | src/manager/controller/config_controller.c | 39 | ||||
-rw-r--r-- | src/manager/controller/control_controller.c | 39 | ||||
-rw-r--r-- | src/manager/controller/gateway_controller.c | 40 | ||||
-rw-r--r-- | src/manager/controller/ikesa_controller.c | 39 |
5 files changed, 95 insertions, 101 deletions
diff --git a/src/manager/controller/auth_controller.c b/src/manager/controller/auth_controller.c index dd469cee4..c9a9b5461 100644 --- a/src/manager/controller/auth_controller.c +++ b/src/manager/controller/auth_controller.c @@ -67,19 +67,15 @@ static void logout(private_auth_controller_t *this, request_t *request) request->redirect(request, "auth/login"); } -/** - * Implementation of controller_t.get_name - */ -static char* get_name(private_auth_controller_t *this) +METHOD(controller_t, get_name, char*, + private_auth_controller_t *this) { return "auth"; } -/** - * Implementation of controller_t.handle - */ -static void handle(private_auth_controller_t *this, - request_t *request, char *action) +METHOD(controller_t, handle, void, + private_auth_controller_t *this, request_t *request, char *action, + char *p2, char *p3, char *p4, char *p5) { if (action) { @@ -99,10 +95,8 @@ static void handle(private_auth_controller_t *this, request->redirect(request, "auth/login"); } -/** - * Implementation of controller_t.destroy - */ -static void destroy(private_auth_controller_t *this) +METHOD(controller_t, destroy, void, + private_auth_controller_t *this) { free(this); } @@ -112,13 +106,18 @@ static void destroy(private_auth_controller_t *this) */ controller_t *auth_controller_create(context_t *context, void *param) { - private_auth_controller_t *this = malloc_thing(private_auth_controller_t); - - this->public.controller.get_name = (char*(*)(controller_t*))get_name; - this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle; - this->public.controller.destroy = (void(*)(controller_t*))destroy; - - this->manager = (manager_t*)context; + private_auth_controller_t *this; + + INIT(this, + .public = { + .controller = { + .get_name = _get_name, + .handle = _handle, + .destroy = _destroy, + }, + }, + .manager = (manager_t*)context, + ); return &this->public.controller; } diff --git a/src/manager/controller/config_controller.c b/src/manager/controller/config_controller.c index 828a4ac97..154ab615e 100644 --- a/src/manager/controller/config_controller.c +++ b/src/manager/controller/config_controller.c @@ -149,19 +149,15 @@ static void list(private_config_controller_t *this, request_t *r) } } -/** - * Implementation of controller_t.get_name - */ -static char* get_name(private_config_controller_t *this) +METHOD(controller_t, get_name, char*, + private_config_controller_t *this) { return "config"; } -/** - * Implementation of controller_t.handle - */ -static void handle(private_config_controller_t *this, - request_t *request, char *action) +METHOD(controller_t, handle, void, + private_config_controller_t *this, request_t *request, char *action, + char *p2, char *p3, char *p4, char *p5) { if (!this->manager->logged_in(this->manager)) { @@ -181,10 +177,8 @@ static void handle(private_config_controller_t *this, return request->redirect(request, "config/list"); } -/** - * Implementation of controller_t.destroy - */ -static void destroy(private_config_controller_t *this) +METHOD(controller_t, destroy, void, + private_config_controller_t *this) { free(this); } @@ -194,13 +188,18 @@ static void destroy(private_config_controller_t *this) */ controller_t *config_controller_create(context_t *context, void *param) { - private_config_controller_t *this = malloc_thing(private_config_controller_t); - - this->public.controller.get_name = (char*(*)(controller_t*))get_name; - this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle; - this->public.controller.destroy = (void(*)(controller_t*))destroy; - - this->manager = (manager_t*)context; + private_config_controller_t *this; + + INIT(this, + .public = { + .controller = { + .get_name = _get_name, + .handle = _handle, + .destroy = _destroy, + }, + }, + .manager = (manager_t*)context, + ); return &this->public.controller; } diff --git a/src/manager/controller/control_controller.c b/src/manager/controller/control_controller.c index fdf66bf14..68238d02f 100644 --- a/src/manager/controller/control_controller.c +++ b/src/manager/controller/control_controller.c @@ -120,19 +120,15 @@ static void terminate(private_control_controller_t *this, request_t *r, handle_result(this, r, e); } -/** - * Implementation of controller_t.get_name - */ -static char* get_name(private_control_controller_t *this) +METHOD(controller_t, get_name, char*, + private_control_controller_t *this) { return "control"; } -/** - * Implementation of controller_t.handle - */ -static void handle(private_control_controller_t *this, - request_t *request, char *action, char *str) +METHOD(controller_t, handle, void, + private_control_controller_t *this, request_t *request, char *action, + char *str, char *p3, char *p4, char *p5) { if (!this->manager->logged_in(this->manager)) { @@ -178,10 +174,8 @@ static void handle(private_control_controller_t *this, return request->redirect(request, "ikesa/list"); } -/** - * Implementation of controller_t.destroy - */ -static void destroy(private_control_controller_t *this) +METHOD(controller_t, destroy, void, + private_control_controller_t *this) { free(this); } @@ -191,13 +185,18 @@ static void destroy(private_control_controller_t *this) */ controller_t *control_controller_create(context_t *context, void *param) { - private_control_controller_t *this = malloc_thing(private_control_controller_t); - - this->public.controller.get_name = (char*(*)(controller_t*))get_name; - this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle; - this->public.controller.destroy = (void(*)(controller_t*))destroy; - - this->manager = (manager_t*)context; + private_control_controller_t *this; + + INIT(this, + .public = { + .controller = { + .get_name = _get_name, + .handle = _handle, + .destroy = _destroy, + }, + }, + .manager = (manager_t*)context, + ); return &this->public.controller; } diff --git a/src/manager/controller/gateway_controller.c b/src/manager/controller/gateway_controller.c index 9fca220e9..39d344502 100644 --- a/src/manager/controller/gateway_controller.c +++ b/src/manager/controller/gateway_controller.c @@ -82,19 +82,15 @@ static void _select(private_gateway_controller_t *this, request_t *request) request->redirect(request, "gateway/list"); } -/** - * Implementation of controller_t.get_name - */ -static char* get_name(private_gateway_controller_t *this) +METHOD(controller_t, get_name, char*, + private_gateway_controller_t *this) { return "gateway"; } -/** - * Implementation of controller_t.handle - */ -static void handle(private_gateway_controller_t *this, - request_t *request, char *action) +METHOD(controller_t, handle, void, + private_gateway_controller_t *this, request_t *request, char *action, + char *p2, char *p3, char *p4, char *p5) { if (!this->manager->logged_in(this->manager)) { @@ -114,11 +110,8 @@ static void handle(private_gateway_controller_t *this, request->redirect(request, "gateway/list"); } - -/** - * Implementation of controller_t.destroy - */ -static void destroy(private_gateway_controller_t *this) +METHOD(controller_t, destroy, void, + private_gateway_controller_t *this) { free(this); } @@ -128,13 +121,18 @@ static void destroy(private_gateway_controller_t *this) */ controller_t *gateway_controller_create(context_t *context, void *param) { - private_gateway_controller_t *this = malloc_thing(private_gateway_controller_t); - - this->public.controller.get_name = (char*(*)(controller_t*))get_name; - this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle; - this->public.controller.destroy = (void(*)(controller_t*))destroy; - - this->manager = (manager_t*)context; + private_gateway_controller_t *this; + + INIT(this, + .public = { + .controller = { + .get_name = _get_name, + .handle = _handle, + .destroy = _destroy, + }, + }, + .manager = (manager_t*)context, + ); return &this->public.controller; } diff --git a/src/manager/controller/ikesa_controller.c b/src/manager/controller/ikesa_controller.c index afa4a67f8..716d51a7a 100644 --- a/src/manager/controller/ikesa_controller.c +++ b/src/manager/controller/ikesa_controller.c @@ -173,19 +173,15 @@ static void list(private_ikesa_controller_t *this, request_t *r) } } -/** - * Implementation of controller_t.get_name - */ -static char* get_name(private_ikesa_controller_t *this) +METHOD(controller_t, get_name, char*, + private_ikesa_controller_t *this) { return "ikesa"; } -/** - * Implementation of controller_t.handle - */ -static void handle(private_ikesa_controller_t *this, - request_t *request, char *action) +METHOD(controller_t, handle, void, + private_ikesa_controller_t *this, request_t *request, char *action, + char *p2, char *p3, char *p4, char *p5) { if (!this->manager->logged_in(this->manager)) { @@ -205,10 +201,8 @@ static void handle(private_ikesa_controller_t *this, return request->redirect(request, "ikesa/list"); } -/** - * Implementation of controller_t.destroy - */ -static void destroy(private_ikesa_controller_t *this) +METHOD(controller_t, destroy, void, + private_ikesa_controller_t *this) { free(this); } @@ -218,13 +212,18 @@ static void destroy(private_ikesa_controller_t *this) */ controller_t *ikesa_controller_create(context_t *context, void *param) { - private_ikesa_controller_t *this = malloc_thing(private_ikesa_controller_t); - - this->public.controller.get_name = (char*(*)(controller_t*))get_name; - this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle; - this->public.controller.destroy = (void(*)(controller_t*))destroy; - - this->manager = (manager_t*)context; + private_ikesa_controller_t *this; + + INIT(this, + .public = { + .controller = { + .get_name = _get_name, + .handle = _handle, + .destroy = _destroy, + }, + }, + .manager = (manager_t*)context, + ); return &this->public.controller; } |