9665c975fb886673feedba58721508a759a80b92
[platform/upstream/rpm.git] / build / rpmbuild_misc.h
1 #ifndef _RPMBUILD_MISC_H
2 #define _RPMBUILD_MISC_H
3
4 #include <sys/types.h>
5 #include <rpm/rpmtypes.h>
6 #include <rpm/rpmds.h>
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 /** \ingroup rpmbuild
13  * Truncate comment lines.
14  * @param s             skip white space, truncate line at '#'
15  */
16 RPM_GNUC_INTERNAL
17 void handleComments(char * s);
18
19 /** \ingroup rpmstring
20  */
21 typedef struct StringBufRec *StringBuf;
22
23 /** \ingroup rpmstring
24  */
25 RPM_GNUC_INTERNAL
26 StringBuf newStringBuf(void);
27
28 /** \ingroup rpmstring
29  */
30 RPM_GNUC_INTERNAL
31 StringBuf freeStringBuf( StringBuf sb);
32
33 /** \ingroup rpmstring
34  */
35 RPM_GNUC_INTERNAL
36 const char * getStringBuf(StringBuf sb);
37
38 /** \ingroup rpmstring
39  */
40 RPM_GNUC_INTERNAL
41 void stripTrailingBlanksStringBuf(StringBuf sb);
42
43 /** \ingroup rpmstring
44  */
45 #define appendStringBuf(sb, s)     appendStringBufAux(sb, s, 0)
46
47 /** \ingroup rpmstring
48  */
49 #define appendLineStringBuf(sb, s) appendStringBufAux(sb, s, 1)
50
51 /** \ingroup rpmstring
52  */
53 RPM_GNUC_INTERNAL
54 void appendStringBufAux(StringBuf sb, const char * s, int nl);
55
56 /** \ingroup rpmbuild
57  * Parse an unsigned number.
58  * @param               line from spec file
59  * @retval res          pointer to uint32_t
60  * @return              0 on success, 1 on failure
61  */
62 RPM_GNUC_INTERNAL
63 uint32_t parseUnsignedNum(const char * line, uint32_t * res);
64
65 /** \ingroup rpmbuild
66  * Add dependency to header, filtering duplicates.
67  * @param h             header
68  * @param tagN          tag, identifies type of dependency
69  * @param N             (e.g. Requires: foo < 0:1.2-3, "foo")
70  * @param EVR           (e.g. Requires: foo < 0:1.2-3, "0:1.2-3")
71  * @param Flags         (e.g. Requires: foo < 0:1.2-3, both "Requires:" and "<")
72  * @param index         (0 always)
73  * @return              0 on success, 1 on error
74  */
75 RPM_GNUC_INTERNAL
76 int addReqProv(Header h, rpmTagVal tagN,
77                 const char * N, const char * EVR, rpmsenseFlags Flags,
78                 uint32_t index);
79
80 /** \ingroup rpmbuild
81  * Add rpmlib feature dependency.
82  * @param h             header
83  * @param feature       rpm feature name (i.e. "rpmlib(Foo)" for feature Foo)
84  * @param featureEVR    rpm feature epoch/version/release
85  * @return              0 always
86  */
87 RPM_GNUC_INTERNAL
88 int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR);
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif /* _RPMBUILD_MISC_H */