triglib.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 <ian@chiark.greenend.org.uk>
  7. *
  8. * This is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef LIBDPKG_TRIGLIB_H
  22. #define LIBDPKG_TRIGLIB_H
  23. #include <dpkg/macros.h>
  24. #include <dpkg/dpkg-db.h>
  25. DPKG_BEGIN_DECLS
  26. /*
  27. * Hooks for more sophisticated processing in dpkg proper.
  28. *
  29. * We do things like this so we can get most of the trigger tracking
  30. * in dpkg-query, dselect, and so on, but avoid the transitional
  31. * processing and deferred trigproc queue management other than when
  32. * we're actually doing real package management work.
  33. */
  34. const char *trig_name_is_illegal(const char *p);
  35. enum trig_options {
  36. trig_await,
  37. trig_noawait
  38. };
  39. struct trigfileint {
  40. struct pkginfo *pkg;
  41. struct filenamenode *fnn;
  42. enum trig_options options;
  43. struct trigfileint *samefile_next;
  44. struct {
  45. struct trigfileint *next, *prev;
  46. } inoverall;
  47. };
  48. /* The first two hooks are normally NULL.
  49. * If non-NULL, we're dpkg proper and we might need to invent trigger
  50. * activations as the first run of a triggers-supporting dpkg. */
  51. struct trig_hooks {
  52. void (*enqueue_deferred)(struct pkginfo *pend);
  53. void (*transitional_activate)(enum modstatdb_rw cstatus);
  54. struct filenamenode *(*namenode_find)(const char *filename, bool nonew);
  55. struct trigfileint **(*namenode_interested)(struct filenamenode *fnn);
  56. /* Returns a pointer from nfmalloc. */
  57. const char *(*namenode_name)(struct filenamenode *fnn);
  58. };
  59. #define TRIGHOOKS_DEFINE_NAMENODE_ACCESSORS \
  60. static struct trigfileint **th_nn_interested(struct filenamenode *fnn) \
  61. { return &fnn->trig_interested; } \
  62. static const char *th_nn_name(struct filenamenode *fnn) \
  63. { return fnn->name; }
  64. void trig_override_hooks(const struct trig_hooks *hooks);
  65. void trig_file_activate_byname(const char *trig, struct pkginfo *aw);
  66. void trig_file_activate(struct filenamenode *trig, struct pkginfo *aw);
  67. bool trig_note_pend_core(struct pkginfo *pend, const char *trig /*not copied!*/);
  68. bool trig_note_pend(struct pkginfo *pend, const char *trig /*not copied!*/);
  69. bool trig_note_aw(struct pkginfo *pend, struct pkginfo *aw);
  70. void trig_clear_awaiters(struct pkginfo *notpend);
  71. typedef void trig_awaited_pend_foreach_func(struct pkginfo *pkg);
  72. void trig_awaited_pend_enqueue(struct pkginfo *pend);
  73. void trig_awaited_pend_foreach(trig_awaited_pend_foreach_func *func);
  74. void trig_awaited_pend_free(void);
  75. void trig_fixup_awaiters(enum modstatdb_rw cstatus);
  76. void trig_file_interests_ensure(void);
  77. void trig_file_interests_save(void);
  78. typedef void trig_parse_cicb(const char *trig, void *user, enum trig_options to);
  79. void trig_cicb_interest_delete(const char *trig, void *user, enum trig_options to);
  80. void trig_cicb_interest_add(const char *trig, void *user, enum trig_options to);
  81. void trig_cicb_statuschange_activate(const char *trig, void *user,
  82. enum trig_options to);
  83. void trig_parse_ci(const char *file, trig_parse_cicb *interest,
  84. trig_parse_cicb *activate, void *user);
  85. void trig_incorporate(enum modstatdb_rw cstatus);
  86. DPKG_END_DECLS
  87. #endif /* LIBDPKG_TRIGLIB_H */