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