summaryrefslogtreecommitdiff
path: root/src/medsrv/controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/medsrv/controller')
-rwxr-xr-xsrc/medsrv/controller/peer_controller.c41
-rwxr-xr-xsrc/medsrv/controller/user_controller.c46
2 files changed, 43 insertions, 44 deletions
diff --git a/src/medsrv/controller/peer_controller.c b/src/medsrv/controller/peer_controller.c
index 5948fcfb7..edcf653b2 100755
--- a/src/medsrv/controller/peer_controller.c
+++ b/src/medsrv/controller/peer_controller.c
@@ -312,19 +312,15 @@ static void delete(private_peer_controller_t *this, request_t *request, int id)
DB_INT, id, DB_UINT, this->user->get_user(this->user));
}
-/**
- * Implementation of controller_t.get_name
- */
-static char* get_name(private_peer_controller_t *this)
+METHOD(controller_t, get_name, char*,
+ private_peer_controller_t *this)
{
return "peer";
}
-/**
- * Implementation of controller_t.handle
- */
-static void handle(private_peer_controller_t *this, request_t *request,
- char *action, char *idstr)
+METHOD(controller_t, handle, void,
+ private_peer_controller_t *this, request_t *request, char *action,
+ char *idstr, char *p3, char *p4, char *p5)
{
if (action)
{
@@ -354,10 +350,8 @@ static void handle(private_peer_controller_t *this, request_t *request,
request->redirect(request, "peer/list");
}
-/**
- * Implementation of controller_t.destroy
- */
-static void destroy(private_peer_controller_t *this)
+METHOD(controller_t, destroy, void,
+ private_peer_controller_t *this)
{
free(this);
}
@@ -367,14 +361,19 @@ static void destroy(private_peer_controller_t *this)
*/
controller_t *peer_controller_create(user_t *user, database_t *db)
{
- private_peer_controller_t *this= malloc_thing(private_peer_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->user = user;
- this->db = db;
+ private_peer_controller_t *this;
+
+ INIT(this,
+ .public = {
+ .controller = {
+ .get_name = _get_name,
+ .handle = _handle,
+ .destroy = _destroy,
+ },
+ },
+ .user = user,
+ .db = db,
+ );
return &this->public.controller;
}
diff --git a/src/medsrv/controller/user_controller.c b/src/medsrv/controller/user_controller.c
index 0f25799d8..12bd938fe 100755
--- a/src/medsrv/controller/user_controller.c
+++ b/src/medsrv/controller/user_controller.c
@@ -44,7 +44,7 @@ struct private_user_controller_t {
user_t *user;
/**
- * minimum required password lenght
+ * minimum required password length
*/
u_int password_length;
};
@@ -293,18 +293,15 @@ static void edit(private_user_controller_t *this, request_t *request)
request->render(request, "templates/user/edit.cs");
}
-/**
- * Implementation of controller_t.get_name
- */
-static char* get_name(private_user_controller_t *this)
+METHOD(controller_t, get_name, char*,
+ private_user_controller_t *this)
{
return "user";
}
-/**
- * Implementation of controller_t.handle
- */
-static void handle(private_user_controller_t *this, request_t *request, char *action)
+METHOD(controller_t, handle, void,
+ private_user_controller_t *this, request_t *request, char *action,
+ char *p2, char *p3, char *p4, char *p5)
{
if (action)
{
@@ -332,10 +329,8 @@ static void handle(private_user_controller_t *this, request_t *request, char *ac
request->redirect(request, "user/login");
}
-/**
- * Implementation of controller_t.destroy
- */
-static void destroy(private_user_controller_t *this)
+METHOD(controller_t, destroy, void,
+ private_user_controller_t *this)
{
free(this);
}
@@ -345,16 +340,21 @@ static void destroy(private_user_controller_t *this)
*/
controller_t *user_controller_create(user_t *user, database_t *db)
{
- private_user_controller_t *this= malloc_thing(private_user_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->user = user;
- this->db = db;
- this->password_length = lib->settings->get_int(lib->settings,
- "medsrv.password_length", 6);
+ private_user_controller_t *this;
+
+ INIT(this,
+ .public = {
+ .controller = {
+ .get_name = _get_name,
+ .handle = _handle,
+ .destroy = _destroy,
+ },
+ },
+ .user = user,
+ .db = db,
+ .password_length = lib->settings->get_int(lib->settings,
+ "medsrv.password_length", 6),
+ );
return &this->public.controller;
}