added missing enumerator implementation
[strongswan.git] / src / manager / database.h
1 /**
2 * @file database.h
3 *
4 * @brief Interface of database_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef DATABASE_H_
24 #define DATABASE_H_
25
26 #include <enumerator.h>
27
28
29 typedef struct database_t database_t;
30
31 /**
32 * @brief Persistent database.
33 */
34 struct database_t {
35
36 /**
37 * @brief Try to log in using specified credentials.
38 *
39 * @param username username
40 * @param password plaintext password
41 * @return user ID if login good, 0 otherwise
42 */
43 int (*login)(database_t *this, char *username, char *password);
44
45 /**
46 * @brief Create an iterator over the gateways.
47 *
48 * enumerate() arguments: int id, char *name, int port, char *address
49 * If port is 0, address is a Unix socket address.
50 *
51 * @param user user Id
52 * @return enumerator
53 */
54 enumerator_t* (*create_gateway_enumerator)(database_t *this, int user);
55
56 /**
57 * @brief Destroy a database instance.
58 */
59 void (*destroy)(database_t *this);
60 };
61
62 /**
63 * @brief Create a database instance.
64 *
65 * @param dbfile SQLite database file
66 */
67 database_t *database_create(char *dbfile);
68
69 #endif /* DATABASE_H_ */