Doxygen annotations for config files.
[tools/librpm-tizen.git] / lib / rpmlib.h
1 #ifndef H_RPMLIB
2 #define H_RPMLIB
3
4 /** \ingroup rpmcli rpmrc rpmdep rpmtrans rpmdb lead signature header payload dbi
5  * \file lib/rpmlib.h
6  *
7  */
8
9 /* This is the *only* module users of rpmlib should need to include */
10
11 /* and it shouldn't need these :-( */
12
13 #include "rpmio.h"
14 #include "rpmmessages.h"
15 #include "rpmerr.h"
16 #include "header.h"
17 #include "popt.h"
18
19 /**
20  * Package read return codes.
21  */
22 typedef enum rpmRC_e {
23     RPMRC_OK            = 0,
24     RPMRC_BADMAGIC      = 1,
25     RPMRC_FAIL          = 2,
26     RPMRC_BADSIZE       = 3,
27     RPMRC_SHORTREAD     = 4,
28 } rpmRC;
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /**
35  * Return package signatures and header from file handle.
36  * @param fd            file handle
37  * @retval signatures   address of signatures pointer (or NULL)
38  * @retval hdr          address of header pointer (or NULL)
39  * @return              rpmRC return code
40  */
41 rpmRC rpmReadPackageInfo(FD_t fd, /*@out@*/ Header * signatures,
42         /*@out@*/ Header * hdr)
43                 /*@modifies fd, *signatures, *hdr @*/;
44
45 /**
46  * Return package header and lead info from file handle.
47  * @param fd            file handle
48  * @retval hdr          address of header (or NULL)
49  * @retval isSource
50  * @retval major
51  * @retval minor
52  * @return              rpmRC return code
53  */
54 rpmRC rpmReadPackageHeader(FD_t fd, /*@out@*/ Header * hdr,
55         /*@out@*/ int * isSource, /*@out@*/ int * major,
56         /*@out@*/ int * minor)
57                 /*@modifies fd, *hdr, *isSource, *major, *minor @*/;
58
59 /** \ingroup header
60  * Return name, version, release strings from header.
61  * @param h             header
62  * @retval np           address of name pointer (or NULL)
63  * @retval vp           address of version pointer (or NULL)
64  * @retval rp           address of release pointer (or NULL)
65  * @return              0 always
66  */
67 int headerNVR(Header h, /*@out@*/ const char **np, /*@out@*/ const char **vp,
68         /*@out@*/ const char **rp) /*@modifies *np, *vp, *rp @*/;
69
70 /** \ingroup header
71  * Translate and merge legacy signature tags into header.
72  * @param h             header
73  * @param sig           signature header
74  */
75 void headerMergeLegacySigs(Header h, const Header sig)
76         /*@modifies h @*/;
77
78 /** \ingroup header
79  * Regenerate signature header.
80  * @param h             header
81  * @return              regenerated signature header
82  */
83 Header headerRegenSigHeader(const Header h)     /*@*/;
84
85 /**
86  * Retrieve file names from header.
87  * The representation of file names in package headers changed in rpm-4.0.
88  * Originally, file names were stored as an array of paths. In rpm-4.0,
89  * file names are stored as separate arrays of dirname's and basename's,
90  * with a dirname index to associate the correct dirname with each basname.
91  * This function is used to retrieve file names independent of how the
92  * file names are represented in the package header.
93  * 
94  * @param h             header
95  * @retval fileListPtr  address of array of file names
96  * @retval fileCountPtr address of number of files
97  */
98 void rpmBuildFileList(Header h, /*@out@*/ const char *** fileListPtr, 
99         /*@out@*/ int * fileCountPtr)
100                 /*@modifies *fileListPtr, *fileCountPtr @*/;
101
102 /**
103  * Retrieve tag info from header.
104  * This is a "dressed" entry to headerGetEntry to do:
105  *      1) DIRNAME/BASENAME/DIRINDICES -> FILENAMES tag conversions.
106  *      2) i18n lookaside (if enabled).
107  *
108  * @param h             header
109  * @param tag           tag
110  * @retval type         address of tag value data type
111  * @retval p            address of pointer to tag value(s)
112  * @retval c            address of number of values
113  * @return              0 on success, 1 on bad magic, 2 on error
114  */
115 int rpmHeaderGetEntry(Header h, int_32 tag, /*@out@*/ int_32 *type,
116         /*@out@*/ void **p, /*@out@*/ int_32 *c)
117                 /*@modifies *type, *p, *c @*/;
118
119 /**
120  * Retrieve tag info from header.
121  * Yet Another "dressed" entry to headerGetEntry in order to unify
122  * signature/header tag retrieval.
123  * @deprecated Signature tags are now duplicated into header when installed.
124  * @todo Eliminate from API.
125  * @param leadp         rpm lead
126  * @param h             header
127  * @param sigs          signatures
128  * @param tag           tag
129  * @retval type         address of tag value data type
130  * @retval p            address of pointer to tag value(s)
131  * @retval c            address of number of values
132  * @return              0 on success, 1 on bad magic, 2 on error
133  */
134 int rpmPackageGetEntry(void *leadp, Header sigs, Header h,
135         int_32 tag, int_32 *type, void **p, int_32 *c)
136                 /*@modifies *type, *p, *c @*/;
137
138 /**
139  * Automatically generated table of tag name/value pairs.
140  */
141 extern const struct headerTagTableEntry rpmTagTable[];
142
143 /**
144  * Number of entries in rpmTagTable.
145  */
146 extern const int rpmTagTableSize;
147
148 /**
149  * Table of query format extensions.
150  * @note Chains to headerDefaultFormats[].
151  */
152 extern const struct headerSprintfExtension rpmHeaderFormats[];
153
154 /**
155  * Pseudo-tags used by the rpmdb iterator API.
156  */
157 #define RPMDBI_PACKAGES         0       /*!< Installed package headers. */
158 #define RPMDBI_DEPENDS          1       /*!< Dependency resolution cache. */
159 #define RPMDBI_LABEL            2       /*!< Fingerprint search marker. */
160 #define RPMDBI_ADDED            3       /*!< Added package headers. */
161 #define RPMDBI_REMOVED          4       /*!< Removed package headers. */
162 #define RPMDBI_AVAILABLE        5       /*!< Available package headers. */
163
164 /**
165  * Tags identify data in package headers.
166  * @note tags should not have value 0!
167  */
168 typedef enum rpmTag_e {
169
170     RPMTAG_HEADERIMAGE          = HEADER_IMAGE,         /*!< Current image. */
171     RPMTAG_HEADERSIGNATURES     = HEADER_SIGNATURES,    /*!< Signatures. */
172     RPMTAG_HEADERIMMUTABLE      = HEADER_IMMUTABLE,     /*!< Original image. */
173     RPMTAG_HEADERREGIONS        = HEADER_REGIONS,       /*!< Regions. */
174
175     RPMTAG_HEADERI18NTABLE      = HEADER_I18NTABLE, /*!< I18N string locales. */
176
177 /* Retrofit (and uniqify) signature tags for use by tagName() and rpmQuery. */
178 /* the md5 sum was broken *twice* on big endian machines */
179 /* XXX 2nd underscore prevents tagTable generation */
180     RPMTAG_SIG_BASE             = HEADER_SIGBASE,
181     RPMTAG_SIGSIZE              = RPMTAG_SIG_BASE+1,
182     RPMTAG_SIGLEMD5_1           = RPMTAG_SIG_BASE+2,
183     RPMTAG_SIGPGP               = RPMTAG_SIG_BASE+3,
184     RPMTAG_SIGLEMD5_2           = RPMTAG_SIG_BASE+4,
185     RPMTAG_SIGMD5               = RPMTAG_SIG_BASE+5,
186     RPMTAG_SIGGPG               = RPMTAG_SIG_BASE+6,
187     RPMTAG_SIGPGP5              = RPMTAG_SIG_BASE+7,    /*!< internal */
188
189     RPMTAG_NAME                 = 1000,
190     RPMTAG_VERSION              = 1001,
191     RPMTAG_RELEASE              = 1002,
192     RPMTAG_EPOCH                = 1003,
193 #define RPMTAG_SERIAL   RPMTAG_EPOCH    /* backward comaptibility */
194     RPMTAG_SUMMARY              = 1004,
195     RPMTAG_DESCRIPTION          = 1005,
196     RPMTAG_BUILDTIME            = 1006,
197     RPMTAG_BUILDHOST            = 1007,
198     RPMTAG_INSTALLTIME          = 1008,
199     RPMTAG_SIZE                 = 1009,
200     RPMTAG_DISTRIBUTION         = 1010,
201     RPMTAG_VENDOR               = 1011,
202     RPMTAG_GIF                  = 1012,
203     RPMTAG_XPM                  = 1013,
204     RPMTAG_LICENSE              = 1014,
205 #define RPMTAG_COPYRIGHT RPMTAG_LICENSE /* backward comaptibility */
206     RPMTAG_PACKAGER             = 1015,
207     RPMTAG_GROUP                = 1016,
208     RPMTAG_CHANGELOG            = 1017, /*!< internal */
209     RPMTAG_SOURCE               = 1018,
210     RPMTAG_PATCH                = 1019,
211     RPMTAG_URL                  = 1020,
212     RPMTAG_OS                   = 1021,
213     RPMTAG_ARCH                 = 1022,
214     RPMTAG_PREIN                = 1023,
215     RPMTAG_POSTIN               = 1024,
216     RPMTAG_PREUN                = 1025,
217     RPMTAG_POSTUN               = 1026,
218     RPMTAG_OLDFILENAMES         = 1027, /* obsolete */
219     RPMTAG_FILESIZES            = 1028,
220     RPMTAG_FILESTATES           = 1029,
221     RPMTAG_FILEMODES            = 1030,
222     RPMTAG_FILEUIDS             = 1031, /*!< internal */
223     RPMTAG_FILEGIDS             = 1032, /*!< internal */
224     RPMTAG_FILERDEVS            = 1033,
225     RPMTAG_FILEMTIMES           = 1034,
226     RPMTAG_FILEMD5S             = 1035,
227     RPMTAG_FILELINKTOS          = 1036,
228     RPMTAG_FILEFLAGS            = 1037,
229     RPMTAG_ROOT                 = 1038, /*!< obsolete */
230     RPMTAG_FILEUSERNAME         = 1039,
231     RPMTAG_FILEGROUPNAME        = 1040,
232     RPMTAG_EXCLUDE              = 1041, /*!< internal - deprecated */
233     RPMTAG_EXCLUSIVE            = 1042, /*!< internal - deprecated */
234     RPMTAG_ICON                 = 1043,
235     RPMTAG_SOURCERPM            = 1044,
236     RPMTAG_FILEVERIFYFLAGS      = 1045,
237     RPMTAG_ARCHIVESIZE          = 1046,
238     RPMTAG_PROVIDENAME          = 1047,
239 #define RPMTAG_PROVIDES RPMTAG_PROVIDENAME      /* backward comaptibility */
240     RPMTAG_REQUIREFLAGS         = 1048,
241     RPMTAG_REQUIRENAME          = 1049,
242     RPMTAG_REQUIREVERSION       = 1050,
243     RPMTAG_NOSOURCE             = 1051, /*!< internal */
244     RPMTAG_NOPATCH              = 1052, /*!< internal */
245     RPMTAG_CONFLICTFLAGS        = 1053,
246     RPMTAG_CONFLICTNAME         = 1054,
247     RPMTAG_CONFLICTVERSION      = 1055,
248     RPMTAG_DEFAULTPREFIX        = 1056, /*!< internal - deprecated */
249     RPMTAG_BUILDROOT            = 1057,
250     RPMTAG_INSTALLPREFIX        = 1058, /*!< internal - deprecated */
251     RPMTAG_EXCLUDEARCH          = 1059,
252     RPMTAG_EXCLUDEOS            = 1060,
253     RPMTAG_EXCLUSIVEARCH        = 1061,
254     RPMTAG_EXCLUSIVEOS          = 1062,
255     RPMTAG_AUTOREQPROV          = 1063, /*!< internal */
256     RPMTAG_RPMVERSION           = 1064,
257     RPMTAG_TRIGGERSCRIPTS       = 1065,
258     RPMTAG_TRIGGERNAME          = 1066,
259     RPMTAG_TRIGGERVERSION       = 1067,
260     RPMTAG_TRIGGERFLAGS         = 1068,
261     RPMTAG_TRIGGERINDEX         = 1069,
262     RPMTAG_VERIFYSCRIPT         = 1079,
263     RPMTAG_CHANGELOGTIME        = 1080,
264     RPMTAG_CHANGELOGNAME        = 1081,
265     RPMTAG_CHANGELOGTEXT        = 1082,
266     RPMTAG_BROKENMD5            = 1083, /*!< internal */
267     RPMTAG_PREREQ               = 1084, /*!< internal */
268     RPMTAG_PREINPROG            = 1085,
269     RPMTAG_POSTINPROG           = 1086,
270     RPMTAG_PREUNPROG            = 1087,
271     RPMTAG_POSTUNPROG           = 1088,
272     RPMTAG_BUILDARCHS           = 1089,
273     RPMTAG_OBSOLETENAME         = 1090,
274 #define RPMTAG_OBSOLETES RPMTAG_OBSOLETENAME    /* backward comaptibility */
275     RPMTAG_VERIFYSCRIPTPROG     = 1091,
276     RPMTAG_TRIGGERSCRIPTPROG    = 1092,
277     RPMTAG_DOCDIR               = 1093, /*!< internal */
278     RPMTAG_COOKIE               = 1094,
279     RPMTAG_FILEDEVICES          = 1095,
280     RPMTAG_FILEINODES           = 1096,
281     RPMTAG_FILELANGS            = 1097,
282     RPMTAG_PREFIXES             = 1098,
283     RPMTAG_INSTPREFIXES         = 1099,
284     RPMTAG_TRIGGERIN            = 1100, /*!< internal */
285     RPMTAG_TRIGGERUN            = 1101, /*!< internal */
286     RPMTAG_TRIGGERPOSTUN        = 1102, /*!< internal */
287     RPMTAG_AUTOREQ              = 1103, /*!< internal */
288     RPMTAG_AUTOPROV             = 1104, /*!< internal */
289     RPMTAG_CAPABILITY           = 1105, /*!< internal obsolete */
290     RPMTAG_SOURCEPACKAGE        = 1106, /*!< internal */
291     RPMTAG_OLDORIGFILENAMES     = 1107, /*!< obsolete */
292     RPMTAG_BUILDPREREQ          = 1108, /*!< internal */
293     RPMTAG_BUILDREQUIRES        = 1109, /*!< internal */
294     RPMTAG_BUILDCONFLICTS       = 1110, /*!< internal */
295     RPMTAG_BUILDMACROS          = 1111,
296     RPMTAG_PROVIDEFLAGS         = 1112,
297     RPMTAG_PROVIDEVERSION       = 1113,
298     RPMTAG_OBSOLETEFLAGS        = 1114,
299     RPMTAG_OBSOLETEVERSION      = 1115,
300     RPMTAG_DIRINDEXES           = 1116,
301     RPMTAG_BASENAMES            = 1117,
302     RPMTAG_DIRNAMES             = 1118,
303     RPMTAG_ORIGDIRINDEXES       = 1119, /*!< internal */
304     RPMTAG_ORIGBASENAMES        = 1120, /*!< internal */
305     RPMTAG_ORIGDIRNAMES         = 1121, /*!< internal */
306     RPMTAG_OPTFLAGS             = 1122,
307     RPMTAG_DISTURL              = 1123,
308     RPMTAG_PAYLOADFORMAT        = 1124,
309     RPMTAG_PAYLOADCOMPRESSOR    = 1125,
310     RPMTAG_PAYLOADFLAGS         = 1126,
311     RPMTAG_MULTILIBS            = 1127,
312     RPMTAG_INSTALLTID           = 1128,
313     RPMTAG_REMOVETID            = 1129,
314     RPMTAG_FIRSTFREE_TAG        /*!< internal */
315 } rpmTag;
316
317 #define RPMTAG_EXTERNAL_TAG             1000000
318
319 /**
320  * File States (when installed).
321  */
322 typedef enum rpmfileStates_e {
323     RPMFILE_STATE_NORMAL        = 0,
324     RPMFILE_STATE_REPLACED      = 1,
325     RPMFILE_STATE_NOTINSTALLED  = 2,
326     RPMFILE_STATE_NETSHARED     = 3
327 } rpmfileStates;
328
329 /**
330  * File Attributes.
331  */
332 typedef enum rpmfileAttrs_e {
333     RPMFILE_CONFIG      = (1 << 0),     /*!< from %%config */
334     RPMFILE_DOC         = (1 << 1),     /*!< from %%doc */
335     RPMFILE_DONOTUSE    = (1 << 2),     /*!< @todo (unimplemented) from %donotuse. */
336     RPMFILE_MISSINGOK   = (1 << 3),     /*!< from %%config(missingok) */
337     RPMFILE_NOREPLACE   = (1 << 4),     /*!< from %%config(noreplace) */
338     RPMFILE_SPECFILE    = (1 << 5),     /*!< @todo (unnecessary) marks 1st file in srpm. */
339     RPMFILE_GHOST       = (1 << 6),     /*!< from %%ghost */
340     RPMFILE_LICENSE     = (1 << 7),     /*!< from %%license */
341     RPMFILE_README      = (1 << 8),     /*!< from %%readme */
342     RPMFILE_EXCLUDE     = (1 << 9)      /*!< from %%exclude */
343 } rpmfileAttrs;
344 #define RPMFILE_MULTILIB_SHIFT          9
345 #define RPMFILE_MULTILIB(N)             ((N) << RPMFILE_MULTILIB_SHIFT)
346 #define RPMFILE_MULTILIB_MASK           RPMFILE_MULTILIB(7)
347
348 /* XXX Check file flags for multilib marker. */
349 #define isFileMULTILIB(_fflags)         ((_fflags) & RPMFILE_MULTILIB_MASK)
350
351 /**
352  * Dependency Attributes.
353  */
354 typedef enum rpmsenseFlags_e {
355     RPMSENSE_ANY        = 0,
356     RPMSENSE_SERIAL     = (1 << 0),     /*!< @todo Legacy. */
357     RPMSENSE_LESS       = (1 << 1),
358     RPMSENSE_GREATER    = (1 << 2),
359     RPMSENSE_EQUAL      = (1 << 3),
360     RPMSENSE_PROVIDES   = (1 << 4), /* only used internally by builds */
361     RPMSENSE_CONFLICTS  = (1 << 5), /* only used internally by builds */
362     RPMSENSE_PREREQ     = (1 << 6),     /*!< @todo Legacy. */
363     RPMSENSE_OBSOLETES  = (1 << 7), /* only used internally by builds */
364     RPMSENSE_INTERP     = (1 << 8),     /*!< Interpreter used by scriptlet. */
365     RPMSENSE_SCRIPT_PRE = ((1 << 9)|RPMSENSE_PREREQ), /*!< %pre dependency. */
366     RPMSENSE_SCRIPT_POST = ((1 << 10)|RPMSENSE_PREREQ), /*!< %post dependency. */
367     RPMSENSE_SCRIPT_PREUN = ((1 << 11)|RPMSENSE_PREREQ), /*!< %preun dependency. */
368     RPMSENSE_SCRIPT_POSTUN = ((1 << 12)|RPMSENSE_PREREQ), /*!< %postun dependency. */
369     RPMSENSE_SCRIPT_VERIFY = (1 << 13), /*!< %verify dependency. */
370     RPMSENSE_FIND_REQUIRES = (1 << 14), /*!< find-requires generated dependency. */
371     RPMSENSE_FIND_PROVIDES = (1 << 15), /*!< find-provides generated dependency. */
372
373     RPMSENSE_TRIGGERIN  = (1 << 16),    /*!< %triggerin dependency. */
374     RPMSENSE_TRIGGERUN  = (1 << 17),    /*!< %triggerun dependency. */
375     RPMSENSE_TRIGGERPOSTUN = (1 << 18), /*!< %triggerpostun dependency. */
376     RPMSENSE_MULTILIB   = (1 << 19),
377     RPMSENSE_SCRIPT_PREP = (1 << 20),   /*!< %prep build dependency. */
378     RPMSENSE_SCRIPT_BUILD = (1 << 21),  /*!< %build build dependency. */
379     RPMSENSE_SCRIPT_INSTALL = (1 << 22),/*!< %install build dependency. */
380     RPMSENSE_SCRIPT_CLEAN = (1 << 23),  /*!< %clean build dependency. */
381     RPMSENSE_RPMLIB     = ((1 << 24) | RPMSENSE_PREREQ), /*!< rpmlib(feature) dependency. */
382     RPMSENSE_TRIGGERPREIN = (1 << 25)   /*!< @todo Implement %triggerprein. */
383
384 } rpmsenseFlags;
385
386 #define RPMSENSE_SENSEMASK      15       /* Mask to get senses, ie serial, */
387                                          /* less, greater, equal.          */
388
389 #define RPMSENSE_TRIGGER        \
390         (RPMSENSE_TRIGGERIN | RPMSENSE_TRIGGERUN | RPMSENSE_TRIGGERPOSTUN)
391
392 #define isDependsMULTILIB(_dflags)      ((_dflags) & RPMSENSE_MULTILIB)
393
394 #define _ALL_REQUIRES_MASK      (\
395     RPMSENSE_INTERP | \
396     RPMSENSE_SCRIPT_PRE | \
397     RPMSENSE_SCRIPT_POST | \
398     RPMSENSE_SCRIPT_PREUN | \
399     RPMSENSE_SCRIPT_POSTUN | \
400     RPMSENSE_SCRIPT_VERIFY | \
401     RPMSENSE_FIND_REQUIRES | \
402     RPMSENSE_SCRIPT_PREP | \
403     RPMSENSE_SCRIPT_BUILD | \
404     RPMSENSE_SCRIPT_INSTALL | \
405     RPMSENSE_SCRIPT_CLEAN | \
406     RPMSENSE_RPMLIB )
407
408 #define _notpre(_x)             ((_x) & ~RPMSENSE_PREREQ)
409 #define _INSTALL_ONLY_MASK \
410     _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB)
411 #define _ERASE_ONLY_MASK  \
412     _notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
413
414 #define isLegacyPreReq(_x)  (((_x) & _ALL_REQUIRES_MASK) == RPMSENSE_PREREQ)
415 #define isInstallPreReq(_x)     ((_x) & _INSTALL_ONLY_MASK)
416 #define isErasePreReq(_x)       ((_x) & _ERASE_ONLY_MASK)
417
418 /* ==================================================================== */
419 /** \name RPMRC */
420 /*@{*/
421
422 /* Stuff for maintaining "variables" like SOURCEDIR, BUILDDIR, etc */
423 #define RPMVAR_OPTFLAGS                 3
424 #define RPMVAR_PROVIDES                 38
425 #define RPMVAR_INCLUDE                  43
426 #define RPMVAR_MACROFILES               49
427
428 #define RPMVAR_NUM                      55      /* number of RPMVAR entries */
429
430 /** \ingroup rpmrc
431  * Return value of an rpmrc variable.
432  * @deprecated Use rpmExpand() with appropriate macro expression.
433  * @todo Eliminate from API.
434  */
435 const char * rpmGetVar(int var);
436
437 /** \ingroup rpmrc
438  * Set value of an rpmrc variable.
439  * @deprecated Use rpmDefineMacro() to change appropriate macro instead.
440  * @todo Eliminate from API.
441  */
442 void rpmSetVar(int var, const char *val);
443
444 /** \ingroup rpmrc
445  * List of macro files to read when configuring rpm.
446  * This is a colon separated list of files. URI's are permitted as well,
447  * identified by the token '://', so file paths must not begin with '//'.
448  */
449 extern const char * macrofiles;
450
451 /** \ingroup rpmrc
452  * Build and install arch/os table identifiers.
453  * @todo Eliminate from API.
454  */
455 enum rpm_machtable_e {
456     RPM_MACHTABLE_INSTARCH      = 0,    /*!< Install platform architecture. */
457     RPM_MACHTABLE_INSTOS        = 1,    /*!< Install platform operating system. */
458     RPM_MACHTABLE_BUILDARCH     = 2,    /*!< Build platform architecture. */
459     RPM_MACHTABLE_BUILDOS       = 3     /*!< Build platform operating system. */
460 };
461 #define RPM_MACHTABLE_COUNT     4       /*!< No. of arch/os tables. */
462
463 /** \ingroup rpmrc
464  * Read macro configuration file(s) for a target.
465  * @param file          colon separated files to read (NULL uses default)
466  * @param target        target platform (NULL uses default)
467  * @return              0 on success, -1 on error
468  */
469 int rpmReadConfigFiles(const char * file, const char * target);
470
471 /** \ingroup rpmrc
472  * Read rpmrc (and macro) configuration file(s).
473  * @param file          colon separated files to read (NULL uses default)
474  * @return              0 on succes
475  */
476 int rpmReadRC(const char * file);
477
478 /** \ingroup rpmrc
479  * Return current arch name and/or number.
480  * @todo Generalize to extract arch component from target_platform macro.
481  * @retval name         address of arch name (or NULL)
482  * @retval num          address of arch number (or NULL)
483  */
484 void rpmGetArchInfo( /*@out@*/ const char ** name, /*@out@*/ int * num);
485
486 /** \ingroup rpmrc
487  * Return current os name and/or number.
488  * @todo Generalize to extract os component from target_platform macro.
489  * @retval name         address of os name (or NULL)
490  * @retval num          address of os number (or NULL)
491  */
492 void rpmGetOsInfo( /*@out@*/ const char ** name, /*@out@*/ int * num);
493
494 /** \ingroup rpmrc
495  * Return arch/os score of a name.
496  * An arch/os score measures the "nearness" of a name to the currently
497  * running (or defined) platform arch/os. For example, the score of arch
498  * "i586" on an i686 platform is (usually) 2. The arch/os score is used
499  * to select one of several otherwise identical packages using the arch/os
500  * tags from the header as hints of the intended platform for the package.
501  * @todo Rewrite to use RE's against config.guess target platform output.
502  *
503  * @param type          any of the RPM_MACHTABLE_* constants
504  * @param name          name
505  * @return              arch score (0 is no match, lower is preferred)
506  */
507 int rpmMachineScore(int type, const char * name);
508
509 /** \ingroup rpmrc
510  * Display current rpmrc (and macro) configuration.
511  * @param f             output file handle
512  * @return              0 always
513  */
514 int rpmShowRC(FILE *f);
515
516 /** \ingroup rpmrc
517  * @deprecated Use addMacro to set _target_* macros.
518  * @todo Eliminate from API.
519  * @param archTable
520  * @param osTable
521  */
522 void rpmSetTables(int archTable, int osTable);  /* only used by build code */
523
524 /** \ingroup rpmrc
525  * Set current arch/os names.
526  * NULL as argument is set to the default value (munged uname())
527  * pushed through a translation table (if appropriate).
528  * @deprecated Use addMacro to set _target_* macros.
529  * @todo Eliminate from API.
530  *
531  * @param arch          arch name (or NULL)
532  * @param os            os name (or NULL)
533  */
534 void rpmSetMachine(const char * arch, const char * os);
535
536 /** \ingroup rpmrc
537  * Return current arch/os names.
538  * @deprecated Use rpmExpand on _target_* macros.
539  * @todo Eliminate from API.
540  *
541  * @retval arch         address of arch name (or NULL)
542  * @retval os           address of os name (or NULL)
543  */
544 void rpmGetMachine( /*@out@*/ const char **arch, /*@out@*/ const char **os);
545
546 /** \ingroup rpmrc
547  * Destroy rpmrc arch/os compatibility tables.
548  * @todo Eliminate from API.
549  */
550 void rpmFreeRpmrc(void);
551
552 /*@}*/
553 /* ==================================================================== */
554 /** \name RPMDB */
555 /*@{*/
556 /** \ingroup rpmdb
557  */
558 typedef /*@abstract@*/ struct rpmdb_s * rpmdb;
559
560 /** \ingroup rpmdb
561  */
562 typedef /*@abstract@*/ struct _dbiIndexSet * dbiIndexSet;
563
564 /** \ingroup rpmdb
565  * Open rpm database.
566  * @param root          path to top of install tree
567  * @retval dbp          address of rpm database
568  * @param mode          open(2) flags:  O_RDWR or O_RDONLY (O_CREAT also)
569  * @param perms         database permissions
570  * @return              0 on success
571  */
572 int rpmdbOpen (const char * root, /*@out@*/ rpmdb * dbp, int mode, int perms);
573
574 /** \ingroup rpmdb
575  * Initialize database.
576  * @param root          path to top of install tree
577  * @param perms         database permissions
578  * @return              0 on success
579  */
580 int rpmdbInit(const char * root, int perms);
581
582 /** \ingroup rpmdb
583  * Close all database indices and free rpmdb.
584  * @param rpmdb         rpm database
585  * @return              0 always
586  */
587 int rpmdbClose ( /*@only@*/ rpmdb rpmdb);
588
589 /** \ingroup rpmdb
590  * Sync all database indices.
591  * @param rpmdb         rpm database
592  * @return              0 always
593  */
594 int rpmdbSync (rpmdb rpmdb);
595
596 /** \ingroup rpmdb
597  * Open all database indices.
598  * @param rpmdb         rpm database
599  * @return              0 always
600  */
601 int rpmdbOpenAll (rpmdb rpmdb);
602
603 /** \ingroup rpmdb
604  * Return number of instances of package in rpm database.
605  * @param db            rpm database
606  * @param name          rpm package name
607  * @return              number of instances
608  */
609 int rpmdbCountPackages(rpmdb db, const char *name);
610
611 /** \ingroup rpmdb
612  */
613 typedef /*@abstract@*/ struct _rpmdbMatchIterator * rpmdbMatchIterator;
614
615 /** \ingroup rpmdb
616  * Destroy rpm database iterator.
617  * @param mi            rpm database iterator
618  */
619 void rpmdbFreeIterator( /*@only@*/ rpmdbMatchIterator mi);
620
621 /** \ingroup rpmdb
622  * Return rpm database used by iterator.
623  * @param mi            rpm database iterator
624  * @return              rpm database handle
625  */
626 /*@kept@*/ rpmdb rpmdbGetIteratorRpmDB(rpmdbMatchIterator mi)   /*@*/;
627
628 /** \ingroup rpmdb
629  * Return join key for current position of rpm database iterator.
630  * @param mi            rpm database iterator
631  * @return              current join key
632  */
633 unsigned int rpmdbGetIteratorOffset(rpmdbMatchIterator mi)      /*@*/;
634
635 /** \ingroup rpmdb
636  * Return number of elements in rpm database iterator.
637  * @param mi            rpm database iterator
638  * @return              number of elements
639  */
640 int rpmdbGetIteratorCount(rpmdbMatchIterator mi)        /*@*/;
641
642 /** \ingroup rpmdb
643  * Append items to set of package instances to iterate.
644  * @param mi            rpm database iterator
645  * @param hdrNums       array of package instances
646  * @param nHdrNums      number of elements in array
647  * @return              0 on success, 1 on failure (bad args)
648  */
649 int rpmdbAppendIterator(rpmdbMatchIterator mi, const int * hdrNums,
650         int nHdrNums)
651                 /*@modifies mi @*/;
652
653 /** \ingroup rpmdb
654  * Remove items from set of package instances to iterate.
655  * @param mi            rpm database iterator
656  * @param hdrNums       array of package instances
657  * @param nHdrNums      number of elements in array
658  * @param sorted        is the array sorted? (array will be sorted on return)
659  * @return              0 on success, 1 on failure (bad args)
660  */
661 int rpmdbPruneIterator(rpmdbMatchIterator mi, int * hdrNums,
662         int nHdrNums, int sorted)
663                 /*@modifies mi @*/;
664
665 /** \ingroup rpmdb
666  * Modify iterator to filter out headers that do not match version.
667  * @todo Replace with a more general mechanism using RE's on tag content.
668  * @param mi            rpm database iterator
669  * @param version       version to check for
670  */
671 void rpmdbSetIteratorVersion(rpmdbMatchIterator mi, const char * version)
672                 /*@modifies mi @*/;
673
674 /** \ingroup rpmdb
675  * Modify iterator to filter out headers that do not match release.
676  * @todo Replace with a more general mechanism using RE's on tag content.
677  * @param mi            rpm database iterator
678  * @param release       release to check for
679  */
680 void rpmdbSetIteratorRelease(rpmdbMatchIterator mi, const char * release)
681                 /*@modifies mi @*/;
682
683 /** \ingroup rpmdb
684  * Modify iterator to mark header for lazy write.
685  * @param mi            rpm database iterator
686  * @param modified      new value of modified
687  * @return              previous value
688  */
689 int rpmdbSetIteratorModified(rpmdbMatchIterator mi, int modified)
690                 /*@modifies mi @*/;
691
692 /** \ingroup rpmdb
693  * Return next package header from iteration.
694  * @param mi            rpm database iterator
695  * @return              NULL on end of iteration.
696  */
697 Header rpmdbNextIterator(rpmdbMatchIterator mi)
698                 /*@modifies mi @*/;
699 #define rpmdbNextIterator(_a) \
700         XrpmdbNextIterator(_a, __FILE__, __LINE__)
701 Header XrpmdbNextIterator(rpmdbMatchIterator mi, const char * f, unsigned int l)
702                 /*@modifies mi @*/;
703
704 /** \ingroup rpmdb
705  * Return database iterator.
706  * @param rpmdb         rpm database
707  * @param rpmtag        rpm tag
708  * @param keyp          key data (NULL for sequential access)
709  * @param keylen        key data length (0 will use strlen(keyp))
710  * @return              NULL on failure
711  */
712 /*@only@*/ /*@null@*/ rpmdbMatchIterator rpmdbInitIterator(
713                         /*@kept@*/ rpmdb rpmdb, int rpmtag,
714                         const void * key, size_t keylen);
715
716 /** \ingroup rpmdb
717  * Add package header to rpm database and indices.
718  * @param rpmdb         rpm database
719  * @param iid           install transaction id (or -1 to skip)
720  * @param h             header
721  * @return              0 on success
722  */
723 int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
724         /*@modifies h @*/;
725
726 /** \ingroup rpmdb
727  * Remove package header from rpm database and indices.
728  * @param rpmdb         rpm database
729  * @param rid           remove transaction id (or -1 to skip)
730  * @param offset        location in Packages dbi
731  * @return              0 on success
732  */
733 int rpmdbRemove(rpmdb db, int rid, unsigned int offset);
734
735 /** \ingroup rpmdb
736  * Rebuild database indices from package headers.
737  * @param root          path to top of install tree
738  */
739 int rpmdbRebuild(const char * root);
740
741 /*@}*/
742 /* ==================================================================== */
743 /** \name RPMPROBS */
744 /*@{*/
745
746 /**
747  * Enumerate transaction set problem types.
748  */
749 typedef enum rpmProblemType_e {
750     RPMPROB_BADARCH,    /*!< package ... is for a different architecture */
751     RPMPROB_BADOS,      /*!< package ... is for a different operating system */
752     RPMPROB_PKG_INSTALLED, /*!< package ... is already installed */
753     RPMPROB_BADRELOCATE,/*!< path ... is not relocateable for package ... */
754     RPMPROB_REQUIRES,   /*!< @todo Use for dependency errors. */
755     RPMPROB_CONFLICT,   /*!< @todo Use for dependency errors. */
756     RPMPROB_NEW_FILE_CONFLICT, /*!< file ... conflicts between attemped installs of ... */
757     RPMPROB_FILE_CONFLICT,/*!< file ... from install of ... conflicts with file from package ... */
758     RPMPROB_OLDPACKAGE, /*!< package ... (which is newer than ...) is already installed */
759     RPMPROB_DISKSPACE,  /*!< installing package ... needs ... on the ...  filesystem */
760     RPMPROB_DISKNODES,  /*!< installing package ... needs ... on the ...  filesystem */
761     RPMPROB_BADPRETRANS /*!< (unimplemented) */
762  } rpmProblemType;
763
764 /**
765  */
766 typedef /*@abstract@*/ struct rpmProblem_s {
767 /*@only@*/ /*@null@*/ const char * pkgNEVR;
768 /*@only@*/ /*@null@*/ const char * altNEVR;
769 /*@kept@*/ const void * key;
770     Header h;
771     rpmProblemType type;
772     int ignoreProblem;
773 /*@only@*/ const char * str1;
774     unsigned long ulong1;
775 } * rpmProblem;
776
777 /**
778  */
779 typedef /*@abstract@*/ struct rpmProblemSet_s {
780     int numProblems;            /*!< Current probs array size. */
781     int numProblemsAlloced;     /*!< Allocated probs array size. */
782     rpmProblem probs;           /*!< Array of specific problems. */
783 } * rpmProblemSet;
784
785 /**
786  */
787 void printDepFlags(FILE *fp, const char *version, int flags)
788         /*@modifies *fp @*/;
789
790 /**
791  */
792 struct rpmDependencyConflict {
793     const char * byName;
794     const char * byVersion;
795     const char * byRelease;
796     Header byHeader;
797     /* these needs fields are misnamed -- they are used for the package
798        which isn't needed as well */
799     const char * needsName;
800     const char * needsVersion;
801     int needsFlags;
802 /*@observer@*/ /*@null@*/ const void * suggestedPackage; /* NULL if none */
803     enum {
804         RPMDEP_SENSE_REQUIRES,          /*!< requirement not satisfied. */
805         RPMDEP_SENSE_CONFLICTS          /*!< conflict was found. */
806     } sense;
807 } ;
808
809 /**
810  */
811 void printDepProblems(FILE *fp, struct rpmDependencyConflict *conflicts,
812         int numConflicts)       /*@modifies *fp @*/;
813
814 /**
815  * Return formatted string representation of problem.
816  * @deprecated API: prob used to be passed by value, now passed by reference.
817  * @param prob          rpm problem
818  * @return              formatted string
819  */
820 /*@only@*/ const char * rpmProblemString(rpmProblem prob) /*@modifies prob @*/;
821
822 /**
823  * Output formatted string representation of problem to file handle.
824  * @deprecated API: prob used to be passed by value, now passed by reference.
825  * @param fp            file handle
826  * @param prob          rpm problem
827  */
828 void rpmProblemPrint(FILE *fp, rpmProblem prob) /*@modifies *fp, prob @*/;
829
830 /**
831  * Print problems to file handle.
832  * @param fp            file handle
833  * @param probs         problem set
834  */
835 void rpmProblemSetPrint(FILE *fp, rpmProblemSet probs)
836                 /*@modifies *fp, probs @*/;
837
838 /**
839  * Destroy problem set.
840  * @param probs         problem set
841  */
842 void rpmProblemSetFree( /*@only@*/ rpmProblemSet probs);
843
844 /*@}*/
845 /* ==================================================================== */
846 /** \name RPMTS */
847 /*@{*/
848 /**
849  * Prototype for headerFreeData() vector.
850  */
851 typedef /*@null@*/
852     void * (*HFD_t) (/*@only@*/ /*@null@*/ const void * data, rpmTagType type);
853
854 /**
855  * Prototype for headerGetEntry() vector.
856  */
857 typedef int (*HGE_t) (Header h, int_32 tag, /*@out@*/ int_32 * type,
858                         /*@out@*/ void ** p, /*@out@*/int_32 * c)
859                                 /*@modifies *type, *p, *c @*/;
860
861 /* we pass these around as an array with a sentinel */
862 typedef struct rpmRelocation_s {
863     const char * oldPath;       /*!< NULL here evals to RPMTAG_DEFAULTPREFIX, */
864     const char * newPath;       /*!< NULL means to omit the file completely! */
865 } rpmRelocation;
866
867 /**
868  * Install source package.
869  * @param root          path to top of install tree
870  * @param fd            file handle
871  * @retval specFile     address of spec file name
872  * @param notify        progress callback
873  * @param notifyData    progress callback private data
874  * @retval cooke        address of cookie pointer
875  * @return              rpmRC return code
876  */
877 rpmRC rpmInstallSourcePackage(const char * root, FD_t fd,
878                         /*@out@*/ const char ** specFile,
879                         rpmCallbackFunction notify, rpmCallbackData notifyData,
880                         /*@out@*/ char ** cookie)
881         /*@modifies *specFile, *cookie @*/;
882
883 /**
884  * Compare headers to determine which header is "newer".
885  * @param first         1st header
886  * @param second        2nd header
887  * @return              result of comparison
888  */
889 int rpmVersionCompare(Header first, Header second);
890
891 /**
892  * File disposition(s) during package install/erase transaction.
893  */
894 typedef enum fileAction_e {
895     FA_UNKNOWN = 0,     /*!< initial action for file ... */
896     FA_CREATE,          /*!< ... copy in from payload. */
897     FA_COPYIN,          /*!< ... copy in from payload. */
898     FA_COPYOUT,         /*!< ... copy out to payload. */
899     FA_BACKUP,          /*!< ... renamed with ".rpmorig" extension. */
900     FA_SAVE,            /*!< ... renamed with ".rpmsave" extension. */
901     FA_SKIP,            /*!< ... already replaced, don't remove. */
902     FA_ALTNAME,         /*!< ... create with ".rpmnew" extension. */
903     FA_ERASE,           /*!< ... to be removed. */
904     FA_SKIPNSTATE,      /*!< ... untouched, state "not installed". */
905     FA_SKIPNETSHARED,   /*!< ... untouched, state "netshared". */
906     FA_SKIPMULTILIB,    /*!< ... untouched. @todo state "multilib" ???. */
907 } fileAction;
908
909 #define XFA_SKIPPING(_a)        \
910     ((_a) == FA_SKIP || (_a) == FA_SKIPNSTATE || (_a) == FA_SKIPNETSHARED || (_a) == FA_SKIPMULTILIB)
911
912 /**
913  * File types.
914  * These are the types of files used internally by rpm. The file
915  * type is determined by applying stat(2) macros like S_ISDIR to
916  * the file mode tag from a header. The values are arbitrary,
917  * but are identical to the linux stat(2) file types.
918  */
919 typedef enum fileTypes_e {
920     PIPE        =  1,   /*!< pipe/fifo */
921     CDEV        =  2,   /*!< character device */
922     XDIR        =  4,   /*!< directory */
923     BDEV        =  6,   /*!< block device */
924     REG         =  8,   /*!< regular file */
925     LINK        = 10,   /*!< hard link */
926     SOCK        = 12,   /*!< socket */
927 } fileTypes;
928
929 /** \ingroup payload
930  * Iterator across package file info, forward on install, backward on erase.
931  */
932 typedef /*@abstract@*/ struct fsmIterator_s * FSMI_t;
933
934 /** \ingroup payload
935  * File state machine data.
936  */
937 typedef /*@abstract@*/ struct fsm_s * FSM_t;
938
939 /** \ingroup rpmtrans
940  * Package state machine data.
941  */
942 typedef /*@abstract@*/ struct psm_s * PSM_t;
943
944 /** \ingroup rpmtrans
945  */
946 typedef /*@abstract@*/ struct transactionFileInfo_s * TFI_t;
947
948 /** \ingroup rpmtrans
949  * The RPM Transaction Set.
950  * Transaction sets are inherently unordered! RPM may reorder transaction
951  * sets to reduce errors. In general, installs/upgrades are done before
952  * strict removals, and prerequisite ordering is done on installs/upgrades.
953  */
954 typedef /*@abstract@*/ struct rpmTransactionSet_s * rpmTransactionSet;
955
956 /** \ingroup rpmtrans
957  * Create an empty transaction set.
958  * @param rpmdb         rpm database (may be NULL if database is not accessed)
959  * @param rootdir       path to top of install tree
960  * @return              transaction set
961  */
962 /*@only@*/ rpmTransactionSet rpmtransCreateSet(rpmdb rpmdb,
963         const char * rootdir);
964
965 /** \ingroup rpmtrans
966  * Add package to be installed to unordered transaction set.
967  *
968  * If fd is NULL, the callback specified in rpmtransCreateSet() is used to
969  * open and close the file descriptor. If Header is NULL, the fd is always
970  * used, otherwise fd is only needed (and only opened) for actual package 
971  * installation.
972  *
973  * @param ts            transaction set
974  * @param h             package header
975  * @param fd            package file handle
976  * @param key           package private data
977  * @param update        is package being upgraded?
978  * @param relocs        package file relocations
979  * @return              0 on success, 1 on I/O error, 2 needs capabilities
980  */
981 int rpmtransAddPackage(rpmTransactionSet ts, Header h, FD_t fd,
982                 /*@owned@*/ const void * key, int update,
983                 rpmRelocation * relocs);
984
985 /** \ingroup rpmtrans
986  * Add package to universe of possible packages to install in transaction set.
987  * @param ts            transaction set
988  * @param h             header
989  * @param key           package private data
990  */
991 void rpmtransAvailablePackage(rpmTransactionSet ts, Header h,
992                 /*@owned@*/ const void * key);
993
994 /** \ingroup rpmtrans
995  * Add package to be removed to unordered transaction set.
996  * @param ts            transaction set
997  * @param dboffset      rpm database instance
998  */
999 void rpmtransRemovePackage(rpmTransactionSet ts, int dboffset);
1000
1001 /** \ingroup rpmtrans
1002  * Destroy transaction set.
1003  * @param ts            transaction set
1004  */
1005 void rpmtransFree( /*@only@*/ rpmTransactionSet ts);
1006
1007 /** \ingroup rpmtrans
1008  * Save file handle to be used as stderr when running package scripts.
1009  * @param ts            transaction set
1010  * @param fd            file handle
1011  */
1012 void rpmtransSetScriptFd(rpmTransactionSet ts, FD_t fd)
1013         /*@modifies ts, fd @*/;
1014
1015 /** \ingroup rpmtrans
1016  * Retrieve keys from ordered transaction set.
1017  * @todo Removed packages have no keys, returned as interleaved NULL pointers.
1018  * @param ts            transaction set
1019  * @retval ep           address of returned element array pointer (or NULL)
1020  * @retval nep          address of no. of returned elements (or NULL)
1021  * @return              0 always
1022  */
1023 int rpmtransGetKeys(const rpmTransactionSet ts,
1024         /*@out@*/ const void *** ep, /*@out@*/ int * nep)
1025                 /*@modifies ep, nep @*/;
1026
1027 /** \ingroup rpmtrans
1028  * Check that all dependencies can be resolved.
1029  * @param ts            transaction set
1030  * @retval conflicts
1031  * @retval numConflicts
1032  * @return              0 on success
1033  */
1034 int rpmdepCheck(rpmTransactionSet ts,
1035         /*@exposed@*/ /*@out@*/ struct rpmDependencyConflict ** conflicts,
1036         /*@exposed@*/ /*@out@*/ int * numConflicts);
1037
1038 /** \ingroup rpmtrans
1039  * Determine package order in a transaction set according to dependencies.
1040  *
1041  * Order packages, returning error if circular dependencies cannot be
1042  * eliminated by removing PreReq's from the loop(s). Only dependencies from
1043  * added or removed packages are used to determine ordering using a
1044  * topological sort (Knuth vol. 1, p. 262). Use rpmdepCheck() to verify
1045  * that all dependencies can be reolved.
1046  *
1047  * The order ends up as installed packages followed by removed packages,
1048  * with packages removed for upgrades immediately following the new package
1049  * to be installed.
1050  *
1051  * The operation would be easier if we could sort the addedPackages array in the
1052  * transaction set, but we store indexes into the array in various places.
1053  *
1054  * @param ts            transaction set
1055  * @return              0 if packages are successfully ordered, 1 otherwise
1056  */
1057 int rpmdepOrder(rpmTransactionSet ts)   /*@modifies ts @*/;
1058
1059 /** \ingroup rpmtrans
1060  * Destroy dependency conflicts storage.
1061  * @param conflicts     dependency conflicts
1062  * @param numConflicts  no. of dependency conflicts
1063  */
1064 void rpmdepFreeConflicts( /*@only@*/ struct rpmDependencyConflict * conflicts,
1065         int numConflicts);
1066
1067 /** \ingroup rpmtrans
1068  * Bit(s) to control rpmRunTransaction() operation.
1069  */
1070 typedef enum rpmtransFlags_e {
1071     RPMTRANS_FLAG_NONE          = 0,
1072     RPMTRANS_FLAG_TEST          = (1 <<  0),    /*!< from --test */
1073     RPMTRANS_FLAG_BUILD_PROBS   = (1 <<  1),    /*!< @todo Document. */
1074     RPMTRANS_FLAG_NOSCRIPTS     = (1 <<  2),    /*!< from --noscripts */
1075     RPMTRANS_FLAG_JUSTDB        = (1 <<  3),    /*!< from --justdb */
1076     RPMTRANS_FLAG_NOTRIGGERS    = (1 <<  4),    /*!< from --notriggers */
1077     RPMTRANS_FLAG_NODOCS        = (1 <<  5),    /*!< from --excludedocs */
1078     RPMTRANS_FLAG_ALLFILES      = (1 <<  6),    /*!< from --allfiles */
1079     RPMTRANS_FLAG_KEEPOBSOLETE  = (1 <<  7),    /*!< @todo Document. */
1080     RPMTRANS_FLAG_MULTILIB      = (1 <<  8),    /*!< @todo Document. */
1081     RPMTRANS_FLAG_DIRSTASH      = (1 <<  9),    /*!< from --dirstash */
1082     RPMTRANS_FLAG_REPACKAGE     = (1 << 10),    /*!< from --repackage */
1083
1084     RPMTRANS_FLAG_PKGCOMMIT     = (1 << 11),
1085     RPMTRANS_FLAG_PKGUNDO       = (1 << 12),
1086     RPMTRANS_FLAG_COMMIT        = (1 << 13),
1087     RPMTRANS_FLAG_UNDO          = (1 << 14),
1088     RPMTRANS_FLAG_REVERSE       = (1 << 15),
1089
1090     RPMTRANS_FLAG_NOTRIGGERPREIN= (1 << 16),
1091     RPMTRANS_FLAG_NOPRE         = (1 << 17),
1092     RPMTRANS_FLAG_NOPOST        = (1 << 18),
1093     RPMTRANS_FLAG_NOTRIGGERIN   = (1 << 19),
1094     RPMTRANS_FLAG_NOTRIGGERUN   = (1 << 20),
1095     RPMTRANS_FLAG_NOPREUN       = (1 << 21),
1096     RPMTRANS_FLAG_NOPOSTUN      = (1 << 22),
1097     RPMTRANS_FLAG_NOTRIGGERPOSTUN = (1 << 23),
1098     RPMTRANS_FLAG_NOPAYLOAD     = (1 << 24),
1099     RPMTRANS_FLAG_APPLYONLY     = (1 << 25),
1100 } rpmtransFlags;
1101
1102 #define _noTransScripts         \
1103   ( RPMTRANS_FLAG_NOPRE |       \
1104     RPMTRANS_FLAG_NOPOST |      \
1105     RPMTRANS_FLAG_NOPREUN |     \
1106     RPMTRANS_FLAG_NOPOSTUN      \
1107   )
1108
1109 #define _noTransTriggers        \
1110   ( RPMTRANS_FLAG_NOTRIGGERPREIN | \
1111     RPMTRANS_FLAG_NOTRIGGERIN | \
1112     RPMTRANS_FLAG_NOTRIGGERUN | \
1113     RPMTRANS_FLAG_NOTRIGGERPOSTUN \
1114   )
1115
1116 /** \ingroup rpmtrans
1117  * Return copy of rpmlib internal provides.
1118  * @retval              address of array of rpmlib internal provide names
1119  * @retval              address of array of rpmlib internal provide flags
1120  * @retval              address of array of rpmlib internal provide versions
1121  * @return              no. of entries
1122  */
1123 int rpmGetRpmlibProvides(/*@out@*/ const char *** provNames,
1124         /*@out@*/ int ** provFlags, /*@out@*/ const char *** provVersions)
1125                 /*@ modifies *provNames, *provFlags, *provVersions @*/;
1126
1127 /** \ingroup rpmtrans
1128  * Compare two versioned dependency ranges, looking for overlap.
1129  * @param AName         1st dependncy name string
1130  * @param AEVR          1st dependency [epoch:]version[-release] string
1131  * @param AFlags        1st dependency logical range qualifiers
1132  * @param BName         2nd dependncy name string
1133  * @param BEVR          2nd dependency [epoch:]version[-release] string
1134  * @param BFlags        2nd dependency logical range qualifiers
1135  * @return              1 if dependencies overlap, 0 otherwise
1136  */
1137 int rpmRangesOverlap(const char *AName, const char *AEVR, int AFlags,
1138         const char *BName, const char *BEVR, int BFlags)        /*@*/;
1139
1140 /** \ingroup rpmtrans
1141  * Check dependency against internal rpmlib feature provides.
1142  * @param keyName       dependency name string
1143  * @param keyEVR        dependency [epoch:]version[-release] string
1144  * @param keyFlags      dependency logical range qualifiers
1145  * @return              1 if dependency overlaps, 0 otherwise
1146  */
1147 int rpmCheckRpmlibProvides(const char * keyName, const char * keyEVR,
1148         int keyFlags)   /*@*/;
1149
1150 /** \ingroup rpmcli
1151  * Display current rpmlib feature provides.
1152  * @param fp            output file handle
1153  */
1154 void rpmShowRpmlibProvides(FILE * fp) /*@modifies *fp @*/;
1155
1156 /**
1157  * @todo Generalize filter mechanism.
1158  */
1159 typedef enum rpmprobFilterFlags_e {
1160     RPMPROB_FILTER_NONE         = 0,
1161     RPMPROB_FILTER_IGNOREOS     = (1 << 0),     /*!< from --ignoreos */
1162     RPMPROB_FILTER_IGNOREARCH   = (1 << 1),     /*!< from --ignorearch */
1163     RPMPROB_FILTER_REPLACEPKG   = (1 << 2),     /*!< from --replacepkgs */
1164     RPMPROB_FILTER_FORCERELOCATE= (1 << 3),     /*!< from --badreloc */
1165     RPMPROB_FILTER_REPLACENEWFILES= (1 << 4),   /*!< from --replacefiles */
1166     RPMPROB_FILTER_REPLACEOLDFILES= (1 << 5),   /*!< from --replacefiles */
1167     RPMPROB_FILTER_OLDPACKAGE   = (1 << 6),     /*!< from --oldpackage */
1168     RPMPROB_FILTER_DISKSPACE    = (1 << 7),     /*!< from --ignoresize */
1169     RPMPROB_FILTER_DISKNODES    = (1 << 8)      /*!< from --ignoresize */
1170 } rpmprobFilterFlags;
1171
1172 /** \ingroup rpmtrans
1173  * Process all packages in transaction set.
1174  * @param ts            transaction set
1175  * @param notify        progress callback
1176  * @param notifyData    progress callback private data
1177  * @param okProbs       previously known problems (or NULL)
1178  * @retval newProbs     address to return unfiltered problems (or NULL)
1179  * @param transFlags    bits to control rpmRunTransactions()
1180  * @param ignoreSet     bits to filter problem types
1181  * @return              0 on success, -1 on error, >0 with newProbs set
1182  */
1183 int rpmRunTransactions(rpmTransactionSet ts,
1184                         rpmCallbackFunction notify,
1185                         /*@owned@*/ rpmCallbackData notifyData,
1186                         rpmProblemSet okProbs,
1187                         /*@out@*/ rpmProblemSet * newProbs,
1188                         rpmtransFlags transFlags,
1189                         rpmprobFilterFlags ignoreSet);
1190
1191 /*@}*/
1192
1193 /**
1194  * Return name of tag from value.
1195  * @param tag           tag value
1196  * @return              name of tag
1197  */
1198 /*@observer@*/ const char *const tagName(int tag)       /*@*/;
1199
1200 /**
1201  * Return value of tag from name.
1202  * @param targstr       name of tag
1203  * @return              tag value
1204  */
1205 int tagValue(const char *tagstr)                        /*@*/;
1206
1207 #define RPMLEAD_BINARY 0
1208 #define RPMLEAD_SOURCE 1
1209
1210 #define RPMLEAD_MAGIC0 0xed
1211 #define RPMLEAD_MAGIC1 0xab
1212 #define RPMLEAD_MAGIC2 0xee
1213 #define RPMLEAD_MAGIC3 0xdb
1214
1215 #define RPMLEAD_SIZE 96         /*!< Don't rely on sizeof(struct) */
1216
1217 /** \ingroup lead
1218  * The lead data structure.
1219  * The lead needs to be 8 byte aligned.
1220  * @deprecated The lead (except for signature_type) is legacy.
1221  * @todo Don't use any information from lead.
1222  */
1223 struct rpmlead {
1224     unsigned char magic[4];
1225     unsigned char major, minor;
1226     short type;
1227     short archnum;
1228     char name[66];
1229     short osnum;
1230     short signature_type;       /*!< Signature header type (RPMSIG_HEADERSIG) */
1231     char reserved[16];          /*!< Pad to 96 bytes -- 8 byte aligned! */
1232 } ;
1233
1234 /**
1235  * Release storage used by file system usage cache.
1236  */
1237 void freeFilesystems(void);
1238
1239 /**
1240  * Return (cached) file system mount points.
1241  * @retval                      addess of file system names (or NULL)
1242  * @retval num                  address of number of file systems
1243  * @return                      0 on success, 1 on error
1244  */
1245 int rpmGetFilesystemList( /*@out@*/ const char *** listptr, /*@out@*/ int * num)
1246         /*@modifies *listptr, *num @*/;
1247
1248 /**
1249  * Determine per-file system usage for a list of files.
1250  * @param filelist              array of absolute file names
1251  * @param fssizes               array of file sizes
1252  * @param numFiles              number of files in list
1253  * @retval usagesPtr            address of per-file system usage array.
1254  * @param flags                 (unused)
1255  * @return                      0 on success, 1 on error
1256  */
1257 int rpmGetFilesystemUsage(const char ** filelist, int_32 * fssizes,
1258         int numFiles, /*@out@*/ uint_32 ** usagesPtr, int flags);
1259
1260 /* ==================================================================== */
1261 /** \name RPMBT */
1262 /*@{*/
1263
1264 /** \ingroup rpmcli
1265  * Describe build command line request.
1266  */
1267 struct rpmBuildArguments {
1268     int buildAmount;            /*!< Bit(s) to control operation. */
1269     const char *buildRootOverride; /*!< from --buildroot */
1270     char *targets;              /*!< Target platform(s), comma separated. */
1271     int force;                  /*!< from --force */
1272     int noBuild;                /*!< from --nobuild */
1273     int noDeps;                 /*!< from --nodeps */
1274     int noLang;                 /*!< from --nolang */
1275     int shortCircuit;           /*!< from --short-circuit */
1276     int sign;                   /*!< from --sign */
1277     int useCatalog;             /*!< from --usecatalog */
1278     char buildMode;             /*!< Build mode (one of "btBC") */
1279     char buildChar;             /*!< Build stage (one of "abcilps ") */
1280 /*@dependent@*/ const char *rootdir;
1281 };
1282 /** \ingroup rpmcli
1283  */
1284 typedef struct rpmBuildArguments BTA_t;
1285
1286 /** \ingroup rpmcli
1287  */
1288 extern struct rpmBuildArguments         rpmBTArgs;
1289
1290 /** \ingroup rpmcli
1291  */
1292 extern struct poptOption                rpmBuildPoptTable[];
1293
1294 /*@}*/
1295 /* ==================================================================== */
1296 /** \name RPMQV */
1297 /*@{*/
1298
1299 /** \ingroup rpmcli
1300  * Bit(s) for rpmVerifyFile() attributes and result.
1301  */
1302 typedef enum rpmVerifyAttrs_e {
1303     RPMVERIFY_NONE      = 0,            /*!< */
1304     RPMVERIFY_MD5       = (1 << 0),     /*!< */
1305     RPMVERIFY_FILESIZE  = (1 << 1),     /*!< */
1306     RPMVERIFY_LINKTO    = (1 << 2),     /*!< */
1307     RPMVERIFY_USER      = (1 << 3),     /*!< */
1308     RPMVERIFY_GROUP     = (1 << 4),     /*!< */
1309     RPMVERIFY_MTIME     = (1 << 5),     /*!< */
1310     RPMVERIFY_MODE      = (1 << 6),     /*!< */
1311     RPMVERIFY_RDEV      = (1 << 7),     /*!< */
1312     RPMVERIFY_READLINKFAIL= (1 << 28),  /*!< */
1313     RPMVERIFY_READFAIL  = (1 << 29),    /*!< */
1314     RPMVERIFY_LSTATFAIL = (1 << 30)     /*!< */
1315 } rpmVerifyAttrs;
1316 #define RPMVERIFY_ALL           ~(RPMVERIFY_NONE)
1317
1318 /** \ingroup rpmcli
1319  * Verify file attributes and MD5 sum.
1320  * @todo gnorpm and python bindings prevent this from being static.
1321  * @todo add rpmVerifyAttrs to prototype.
1322  * @param root          path to top of install tree
1323  * @param h             header
1324  * @param filenum       index of file in header file info arrays
1325  * @retval result       address of failure flags
1326  * @param omitMask      bit(s) to disable verify checks
1327  * @return              0 on success (or not installed), 1 on error
1328  */
1329 int rpmVerifyFile(const char * root, Header h, int filenum,
1330         /*@out@*/ int * result, int omitMask);
1331
1332 /**
1333  * Return exit code from running verify script in header.
1334  * @todo gnorpm/kpackage prevents static, should be using VERIFY_SCRIPT flag.
1335  * @param rootDir       path to top of install tree
1336  * @param h             header
1337  * @param scriptFd      file handle to use for stderr (or NULL)
1338  * @return              0 on success
1339  */
1340 int rpmVerifyScript(const char * rootDir, Header h, FD_t scriptFd);
1341
1342 /** \ingroup rpmcli
1343  * The command line argument will be used to retrieve header(s) ...
1344  */
1345 typedef enum rpmQVSources_e {
1346     RPMQV_PACKAGE = 0,  /*!< ... from package name db search. */
1347     RPMQV_PATH,         /*!< ... from file path db search. */
1348     RPMQV_ALL,          /*!< ... from each installed package. */
1349     RPMQV_RPM,          /*!< ... from reading binary rpm package. */
1350     RPMQV_GROUP,        /*!< ... from group db search. */
1351     RPMQV_WHATPROVIDES, /*!< ... from provides db search. */
1352     RPMQV_WHATREQUIRES, /*!< ... from requires db search. */
1353     RPMQV_TRIGGEREDBY,  /*!< ... from trigger db search. */
1354     RPMQV_DBOFFSET,     /*!< ... from database header instance. */
1355     RPMQV_SPECFILE      /*!< ... from spec file parse (query only). */
1356 } rpmQVSources;
1357
1358 /** \ingroup rpmcli
1359  * Bit(s) to control rpmQuery() operation, stored in qva_flags.
1360  */
1361 typedef enum rpmQueryFlags_e {
1362     QUERY_FOR_LIST      = (1 << 1),     /*!< from --list */
1363     QUERY_FOR_STATE     = (1 << 2),     /*!< from --state */
1364     QUERY_FOR_DOCS      = (1 << 3),     /*!< from --docfiles */
1365     QUERY_FOR_CONFIG    = (1 << 4),     /*!< from --configfiles */
1366     QUERY_FOR_DUMPFILES = (1 << 8)      /*!< from --dump */
1367 } rpmQueryFlags;
1368
1369 /** \ingroup rpmcli
1370  * Bit(s) to control rpmVerify() operation, stored in qva_flags.
1371  */
1372 typedef enum rpmVerifyFlags_e {
1373     VERIFY_FILES        = (1 <<  9),    /*!< from --nofiles */
1374     VERIFY_DEPS         = (1 << 10),    /*!< from --nodeps */
1375     VERIFY_SCRIPT       = (1 << 11),    /*!< from --noscripts */
1376     VERIFY_MD5          = (1 << 12)     /*!< from --nomd5 */
1377 } rpmVerifyFlags;
1378
1379 /** \ingroup rpmcli
1380  * Describe query/verify command line request.
1381  */
1382 typedef struct rpmQVArguments {
1383     rpmQVSources qva_source;    /*!< Identify CLI arg type. */
1384     int         qva_sourceCount;/*!< Exclusive check (>1 is error). */
1385     int         qva_flags;      /*!< Bit(s) to control operation. */
1386     int         qva_verbose;    /*!< (unused) */
1387     const char *qva_queryFormat;/*!< Format for headerSprintf(). */
1388     const char *qva_prefix;     /*!< Path to top of install tree. */
1389     char        qva_mode;       /*!< 'q' is query, 'v' is verify mode. */
1390     char        qva_char;       /*!< (unused) always ' ' */
1391 } QVA_t;
1392
1393 /** \ingroup rpmcli
1394  */
1395 extern QVA_t rpmQVArgs;
1396
1397 /** \ingroup rpmcli
1398  */
1399 extern struct poptOption rpmQVSourcePoptTable[];
1400
1401 /** \ingroup rpmcli
1402  * @param qva           parsed query/verify options
1403  * @param db            rpm database
1404  * @param h             header to use for query/verify
1405  */
1406 typedef int (*QVF_t) (QVA_t *qva, rpmdb db, Header h);
1407
1408 /** \ingroup rpmcli
1409  * Display query/verify information for each header in iterator.
1410  * @param qva           parsed query/verify options
1411  * @param mi            rpm database iterator
1412  * @param showPackage   query/verify display routine
1413  * @return              result of last non-zero showPackage() return
1414  */
1415 int showMatches(QVA_t *qva, /*@only@*/ /*@null@*/ rpmdbMatchIterator mi,
1416         QVF_t showPackage);
1417
1418 /** \ingroup rpmcli
1419  */
1420 extern int specedit;
1421
1422 /** \ingroup rpmcli
1423  */
1424 extern struct poptOption rpmQueryPoptTable[];
1425
1426 /** \ingroup rpmcli
1427  * Display list of tags that can be used in --queryformat.
1428  * @param f     file handle to use for display
1429  */
1430 void rpmDisplayQueryTags(FILE * f);
1431
1432 /** \ingroup rpmcli
1433  * Common query/verify source interface, called once for each CLI arg.
1434  * @param qva           parsed query/verify options
1435  * @param source        type of source to query/verify
1436  * @param arg           name of source to query/verify
1437  * @param db            rpm database
1438  * @param showPackage   query/verify specific display routine
1439  * @return              showPackage() result, 1 if rpmdbInitIterator() is NULL
1440  */
1441 int rpmQueryVerify(QVA_t *qva, rpmQVSources source, const char * arg,
1442         rpmdb db, QVF_t showPackage);
1443
1444 /** \ingroup rpmcli
1445  * Display results of package query.
1446  * @todo Devise a meaningful return code.
1447  * @param qva           parsed query/verify options
1448  * @param db            rpm database (unused for queries)
1449  * @param h             header to use for query
1450  * @return              0 always
1451  */
1452 int showQueryPackage(QVA_t *qva, rpmdb db, Header h);
1453
1454 /** \ingroup rpmcli
1455  * Display package information.
1456  * @param qva           parsed query/verify options
1457  * @param source        type of source to query
1458  * @param arg           name of source to query
1459  * @return              rpmQueryVerify() result, or 1 on rpmdbOpen() failure
1460  */
1461 int rpmQuery(QVA_t *qva, rpmQVSources source, const char * arg);
1462
1463 /** \ingroup rpmcli
1464  */
1465 extern struct poptOption rpmVerifyPoptTable[];
1466
1467 /** \ingroup rpmcli
1468  * Display results of package verify.
1469  * @param qva           parsed query/verify options
1470  * @param db            rpm database
1471  * @param h             header to use for verify
1472  * @return              result of last non-zero verify return
1473  */
1474 int showVerifyPackage(QVA_t *qva, /*@only@*/ rpmdb db, Header h);
1475
1476 /** \ingroup rpmcli
1477  * Verify package install.
1478  * @param qva           parsed query/verify options
1479  * @param source        type of source to verify
1480  * @param arg           name of source to verify
1481  * @return              rpmQueryVerify() result, or 1 on rpmdbOpen() failure
1482  */
1483 int rpmVerify(QVA_t *qva, rpmQVSources source, const char *arg);
1484
1485 /*@}*/
1486 /* ==================================================================== */
1487 /** \name RPMEIU */
1488 /*@{*/
1489 /* --- install/upgrade/erase modes */
1490
1491 /** \ingroup rpmcli
1492  * Bit(s) to control rpmInstall() operation.
1493  */
1494 typedef enum rpmInstallInterfaceFlags_e {
1495     INSTALL_NONE        = 0,
1496     INSTALL_PERCENT     = (1 << 0),     /*!< from --percent */
1497     INSTALL_HASH        = (1 << 1),     /*!< from --hash */
1498     INSTALL_NODEPS      = (1 << 2),     /*!< from --nodeps */
1499     INSTALL_NOORDER     = (1 << 3),     /*!< from --noorder */
1500     INSTALL_LABEL       = (1 << 4),     /*!< from --verbose (notify) */
1501     INSTALL_UPGRADE     = (1 << 5),     /*!< from --upgrade */
1502     INSTALL_FRESHEN     = (1 << 6),     /*!< from --freshen */
1503 } rpmInstallInterfaceFlags;
1504
1505 /** \ingroup rpmcli
1506  * Install/upgrade/freshen binary rpm package.
1507  * @param rootdir       path to top of install tree
1508  * @param argv          array of package file names (NULL terminated)
1509  * @param transFlags    bits to control rpmRunTransactions()
1510  * @param interfaceFlags bits to control rpmInstall()
1511  * @param probFilter    bits to filter problem types
1512  * @param relocations   package file relocations
1513  * @return              0 on success
1514  */
1515 int rpmInstall(const char * rootdir, const char ** argv,
1516                 rpmtransFlags transFlags, 
1517                 rpmInstallInterfaceFlags interfaceFlags,
1518                 rpmprobFilterFlags probFilter,
1519                 rpmRelocation * relocations);
1520
1521 /** \ingroup rpmcli
1522  * Install source rpm package.
1523  * @param prefix        path to top of install tree
1524  * @param arg           source rpm file name
1525  * @retval specFile     address of (installed) spec file name
1526  * @retval cookie
1527  * @return              0 on success
1528  */
1529 int rpmInstallSource(const char * prefix, const char * arg,
1530                 /*@out@*/ const char ** specFile, /*@out@*/ char ** cookie);
1531
1532 /** \ingroup rpmcli
1533  * Bit(s) to control rpmErase() operation.
1534  */
1535 typedef enum rpmEraseInterfaceFlags_e {
1536     UNINSTALL_NONE      = 0,
1537     UNINSTALL_NODEPS    = (1 << 0),     /*!< from --nodeps */
1538     UNINSTALL_ALLMATCHES= (1 << 1),     /*!< from --allmatches */
1539 } rpmEraseInterfaceFlags;
1540
1541 /** \ingroup rpmcli
1542  * Erase binary rpm package.
1543  * @param rootdir       path to top of install tree
1544  * @param argv          array of package file names (NULL terminated)
1545  * @param transFlags    bits to control rpmRunTransactions()
1546  * @param interfaceFlags bits to control rpmInstall()
1547  * @return              0 on success
1548  */
1549 int rpmErase(const char * rootdir, const char ** argv,
1550                 rpmtransFlags transFlags, 
1551                 rpmEraseInterfaceFlags interfaceFlags);
1552
1553 /*@}*/
1554 /* ==================================================================== */
1555 /** \name RPMK */
1556 /*@{*/
1557
1558 /** \ingroup signature
1559  * Tags found in signature header from package.
1560  */
1561 enum rpmtagSignature {
1562     RPMSIGTAG_SIZE      = 1000, /*!< Size in bytes. */
1563 /* the md5 sum was broken *twice* on big endian machines */
1564     RPMSIGTAG_LEMD5_1   = 1001, /*!< Broken MD5, take 1 */
1565     RPMSIGTAG_PGP       = 1002, /*!< PGP 2.6.3 signature. */
1566     RPMSIGTAG_LEMD5_2   = 1003, /*!< Broken MD5, take 2 */
1567     RPMSIGTAG_MD5       = 1004, /*!< MD5 signature. */
1568     RPMSIGTAG_GPG       = 1005, /*!< GnuPG signature. */
1569     RPMSIGTAG_PGP5      = 1006, /*!< PGP5 signature @deprecated legacy. */
1570
1571 /* Signature tags by Public Key Algorithm (RFC 2440) */
1572 /* N.B.: These tags are tenative, the values may change */
1573     RPMTAG_PK_BASE      = 512,          /*!< @todo Implement. */
1574     RPMTAG_PK_RSA_ES    = RPMTAG_PK_BASE+1,     /*!< (unused */
1575     RPMTAG_PK_RSA_E     = RPMTAG_PK_BASE+2,     /*!< (unused) */
1576     RPMTAG_PK_RSA_S     = RPMTAG_PK_BASE+3,     /*!< (unused) */
1577     RPMTAG_PK_ELGAMAL_E = RPMTAG_PK_BASE+16,    /*!< (unused) */
1578     RPMTAG_PK_DSA       = RPMTAG_PK_BASE+17,    /*!< (unused) */
1579     RPMTAG_PK_ELLIPTIC  = RPMTAG_PK_BASE+18,    /*!< (unused) */
1580     RPMTAG_PK_ECDSA     = RPMTAG_PK_BASE+19,    /*!< (unused) */
1581     RPMTAG_PK_ELGAMAL_ES= RPMTAG_PK_BASE+20,    /*!< (unused) */
1582     RPMTAG_PK_DH        = RPMTAG_PK_BASE+21,    /*!< (unused) */
1583
1584     RPMTAG_HASH_BASE    = 512+64,       /*!< @todo Implement. */
1585     RPMTAG_HASH_MD5     = RPMTAG_HASH_BASE+1,   /*!< (unused) */
1586     RPMTAG_HASH_SHA1    = RPMTAG_HASH_BASE+2,   /*!< (unused) */
1587     RPMTAG_HASH_RIPEMD160= RPMTAG_HASH_BASE+3,  /*!< (unused) */
1588     RPMTAG_HASH_MD2     = RPMTAG_HASH_BASE+5,   /*!< (unused) */
1589     RPMTAG_HASH_TIGER192= RPMTAG_HASH_BASE+6,   /*!< (unused) */
1590     RPMTAG_HASH_HAVAL_5_160= RPMTAG_HASH_BASE+7 /*!< (unused) */
1591 };
1592
1593 /**
1594  *  Return codes from verifySignature().
1595  */
1596 typedef enum rpmVerifySignatureReturn_e {
1597     RPMSIG_OK           = 0,    /*!< Signature is OK. */
1598     RPMSIG_UNKNOWN      = 1,    /*!< Signature is unknown. */
1599     RPMSIG_BAD          = 2,    /*!< Signature does not verify. */
1600     RPMSIG_NOKEY        = 3,    /*!< Key is unavailable. */
1601     RPMSIG_NOTTRUSTED   = 4,    /*!< Signature is OK, but key is not trusted. */
1602 } rpmVerifySignatureReturn;
1603
1604 /** \ingroup signature
1605  * Verify a signature from a package.
1606  * @param file          file name of header+payload
1607  * @param sigTag        type of signature
1608  * @param sig           signature itself
1609  * @param count         no. of bytes in signature
1610  * @retval result       detailed text result of signature verification
1611  * @return              result of signature verification
1612  */
1613 rpmVerifySignatureReturn rpmVerifySignature(const char *file,
1614                 int_32 sigTag, const void * sig, int count, char *result);
1615
1616 /** \ingroup signature
1617  * Destroy signature header from package.
1618  */
1619 void rpmFreeSignature(Header h);
1620
1621 /* --- checksig/resign */
1622
1623 /** \ingroup rpmcli
1624  * Bit(s) to control rpmCheckSig() operation.
1625  */
1626 typedef enum rpmCheckSigFlags_e {
1627     CHECKSIG_NONE       = 0,            /*!< Don't check any signatures. */
1628     CHECKSIG_PGP        = (1 << 0),     /*!< if not --nopgp */
1629     CHECKSIG_MD5        = (1 << 1),     /*!< if not --nomd5 */
1630     CHECKSIG_GPG        = (1 << 2),     /*!< if not --nogpg */
1631 } rpmCheckSigFlags;
1632
1633 /** \ingroup rpmcli
1634  * Check elements in signature header.
1635  * @param flags         bit(s) to enable signature checks
1636  * @param argv          array of package file names (NULL terminated)
1637  * @return              0 on success
1638  */
1639 int rpmCheckSig(rpmCheckSigFlags flags, const char ** argv);
1640
1641 /** \ingroup rpmcli
1642  * Bit(s) to control rpmReSign() operation.
1643  */
1644 typedef enum rpmResignFlags_e {
1645     RESIGN_NEW_SIGNATURE = 0,   /*!< from --resign */
1646     RESIGN_ADD_SIGNATURE,       /*!< from --addsign */
1647 } rpmResignFlags;
1648
1649 /** \ingroup rpmcli
1650  * Create/modify elements in signature header.
1651  * @param add           type of signature operation
1652  * @param passPhrase
1653  * @param argv          array of package file names (NULL terminated)
1654  * @return              0 on success
1655  */
1656 int rpmReSign(rpmResignFlags add, char *passPhrase, const char ** argv);
1657
1658 /*@}*/
1659
1660 #ifdef __cplusplus
1661 }
1662 #endif
1663
1664 #endif  /* H_RPMLIB */