4 * Copyright (c) 2006-2012 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 <sys/types.h> /* off_t */
34 /** Package operations struct. This struct contains function pointers to
35 * all methods used to access data in a package to allow for things such
36 * as lazy package intialization (such as used by the file backend). Each
37 * backend is free to define a stuct containing pointers to a specific
38 * implementation of these methods. Some backends may find using the
39 * defined default_pkg_ops struct to work just fine for their needs.
41 struct pkg_operations
{
42 const char *(*get_desc
) (alpm_pkg_t
*);
43 const char *(*get_url
) (alpm_pkg_t
*);
44 alpm_time_t (*get_builddate
) (alpm_pkg_t
*);
45 alpm_time_t (*get_installdate
) (alpm_pkg_t
*);
46 const char *(*get_packager
) (alpm_pkg_t
*);
47 const char *(*get_arch
) (alpm_pkg_t
*);
48 off_t (*get_isize
) (alpm_pkg_t
*);
49 alpm_pkgreason_t (*get_reason
) (alpm_pkg_t
*);
50 alpm_pkgvalidation_t (*get_validation
) (alpm_pkg_t
*);
51 int (*has_scriptlet
) (alpm_pkg_t
*);
53 alpm_list_t
*(*get_licenses
) (alpm_pkg_t
*);
54 alpm_list_t
*(*get_groups
) (alpm_pkg_t
*);
55 alpm_list_t
*(*get_depends
) (alpm_pkg_t
*);
56 alpm_list_t
*(*get_optdepends
) (alpm_pkg_t
*);
57 alpm_list_t
*(*get_conflicts
) (alpm_pkg_t
*);
58 alpm_list_t
*(*get_provides
) (alpm_pkg_t
*);
59 alpm_list_t
*(*get_replaces
) (alpm_pkg_t
*);
60 alpm_filelist_t
*(*get_files
) (alpm_pkg_t
*);
61 alpm_list_t
*(*get_backup
) (alpm_pkg_t
*);
63 void *(*changelog_open
) (alpm_pkg_t
*);
64 size_t (*changelog_read
) (void *, size_t, const alpm_pkg_t
*, void *);
65 int (*changelog_close
) (const alpm_pkg_t
*, void *);
67 int (*force_load
) (alpm_pkg_t
*);
70 /** The standard package operations struct. get fields directly from the
71 * struct itself with no abstraction layer or any type of lazy loading.
72 * The actual definition is in package.c so it can have access to the
73 * default accessor functions which are defined there.
75 extern struct pkg_operations default_pkg_ops
;
78 unsigned long name_hash
;
90 alpm_time_t builddate
;
91 alpm_time_t installdate
;
99 alpm_pkgreason_t reason
;
100 alpm_pkgvalidation_t validation
;
101 alpm_dbinfrq_t infolevel
;
102 alpm_pkgfrom_t origin
;
103 /* origin == PKG_FROM_FILE, use pkg->origin_data.file
104 * origin == PKG_FROM_*DB, use pkg->origin_data.db */
109 alpm_handle_t
*handle
;
111 alpm_list_t
*licenses
;
112 alpm_list_t
*replaces
;
115 alpm_list_t
*depends
;
116 alpm_list_t
*optdepends
;
117 alpm_list_t
*conflicts
;
118 alpm_list_t
*provides
;
120 alpm_list_t
*delta_path
;
121 alpm_list_t
*removes
; /* in transaction targets only */
123 struct pkg_operations
*ops
;
125 alpm_filelist_t files
;
128 alpm_file_t
*_alpm_file_copy(alpm_file_t
*dest
, const alpm_file_t
*src
);
130 alpm_pkg_t
*_alpm_pkg_new(void);
131 int _alpm_pkg_dup(alpm_pkg_t
*pkg
, alpm_pkg_t
**new_ptr
);
132 void _alpm_pkg_free(alpm_pkg_t
*pkg
);
133 void _alpm_pkg_free_trans(alpm_pkg_t
*pkg
);
135 int _alpm_pkg_validate_internal(alpm_handle_t
*handle
,
136 const char *pkgfile
, alpm_pkg_t
*syncpkg
, alpm_siglevel_t level
,
137 alpm_siglist_t
**sigdata
, alpm_pkgvalidation_t
*validation
);
138 alpm_pkg_t
*_alpm_pkg_load_internal(alpm_handle_t
*handle
,
139 const char *pkgfile
, int full
);
141 int _alpm_pkg_cmp(const void *p1
, const void *p2
);
142 int _alpm_pkg_compare_versions(alpm_pkg_t
*local_pkg
, alpm_pkg_t
*pkg
);
143 alpm_pkg_t
*_alpm_pkg_find(alpm_list_t
*haystack
, const char *needle
);
144 int _alpm_pkg_should_ignore(alpm_handle_t
*handle
, alpm_pkg_t
*pkg
);
146 #endif /* _ALPM_PACKAGE_H */
148 /* vim: set ts=2 sw=2 noet: */