Permit file objects in python header constructor
[platform/upstream/rpm.git] / build / rpmfc.h
1 #ifndef _H_RPMFC_
2 #define _H_RPMFC_
3
4 /** \ingroup rpmfc rpmbuild
5  * \file build/rpmfc.h
6  * Structures and methods for build-time file classification.
7  */
8
9 #include <magic.h>
10
11 #include <rpm/rpmtypes.h>
12 #include <rpm/argv.h>   /* for ARGV_t */
13 #include <rpm/rpmstring.h>      /* for StringBuf */
14 #include <rpm/rpmspec.h>        /* for Package */
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 extern int _rpmfc_debug;
21
22 /** \ingroup rpmfc
23  */
24 typedef struct rpmfc_s * rpmfc;
25
26 /** \ingroup rpmfc
27  */
28 enum FCOLOR_e {
29     RPMFC_BLACK                 = 0,
30     RPMFC_ELF32                 = (1 <<  0),
31     RPMFC_ELF64                 = (1 <<  1),
32     RPMFC_ELFMIPSN32            = (1 <<  2),
33 #define RPMFC_ELF       (RPMFC_ELF32|RPMFC_ELF64|RPMFC_ELFMIPSN32)
34         /* (1 << 3) leaks into package headers, reserved */
35
36         /* bits 4-7 unused */
37     RPMFC_PKGCONFIG             = (1 <<  8),
38     RPMFC_LIBTOOL               = (1 <<  9),
39     RPMFC_BOURNE                = (1 << 10),
40     RPMFC_MONO                  = (1 << 11),
41
42     RPMFC_SCRIPT                = (1 << 12),
43     RPMFC_STATIC                = (1 << 13),
44     RPMFC_NOTSTRIPPED           = (1 << 14),
45         /* bit 15 unused */
46
47         /* bits 16-19 are enumerated, not bits */
48     RPMFC_DIRECTORY             = (1 << 16),
49     RPMFC_SYMLINK               = (2 << 16),
50     RPMFC_DEVICE                = (3 << 16),
51     RPMFC_LIBRARY               = (4 << 16),
52     RPMFC_FONT                  = (5 << 16),
53     RPMFC_IMAGE                 = (6 << 16),
54     RPMFC_MANPAGE               = (7 << 16),
55     RPMFC_TEXT                  = (8 << 16),
56     RPMFC_DOCUMENT              = (9 << 16),
57
58     RPMFC_ARCHIVE               = (1 << 20),
59     RPMFC_COMPRESSED            = (1 << 21),
60     RPMFC_MODULE                = (1 << 22),
61     RPMFC_EXECUTABLE            = (1 << 23),
62
63     RPMFC_PERL                  = (1 << 24),
64     RPMFC_JAVA                  = (1 << 25),
65     RPMFC_PYTHON                = (1 << 26),
66     RPMFC_PHP                   = (1 << 27),
67     RPMFC_TCL                   = (1 << 28),
68
69     RPMFC_WHITE                 = (1 << 29),
70     RPMFC_INCLUDE               = (1 << 30),
71     RPMFC_ERROR                 = (1 << 31)
72 };
73
74 /** \ingroup rpmfc
75  */
76 typedef enum FCOLOR_e FCOLOR_t;
77
78 /** \ingroup rpmfc
79  */
80 typedef const struct rpmfcTokens_s * rpmfcToken;
81
82 /** \ingroup rpmfc
83  * Return helper output.
84  * @param av            helper argv (with possible macros)
85  * @param sb_stdin      helper input
86  * @retval *sb_stdoutp  helper output
87  * @param failnonzero   IS non-zero helper exit status a failure?
88  */
89 int rpmfcExec(ARGV_const_t av, StringBuf sb_stdin, StringBuf * sb_stdoutp,
90                 int failnonzero);
91
92 /** \ingroup rpmfc
93  * Return file color given file(1) string.
94  * @param fmstr         file(1) string
95  * @return              file color
96  */
97 int rpmfcColoring(const char * fmstr);
98
99 /** \ingroup rpmfc
100  * Print results of file classification.
101  * @todo Remove debugging routine.
102  * @param msg           message prefix (NULL for none)
103  * @param fc            file classifier
104  * @param fp            output file handle (NULL for stderr)
105  */
106 void rpmfcPrint(const char * msg, rpmfc fc, FILE * fp);
107
108 /** \ingroup rpmfc
109  * Destroy a file classifier.
110  * @param fc            file classifier
111  * @return              NULL always
112  */
113 rpmfc rpmfcFree(rpmfc fc);
114
115 /** \ingroup rpmfc
116  * Create a file classifier.
117  * @return              new file classifier
118  */
119 rpmfc rpmfcNew(void);
120
121 /** \ingroup rpmfc
122  * Build file class dictionary and mappings.
123  * @param fc            file classifier
124  * @param argv          files to classify
125  * @param fmode         files mode_t array (or NULL)
126  * @return              RPMRC_OK on success
127  */
128 rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode);
129
130 /** \ingroup rpmfc
131  * Build file/package dependency dictionary and mappings.
132  * @param fc            file classifier
133  * @return              RPMRC_OK on success
134  */
135 rpmRC rpmfcApply(rpmfc fc);
136
137 /** \ingroup rpmfc
138  * Generate package dependencies.
139  * @param spec          spec file control
140  * @param pkg           package control
141  * @return              RPMRC_OK on success
142  */
143 rpmRC rpmfcGenerateDepends(const rpmSpec spec, Package pkg);
144
145 /** \ingroup rpmfc
146  * Retrieve file classification provides
147  * @param fc            file classifier
148  * @return              rpmds dependency set of fc provides
149  */
150 rpmds rpmfcProvides(rpmfc fc);
151
152 /** \ingroup rpmfc
153  * Retrieve file classification requires
154  * @param fc            file classifier
155  * @return              rpmds dependency set of fc requires
156  */
157 rpmds rpmfcRequires(rpmfc fc);
158
159 #ifdef __cplusplus
160 }
161 #endif
162
163 #endif /* _H_RPMFC_ */