Realize the remaining bits of direct rpmdb interface are dead too
[platform/upstream/rpm.git] / build / rpmspec.h
1 #ifndef _H_SPEC_
2 #define _H_SPEC_
3
4 /** \ingroup rpmbuild
5  * \file build/rpmspec.h
6  *  The rpmSpec and Package data structures used during build.
7  */
8
9 #include <rpm/rpmstring.h>      /* StringBuf */
10 #include <rpm/rpmcli.h> /* for QVA_t */
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 /** \ingroup rpmbuild
17  */
18 typedef struct Package_s * Package;
19
20 /** \ingroup rpmbuild
21  */
22 struct TriggerFileEntry {
23     int index;
24     char * fileName;
25     char * script;
26     char * prog;
27     struct TriggerFileEntry * next;
28 };
29
30 #define RPMBUILD_ISSOURCE       (1 << 0)
31 #define RPMBUILD_ISPATCH        (1 << 1)
32 #define RPMBUILD_ISICON         (1 << 2)
33 #define RPMBUILD_ISNO           (1 << 3)
34
35 #define RPMBUILD_DEFAULT_LANG "C"
36
37 /** \ingroup rpmbuild
38  */
39 struct Source {
40     char * fullSource;
41     char * source;     /* Pointer into fullSource */
42     int flags;
43     uint32_t num;
44 struct Source * next;
45 };
46
47 /** \ingroup rpmbuild
48  */
49 typedef struct ReadLevelEntry {
50     int reading;
51     struct ReadLevelEntry * next;
52 } RLE_t;
53
54 /** \ingroup rpmbuild
55  */
56 typedef struct OpenFileInfo {
57     char * fileName;
58     FD_t fd;
59     int lineNum;
60     char readBuf[BUFSIZ];
61     char * readPtr;
62     struct OpenFileInfo * next;
63 } OFI_t;
64
65 /** \ingroup rpmbuild
66  */
67 typedef struct spectag_s {
68     int t_tag;
69     int t_startx;
70     int t_nlines;
71     char * t_lang;
72     char * t_msgid;
73 } * spectag;
74
75 /** \ingroup rpmbuild
76  */
77 typedef struct spectags_s {
78     spectag st_t;
79     int st_nalloc;
80     int st_ntags;
81 } * spectags;
82
83 /** \ingroup rpmbuild
84  */
85 typedef struct speclines_s {
86     char **sl_lines;
87     int sl_nalloc;
88     int sl_nlines;
89 } * speclines;
90
91 /** \ingroup rpmbuild
92  * The structure used to store values parsed from a spec file.
93  */
94 struct rpmSpec_s {
95     char * specFile;    /*!< Name of the spec file. */
96     char * buildRoot;
97     char * buildSubdir;
98     char * rootDir;
99
100     speclines sl;
101     spectags st;
102
103     struct OpenFileInfo * fileStack;
104     char lbuf[10*BUFSIZ];
105     char *lbufPtr;
106     char nextpeekc;
107     char * nextline;
108     char * line;
109     int lineNum;
110
111     struct ReadLevelEntry * readStack;
112
113     Header buildRestrictions;
114     rpmSpec * BASpecs;
115     const char ** BANames;
116     int BACount;
117     int recursing;              /*!< parse is recursive? */
118
119     int force;
120     int anyarch;
121
122     char * passPhrase;
123     int timeCheck;
124     char * cookie;
125
126     struct Source * sources;
127     int numSources;
128     int noSource;
129
130     char * sourceRpmName;
131     unsigned char * sourcePkgId;
132     Header sourceHeader;
133     rpmfi sourceCpioList;
134
135     rpmMacroContext macros;
136
137     StringBuf prep;             /*!< %prep scriptlet. */
138     StringBuf build;            /*!< %build scriptlet. */
139     StringBuf install;          /*!< %install scriptlet. */
140     StringBuf check;            /*!< %check scriptlet. */
141     StringBuf clean;            /*!< %clean scriptlet. */
142
143     Package packages;           /*!< Package list. */
144 };
145
146 /** \ingroup rpmbuild
147  * The structure used to store values for a package.
148  */
149 struct Package_s {
150     Header header;
151     rpmds ds;                   /*!< Requires: N = EVR */
152     rpmfi cpioList;
153
154     struct Source * icon;
155
156     int autoReq;
157     int autoProv;
158
159     char * preInFile;   /*!< %pre scriptlet. */
160     char * postInFile;  /*!< %post scriptlet. */
161     char * preUnFile;   /*!< %preun scriptlet. */
162     char * postUnFile;  /*!< %postun scriptlet. */
163     char * preTransFile;        /*!< %pretrans scriptlet. */
164     char * postTransFile;       /*!< %posttrans scriptlet. */
165     char * verifyFile;  /*!< %verifyscript scriptlet. */
166
167     StringBuf specialDoc;
168     char *specialDocDir;
169
170     struct TriggerFileEntry * triggerFiles;
171
172     StringBuf fileFile;
173     StringBuf fileList;         /* If NULL, package will not be written */
174
175     Package next;
176 };
177
178 /** \ingroup rpmbuild
179  * Create and initialize rpmSpec structure.
180  * @return spec         spec file control structure
181  */
182 rpmSpec newSpec(void);
183
184 /** \ingroup rpmbuild
185  * Destroy Spec structure.
186  * @param spec          spec file control structure
187  * @return              NULL always
188  */
189 rpmSpec freeSpec(rpmSpec spec);
190
191 /** \ingroup rpmbuild
192  * Function to query spec file(s).
193  * @param ts            transaction set
194  * @param qva           parsed query/verify options
195  * @param arg           query argument
196  * @return              0 on success, else no. of failures
197  */
198 int rpmspecQuery(rpmts ts, QVA_t qva, const char * arg);
199
200 /** \ingroup rpmbuild
201  */
202 struct OpenFileInfo * newOpenFileInfo(void);
203
204 /** \ingroup rpmbuild
205  * stashSt.
206  * @param spec          spec file control structure
207  * @param h             header
208  * @param tag           tag
209  * @param lang          locale
210  */
211 spectag stashSt(rpmSpec spec, Header h, rpmTag tag, const char * lang);
212
213 /** \ingroup rpmbuild
214  * addSource.
215  * @param spec          spec file control structure
216  * @param pkg           package control
217  * @param field         field to parse
218  * @param tag           tag
219  */
220 int addSource(rpmSpec spec, Package pkg, const char * field, rpmTag tag);
221
222 /** \ingroup rpmbuild
223  * parseNoSource.
224  * @param spec          spec file control structure
225  * @param field         field to parse
226  * @param tag           tag
227  */
228 int parseNoSource(rpmSpec spec, const char * field, rpmTag tag);
229
230 #ifdef __cplusplus
231 }
232 #endif
233
234 #endif /* _H_SPEC_ */