Make rpmerr.h private, include directly where needed.
[platform/upstream/rpm.git] / build / parseBuildInstallClean.c
1 /** \ingroup rpmbuild
2  * \file build/parseBuildInstallClean.c
3  *  Parse %build/%install/%clean section from spec file.
4  */
5 #include "system.h"
6
7 #include "rpmbuild.h"
8 #include "rpmerr.h"
9 #include "debug.h"
10
11
12 int parseBuildInstallClean(rpmSpec spec, rpmParseState parsePart)
13 {
14     int nextPart, rc;
15     StringBuf *sbp = NULL;
16     const char *name = NULL;
17
18     if (parsePart == PART_BUILD) {
19         sbp = &(spec->build);
20         name = "%build";
21     } else if (parsePart == PART_INSTALL) {
22         sbp = &(spec->install);
23         name = "%install";
24     } else if (parsePart == PART_CHECK) {
25         sbp = &(spec->check);
26         name = "%check";
27     } else if (parsePart == PART_CLEAN) {
28         sbp = &(spec->clean);
29         name = "%clean";
30     }
31     
32     if (*sbp != NULL) {
33         rpmlog(RPMERR_BADSPEC, _("line %d: second %s\n"),
34                 spec->lineNum, name);
35         return RPMERR_BADSPEC;
36     }
37     
38     *sbp = newStringBuf();
39
40     /* There are no options to %build, %install, %check, or %clean */
41     if ((rc = readLine(spec, STRIP_NOTHING)) > 0)
42         return PART_NONE;
43     if (rc)
44         return rc;
45     
46     while (! (nextPart = isPart(spec->line))) {
47         appendStringBuf(*sbp, spec->line);
48         if ((rc = readLine(spec, STRIP_NOTHING)) > 0)
49             return PART_NONE;
50         if (rc)
51             return rc;
52     }
53
54     return nextPart;
55 }