- split file info tag sets into rpmfi.c.
[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 "fsm.h"
10 #include "depends.h"
11
12 /**
13  */
14 #define PSM_VERBOSE     0x8000
15 #define PSM_INTERNAL    0x4000
16 #define PSM_SYSCALL     0x2000
17 #define PSM_DEAD        0x1000
18 #define _fv(_a)         ((_a) | PSM_VERBOSE)
19 #define _fi(_a)         ((_a) | PSM_INTERNAL)
20 #define _fs(_a)         ((_a) | (PSM_INTERNAL | PSM_SYSCALL))
21 #define _fd(_a)         ((_a) | (PSM_INTERNAL | PSM_DEAD))
22 typedef enum pkgStage_e {
23     PSM_UNKNOWN         =  0,
24     PSM_INIT            =  1,
25     PSM_PRE             =  2,
26     PSM_PROCESS         =  3,
27     PSM_POST            =  4,
28     PSM_UNDO            =  5,
29     PSM_FINI            =  6,
30
31     PSM_PKGINSTALL      =  7,
32     PSM_PKGERASE        =  8,
33     PSM_PKGCOMMIT       = 10,
34     PSM_PKGSAVE         = 12,
35
36     PSM_CREATE          = 17,
37     PSM_NOTIFY          = 22,
38     PSM_DESTROY         = 23,
39     PSM_COMMIT          = 25,
40
41     PSM_CHROOT_IN       = 51,
42     PSM_CHROOT_OUT      = 52,
43     PSM_SCRIPT          = 53,
44     PSM_TRIGGERS        = 54,
45     PSM_IMMED_TRIGGERS  = 55,
46     PSM_RPMIO_FLAGS     = 56,
47
48     PSM_RPMDB_LOAD      = 97,
49     PSM_RPMDB_ADD       = 98,
50     PSM_RPMDB_REMOVE    = 99,
51
52 } pkgStage;
53 #undef  _fv
54 #undef  _fi
55 #undef  _fs
56 #undef  _fd
57
58 /**
59  */
60 struct psm_s {
61 /*@refcounted@*/
62     rpmTransactionSet ts;       /*!< transaction set */
63 /*@dependent@*/
64     transactionElement te;      /*!< transaction element */
65 /*@refcounted@*/
66     TFI_t fi;                   /*!< transaction element file info */
67     FD_t cfd;                   /*!< Payload file handle. */
68     FD_t fd;                    /*!< Repackage file handle. */
69     Header oh;                  /*!< Repackage/multilib header. */
70 /*@null@*/
71     rpmdbMatchIterator mi;
72 /*@observer@*/
73     const char * stepName;
74 /*@only@*/ /*@null@*/
75     const char * rpmio_flags;
76 /*@only@*/ /*@null@*/
77     const char * failedFile;
78 /*@only@*/ /*@null@*/
79     const char * pkgURL;        /*!< Repackage URL. */
80 /*@dependent@*/
81     const char * pkgfn;         /*!< Repackage file name. */
82     int scriptTag;              /*!< Scriptlet data tag. */
83     int progTag;                /*!< Scriptlet interpreter tag. */
84     int npkgs_installed;        /*!< No. of installed instances. */
85     int scriptArg;              /*!< Scriptlet package arg. */
86     int sense;                  /*!< One of RPMSENSE_TRIGGER{IN,UN,POSTUN}. */
87     int countCorrection;        /*!< 0 if installing, -1 if removing. */
88     int chrootDone;             /*!< Was chroot(2) done by pkgStage? */
89     rpmCallbackType what;       /*!< Callback type. */
90     unsigned long amount;       /*!< Callback amount. */
91     unsigned long total;        /*!< Callback total. */
92     rpmRC rc;
93     pkgStage goal;
94 /*@unused@*/
95     pkgStage stage;
96 };
97
98 #ifdef __cplusplus
99 extern "C" {
100 #endif
101
102 /**
103  * Return formatted string representation of package disposition.
104  * @param a             package dispostion
105  * @return              formatted string
106  */
107 /*@observer@*/ const char *const fiTypeString(/*@partial@*/TFI_t fi)
108         /*@*/;
109
110 /**
111  * Package state machine driver.
112  * @param psm           package state machine data
113  * @param stage         next stage
114  * @return              0 on success
115  */
116 int psmStage(PSM_t psm, pkgStage stage)
117         /*@globals rpmGlobalMacroContext,
118                 fileSystem, internalState @*/
119         /*@modifies psm, rpmGlobalMacroContext,
120                 fileSystem, internalState @*/;
121
122 #ifdef __cplusplus
123 }
124 #endif
125
126 #endif  /* H_PSM */