summaryrefslogtreecommitdiffstats
path: root/database/postgresql/prepared-sql.h
blob: 0d09f203bf1c060e94a497bb652d6a376f3b88f0 (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
/*  prepared-sql.h  -- PostgreSQL database driver for eurephia
 *
 *  GPLv2 only - Copyright (C) 2012
 *               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.
 *
 */

/**
 * @file   prepared-sql.h
 * @author David Sommerseth <dazo@users.sourceforge.net>
 * @date   2012-01-15
 *
 * @brief  eurephia database driver for the PostgreSQL database.
 *         The infrastructure needed for prepared SQL statements
 */

#ifndef _PREPARED_SQL_H
#define _PREPARED_SQL_H

#include <stdarg.h>
#include <eurephia_context.h>

typedef enum { PREPSQL_NONE = 0, PREPSQL_TLS_AUTH, PREPSQL_USERPWD_AUTH,
               PREPSQL_BLACKLIST_ATTEMPTUPD, PREPSQL_USERS_LASTACC_UPD,
               PREPSQL_USERS_GETUID, PREPSQL_ATTEMPTS_RESET, PREPSQL_ATTEMPTS_INCR,
               PREPSQL_ATTEMPTS_REG_CERT, PREPSQL_ATTEMPTS_REG_USERNAME,
               PREPSQL_ATTEMPTS_REG_IPADDR,
               PREPSQL_BLACKLIST_CHECK_CERT, PREPSQL_BLACKLIST_CHECK_USERNAME,
               PREPSQL_BLACKLIST_CHECK_IPADDR,
               PREPSQL_BLACKLIST_REG_CERT, PREPSQL_BLACKLIST_REG_USERNAME,
               PREPSQL_BLACKLIST_REG_IPADDR,
               PREPSQL_SESSIONKEY_GETSEED_SESSION, PREPSQL_SESSIONKEY_GETSEED_AUTH,
               PREPSQL_SESSIONKEY_GETMAC,
               PREPSQL_SESSIONKEY_UNIQ_ADMIN, PREPSQL_SESSIONKEY_UNIQ_PLAUTH,
               PREPSQL_SESSIONKEY_REGISTER, PREPSQL_SESSIONKEY_REMOVE,
               PREPSQL_SESSIONVARS_LOAD, PREPSQL_SESSIONVARS_STORE_NEW,
               PREPSQL_SESSIONVARS_STORE_UPDATE, PREPSQL_SESSIONVARS_STORE_DELETE,
               PREPSQL_SESSIONS_DESTROY_LASTLOG, PREPSQL_SESSIONS_DESTROY_SESS,
               PREPSQL_REGISTER_LOGIN, PREPSQL_REGISTER_LOGOUT,
               PREPSQL_MACHISTORY_REGISTER, PREPSQL_MACHISTORY_LASTLOG,
               PREPSQL_FIREWALL_GETPROFILE
} ePG_prepID;

typedef struct _ePGprepParam_s {
        ePG_prepID prepid;
        int index;
        char **params;
} ePGprepParams;

int ePGprepStatementGetID(ePG_prepID prepid);
const char const * ePGprepStatementGetName(eurephiaCTX *ctx, ePG_prepID prepid);
int ePGprepLoadStatements(eurephiaCTX *ctx);
ePGprepParams * ePGprepParamsAlloc(eurephiaCTX *ctx, ePG_prepID prepid);
int ePGprepParamsAddArgument(eurephiaCTX *ctx, ePGprepParams *prms, const char *arg);
int ePGprepParamsAddArgumentInt(eurephiaCTX *ctx, ePGprepParams *prms, const int arg);
PGresult * ePGprepExec(eurephiaCTX *ctx, ePGprepParams *qry_args);

#endif