2 * libdpkg - Debian packaging suite library routines
3 * c-trigdeferred.c - test triggered deferred file parser
5 * Copyright © 2016 Guillem Jover <guillem@debian.org>
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include <dpkg/dpkg-db.h>
29 #include <dpkg/ehandle.h>
30 #include <dpkg/trigdeferred.h>
33 test_tdm_begin(const char *trig)
35 printf("<T='%s'", trig);
39 test_tdm_package(const char *awname)
41 printf(" P='%s'", awname);
50 static const struct trigdefmeths test_tdm = {
51 .trig_begin = test_tdm_begin,
52 .package = test_tdm_package,
53 .trig_end = test_tdm_end,
57 test_trigdeferred_parser(const char *admindir)
59 enum trigdef_update_flags tduf;
60 enum trigdef_update_status tdus;
62 dpkg_db_set_dir(admindir);
64 trigdef_set_methods(&test_tdm);
66 tduf = TDUF_NO_LOCK | TDUF_WRITE_IF_EMPTY | TDUF_WRITE_IF_ENOENT;
67 tdus = trigdef_update_start(tduf);
69 return -tdus + TDUS_OK;
73 trigdef_process_done();
79 main(int argc, char **argv)
81 const char *admindir = argv[1];
84 setvbuf(stdout, NULL, _IOLBF, 0);
89 ohshit("missing triggers deferred admindir");
91 ret = test_trigdeferred_parser(admindir);
93 pop_error_context(ehflag_normaltidy);