pkg-spec.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * libdpkg - Debian packaging suite library routines
  3. * pkg-spec.h - primitives for pkg specifier handling
  4. *
  5. * Copyright © 2011 Linaro Limited
  6. * Copyright © 2011 Raphaël Hertzog <hertzog@debian.org>
  7. * Copyright © 2011-2014 Guillem Jover <guillem@debian.org>
  8. *
  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.
  13. *
  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.
  18. *
  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/>.
  21. */
  22. #ifndef LIBDPKG_PKG_SPEC_H
  23. #define LIBDPKG_PKG_SPEC_H
  24. #include <stdbool.h>
  25. #include <dpkg/macros.h>
  26. #include <dpkg/dpkg-db.h>
  27. #include <dpkg/error.h>
  28. #include <dpkg/arch.h>
  29. DPKG_BEGIN_DECLS
  30. /**
  31. * @defgroup pkg-spec Package specifiers
  32. * @ingroup dpkg-public
  33. * @{
  34. */
  35. enum pkg_spec_flags {
  36. /** Recognize glob patterns. */
  37. PKG_SPEC_PATTERNS = DPKG_BIT(0),
  38. /* How to consider the lack of an arch qualifier. */
  39. PKG_SPEC_ARCH_SINGLE = DPKG_BIT(8),
  40. PKG_SPEC_ARCH_WILDCARD = DPKG_BIT(9),
  41. PKG_SPEC_ARCH_MASK = 0xff00,
  42. };
  43. struct pkg_spec {
  44. char *name;
  45. const struct dpkg_arch *arch;
  46. enum pkg_spec_flags flags;
  47. /* Members below are private state. */
  48. bool name_is_pattern;
  49. bool arch_is_pattern;
  50. /** Used for the pkg_db iterator. */
  51. struct pkgiterator *pkg_iter;
  52. /** Used for the pkgset iterator. */
  53. struct pkginfo *pkg_next;
  54. };
  55. void pkg_spec_init(struct pkg_spec *ps, enum pkg_spec_flags flags);
  56. void pkg_spec_destroy(struct pkg_spec *ps);
  57. const char *pkg_spec_is_illegal(struct pkg_spec *ps);
  58. const char *pkg_spec_set(struct pkg_spec *ps,
  59. const char *pkgname, const char *archname);
  60. const char *pkg_spec_parse(struct pkg_spec *ps, const char *str);
  61. bool pkg_spec_match_pkg(struct pkg_spec *ps,
  62. struct pkginfo *pkg, struct pkgbin *pkgbin);
  63. struct pkginfo *pkg_spec_parse_pkg(const char *str, struct dpkg_error *err);
  64. struct pkginfo *pkg_spec_find_pkg(const char *pkgname, const char *archname,
  65. struct dpkg_error *err);
  66. void pkg_spec_iter_init(struct pkg_spec *ps);
  67. struct pkginfo *pkg_spec_iter_next_pkg(struct pkg_spec *ps);
  68. void pkg_spec_iter_destroy(struct pkg_spec *ps);
  69. /** @} */
  70. DPKG_END_DECLS
  71. #endif