Version bump to 5.9.7dr2
[strongswan.git] / src / medsrv / user.c
1 /*
2 * Copyright (C) 2008 Martin Willi
3 *
4 * Copyright (C) secunet Security Networks AG
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 #include "user.h"
18
19 typedef struct private_user_t private_user_t;
20
21 /**
22 * private data of user
23 */
24 struct private_user_t {
25
26 /**
27 * public functions
28 */
29 user_t public;
30
31 /**
32 * user id, if we are logged in; otherwise 0
33 */
34 u_int user;
35 };
36
37 METHOD(user_t, set_user, void,
38 private_user_t *this, u_int id)
39 {
40 this->user = id;
41 }
42
43 METHOD(user_t, get_user, u_int,
44 private_user_t *this)
45 {
46 return this->user;
47 }
48
49 METHOD(fast_context_t, destroy, void,
50 private_user_t *this)
51 {
52 free(this);
53 }
54
55 /*
56 * see header file
57 */
58 user_t *user_create(void *param)
59 {
60 private_user_t *this;
61
62 INIT(this,
63 .public = {
64 .set_user = _set_user,
65 .get_user = _get_user,
66 .context = {
67 .destroy = _destroy,
68 },
69 },
70 );
71
72 return &this->public;
73 }