2 * libdpkg - Debian packaging suite library routines
3 * pkg-spec.h - primitives for pkg specifier handling
5 * Copyright © 2011 Linaro Limited
6 * Copyright © 2011 Raphaël Hertzog <hertzog@debian.org>
7 * Copyright © 2011-2014 Guillem Jover <guillem@debian.org>
9 * This 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 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 <https://www.gnu.org/licenses/>.
23 #ifndef LIBDPKG_PKG_SPEC_H
24 #define LIBDPKG_PKG_SPEC_H
28 #include <dpkg/macros.h>
29 #include <dpkg/dpkg-db.h>
30 #include <dpkg/error.h>
31 #include <dpkg/arch.h>
36 * @defgroup pkg-spec Package specifiers
37 * @ingroup dpkg-public
41 enum DPKG_ATTR_ENUM_FLAGS pkg_spec_flags
{
42 /** Recognize glob patterns. */
43 PKG_SPEC_PATTERNS
= DPKG_BIT(0),
45 /* How to consider the lack of an arch qualifier. */
46 PKG_SPEC_ARCH_SINGLE
= DPKG_BIT(8),
47 PKG_SPEC_ARCH_WILDCARD
= DPKG_BIT(9),
48 PKG_SPEC_ARCH_MASK
= 0x0300,
53 const struct dpkg_arch
*arch
;
55 enum pkg_spec_flags flags
;
57 /* Members below are private state. */
62 /** Used for the pkg_db iterator. */
63 struct pkg_hash_iter
*pkg_iter
;
64 /** Used for the pkgset iterator. */
65 struct pkginfo
*pkg_next
;
68 void pkg_spec_init(struct pkg_spec
*ps
, enum pkg_spec_flags flags
);
69 void pkg_spec_destroy(struct pkg_spec
*ps
);
71 const char *pkg_spec_is_illegal(struct pkg_spec
*ps
);
73 const char *pkg_spec_set(struct pkg_spec
*ps
,
74 const char *pkgname
, const char *archname
);
75 const char *pkg_spec_parse(struct pkg_spec
*ps
, const char *str
);
76 bool pkg_spec_match_pkg(struct pkg_spec
*ps
,
77 struct pkginfo
*pkg
, struct pkgbin
*pkgbin
);
79 struct pkginfo
*pkg_spec_parse_pkg(const char *str
, struct dpkg_error
*err
);
80 struct pkginfo
*pkg_spec_find_pkg(const char *pkgname
, const char *archname
,
81 struct dpkg_error
*err
);
83 void pkg_spec_iter_init(struct pkg_spec
*ps
);
84 struct pkginfo
*pkg_spec_iter_next_pkg(struct pkg_spec
*ps
);
85 void pkg_spec_iter_destroy(struct pkg_spec
*ps
);