libalpm
Arch Linux Package Manager Library
|
00001 /* 00002 * db.h 00003 * 00004 * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org> 00005 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> 00006 * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> 00007 * Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org> 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 #ifndef _ALPM_DB_H 00023 #define _ALPM_DB_H 00024 00025 /* libarchive */ 00026 #include <archive.h> 00027 #include <archive_entry.h> 00028 00029 #include "alpm.h" 00030 #include "pkghash.h" 00031 #include "signing.h" 00032 00033 /* Database entries */ 00034 typedef enum _alpm_dbinfrq_t { 00035 INFRQ_BASE = 1, 00036 INFRQ_DESC = (1 << 1), 00037 INFRQ_FILES = (1 << 2), 00038 INFRQ_SCRIPTLET = (1 << 3), 00039 INFRQ_DSIZE = (1 << 4), 00040 /* ALL should be info stored in the package or database */ 00041 INFRQ_ALL = 0x1F, 00042 INFRQ_ERROR = (1 << 31) 00043 } alpm_dbinfrq_t; 00044 00045 /** Database status. Bitflags. */ 00046 enum _alpm_dbstatus_t { 00047 DB_STATUS_VALID = (1 << 0), 00048 DB_STATUS_INVALID = (1 << 1), 00049 DB_STATUS_EXISTS = (1 << 2), 00050 DB_STATUS_MISSING = (1 << 3), 00051 00052 DB_STATUS_LOCAL = (1 << 10), 00053 DB_STATUS_PKGCACHE = (1 << 11), 00054 DB_STATUS_GRPCACHE = (1 << 12) 00055 }; 00056 00057 struct db_operations { 00058 int (*validate) (alpm_db_t *); 00059 int (*populate) (alpm_db_t *); 00060 void (*unregister) (alpm_db_t *); 00061 }; 00062 00063 /* Database */ 00064 struct __alpm_db_t { 00065 alpm_handle_t *handle; 00066 char *treename; 00067 /* do not access directly, use _alpm_db_path(db) for lazy access */ 00068 char *_path; 00069 alpm_pkghash_t *pkgcache; 00070 alpm_list_t *grpcache; 00071 alpm_list_t *servers; 00072 struct db_operations *ops; 00073 /* flags determining validity, local, loaded caches, etc. */ 00074 enum _alpm_dbstatus_t status; 00075 alpm_siglevel_t siglevel; 00076 }; 00077 00078 00079 /* db.c, database general calls */ 00080 alpm_db_t *_alpm_db_new(const char *treename, int is_local); 00081 void _alpm_db_free(alpm_db_t *db); 00082 const char *_alpm_db_path(alpm_db_t *db); 00083 int _alpm_db_cmp(const void *d1, const void *d2); 00084 alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles); 00085 alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle); 00086 alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename, 00087 alpm_siglevel_t level); 00088 void _alpm_db_unregister(alpm_db_t *db); 00089 00090 /* be_*.c, backend specific calls */ 00091 int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_t *info); 00092 int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq); 00093 int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info); 00094 char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filename); 00095 00096 /* cache bullshit */ 00097 /* packages */ 00098 void _alpm_db_free_pkgcache(alpm_db_t *db); 00099 int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg); 00100 int _alpm_db_remove_pkgfromcache(alpm_db_t *db, alpm_pkg_t *pkg); 00101 alpm_pkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db); 00102 alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db); 00103 alpm_pkg_t *_alpm_db_get_pkgfromcache(alpm_db_t *db, const char *target); 00104 /* groups */ 00105 alpm_list_t *_alpm_db_get_groupcache(alpm_db_t *db); 00106 alpm_group_t *_alpm_db_get_groupfromcache(alpm_db_t *db, const char *target); 00107 00108 #endif /* _ALPM_DB_H */ 00109 00110 /* vim: set ts=2 sw=2 noet: */