Read pkgcache into hash
[pacman-ng.git] / lib / libalpm / trans.h
blobce2dc529124c9172ec25448df04cbba2ab6e6d2c
1 /*
2 * trans.h
4 * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
5 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
6 * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
7 * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
8 * Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef _ALPM_TRANS_H
24 #define _ALPM_TRANS_H
26 #include "alpm.h"
28 typedef enum _pmtransstate_t {
29 STATE_IDLE = 0,
30 STATE_INITIALIZED,
31 STATE_PREPARED,
32 STATE_DOWNLOADING,
33 STATE_COMMITING,
34 STATE_COMMITED,
35 STATE_INTERRUPTED
36 } pmtransstate_t;
38 /* Transaction */
39 struct __pmtrans_t {
40 pmtransflag_t flags;
41 pmtransstate_t state;
42 alpm_list_t *add; /* list of (pmpkg_t *) */
43 alpm_list_t *remove; /* list of (pmpkg_t *) */
44 alpm_list_t *skip_add; /* list of (char *) */
45 alpm_list_t *skip_remove; /* list of (char *) */
46 alpm_trans_cb_event cb_event;
47 alpm_trans_cb_conv cb_conv;
48 alpm_trans_cb_progress cb_progress;
51 #define EVENT(t, e, d1, d2) \
52 do { \
53 if((t) && (t)->cb_event) { \
54 (t)->cb_event(e, d1, d2); \
55 } \
56 } while(0)
57 #define QUESTION(t, q, d1, d2, d3, r) \
58 do { \
59 if((t) && (t)->cb_conv) { \
60 (t)->cb_conv(q, d1, d2, d3, r); \
61 } \
62 } while(0)
63 #define PROGRESS(t, e, p, per, h, r) \
64 do { \
65 if((t) && (t)->cb_progress) { \
66 (t)->cb_progress(e, p, per, h, r); \
67 } \
68 } while(0)
70 pmtrans_t *_alpm_trans_new(void);
71 void _alpm_trans_free(pmtrans_t *trans);
72 int _alpm_trans_init(pmtrans_t *trans, pmtransflag_t flags,
73 alpm_trans_cb_event event, alpm_trans_cb_conv conv,
74 alpm_trans_cb_progress progress);
75 int _alpm_runscriptlet(const char *root, const char *installfn,
76 const char *script, const char *ver,
77 const char *oldver, pmtrans_t *trans);
79 #endif /* _ALPM_TRANS_H */
81 /* vim: set ts=2 sw=2 noet: */