Rename pmpkg_t to alpm_pkg_t
[pacman-ng.git] / lib / libalpm / db.h
blob9c6d60528bc7145e4c683e9bcc286f96a94dd095
1 /*
2 * db.h
4 * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@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>
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.
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.
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/>.
22 #ifndef _ALPM_DB_H
23 #define _ALPM_DB_H
25 #include <time.h>
27 /* libarchive */
28 #include <archive.h>
29 #include <archive_entry.h>
31 #include "alpm.h"
32 #include "pkghash.h"
33 #include "signing.h"
35 /* Database entries */
36 typedef enum _pmdbinfrq_t {
37 INFRQ_BASE = 1,
38 INFRQ_DESC = (1 << 1),
39 INFRQ_FILES = (1 << 2),
40 INFRQ_SCRIPTLET = (1 << 3),
41 INFRQ_DSIZE = (1 << 4),
42 /* ALL should be info stored in the package or database */
43 INFRQ_ALL = 0x1F
44 } pmdbinfrq_t;
46 /** Database status. Bitflags. */
47 enum _pmdbstatus_t {
48 DB_STATUS_VALID = (1 << 0),
49 DB_STATUS_PKGCACHE = (1 << 1),
50 DB_STATUS_GRPCACHE = (1 << 2)
53 struct db_operations {
54 int (*populate) (alpm_db_t *);
55 void (*unregister) (alpm_db_t *);
58 /* Database */
59 struct __alpm_db_t {
60 alpm_handle_t *handle;
61 char *treename;
62 /* do not access directly, use _alpm_db_path(db) for lazy access */
63 char *_path;
64 /* also indicates whether we are RO or RW */
65 int is_local;
66 /* flags determining validity, loaded caches, etc. */
67 enum _pmdbstatus_t status;
68 pmpkghash_t *pkgcache;
69 alpm_list_t *grpcache;
70 alpm_list_t *servers;
71 pgp_verify_t pgp_verify;
73 struct db_operations *ops;
77 /* db.c, database general calls */
78 alpm_db_t *_alpm_db_new(const char *treename, int is_local);
79 void _alpm_db_free(alpm_db_t *db);
80 const char *_alpm_db_path(alpm_db_t *db);
81 char *_alpm_db_sig_path(alpm_db_t *db);
82 int _alpm_db_cmp(const void *d1, const void *d2);
83 alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles);
84 alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle);
85 alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
86 pgp_verify_t level);
87 void _alpm_db_unregister(alpm_db_t *db);
89 /* be_*.c, backend specific calls */
90 int _alpm_local_db_read(alpm_db_t *db, alpm_pkg_t *info, pmdbinfrq_t inforeq);
91 int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_t *info);
92 int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, pmdbinfrq_t inforeq);
93 int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info);
95 /* cache bullshit */
96 /* packages */
97 void _alpm_db_free_pkgcache(alpm_db_t *db);
98 int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg);
99 int _alpm_db_remove_pkgfromcache(alpm_db_t *db, alpm_pkg_t *pkg);
100 pmpkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db);
101 alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db);
102 int _alpm_db_ensure_pkgcache(alpm_db_t *db, pmdbinfrq_t infolevel);
103 alpm_pkg_t *_alpm_db_get_pkgfromcache(alpm_db_t *db, const char *target);
104 /* groups */
105 void _alpm_db_free_grpcache(alpm_db_t *db);
106 alpm_list_t *_alpm_db_get_grpcache(alpm_db_t *db);
107 pmgrp_t *_alpm_db_get_grpfromcache(alpm_db_t *db, const char *target);
109 #endif /* _ALPM_DB_H */
111 /* vim: set ts=2 sw=2 noet: */