Unexport rpmpms typedef, nothing outside rpm can use it anyway
[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 #include <rpmsq.h>
10
11 extern int _psm_debug;
12
13 typedef struct rpmpsm_s * rpmpsm;
14
15 /**
16  */
17 #define PSM_VERBOSE     0x8000
18 #define PSM_INTERNAL    0x4000
19 #define PSM_SYSCALL     0x2000
20 #define PSM_DEAD        0x1000
21 #define _fv(_a)         ((_a) | PSM_VERBOSE)
22 #define _fi(_a)         ((_a) | PSM_INTERNAL)
23 #define _fs(_a)         ((_a) | (PSM_INTERNAL | PSM_SYSCALL))
24 #define _fd(_a)         ((_a) | (PSM_INTERNAL | PSM_DEAD))
25 typedef enum pkgStage_e {
26     PSM_UNKNOWN         =  0,
27     PSM_INIT            =  1,
28     PSM_PRE             =  2,
29     PSM_PROCESS         =  3,
30     PSM_POST            =  4,
31     PSM_UNDO            =  5,
32     PSM_FINI            =  6,
33
34     PSM_PKGINSTALL      =  7,
35     PSM_PKGERASE        =  8,
36     PSM_PKGCOMMIT       = 10,
37     PSM_PKGSAVE         = 12,
38
39     PSM_CREATE          = 17,
40     PSM_NOTIFY          = 22,
41     PSM_DESTROY         = 23,
42     PSM_COMMIT          = 25,
43
44     PSM_CHROOT_IN       = 51,
45     PSM_CHROOT_OUT      = 52,
46     PSM_SCRIPT          = 53,
47     PSM_TRIGGERS        = 54,
48     PSM_IMMED_TRIGGERS  = 55,
49     PSM_RPMIO_FLAGS     = 56,
50
51     PSM_RPMDB_LOAD      = 97,
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 /**
62  */
63 struct rpmpsm_s {
64     struct rpmsqElem sq;        /*!< Scriptlet/signal queue element. */
65
66     rpmts ts;                   /*!< transaction set */
67     rpmte te;                   /*!< current transaction element */
68     rpmfi fi;                   /*!< transaction element file info */
69     FD_t cfd;                   /*!< Payload file handle. */
70     FD_t fd;                    /*!< Repackage file handle. */
71     Header oh;                  /*!< Repackage header. */
72     rpmdbMatchIterator mi;
73     const char * stepName;
74     const char * rpmio_flags;
75     const char * failedFile;
76     const char * pkgURL;        /*!< Repackage URL. */
77     const char * pkgfn;         /*!< Repackage file name. */
78     int scriptTag;              /*!< Scriptlet data tag. */
79     int progTag;                /*!< Scriptlet interpreter tag. */
80     int npkgs_installed;        /*!< No. of installed instances. */
81     int scriptArg;              /*!< Scriptlet package arg. */
82     int sense;                  /*!< One of RPMSENSE_TRIGGER{IN,UN,POSTUN}. */
83     int countCorrection;        /*!< 0 if installing, -1 if removing. */
84     int chrootDone;             /*!< Was chroot(2) done by pkgStage? */
85     int unorderedSuccessor;     /*!< Can the PSM be run asynchronously? */
86     rpmCallbackType what;       /*!< Callback type. */
87     unsigned long amount;       /*!< Callback amount. */
88     unsigned long total;        /*!< Callback total. */
89     rpmRC rc;
90     pkgStage goal;
91     pkgStage stage;             /*!< Current psm stage. */
92     pkgStage nstage;            /*!< Next psm stage. */
93
94     int nrefs;                  /*!< Reference count. */
95 };
96
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100
101 /**
102  * Unreference a package state machine instance.
103  * @param psm           package state machine
104  * @param msg
105  * @return              NULL always
106  */
107 rpmpsm rpmpsmUnlink (rpmpsm psm,
108                 const char * msg);
109
110 /** @todo Remove debugging entry from the ABI. */
111 rpmpsm XrpmpsmUnlink (rpmpsm psm,
112                 const char * msg, const char * fn, unsigned ln);
113 #define rpmpsmUnlink(_psm, _msg)        XrpmpsmUnlink(_psm, _msg, __FILE__, __LINE__)
114
115 /**
116  * Reference a package state machine instance.
117  * @param psm           package state machine
118  * @param msg
119  * @return              new package state machine reference
120  */
121 rpmpsm rpmpsmLink (rpmpsm psm, const char * msg);
122
123 /** @todo Remove debugging entry from the ABI. */
124 rpmpsm XrpmpsmLink (rpmpsm psm, const char * msg,
125                 const char * fn, unsigned ln);
126 #define rpmpsmLink(_psm, _msg)  XrpmpsmLink(_psm, _msg, __FILE__, __LINE__)
127
128 /**
129  * Destroy a package state machine.
130  * @param psm           package state machine
131  * @return              NULL always
132  */
133 rpmpsm rpmpsmFree(rpmpsm psm);
134
135 /**
136  * Create and load a package state machine.
137  * @param ts            transaction set
138  * @param te            transaction set element
139  * @param fi            file info set
140  * @return              new package state machine
141  */
142 rpmpsm rpmpsmNew(rpmts ts, rpmte te, rpmfi fi);
143
144 /**
145  * Package state machine driver.
146  * @param psm           package state machine data
147  * @param stage         next stage
148  * @return              0 on success
149  */
150 rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage);
151 #define rpmpsmUNSAFE    rpmpsmSTAGE
152
153 #ifdef __cplusplus
154 }
155 #endif
156
157 #endif  /* H_PSM */