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