triglib.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * libdpkg - Debian packaging suite library routines
  3. * triglib.h - declarations for trigger handling
  4. *
  5. * Copyright © 2007 Canonical, Ltd.
  6. * written by Ian Jackson <ijackson@chiark.greenend.org.uk>
  7. * Copyright © 2008-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_TRIGLIB_H
  23. #define LIBDPKG_TRIGLIB_H
  24. #include <dpkg/macros.h>
  25. #include <dpkg/dpkg-db.h>
  26. DPKG_BEGIN_DECLS
  27. /**
  28. * @defgroup triglib Trigger handling
  29. * @ingroup dpkg-internal
  30. * @{
  31. */
  32. /*
  33. * Hooks for more sophisticated processing in dpkg proper.
  34. *
  35. * We do things like this so we can get most of the trigger tracking
  36. * in dpkg-query, dselect, and so on, but avoid the transitional
  37. * processing and deferred trigproc queue management other than when
  38. * we're actually doing real package management work.
  39. */
  40. const char *trig_name_is_illegal(const char *p);
  41. enum trig_options {
  42. TRIG_AWAIT,
  43. TRIG_NOAWAIT,
  44. };
  45. struct trigfileint {
  46. struct pkginfo *pkg;
  47. struct pkgbin *pkgbin;
  48. struct filenamenode *fnn;
  49. enum trig_options options;
  50. struct trigfileint *samefile_next;
  51. struct {
  52. struct trigfileint *next, *prev;
  53. } inoverall;
  54. };
  55. /**
  56. * The first two hooks are normally NULL.
  57. * If non-NULL, we're dpkg proper and we might need to invent trigger
  58. * activations as the first run of a triggers-supporting dpkg.
  59. */
  60. struct trig_hooks {
  61. void (*enqueue_deferred)(struct pkginfo *pend);
  62. void (*transitional_activate)(enum modstatdb_rw cstatus);
  63. struct filenamenode *(*namenode_find)(const char *filename, bool nonew);
  64. struct trigfileint **(*namenode_interested)(struct filenamenode *fnn);
  65. /** Returns a pointer from nfmalloc. */
  66. const char *(*namenode_name)(struct filenamenode *fnn);
  67. };
  68. #define TRIGHOOKS_DEFINE_NAMENODE_ACCESSORS \
  69. static struct trigfileint **th_nn_interested(struct filenamenode *fnn) \
  70. { return &fnn->trig_interested; } \
  71. static const char *th_nn_name(struct filenamenode *fnn) \
  72. { return fnn->name; }
  73. void trig_override_hooks(const struct trig_hooks *hooks);
  74. void trig_file_activate_byname(const char *trig, struct pkginfo *aw);
  75. void trig_file_activate(struct filenamenode *trig, struct pkginfo *aw);
  76. void trig_path_activate(struct filenamenode *trig, struct pkginfo *aw);
  77. bool trig_note_pend_core(struct pkginfo *pend, const char *trig /*not copied!*/);
  78. bool trig_note_pend(struct pkginfo *pend, const char *trig /*not copied!*/);
  79. bool trig_note_aw(struct pkginfo *pend, struct pkginfo *aw);
  80. void trig_clear_awaiters(struct pkginfo *notpend);
  81. typedef void trig_awaited_pend_foreach_func(struct pkginfo *pkg);
  82. void trig_awaited_pend_enqueue(struct pkginfo *pend);
  83. void trig_awaited_pend_foreach(trig_awaited_pend_foreach_func *func);
  84. void trig_awaited_pend_free(void);
  85. void trig_fixup_awaiters(enum modstatdb_rw cstatus);
  86. void trig_file_interests_ensure(void);
  87. void trig_file_interests_save(void);
  88. typedef void trig_parse_cicb(const char *trig, struct pkginfo *pkg,
  89. struct pkgbin *pkgbin, enum trig_options to);
  90. void trig_cicb_interest_delete(const char *trig, struct pkginfo *pkg,
  91. struct pkgbin *pkgbin, enum trig_options to);
  92. void trig_cicb_interest_add(const char *trig, struct pkginfo *pkg,
  93. struct pkgbin *pkgbin, enum trig_options to);
  94. void trig_cicb_statuschange_activate(const char *trig, struct pkginfo *pkg,
  95. struct pkgbin *pkgbin, enum trig_options to);
  96. void trig_parse_ci(const char *file, trig_parse_cicb *interest,
  97. trig_parse_cicb *activate, struct pkginfo *pkg,
  98. struct pkgbin *pkgbin);
  99. void trig_incorporate(enum modstatdb_rw cstatus);
  100. /** @} */
  101. DPKG_END_DECLS
  102. #endif /* LIBDPKG_TRIGLIB_H */