Sanitize python object -> tag number exception handling
[platform/upstream/rpm.git] / lib / psm.h
1 #ifndef H_PSM
2 #define H_PSM
3
4 /** \ingroup rpmtrans payload
5  * \file lib/psm.h
6  * Package state machine to handle a package from a transaction set.
7  */
8
9 #define _RPMSQ_INTERNAL 
10 #include <rpm/rpmsq.h>
11 #include <rpm/rpmcallback.h>
12
13 extern int _psm_debug;
14
15 typedef struct rpmpsm_s * rpmpsm;
16
17 /**
18  */
19 #define PSM_VERBOSE     0x8000
20 #define PSM_INTERNAL    0x4000
21 #define PSM_SYSCALL     0x2000
22 #define PSM_DEAD        0x1000
23 #define _fv(_a)         ((_a) | PSM_VERBOSE)
24 #define _fi(_a)         ((_a) | PSM_INTERNAL)
25 #define _fs(_a)         ((_a) | (PSM_INTERNAL | PSM_SYSCALL))
26 #define _fd(_a)         ((_a) | (PSM_INTERNAL | PSM_DEAD))
27 typedef enum pkgStage_e {
28     PSM_UNKNOWN         =  0,
29     PSM_INIT            =  1,
30     PSM_PRE             =  2,
31     PSM_PROCESS         =  3,
32     PSM_POST            =  4,
33     PSM_UNDO            =  5,
34     PSM_FINI            =  6,
35
36     PSM_PKGINSTALL      =  7,
37     PSM_PKGERASE        =  8,
38     PSM_PKGCOMMIT       = 10,
39
40     PSM_CREATE          = 17,
41     PSM_NOTIFY          = 22,
42     PSM_DESTROY         = 23,
43     PSM_COMMIT          = 25,
44
45     PSM_CHROOT_IN       = 51,
46     PSM_CHROOT_OUT      = 52,
47     PSM_SCRIPT          = 53,
48     PSM_TRIGGERS        = 54,
49     PSM_IMMED_TRIGGERS  = 55,
50     PSM_RPMIO_FLAGS     = 56,
51
52     PSM_RPMDB_ADD       = 98,
53     PSM_RPMDB_REMOVE    = 99
54
55 } pkgStage;
56 #undef  _fv
57 #undef  _fi
58 #undef  _fs
59 #undef  _fd
60
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64
65 /**
66  * Unreference a package state machine instance.
67  * @param psm           package state machine
68  * @param msg
69  * @return              NULL always
70  */
71 RPM_GNUC_INTERNAL
72 rpmpsm rpmpsmUnlink (rpmpsm psm,
73                 const char * msg);
74
75 /**
76  * Reference a package state machine instance.
77  * @param psm           package state machine
78  * @param msg
79  * @return              new package state machine reference
80  */
81 RPM_GNUC_INTERNAL
82 rpmpsm rpmpsmLink (rpmpsm psm, const char * msg);
83
84 /**
85  * Destroy a package state machine.
86  * @param psm           package state machine
87  * @return              NULL always
88  */
89 RPM_GNUC_INTERNAL
90 rpmpsm rpmpsmFree(rpmpsm psm);
91
92 /**
93  * Create and load a package state machine.
94  * @param ts            transaction set
95  * @param te            transaction set element
96  * @return              new package state machine
97  */
98 RPM_GNUC_INTERNAL
99 rpmpsm rpmpsmNew(rpmts ts, rpmte te);
100
101 /**
102  * Package state machine driver.
103  * @param psm           package state machine data
104  * @param stage         next stage
105  * @return              0 on success
106  */
107 RPM_GNUC_INTERNAL
108 rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage);
109 #define rpmpsmUNSAFE    rpmpsmSTAGE
110
111 /**
112  * Run rpmpsmStage(PSM_SCRIPT) for scriptTag and progTag
113  * @param psm           package state machine data
114  * @param scriptTag     scriptlet tag to execute
115  * @param progTag       scriptlet prog tag to execute
116  * @return              0 on success
117  */
118 RPM_GNUC_INTERNAL
119 rpmRC rpmpsmScriptStage(rpmpsm psm, rpmTag scriptTag, rpmTag progTag);
120
121 #ifdef __cplusplus
122 }
123 #endif
124
125 #endif  /* H_PSM */