2 * libdpkg - Debian packaging suite library routines
3 * triglib.h - declarations for trigger handling
5 * Copyright © 2007 Canonical, Ltd.
6 * written by Ian Jackson <ijackson@chiark.greenend.org.uk>
7 * Copyright © 2008-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_TRIGLIB_H
24 #define LIBDPKG_TRIGLIB_H
26 #include <dpkg/macros.h>
27 #include <dpkg/dpkg-db.h>
32 * @defgroup triglib Trigger handling
33 * @ingroup dpkg-internal
38 * Hooks for more sophisticated processing in dpkg proper.
40 * We do things like this so we can get most of the trigger tracking
41 * in dpkg-query, dselect, and so on, but avoid the transitional
42 * processing and deferred trigproc queue management other than when
43 * we're actually doing real package management work.
46 const char *trig_name_is_illegal(const char *p
);
55 struct pkgbin
*pkgbin
;
56 struct filenamenode
*fnn
;
57 enum trig_options options
;
58 struct trigfileint
*samefile_next
;
60 struct trigfileint
*next
, *prev
;
65 * The first two hooks are normally NULL.
66 * If non-NULL, we're dpkg proper and we might need to invent trigger
67 * activations as the first run of a triggers-supporting dpkg.
70 void (*enqueue_deferred
)(struct pkginfo
*pend
);
71 void (*transitional_activate
)(enum modstatdb_rw cstatus
);
73 struct filenamenode
*(*namenode_find
)(const char *filename
, bool nonew
);
74 struct trigfileint
**(*namenode_interested
)(struct filenamenode
*fnn
);
76 /** Returns a pointer from nfmalloc. */
77 const char *(*namenode_name
)(struct filenamenode
*fnn
);
80 #define TRIGHOOKS_DEFINE_NAMENODE_ACCESSORS \
81 static struct trigfileint **th_nn_interested(struct filenamenode *fnn) \
82 { return &fnn->trig_interested; } \
83 static const char *th_nn_name(struct filenamenode *fnn) \
86 void trig_override_hooks(const struct trig_hooks
*hooks
);
88 void trig_file_activate_byname(const char *trig
, struct pkginfo
*aw
);
89 void trig_file_activate(struct filenamenode
*trig
, struct pkginfo
*aw
);
90 void trig_path_activate(struct filenamenode
*trig
, struct pkginfo
*aw
);
92 bool trig_note_pend_core(struct pkginfo
*pend
, const char *trig
/*not copied!*/);
93 bool trig_note_pend(struct pkginfo
*pend
, const char *trig
/*not copied!*/);
94 bool trig_note_aw(struct pkginfo
*pend
, struct pkginfo
*aw
);
95 void trig_clear_awaiters(struct pkginfo
*notpend
);
97 typedef void trig_awaited_pend_foreach_func(struct pkginfo
*pkg
);
99 void trig_awaited_pend_enqueue(struct pkginfo
*pend
);
100 void trig_awaited_pend_foreach(trig_awaited_pend_foreach_func
*func
);
101 void trig_awaited_pend_free(void);
103 void trig_fixup_awaiters(enum modstatdb_rw cstatus
);
105 void trig_file_interests_ensure(void);
106 void trig_file_interests_save(void);
108 typedef void trig_parse_cicb(const char *trig
, struct pkginfo
*pkg
,
109 struct pkgbin
*pkgbin
, enum trig_options to
);
110 void trig_cicb_interest_delete(const char *trig
, struct pkginfo
*pkg
,
111 struct pkgbin
*pkgbin
, enum trig_options to
);
112 void trig_cicb_interest_add(const char *trig
, struct pkginfo
*pkg
,
113 struct pkgbin
*pkgbin
, enum trig_options to
);
114 void trig_cicb_statuschange_activate(const char *trig
, struct pkginfo
*pkg
,
115 struct pkgbin
*pkgbin
, enum trig_options to
);
116 void trig_parse_ci(const char *file
, trig_parse_cicb
*interest
,
117 trig_parse_cicb
*activate
, struct pkginfo
*pkg
,
118 struct pkgbin
*pkgbin
);
120 void trig_incorporate(enum modstatdb_rw cstatus
);
126 #endif /* LIBDPKG_TRIGLIB_H */