libalpm
Arch Linux Package Manager Library
db.h
Go to the documentation of this file.
1/*
2 * db.h
3 *
4 * Copyright (c) 2006-2024 Pacman Development Team <pacman-dev@lists.archlinux.org>
5 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
6 * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
7 * Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
8 *
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
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22#ifndef ALPM_DB_H
23#define ALPM_DB_H
24
25/* libarchive */
26#include <archive.h>
27#include <archive_entry.h>
28
29#include "alpm.h"
30#include "pkghash.h"
31#include "signing.h"
32
33/* Database entries */
34typedef enum _alpm_dbinfrq_t {
35 INFRQ_BASE = (1 << 0),
36 INFRQ_DESC = (1 << 1),
37 INFRQ_FILES = (1 << 2),
38 INFRQ_SCRIPTLET = (1 << 3),
39 INFRQ_DSIZE = (1 << 4),
40 /* ALL should be info stored in the package or database */
43 INFRQ_ERROR = (1 << 30)
45
46/** Database status. Bitflags. */
47enum _alpm_dbstatus_t {
48 DB_STATUS_VALID = (1 << 0),
50 DB_STATUS_EXISTS = (1 << 2),
52
53 DB_STATUS_LOCAL = (1 << 10),
54 DB_STATUS_PKGCACHE = (1 << 11),
55 DB_STATUS_GRPCACHE = (1 << 12)
56};
57
59 int (*validate) (alpm_db_t *);
60 int (*populate) (alpm_db_t *);
61 void (*unregister) (alpm_db_t *);
62};
63
64/* Database */
65struct _alpm_db_t {
66 alpm_handle_t *handle;
67 char *treename;
68 /* do not access directly, use _alpm_db_path(db) for lazy access */
69 char *_path;
70 alpm_pkghash_t *pkgcache;
71 alpm_list_t *grpcache;
72 alpm_list_t *cache_servers;
73 alpm_list_t *servers;
74 const struct db_operations *ops;
75
76 /* bitfields for validity, local, loaded caches, etc. */
77 /* From _alpm_dbstatus_t */
78 int status;
79 /* alpm_siglevel_t */
80 int siglevel;
81 /* alpm_db_usage_t */
82 int usage;
83};
84
85
86/* db.c, database general calls */
87alpm_db_t *_alpm_db_new(const char *treename, int is_local);
88void _alpm_db_free(alpm_db_t *db);
89const char *_alpm_db_path(alpm_db_t *db);
90int _alpm_db_cmp(const void *d1, const void *d2);
91int _alpm_db_search(alpm_db_t *db, const alpm_list_t *needles,
92 alpm_list_t **ret);
93alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle);
94alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
95 int level);
96void _alpm_db_unregister(alpm_db_t *db);
97
98/* be_*.c, backend specific calls */
99int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_t *info);
100int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, int inforeq);
101int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info);
102char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filename);
103
104/* cache bullshit */
105/* packages */
106void _alpm_db_free_pkgcache(alpm_db_t *db);
107int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg);
108int _alpm_db_remove_pkgfromcache(alpm_db_t *db, alpm_pkg_t *pkg);
109alpm_pkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db);
110alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db);
111alpm_pkg_t *_alpm_db_get_pkgfromcache(alpm_db_t *db, const char *target);
112/* groups */
113alpm_list_t *_alpm_db_get_groupcache(alpm_db_t *db);
114alpm_group_t *_alpm_db_get_groupfromcache(alpm_db_t *db, const char *target);
115
116#endif /* ALPM_DB_H */
@ DB_STATUS_VALID
Definition db.h:48
int(* populate)(alpm_db_t *)
Definition db.h:60
@ DB_STATUS_LOCAL
Definition db.h:53
@ DB_STATUS_MISSING
Definition db.h:51
@ DB_STATUS_INVALID
Definition db.h:49
int(* validate)(alpm_db_t *)
Definition db.h:59
@ DB_STATUS_PKGCACHE
Definition db.h:54
alpm_dbinfrq_t
Definition db.h:34
@ INFRQ_SCRIPTLET
Definition db.h:38
@ INFRQ_BASE
Definition db.h:35
@ INFRQ_FILES
Definition db.h:37
@ INFRQ_ERROR
Definition db.h:43
@ INFRQ_DSIZE
Definition db.h:39
@ INFRQ_ALL
Definition db.h:41
@ INFRQ_DESC
Definition db.h:36
@ DB_STATUS_EXISTS
Definition db.h:50
void(* unregister)(alpm_db_t *)
Definition db.h:61
@ DB_STATUS_GRPCACHE
Definition db.h:55
Definition db.h:58
Package group.
Definition alpm.h:179
A doubly linked list.
Definition alpm_list.h:51
alpm_loglevel_t level
Definition sandbox.h:40