pkg-spec.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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-2012 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 <http://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. struct pkg_spec {
  36. char *name;
  37. const struct dpkg_arch *arch;
  38. enum pkg_spec_flags {
  39. /** Recognize glob patterns. */
  40. psf_patterns = 00001,
  41. /* How to consider the lack of an arch qualifier. */
  42. psf_arch_def_single = 00100,
  43. psf_arch_def_wildcard = 00200,
  44. psf_arch_def_mask = 00300,
  45. } flags;
  46. /* Members below are private state. */
  47. bool name_is_pattern;
  48. bool arch_is_pattern;
  49. /** Used for the pkg_db iterator. */
  50. struct pkgiterator *pkg_iter;
  51. /** Used for the pkgset iterator. */
  52. struct pkginfo *pkg_next;
  53. };
  54. void pkg_spec_init(struct pkg_spec *ps, enum pkg_spec_flags flags);
  55. void pkg_spec_destroy(struct pkg_spec *ps);
  56. const char *pkg_spec_is_illegal(struct pkg_spec *ps);
  57. const char *pkg_spec_set(struct pkg_spec *ps,
  58. const char *pkgname, const char *archname);
  59. const char *pkg_spec_parse(struct pkg_spec *ps, const char *str);
  60. bool pkg_spec_match_pkg(struct pkg_spec *ps,
  61. struct pkginfo *pkg, struct pkgbin *pkgbin);
  62. struct pkginfo *pkg_spec_parse_pkg(const char *str, struct dpkg_error *err);
  63. struct pkginfo *pkg_spec_find_pkg(const char *pkgname, const char *archname,
  64. struct dpkg_error *err);
  65. void pkg_spec_iter_init(struct pkg_spec *ps);
  66. struct pkginfo *pkg_spec_iter_next_pkg(struct pkg_spec *ps);
  67. void pkg_spec_iter_destroy(struct pkg_spec *ps);
  68. /** @} */
  69. DPKG_END_DECLS
  70. #endif