summaryrefslogtreecommitdiffstats
path: root/common/eurephia_admin_common.h
blob: aa6a9890d5621aee58d22a521189493de7fba100 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* eurephia_admin_common.h  --  Common functions used for the admin API
 *
 *  GPLv2 - Copyright (C) 2008  David Sommerseth <dazo@users.sourceforge.net>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; version 2
 *  of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

#ifndef   	EUREPHIA_ADMIN_COMMON_H_
# define   	EUREPHIA_ADMIN_COMMON_H_

#include <eurephia_admin_struct.h>

#define TABLE_USERS         0x01
#define TABLE_CERTS         0x02
#define TABLE_LASTLOG       0x03
#define TABLE_ATTEMPTS      0x04
#define TABLE_BLACKLIST     0x05

#define SORTKEY_NONE        0x00000
#define SORTKEY_RECID       0x00001  // Primary keys
#define SORTKEY_UID         0x00002
#define SORTKEY_CERTID      0x00004
#define SORTKEY_UNAME       0x00008
#define SORTKEY_ACTIVATED   0x00010
#define SORTKEY_DEACTIVATED 0x00020
#define SORTKEY_LASTACCESS  0x00040

#define SORTKEY_CERTDEPTH   0x00080
#define SORTKEY_CNAME       0x00100
#define SORTKEY_EMAIL       0x00200
#define SORTKEY_ORG         0x00400
#define SORTKEY_REGISTERED  0x00800

#define SORTKEY_REMOTEIP    0x01000
#define SORTKEY_VPNIP       0x02000
#define SORTKEY_ATTEMPTS    0x04000
#define SORTKEY_LASTATTEMPT 0x08000

#define SORTKEY_SESSTATUS   0x10000
#define SORTKEY_LOGIN       0x20000
#define SORTKEY_LOGOUT      0x40000

#ifdef EUREPHIA_ADMIN_COMMON_C
eFieldMap eSortkeys_user[] = {
        {TABLE_USERS, SORTKEY_RECID,       "recid"},
        {TABLE_USERS, SORTKEY_RECID,       "uid"},
        {TABLE_USERS, SORTKEY_UNAME,       "username"},
        {TABLE_USERS, SORTKEY_ACTIVATED,   "activated"},
        {TABLE_USERS, SORTKEY_DEACTIVATED, "deactivated"},
        {TABLE_USERS, SORTKEY_LASTACCESS,  "lastaccess"},
        {TABLE_USERS, SORTKEY_NONE, NULL}
};

eFieldMap eSortkeys_certificates[] = {
        {TABLE_CERTS, SORTKEY_RECID,       "recid"},
        {TABLE_CERTS, SORTKEY_RECID,       "certid"},
        {TABLE_CERTS, SORTKEY_CERTDEPTH,   "depth"},
        {TABLE_CERTS, SORTKEY_CNAME,       "name"},
        {TABLE_CERTS, SORTKEY_ORG,         "org"},
        {TABLE_CERTS, SORTKEY_EMAIL,       "email"},
        {TABLE_CERTS, SORTKEY_REGISTERED,  "registered"},
        {TABLE_CERTS, SORTKEY_NONE, NULL}
};

eFieldMap eSortkeys_lastlog[] = {
        {TABLE_LASTLOG, SORTKEY_UID,         "uid"},
        {TABLE_LASTLOG, SORTKEY_CERTID,      "certid"},
        {TABLE_LASTLOG, SORTKEY_REMOTEIP,    "ip"},
        {TABLE_LASTLOG, SORTKEY_VPNIP,       "vpnip"},
        {TABLE_LASTLOG, SORTKEY_SESSTATUS,   "status"},
        {TABLE_LASTLOG, SORTKEY_LOGIN,       "login"},
        {TABLE_LASTLOG, SORTKEY_LOGOUT,      "logout"},
        {TABLE_LASTLOG, SORTKEY_RECID,       "recid"},
        {TABLE_LASTLOG, SORTKEY_NONE, NULL}
};

eFieldMap eSortkeys_attempts[] = {
        {TABLE_ATTEMPTS, SORTKEY_UNAME,       "username"},
        {TABLE_ATTEMPTS, SORTKEY_REMOTEIP,    "ip"},
        {TABLE_ATTEMPTS, SORTKEY_ATTEMPTS,    "attempts"},
        {TABLE_ATTEMPTS, SORTKEY_REGISTERED,  "registered"},
        {TABLE_ATTEMPTS, SORTKEY_LASTATTEMPT, "lastattempt"},
        {TABLE_ATTEMPTS, SORTKEY_RECID,       "recid"},
        {TABLE_ATTEMPTS, SORTKEY_NONE, NULL}
};

eFieldMap eSortkeys_blacklist[] = {
        {TABLE_BLACKLIST, SORTKEY_UNAME,       "username"},
        {TABLE_BLACKLIST, SORTKEY_REMOTEIP,    "ip"},
        {TABLE_BLACKLIST, SORTKEY_REGISTERED,  "registered"},
        {TABLE_BLACKLIST, SORTKEY_LASTACCESS,  "lastattempt"},
        {TABLE_BLACKLIST, SORTKEY_LASTACCESS,  "lastaccessed"},
        {TABLE_BLACKLIST, SORTKEY_RECID,       "recid"},
        {TABLE_BLACKLIST, SORTKEY_NONE, NULL}
};

#endif // #ifdef EUREPHIA_ADMIN_COMMON_C


eFieldMap *eAdminGetTableMap(int table);
char *eAdminConvertSortKeys(eFieldMap *, const char *);

eurephiaUSERINFO *eAdminPopulateUSERINFO(int uid, const char *uname, const char *pwd,
                                         const char *activated, const char *deactivd, const char *lastacc);

void _eAdminFreeUSERINFO_func(eurephiaUSERINFO *);
#define eAdminFreeUSERINFO(x) { _eAdminFreeUSERINFO_func(x); x = NULL; }

void _eAdminFreeUSERLIST_func(eurephiaUSERLIST *);
#define eAdminFreeUSERLIST(x) { _eAdminFreeUSERLIST_func(x); x = NULL; }

#endif 	    /* !EUREPHIA_ADMIN_COMMON_H_ */