lclint fiddles to annotate globals.
[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 /*@-typeuse@*/
45 typedef struct ReadLevelEntry {
46     int reading;
47 /*@dependent@*/ struct ReadLevelEntry * next;
48 } RLE_t;
49 /*@=typeuse@*/
50
51 /** \ingroup rpmbuild
52  */
53 typedef struct OpenFileInfo {
54 /*@only@*/ const char * fileName;
55     FD_t fd;
56     int lineNum;
57     char readBuf[BUFSIZ];
58 /*@dependent@*/ char *readPtr;
59 /*@owned@*/ struct OpenFileInfo * next;
60 } OFI_t;
61
62 /** \ingroup rpmbuild
63  */
64 typedef struct spectag_s {
65     int t_tag;
66     int t_startx;
67     int t_nlines;
68 /*@only@*/ const char * t_lang;
69 /*@only@*/ const char * t_msgid;
70 } * spectag;
71
72 /** \ingroup rpmbuild
73  */
74 typedef struct spectags_s {
75 /*@owned@*/ spectag st_t;
76     int st_nalloc;
77     int st_ntags;
78 } * spectags;
79
80 /** \ingroup rpmbuild
81  */
82 typedef struct speclines_s {
83 /*@only@*/ char **sl_lines;
84     int sl_nalloc;
85     int sl_nlines;
86 } * speclines;
87
88 /** \ingroup rpmbuild
89  * The structure used to store values parsed from a spec file.
90  */
91 struct SpecStruct {
92 /*@only@*/ const char * specFile;       /*!< Name of the spec file. */
93 /*@only@*/ const char * sourceRpmName;
94 /*@only@*/ const char * buildRootURL;
95 /*@only@*/ const char * buildSubdir;
96 /*@only@*/ const char * rootURL;
97
98 /*@owned@*/ /*@null@*/ speclines sl;
99 /*@owned@*/ /*@null@*/ spectags st;
100
101 /*@owned@*/ struct OpenFileInfo * fileStack;
102     char lbuf[4*BUFSIZ];
103     char nextpeekc;
104 /*@dependent@*/ char * nextline;
105 /*@dependent@*/ char * line;
106     int lineNum;
107
108 /*@owned@*/ struct ReadLevelEntry * readStack;
109
110 /*@refcounted@*/ Header buildRestrictions;
111 /*@owned@*/ /*@null@*/ struct SpecStruct ** BASpecs;
112 /*@only@*/ /*@null@*/ const char ** BANames;
113     int BACount;
114     int recursing;                      /*!< parse is recursive? */
115
116     int force;
117     int anyarch;
118
119     int gotBuildRootURL;
120
121 /*@null@*/ char * passPhrase;
122     int timeCheck;
123 /*@null@*/ const char * cookie;
124
125 /*@owned@*/ struct Source * sources;
126     int numSources;
127     int noSource;
128
129 /*@refcounted@*/ Header sourceHeader;
130 /*@owned@*/ void * sourceCpioList;
131
132 /*@dependent@*/ /*@null@*/ MacroContext macros;
133
134 /*@only@*/ StringBuf prep;              /*!< %prep scriptlet. */
135 /*@only@*/ StringBuf build;             /*!< %build scriptlet. */
136 /*@only@*/ StringBuf install;           /*!< %install scriptlet. */
137 /*@only@*/ StringBuf clean;             /*!< %clean scriptlet. */
138
139 /*@owned@*/ struct PackageStruct * packages;    /*!< Package list. */
140 };
141
142 /** \ingroup rpmbuild
143  * The structure used to store values for a package.
144  */
145 struct PackageStruct {
146 /*@refcounted@*/ Header header;
147
148 /*@owned@*/ void * cpioList;
149
150 /*@owned@*/ struct Source * icon;
151
152     int autoReq;
153     int autoProv;
154
155 /*@only@*/ const char * preInFile;      /*!< %pre scriptlet. */
156 /*@only@*/ const char * postInFile;     /*!< %post scriptlet. */
157 /*@only@*/ const char * preUnFile;      /*!< %preun scriptlet. */
158 /*@only@*/ const char * postUnFile;     /*!< %postun scriptlet. */
159 /*@only@*/ const char * verifyFile;     /*!< %verifyscript scriptlet. */
160
161 /*@only@*/ StringBuf specialDoc;
162
163 /*@only@*/ struct TriggerFileEntry * triggerFiles;
164
165 /*@only@*/ const char * fileFile;
166 /*@only@*/ StringBuf fileList; /* If NULL, package will not be written */
167
168 /*@dependent@*/ struct PackageStruct * next;
169 };
170
171 /** \ingroup rpmbuild
172  */
173 typedef struct PackageStruct * Package;
174
175 #ifdef __cplusplus
176 extern "C" {
177 #endif
178
179 /** \ingroup rpmbuild
180  * Create and initialize Spec structure.
181  * @return spec         spec file control structure
182  */
183 /*@only@*/ Spec newSpec(void)
184         /*@globals rpmGlobalMacroContext @*/
185         /*@modifies rpmGlobalMacroContext @*/;
186
187 /** \ingroup rpmbuild
188  * Destroy Spec structure.
189  * @param spec          spec file control structure
190  * @return              NULL always
191  */
192 /*@null@*/ Spec freeSpec(/*@only@*/ /*@null@*/ Spec spec)
193         /*@globals fileSystem @*/
194         /*@modifies spec, fileSystem @*/;
195
196 /** \ingroup rpmbuild
197  * @param spec          spec file control structure
198  * @return              NULL always
199  */
200 /*@-declundef@*/
201 extern /*@null@*/ Spec (*freeSpecVec) (Spec spec)       /* XXX FIXME */
202         /*@globals fileSystem @*/
203         /*@modifies spec, fileSystem @*/;
204 /*@=declundef@*/
205
206 /** \ingroup rpmbuild
207  */
208 struct OpenFileInfo * newOpenFileInfo(void)     /*@*/;
209
210 /** \ingroup rpmbuild
211  * @param spec          spec file control structure
212  */
213 spectag stashSt(Spec spec, Header h, int tag, const char * lang)
214         /*@modifies spec->st @*/;
215
216 /** \ingroup rpmbuild
217  * @param spec          spec file control structure
218  */
219 int addSource(Spec spec, Package pkg, const char * field, int tag)
220         /*@globals rpmGlobalMacroContext @*/
221         /*@modifies spec->sources, spec->numSources,
222                 spec->st, spec->macros,
223                 pkg->icon @*/;
224
225 /** \ingroup rpmbuild
226  * @param spec          spec file control structure
227  */
228 int parseNoSource(Spec spec, const char * field, int tag)
229         /*@modifies nothing @*/;
230
231 #ifdef __cplusplus
232 }
233 #endif
234
235 #endif /* _H_SPEC_ */