]>
Commit | Line | Data |
---|---|---|
d04baaba JV |
1 | /* |
2 | * db.h | |
23229097 | 3 | * |
1dd34058 | 4 | * Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org> |
c72b4543 | 5 | * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> |
d37ad048 AG |
6 | * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> |
7 | * Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org> | |
23229097 | 8 | * |
d04baaba JV |
9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
9781d0d6 | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
d04baaba JV |
21 | */ |
22 | #ifndef _ALPM_DB_H | |
23 | #define _ALPM_DB_H | |
24 | ||
4a8e396a AM |
25 | /* libarchive */ |
26 | #include <archive.h> | |
27 | #include <archive_entry.h> | |
28 | ||
ed6fda2f | 29 | #include "alpm.h" |
fb4b422f | 30 | #include "pkghash.h" |
ed6fda2f AM |
31 | #include "signing.h" |
32 | ||
d04baaba | 33 | /* Database entries */ |
028b965e | 34 | typedef enum _alpm_dbinfrq_t { |
e3ac8062 H |
35 | INFRQ_BASE = 1, |
36 | INFRQ_DESC = (1 << 1), | |
21833d90 AM |
37 | INFRQ_FILES = (1 << 2), |
38 | INFRQ_SCRIPTLET = (1 << 3), | |
39 | INFRQ_DSIZE = (1 << 4), | |
df99495b | 40 | /* ALL should be info stored in the package or database */ |
ef4757af DM |
41 | INFRQ_ALL = 0x1F, |
42 | INFRQ_ERROR = (1 << 31) | |
028b965e | 43 | } alpm_dbinfrq_t; |
22c0037a | 44 | |
79e98316 | 45 | /** Database status. Bitflags. */ |
7633c14b | 46 | enum _alpm_dbstatus_t { |
79e98316 | 47 | DB_STATUS_VALID = (1 << 0), |
c885a953 DM |
48 | DB_STATUS_INVALID = (1 << 1), |
49 | DB_STATUS_EXISTS = (1 << 2), | |
50 | DB_STATUS_MISSING = (1 << 3), | |
51 | ||
52 | DB_STATUS_LOCAL = (1 << 10), | |
53 | DB_STATUS_PKGCACHE = (1 << 11), | |
54 | DB_STATUS_GRPCACHE = (1 << 12) | |
79e98316 DM |
55 | }; |
56 | ||
efbae3cf | 57 | struct db_operations { |
68284da0 | 58 | int (*validate) (alpm_db_t *); |
939d5a95 AM |
59 | int (*populate) (alpm_db_t *); |
60 | void (*unregister) (alpm_db_t *); | |
efbae3cf DM |
61 | }; |
62 | ||
d04baaba | 63 | /* Database */ |
939d5a95 | 64 | struct __alpm_db_t { |
64c1cf79 | 65 | alpm_handle_t *handle; |
1dfd841e | 66 | char *treename; |
72883e3b DM |
67 | /* do not access directly, use _alpm_db_path(db) for lazy access */ |
68 | char *_path; | |
71fa9f91 | 69 | alpm_pkghash_t *pkgcache; |
61670172 AG |
70 | alpm_list_t *grpcache; |
71 | alpm_list_t *servers; | |
efbae3cf | 72 | struct db_operations *ops; |
c885a953 DM |
73 | /* flags determining validity, local, loaded caches, etc. */ |
74 | enum _alpm_dbstatus_t status; | |
75 | alpm_siglevel_t siglevel; | |
106d0fc5 | 76 | alpm_db_usage_t usage; |
aa1c0ba9 | 77 | }; |
44dc48f1 | 78 | |
efbae3cf | 79 | |
e3aace4a | 80 | /* db.c, database general calls */ |
939d5a95 AM |
81 | alpm_db_t *_alpm_db_new(const char *treename, int is_local); |
82 | void _alpm_db_free(alpm_db_t *db); | |
83 | const char *_alpm_db_path(alpm_db_t *db); | |
57393eb7 | 84 | int _alpm_db_cmp(const void *d1, const void *d2); |
939d5a95 AM |
85 | alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles); |
86 | alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle); | |
87 | alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename, | |
7af0ab1c | 88 | alpm_siglevel_t level); |
939d5a95 | 89 | void _alpm_db_unregister(alpm_db_t *db); |
e3aace4a | 90 | |
4a8e396a | 91 | /* be_*.c, backend specific calls */ |
8a04bc25 | 92 | int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_t *info); |
028b965e | 93 | int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq); |
8a04bc25 | 94 | int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info); |
39b0ac43 | 95 | char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filename); |
4a8e396a | 96 | |
522ef5e9 DM |
97 | /* cache bullshit */ |
98 | /* packages */ | |
939d5a95 | 99 | void _alpm_db_free_pkgcache(alpm_db_t *db); |
8a04bc25 AM |
100 | int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg); |
101 | int _alpm_db_remove_pkgfromcache(alpm_db_t *db, alpm_pkg_t *pkg); | |
71fa9f91 | 102 | alpm_pkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db); |
939d5a95 | 103 | alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db); |
8a04bc25 | 104 | alpm_pkg_t *_alpm_db_get_pkgfromcache(alpm_db_t *db, const char *target); |
522ef5e9 | 105 | /* groups */ |
f1bb56ce | 106 | alpm_list_t *_alpm_db_get_groupcache(alpm_db_t *db); |
b1894ccf | 107 | alpm_group_t *_alpm_db_get_groupfromcache(alpm_db_t *db, const char *target); |
522ef5e9 | 108 | |
d04baaba JV |
109 | #endif /* _ALPM_DB_H */ |
110 | ||
111 | /* vim: set ts=2 sw=2 noet: */ |