2 * libdpkg - Debian packaging suite library routines
3 * trignote.c - trigger note 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/>.
28 #include <dpkg/dpkg.h>
29 #include <dpkg/dpkg-db.h>
31 #include <dpkg/pkg-list.h>
32 #include <dpkg/dlist.h>
33 #include <dpkg/triglib.h>
36 * Note: This is also called from fields.c where *pend is a temporary!
41 trig_note_pend_core(struct pkginfo
*pend
, const char *trig
)
45 for (tp
= pend
->trigpend_head
; tp
; tp
= tp
->next
)
46 if (strcmp(tp
->name
, trig
) == 0)
49 tp
= nfmalloc(sizeof(*tp
));
51 tp
->next
= pend
->trigpend_head
;
52 pend
->trigpend_head
= tp
;
60 * @retval true For done.
61 * @retval false For already noted.
64 trig_note_pend(struct pkginfo
*pend
, const char *trig
)
66 if (!trig_note_pend_core(pend
, trig
))
69 if (pend
->trigaw
.head
)
70 pkg_set_status(pend
, PKG_STAT_TRIGGERSAWAITED
);
72 pkg_set_status(pend
, PKG_STAT_TRIGGERSPENDING
);
78 * Note: This is called also from fields.c where *aw is a temporary
79 * but pend is from pkg_hash_find()!
81 * @retval true For done.
82 * @retval false For already noted.
85 trig_note_aw(struct pkginfo
*pend
, struct pkginfo
*aw
)
89 /* We search through aw's list because that's probably shorter. */
90 for (ta
= aw
->trigaw
.head
; ta
; ta
= ta
->sameaw
.next
)
94 ta
= nfmalloc(sizeof(*ta
));
97 ta
->samepend_next
= pend
->othertrigaw_head
;
98 pend
->othertrigaw_head
= ta
;
99 LIST_LINK_TAIL_PART(aw
->trigaw
, ta
, sameaw
);
104 static struct pkg_list
*trig_awaited_pend_head
;
107 trig_awaited_pend_enqueue(struct pkginfo
*pend
)
111 for (tp
= trig_awaited_pend_head
; tp
; tp
= tp
->next
)
115 pkg_list_prepend(&trig_awaited_pend_head
, pend
);
119 trig_awaited_pend_foreach(trig_awaited_pend_foreach_func
*func
)
123 for (tp
= trig_awaited_pend_head
; tp
; tp
= tp
->next
)
124 if (!tp
->pkg
->trigpend_head
)
129 trig_awaited_pend_free(void)
131 pkg_list_free(trig_awaited_pend_head
);
132 trig_awaited_pend_head
= NULL
;