Rename pmdb_t to alpm_db_t
[pacman-ng.git] / lib / libalpm / package.h
blobb74d30ef770cbc43507d8bf876ea592b45a5d287
1 /*
2 * package.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 David Kimpe <dnaku@frugalware.org>
8 * Copyright (c) 2005, 2006 by Christian Hamar <krics@linuxforum.hu>
9 * Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef _ALPM_PACKAGE_H
25 #define _ALPM_PACKAGE_H
27 #include "config.h" /* ensure off_t is correct length */
29 #include <sys/types.h> /* off_t */
30 #include <time.h> /* time_t */
32 #include "alpm.h"
33 #include "backup.h"
34 #include "db.h"
35 #include "signing.h"
37 typedef enum _pmpkgfrom_t {
38 PKG_FROM_FILE = 1,
39 PKG_FROM_LOCALDB,
40 PKG_FROM_SYNCDB
41 } pmpkgfrom_t;
43 /** Package operations struct. This struct contains function pointers to
44 * all methods used to access data in a package to allow for things such
45 * as lazy package intialization (such as used by the file backend). Each
46 * backend is free to define a stuct containing pointers to a specific
47 * implementation of these methods. Some backends may find using the
48 * defined default_pkg_ops struct to work just fine for their needs.
50 struct pkg_operations {
51 const char *(*get_filename) (pmpkg_t *);
52 const char *(*get_desc) (pmpkg_t *);
53 const char *(*get_url) (pmpkg_t *);
54 time_t (*get_builddate) (pmpkg_t *);
55 time_t (*get_installdate) (pmpkg_t *);
56 const char *(*get_packager) (pmpkg_t *);
57 const char *(*get_md5sum) (pmpkg_t *);
58 const char *(*get_arch) (pmpkg_t *);
59 off_t (*get_size) (pmpkg_t *);
60 off_t (*get_isize) (pmpkg_t *);
61 alpm_pkgreason_t (*get_reason) (pmpkg_t *);
62 int (*has_scriptlet) (pmpkg_t *);
64 alpm_list_t *(*get_licenses) (pmpkg_t *);
65 alpm_list_t *(*get_groups) (pmpkg_t *);
66 alpm_list_t *(*get_depends) (pmpkg_t *);
67 alpm_list_t *(*get_optdepends) (pmpkg_t *);
68 alpm_list_t *(*get_conflicts) (pmpkg_t *);
69 alpm_list_t *(*get_provides) (pmpkg_t *);
70 alpm_list_t *(*get_replaces) (pmpkg_t *);
71 alpm_list_t *(*get_deltas) (pmpkg_t *);
72 alpm_list_t *(*get_files) (pmpkg_t *);
73 alpm_list_t *(*get_backup) (pmpkg_t *);
75 void *(*changelog_open) (pmpkg_t *);
76 size_t (*changelog_read) (void *, size_t, const pmpkg_t *, const void *);
77 int (*changelog_close) (const pmpkg_t *, void *);
79 /* still to add:
80 * checkmd5sum() ?
81 * compute_requiredby()
85 /** The standard package operations struct. get fields directly from the
86 * struct itself with no abstraction layer or any type of lazy loading.
87 * The actual definition is in package.c so it can have access to the
88 * default accessor functions which are defined there.
90 extern struct pkg_operations default_pkg_ops;
92 struct __pmpkg_t {
93 unsigned long name_hash;
94 char *filename;
95 char *name;
96 char *version;
97 char *desc;
98 char *url;
99 char *packager;
100 char *md5sum;
101 char *base64_sig;
102 char *arch;
104 time_t builddate;
105 time_t installdate;
107 off_t size;
108 off_t isize;
109 off_t download_size;
111 int scriptlet;
113 alpm_pkgreason_t reason;
114 pmdbinfrq_t infolevel;
115 pmpkgfrom_t origin;
116 /* origin == PKG_FROM_FILE, use pkg->origin_data.file
117 * origin == PKG_FROM_*DB, use pkg->origin_data.db */
118 union {
119 alpm_db_t *db;
120 char *file;
121 } origin_data;
122 alpm_handle_t *handle;
124 alpm_list_t *licenses;
125 alpm_list_t *replaces;
126 alpm_list_t *groups;
127 alpm_list_t *files;
128 alpm_list_t *backup;
129 alpm_list_t *depends;
130 alpm_list_t *optdepends;
131 alpm_list_t *conflicts;
132 alpm_list_t *provides;
133 alpm_list_t *deltas;
134 alpm_list_t *delta_path;
135 alpm_list_t *removes; /* in transaction targets only */
137 struct pkg_operations *ops;
140 pmpkg_t* _alpm_pkg_new(void);
141 pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg);
142 void _alpm_pkg_free(pmpkg_t *pkg);
143 void _alpm_pkg_free_trans(pmpkg_t *pkg);
146 pmpkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, const char *pkgfile,
147 int full, const char *md5sum, const char *base64_sig,
148 pgp_verify_t check_sig);
150 int _alpm_pkg_cmp(const void *p1, const void *p2);
151 int _alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg);
152 pmpkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle);
153 int _alpm_pkg_should_ignore(alpm_handle_t *handle, pmpkg_t *pkg);
155 #endif /* _ALPM_PACKAGE_H */
157 /* vim: set ts=2 sw=2 noet: */