- enough lclint annotations and fiddles already.
[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 Spec and Package data structures used during build.
7  */
8
9 /** \ingroup rpmbuild
10  */
11 typedef struct SpecStruct *Spec;
12
13 #include "rpmmacro.h"
14
15 /** \ingroup rpmbuild
16  */
17 struct TriggerFileEntry {
18     int index;
19 /*@only@*/ char *fileName;
20 /*@only@*/ char *script;
21 /*@only@*/ char *prog;
22 /*@owned@*/ struct TriggerFileEntry *next;
23 };
24
25 #define RPMBUILD_ISSOURCE     1
26 #define RPMBUILD_ISPATCH     (1 << 1)
27 #define RPMBUILD_ISICON      (1 << 2)
28 #define RPMBUILD_ISNO        (1 << 3)
29
30 #define RPMBUILD_DEFAULT_LANG "C"
31
32 /** \ingroup rpmbuild
33  */
34 struct Source {
35 /*@owned@*/ char * fullSource;
36 /*@dependent@*/ char * source;     /* Pointer into fullSource */
37     int flags;
38     int num;
39 /*@owned@*/ struct Source * next;
40 };
41
42 /** \ingroup rpmbuild
43  */
44 typedef struct ReadLevelEntry {
45     int reading;
46 /*@dependent@*/ struct ReadLevelEntry * next;
47 } RLE_t;
48
49 /** \ingroup rpmbuild
50  */
51 typedef struct OpenFileInfo {
52 /*@only@*/ const char * fileName;
53     FD_t fd;
54     int lineNum;
55     char readBuf[BUFSIZ];
56 /*@dependent@*/ char *readPtr;
57 /*@owned@*/ struct OpenFileInfo * next;
58 } OFI_t;
59
60 /** \ingroup rpmbuild
61  */
62 struct spectag {
63     int t_tag;
64     int t_startx;
65     int t_nlines;
66 /*@only@*/ const char * t_lang;
67 /*@only@*/ const char * t_msgid;
68 };
69
70 /** \ingroup rpmbuild
71  */
72 struct spectags {
73 /*@owned@*/ struct spectag *st_t;
74     int st_nalloc;
75     int st_ntags;
76 };
77
78 /** \ingroup rpmbuild
79  */
80 struct speclines {
81 /*@only@*/ char **sl_lines;
82     int sl_nalloc;
83     int sl_nlines;
84 };
85
86 /** \ingroup rpmbuild
87  * The structure used to store values parsed from a spec file.
88  */
89 struct SpecStruct {
90 /*@only@*/ const char * specFile;       /*!< Name of the spec file. */
91 /*@only@*/ const char * sourceRpmName;
92 /*@only@*/ const char * buildRootURL;
93 /*@only@*/ const char * buildSubdir;
94 /*@only@*/ const char * rootURL;
95
96 /*@owned@*/ /*@null@*/ struct speclines * sl;
97 /*@owned@*/ /*@null@*/ struct spectags * st;
98
99 /*@owned@*/ struct OpenFileInfo * fileStack;
100     char lbuf[4*BUFSIZ];
101     char nextpeekc;
102 /*@dependent@*/ char * nextline;
103 /*@dependent@*/ char * line;
104     int lineNum;
105
106 /*@owned@*/ struct ReadLevelEntry * readStack;
107
108 /*@refcounted@*/ Header buildRestrictions;
109 /*@owned@*/ /*@null@*/ struct SpecStruct ** buildArchitectureSpecs;
110 /*@only@*/ /*@null@*/ const char ** buildArchitectures;
111     int buildArchitectureCount;
112     int inBuildArchitectures;
113
114     int force;
115     int anyarch;
116
117     int gotBuildRootURL;
118
119 /*@null@*/ char * passPhrase;
120     int timeCheck;
121 /*@null@*/ const char * cookie;
122
123 /*@owned@*/ struct Source * sources;
124     int numSources;
125     int noSource;
126
127 /*@refcounted@*/ Header sourceHeader;
128 /*@owned@*/ void * sourceCpioList;
129
130 /*@dependent@*/ /*@null@*/ MacroContext macros;
131
132 /*@only@*/ StringBuf prep;              /*!< %prep scriptlet. */
133 /*@only@*/ StringBuf build;             /*!< %build scriptlet. */
134 /*@only@*/ StringBuf install;           /*!< %install scriptlet. */
135 /*@only@*/ StringBuf clean;             /*!< %clean scriptlet. */
136
137 /*@owned@*/ struct PackageStruct * packages;    /*!< Package list. */
138 };
139
140 /** \ingroup rpmbuild
141  * The structure used to store values for a package.
142  */
143 struct PackageStruct {
144 /*@refcounted@*/ Header header;
145
146 /*@owned@*/ void * cpioList;
147
148 /*@owned@*/ struct Source * icon;
149
150     int autoReq;
151     int autoProv;
152
153 /*@only@*/ const char * preInFile;      /*!< %pre scriptlet. */
154 /*@only@*/ const char * postInFile;     /*!< %post scriptlet. */
155 /*@only@*/ const char * preUnFile;      /*!< %preun scriptlet. */
156 /*@only@*/ const char * postUnFile;     /*!< %postun scriptlet. */
157 /*@only@*/ const char * verifyFile;     /*!< %verifyscript scriptlet. */
158
159 /*@only@*/ StringBuf specialDoc;
160
161 /*@only@*/ struct TriggerFileEntry * triggerFiles;
162
163 /*@only@*/ const char * fileFile;
164 /*@only@*/ StringBuf fileList; /* If NULL, package will not be written */
165
166 /*@dependent@*/ struct PackageStruct * next;
167 };
168
169 /** \ingroup rpmbuild
170  */
171 typedef struct PackageStruct * Package;
172
173 #ifdef __cplusplus
174 extern "C" {
175 #endif
176
177 /** \ingroup rpmbuild
178  * Create and initialize Spec structure.
179  */
180 /*@only@*/ Spec newSpec(void)   /*@*/;
181
182 /** \ingroup rpmbuild
183  * Destroy Spec structure.
184  * @param spec          spec file control structure
185  */
186 void freeSpec(/*@only@*/ Spec spec)
187         /*@modifies spec @*/;
188
189 /** \ingroup rpmbuild
190  * @param spec          spec file control structure
191  */
192 extern void (*freeSpecVec) (Spec spec)  /* XXX FIXME */
193         /*@modifies spec @*/;
194
195 /** \ingroup rpmbuild
196  */
197 struct OpenFileInfo * newOpenFileInfo(void)     /*@*/;
198
199 /** \ingroup rpmbuild
200  * @param spec          spec file control structure
201  */
202 struct spectag * stashSt(Spec spec, Header h, int tag, const char * lang)
203         /*@modifies spec->st @*/;
204
205 /** \ingroup rpmbuild
206  * @param spec          spec file control structure
207  */
208 int addSource(Spec spec, Package pkg, const char * field, int tag)
209         /*@modifies spec->sources, spec->numSources,
210                 spec->st, spec->macros,
211                 pkg->icon @*/;
212
213 /** \ingroup rpmbuild
214  * @param spec          spec file control structure
215  */
216 int parseNoSource(Spec spec, const char * field, int tag)
217         /*@modifies nothing @*/;
218
219 #ifdef __cplusplus
220 }
221 #endif
222
223 #endif /* _H_SPEC_ */