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