header.h   header.h 
/* RPM - Copyright (C) 1995 Red Hat Software #ifndef H_HEADER
#define H_HEADER
/** \ingroup header
* \file lib/header.h
* *
* header.h - routines for managing rpm tagged structures * An rpm header carries all information about a package. A header is
* a collection of data elements called tags. Each tag has a data type,
* and includes 1 or more values.
*
* \par Historical Issues
*
* Here's a brief description of features/incompatibilities that
* have been added to headers and tags.
*
* - version 1
* - Support for version 1 headers was removed in rpm-4.0.
*
* - version 2
* - @todo Document version2 headers.
*
* - version 3 (added in rpm-3.0)
* - Added RPM_I18NSTRING_TYPE as an associative array reference
* for i18n locale dependent single element tags (i.e Group).
* - Added an 8 byte magic string to headers in packages on-disk. The
* magic string was not added to headers in the database.
*
* - version 4 (added in rpm-4.0)
* - Represent file names as a (dirname/basename/dirindex) triple
* rather than as an absolute path name. Legacy package headers are
* converted when the header is read. Legacy database headers are
* converted when the database is rebuilt.
* - Simplify dependencies by eliminating the implict check on
* package name/version/release in favor of an explict check
* on package provides. Legacy package headers are converted
* when the header is read. Legacy database headers are
* converted when the database is rebuilt.
* - (rpm-4.0.2) The original package header (and all original
* metadata) is preserved in what's called an "immutable header regio
n".
* The original header can be retrieved as an RPM_BIN_TYPE, just
* like any other tag, and the original header reconstituted using
* headerLoad().
* - (rpm-4.0.2) The signature tags are added (and renumbered to avoid
* tag value collisions) to the package header during package
* installation.
* - (rpm-4.0.3) A SHA1 digest of the original header is appended
* (i.e. detached digest) to the immutable header region to verify
* changes to the original header.
* - (rpm-4.0.3) Private methods (e.g. headerLoad(), headerUnload(), et
c.)
* to permit header data to be manipulated opaquely through vectors.
* - (rpm-4.0.3) Sanity checks on header data to limit #tags to 65K,
* #bytes to 16Mb, and total metadata size to 32Mb added.
* .
*
* \par Development Issues
*
* Here's a brief description of future features/incompatibilities that
* will be added to headers.
*
* - Private header methods.
* - Private methods for the transaction element file info TFI_t may
* be used as proof-of-concept, binary XML may be implemented
* as a header format representation soon thereafter.
* - DSA signature for header metadata.
* - The manner in which rpm packages are signed is going to change.
* The SHA1 digest in the header will be signed, equivalent to a DSA
* digital signature on the original header metadata. As the original
* header will contain "trusted" (i.e. because the header is signed
* with DSA) file MD5 digests, there will be little or no reason
* to sign the payload, but that may happen as well. Note that cpio
* headers in the payload are not used to install package metadata,
* only the name field in the cpio header is used to associate an
* archive file member with the corresponding entry for the file
* in header metadata.
* .
*/ */
/* WARNING: 1 means success, 0 means failure (yes, this is backwards) */ /* RPM - Copyright (C) 1995-2001 Red Hat Software */
#ifndef H_HEADER
#define H_HEADER
#include <stdio.h> #include <stdio.h>
#include <zlib.h> #include <rpmio.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#if defined(__alpha__) || defined(__alpha) #if defined(__alpha__) || defined(__alpha)
typedef long int int_64; typedef long int int_64;
typedef int int_32; typedef int int_32;
typedef short int int_16; typedef short int int_16;
typedef char int_8; typedef char int_8;
skipping to change at line 39 skipping to change at line 109
typedef long long int int_64; typedef long long int int_64;
#endif #endif
typedef int int_32; typedef int int_32;
typedef short int int_16; typedef short int int_16;
typedef char int_8; typedef char int_8;
typedef unsigned int uint_32; typedef unsigned int uint_32;
typedef unsigned short uint_16; typedef unsigned short uint_16;
#endif #endif
typedef /*@abstract@*/ /*@refcounted@*/ struct headerToken *Header; /*@-redef@*/ /* LCL: no clue */
typedef /*@abstract@*/ struct headerIteratorS *HeaderIterator; /** \ingroup header
*/
typedef const char * errmsg_t;
struct headerTagTableEntry { /** \ingroup header
const char * name; */
int val; typedef int_32 * hTAG_t;
typedef int_32 * hTYP_t;
typedef const void * hPTR_t;
typedef int_32 * hCNT_t;
/** \ingroup header
*/
typedef /*@abstract@*/ /*@refcounted@*/ struct headerToken * Header;
/** \ingroup header
*/
typedef /*@abstract@*/ struct headerIteratorS * HeaderIterator;
/** \ingroup header
* Associate tag names with numeric values.
*/
typedef /*@abstract@*/ struct headerTagTableEntry_s * headerTagTableEntry;
struct headerTagTableEntry_s {
/*@observer@*/ /*@null@*/ const char * name; /*!< Tag name. */
int val; /*!< Tag numeric value. */
}; };
enum headerSprintfExtenstionType { HEADER_EXT_LAST = 0, HEADER_EXT_FORMAT, /** \ingroup header
HEADER_EXT_MORE, HEADER_EXT_TAG }; */
enum headerSprintfExtenstionType {
HEADER_EXT_LAST = 0, /*!< End of extension chain. */
HEADER_EXT_FORMAT, /*!< headerTagFormatFunction() extension */
HEADER_EXT_MORE, /*!< Chain to next table. */
HEADER_EXT_TAG /*!< headerTagTagFunction() extension */
};
/* This will only ever be passed RPM_TYPE_INT32 or RPM_TYPE_STRING to /** \ingroup header
help keep things simple */ * HEADER_EXT_TAG format function prototype.
typedef char * (*headerTagFormatFunction)(int_32 type, const void * data, * This will only ever be passed RPM_INT32_TYPE or RPM_STRING_TYPE to
char * formatPrefix, * help keep things simple.
int padding, int element); *
/* This is allowed to fail, which indicates the tag doesn't exist */ * @param type tag type
typedef int (*headerTagTagFunction)(Header h, int_32 * type, const void ** * @param data tag value
data, * @param formatPrefix
int_32 * count, int * freeData); * @param padding
* @param element
* @return formatted string
*/
typedef /*only@*/ char * (*headerTagFormatFunction)(int_32 type,
const void * data, char * formatPrefix,
int padding, int element);
/** \ingroup header
* HEADER_EXT_FORMAT format function prototype.
* This is allowed to fail, which indicates the tag doesn't exist.
*
* @param h header
* @retval type address of tag type
* @retval data address of tag value pointer
* @retval count address of no. of data items
* @retval freedata address of data-was-malloc'ed indicator
* @return 0 on success
*/
typedef int (*headerTagTagFunction) (Header h,
/*@null@*/ /*@out@*/ hTYP_t type,
/*@null@*/ /*@out@*/ hPTR_t * data,
/*@null@*/ /*@out@*/ hCNT_t count,
/*@null@*/ /*@out@*/ int * freeData);
struct headerSprintfExtension { /** \ingroup header
enum headerSprintfExtenstionType type; * Define header tag output formats.
char * name; */
typedef /*@abstract@*/ struct headerSprintfExtension_s * headerSprintfExten
sion;
struct headerSprintfExtension_s {
enum headerSprintfExtenstionType type; /*!< Type of extension. */
/*@observer@*/ /*@null@*/
const char * name; /*!< Name of extension. */
union { union {
void * generic; /*@observer@*/ /*@null@*/
headerTagFormatFunction formatFunction; void * generic; /*!< Private extension. */
headerTagTagFunction tagFunction; headerTagFormatFunction formatFunction; /*!< HEADER_EXT_TAG extensio
struct headerSprintfExtension * more; n. */
headerTagTagFunction tagFunction; /*!< HEADER_EXT_FORMAT exten
sion. */
struct headerSprintfExtension_s * more; /*!< Chained table extension
. */
} u; } u;
}; };
/* This defines some basic conversions all header users would probably like /** \ingroup header
to have */ * Supported default header tag output formats.
extern const struct headerSprintfExtension headerDefaultFormats[]; */
/*@-redecl@*/
/*@observer@*/
extern const struct headerSprintfExtension_s headerDefaultFormats[];
/*@=redecl@*/
/* read and write a header from a file */ /** \ingroup header
Header headerRead(FD_t fd, int magicp); * Include calculation for 8 bytes of (magic, 0)?
int headerWrite(FD_t fd, Header h, int magicp); */
Header headerGzRead(FD_t fd, int magicp); enum hMagic {
int headerGzWrite(FD_t fd, Header h, int magicp); HEADER_MAGIC_NO = 0,
unsigned int headerSizeof(Header h, int magicp); HEADER_MAGIC_YES = 1
};
#define HEADER_MAGIC_NO 0 /** \ingroup header
#define HEADER_MAGIC_YES 1 * The basic types of data in tags from headers.
*/
typedef enum rpmTagType_e {
#define RPM_MIN_TYPE 0
RPM_NULL_TYPE = 0,
RPM_CHAR_TYPE = 1,
RPM_INT8_TYPE = 2,
RPM_INT16_TYPE = 3,
RPM_INT32_TYPE = 4,
/* RPM_INT64_TYPE = 5, ---- These aren't supported (yet) */
RPM_STRING_TYPE = 6,
RPM_BIN_TYPE = 7,
RPM_STRING_ARRAY_TYPE = 8,
RPM_I18NSTRING_TYPE = 9
#define RPM_MAX_TYPE 9
} rpmTagType;
/* load and unload a header from a chunk of memory */ /** \ingroup header
Header headerLoad(void *p); * New rpm data types under consideration/development.
void *headerUnload(Header h); * These data types may (or may not) be added to rpm at some point. In orde
r
* to avoid incompatibility with legacy versions of rpm, these data (sub-)t
ypes
* are introduced into the header by overloading RPM_BIN_TYPE, with the bin
ary
* value of the tag a 16 byte image of what should/will be in the header in
dex,
* followed by per-tag private data.
*/
/*@-enummemuse -typeuse @*/
typedef enum rpmSubTagType_e {
RPM_REGION_TYPE = -10,
RPM_BIN_ARRAY_TYPE = -11,
/*!<@todo Implement, kinda like RPM_STRING_ARRAY_TYPE for known (but vari
able)
length binary data. */
RPM_XREF_TYPE = -12
/*!<@todo Implement, intent is to to carry a (???,tagNum,valNum) cross
reference to retrieve data from other tags. */
} rpmSubTagType;
/*@=enummemuse =typeuse @*/
Header headerNew(void); /**
void headerFree( /*@killref@*/ Header h); * Header private tags.
* @note General use tags should start at 1000 (RPM's tag space starts ther
e).
*/
#define HEADER_IMAGE 61
#define HEADER_SIGNATURES 62
#define HEADER_IMMUTABLE 63
#define HEADER_REGIONS 64
#define HEADER_I18NTABLE 100
#define HEADER_SIGBASE 256
#define HEADER_TAGBASE 1000
/* dump a header to a file, in human readable format */ /**
void headerDump(Header h, FILE *f, int flags, */
const struct headerTagTableEntry * tags); /*@-typeuse -fielduse@*/
typedef union hRET_s {
const void * ptr;
const char ** argv;
const char * str;
uint_32 * ui32p;
uint_16 * ui16p;
int_32 * i32p;
int_16 * i16p;
int_8 * i8p;
} * hRET_t;
/*@=typeuse =fielduse@*/
/* the returned string must be free()d */ /**
char * headerSprintf(Header h, const char * fmt, */
const struct headerTagTableEntry * tags, /*@-typeuse -fielduse@*/
const struct headerSprintfExtension * extentions, typedef struct HE_s {
/*@out@*/ const char ** error); int_32 tag;
/*@null@*/ hTYP_t typ;
union {
/*@null@*/ hPTR_t * ptr;
/*@null@*/ hRET_t * ret;
} u;
/*@null@*/ hCNT_t cnt;
} * HE_t;
/*@=typeuse =fielduse@*/
#define HEADER_DUMP_INLINE 1 /** \ingroup header
* Create new (empty) header instance.
* @return header
*/
typedef
Header (*HDRnew) (void)
/*@*/;
/* Duplicate tags are okay, but only defined for iteration (with the /** \ingroup header
exceptions noted below). While you are allowed to add i18n string * Dereference a header instance.
arrays through this function, you probably don't mean to. See * @param h header
headerAddI18NString() instead */ * @return NULL always
int headerAddEntry(Header h, int_32 tag, int_32 type, const void *p, int_32 */
c); typedef
/* if there are multiple entries with this tag, the first one gets replaced /*@null@*/ Header (*HDRfree) (/*@null@*/ /*@killref@*/ Header h)
*/ /*@modifies h @*/;
int headerModifyEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c)
;
/* Return array of lang names */ /** \ingroup header
char **headerGetLangs(Header h); * Reference a header instance.
* @param h header
* @return referenced header instance
*/
typedef
Header (*HDRlink) (Header h)
/*@modifies h @*/;
/* A NULL lang is interpreted as the C locale. Here are the rules: /** \ingroup header
* Dereference a header instance.
* @param h header
* @return NULL always
*/
typedef
Header (*HDRunlink) (/*@killref@*/ /*@null@*/ Header h)
/*@modifies h @*/;
1) If the tag isn't in the Header, it's added with the passed string /** \ingroup header
as a version. * Sort tags in header.
2) If the tag occurs multiple times in entry, which tag is affected * @todo Eliminate from API.
by the operation is undefined. * @param h header
2) If the tag is in the header w/ this language, the entry is */
*replaced* (like headerModifyEntry()). typedef
void (*HDRsort) (Header h)
/*@modifies h @*/;
This function is intended to just "do the right thing". If you need /** \ingroup header
more fine grained control use headerAddEntry() and headerModifyEntry() * Restore tags in header to original ordering.
but be careful! * @todo Eliminate from API.
*/ * @param h header
int headerAddI18NString(Header h, int_32 tag, const char * string, */
const char * lang); typedef
void (*HDRunsort) (Header h)
/*@modifies h @*/;
/* Appends item p to entry w/ tag and type as passed. Won't work on /** \ingroup header
RPM_STRING_TYPE. Any pointers from headerGetEntry() for this entry * Return size of on-disk header representation in bytes.
are invalid after this call has been made! */ * @param h header
int headerAppendEntry(Header h, int_32 tag, int_32 type, void * p, int_32 c * @param magicp include size of 8 bytes for (magic, 0)?
); * @return size of on-disk header
int headerAddOrAppendEntry(Header h, int_32 tag, int_32 type, */
void * p, int_32 c); typedef
unsigned int (*HDRsizeof) (/*@null@*/ Header h, enum hMagic magicp)
/*@modifies h @*/;
/* Will never return RPM_I18NSTRING_TYPE! RPM_STRING_TYPE elements w/ /** \ingroup header
RPM_I18NSTRING_TYPE equivalent enreies are translated (if HEADER_I18NTAB * Convert header to on-disk representation.
LE * @param h header (with pointers)
entry is present). */ * @return on-disk header blob (i.e. with offsets)
int headerGetEntry(Header h, int_32 tag, /*@out@*/ int_32 *type, */
/*@out@*/ void **p, /*@out@*/int_32 *c); typedef
/*@only@*/ /*@null@*/ void * (*HDRunload) (Header h)
/*@modifies h @*/;
/* This gets an entry, and uses as little extra RAM as possible to represen /** \ingroup header
t * Convert header to on-disk representation, and then reload.
it (this is only an issue for RPM_STRING_ARRAY_TYPE. */ * This is used to insure that all header data is in one chunk.
int headerGetEntryMinMemory(Header h, int_32 tag, int_32 *type, * @param h header (with pointers)
/*@out@*/ void **p, /*@out@*/ int_32 *c); * @param tag region tag
* @return on-disk header (with offsets)
*/
typedef
/*@null@*/ Header (*HDRreload) (/*@only@*/ Header h, int tag)
/*@modifies h @*/;
/* If *type is RPM_NULL_TYPE any type will match, otherwise only *type will /** \ingroup header
match. */ * Duplicate a header.
int headerGetRawEntry(Header h, int_32 tag, /*@out@*/ int_32 *type, * @param h header
/*@out@*/ void **p, /*@out@*/ int_32 *c); * @return new header instance
*/
typedef
Header (*HDRcopy) (Header h)
/*@modifies h @*/;
int headerIsEntry(Header h, int_32 tag); /** \ingroup header
/* removes all entries of type tag from the header, returns 1 if none were * Convert header to in-memory representation.
found */ * @param uh on-disk header blob (i.e. with offsets)
int headerRemoveEntry(Header h, int_32 tag); * @return header
*/
typedef
/*@null@*/ Header (*HDRload) (/*@kept@*/ void * uh)
/*@modifies uh @*/;
HeaderIterator headerInitIterator(Header h); /** \ingroup header
int headerNextIterator(HeaderIterator iter, * Make a copy and convert header to in-memory representation.
/*@out@*/ int_32 *tag, /*@out@*/ int_32 *type, /*@out@*/ void **p, * @param uh on-disk header blob (i.e. with offsets)
/*@out@*/ int_32 *c); * @return header
void headerFreeIterator( /*@only@*/ HeaderIterator iter); */
typedef
/*@null@*/ Header (*HDRcopyload) (const void * uh)
/*@*/;
Header headerCopy(Header h); /** \ingroup header
void headerSort(Header h); * Read (and load) header from file handle.
Header headerLink(Header h); * @param fd file handle
int headerUsageCount(Header h); * @param magicp read (and verify) 8 bytes of (magic, 0)?
* @return header (or NULL on error)
*/
typedef
/*@null@*/ Header (*HDRhdrread) (FD_t fd, enum hMagic magicp)
/*@modifies fd @*/;
void headerCopyTags(Header headerFrom, Header headerTo, int_32 *tagstocopy) /** \ingroup header
; * Write (with unload) header to file handle.
* @param fd file handle
* @param h header
* @param magicp prefix write with 8 bytes of (magic, 0)?
* @return 0 on success, 1 on error
*/
typedef
int (*HDRhdrwrite) (FD_t fd, /*@null@*/ Header h, enum hMagic magicp)
/*@globals fileSystem @*/
/*@modifies fd, h, fileSystem @*/;
/* Entry Types */ /** \ingroup header
* Check if tag is in header.
* @param h header
* @param tag tag
* @return 1 on success, 0 on failure
*/
typedef
int (*HDRisentry) (/*@null@*/Header h, int_32 tag)
/*@*/;
#define RPM_MIN_TYPE 0 /** \ingroup header
#define RPM_NULL_TYPE 0 * Free data allocated when retrieved from header.
#define RPM_CHAR_TYPE 1 * @param h header
#define RPM_INT8_TYPE 2 * @param data address of data (or NULL)
#define RPM_INT16_TYPE 3 * @param type type of data (or -1 to force free)
#define RPM_INT32_TYPE 4 * @return NULL always
/* #define RPM_INT64_TYPE 5 ---- These aren't supported (yet) */ */
#define RPM_STRING_TYPE 6 typedef
#define RPM_BIN_TYPE 7 /*@null@*/ void * (*HDRfreetag) (Header h,
#define RPM_STRING_ARRAY_TYPE 8 /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
#define RPM_I18NSTRING_TYPE 9 /*@modifies data @*/;
#define RPM_MAX_TYPE 9
/* Tags -- general use tags should start at 1000 (RPM's tag space starts /** \ingroup header
there) */ * Retrieve tag value.
* Will never return RPM_I18NSTRING_TYPE! RPM_STRING_TYPE elements with
* RPM_I18NSTRING_TYPE equivalent entries are translated (if HEADER_I18NTAB
LE
* entry is present).
*
* @param h header
* @param tag tag
* @retval type address of tag value data type (or NULL)
* @retval p address of pointer to tag value(s) (or NULL)
* @retval c address of number of values (or NULL)
* @return 1 on success, 0 on failure
*/
typedef
int (*HDRget) (Header h, int_32 tag,
/*@null@*/ /*@out@*/ hTYP_t type,
/*@null@*/ /*@out@*/ void ** p,
/*@null@*/ /*@out@*/ hCNT_t c)
/*@modifies *type, *p, *c @*/;
#define HEADER_I18NTABLE 100 /** \ingroup header
* Retrieve tag value using header internal array.
* Get an entry using as little extra RAM as possible to return the tag val
ue.
* This is only an issue for RPM_STRING_ARRAY_TYPE.
*
* @param h header
* @param tag tag
* @retval type address of tag value data type (or NULL)
* @retval p address of pointer to tag value(s) (or NULL)
* @retval c address of number of values (or NULL)
* @return 1 on success, 0 on failure
*/
typedef
int (*HDRgetmin) (Header h, int_32 tag,
/*@null@*/ /*@out@*/ hTYP_t type,
/*@null@*/ /*@out@*/ hPTR_t * p,
/*@null@*/ /*@out@*/ hCNT_t c)
/*@modifies *type, *p, *c @*/;
/** \ingroup header
* Add tag to header.
* Duplicate tags are okay, but only defined for iteration (with the
* exceptions noted below). While you are allowed to add i18n string
* arrays through this function, you probably don't mean to. See
* headerAddI18NString() instead.
*
* @param h header
* @param tag tag
* @param type tag value data type
* @param p pointer to tag value(s)
* @param c number of values
* @return 1 on success, 0 on failure
*/
typedef
int (*HDRadd) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
/*@modifies h @*/;
/** \ingroup header
* Append element to tag array in header.
* Appends item p to entry w/ tag and type as passed. Won't work on
* RPM_STRING_TYPE. Any pointers into header memory returned from
* headerGetEntryMinMemory() for this entry are invalid after this
* call has been made!
*
* @param h header
* @param tag tag
* @param type tag value data type
* @param p pointer to tag value(s)
* @param c number of values
* @return 1 on success, 0 on failure
*/
typedef
int (*HDRappend) (Header h, int_32 tag, int_32 type, const void * p, int_32
c)
/*@modifies h @*/;
/** \ingroup header
* Add or append element to tag array in header.
* @todo Arg "p" should have const.
* @param h header
* @param tag tag
* @param type tag value data type
* @param p pointer to tag value(s)
* @param c number of values
* @return 1 on success, 0 on failure
*/
typedef
int (*HDRaddorappend) (Header h, int_32 tag, int_32 type, const void * p, i
nt_32 c)
/*@modifies h @*/;
/** \ingroup header
* Add locale specific tag to header.
* A NULL lang is interpreted as the C locale. Here are the rules:
* \verbatim
* - If the tag isn't in the header, it's added with the passed string
* as new value.
* - If the tag occurs multiple times in entry, which tag is affected
* by the operation is undefined.
* - If the tag is in the header w/ this language, the entry is
* *replaced* (like headerModifyEntry()).
* \endverbatim
* This function is intended to just "do the right thing". If you need
* more fine grained control use headerAddEntry() and headerModifyEntry().
*
* @param h header
* @param tag tag
* @param string tag value
* @param lang locale
* @return 1 on success, 0 on failure
*/
typedef
int (*HDRaddi18n) (Header h, int_32 tag, const char * string,
const char * lang)
/*@modifies h @*/;
/** \ingroup header
* Modify tag in header.
* If there are multiple entries with this tag, the first one gets replaced
.
* @param h header
* @param tag tag
* @param type tag value data type
* @param p pointer to tag value(s)
* @param c number of values
* @return 1 on success, 0 on failure
*/
typedef
int (*HDRmodify) (Header h, int_32 tag, int_32 type, const void * p, int_32
c)
/*@modifies h @*/;
/** \ingroup header
* Delete tag in header.
* Removes all entries of type tag from the header, returns 1 if none were
* found.
*
* @param h header
* @param tag tag
* @return 0 on success, 1 on failure (INCONSISTENT)
*/
typedef
int (*HDRremove) (Header h, int_32 tag)
/*@modifies h @*/;
/** \ingroup header
* Return formatted output string from header tags.
* The returned string must be free()d.
*
* @param h header
* @param fmt format to use
* @param tags array of tag name/value pairs
* @param extensions chained table of formatting extensions.
* @retval errmsg error message (if any)
* @return formatted output string (malloc'ed)
*/
typedef
/*@only@*/ char * (*HDRhdrsprintf) (Header h, const char * fmt,
const struct headerTagTableEntry_s * tags,
const struct headerSprintfExtension_s * extensions,
/*@null@*/ /*@out@*/ errmsg_t * errmsg)
/*@modifies *errmsg @*/;
/** \ingroup header
* Duplicate tag values from one header into another.
* @param headerFrom source header
* @param headerTo destination header
* @param tagstocopy array of tags that are copied
*/
typedef
void (*HDRcopytags) (Header headerFrom, Header headerTo, hTAG_t tagstocopy)
/*@modifies headerFrom, headerTo @*/;
/** \ingroup header
* Destroy header tag iterator.
* @param hi header tag iterator
* @return NULL always
*/
typedef
HeaderIterator (*HDRfreeiter) (/*@only@*/ HeaderIterator hi)
/*@modifies hi @*/;
/** \ingroup header
* Create header tag iterator.
* @param h header
* @return header tag iterator
*/
typedef
HeaderIterator (*HDRinititer) (Header h)
/*@modifies h */;
/** \ingroup header
* Return next tag from header.
* @param hi header tag iterator
* @retval tag address of tag
* @retval type address of tag value data type
* @retval p address of pointer to tag value(s)
* @retval c address of number of values
* @return 1 on success, 0 on failure
*/
typedef
int (*HDRnextiter) (HeaderIterator hi,
/*@null@*/ /*@out@*/ hTAG_t tag,
/*@null@*/ /*@out@*/ hTYP_t type,
/*@null@*/ /*@out@*/ hPTR_t * p,
/*@null@*/ /*@out@*/ hCNT_t c)
/*@modifies hi, *tag, *type, *p, *c @*/;
/** \ingroup header
* Header method vectors.
*/
typedef /*@abstract@*/ struct HV_s * HV_t;
struct HV_s {
HDRnew hdrnew;
HDRfree hdrfree;
HDRlink hdrlink;
HDRsort hdrsort;
HDRunsort hdrunsort;
HDRsizeof hdrsizeof;
HDRunload hdrunload;
HDRreload hdrreload;
HDRcopy hdrcopy;
HDRload hdrload;
HDRcopyload hdrcopyload;
HDRhdrread hdrread;
HDRhdrwrite hdrwrite;
HDRisentry hdrisentry;
HDRfreetag hdrfreetag;
HDRget hdrget;
HDRgetmin hdrgetmin;
HDRadd hdradd;
HDRappend hdrappend;
HDRaddorappend hdraddorappend;
HDRaddi18n hdraddi18n;
HDRmodify hdrmodify;
HDRremove hdrremove;
HDRhdrsprintf hdrsprintf;
HDRcopytags hdrcopytags;
HDRfreeiter hdrfreeiter;
HDRinititer hdrinititer;
HDRnextiter hdrnextiter;
HDRunlink hdrunlink;
/*@null@*/
void * hdrvecs;
/*@null@*/
void * hdrdata;
int hdrversion;
};
/** \ingroup header
* Free data allocated when retrieved from header.
* @deprecated Use headerFreeTag() instead.
* @todo Remove from API.
*
* @param data address of data (or NULL)
* @param type type of data (or -1 to force free)
* @return NULL always
*/
/*@unused@*/ static inline /*@null@*/
void * headerFreeData( /*@only@*/ /*@null@*/ const void * data, rpmTagType
type)
/*@modifies data @*/
{
if (data) {
/*@-branchstate@*/
if (type == -1 ||
type == RPM_STRING_ARRAY_TYPE ||
type == RPM_I18NSTRING_TYPE ||
type == RPM_BIN_TYPE)
free((void *)data);
/*@=branchstate@*/
}
return NULL;
}
#if !defined(__HEADER_PROTOTYPES__)
#include <hdrinline.h>
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* H_HEADER */ #endif /* H_HEADER */
 End of changes. 36 change blocks. 
132 lines changed or deleted 671 lines changed or added


 popt.h   popt.h 
/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING /** \file popt/popt.h
* \ingroup popt
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from file accompanying popt source distributions, available from
ftp://ftp.redhat.com/pub/code/popt */ ftp://ftp.rpm.org/pub/rpm/dist. */
#ifndef H_POPT #ifndef H_POPT
#define H_POPT #define H_POPT
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> /* for FILE * */ #include <stdio.h> /* for FILE * */
#define POPT_OPTION_DEPTH 10 #define POPT_OPTION_DEPTH 10
#define POPT_ARG_NONE 0 /** \ingroup popt
#define POPT_ARG_STRING 1 * \name Arg type identifiers
#define POPT_ARG_INT 2 */
#define POPT_ARG_LONG 3 /*@{*/
#define POPT_ARG_INCLUDE_TABLE 4 /* arg points to table */ #define POPT_ARG_NONE 0 /*!< no arg */
#define POPT_ARG_CALLBACK 5 /* table-wide callback... must be #define POPT_ARG_STRING 1 /*!< arg will be saved as st
ring */
#define POPT_ARG_INT 2 /*!< arg will be converted to int */
#define POPT_ARG_LONG 3 /*!< arg will be converted to long *
/
#define POPT_ARG_INCLUDE_TABLE 4 /*!< arg points to table */
#define POPT_ARG_CALLBACK 5 /*!< table-wide callback... must be
set first in table; arg points set first in table; arg points
to callback, descrip points to to callback, descrip points to
callback data to pass */ callback data to pass */
#define POPT_ARG_INTL_DOMAIN 6 /* set the translation domain #define POPT_ARG_INTL_DOMAIN 6 /*!< set the translation domain
for this table and any for this table and any
included tables; arg points included tables; arg points
to the domain string */ to the domain string */
#define POPT_ARG_VAL 7 /* arg should take value val */ #define POPT_ARG_VAL 7 /*!< arg should take value val */
#define POPT_ARG_FLOAT 8 /*!< arg will be converted t
o float */
#define POPT_ARG_DOUBLE 9 /*!< arg will be converted t
o double */
#define POPT_ARG_MASK 0x0000FFFF #define POPT_ARG_MASK 0x0000FFFF
#define POPT_ARGFLAG_ONEDASH 0x80000000 /* allow -longoption */ /*@}*/
#define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /* don't show in help/usage */
#define POPT_ARGFLAG_STRIP 0x20000000 /* strip this arg from argv (onl /** \ingroup popt
y applies to long args) */ * \name Arg modifiers
#define POPT_CBFLAG_PRE 0x80000000 /* call the callback bef */
ore parse */ /*@{*/
#define POPT_CBFLAG_POST 0x40000000 /* call the callback after parse #define POPT_ARGFLAG_ONEDASH 0x80000000 /*!< allow -longoption */
*/ #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /*!< don't show in help/usage *
#define POPT_CBFLAG_INC_DATA 0x20000000 /* use data from the include lin /
e, #define POPT_ARGFLAG_STRIP 0x20000000 /*!< strip this arg from argv(on
ly applies to long args) */
#define POPT_ARGFLAG_OPTIONAL 0x10000000 /*!< arg may be missing
*/
#define POPT_ARGFLAG_OR 0x08000000 /*!< arg will be or'ed *
/
#define POPT_ARGFLAG_NOR 0x09000000 /*!< arg will be nor'ed
*/
#define POPT_ARGFLAG_AND 0x04000000 /*!< arg will be and'ed
*/
#define POPT_ARGFLAG_NAND 0x05000000 /*!< arg will be nand'ed
*/
#define POPT_ARGFLAG_XOR 0x02000000 /*!< arg will be xor'ed
*/
#define POPT_ARGFLAG_NOT 0x01000000 /*!< arg will be negated
*/
#define POPT_ARGFLAG_LOGICALOPS \
(POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)
#define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR)
/*!< set arg bit(s) */
#define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND)
/*!< clear arg bit(s) */
#define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000 /*!< show default value
in --help */
/*@}*/
/** \ingroup popt
* \name Callback modifiers
*/
/*@{*/
#define POPT_CBFLAG_PRE 0x80000000 /*!< call the callback b
efore parse */
#define POPT_CBFLAG_POST 0x40000000 /*!< call the callback after par
se */
#define POPT_CBFLAG_INC_DATA 0x20000000 /*!< use data from the include l
ine,
not the subtable */ not the subtable */
#define POPT_CBFLAG_SKIPOPTION 0x10000000 /*!< don't callback with option
*/
#define POPT_CBFLAG_CONTINUE 0x08000000 /*!< continue callbacks with opt
ion */
/*@}*/
#define POPT_ERROR_NOARG -10 /** \ingroup popt
#define POPT_ERROR_BADOPT -11 * \name Error return values
#define POPT_ERROR_OPTSTOODEEP -13 */
#define POPT_ERROR_BADQUOTE -15 /* only from poptParseArgString() */ /*@{*/
#define POPT_ERROR_ERRNO -16 /* only from poptParseArgString() */ #define POPT_ERROR_NOARG -10 /*!< missing argument */
#define POPT_ERROR_BADNUMBER -17 #define POPT_ERROR_BADOPT -11 /*!< unknown option */
#define POPT_ERROR_OVERFLOW -18 #define POPT_ERROR_OPTSTOODEEP -13 /*!< aliases nested too deeply */
#define POPT_ERROR_BADQUOTE -15 /*!< error in paramter quoting */
#define POPT_ERROR_ERRNO -16 /*!< errno set, use strerror(errno)
*/
#define POPT_ERROR_BADNUMBER -17 /*!< invalid numeric value */
#define POPT_ERROR_OVERFLOW -18 /*!< number too large or too small *
/
#define POPT_ERROR_BADOPERATION -19 /*!< mutually exclusive logi
cal operations requested */
#define POPT_ERROR_NULLARG -20 /*!< opt->arg should not be
NULL */
#define POPT_ERROR_MALLOC -21 /*!< memory allocation faile
d */
/*@}*/
/* poptBadOption() flags */ /** \ingroup popt
#define POPT_BADOPTION_NOALIAS (1 << 0) /* don't go into an alias */ * \name poptBadOption() flags
*/
/*@{*/
#define POPT_BADOPTION_NOALIAS (1 << 0) /*!< don't go into an alias */
/*@}*/
/* poptGetContext() flags */ /** \ingroup popt
#define POPT_CONTEXT_NO_EXEC (1 << 0) /* ignore exec expansions */ * \name poptGetContext() flags
#define POPT_CONTEXT_KEEP_FIRST (1 << 1) /* pay attention to argv[0 */
] */ /*@{*/
#define POPT_CONTEXT_POSIXMEHARDER (1 << 2) /* options can't follow args */ #define POPT_CONTEXT_NO_EXEC (1 << 0) /*!< ignore exec expansions */
#define POPT_CONTEXT_KEEP_FIRST (1 << 1) /*!< pay attention to argv
[0] */
#define POPT_CONTEXT_POSIXMEHARDER (1 << 2) /*!< options can't follow args
*/
#define POPT_CONTEXT_ARG_OPTS (1 << 4) /*!< return args as options with va
lue 0 */
/*@}*/
/** \ingroup popt
*/
struct poptOption { struct poptOption {
/*@observer@*/ /*@null@*/ const char * longName; /* may be NULL */ /*@observer@*/ /*@null@*/ const char * longName; /*!< may be NULL */
char shortName; /* may be '\0' */ char shortName; /*!< may be '\0' */
int argInfo; int argInfo;
/*@shared@*/ /*@null@*/ void * arg; /* depends on argInf /*@shared@*/ /*@null@*/ void * arg; /*!< depends on argInfo */
o */ int val; /*!< 0 means don't return, just update flag
int val; /* 0 means don't return, just update flag */ */
/*@shared@*/ /*@null@*/ const char * descrip; /* description for a /*@observer@*/ /*@null@*/ const char * descrip; /*!< description for
utohelp -- may be NULL */ autohelp -- may be NULL */
/*@shared@*/ /*@null@*/ const char * argDescrip; /* argument descript /*@observer@*/ /*@null@*/ const char * argDescrip; /*!< argument descriptio
ion for autohelp */ n for autohelp */
}; };
/** \ingroup popt
* A popt alias argument for poptAddAlias().
*/
struct poptAlias { struct poptAlias {
/*@owned@*/ /*@null@*/ const char * longName; /* may be NULL */ /*@owned@*/ /*@null@*/ const char * longName; /*!< may be NULL */
char shortName; /* may be '\0' */ char shortName; /*!< may be '\0' */
int argc; int argc;
/*@owned@*/ const char ** argv; /* must be free()able */ /*@owned@*/ const char ** argv; /*!< must be free()able */
}; };
/** \ingroup popt
* A popt alias or exec argument for poptAddItem().
*/
typedef struct poptItem_s {
struct poptOption option; /*!< alias/exec name(s) and description. */
int argc; /*!< (alias) no. of args. */
/*@owned@*/ const char ** argv; /*!< (alias) args, must be free()abl
e. */
} * poptItem;
/** \ingroup popt
* \name Auto-generated help/usage
*/
/*@{*/
/**
* Empty table marker to enable displaying popt alias/exec options.
*/
/*@observer@*/ /*@checked@*/
extern struct poptOption poptAliasOptions[];
#define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptio
ns, \
0, "Options implemented via popt alias/exec:", NULL
},
/**
* Auto help table options.
*/
/*@observer@*/ /*@checked@*/
extern struct poptOption poptHelpOptions[]; extern struct poptOption poptHelpOptions[];
#define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions , \ #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions , \
0, "Help options", NULL }, 0, "Help options:", NULL },
typedef struct poptContext_s * poptContext; #define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL }
/*@}*/
/** \ingroup popt
*/
typedef /*@abstract@*/ struct poptContext_s * poptContext;
/** \ingroup popt
*/
#ifndef __cplusplus #ifndef __cplusplus
/*@-typeuse@*/
typedef struct poptOption * poptOption; typedef struct poptOption * poptOption;
/*@=typeuse@*/
#endif #endif
enum poptCallbackReason { POPT_CALLBACK_REASON_PRE, enum poptCallbackReason { POPT_CALLBACK_REASON_PRE,
POPT_CALLBACK_REASON_POST, POPT_CALLBACK_REASON_POST,
POPT_CALLBACK_REASON_OPTION }; POPT_CALLBACK_REASON_OPTION };
typedef void (*poptCallbackType)(poptContext con,
enum poptCallbackReason reason,
const struct poptOption * opt,
const char * arg, const void * data);
/*@only@*/ poptContext poptGetContext(/*@keep@*/ const char * name, #ifdef __cplusplus
int argc, /*@keep@*/ const char ** argv, extern "C" {
/*@keep@*/ const struct poptOption * options, int flags); #endif
void poptResetContext(poptContext con); /*@-type@*/
/* returns 'val' element, -1 on last item, POPT_ERROR_* on error */ /** \ingroup popt
int poptGetNextOpt(poptContext con); * Table callback prototype.
/* returns NULL if no argument is available */ * @param con context
/*@observer@*/ /*@null@*/ const char * poptGetOptArg(poptContext con); * @param reason reason for callback
/* returns NULL if no more options are available */ * @param opt option that triggered callback
/*@observer@*/ /*@null@*/ const char * poptGetArg(poptContext con); * @param arg @todo Document.
/*@observer@*/ /*@null@*/ const char * poptPeekArg(poptContext con); * @param data @todo Document.
/*@observer@*/ /*@null@*/ const char ** poptGetArgs(poptContext con); */
/* returns the option which caused the most recent error */ typedef void (*poptCallbackType) (poptContext con,
/*@observer@*/ const char * poptBadOption(poptContext con, int flags); enum poptCallbackReason reason,
void poptFreeContext( /*@only@*/ poptContext con); /*@null@*/ const struct poptOption * opt,
int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv); /*@null@*/ const char * arg,
int poptAddAlias(poptContext con, struct poptAlias alias, int flags); /*@null@*/ const void * data)
int poptReadConfigFile(poptContext con, const char * fn); /*@*/;
/* like above, but reads /etc/popt and $HOME/.popt along with environment
vars */ /** \ingroup popt
int poptReadDefaultConfig(poptContext con, int useEnv); * Initialize popt context.
/* argv should be freed -- this allows ', ", and \ quoting, but ' is treate * @param name
d * @param argc no. of arguments
the same as " and both may include \ quotes */ * @param argv argument array
int poptDupArgv(int argc, const char **argv, * @param options address of popt option table
/*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr); * @param flags or'd POPT_CONTEXT_* bits
* @return initialized popt context
*/
/*@only@*/ /*@null@*/ poptContext poptGetContext(
/*@dependent@*/ /*@keep@*/ const char * name,
int argc, /*@dependent@*/ /*@keep@*/ const char ** argv,
/*@dependent@*/ /*@keep@*/ const struct poptOption * options
,
int flags)
/*@*/;
/** \ingroup popt
* Reinitialize popt context.
* @param con context
*/
void poptResetContext(/*@null@*/poptContext con)
/*@modifies con @*/;
/** \ingroup popt
* Return value of next option found.
* @param con context
* @return next option val, -1 on last item, POPT_ERROR_* on er
ror
*/
int poptGetNextOpt(/*@null@*/poptContext con)
/*@globals fileSystem@*/
/*@modifies con, fileSystem @*/;
/*@-redecl@*/
/** \ingroup popt
* Return next option argument (if any).
* @param con context
* @return option argument, NULL if no more options are availab
le
*/
/*@observer@*/ /*@null@*/ const char * poptGetOptArg(/*@null@*/poptContext
con)
/*@modifies con @*/;
/** \ingroup popt
* Return current option's argument.
* @param con context
* @return option argument, NULL if no more options are availab
le
*/
/*@observer@*/ /*@null@*/ const char * poptGetArg(/*@null@*/poptContext con
)
/*@modifies con @*/;
/** \ingroup popt
* Peek at current option's argument.
* @param con context
* @return option argument
*/
/*@observer@*/ /*@null@*/ const char * poptPeekArg(/*@null@*/poptContext co
n)
/*@*/;
/** \ingroup popt
* Return remaining arguments.
* @param con context
* @return argument array, terminated with NULL
*/
/*@observer@*/ /*@null@*/ const char ** poptGetArgs(/*@null@*/poptContext c
on)
/*@modifies con @*/;
/** \ingroup popt
* Return the option which caused the most recent error.
* @param con context
* @return offending option
*/
/*@observer@*/ const char * poptBadOption(/*@null@*/poptContext con, int fl
ags)
/*@*/;
/*@=redecl@*/
/** \ingroup popt
* Destroy context.
* @param con context
* @return NULL always
*/
/*@null@*/ poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext c
on)
/*@modifies con @*/;
/** \ingroup popt
* Add arguments to context.
* @param con context
* @param argv argument array, NULL terminated
* @return 0 on success, POPT_ERROR_OPTSTOODEEP on failure
*/
int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv)
/*@modifies con @*/;
/** \ingroup popt
* Add alias to context.
* @todo Pass alias by reference, not value.
* @deprecated Use poptAddItem instead.
* @param con context
* @param alias alias to add
* @param flags (unused)
* @return 0 on success
*/
/*@unused@*/
int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
/*@modifies con @*/;
/** \ingroup popt
* Add alias/exec item to context.
* @param con context
* @param item alias/exec item to add
* @param flags 0 for alias, 1 for exec
* @return 0 on success
*/
int poptAddItem(poptContext con, poptItem newItem, int flags)
/*@modifies con @*/;
/** \ingroup popt
* Read configuration file.
* @param con context
* @param fn file name to read
* @return 0 on success, POPT_ERROR_ERRNO on failure
*/
int poptReadConfigFile(poptContext con, const char * fn)
/*@globals fileSystem@*/
/*@modifies fileSystem,
con->execs, con->numExecs @*/;
/** \ingroup popt
* Read default configuration from /etc/popt and $HOME/.popt.
* @param con context
* @param useEnv (unused)
* @return 0 on success, POPT_ERROR_ERRNO on failure
*/
int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
/*@globals fileSystem@*/
/*@modifies fileSystem,
con->execs, con->numExecs @*/;
/** \ingroup popt
* Duplicate an argument array.
* @note: The argument array is malloc'd as a single area, so only argv mus
t
* be free'd.
*
* @param argc no. of arguments
* @param argv argument array
* @retval argcPtr address of returned no. of arguments
* @retval argvPtr address of returned argument array
* @return 0 on success, POPT_ERROR_NOARG on failure
*/
int poptDupArgv(int argc, /*@null@*/ const char **argv,
/*@null@*/ /*@out@*/ int * argcPtr,
/*@null@*/ /*@out@*/ const char *** argvPtr)
/*@modifies *argcPtr, *argvPtr @*/;
/** \ingroup popt
* Parse a string into an argument array.
* The parse allows ', ", and \ quoting, but ' is treated the same as " and
* both may include \ quotes.
* @note: The argument array is malloc'd as a single area, so only argv mus
t
* be free'd.
*
* @param s string to parse
* @retval argcPtr address of returned no. of arguments
* @retval argvPtr address of returned argument array
*/
int poptParseArgvString(const char * s, int poptParseArgvString(const char * s,
/*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr); /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr)
/*@observer@*/ const char *const poptStrerror(const int error); /*@modifies *argcPtr, *argvPtr @*/;
void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
; /** \ingroup popt
void poptPrintHelp(poptContext con, FILE * f, int flags); * Return formatted error string for popt failure.
void poptPrintUsage(poptContext con, FILE * f, int flags); * @param error popt error
void poptSetOtherOptionHelp(poptContext con, const char * text); * @return error string
/*@observer@*/ const char * poptGetInvocationName(poptContext con); */
/* shuffles argv pointers to remove stripped args, returns new argc */ /*@-redecl@*/
int poptStrippedArgv(poptContext con, int argc, char **argv); /*@observer@*/ const char *const poptStrerror(const int error)
/*@*/;
/*@=redecl@*/
/** \ingroup popt
* Limit search for executables.
* @param con context
* @param path single path to search for executables
* @param allowAbsolute absolute paths only?
*/
void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
/*@modifies con @*/;
/** \ingroup popt
* Print detailed description of options.
* @param con context
* @param fp ouput file handle
* @param flags (unused)
*/
void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/;
/** \ingroup popt
* Print terse description of options.
* @param con context
* @param fp ouput file handle
* @param flags (unused)
*/
void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/;
/** \ingroup popt
* Provide text to replace default "[OPTION...]" in help/usage output.
* @param con context
* @param text replacement text
*/
/*@-fcnuse@*/
void poptSetOtherOptionHelp(poptContext con, const char * text)
/*@modifies con @*/;
/*@=fcnuse@*/
/** \ingroup popt
* Return argv[0] from context.
* @param con context
* @return argv[0]
*/
/*@-redecl -fcnuse@*/
/*@observer@*/ const char * poptGetInvocationName(poptContext con)
/*@*/;
/*@=redecl =fcnuse@*/
/** \ingroup popt
* Shuffle argv pointers to remove stripped args, returns new argc.
* @param con context
* @param argc no. of args
* @param argv arg vector
* @return new argc
*/
/*@-fcnuse@*/
int poptStrippedArgv(poptContext con, int argc, char ** argv)
/*@modifies *argv @*/;
/*@=fcnuse@*/
/*@=type@*/
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 27 change blocks. 
92 lines changed or deleted 443 lines changed or added


 rpmio.h   rpmio.h 
#ifndef H_RPMIO #ifndef H_RPMIO
#define H_RPMIO #define H_RPMIO
/** \ingroup rpmio
* \file rpmio/rpmio.h
*
*/
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
/*@-noparams@*/
#include <glob.h> #include <glob.h>
/*@=noparams@*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
/**
*/
#ifdef NOTYET
typedef /*@abstract@*/ struct pgpDig_s * pgpDig;
#endif
/** \ingroup rpmio
* Hide libio API lossage.
* The libio interface changed after glibc-2.1.3 to pass the seek offset
* argument as a pointer rather than as an off_t. The snarl below defines
* typedefs to isolate the lossage.
* API unchanged.
*/
/*@{*/
#if !defined(__LCLINT__) && defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC
_MINOR__ == 2
#define USE_COOKIE_SEEK_POINTER 1
typedef _IO_off64_t _libio_off_t;
typedef _libio_off_t * _libio_pos_t;
#else
typedef off_t _libio_off_t;
typedef off_t _libio_pos_t;
#endif
/*@}*/
/** \ingroup rpmio
*/
typedef /*@abstract@*/ /*@refcounted@*/ struct _FD_s * FD_t; typedef /*@abstract@*/ /*@refcounted@*/ struct _FD_s * FD_t;
/** \ingroup rpmio
*/
typedef /*@observer@*/ struct FDIO_s * FDIO_t; typedef /*@observer@*/ struct FDIO_s * FDIO_t;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef ssize_t fdio_read_function_t (void *cookie, char *buf, size_t nbyte /** \ingroup rpmio
s); * \name RPMIO Vectors.
typedef ssize_t fdio_write_function_t (void *cookie, const char *buf, size_ */
t nbytes); /*@{*/
typedef int fdio_seek_function_t (void *cookie, off_t offset, int whence);
typedef int fdio_close_function_t (void *cookie);
typedef /*@null@*/ FD_t fdio_ref_function_t ( /*@only@*/ void * cookie, /**
const char * msg, const char * file, unsigned line); */
typedef /*@null@*/ FD_t fdio_deref_function_t ( /*@only@*/ FD_t fd, typedef ssize_t (*fdio_read_function_t) (void *cookie, char *buf, size_t nb
const char * msg, const char * file, unsigned line); ytes)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
typedef /*@null@*/ FD_t fdio_new_function_t (const char * msg, /**
const char * file, unsigned line); */
typedef ssize_t (*fdio_write_function_t) (void *cookie, const char *buf, si
ze_t nbytes)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
typedef int fdio_fileno_function_t (void * cookie); /**
*/
typedef int (*fdio_seek_function_t) (void *cookie, _libio_pos_t pos, int wh
ence)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
typedef FD_t fdio_open_function_t (const char * path, int flags, mode_t mod /**
e); */
typedef FD_t fdio_fopen_function_t (const char * path, const char * fmode); typedef int (*fdio_close_function_t) (void *cookie)
typedef void * fdio_ffileno_function_t (FD_t fd); /*@globals fileSystem @*/
typedef int fdio_fflush_function_t (FD_t fd); /*@modifies *cookie, fileSystem @*/;
typedef int fdio_mkdir_function_t (const char * path, mode_t mode); /**
typedef int fdio_chdir_function_t (const char * path); */
typedef int fdio_rmdir_function_t (const char * path); typedef /*@only@*/ /*@null@*/ FD_t (*fdio_ref_function_t) ( /*@only@*/ void
typedef int fdio_rename_function_t (const char * oldpath, const char * newp * cookie,
ath); const char * msg, const char * file, unsigned line)
typedef int fdio_unlink_function_t (const char * path); /*@globals fileSystem @*/
/*@modifies fileSystem @*/;
typedef int fdio_stat_function_t (const char * path, struct stat * st); /**
typedef int fdio_lstat_function_t (const char * path, struct stat * st); */
typedef int fdio_access_function_t (const char * path, int amode); typedef /*@only@*/ /*@null@*/ FD_t (*fdio_deref_function_t) ( /*@only@*/ FD
_t fd,
const char * msg, const char * file, unsigned line)
/*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
/**
*/
typedef /*@only@*/ /*@null@*/ FD_t (*fdio_new_function_t) (const char * msg
,
const char * file, unsigned line)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
typedef int (*fdio_fileno_function_t) (void * cookie)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
/**
*/
typedef FD_t (*fdio_open_function_t) (const char * path, int flags, mode_t
mode)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
typedef FD_t (*fdio_fopen_function_t) (const char * path, const char * fmod
e)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
typedef void * (*fdio_ffileno_function_t) (FD_t fd)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
typedef int (*fdio_fflush_function_t) (FD_t fd)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/*@}*/
/** \ingroup rpmrpc
* \name RPMRPC Vectors.
*/
/*@{*/
/**
*/
typedef int (*fdio_mkdir_function_t) (const char * path, mode_t mode)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
typedef int (*fdio_chdir_function_t) (const char * path)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
typedef int (*fdio_rmdir_function_t) (const char * path)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
typedef int (*fdio_rename_function_t) (const char * oldpath, const char * n
ewpath)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
typedef int (*fdio_unlink_function_t) (const char * path)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/*@-typeuse@*/
/**
*/
typedef int (*fdio_stat_function_t) (const char * path, /*@out@*/ struct st
at * st)
/*@globals fileSystem @*/
/*@modifies *st, fileSystem @*/;
/**
*/
typedef int (*fdio_lstat_function_t) (const char * path, /*@out@*/ struct s
tat * st)
/*@globals fileSystem @*/
/*@modifies *st, fileSystem @*/;
/**
*/
typedef int (*fdio_access_function_t) (const char * path, int amode)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/*@=typeuse@*/
/*@}*/
/** \ingroup rpmio
*/
struct FDIO_s { struct FDIO_s {
fdio_read_function_t * read; fdio_read_function_t read;
fdio_write_function_t * write; fdio_write_function_t write;
fdio_seek_function_t * seek; fdio_seek_function_t seek;
fdio_close_function_t * close; fdio_close_function_t close;
fdio_ref_function_t * _fdref; fdio_ref_function_t _fdref;
fdio_deref_function_t * _fdderef; fdio_deref_function_t _fdderef;
fdio_new_function_t * _fdnew; fdio_new_function_t _fdnew;
fdio_fileno_function_t * _fileno; fdio_fileno_function_t _fileno;
fdio_open_function_t * _open; fdio_open_function_t _open;
fdio_fopen_function_t * _fopen; fdio_fopen_function_t _fopen;
fdio_ffileno_function_t * _ffileno; fdio_ffileno_function_t _ffileno;
fdio_fflush_function_t * _fflush; fdio_fflush_function_t _fflush;
fdio_mkdir_function_t * _mkdir; fdio_mkdir_function_t _mkdir;
fdio_chdir_function_t * _chdir; fdio_chdir_function_t _chdir;
fdio_rmdir_function_t * _rmdir; fdio_rmdir_function_t _rmdir;
fdio_rename_function_t * _rename; fdio_rename_function_t _rename;
fdio_unlink_function_t * _unlink; fdio_unlink_function_t _unlink;
}; };
/*@observer@*/ const char * Fstrerror(FD_t fd); /** \ingroup rpmio
* \name RPMIO Interface.
*/
/*@{*/
size_t Fread (/*@out@*/ void * buf, size_t size, size_t nmemb, FD_t fd); /**
size_t Fwrite (const void *buf, size_t size, size_t nmemb, FD_t fd); * strerror(3) clone.
int Fseek (FD_t fd, long int offset, int whence); */
int Fclose ( /*@killref@*/ FD_t fd); /*@-redecl@*/
FD_t Fdopen (FD_t fd, const char * fmode); /*@observer@*/ const char * Fstrerror(/*@null@*/ FD_t fd)
FD_t Fopen (const char * path, const char * fmode); /*@*/;
/*@=redecl@*/
int Fflush (FD_t fd); /**
int Ferror (FD_t fd); * fread(3) clone.
int Fileno (FD_t fd); */
size_t Fread(/*@out@*/ void * buf, size_t size, size_t nmemb, FD_t fd)
/*@globals fileSystem @*/
/*@modifies fd, *buf, fileSystem @*/;
int Fcntl (FD_t, int op, void *lip); /**
ssize_t Pread (FD_t fd, /*@out@*/ void * buf, size_t count, off_t offset); * fwrite(3) clone.
ssize_t Pwrite (FD_t fd, const void * buf, size_t count, off_t offset); */
int Mkdir (const char * path, mode_t mode); size_t Fwrite(const void * buf, size_t size, size_t nmemb, FD_t fd)
int Chdir (const char * path); /*@globals fileSystem @*/
int Rmdir (const char * path); /*@modifies fd, fileSystem @*/;
int Rename (const char * oldpath, const char * newpath);
int Link (const char * oldpath, const char * newpath);
int Unlink (const char * path);
int Readlink(const char * path, char * buf, size_t bufsiz);
int Stat (const char * path, struct stat * st); /**
int Lstat (const char * path, struct stat * st); * fseek(3) clone.
int Access (const char * path, int amode); */
int Fseek(FD_t fd, _libio_off_t offset, int whence)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
int Glob (const char * pattern, int flags, /**
int errfunc(const char * epath, int eerrno), glob_t * pglob) * fclose(3) clone.
; */
void Globfree(glob_t * pglob); int Fclose( /*@killref@*/ FD_t fd)
/*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
DIR * Opendir (const char * name); /**
struct dirent * Readdir (DIR * dir); */
int Closedir(DIR * dir); /*@null@*/ FD_t Fdopen(FD_t ofd, const char * fmode)
/*@globals fileSystem @*/
/*@modifies ofd, fileSystem @*/;
/*@observer@*/ extern FDIO_t gzdio; /**
* fopen(3) clone.
*/
/*@null@*/ FD_t Fopen(/*@null@*/ const char * path,
/*@null@*/ const char * fmode)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
void fdPush (FD_t fd, FDIO_t io, void * fp, int fdno); /**
void fdPop (FD_t fd); * fflush(3) clone.
*/
int Fflush(/*@null@*/ FD_t fd)
/*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
/*@dependent@*/ /*@null@*/ void * fdGetFp (FD_t fd); /**
void fdSetFdno(FD_t fd, int fdno); * ferror(3) clone.
void fdSetContentLength(FD_t fd, ssize_t contentLength); */
off_t fdSize (FD_t fd); int Ferror(/*@null@*/ FD_t fd)
void fdSetSyserrno(FD_t fd, int syserrno, const void * errcookie); /*@*/;
/*@null@*/ const FDIO_t fdGetIo(FD_t fd); /**
void fdSetIo (FD_t fd, FDIO_t io); * fileno(3) clone.
*/
int Fileno(FD_t fd)
/*@globals fileSystem @*/
/*@modifies fileSystem@*/;
int fdGetRdTimeoutSecs(FD_t fd); /**
* fcntl(2) clone.
*/
int Fcntl(FD_t fd, int op, void *lip)
/*@globals fileSystem @*/
/*@modifies fd, *lip, fileSystem @*/;
long int fdGetCpioPos(FD_t fd); /*@}*/
void fdSetCpioPos(FD_t fd, long int cpioPos);
/** \ingroup rpmrpc
* \name RPMRPC Interface.
*/
/*@{*/
/**
* mkdir(2) clone.
*/
int Mkdir(const char * path, mode_t mode)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
* chdir(2) clone.
*/
int Chdir(const char * path)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
* rmdir(2) clone.
*/
int Rmdir(const char * path)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
* rename(2) clone.
*/
int Rename(const char * oldpath, const char * newpath)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
* link(2) clone.
*/
int Link(const char * oldpath, const char * newpath)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
* unlink(2) clone.
*/
int Unlink(const char * path)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
* readlink(2) clone.
*/
int Readlink(const char * path, /*@out@*/ char * buf, size_t bufsiz)
/*@globals fileSystem @*/
/*@modifies *buf, fileSystem @*/;
/**
* stat(2) clone.
*/
int Stat(const char * path, /*@out@*/ struct stat * st)
/*@globals fileSystem @*/
/*@modifies *st, fileSystem @*/;
/**
* lstat(2) clone.
*/
int Lstat(const char * path, /*@out@*/ struct stat * st)
/*@globals fileSystem @*/
/*@modifies *st, fileSystem @*/;
/**
* access(2) clone.
*/
int Access(const char * path, int amode)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
* glob(3) clone.
*/
int Glob(const char * pattern, int flags,
int errfunc(const char * epath, int eerrno),
/*@out@*/ glob_t * pglob)
/*@globals fileSystem @*/
/*@modifies *pglob, fileSystem @*/;
/**
* globfree(3) clone.
*/
void Globfree( /*@only@*/ glob_t * pglob)
/*@globals fileSystem @*/
/*@modifies *pglob, fileSystem @*/;
/**
* opendir(3) clone.
*/
/*@null@*/
DIR * Opendir(const char * path)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
* readdir(3) clone.
*/
/*@null@*/ struct dirent * Readdir(DIR * dir)
/*@globals fileSystem @*/
/*@modifies *dir, fileSystem @*/;
/**
* closedir(3) clone.
*/
int Closedir(/*@only@*/ DIR * dir)
/*@globals fileSystem @*/
/*@modifies *dir, fileSystem @*/;
/*@}*/
/** \ingroup rpmio
* \name RPMIO Utilities.
*/
/*@{*/
/**
*/
off_t fdSize(FD_t fd)
/*@globals fileSystem @*/
/*@modifies fd, fileSystem@*/;
/**
*/
/*@null@*/ FD_t fdDup(int fdno)
/*@globals fileSystem @*/
/*@modifies fileSystem@*/;
extern /*@null@*/ FD_t fdDup(int fdno);
#ifdef UNUSED #ifdef UNUSED
extern /*@null@*/ FILE *fdFdopen( /*@only@*/ void * cookie, const char * mo de); /*@null@*/ FILE *fdFdopen( /*@only@*/ void * cookie, const char * mode);
#endif #endif
/* Legacy interfaces needed by gnorpm, rpmfind et al */ /* XXX Legacy interfaces needed by gnorpm, rpmfind et al */
int fdFileno(void * cookie); /*@-exportlocal@*/
/*@null@*/ FD_t fdOpen(const char *path, int flags, mode_t mode); /**
ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count); */
ssize_t fdWrite(void * cookie, const char * buf, size_t count); #ifndef H_RPMIO_INTERNAL /* XXX avoid gcc warning */
int fdClose( /*@only@*/ void * cookie); /*@unused@*/ int fdFileno(void * cookie)
/*@*/;
#define fdFileno(_fd) fdio->_fileno(_fd)
#endif
/**
*/
/*@null@*/ FD_t fdOpen(const char *path, int flags, mode_t mode)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
#define fdOpen(_path, _flags, _mode) fdio->_open((_path), (_flags
), (_mode))
/**
*/
ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count)
/*@globals fileSystem @*/
/*@modifies *cookie, *buf, fileSystem @*/;
#define fdRead(_fd, _buf, _count) fdio->read((_fd), (_buf), (_
count))
/**
*/
ssize_t fdWrite(void * cookie, const char * buf, size_t count)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
#define fdWrite(_fd, _buf, _count) fdio->write((_fd), (_buf), (
_count))
/**
*/
int fdClose( /*@only@*/ void * cookie)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
#define fdCLose(_fd) fdio->close(_fd)
/**
*/
/*@unused@*/
/*@only@*/ /*@null@*/
FD_t fdLink (/*@only@*/ void * cookie, const char * msg)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
#define fdLink(_fd, _msg) fdio->_fdref(_fd, _msg, __FILE__, __ LINE__) #define fdLink(_fd, _msg) fdio->_fdref(_fd, _msg, __FILE__, __ LINE__)
/**
*/
/*@unused@*/
/*@only@*/ /*@null@*/
FD_t fdFree(/*@only@*/ FD_t fd, const char * msg)
/*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
#define fdFree(_fd, _msg) fdio->_fdderef(_fd, _msg, __FILE__, __LINE__) #define fdFree(_fd, _msg) fdio->_fdderef(_fd, _msg, __FILE__, __LINE__)
/**
*/
/*@unused@*/
/*@only@*/ /*@null@*/
FD_t fdNew (const char * msg)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
#define fdNew(_msg) fdio->_fdnew(_msg, __FILE__, __LINE_ _) #define fdNew(_msg) fdio->_fdnew(_msg, __FILE__, __LINE_ _)
int fdWritable(FD_t fd, int secs); /**
int fdReadable(FD_t fd, int secs); */
int fdWritable(FD_t fd, int secs)
/*@globals errno, fileSystem @*/
/*@modifies fd, errno, fileSystem @*/;
/*@observer@*/ extern FDIO_t fdio; /**
/*@observer@*/ extern FDIO_t fpio; */
int fdReadable(FD_t fd, int secs)
/*@globals errno @*/
/*@modifies fd, errno @*/;
/*@=exportlocal@*/
/* /**
* Support for FTP and HTTP I/O. * FTP and HTTP error codes.
*/ */
#define FTPERR_BAD_SERVER_RESPONSE -1 /*@-typeuse@*/
#define FTPERR_SERVER_IO_ERROR -2 typedef enum ftperrCode_e {
#define FTPERR_SERVER_TIMEOUT -3 FTPERR_BAD_SERVER_RESPONSE = -1, /*!< Bad server response */
#define FTPERR_BAD_HOST_ADDR -4 FTPERR_SERVER_IO_ERROR = -2, /*!< Server I/O error */
#define FTPERR_BAD_HOSTNAME -5 FTPERR_SERVER_TIMEOUT = -3, /*!< Server timeout */
#define FTPERR_FAILED_CONNECT -6 FTPERR_BAD_HOST_ADDR = -4, /*!< Unable to lookup server host ad
#define FTPERR_FILE_IO_ERROR -7 dress */
#define FTPERR_PASSIVE_ERROR -8 FTPERR_BAD_HOSTNAME = -5, /*!< Unable to lookup server
#define FTPERR_FAILED_DATA_CONNECT -9 host name */
#define FTPERR_FILE_NOT_FOUND -10 FTPERR_FAILED_CONNECT = -6, /*!< Failed to connect to server */
#define FTPERR_NIC_ABORT_IN_PROGRESS -11 FTPERR_FILE_IO_ERROR = -7, /*!< Failed to establish data connec
#define FTPERR_UNKNOWN -100 tion to server */
FTPERR_PASSIVE_ERROR = -8, /*!< I/O error to local file */
FTPERR_FAILED_DATA_CONNECT = -9, /*!< Error setting remote server to
passive mode */
FTPERR_FILE_NOT_FOUND = -10, /*!< File not found on server */
FTPERR_NIC_ABORT_IN_PROGRESS= -11, /*!< Abort in progress */
FTPERR_UNKNOWN = -100 /*!< Unknown or unexpected error */
} ftperrCode;
/*@=typeuse@*/
/*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd); /**
/*@observer@*/ const char * urlStrerror(const char * url); */
/*@-redecl@*/
/*@observer@*/ const char *const ftpStrerror(int errorNumber) /*@*/;
/*@=redecl@*/
int ufdCopy(FD_t sfd, FD_t tfd); /**
int ufdGetFile( /*@killref@*/ FD_t sfd, FD_t tfd); */
/*@observer@*/ const char *const ftpStrerror(int errorNumber); /*@unused@*/
/*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd)
/*@modifies fd @*/;
int timedRead(FD_t fd, /*@out@*/ void * bufptr, int length); /**
#define timedRead ufdio->read */
/*@-redecl@*/
/*@unused@*/
/*@observer@*/ const char * urlStrerror(const char * url) /*@*/;
/*@=redecl@*/
/*@observer@*/ extern FDIO_t ufdio; /**
*/
/*@-exportlocal@*/
int ufdCopy(FD_t sfd, FD_t tfd)
/*@globals fileSystem @*/
/*@modifies sfd, tfd, fileSystem @*/;
/*@=exportlocal@*/
/* /**
* Support for first fit File Allocation I/O.
*/ */
int ufdGetFile( /*@killref@*/ FD_t sfd, FD_t tfd)
/*@globals fileSystem @*/
/*@modifies sfd, tfd, fileSystem @*/;
long int fadGetFileSize(FD_t fd); /**
void fadSetFileSize(FD_t fd, long int fileSize); */
unsigned int fadGetFirstFree(FD_t fd); /*@unused@*/ int timedRead(FD_t fd, /*@out@*/ void * bufptr, int length)
void fadSetFirstFree(FD_t fd, unsigned int firstFree); /*@globals fileSystem @*/
/*@modifies fd, *bufptr, fileSystem @*/;
#define timedRead ufdio->read
/*@observer@*/ extern FDIO_t fadio; /*@-exportlocal@*/
/**
*/
/*@observer@*/ /*@unchecked@*/ extern FDIO_t fdio;
#ifdef HAVE_ZLIB_H /**
/*
* Support for GZIP library.
*/ */
/*@observer@*/ /*@unchecked@*/ extern FDIO_t fpio;
#include <zlib.h> /**
*/
/*@observer@*/ /*@unchecked@*/ extern FDIO_t ufdio;
/*@observer@*/ extern FDIO_t gzdio; /**
*/
/*@observer@*/ /*@unchecked@*/ extern FDIO_t gzdio;
#endif /* HAVE_ZLIB_H */ /**
*/
/*@observer@*/ /*@unchecked@*/ extern FDIO_t bzdio;
#ifdef HAVE_BZLIB_H /**
/*
* Support for BZIP2 library.
*/ */
/*@observer@*/ /*@unchecked@*/ extern FDIO_t fadio;
/*@=exportlocal@*/
/*@}*/
#include <bzlib.h> /*@unused@*/ static inline int xislower(int c) /*@*/ {
return (c >= 'a' && c <= 'z');
}
/*@unused@*/ static inline int xisupper(int c) /*@*/ {
return (c >= 'A' && c <= 'Z');
}
/*@unused@*/ static inline int xisalpha(int c) /*@*/ {
return (xislower(c) || xisupper(c));
}
/*@unused@*/ static inline int xisdigit(int c) /*@*/ {
return (c >= '0' && c <= '9');
}
/*@unused@*/ static inline int xisalnum(int c) /*@*/ {
return (xisalpha(c) || xisdigit(c));
}
/*@unused@*/ static inline int xisblank(int c) /*@*/ {
return (c == ' ' || c == '\t');
}
/*@unused@*/ static inline int xisspace(int c) /*@*/ {
return (xisblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v'
);
}
/*@observer@*/ extern FDIO_t bzdio; /*@unused@*/ static inline int xtolower(int c) /*@*/ {
return ((xisupper(c)) ? (c | ('a' - 'A')) : c);
}
/*@unused@*/ static inline int xtoupper(int c) /*@*/ {
return ((xislower(c)) ? (c & ~('a' - 'A')) : c);
}
#endif /* HAVE_BZLIB_H */ /** \ingroup rpmio
* Locale insensitive strcasecmp(3).
*/
int xstrcasecmp(const char * s1, const char * s2) /*@*/;
/** \ingroup rpmio
* Locale insensitive strncasecmp(3).
*/
int xstrncasecmp(const char *s1, const char * s2, size_t n) /*@*/;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* H_RPMIO */ #endif /* H_RPMIO */
 End of changes. 59 change blocks. 
140 lines changed or deleted 586 lines changed or added


 rpmlib.h   rpmlib.h 
#ifndef H_RPMLIB #ifndef H_RPMLIB
#define H_RPMLIB #define H_RPMLIB
/* This is the *only* module users of rpmlib should need to include */ /** \ingroup rpmcli rpmrc rpmdep rpmtrans rpmdb lead signature header paylo
ad dbi
* \file lib/rpmlib.h
*/
/* and it shouldn't need these :-( */ #include "rpmio.h"
#include "rpmmessages.h"
#include "rpmerr.h"
#include "header.h"
#include "popt.h"
#include <rpmio.h> /**
#include <dbindex.h> * Package read return codes.
#include <header.h> */
#include <popt.h> typedef enum rpmRC_e {
RPMRC_OK = 0,
RPMRC_BADMAGIC = 1,
RPMRC_FAIL = 2,
RPMRC_BADSIZE = 3,
RPMRC_SHORTREAD = 4
} rpmRC;
/*@-redecl@*/
/*@checked@*/
extern struct MacroContext_s * rpmGlobalMacroContext;
/*@checked@*/
extern struct MacroContext_s * rpmCLIMacroContext;
/*@observer@*/ /*@checked@*/
extern const char * RPMVERSION;
/*@observer@*/ /*@checked@*/
extern const char * rpmNAME;
/*@observer@*/ /*@checked@*/
extern const char * rpmEVR;
/*@checked@*/
extern int rpmFLAGS;
/*@=redecl@*/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
int rpmReadPackageInfo(FD_t fd, /*@out@*/ Header * signatures, /**
/*@out@*/ Header * hdr); * Wrapper to free(3), hides const compilation noise, permit NULL, return N
int rpmReadPackageHeader(FD_t fd, /*@out@*/ Header * hdr, ULL.
/*@out@*/ int * isSource, /*@out@*/ int * major, /*@out@*/ int * min * @param p memory to free
or); * @return NULL always
*/
/*@unused@*/ static inline /*@null@*/
void * _free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p)
/*@modifies p @*/
{
if (p != NULL) free((void *)p);
return NULL;
}
int headerNVR(Header h, /*@out@*/ const char **np, /*@out@*/ const char **v /**
p, * Return package signatures and header from file handle.
/*@out@*/ const char **rp); * @deprecated Signature tags are appended to header in rpm-4.0.2.
* @todo Eliminate.
* @param fd file handle
* @retval sigp address of signature header (or NULL)
* @retval hdrp address of header (or NULL)
* @return rpmRC return code
*/
rpmRC rpmReadPackageInfo(FD_t fd, /*@null@*/ /*@out@*/ Header * sigp,
/*@null@*/ /*@out@*/ Header * hdrp)
/*@globals fileSystem @*/
/*@modifies fd, *sigp, *hdrp, fileSystem @*/;
void rpmBuildFileList(Header h, /*@out@*/ const char *** fileListPtr, /**
/*@out@*/ int * fileCountPtr); * Return package header and lead info from file handle.
* @param fd file handle
* @retval hdrp address of header (or NULL)
* @retval isSource address to return lead source flag (or NULL)
* @retval major address to return lead major (or NULL)
* @retval minor address to return lead minor (or NULL)
* @return rpmRC return code
*/
rpmRC rpmReadPackageHeader(FD_t fd, /*@null@*/ /*@out@*/ Header * hdrp,
/*@null@*/ /*@out@*/ int * isSource,
/*@null@*/ /*@out@*/ int * major,
/*@null@*/ /*@out@*/ int * minor)
/*@globals fileSystem @*/
/*@modifies fd, *hdrp, *isSource, *major, *minor, fileSystem @*/;
/* /** \ingroup header
* XXX This is a "dressed" entry to headerGetEntry to do: * Return name, version, release strings from header.
* @param h header
* @retval np address of name pointer (or NULL)
* @retval vp address of version pointer (or NULL)
* @retval rp address of release pointer (or NULL)
* @return 0 always
*/
int headerNVR(Header h,
/*@null@*/ /*@out@*/ const char ** np,
/*@null@*/ /*@out@*/ const char ** vp,
/*@null@*/ /*@out@*/ const char ** rp)
/*@modifies *np, *vp, *rp @*/;
/** \ingroup header
* Translate and merge legacy signature tags into header.
* @param h header
* @param sig signature header
*/
void headerMergeLegacySigs(Header h, const Header sig)
/*@modifies h @*/;
/** \ingroup header
* Regenerate signature header.
* @param h header
* @return regenerated signature header
*/
Header headerRegenSigHeader(const Header h)
/*@*/;
/**
* Retrieve file names from header.
* The representation of file names in package headers changed in rpm-4.0.
* Originally, file names were stored as an array of paths. In rpm-4.0,
* file names are stored as separate arrays of dirname's and basename's,
* with a dirname index to associate the correct dirname with each basname.
* This function is used to retrieve file names independent of how the
* file names are represented in the package header.
*
* @param h header
* @retval fileListPtr address of array of file names
* @retval fileCountPtr address of number of files
*/
void rpmBuildFileList(Header h, /*@out@*/ const char *** fileListPtr,
/*@out@*/ int * fileCountPtr)
/*@modifies *fileListPtr, *fileCountPtr @*/;
/**
* Retrieve tag info from header.
* This is a "dressed" entry to headerGetEntry to do:
* 1) DIRNAME/BASENAME/DIRINDICES -> FILENAMES tag conversions. * 1) DIRNAME/BASENAME/DIRINDICES -> FILENAMES tag conversions.
* 2) i18n lookaside (if enabled). * 2) i18n lookaside (if enabled).
*
* @param h header
* @param tag tag
* @retval type address of tag value data type
* @retval p address of pointer to tag value(s)
* @retval c address of number of values
* @return 0 on success, 1 on bad magic, 2 on error
*/ */
int rpmHeaderGetEntry(Header h, int_32 tag, /*@out@*/ int_32 *type, int rpmHeaderGetEntry(Header h, int_32 tag, /*@out@*/ int_32 *type,
/*@out@*/ void **p, /*@out@*/int_32 *c); /*@out@*/ void **p, /*@out@*/ int_32 *c)
/*@modifies *type, *p, *c @*/;
/* 0 = success */ /**
/* 1 = bad magic */ * Retrieve tag info from header.
/* 2 = error */ * Yet Another "dressed" entry to headerGetEntry in order to unify
* signature/header tag retrieval.
* @deprecated Signature tags are now duplicated into header when installed
.
* @todo Eliminate from API.
* @param leadp rpm lead
* @param h header
* @param sigs signatures
* @param tag tag
* @retval type address of tag value data type
* @retval p address of pointer to tag value(s)
* @retval c address of number of values
* @return 0 on success, 1 on bad magic, 2 on error
*/
/*@unused@*/
int rpmPackageGetEntry(void *leadp, Header sigs, Header h,
int_32 tag, int_32 *type, void **p, int_32 *c)
/*@modifies h, *type, *p, *c @*/;
extern const struct headerTagTableEntry rpmTagTable[]; /**
* Automatically generated table of tag name/value pairs.
*/
/*@-redecl@*/
/*@observer@*/ /*@unchecked@*/
extern const struct headerTagTableEntry_s rpmTagTable[];
/*@=redecl@*/
/**
* Number of entries in rpmTagTable.
*/
/*@-redecl@*/
/*@unchecked@*/
extern const int rpmTagTableSize; extern const int rpmTagTableSize;
/*@=redecl@*/
/* this chains to headerDefaultFormats[] */ /**
extern const struct headerSprintfExtension rpmHeaderFormats[]; * Table of query format extensions.
* @note Chains to headerDefaultFormats[].
*/
/*@-redecl@*/
/*@observer@*/ /*@unchecked@*/
extern const struct headerSprintfExtension_s rpmHeaderFormats[];
/*@=redecl@*/
/* these tags are for both the database and packages */ /**
/* none of these can be 0 !! */ * Pseudo-tags used by the rpmdb iterator API.
*/
#define RPMDBI_PACKAGES 0 /*!< Installed package heade
rs. */
#define RPMDBI_DEPENDS 1 /*!< Dependency resolution c
ache. */
#define RPMDBI_LABEL 2 /*!< Fingerprint search mark
er. */
#define RPMDBI_ADDED 3 /*!< Added package headers.
*/
#define RPMDBI_REMOVED 4 /*!< Removed package headers
. */
#define RPMDBI_AVAILABLE 5 /*!< Available package heade
rs. */
#define RPMTAG_NAME 1000 /**
#define RPMTAG_VERSION 1001 * Tags identify data in package headers.
#define RPMTAG_RELEASE 1002 * @note tags should not have value 0!
#define RPMTAG_EPOCH 1003 */
#define RPMTAG_SERIAL RPMTAG_EPOCH /* backward comaptib typedef enum rpmTag_e {
ility */
#define RPMTAG_SUMMARY 1004 RPMTAG_HEADERIMAGE = HEADER_IMAGE, /*!< Current image.
#define RPMTAG_DESCRIPTION 1005 */
#define RPMTAG_BUILDTIME 1006 RPMTAG_HEADERSIGNATURES = HEADER_SIGNATURES, /*!< Signatures. */
#define RPMTAG_BUILDHOST 1007 RPMTAG_HEADERIMMUTABLE = HEADER_IMMUTABLE, /*!< Original image.
#define RPMTAG_INSTALLTIME 1008 */
#define RPMTAG_SIZE 1009 /*@-enummemuse@*/
#define RPMTAG_DISTRIBUTION 1010 RPMTAG_HEADERREGIONS = HEADER_REGIONS, /*!< Regions. */
#define RPMTAG_VENDOR 1011
#define RPMTAG_GIF 1012 RPMTAG_HEADERI18NTABLE = HEADER_I18NTABLE, /*!< I18N string locales
#define RPMTAG_XPM 1013 . */
#define RPMTAG_LICENSE 1014 /*@=enummemuse@*/
#define RPMTAG_COPYRIGHT RPMTAG_LICENSE /* backward comaptib
ility */ /* Retrofit (and uniqify) signature tags for use by tagName() and rpmQuery.
#define RPMTAG_PACKAGER 1015 */
#define RPMTAG_GROUP 1016 /* the md5 sum was broken *twice* on big endian machines */
#define RPMTAG_CHANGELOG 1017 /* internal */ /* XXX 2nd underscore prevents tagTable generation */
#define RPMTAG_SOURCE 1018 RPMTAG_SIG_BASE = HEADER_SIGBASE,
#define RPMTAG_PATCH 1019 RPMTAG_SIGSIZE = RPMTAG_SIG_BASE+1,
#define RPMTAG_URL 1020 RPMTAG_SIGLEMD5_1 = RPMTAG_SIG_BASE+2, /*!< internal */
#define RPMTAG_OS 1021 RPMTAG_SIGPGP = RPMTAG_SIG_BASE+3,
#define RPMTAG_ARCH 1022 RPMTAG_SIGLEMD5_2 = RPMTAG_SIG_BASE+4, /*!< internal */
#define RPMTAG_PREIN 1023 RPMTAG_SIGMD5 = RPMTAG_SIG_BASE+5,
#define RPMTAG_POSTIN 1024 RPMTAG_SIGGPG = RPMTAG_SIG_BASE+6,
#define RPMTAG_PREUN 1025 RPMTAG_SIGPGP5 = RPMTAG_SIG_BASE+7, /*!< internal */
#define RPMTAG_POSTUN 1026
#define RPMTAG_OLDFILENAMES 1027 /* obsolete */ /*@-enummemuse@*/
#define RPMTAG_FILESIZES 1028 RPMTAG_BADSHA1HEADER = RPMTAG_SIG_BASE+8, /*!< internal */
#define RPMTAG_FILESTATES 1029 /*@=enummemuse@*/
#define RPMTAG_FILEMODES 1030 RPMTAG_SHA1HEADER = RPMTAG_SIG_BASE+9,
#define RPMTAG_FILEUIDS 1031 /* internal */
#define RPMTAG_FILEGIDS 1032 /* internal */ RPMTAG_NAME = 1000,
#define RPMTAG_FILERDEVS 1033 RPMTAG_VERSION = 1001,
#define RPMTAG_FILEMTIMES 1034 RPMTAG_RELEASE = 1002,
#define RPMTAG_FILEMD5S 1035 RPMTAG_EPOCH = 1003,
#define RPMTAG_FILELINKTOS 1036 #define RPMTAG_SERIAL RPMTAG_EPOCH /* backward comaptibility */
#define RPMTAG_FILEFLAGS 1037 RPMTAG_SUMMARY = 1004,
#define RPMTAG_ROOT 1038 /* obsolete */ RPMTAG_DESCRIPTION = 1005,
#define RPMTAG_FILEUSERNAME 1039 RPMTAG_BUILDTIME = 1006,
#define RPMTAG_FILEGROUPNAME 1040 RPMTAG_BUILDHOST = 1007,
#define RPMTAG_EXCLUDE 1041 /* internal - depricate RPMTAG_INSTALLTIME = 1008,
d */ RPMTAG_SIZE = 1009,
#define RPMTAG_EXCLUSIVE 1042 /* internal - depricate RPMTAG_DISTRIBUTION = 1010,
d */ RPMTAG_VENDOR = 1011,
#define RPMTAG_ICON 1043 RPMTAG_GIF = 1012,
#define RPMTAG_SOURCERPM 1044 RPMTAG_XPM = 1013,
#define RPMTAG_FILEVERIFYFLAGS 1045 RPMTAG_LICENSE = 1014,
#define RPMTAG_ARCHIVESIZE 1046 #define RPMTAG_COPYRIGHT RPMTAG_LICENSE /* backward comaptibility */
#define RPMTAG_PROVIDENAME 1047 RPMTAG_PACKAGER = 1015,
#define RPMTAG_PROVIDES RPMTAG_PROVIDENAME /* backward comaptib RPMTAG_GROUP = 1016,
ility */ /*@-enummemuse@*/
#define RPMTAG_REQUIREFLAGS 1048 RPMTAG_CHANGELOG = 1017, /*!< internal */
#define RPMTAG_REQUIRENAME 1049 /*@=enummemuse@*/
#define RPMTAG_REQUIREVERSION 1050 RPMTAG_SOURCE = 1018,
#define RPMTAG_NOSOURCE 1051 /* internal */ RPMTAG_PATCH = 1019,
#define RPMTAG_NOPATCH 1052 /* internal */ RPMTAG_URL = 1020,
#define RPMTAG_CONFLICTFLAGS 1053 RPMTAG_OS = 1021,
#define RPMTAG_CONFLICTNAME 1054 RPMTAG_ARCH = 1022,
#define RPMTAG_CONFLICTVERSION 1055 RPMTAG_PREIN = 1023,
#define RPMTAG_DEFAULTPREFIX 1056 /* internal - deprecate RPMTAG_POSTIN = 1024,
d */ RPMTAG_PREUN = 1025,
#define RPMTAG_BUILDROOT 1057 RPMTAG_POSTUN = 1026,
#define RPMTAG_INSTALLPREFIX 1058 /* internal - deprecate RPMTAG_OLDFILENAMES = 1027, /* obsolete */
d */ RPMTAG_FILESIZES = 1028,
#define RPMTAG_EXCLUDEARCH 1059 RPMTAG_FILESTATES = 1029,
#define RPMTAG_EXCLUDEOS 1060 RPMTAG_FILEMODES = 1030,
#define RPMTAG_EXCLUSIVEARCH 1061 RPMTAG_FILEUIDS = 1031, /*!< internal */
#define RPMTAG_EXCLUSIVEOS 1062 RPMTAG_FILEGIDS = 1032, /*!< internal */
#define RPMTAG_AUTOREQPROV 1063 /* internal */ RPMTAG_FILERDEVS = 1033,
#define RPMTAG_RPMVERSION 1064 RPMTAG_FILEMTIMES = 1034,
#define RPMTAG_TRIGGERSCRIPTS 1065 RPMTAG_FILEMD5S = 1035,
#define RPMTAG_TRIGGERNAME 1066 RPMTAG_FILELINKTOS = 1036,
#define RPMTAG_TRIGGERVERSION 1067 RPMTAG_FILEFLAGS = 1037,
#define RPMTAG_TRIGGERFLAGS 1068 /*@-enummemuse@*/
#define RPMTAG_TRIGGERINDEX 1069 RPMTAG_ROOT = 1038, /*!< internal - obsolete */
#define RPMTAG_VERIFYSCRIPT 1079 /*@=enummemuse@*/
#define RPMTAG_CHANGELOGTIME 1080 RPMTAG_FILEUSERNAME = 1039,
#define RPMTAG_CHANGELOGNAME 1081 RPMTAG_FILEGROUPNAME = 1040,
#define RPMTAG_CHANGELOGTEXT 1082 /*@-enummemuse@*/
#define RPMTAG_BROKENMD5 1083 /* internal */ RPMTAG_EXCLUDE = 1041, /*!< internal - obsolete */
#define RPMTAG_PREREQ 1084 /* internal */ RPMTAG_EXCLUSIVE = 1042, /*!< internal - obsolete */
#define RPMTAG_PREINPROG 1085 /*@=enummemuse@*/
#define RPMTAG_POSTINPROG 1086 RPMTAG_ICON = 1043,
#define RPMTAG_PREUNPROG 1087 RPMTAG_SOURCERPM = 1044,
#define RPMTAG_POSTUNPROG 1088 RPMTAG_FILEVERIFYFLAGS = 1045,
#define RPMTAG_BUILDARCHS 1089 RPMTAG_ARCHIVESIZE = 1046,
#define RPMTAG_OBSOLETENAME 1090 RPMTAG_PROVIDENAME = 1047,
#define RPMTAG_PROVIDES RPMTAG_PROVIDENAME /* backward comaptib
ility */
RPMTAG_REQUIREFLAGS = 1048,
RPMTAG_REQUIRENAME = 1049,
RPMTAG_REQUIREVERSION = 1050,
RPMTAG_NOSOURCE = 1051, /*!< internal */
RPMTAG_NOPATCH = 1052, /*!< internal */
RPMTAG_CONFLICTFLAGS = 1053,
RPMTAG_CONFLICTNAME = 1054,
RPMTAG_CONFLICTVERSION = 1055,
RPMTAG_DEFAULTPREFIX = 1056, /*!< internal - deprecated */
RPMTAG_BUILDROOT = 1057, /*!< internal */
RPMTAG_INSTALLPREFIX = 1058, /*!< internal - deprecated */
RPMTAG_EXCLUDEARCH = 1059,
RPMTAG_EXCLUDEOS = 1060,
RPMTAG_EXCLUSIVEARCH = 1061,
RPMTAG_EXCLUSIVEOS = 1062,
RPMTAG_AUTOREQPROV = 1063, /*!< internal */
RPMTAG_RPMVERSION = 1064,
RPMTAG_TRIGGERSCRIPTS = 1065,
RPMTAG_TRIGGERNAME = 1066,
RPMTAG_TRIGGERVERSION = 1067,
RPMTAG_TRIGGERFLAGS = 1068,
RPMTAG_TRIGGERINDEX = 1069,
RPMTAG_VERIFYSCRIPT = 1079,
RPMTAG_CHANGELOGTIME = 1080,
RPMTAG_CHANGELOGNAME = 1081,
RPMTAG_CHANGELOGTEXT = 1082,
/*@-enummemuse@*/
RPMTAG_BROKENMD5 = 1083, /*!< internal */
/*@=enummemuse@*/
RPMTAG_PREREQ = 1084, /*!< internal */
RPMTAG_PREINPROG = 1085,
RPMTAG_POSTINPROG = 1086,
RPMTAG_PREUNPROG = 1087,
RPMTAG_POSTUNPROG = 1088,
RPMTAG_BUILDARCHS = 1089,
RPMTAG_OBSOLETENAME = 1090,
#define RPMTAG_OBSOLETES RPMTAG_OBSOLETENAME /* backward comaptib ility */ #define RPMTAG_OBSOLETES RPMTAG_OBSOLETENAME /* backward comaptib ility */
#define RPMTAG_VERIFYSCRIPTPROG 1091 RPMTAG_VERIFYSCRIPTPROG = 1091,
#define RPMTAG_TRIGGERSCRIPTPROG 1092 RPMTAG_TRIGGERSCRIPTPROG = 1092,
#define RPMTAG_DOCDIR 1093 /* internal */ RPMTAG_DOCDIR = 1093, /*!< internal */
#define RPMTAG_COOKIE 1094 RPMTAG_COOKIE = 1094,
#define RPMTAG_FILEDEVICES 1095 RPMTAG_FILEDEVICES = 1095,
#define RPMTAG_FILEINODES 1096 RPMTAG_FILEINODES = 1096,
#define RPMTAG_FILELANGS 1097 RPMTAG_FILELANGS = 1097,
#define RPMTAG_PREFIXES 1098 RPMTAG_PREFIXES = 1098,
#define RPMTAG_INSTPREFIXES 1099 RPMTAG_INSTPREFIXES = 1099,
#define RPMTAG_TRIGGERIN 1100 /* internal */ RPMTAG_TRIGGERIN = 1100, /*!< internal */
#define RPMTAG_TRIGGERUN 1101 /* internal */ RPMTAG_TRIGGERUN = 1101, /*!< internal */
#define RPMTAG_TRIGGERPOSTUN 1102 /* internal */ RPMTAG_TRIGGERPOSTUN = 1102, /*!< internal */
#define RPMTAG_AUTOREQ 1103 /* internal */ RPMTAG_AUTOREQ = 1103, /*!< internal */
#define RPMTAG_AUTOPROV 1104 /* internal */ RPMTAG_AUTOPROV = 1104, /*!< internal */
#define RPMTAG_CAPABILITY 1105 /* unused internal */ /*@-enummemuse@*/
#define RPMTAG_SOURCEPACKAGE 1106 /* internal */ RPMTAG_CAPABILITY = 1105, /*!< internal - obsolete */
#define RPMTAG_OLDORIGFILENAMES 1107 /* obsolete */ /*@=enummemuse@*/
#define RPMTAG_BUILDPREREQ 1108 /* internal */ RPMTAG_SOURCEPACKAGE = 1106, /*!< internal */
#define RPMTAG_BUILDREQUIRES 1109 /* internal */ /*@-enummemuse@*/
#define RPMTAG_BUILDCONFLICTS 1110 /* internal */ RPMTAG_OLDORIGFILENAMES = 1107, /*!< internal - obsolete */
#define RPMTAG_BUILDMACROS 1111 /*@=enummemuse@*/
#define RPMTAG_PROVIDEFLAGS 1112 RPMTAG_BUILDPREREQ = 1108, /*!< internal */
#define RPMTAG_PROVIDEVERSION 1113 RPMTAG_BUILDREQUIRES = 1109, /*!< internal */
#define RPMTAG_OBSOLETEFLAGS 1114 RPMTAG_BUILDCONFLICTS = 1110, /*!< internal */
#define RPMTAG_OBSOLETEVERSION 1115 /*@-enummemuse@*/
#define RPMTAG_DIRINDEXES 1116 RPMTAG_BUILDMACROS = 1111, /*!< internal */
#define RPMTAG_BASENAMES 1117 /*@=enummemuse@*/
#define RPMTAG_DIRNAMES 1118 RPMTAG_PROVIDEFLAGS = 1112,
#define RPMTAG_ORIGDIRINDEXES 1119 /* internal */ RPMTAG_PROVIDEVERSION = 1113,
#define RPMTAG_ORIGBASENAMES 1120 /* internal */ RPMTAG_OBSOLETEFLAGS = 1114,
#define RPMTAG_ORIGDIRNAMES 1121 /* internal */ RPMTAG_OBSOLETEVERSION = 1115,
#define RPMTAG_OPTFLAGS 1122 RPMTAG_DIRINDEXES = 1116,
#define RPMTAG_DISTURL 1123 RPMTAG_BASENAMES = 1117,
#define RPMTAG_PAYLOADFORMAT 1124 RPMTAG_DIRNAMES = 1118,
#define RPMTAG_PAYLOADCOMPRESSOR 1125 RPMTAG_ORIGDIRINDEXES = 1119, /*!< internal */
#define RPMTAG_PAYLOADFLAGS 1126 RPMTAG_ORIGBASENAMES = 1120, /*!< internal */
RPMTAG_ORIGDIRNAMES = 1121, /*!< internal */
RPMTAG_OPTFLAGS = 1122,
RPMTAG_DISTURL = 1123,
RPMTAG_PAYLOADFORMAT = 1124,
RPMTAG_PAYLOADCOMPRESSOR = 1125,
RPMTAG_PAYLOADFLAGS = 1126,
RPMTAG_MULTILIBS = 1127,
RPMTAG_INSTALLTID = 1128,
RPMTAG_REMOVETID = 1129,
RPMTAG_SHA1RHN = 1130, /*!< internal */
RPMTAG_RHNPLATFORM = 1131,
RPMTAG_PLATFORM = 1132,
/*@-enummemuse@*/
RPMTAG_FIRSTFREE_TAG /*!< internal */
/*@=enummemuse@*/
} rpmTag;
#define RPMTAG_FIRSTFREE_TAG 1127 /* internal */
#define RPMTAG_EXTERNAL_TAG 1000000 #define RPMTAG_EXTERNAL_TAG 1000000
#define RPMFILE_STATE_NORMAL 0 /**
#define RPMFILE_STATE_REPLACED 1 * File States (when installed).
#define RPMFILE_STATE_NOTINSTALLED 2 */
#define RPMFILE_STATE_NETSHARED 3 typedef enum rpmfileState_e {
RPMFILE_STATE_NORMAL = 0,
RPMFILE_STATE_REPLACED = 1,
RPMFILE_STATE_NOTINSTALLED = 2,
RPMFILE_STATE_NETSHARED = 3
} rpmfileState;
/* these can be ORed together */ /**
#define RPMFILE_CONFIG (1 << 0) * File Attributes.
#define RPMFILE_DOC (1 << 1) */
#define RPMFILE_DONOTUSE (1 << 2) typedef enum rpmfileAttrs_e {
#define RPMFILE_MISSINGOK (1 << 3) /*@-enummemuse@*/
#define RPMFILE_NOREPLACE (1 << 4) RPMFILE_NONE = 0,
#define RPMFILE_SPECFILE (1 << 5) /*@=enummemuse@*/
#define RPMFILE_GHOST (1 << 6) RPMFILE_CONFIG = (1 << 0), /*!< from %%config */
#define RPMFILE_LICENSE (1 << 7) RPMFILE_DOC = (1 << 1), /*!< from %%doc */
#define RPMFILE_README (1 << 8) /*@-enummemuse@*/
RPMFILE_DONOTUSE = (1 << 2), /*!< @todo (unimplemented) from %don
otuse. */
/*@=enummemuse@*/
RPMFILE_MISSINGOK = (1 << 3), /*!< from %%config(missingok) */
RPMFILE_NOREPLACE = (1 << 4), /*!< from %%config(noreplace) */
RPMFILE_SPECFILE = (1 << 5), /*!< @todo (unnecessary) marks 1st f
ile in srpm. */
RPMFILE_GHOST = (1 << 6), /*!< from %%ghost */
RPMFILE_LICENSE = (1 << 7), /*!< from %%license */
RPMFILE_README = (1 << 8), /*!< from %%readme */
RPMFILE_EXCLUDE = (1 << 9) /*!< from %%exclude */
} rpmfileAttrs;
#define RPMFILE_MULTILIB_SHIFT 9
#define RPMFILE_MULTILIB(N) ((N) << RPMFILE_MULTILIB_SHI
FT)
#define RPMFILE_MULTILIB_MASK RPMFILE_MULTILIB(7)
#define RPMVERIFY_NONE 0 #define RPMFILE_ALL ~(RPMFILE_NONE)
#define RPMVERIFY_MD5 (1 << 0)
#define RPMVERIFY_FILESIZE (1 << 1)
#define RPMVERIFY_LINKTO (1 << 2)
#define RPMVERIFY_USER (1 << 3)
#define RPMVERIFY_GROUP (1 << 4)
#define RPMVERIFY_MTIME (1 << 5)
#define RPMVERIFY_MODE (1 << 6)
#define RPMVERIFY_RDEV (1 << 7)
#define RPMVERIFY_READLINKFAIL (1 << 28)
#define RPMVERIFY_READFAIL (1 << 29)
#define RPMVERIFY_LSTATFAIL (1 << 30)
#define RPMVERIFY_ALL ~(RPMVERIFY_NONE) /* XXX Check file flags for multilib marker. */
#define isFileMULTILIB(_fflags) ((_fflags) & RPMFILE_MULTILI
B_MASK)
/**
* Dependency Attributes.
*/
typedef enum rpmsenseFlags_e {
RPMSENSE_ANY = 0,
/*@-enummemuse@*/
RPMSENSE_SERIAL = (1 << 0), /*!< @todo Legacy. */
/*@=enummemuse@*/
RPMSENSE_LESS = (1 << 1),
RPMSENSE_GREATER = (1 << 2),
RPMSENSE_EQUAL = (1 << 3),
RPMSENSE_PROVIDES = (1 << 4), /* only used internally by builds */
RPMSENSE_CONFLICTS = (1 << 5), /* only used internally by builds */
RPMSENSE_PREREQ = (1 << 6), /*!< @todo Legacy. */
RPMSENSE_OBSOLETES = (1 << 7), /* only used internally by builds */
RPMSENSE_INTERP = (1 << 8), /*!< Interpreter used by scriptlet.
*/
RPMSENSE_SCRIPT_PRE = ((1 << 9)|RPMSENSE_PREREQ), /*!< %pre depe
ndency. */
RPMSENSE_SCRIPT_POST = ((1 << 10)|RPMSENSE_PREREQ), /*!< %post dependen
cy. */
RPMSENSE_SCRIPT_PREUN = ((1 << 11)|RPMSENSE_PREREQ), /*!< %preun depend
ency. */
RPMSENSE_SCRIPT_POSTUN = ((1 << 12)|RPMSENSE_PREREQ), /*!< %postun depe
ndency. */
RPMSENSE_SCRIPT_VERIFY = (1 << 13), /*!< %verify dependency. */
RPMSENSE_FIND_REQUIRES = (1 << 14), /*!< find-requires generated depend
ency. */
RPMSENSE_FIND_PROVIDES = (1 << 15), /*!< find-provides generated depend
ency. */
RPMSENSE_TRIGGERIN = (1 << 16), /*!< %triggerin dependency. */
RPMSENSE_TRIGGERUN = (1 << 17), /*!< %triggerun dependency. */
RPMSENSE_TRIGGERPOSTUN = (1 << 18), /*!< %triggerpostun dependen
cy. */
RPMSENSE_MULTILIB = (1 << 19),
RPMSENSE_SCRIPT_PREP = (1 << 20), /*!< %prep build dependency. */
RPMSENSE_SCRIPT_BUILD = (1 << 21), /*!< %build build dependency. */
RPMSENSE_SCRIPT_INSTALL = (1 << 22),/*!< %install build dependency. */
RPMSENSE_SCRIPT_CLEAN = (1 << 23), /*!< %clean build dependency. */
RPMSENSE_RPMLIB = ((1 << 24) | RPMSENSE_PREREQ), /*!< rpmlib(feature
) dependency. */
/*@-enummemuse@*/
RPMSENSE_TRIGGERPREIN = (1 << 25), /*!< @todo Implement %triggerprein.
*/
/*@=enummemuse@*/
/*@-enummemuse@*/
RPMSENSE_KEYRING = (1 << 26)
/*@=enummemuse@*/
} rpmsenseFlags;
#define RPMSENSE_ANY 0
#define RPMSENSE_SERIAL (1 << 0) /* eliminated, backward com
patibilty */
#define RPMSENSE_LESS (1 << 1)
#define RPMSENSE_GREATER (1 << 2)
#define RPMSENSE_EQUAL (1 << 3)
#define RPMSENSE_PROVIDES (1 << 4) /* only used internally by
builds */
#define RPMSENSE_CONFLICTS (1 << 5) /* only used internally by
builds */
#define RPMSENSE_PREREQ (1 << 6)
#define RPMSENSE_OBSOLETES (1 << 7) /* only used internally by
builds */
#define RPMSENSE_SENSEMASK 15 /* Mask to get senses, ie s erial, */ #define RPMSENSE_SENSEMASK 15 /* Mask to get senses, ie s erial, */
/* less, greater, equal. */ /* less, greater, equal. */
#define RPMSENSE_TRIGGERIN (1 << 16) #define RPMSENSE_TRIGGER \
#define RPMSENSE_TRIGGERUN (1 << 17) (RPMSENSE_TRIGGERIN | RPMSENSE_TRIGGERUN | RPMSENSE_TRIGGERPOSTUN)
#define RPMSENSE_TRIGGERPOSTUN (1 << 18)
#define RPMSENSE_TRIGGER (RPMSENSE_TRIGGERIN | RPMSENSE_TRIGG
ERUN | \
RPMSENSE_TRIGGERPOSTUN)
/* Stuff for maintaining "variables" like SOURCEDIR, BUILDDIR, etc */ #define isDependsMULTILIB(_dflags) ((_dflags) & RPMSENSE_MULTIL IB)
/* #define RPMVAR_SOURCEDIR 0 -- No longer used */ #define _ALL_REQUIRES_MASK (\
/* #define RPMVAR_BUILDDIR 1 -- No longer used */ RPMSENSE_INTERP | \
/* #define RPMVAR_DOCDIR 2 -- No longer used */ RPMSENSE_SCRIPT_PRE | \
RPMSENSE_SCRIPT_POST | \
RPMSENSE_SCRIPT_PREUN | \
RPMSENSE_SCRIPT_POSTUN | \
RPMSENSE_SCRIPT_VERIFY | \
RPMSENSE_FIND_REQUIRES | \
RPMSENSE_SCRIPT_PREP | \
RPMSENSE_SCRIPT_BUILD | \
RPMSENSE_SCRIPT_INSTALL | \
RPMSENSE_SCRIPT_CLEAN | \
RPMSENSE_RPMLIB | \
RPMSENSE_KEYRING )
#define _notpre(_x) ((_x) & ~RPMSENSE_PREREQ)
#define _INSTALL_ONLY_MASK \
_notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB|RPMSEN
SE_KEYRING)
#define _ERASE_ONLY_MASK \
_notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
#define isLegacyPreReq(_x) (((_x) & _ALL_REQUIRES_MASK) == RPMSENSE
_PREREQ)
#define isInstallPreReq(_x) ((_x) & _INSTALL_ONLY_MASK)
#define isErasePreReq(_x) ((_x) & _ERASE_ONLY_MASK)
/* ==================================================================== */
/** \name RPMRC */
/*@{*/
/* Stuff for maintaining "variables" like SOURCEDIR, BUILDDIR, etc */
#define RPMVAR_OPTFLAGS 3 #define RPMVAR_OPTFLAGS 3
/* #define RPMVAR_TOPDIR 4 -- No longer used */
/* #define RPMVAR_SPECDIR 5 -- No longer used */
/* #define RPMVAR_ROOT 6 -- No longer used */
/* #define RPMVAR_RPMDIR 7 -- No longer used */
/* #define RPMVAR_SRPMDIR 8 -- No longer used */
/* #define RPMVAR_ARCHSENSITIVE 9 -- No longer used */
/* #define RPMVAR_REQUIREDISTRIBUTION 10 -- No longer used */
/* #define RPMVAR_REQUIREGROUP 11 -- No longer used */
/* #define RPMVAR_REQUIREVENDOR 12 -- No longer used */
/* #define RPMVAR_DISTRIBUTION 13 -- No longer used */
/* #define RPMVAR_VENDOR 14 -- No longer used */
/* #define RPMVAR_MESSAGELEVEL 15 -- No longer used */
/* #define RPMVAR_REQUIREICON 16 -- No longer used */
/* #define RPMVAR_TIMECHECK 17 -- No longer used */
/* #define RPMVAR_SIGTYPE 18 -- No longer used */
/* #define RPMVAR_PGP_PATH 19 -- No longer used */
/* #define RPMVAR_PGP_NAME 20 -- No longer used */
/* #define RPMVAR_PGP_SECRING 21 -- No longer used */
/* #define RPMVAR_PGP_PUBRING 22 -- No longer used */
/* #define RPMVAR_EXCLUDEDOCS 23 -- No longer used */
/* #define RPMVAR_BUILDARCH 24 -- No longer used */
/* #define RPMVAR_BUILDOS 25 -- No longer used */
/* #define RPMVAR_BUILDROOT 26 */
/* #define RPMVAR_DBPATH 27 -- No longer used */
/* #define RPMVAR_PACKAGER 28 -- No longer used */
/* #define RPMVAR_FTPPROXY 29 -- No longer used */
/* #define RPMVAR_TMPPATH 30 -- No longer used */
/* #define RPMVAR_CPIOBIN 31 -- No longer used */
/* #define RPMVAR_FTPPORT 32 -- No longer used */
/* #define RPMVAR_NETSHAREDPATH 33 -- No longer used */
/* #define RPMVAR_DEFAULTDOCDIR 34 -- No longer used */
/* #define RPMVAR_FIXPERMS 35 -- No longer used */
/* #define RPMVAR_GZIPBIN 36 -- No longer used */
/* #define RPMVAR_RPMFILENAME 37 -- No longer used */
#define RPMVAR_PROVIDES 38 #define RPMVAR_PROVIDES 38
/* #define RPMVAR_BUILDSHELL 39 -- No longer used */
/* #define RPMVAR_INSTCHANGELOG 40 -- No longer used */
/* #define RPMVAR_BZIP2BIN 41 -- No longer used */
/* #define RPMVAR_LANGPATT 42 -- No longer used */
#define RPMVAR_INCLUDE 43 #define RPMVAR_INCLUDE 43
/* #define RPMVAR_ARCH 44 -- No longer used */
/* #define RPMVAR_OS 45 -- No longer used */
/* #define RPMVAR_BUILDPLATFORM 46 -- No longer used */
/* #define RPMVAR_BUILDARCH 47 -- No longer used */
/* #define RPMVAR_BUILDOS 48 -- No longer used */
#define RPMVAR_MACROFILES 49 #define RPMVAR_MACROFILES 49
/* #define RPMVAR_GPG_PATH 51 -- No longer used */
/* #define RPMVAR_GPG_NAME 52 -- No longer used */
/* #define RPMVAR_HTTPPROXY 53 -- No longer used */
/* #define RPMVAR_HTTPPORT 54 -- No longer used */
#define RPMVAR_NUM 55 /* number of RPMVAR entries */ #define RPMVAR_NUM 55 /* number of RPMVAR entries */
#define xfree(_p) free((void *)_p) /** \ingroup rpmrc
* Return value of an rpmrc variable.
* @deprecated Use rpmExpand() with appropriate macro expression.
* @todo Eliminate from API.
*/
/*@-redecl@*/
/*@observer@*/ /*@null@*/ extern const char * rpmGetVar(int var)
/*@*/;
/*@=redecl@*/
const char * rpmGetVar(int var); /** \ingroup rpmrc
void rpmSetVar(int var, const char *val); * Set value of an rpmrc variable.
* @deprecated Use rpmDefineMacro() to change appropriate macro instead.
* @todo Eliminate from API.
*/
void rpmSetVar(int var, const char * val)
/*@globals internalState @*/
/*@modifies internalState @*/;
/** rpmrc.c **/ /** \ingroup rpmrc
* List of macro files to read when configuring rpm.
* This is a colon separated list of files. URI's are permitted as well,
* identified by the token '://', so file paths must not begin with '//'.
*/
/*@-redecl@*/
/*@observer@*/ /*@unchecked@*/
extern const char * macrofiles;
/*@=redecl@*/
#define RPM_MACHTABLE_INSTARCH 0 /** \ingroup rpmrc
#define RPM_MACHTABLE_INSTOS 1 * Build and install arch/os table identifiers.
#define RPM_MACHTABLE_BUILDARCH 2 * @todo Eliminate from API.
#define RPM_MACHTABLE_BUILDOS 3 */
#define RPM_MACHTABLE_COUNT 4 /* number of arch/os enum rpm_machtable_e {
tables */ RPM_MACHTABLE_INSTARCH = 0, /*!< Install platform architecture.
*/
RPM_MACHTABLE_INSTOS = 1, /*!< Install platform operating syst
em. */
RPM_MACHTABLE_BUILDARCH = 2, /*!< Build platform architecture. */
RPM_MACHTABLE_BUILDOS = 3 /*!< Build platform operating system
. */
};
#define RPM_MACHTABLE_COUNT 4 /*!< No. of arch/os tables.
*/
int rpmReadConfigFiles(const char * file, const char * target); /** \ingroup rpmrc
int rpmReadRC(const char * file); * Read macro configuration file(s) for a target.
void rpmGetArchInfo( /*@out@*/ const char ** name, /*@out@*/ int * num); * @param file colon separated files to read (NULL uses default)
void rpmGetOsInfo( /*@out@*/ const char ** name, /*@out@*/ int * num); * @param target target platform (NULL uses default)
int rpmMachineScore(int type, const char * name); * @return 0 on success, -1 on error
int rpmShowRC(FILE *f); */
void rpmSetTables(int archTable, int osTable); /* only used by build code int rpmReadConfigFiles(/*@null@*/ const char * file,
*/ /*@null@*/ const char * target)
/* if either are NULL, they are set to the default value (munged uname()) /*@globals rpmGlobalMacroContext, rpmCLIMacroContext,
pushed through a translation table (if appropriate) */ fileSystem, internalState @*/
void rpmSetMachine(const char * arch, const char * os); /*@modifies rpmGlobalMacroContext, rpmCLIMacroContext,
void rpmGetMachine( /*@out@*/ const char **arch, /*@out@*/ const char **os) fileSystem, internalState @*/;
;
void rpmFreeRpmrc(void);
/** **/ /** \ingroup rpmrc
* Return current arch name and/or number.
* @todo Generalize to extract arch component from target_platform macro.
* @retval name address of arch name (or NULL)
* @retval num address of arch number (or NULL)
*/
void rpmGetArchInfo( /*@null@*/ /*@out@*/ const char ** name,
/*@null@*/ /*@out@*/ int * num)
/*@modifies *name, *num @*/;
typedef /*@abstract@*/ struct rpmdb_s * rpmdb; /** \ingroup rpmrc
* Return current os name and/or number.
* @todo Generalize to extract os component from target_platform macro.
* @retval name address of os name (or NULL)
* @retval num address of os number (or NULL)
*/
void rpmGetOsInfo( /*@null@*/ /*@out@*/ const char ** name,
/*@null@*/ /*@out@*/ int * num)
/*@modifies *name, *num @*/;
typedef enum rpmCallbackType_e { /** \ingroup rpmrc
RPMCALLBACK_INST_PROGRESS, RPMCALLBACK_INST_START, * Return arch/os score of a name.
RPMCALLBACK_INST_OPEN_FILE, RPMCALLBACK_INST_CLOSE_FILE, * An arch/os score measures the "nearness" of a name to the currently
RPMCALLBACK_TRANS_PROGRESS, RPMCALLBACK_TRANS_START, RPMCALLBACK_TRANS_ * running (or defined) platform arch/os. For example, the score of arch
STOP, * "i586" on an i686 platform is (usually) 2. The arch/os score is used
RPMCALLBACK_UNINST_PROGRESS, RPMCALLBACK_UNINST_START, RPMCALLBACK_UNIN * to select one of several otherwise identical packages using the arch/os
ST_STOP * tags from the header as hints of the intended platform for the package.
} rpmCallbackType; * @todo Rewrite to use RE's against config.guess target platform output.
typedef void * (*rpmCallbackFunction)(const Header h, *
const rpmCallbackType what, * @param type any of the RPM_MACHTABLE_* constants
const unsigned long amount, * @param name name
const unsigned long total, * @return arch score (0 is no match, lower is preferred)
const void * pkgKey, void * data); */
int rpmMachineScore(int type, const char * name)
/*@*/;
void urlSetCallback(rpmCallbackFunction notify, void *notifyData, int not /** \ingroup rpmrc
ifyCount); * Display current rpmrc (and macro) configuration.
* @param fp output file handle
* @return 0 always
*/
int rpmShowRC(FILE * fp)
/*@globals rpmGlobalMacroContext, fileSystem @*/
/*@modifies *fp, rpmGlobalMacroContext, fileSystem @*/;
int rpmdbOpen (const char * root, /*@out@*/ rpmdb * dbp, int mode, int perm /** \ingroup rpmrc
s); * @deprecated Use addMacro to set _target_* macros.
/* 0 on error */ * @todo Eliminate from API.
int rpmdbInit(const char * root, int perms); # @note Only used by build code.
/* nonzero on error */ * @param archTable
void rpmdbClose ( /*@only@*/ rpmdb db); * @param osTable
/* Databases like this should only have rpmdb*RecNum and rpmdbGetRecord */
used on them. Anything else could fail! */ void rpmSetTables(int archTable, int osTable)
int rpmdbOpenForTraversal(const char * prefix, /*@out@*/ rpmdb * rpmdbp); /*@globals internalState @*/
/*@modifies internalState @*/;
int rpmdbFirstRecNum(rpmdb db); /** \ingroup rpmrc
int rpmdbNextRecNum(rpmdb db, unsigned int lastOffset); * Set current arch/os names.
/* 0 at end, -1 on error */ * NULL as argument is set to the default value (munged uname())
* pushed through a translation table (if appropriate).
* @deprecated Use addMacro to set _target_* macros.
* @todo Eliminate from API.
*
* @param arch arch name (or NULL)
* @param os os name (or NULL)
*/
void rpmSetMachine(/*@null@*/ const char * arch, /*@null@*/ const char * os
)
/*@globals internalState @*/
/*@modifies internalState @*/;
Header rpmdbGetRecord(rpmdb db, unsigned int offset); /** \ingroup rpmrc
int rpmdbFindByFile(rpmdb db, const char * filespec, * Return current arch/os names.
/*@out@*/ dbiIndexSet * matches); * @deprecated Use rpmExpand on _target_* macros.
int rpmdbFindByGroup(rpmdb db, const char * group, * @todo Eliminate from API.
/*@out@*/ dbiIndexSet * matches); *
int rpmdbFindPackage(rpmdb db, const char * name, * @retval arch address of arch name (or NULL)
/*@out@*/ dbiIndexSet * matches); * @retval os address of os name (or NULL)
int rpmdbFindByProvides(rpmdb db, const char * provides, */
/*@out@*/ dbiIndexSet * matches); /*@unused@*/
int rpmdbFindByRequiredBy(rpmdb db, const char * requires, void rpmGetMachine( /*@null@*/ /*@out@*/ const char **arch,
/*@out@*/ dbiIndexSet * matches); /*@null@*/ /*@out@*/ const char **os)
int rpmdbFindByConflicts(rpmdb db, const char * conflicts, /*@modifies *arch, *os @*/;
/*@out@*/ dbiIndexSet * matches);
int rpmdbFindByTriggeredBy(rpmdb db, const char * package,
/*@out@*/ dbiIndexSet * matches);
/* these are just convenience functions */ /** \ingroup rpmrc
int rpmdbFindByLabel(rpmdb db, const char * label, * Destroy rpmrc arch/os compatibility tables.
/*@out@*/ dbiIndexSet * matches); * @todo Eliminate from API.
int rpmdbFindByHeader(rpmdb db, Header h, */
/*@out@*/ dbiIndexSet * matches); void rpmFreeRpmrc(void)
/*@globals internalState @*/
/*@modifies internalState @*/;
/* we pass these around as an array with a sentinel */ /*@}*/
typedef struct rpmRelocation_s { /* ==================================================================== */
const char * oldPath; /* NULL here evals to RPMTAG_DEFAULTPREFIX, /** \name RPMDB */
*/ /*@{*/
/* XXX for backwards compatibility */
const char * newPath; /* NULL means to omit the file completely! *
/
} rpmRelocation;
int rpmInstallSourcePackage(const char * root, FD_t fd, const char ** specF /** \ingroup rpmdb
ile, */
rpmCallbackFunction notify, void * notifyData, typedef /*@abstract@*/ struct rpmdb_s * rpmdb;
char ** cookie);
int rpmVersionCompare(Header first, Header second);
int rpmdbRebuild(const char * root);
int rpmVerifyFile(const char * root, Header h, int filenum, /** \ingroup rpmdb
/*@out@*/ int * result, int omitMask); */
int rpmVerifyScript(const char * root, Header h, FD_t err); typedef /*@abstract@*/ struct _dbiIndexSet * dbiIndexSet;
/* Transaction sets are inherently unordered! RPM may reorder transaction /** \ingroup rpmdb
sets to reduce errors. In general, installs/upgrades are done before * Tags for which rpmdb indices will be built.
strict removals, and prerequisite ordering is done on installs/upgrades. */
*/ /*@unchecked@*/
typedef /*@abstract@*/ struct rpmTransactionSet_s * rpmTransactionSet; /*@only@*/ /*@null@*/ extern int * dbiTags;
/*@unchecked@*/
extern int dbiTagsMax;
struct rpmDependencyConflict { /** \ingroup rpmdb
char * byName, * byVersion, * byRelease; * Open rpm database.
Header byHeader; * @param prefix path to top of install tree
/* these needs fields are misnamed -- they are used for the package * @retval dbp address of rpm database
which isn't needed as well */ * @param mode open(2) flags: O_RDWR or O_RDONLY (O_CREAT also)
char * needsName, * needsVersion; * @param perms database permissions
int needsFlags; * @return 0 on success
/*@observer@*/ /*@null@*/ const void * suggestedPackage; /* NULL if non */
e */ int rpmdbOpen (/*@null@*/ const char * prefix, /*@null@*/ /*@out@*/ rpmdb *
enum { RPMDEP_SENSE_REQUIRES, RPMDEP_SENSE_CONFLICTS } sense; dbp,
} ; int mode, int perms)
/*@globals fileSystem @*/
/*@modifies *dbp, fileSystem @*/;
/* db may be NULL, but don't do things which require the database! */ /** \ingroup rpmdb
/*@only@*/ rpmTransactionSet rpmtransCreateSet( /*@only@*/ rpmdb db, * Initialize database.
const char * rootdir); * @param prefix path to top of install tree
* @param perms database permissions
* @return 0 on success
*/
int rpmdbInit(/*@null@*/ const char * prefix, int perms)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/* if fd is NULL, the callback specified in rpmtransCreateSet() is used to /** \ingroup rpmdb
open and close the file descriptor. If Header is NULL, the fd is always * Verify database components.
used, otherwise fd is only needed (and only opened) for actual package * @param prefix path to top of install tree
installation * @return 0 on success
*/
int rpmdbVerify(/*@null@*/ const char * prefix)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
returns 0 on success, 1 on I/O error, 2 if the package needs capabilitie /** \ingroup rpmdb
s * Close all database indices and free rpmdb.
which are not implemented */ * @param db rpm database
int rpmtransAddPackage(rpmTransactionSet rpmdep, Header h, FD_t fd, * @return 0 on success
/*@owned@*/ const void * key, int update, */
rpmRelocation * relocs); int rpmdbClose (/*@only@*/ /*@null@*/ rpmdb db)
void rpmtransAvailablePackage(rpmTransactionSet rpmdep, Header h, /*@globals fileSystem @*/
/*@owned@*/ const void * key); /*@modifies fileSystem @*/;
void rpmtransRemovePackage(rpmTransactionSet rpmdep, int dboffset);
void rpmtransFree( /*@only@*/ rpmTransactionSet rpmdep);
void rpmtransSetScriptFd(rpmTransactionSet ts, FD_t fd);
/* this checks for dependency satisfaction, but *not* ordering */ /** \ingroup rpmdb
int rpmdepCheck(rpmTransactionSet rpmdep, * Sync all database indices.
/*@exposed@*/ /*@out@*/ struct rpmDependencyConflict ** conflicts, * @param db rpm database
/*@exposed@*/ /*@out@*/ int * numConflicts); * @return 0 on success
*/
int rpmdbSync (/*@null@*/ rpmdb db)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/* Orders items, returns error on circle, finals keys[] is NULL. No depende /** \ingroup rpmdb
ncy * Open all database indices.
check is done, use rpmdepCheck() for that. If dependencies are not * @param db rpm database
satisfied a "best-try" ordering is returned. */ * @return 0 on success
int rpmdepOrder(rpmTransactionSet order); */
void rpmdepFreeConflicts( /*@only@*/ struct rpmDependencyConflict * conflic int rpmdbOpenAll (/*@null@*/ rpmdb db)
ts, /*@modifies db @*/;
int numConflicts);
#define RPMTRANS_FLAG_TEST (1 << 0) /** \ingroup rpmdb
#define RPMTRANS_FLAG_BUILD_PROBS (1 << 1) * Return number of instances of package in rpm database.
#define RPMTRANS_FLAG_NOSCRIPTS (1 << 2) * @param db rpm database
#define RPMTRANS_FLAG_JUSTDB (1 << 3) * @param name rpm package name
#define RPMTRANS_FLAG_NOTRIGGERS (1 << 4) * @return number of instances
#define RPMTRANS_FLAG_NODOCS (1 << 5) */
#define RPMTRANS_FLAG_ALLFILES (1 << 6) int rpmdbCountPackages(/*@null@*/ rpmdb db, const char * name)
#define RPMTRANS_FLAG_KEEPOBSOLETE (1 << 7) /*@globals fileSystem @*/
/*@modifies db, fileSystem @*/;
/** /** \ingroup rpmdb
*/ */
int rpmRangesOverlap(const char *AName, const char *AEVR, int AFlags, typedef /*@abstract@*/ struct _rpmdbMatchIterator * rpmdbMatchIterator;
const char *BName, const char *BEVR, int BFlags);
/** /** \ingroup rpmdb
* Destroy rpm database iterator.
* @param mi rpm database iterator
* @return NULL always
*/ */
int rpmCheckRpmlibProvides(const char * keyName, const char * keyEVR, /*@null@*/ rpmdbMatchIterator rpmdbFreeIterator(
int keyFlags); /*@only@*//*@null@*/rpmdbMatchIterator mi)
/*@globals fileSystem @*/
/*@modifies mi, fileSystem @*/;
/** \ingroup rpmdb
* Return rpm database used by iterator.
* @param mi rpm database iterator
* @return rpm database handle
*/
/*@kept@*/ /*@null@*/ rpmdb rpmdbGetIteratorRpmDB(
/*@null@*/ rpmdbMatchIterator mi)
/*@*/;
/** \ingroup rpmdb
* Return join key for current position of rpm database iterator.
* @param mi rpm database iterator
* @return current join key
*/
unsigned int rpmdbGetIteratorOffset(/*@null@*/ rpmdbMatchIterator mi)
/*@*/;
/** \ingroup rpmdb
* Return number of elements in rpm database iterator.
* @param mi rpm database iterator
* @return number of elements
*/
int rpmdbGetIteratorCount(/*@null@*/ rpmdbMatchIterator mi)
/*@*/;
/** \ingroup rpmdb
* Append items to set of package instances to iterate.
* @param mi rpm database iterator
* @param hdrNums array of package instances
* @param nHdrNums number of elements in array
* @return 0 on success, 1 on failure (bad args)
*/
int rpmdbAppendIterator(/*@null@*/ rpmdbMatchIterator mi,
/*@null@*/ const int * hdrNums, int nHdrNums)
/*@modifies mi @*/;
/** \ingroup rpmdb
* Remove items from set of package instances to iterate.
* @note Sorted hdrNums are always passed in rpmlib.
* @param mi rpm database iterator
* @param hdrNums array of package instances
* @param nHdrNums number of elements in array
* @param sorted is the array sorted? (array will be sorted on return
)
* @return 0 on success, 1 on failure (bad args)
*/
int rpmdbPruneIterator(/*@null@*/ rpmdbMatchIterator mi,
/*@null@*/ int * hdrNums, int nHdrNums, int sorted)
/*@modifies mi, hdrNums @*/;
/** /**
* Tag value pattern match mode.
*/ */
void rpmShowRpmlibProvides(FILE * fp); typedef enum rpmMireMode_e {
RPMMIRE_DEFAULT = 0, /*!< regex with \., .* and ^...$ */
RPMMIRE_STRCMP = 1, /*!< strcmp on strings */
RPMMIRE_REGEX = 2, /*!< regex patterns */
RPMMIRE_GLOB = 3 /*!< glob patterns */
} rpmMireMode;
typedef enum rpmProblemType_e { RPMPROB_BADARCH, /** \ingroup rpmdb
RPMPROB_BADOS, * Add pattern to iterator selector.
RPMPROB_PKG_INSTALLED, * @param mi rpm database iterator
RPMPROB_BADRELOCATE, * @param tag rpm tag
RPMPROB_REQUIRES, * @param mode type of pattern match
RPMPROB_CONFLICT, * @param pattern pattern to match
RPMPROB_NEW_FILE_CONFLICT, * @return 0 on success
RPMPROB_FILE_CONFLICT, */
RPMPROB_OLDPACKAGE, int rpmdbSetIteratorRE(/*@null@*/ rpmdbMatchIterator mi, rpmTag tag,
RPMPROB_DISKSPACE rpmMireMode mode, /*@null@*/ const char * pattern)
} rpmProblemType; /*@modifies mi @*/;
/** \ingroup rpmdb
* Modify iterator to filter out headers that do not match version.
* @deprecated Use
* rpmdbSetIteratorRE(mi, RPMTAG_VERSION, RPMMIRE_DEFAULT, version)
* instead.
* @todo Eliminate from API.
* @param mi rpm database iterator
* @param version version to match (can be a regex pattern)
* @return 0 on success
*/
/*@unused@*/
int rpmdbSetIteratorVersion(/*@null@*/ rpmdbMatchIterator mi,
/*@null@*/ const char * version)
/*@modifies mi @*/;
/** \ingroup rpmdb
* Modify iterator to filter out headers that do not match release.
* @deprecated Use
* rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, RPMMIRE_DEFAULT, release)
* instead.
* @todo Eliminate from API.
* @param mi rpm database iterator
* @param release release to match (can be a regex pattern)
* @return 0 on success
*/
/*@unused@*/
int rpmdbSetIteratorRelease(/*@null@*/ rpmdbMatchIterator mi,
/*@null@*/ const char * release)
/*@modifies mi @*/;
/** \ingroup rpmdb
* Prepare iterator for lazy writes.
* @note Must be called before rpmdbNextIterator() in CDB model database.
* @param mi rpm database iterator
* @param rewrite new value of rewrite
* @return previous value
*/
int rpmdbSetIteratorRewrite(/*@null@*/ rpmdbMatchIterator mi, int rewrite)
/*@modifies mi @*/;
/** \ingroup rpmdb
* Modify iterator to mark header for lazy write.
* @param mi rpm database iterator
* @param modified new value of modified
* @return previous value
*/
int rpmdbSetIteratorModified(/*@null@*/ rpmdbMatchIterator mi, int modified
)
/*@modifies mi @*/;
/** \ingroup rpmdb
* Return next package header from iteration.
* @param mi rpm database iterator
* @return NULL on end of iteration.
*/
/*@null@*/ Header rpmdbNextIterator(/*@null@*/ rpmdbMatchIterator mi)
/*@globals fileSystem @*/
/*@modifies mi, fileSystem @*/;
/** @todo Remove debugging entry from the ABI. */
/*@unused@*/
/*@null@*/ Header XrpmdbNextIterator(rpmdbMatchIterator mi,
const char * f, unsigned int l)
/*@globals fileSystem @*/
/*@modifies mi, fileSystem @*/;
/** \ingroup rpmdb
* Return database iterator.
* @param db rpm database
* @param rpmtag rpm tag
* @param keyp key data (NULL for sequential access)
* @param keylen key data length (0 will use strlen(keyp))
* @return NULL on failure
*/
/*@only@*/ /*@null@*/ rpmdbMatchIterator rpmdbInitIterator(
/*@kept@*/ /*@null@*/ rpmdb db, int rpmtag,
/*@null@*/ const void * keyp, size_t keylen)
/*@globals fileSystem @*/
/*@modifies db, fileSystem @*/;
/** \ingroup rpmdb
* Add package header to rpm database and indices.
* @param db rpm database
* @param iid install transaction id (iid = 0 or -1 to skip)
* @param h header
* @return 0 on success
*/
int rpmdbAdd(/*@null@*/ rpmdb db, int iid, Header h)
/*@globals fileSystem @*/
/*@modifies db, h, fileSystem @*/;
/** \ingroup rpmdb
* Remove package header from rpm database and indices.
* @param db rpm database
* @param rid remove transaction id (rid = 0 or -1 to skip)
* @param hdrNum package instance number in database
* @return 0 on success
*/
int rpmdbRemove(/*@null@*/ rpmdb db, /*@unused@*/ int rid, unsigned int hdr
Num)
/*@globals fileSystem @*/
/*@modifies db, fileSystem @*/;
/** \ingroup rpmdb
* Rebuild database indices from package headers.
* @param prefix path to top of install tree
* @return 0 on success
*/
int rpmdbRebuild(/*@null@*/ const char * prefix)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/*@}*/
/* ==================================================================== */
/** \name RPMPROBS */
/*@{*/
/**
* Enumerate transaction set problem types.
*/
typedef enum rpmProblemType_e {
RPMPROB_BADARCH, /*!< package ... is for a different architecture */
RPMPROB_BADOS, /*!< package ... is for a different operating system
*/
RPMPROB_PKG_INSTALLED, /*!< package ... is already installed */
RPMPROB_BADRELOCATE,/*!< path ... is not relocateable for package ... *
/
RPMPROB_REQUIRES, /*!< package ... has unsatisfied Requires: ... */
RPMPROB_CONFLICT, /*!< package ... has unsatisfied Conflicts: ... */
RPMPROB_NEW_FILE_CONFLICT, /*!< file ... conflicts between attemped ins
talls of ... */
RPMPROB_FILE_CONFLICT,/*!< file ... from install of ... conflicts with
file from package ... */
RPMPROB_OLDPACKAGE, /*!< package ... (which is newer than ...) i
s already installed */
RPMPROB_DISKSPACE, /*!< installing package ... needs ... on the ... fil
esystem */
RPMPROB_DISKNODES, /*!< installing package ... needs ... on the ... fil
esystem */
RPMPROB_BADPRETRANS /*!< (unimplemented) */
} rpmProblemType;
/**
*/
typedef /*@abstract@*/ struct rpmProblem_s { typedef /*@abstract@*/ struct rpmProblem_s {
Header h, altH; /*@only@*/ /*@null@*/ const char * pkgNEVR;
/*@dependent@*/ const void * key; /*@only@*/ /*@null@*/ const char * altNEVR;
/*@kept@*/ /*@null@*/ const void * key;
/*@null@*/ Header h;
rpmProblemType type; rpmProblemType type;
int ignoreProblem; int ignoreProblem;
/*@only@*/ const char * str1; /*@only@*/ /*@null@*/ const char * str1;
unsigned long ulong1; unsigned long ulong1;
} rpmProblem; } * rpmProblem;
/**
*/
typedef /*@abstract@*/ struct rpmProblemSet_s { typedef /*@abstract@*/ struct rpmProblemSet_s {
int numProblems; int numProblems; /*!< Current probs array size. */
int numProblemsAlloced; int numProblemsAlloced; /*!< Allocated probs array size. */
rpmProblem * probs; rpmProblem probs; /*!< Array of specific problems. */
} * rpmProblemSet; } * rpmProblemSet;
void printDepFlags(FILE *fp, const char *version, int flags); /**
void printDepProblems(FILE *fp, struct rpmDependencyConflict *conflicts, */
int numConflicts); void printDepFlags(FILE *fp, const char *version, int flags)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/;
/*@only@*/ const char * rpmProblemString(rpmProblem prob); /**
void rpmProblemPrint(FILE *fp, rpmProblem prob); * Dependency problems found by rpmdepCheck().
void rpmProblemSetPrint(FILE *fp, rpmProblemSet probs); */
typedef /*@abstract@*/ struct rpmDependencyConflict_s {
const char * byName; /*!< package name */
const char * byVersion; /*!< package version */
const char * byRelease; /*!< package release */
Header byHeader; /*!< header with dependency problems */
/*
* These needs fields are misnamed -- they are used for the package
* which isn't needed as well.
*/
const char * needsName; /*!< dependency name */
const char * needsVersion; /*!< dependency epoch:version-release */
int needsFlags; /*!< dependency flags */
/*@owned@*/ /*@null@*/ const void ** suggestedPackages; /* terminated by NU
LL */
enum {
RPMDEP_SENSE_REQUIRES, /*!< requirement not satisfied. */
RPMDEP_SENSE_CONFLICTS /*!< conflict was found. */
} sense;
} * rpmDependencyConflict;
void rpmProblemSetFree( /*@only@*/ rpmProblemSet probs); /**
* Print results of rpmdepCheck() dependency check.
* @param fp output file
* @param conflicts dependency problems
* @param numConflicts no. of dependency problems
*/
void printDepProblems(FILE * fp, const rpmDependencyConflict conflicts,
int numConflicts)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/;
int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, /**
void * notifyData, rpmProblemSet okProbs, * Return formatted string representation of problem.
/*@out@*/ rpmProblemSet * newProbs, int flags, * @deprecated API: prob used to be passed by value, now passed by referenc
int ignoreSet); e.
* @param prob rpm problem
* @return formatted string (malloc'd)
*/
/*@-redecl@*/ /* LCL: is confused. */
/*@only@*/ extern const char * rpmProblemString(const rpmProblem prob)
/*@*/;
/*@=redecl@*/
#define RPMPROB_FILTER_IGNOREOS (1 << 0) /**
#define RPMPROB_FILTER_IGNOREARCH (1 << 1) * Output formatted string representation of problem to file handle.
#define RPMPROB_FILTER_REPLACEPKG (1 << 2) * @deprecated API: prob used to be passed by value, now passed by referenc
#define RPMPROB_FILTER_FORCERELOCATE (1 << 3) e.
#define RPMPROB_FILTER_REPLACENEWFILES (1 << 4) * @param fp file handle
#define RPMPROB_FILTER_REPLACEOLDFILES (1 << 5) * @param prob rpm problem
#define RPMPROB_FILTER_OLDPACKAGE (1 << 6) */
#define RPMPROB_FILTER_DISKSPACE (1 << 7) void rpmProblemPrint(FILE *fp, rpmProblem prob)
/*@globals fileSystem @*/
/*@modifies prob, *fp, fileSystem @*/;
/** messages.c **/ /**
* Print problems to file handle.
* @param fp file handle
* @param probs problem set
*/
void rpmProblemSetPrint(FILE *fp, rpmProblemSet probs)
/*@globals fileSystem @*/
/*@modifies probs, *fp, fileSystem @*/;
#define RPMMESS_DEBUG 1 /**
#define RPMMESS_VERBOSE 2 * Destroy problem set.
#define RPMMESS_NORMAL 3 * @param probs problem set
#define RPMMESS_WARNING 4 */
#define RPMMESS_ERROR 5 void rpmProblemSetFree( /*@only@*/ rpmProblemSet probs)
#define RPMMESS_FATALERROR 6 /*@modifies probs @*/;
#define RPMMESS_QUIET (RPMMESS_NORMAL + 1) /*@}*/
/* ==================================================================== */
/** \name RPMTS */
/*@{*/
/**
* Prototype for headerFreeData() vector.
* @param data address of data (or NULL)
* @param type type of data (or -1 to force free)
* @return NULL always
*/
typedef /*@null@*/
void * (*HFD_t) (/*@only@*/ /*@null@*/ const void * data, rpmTagType ty
pe)
/*@modifies data @*/;
void rpmIncreaseVerbosity(void); /**
void rpmSetVerbosity(int level); * Prototype for headerGetEntry() vector.
int rpmGetVerbosity(void); * Will never return RPM_I18NSTRING_TYPE! RPM_STRING_TYPE elements with
int rpmIsVerbose(void); * RPM_I18NSTRING_TYPE equivalent entries are translated (if HEADER_I18NTAB
int rpmIsDebug(void); LE
void rpmMessage(int level, const char * format, ...); * entry is present).
*
* @param h header
* @param tag tag
* @retval type address of tag value data type (or NULL)
* @retval p address of pointer to tag value(s) (or NULL)
* @retval c address of number of values (or NULL)
* @return 1 on success, 0 on failure
*/
typedef int (*HGE_t) (Header h, rpmTag tag,
/*@null@*/ /*@out@*/ rpmTagType * type,
/*@null@*/ /*@out@*/ void ** p,
/*@null@*/ /*@out@*/ int_32 * c)
/*@modifies *type, *p, *c @*/;
/** rpmlead.c **/ /**
* Prototype for headerAddEntry() vector.
* Duplicate tags are okay, but only defined for iteration (with the
* exceptions noted below). While you are allowed to add i18n string
* arrays through this function, you probably don't mean to. See
* headerAddI18NString() instead.
*
* @param h header
* @param tag tag
* @param type tag value data type
* @param p pointer to tag value(s)
* @param c number of values
* @return 1 on success, 0 on failure
*/
typedef int (*HAE_t) (Header h, rpmTag tag, rpmTagType type,
const void * p, int_32 c)
/*@modifies h @*/;
#define RPMLEAD_BINARY 0 /**
#define RPMLEAD_SOURCE 1 * Prototype for headerModifyEntry() vector.
* If there are multiple entries with this tag, the first one gets replaced
.
* @param h header
* @param tag tag
* @param type tag value data type
* @param p pointer to tag value(s)
* @param c number of values
* @return 1 on success, 0 on failure
*/
typedef int (*HME_t) (Header h, rpmTag tag, rpmTagType type,
const void * p, int_32 c)
/*@modifies h @*/;
#define RPMLEAD_MAGIC0 0xed /**
#define RPMLEAD_MAGIC1 0xab * Prototype for headerRemoveEntry() vector.
#define RPMLEAD_MAGIC2 0xee * Delete tag in header.
#define RPMLEAD_MAGIC3 0xdb * Removes all entries of type tag from the header, returns 1 if none were
* found.
*
* @param h header
* @param tag tag
* @return 0 on success, 1 on failure (INCONSISTENT)
*/
typedef int (*HRE_t) (Header h, int_32 tag)
/*@modifies h @*/;
/* The lead needs to be 8 byte aligned */ /**
* We pass these around as an array with a sentinel.
*/
typedef struct rpmRelocation_s {
/*@only@*/ /*@null@*/
const char * oldPath; /*!< NULL here evals to RPMTAG_DEFAULTPREFIX
, */
/*@only@*/ /*@null@*/
const char * newPath; /*!< NULL means to omit the file completely!
*/
} rpmRelocation;
#define RPMLEAD_SIZE 96 /**
* Install source package.
* @param rootDir path to top of install tree (or NULL)
* @param fd file handle
* @retval specFilePtr address of spec file name (or NULL)
* @param notify progress callback
* @param notifyData progress callback private data
* @retval cooke address of cookie pointer (or NULL)
* @return rpmRC return code
*/
rpmRC rpmInstallSourcePackage(/*@null@*/ const char * rootDir, FD_t fd,
/*@null@*/ /*@out@*/ const char ** specFilePtr,
/*@null@*/ rpmCallbackFunction notify,
/*@null@*/ rpmCallbackData notifyData,
/*@null@*/ /*@out@*/ char ** cookie)
/*@modifies fd, *specFilePtr, *cookie @*/;
struct rpmlead { /**
unsigned char magic[4]; * Compare headers to determine which header is "newer".
unsigned char major, minor; * @param first 1st header
short type; * @param second 2nd header
short archnum; * @return result of comparison
char name[66]; */
short osnum; int rpmVersionCompare(Header first, Header second)
short signature_type; /*@*/;
char reserved[16]; /* pads to 96 bytes -- 8 byte aligned! */
} ;
struct oldrpmlead { /* for version 1 packages */ /**
unsigned char magic[4]; * File disposition(s) during package install/erase transaction.
unsigned char major, minor; */
short type; typedef enum fileAction_e {
short archnum; FA_UNKNOWN = 0, /*!< initial action for file ... */
char name[66]; FA_CREATE, /*!< ... copy in from payload. */
unsigned int specOffset; FA_COPYIN, /*!< ... copy in from payload. */
unsigned int specLength; FA_COPYOUT, /*!< ... copy out to payload. */
unsigned int archiveOffset; FA_BACKUP, /*!< ... renamed with ".rpmorig" extension. */
} ; FA_SAVE, /*!< ... renamed with ".rpmsave" extension. */
FA_SKIP, /*!< ... already replaced, don't remove. */
FA_ALTNAME, /*!< ... create with ".rpmnew" extension. */
FA_ERASE, /*!< ... to be removed. */
FA_SKIPNSTATE, /*!< ... untouched, state "not installed". */
FA_SKIPNETSHARED, /*!< ... untouched, state "netshared". */
FA_SKIPMULTILIB /*!< ... untouched. @todo state "multilib" ???. */
} fileAction;
/** rpmerr.c **/ #define XFA_SKIPPING(_a) \
((_a) == FA_SKIP || (_a) == FA_SKIPNSTATE || (_a) == FA_SKIPNETSHARED |
| (_a) == FA_SKIPMULTILIB)
typedef void (*rpmErrorCallBackType)(void); /**
* File types.
* These are the file types used internally by rpm. The file
* type is determined by applying stat(2) macros like S_ISDIR to
* the file mode tag from a header. The values are arbitrary,
* but are identical to the linux stat(2) file types.
*/
typedef enum fileTypes_e {
PIPE = 1, /*!< pipe/fifo */
CDEV = 2, /*!< character device */
XDIR = 4, /*!< directory */
BDEV = 6, /*!< block device */
REG = 8, /*!< regular file */
LINK = 10, /*!< hard link */
SOCK = 12 /*!< socket */
} fileTypes;
#if defined(__GNUC__) /** \ingroup payload
void rpmError(int code, char * format, ...) __attribute__ ((__format__ (__p * Iterator across package file info, forward on install, backward on erase
rintf__, 2, 3))); .
#else */
void rpmError(int code, char * format, ...); typedef /*@abstract@*/ struct fsmIterator_s * FSMI_t;
#endif
int rpmErrorCode(void); /** \ingroup payload
char *rpmErrorCodeString(void); * File state machine data.
char *rpmErrorString(void); */
rpmErrorCallBackType rpmErrorSetCallback(rpmErrorCallBackType); typedef /*@abstract@*/ struct fsm_s * FSM_t;
#define RPMERR_GDBMOPEN -2 /* gdbm open failed */ /** \ingroup rpmtrans
#define RPMERR_GDBMREAD -3 /* gdbm read failed */ * Package state machine data.
#define RPMERR_GDBMWRITE -4 /* gdbm write failed */ */
#define RPMERR_INTERNAL -5 /* internal RPM error */ typedef /*@abstract@*/ struct psm_s * PSM_t;
#define RPMERR_DBCORRUPT -6 /* rpm database is corrupt *
/
#define RPMERR_OLDDBCORRUPT -7 /* old style rpm database is
corrupt */
#define RPMERR_OLDDBMISSING -8 /* old style rpm database is
missing */
#define RPMERR_NOCREATEDB -9 /* cannot create new databas
e */
#define RPMERR_DBOPEN -10 /* database open failed */
#define RPMERR_DBGETINDEX -11 /* database get from index f
ailed */
#define RPMERR_DBPUTINDEX -12 /* database get from index f
ailed */
#define RPMERR_NEWPACKAGE -13 /* package is too new to han
dle */
#define RPMERR_BADMAGIC -14 /* bad magic for an RPM */
#define RPMERR_RENAME -15 /* rename(2) failed */
#define RPMERR_UNLINK -16 /* unlink(2) failed */
#define RPMERR_RMDIR -17 /* rmdir(2) failed */
#define RPMERR_PKGINSTALLED -18 /* package already installed
*/
#define RPMERR_CHOWN -19 /* chown() call failed */
#define RPMERR_NOUSER -20 /* user does not exist */
#define RPMERR_NOGROUP -21 /* group does not exist */
#define RPMERR_MKDIR -22 /* mkdir() call failed */
#define RPMERR_FILECONFLICT -23 /* file being installed exis
ts */
#define RPMERR_RPMRC -24 /* bad line in rpmrc */
#define RPMERR_NOSPEC -25 /* .spec file is missing */
#define RPMERR_NOTSRPM -26 /* a source rpm was expected
*/
#define RPMERR_FLOCK -27 /* locking the database fail
ed */
#define RPMERR_OLDPACKAGE -28 /* trying upgrading to old v
ersion */
/*#define RPMERR_BADARCH -29 bad architecture or arch mismatch
*/
#define RPMERR_CREATE -30 /* failed to create a file *
/
#define RPMERR_NOSPACE -31 /* out of disk space */
#define RPMERR_NORELOCATE -32 /* tried to do improper relo
catation */
/*#define RPMERR_BADOS -33 bad architecture or arch mismatch
*/
#define RPMMESS_BACKUP -34 /* backup made during [un]in
stall */
#define RPMERR_MTAB -35 /* failed to read mount tabl
e */
#define RPMERR_STAT -36 /* failed to stat something
*/
#define RPMERR_BADDEV -37 /* file on device not listed
in mtab */
#define RPMMESS_ALTNAME -38 /* file written as .rpmnew *
/
#define RPMMESS_PREREQLOOP -39 /* loop in prerequisites */
#define RPMERR_BADRELOCATE -40 /* bad relocation was specif
ied */
#define RPMERR_OLDDB -41 /* old format database */
/* spec.c build.c pack.c */ /** \ingroup rpmtrans
#define RPMERR_UNMATCHEDIF -107 /* unclosed %ifarch or %ifos */
*/ typedef /*@abstract@*/ struct transactionFileInfo_s * TFI_t;
#define RPMERR_BADARG -109
#define RPMERR_SCRIPT -110 /* errors related to script
exec */
#define RPMERR_READERROR -111
#define RPMERR_UNKNOWNOS -112
#define RPMERR_UNKNOWNARCH -113
#define RPMERR_EXEC -114
#define RPMERR_FORK -115
#define RPMERR_CPIO -116
#define RPMERR_GZIP -117
#define RPMERR_BADSPEC -118
#define RPMERR_LDD -119 /* couldn't understand ldd o
utput */
#define RPMERR_BADFILENAME -120
#define RPMERR_BADSIGTYPE -200 /* Unknown signature type */ /** \ingroup rpmtrans
#define RPMERR_SIGGEN -201 /* Error generating signatur * The RPM Transaction Set.
e */ * Transaction sets are inherently unordered! RPM may reorder transaction
* sets to reduce errors. In general, installs/upgrades are done before
* strict removals, and prerequisite ordering is done on installs/upgrades.
*/
typedef /*@abstract@*/ struct rpmTransactionSet_s * rpmTransactionSet;
/** signature.c **/ /** \ingroup rpmtrans
* Create an empty transaction set.
* @param rpmdb rpm database (may be NULL if database is not
accessed)
* @param rootdir path to top of install tree
* @return transaction set
*/
/*@only@*/ rpmTransactionSet rpmtransCreateSet(
/*@null@*/ /*@kept@*/ rpmdb rpmdb,
/*@null@*/ const char * rootDir)
/*@*/;
/**************************************************/ /** \ingroup rpmtrans
/* */ * Add package to be installed to unordered transaction set.
/* Signature Tags */ *
/* */ * If fd is NULL, the callback specified in rpmtransCreateSet() is used to
/* These go in the sig Header to specify */ * open and close the file descriptor. If Header is NULL, the fd is always
/* individual signature types. */ * used, otherwise fd is only needed (and only opened) for actual package
/* */ * installation.
/**************************************************/ *
* @param ts transaction set
* @param h package header
* @param fd package file handle
* @param key package private data
* @param upgrade is package being upgraded?
* @param relocs package file relocations
* @return 0 on success, 1 on I/O error, 2 needs capabilities
*/
int rpmtransAddPackage(rpmTransactionSet ts, Header h, /*@null@*/ FD_t fd,
/*@null@*/ /*@owned@*/ const void * key, int upgrade,
/*@null@*/ rpmRelocation * relocs)
/*@modifies fd, h, ts @*/;
#define RPMSIGTAG_SIZE 1000 /** \ingroup rpmtrans
/* the md5 sum was broken *twice* on big endian machines */ * Add package to universe of possible packages to install in transaction s
#define RPMSIGTAG_LEMD5_1 1001 et.
#define RPMSIGTAG_PGP 1002 * @param ts transaction set
#define RPMSIGTAG_LEMD5_2 1003 * @param h header
#define RPMSIGTAG_MD5 1004 * @param key package private data
#define RPMSIGTAG_GPG 1005 */
#define RPMSIGTAG_PGP5 1006 /* XXX legacy use on /*@unused@*/
ly */ void rpmtransAvailablePackage(rpmTransactionSet ts, Header h,
/*@null@*/ /*@owned@*/ const void * key)
/*@modifies h, ts @*/;
/* Signature tags by Public Key Algorithm (RFC 2440) */ /** \ingroup rpmtrans
/* N.B.: These tags are tenative, the values may change */ * Add package to be removed to unordered transaction set.
#define RPMTAG_PK_BASE 2048 * @param ts transaction set
#define RPMTAG_PK_RSA_ES RPMTAG_PK_BASE+1 * @param dboffset rpm database instance
#define RPMTAG_PK_RSA_E RPMTAG_PK_BASE+2 * @return 0 on success
#define RPMTAG_PK_RSA_S RPMTAG_PK_BASE+3 */
#define RPMTAG_PK_ELGAMAL_E RPMTAG_PK_BASE+16 int rpmtransRemovePackage(rpmTransactionSet ts, int dboffset)
#define RPMTAG_PK_DSA RPMTAG_PK_BASE+17 /*@modifies ts @*/;
#define RPMTAG_PK_ELLIPTIC RPMTAG_PK_BASE+18
#define RPMTAG_PK_ECDSA RPMTAG_PK_BASE+19
#define RPMTAG_PK_ELGAMAL_ES RPMTAG_PK_BASE+20
#define RPMTAG_PK_DH RPMTAG_PK_BASE+21
#define RPMTAG_HASH_BASE 2048+64 /** \ingroup rpmtrans
#define RPMTAG_HASH_MD5 RPMTAG_HASH_BASE+1 * Destroy transaction set.
#define RPMTAG_HASH_SHA1 RPMTAG_HASH_BASE+2 * @param ts transaction set
#define RPMTAG_HASH_RIPEMD160 RPMTAG_HASH_BASE+3 * @return NULL always
#define RPMTAG_HASH_MD2 RPMTAG_HASH_BASE+5 */
#define RPMTAG_HASH_TIGER192 RPMTAG_HASH_BASE+6 /*@null@*/ rpmTransactionSet
#define RPMTAG_HASH_HAVAL_5_160 RPMTAG_HASH_BASE+7 rpmtransFree(/*@only@*//*@null@*/ rpmTransactionSet ts)
/*@modifies ts @*/;
/**************************************************/ /** \ingroup rpmtrans
/* */ * Save file handle to be used as stderr when running package scripts.
/* verifySignature() results */ * @param ts transaction set
/* */ * @param fd file handle
/**************************************************/ */
/*@unused@*/
void rpmtransSetScriptFd(rpmTransactionSet ts, FD_t fd)
/*@modifies ts, fd @*/;
/* verifySignature() results */ /** \ingroup rpmtrans
#define RPMSIG_OK 0 * Retrieve keys from ordered transaction set.
#define RPMSIG_UNKNOWN 1 * @todo Removed packages have no keys, returned as interleaved NULL pointe
#define RPMSIG_BAD 2 rs.
#define RPMSIG_NOKEY 3 /* Do not have the key to check t * @param ts transaction set
his signature */ * @retval ep address of returned element array pointer (or NULL)
#define RPMSIG_NOTTRUSTED 4 /* We have the key but it is not * @retval nep address of no. of returned elements (or NULL)
trusted */ * @return 0 always
*/
/*@unused@*/
int rpmtransGetKeys(const rpmTransactionSet ts,
/*@null@*/ /*@out@*/ const void *** ep,
/*@null@*/ /*@out@*/ int * nep)
/*@modifies ep, nep @*/;
void rpmFreeSignature(Header h); /** \ingroup rpmtrans
* Check that all dependencies can be resolved.
* @param ts transaction set
* @retval conflicts dependency problems
* @retval numConflicts no. of dependency problems
* @return 0 on success
*/
int rpmdepCheck(rpmTransactionSet ts,
/*@exposed@*/ /*@out@*/ rpmDependencyConflict * conflicts,
/*@exposed@*/ /*@out@*/ int * numConflicts)
/*@globals fileSystem, internalState @*/
/*@modifies ts, *conflicts, *numConflicts,
fileSystem, internalState @*/;
int rpmVerifySignature(const char *file, int_32 sigTag, void *sig, int coun /** \ingroup rpmtrans
t, * Determine package order in a transaction set according to dependencies.
char *result); *
* Order packages, returning error if circular dependencies cannot be
* eliminated by removing PreReq's from the loop(s). Only dependencies from
* added or removed packages are used to determine ordering using a
* topological sort (Knuth vol. 1, p. 262). Use rpmdepCheck() to verify
* that all dependencies can be resolved.
*
* The final order ends up as installed packages followed by removed packag
es,
* with packages removed for upgrades immediately following the new package
* to be installed.
*
* The operation would be easier if we could sort the addedPackages array i
n the
* transaction set, but we store indexes into the array in various places.
*
* @param ts transaction set
* @return 0 if packages are successfully ordered, 1 otherwise
*/
int rpmdepOrder(rpmTransactionSet ts)
/*@globals fileSystem, internalState@*/
/*@modifies ts, fileSystem, internalState @*/;
void freeFilesystems(void); /** \ingroup rpmtrans
int rpmGetFilesystemList( /*@out@*/ const char *** listptr, /*@out@*/int * * Destroy dependency conflicts storage.
num); * @param conflicts dependency problems
int rpmGetFilesystemUsage(const char ** filelist, int_32 * fssizes, * @param numConflicts no. of dependency problems
int numFiles, /*@out@*/ uint_32 ** usagesPtr, int flags); * @retrun NULL always
*/
/*@null@*/ rpmDependencyConflict rpmdepFreeConflicts(
/*@only@*/ /*@null@*/ rpmDependencyConflict conflicts,
int numConflicts)
/*@modifies conflicts @*/;
/* ==================================================================== */ /** \ingroup rpmtrans
/* --- query/verify */ * Bit(s) to control rpmRunTransactions() operation.
*/
typedef enum rpmtransFlags_e {
RPMTRANS_FLAG_NONE = 0,
RPMTRANS_FLAG_TEST = (1 << 0), /*!< from --test */
RPMTRANS_FLAG_BUILD_PROBS = (1 << 1), /*!< @todo Document. */
RPMTRANS_FLAG_NOSCRIPTS = (1 << 2), /*!< from --noscripts */
RPMTRANS_FLAG_JUSTDB = (1 << 3), /*!< from --justdb */
RPMTRANS_FLAG_NOTRIGGERS = (1 << 4), /*!< from --notriggers */
RPMTRANS_FLAG_NODOCS = (1 << 5), /*!< from --excludedocs */
RPMTRANS_FLAG_ALLFILES = (1 << 6), /*!< from --allfiles */
/*@-enummemuse@*/
RPMTRANS_FLAG_KEEPOBSOLETE = (1 << 7), /*!< @todo Document. */
/*@=enummemuse@*/
RPMTRANS_FLAG_MULTILIB = (1 << 8), /*!< @todo Document. */
RPMTRANS_FLAG_DIRSTASH = (1 << 9), /*!< from --dirstash */
RPMTRANS_FLAG_REPACKAGE = (1 << 10), /*!< from --repackage */
/* XXX SPECFILE is not verify sources */ RPMTRANS_FLAG_PKGCOMMIT = (1 << 11),
enum rpmQVSources { RPMQV_PACKAGE = 0, RPMQV_PATH, RPMQV_ALL, RPMQV_RPM, /*@-enummemuse@*/
RPMQV_GROUP, RPMQV_WHATPROVIDES, RPMQV_WHATREQUIRES, RPMTRANS_FLAG_PKGUNDO = (1 << 12),
RPMQV_TRIGGEREDBY, RPMQV_DBOFFSET, RPMQV_SPECFILE }; /*@=enummemuse@*/
RPMTRANS_FLAG_COMMIT = (1 << 13),
/*@-enummemuse@*/
RPMTRANS_FLAG_UNDO = (1 << 14),
/*@=enummemuse@*/
RPMTRANS_FLAG_REVERSE = (1 << 15),
extern struct poptOption rpmQVSourcePoptTable[]; RPMTRANS_FLAG_NOTRIGGERPREIN= (1 << 16), /*!< from --notriggerprein *
/
RPMTRANS_FLAG_NOPRE = (1 << 17), /*!< from --nopre */
RPMTRANS_FLAG_NOPOST = (1 << 18), /*!< from --nopost */
RPMTRANS_FLAG_NOTRIGGERIN = (1 << 19), /*!< from --notriggerin */
RPMTRANS_FLAG_NOTRIGGERUN = (1 << 20), /*!< from --notriggerun */
RPMTRANS_FLAG_NOPREUN = (1 << 21), /*!< from --nopreun */
RPMTRANS_FLAG_NOPOSTUN = (1 << 22), /*!< from --nopostun */
RPMTRANS_FLAG_NOTRIGGERPOSTUN = (1 << 23), /*!< from --notriggerpostun
*/
/*@-enummemuse@*/
RPMTRANS_FLAG_NOPAYLOAD = (1 << 24),
/*@=enummemuse@*/
RPMTRANS_FLAG_APPLYONLY = (1 << 25),
struct rpmQVArguments { /*@-enummemuse@*/
enum rpmQVSources qva_source; RPMTRANS_FLAG_CHAINSAW = (1 << 26),
int qva_sourceCount; /* > 1 is an error */ /*@=enummemuse@*/
int qva_flags; RPMTRANS_FLAG_NOMD5 = (1 << 27) /*!< from --nomd5 */
int qva_verbose; } rpmtransFlags;
const char *qva_queryFormat;
const char *qva_prefix;
};
typedef struct rpmQVArguments QVA_t;
typedef int (*QVF_t) (QVA_t *qva, rpmdb db, Header h); #define _noTransScripts \
int showMatches(QVA_t *qva, rpmdb db, dbiIndexSet matches, QVF_t showPackag ( RPMTRANS_FLAG_NOPRE | \
e); RPMTRANS_FLAG_NOPOST | \
RPMTRANS_FLAG_NOPREUN | \
RPMTRANS_FLAG_NOPOSTUN \
)
#define QUERY_FOR_LIST (1 << 1) #define _noTransTriggers \
#define QUERY_FOR_STATE (1 << 2) ( RPMTRANS_FLAG_NOTRIGGERPREIN | \
#define QUERY_FOR_DOCS (1 << 3) RPMTRANS_FLAG_NOTRIGGERIN | \
#define QUERY_FOR_CONFIG (1 << 4) RPMTRANS_FLAG_NOTRIGGERUN | \
#define QUERY_FOR_DUMPFILES (1 << 8) RPMTRANS_FLAG_NOTRIGGERPOSTUN \
)
/*@observer@*/ const char *const tagName(int tag); /** \ingroup rpmtrans
extern int specedit; * Return copy of rpmlib internal provides.
extern struct poptOption rpmQueryPoptTable[]; * @retval address of array of rpmlib internal provide names
* @retval address of array of rpmlib internal provide flags
* @retval address of array of rpmlib internal provide versions
* @return no. of entries
*/
/*@unused@*/
int rpmGetRpmlibProvides(/*@null@*/ /*@out@*/ const char *** provNames,
/*@null@*/ /*@out@*/ int ** provFlags,
/*@null@*/ /*@out@*/ const char *** provVersions)
/*@modifies *provNames, *provFlags, *provVersions @*/;
void rpmDisplayQueryTags(FILE * f); /** \ingroup rpmtrans
int rpmQueryVerify(QVA_t *qva, enum rpmQVSources source, const char * arg, * Segmented string compare for version and/or release.
rpmdb db, QVF_t showPackage); *
* @param a 1st string
* @param b 2nd string
* @return +1 if a is "newer", 0 if equal, -1 if b is "newer"
*/
int rpmvercmp(const char * a, const char * b)
/*@*/;
int showQueryPackage(QVA_t *qva, rpmdb db, Header h); /** \ingroup rpmtrans
int rpmQuery(QVA_t *qva, enum rpmQVSources source, const char * arg); * Compare two versioned dependency ranges, looking for overlap.
* @param AName 1st dependncy name string
* @param AEVR 1st dependency [epoch:]version[-release] string
* @param AFlags 1st dependency logical range qualifiers
* @param BName 2nd dependncy name string
* @param BEVR 2nd dependency [epoch:]version[-release] string
* @param BFlags 2nd dependency logical range qualifiers
* @return 1 if dependencies overlap, 0 otherwise
*/
int rpmRangesOverlap(const char * AName, const char * AEVR, int AFlags,
const char * BName, const char * BEVR, int BFlags)
/*@*/;
#define VERIFY_FILES (1 << 9) /** \ingroup rpmtrans
#define VERIFY_DEPS (1 << 10) * Check dependency against internal rpmlib feature provides.
#define VERIFY_SCRIPT (1 << 11) * @param keyName dependency name string
#define VERIFY_MD5 (1 << 12) * @param keyEVR dependency [epoch:]version[-release] string
* @param keyFlags dependency logical range qualifiers
* @return 1 if dependency overlaps, 0 otherwise
*/
int rpmCheckRpmlibProvides(const char * keyName, const char * keyEVR,
int keyFlags)
/*@*/;
extern struct poptOption rpmVerifyPoptTable[]; /** \ingroup rpmcli
* Display current rpmlib feature provides.
* @param fp output file handle
*/
void rpmShowRpmlibProvides(FILE * fp)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/;
int showVerifyPackage(QVA_t *qva, /*@only@*/ rpmdb db, Header h); /**
int rpmVerify(QVA_t *qva, enum rpmQVSources source, const char *arg); * @todo Generalize filter mechanism.
*/
typedef enum rpmprobFilterFlags_e {
RPMPROB_FILTER_NONE = 0,
RPMPROB_FILTER_IGNOREOS = (1 << 0), /*!< from --ignoreos */
RPMPROB_FILTER_IGNOREARCH = (1 << 1), /*!< from --ignorearch */
RPMPROB_FILTER_REPLACEPKG = (1 << 2), /*!< from --replacepkgs */
RPMPROB_FILTER_FORCERELOCATE= (1 << 3), /*!< from --badreloc */
RPMPROB_FILTER_REPLACENEWFILES= (1 << 4), /*!< from --replacefiles */
RPMPROB_FILTER_REPLACEOLDFILES= (1 << 5), /*!< from --replacefiles */
RPMPROB_FILTER_OLDPACKAGE = (1 << 6), /*!< from --oldpackage */
RPMPROB_FILTER_DISKSPACE = (1 << 7), /*!< from --ignoresize */
RPMPROB_FILTER_DISKNODES = (1 << 8) /*!< from --ignoresize */
} rpmprobFilterFlags;
/** \ingroup rpmtrans
* Process all packages in transaction set.
* @param ts transaction set
* @param notify progress callback
* @param notifyData progress callback private data
* @param okProbs previously known problems (or NULL)
* @retval newProbs address to return unfiltered problems (or NULL)
* @param transFlags bits to control rpmRunTransactions()
* @param ignoreSet bits to filter problem types
* @return 0 on success, -1 on error, >0 with newProbs set
*/
int rpmRunTransactions(rpmTransactionSet ts,
rpmCallbackFunction notify,
/*@owned@*/ rpmCallbackData notifyData,
rpmProblemSet okProbs,
/*@out@*/ rpmProblemSet * newProbs,
rpmtransFlags transFlags,
rpmprobFilterFlags ignoreSet)
/*@globals rpmGlobalMacroContext,
fileSystem, internalState@*/
/*@modifies ts, *newProbs, rpmGlobalMacroContext,
fileSystem, internalState @*/;
/*@}*/
/**
* Return name of tag from value.
* @param tag tag value
* @return name of tag
*/
/*@-redecl@*/
/*@observer@*/ extern const char *const tagName(int tag)
/*@*/;
/*@=redecl@*/
/**
* Return value of tag from name.
* @param targstr name of tag
* @return tag value
*/
int tagValue(const char *tagstr)
/*@*/;
#define RPMLEAD_BINARY 0
#define RPMLEAD_SOURCE 1
#define RPMLEAD_MAGIC0 0xed
#define RPMLEAD_MAGIC1 0xab
#define RPMLEAD_MAGIC2 0xee
#define RPMLEAD_MAGIC3 0xdb
#define RPMLEAD_SIZE 96 /*!< Don't rely on sizeof(struct) */
/** \ingroup lead
* The lead data structure.
* The lead needs to be 8 byte aligned.
* @deprecated The lead (except for signature_type) is legacy.
* @todo Don't use any information from lead.
*/
struct rpmlead {
unsigned char magic[4];
unsigned char major, minor;
short type;
short archnum;
char name[66];
short osnum;
short signature_type; /*!< Signature header type (RPMSIG_HEADERSIG
) */
/*@unused@*/ char reserved[16]; /*!< Pad to 96 bytes -- 8 byte align
ed */
} ;
/**
* Release storage used by file system usage cache.
*/
void freeFilesystems(void)
/*@globals internalState@*/
/*@modifies internalState@*/;
/**
* Return (cached) file system mount points.
* @retval listptr addess of file system names (or NULL)
* @retval num address of number of file systems (or NULL)
* @return 0 on success, 1 on error
*/
int rpmGetFilesystemList( /*@null@*/ /*@out@*/ const char *** listptr,
/*@null@*/ /*@out@*/ int * num)
/*@globals fileSystem, internalState @*/
/*@modifies *listptr, *num, fileSystem, internalState @*/;
/**
* Determine per-file system usage for a list of files.
* @param fileList array of absolute file names
* @param fssizes array of file sizes
* @param numFiles number of files in list
* @retval usagesPtr address of per-file system usage array (or N
ULL)
* @param flags (unused)
* @return 0 on success, 1 on error
*/
int rpmGetFilesystemUsage(const char ** fileList, int_32 * fssizes,
int numFiles, /*@null@*/ /*@out@*/ uint_32 ** usagesPtr,
int flags)
/*@globals rpmGlobalMacroContext,
fileSystem, internalState @*/
/*@modifies *usagesPtr, rpmGlobalMacroContext,
fileSystem, internalState @*/;
/* ==================================================================== */ /* ==================================================================== */
/* --- install/upgrade/erase */ /** \name RPMQV */
/*@{*/
#define INSTALL_PERCENT (1 << 0) /** \ingroup rpmcli
#define INSTALL_HASH (1 << 1) */
#define INSTALL_NODEPS (1 << 2) typedef struct rpmQVArguments_s * QVA_t;
#define INSTALL_NOORDER (1 << 3)
#define INSTALL_LABEL (1 << 4) /* set if we're being verbose */
#define INSTALL_UPGRADE (1 << 5)
#define INSTALL_FRESHEN (1 << 6)
#define UNINSTALL_NODEPS (1 << 0) /** \ingroup rpmcli
#define UNINSTALL_ALLMATCHES (1 << 1) * The command line argument will be used to retrieve header(s) ...
* @todo Move to rpmcli.h
*/
typedef enum rpmQVSources_e {
RPMQV_PACKAGE = 0, /*!< ... from package name db search. */
RPMQV_PATH, /*!< ... from file path db search. */
RPMQV_ALL, /*!< ... from each installed package. */
RPMQV_RPM, /*!< ... from reading binary rpm package. */
RPMQV_GROUP, /*!< ... from group db search. */
RPMQV_WHATPROVIDES, /*!< ... from provides db search. */
RPMQV_WHATREQUIRES, /*!< ... from requires db search. */
RPMQV_TRIGGEREDBY, /*!< ... from trigger db search. */
RPMQV_DBOFFSET, /*!< ... from database header instance. */
RPMQV_SPECFILE, /*!< ... from spec file parse (query only). */
RPMQV_PKGID, /*!< ... from package id (header+payload MD5). */
RPMQV_HDRID, /*!< ... from header id (immutable header SHA1). */
RPMQV_FILEID, /*!< ... from file id (file MD5). */
RPMQV_TID /*!< ... from install transaction id (time stamp). *
/
} rpmQVSources;
int rpmInstall(const char * rootdir, const char ** argv, int installFlags, /** \ingroup rpmcli
int interfaceFlags, int probFilter, rpmRelocation * relocation * Bit(s) for rpmVerifyFile() attributes and result.
s); * @todo Move to rpmcli.h.
int rpmInstallSource(const char * prefix, const char * arg, const char ** s */
pecFile, typedef enum rpmVerifyAttrs_e {
char ** cookie); RPMVERIFY_NONE = 0, /*!< */
int rpmErase(const char * rootdir, const char ** argv, int uninstallFlags, RPMVERIFY_MD5 = (1 << 0), /*!< from %verify(md5) */
int interfaceFlags); RPMVERIFY_FILESIZE = (1 << 1), /*!< from %verify(size) */
RPMVERIFY_LINKTO = (1 << 2), /*!< from %verify(link) */
RPMVERIFY_USER = (1 << 3), /*!< from %verify(user) */
RPMVERIFY_GROUP = (1 << 4), /*!< from %verify(group) */
RPMVERIFY_MTIME = (1 << 5), /*!< from %verify(mtime) */
RPMVERIFY_MODE = (1 << 6), /*!< from %verify(mode) */
RPMVERIFY_RDEV = (1 << 7), /*!< from %verify(rdev) */
/* bits 8-15 unused, reserved for rpmVerifyAttrs */
/* bits 16-19 used in rpmVerifyFlags */
/* bits 20-22 unused */
/* bits 23-27 used in rpmQueryFlags */
RPMVERIFY_READLINKFAIL= (1 << 28), /*!< */
RPMVERIFY_READFAIL = (1 << 29), /*!< */
RPMVERIFY_LSTATFAIL = (1 << 30) /*!< */
/* bit 31 unused */
} rpmVerifyAttrs;
#define RPMVERIFY_ALL ~(RPMVERIFY_NONE)
/** \ingroup rpmcli
* Verify file attributes (including MD5 sum).
* @todo gnorpm and python bindings prevent this from being static.
* @param root path to top of install tree
* @param h header
* @param filenum index of file in header file info arrays
* @retval result address of bit(s) returned to indicate failure
* @param omitMask bit(s) to disable verify checks
* @return 0 on success (or not installed), 1 on error
*/
int rpmVerifyFile(const char * root, Header h, int filenum,
/*@out@*/ rpmVerifyAttrs * result, rpmVerifyAttrs omitMask)
/*@globals fileSystem @*/
/*@modifies h, *result, fileSystem @*/;
/**
* Return exit code from running verify script from header.
* @todo gnorpm/kpackage prevents static, should be using VERIFY_SCRIPT fla
g.
* @param rootDir path to top of install tree
* @param h header
* @param scriptFd file handle to use for stderr (or NULL)
* @return 0 on success
*/
int rpmVerifyScript(const char * rootDir, Header h, /*@null@*/ FD_t scriptF
d)
/*@globals rpmGlobalMacroContext, fileSystem @*/
/*@modifies h, scriptFd,
rpmGlobalMacroContext, fileSystem @*/;
/*@}*/
/* ==================================================================== */ /* ==================================================================== */
/* --- checksig/resign */ /** \name RPMEIU */
/*@{*/
/* --- install/upgrade/erase modes */
#define CHECKSIG_PGP (1 << 0) /** \ingroup rpmcli
#define CHECKSIG_MD5 (1 << 1) * Bit(s) to control rpmInstall() operation.
#define CHECKSIG_GPG (1 << 2) * @todo Move to rpmcli.h
*/
typedef enum rpmInstallInterfaceFlags_e {
INSTALL_NONE = 0,
INSTALL_PERCENT = (1 << 0), /*!< from --percent */
INSTALL_HASH = (1 << 1), /*!< from --hash */
INSTALL_NODEPS = (1 << 2), /*!< from --nodeps */
INSTALL_NOORDER = (1 << 3), /*!< from --noorder */
INSTALL_LABEL = (1 << 4), /*!< from --verbose (notify) */
INSTALL_UPGRADE = (1 << 5), /*!< from --upgrade */
INSTALL_FRESHEN = (1 << 6), /*!< from --freshen */
INSTALL_INSTALL = (1 << 7), /*!< from --install */
INSTALL_ERASE = (1 << 8) /*!< from --erase */
} rpmInstallInterfaceFlags;
int rpmCheckSig(int flags, const char **argv); /** \ingroup rpmcli
int rpmReSign(int add, char *passPhrase, const char **argv); * Bit(s) to control rpmErase() operation.
*/
typedef enum rpmEraseInterfaceFlags_e {
UNINSTALL_NONE = 0,
UNINSTALL_NODEPS = (1 << 0), /*!< from --nodeps */
UNINSTALL_ALLMATCHES= (1 << 1) /*!< from --allmatches */
} rpmEraseInterfaceFlags;
#define ADD_SIGNATURE 1 /*@}*/
#define NEW_SIGNATURE 0 /* ==================================================================== */
/** \name RPMK */
/*@{*/
/** \ingroup signature
* Tags found in signature header from package.
*/
enum rpmtagSignature {
RPMSIGTAG_SIZE = 1000, /*!< Header+Payload size in bytes. */
/* the md5 sum was broken *twice* on big endian machines */
RPMSIGTAG_LEMD5_1 = 1001, /*!< Broken MD5, take 1 */
RPMSIGTAG_PGP = 1002, /*!< PGP 2.6.3 signature. */
RPMSIGTAG_LEMD5_2 = 1003, /*!< Broken MD5, take 2 */
RPMSIGTAG_MD5 = 1004, /*!< MD5 signature. */
RPMSIGTAG_GPG = 1005, /*!< GnuPG signature. */
RPMSIGTAG_PGP5 = 1006, /*!< PGP5 signature @deprecated legacy. */
};
/**
* Return codes from verifySignature().
*/
typedef enum rpmVerifySignatureReturn_e {
RPMSIG_OK = 0, /*!< Signature is OK. */
RPMSIG_UNKNOWN = 1, /*!< Signature is unknown. */
RPMSIG_BAD = 2, /*!< Signature does not verify. */
RPMSIG_NOKEY = 3, /*!< Key is unavailable. */
RPMSIG_NOTTRUSTED = 4 /*!< Signature is OK, but key is not trusted
. */
} rpmVerifySignatureReturn;
/** \ingroup signature
* Verify a signature from a package.
* @param file file name of header+payload
* @param sigTag type of signature
* @param sig signature itself
* @param count no. of bytes in signature
* @retval result detailed text result of signature verification
* @return result of signature verification
*/
rpmVerifySignatureReturn rpmVerifySignature(const char *file,
int_32 sigTag, const void * sig, int count,
/*@out@*/ char * result)
/*@globals rpmGlobalMacroContext, fileSystem @*/
/*@modifies *result, rpmGlobalMacroContext, fileSystem @*/;
/** \ingroup signature
* Destroy signature header from package.
* @param h signature header
* @return NULL always
*/
/*@null@*/ Header rpmFreeSignature(/*@null@*/ /*@killref@*/ Header h)
/*@modifies h @*/;
/*@}*/
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* H_RPMLIB */ #endif /* H_RPMLIB */
 End of changes. 120 change blocks. 
702 lines changed or deleted 1717 lines changed or added


 rpmmacro.h   rpmmacro.h 
#ifndef _H_MACRO_ #ifndef _H_MACRO_
#define _H_MACRO_ #define _H_MACRO_
/** \ingroup rpmio
* \file rpmio/rpmmacro.h
*/
/*! The structure used to store a macro. */ /*! The structure used to store a macro. */
typedef /*@abstract@*/ struct MacroEntry { typedef /*@abstract@*/ struct MacroEntry_s {
struct MacroEntry *prev;/*!< Macro entry stack. */ struct MacroEntry_s *prev;/*!< Macro entry stack. */
const char *name; /*!< Macro name. */ const char *name; /*!< Macro name. */
const char *opts; /*!< Macro parameters (a la getopt) */ const char *opts; /*!< Macro parameters (a la getopt) */
const char *body; /*!< Macro body. */ const char *body; /*!< Macro body. */
int used; /*!< No. of expansions. */ int used; /*!< No. of expansions. */
int level; /*!< Scoping level. */ int level; /*!< Scoping level. */
} MacroEntry; } * MacroEntry;
/*! The structure used to store the set of macros in a context. */ /*! The structure used to store the set of macros in a context. */
typedef /*@abstract@*/ struct MacroContext { typedef /*@abstract@*/ struct MacroContext_s {
MacroEntry ** macroTable; /*!< Macro entry table for context. /*@owned@*//*@null@*/ MacroEntry *macroTable; /*!< Macro entry table for c
*/ ontext. */
int macrosAllocated;/*!< No. of allocated macros. */ int macrosAllocated;/*!< No. of allocated macros. */
int firstFree; /*!< No. of macros. */ int firstFree; /*!< No. of macros. */
} MacroContext; } * MacroContext;
/* /*@-redecl@*/
* Markers for types of macros added throughout rpm. /*@checked@*/
extern MacroContext rpmGlobalMacroContext;
/*@checked@*/
extern MacroContext rpmCLIMacroContext;
/*@=redecl@*/
/** \ingroup rpmrc
* List of macro files to read when configuring rpm.
* This is a colon separated list of files. URI's are permitted as well,
* identified by the token '://', so file paths must not begin with '//'.
*/
/*@-redecl@*/
/*@observer@*/ /*@unchecked@*/
extern const char * macrofiles;
/*@=redecl@*/
/**
* Markers for sources of macros added throughout rpm.
*/ */
#define RMIL_DEFAULT -15 #define RMIL_DEFAULT -15
#define RMIL_MACROFILES -13 #define RMIL_MACROFILES -13
#define RMIL_RPMRC -11 #define RMIL_RPMRC -11
#define RMIL_CMDLINE -7 #define RMIL_CMDLINE -7
#define RMIL_TARBALL -5 #define RMIL_TARBALL -5
#define RMIL_SPEC -3 #define RMIL_SPEC -3
#define RMIL_OLDSPEC -1 #define RMIL_OLDSPEC -1
#define RMIL_GLOBAL 0 #define RMIL_GLOBAL 0
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void rpmDumpMacroTable (MacroContext * mc, FILE * fp); /**
* Print macros to file stream.
* @param mc macro context (NULL uses global context).
* @param fp file stream (NULL uses stderr).
*/
void rpmDumpMacroTable (/*@null@*/ MacroContext mc,
/*@null@*/ FILE * fp)
/*@globals rpmGlobalMacroContext,
fileSystem@*/
/*@modifies *fp, fileSystem @*/;
/* XXX this is used only in build/expression.c and will go away. */ /**
const char *getMacroBody (MacroContext *mc, const char *name); * Expand macro into buffer.
* @deprecated Use rpmExpand().
* @todo Eliminate from API.
* @param spec cookie (unused)
* @param mc macro context (NULL uses global context).
* @retval sbuf input macro to expand, output expansion
* @param slen size of buffer
* @return 0 on success
*/
int expandMacros (/*@null@*/ void * spec, /*@null@*/ MacroContext mc,
/*@in@*/ /*@out@*/ char * sbuf,
size_t slen)
/*@globals rpmGlobalMacroContext,
fileSystem @*/
/*@modifies *sbuf, rpmGlobalMacroContext, fileSystem @*/;
int expandMacros (void * spec, MacroContext * mc, char * sbuf, /**
size_t sbuflen); * Add macro to context.
void addMacro (MacroContext * mc, const char * n, const char * o, * @deprecated Use rpmDefineMacro().
const char * b, int depth); * @param mc macro context (NULL uses global context).
void delMacro (MacroContext * mc, const char * n); * @param n macro name
* @param o macro paramaters
* @param b macro body
* @param level macro recursion level (0 is entry API)
*/
void addMacro (/*@null@*/ MacroContext mc, const char * n,
/*@null@*/ const char * o,
/*@null@*/ const char * b, int level)
/*@globals rpmGlobalMacroContext@*/
/*@modifies mc, rpmGlobalMacroContext @*/;
int rpmDefineMacro (MacroContext * mc, const char * macro, int level); /**
void rpmLoadMacros (MacroContext *mc, int level); * Delete macro from context.
void rpmInitMacros (MacroContext * mc, const char * macrofiles); * @param mc macro context (NULL uses global context).
void rpmFreeMacros (MacroContext * mc); * @param n macro name
*/
void delMacro (/*@null@*/ MacroContext mc, const char * n)
/*@globals rpmGlobalMacroContext@*/
/*@modifies mc, rpmGlobalMacroContext @*/;
#define COMPRESSED_NOT 0 /**
#define COMPRESSED_OTHER 1 * Define macro in context.
#define COMPRESSED_BZIP2 2 * @param mc macro context (NULL uses global context).
int isCompressed (const char * file, int * compressed); * @param n macro name, options, body
* @param level macro recursion level (0 is entry API)
* @return @todo Document.
*/
int rpmDefineMacro (/*@null@*/ MacroContext mc, const char * macro,
int level)
/*@globals rpmGlobalMacroContext@*/
/*@modifies mc, rpmGlobalMacroContext @*/;
char * rpmExpand (const char * arg, ...); /**
char * rpmCleanPath (char * path); * Load macros from specific context into global context.
const char *rpmGetPath (const char * path, ...); * @param mc macro context (NULL does nothing).
const char *rpmGenPath (const char * root, const char * mdir, * @param level macro recursion level (0 is entry API)
const char * file); */
int rpmExpandNumeric (const char * arg); void rpmLoadMacros (/*@null@*/ MacroContext mc, int level)
/*@globals rpmGlobalMacroContext@*/
/*@modifies rpmGlobalMacroContext @*/;
/**
* Initialize global macro context from set of macrofile(s).
* @param mc (unused)
* @param macrofiles colon separated list of macro files (NULL does nothi
ng)
*/
void rpmInitMacros (/*@null@*/ MacroContext mc, const char * macrofiles
)
/*@globals rpmGlobalMacroContext, rpmCLIMacroContext,
fileSystem @*/
/*@modifies rpmGlobalMacroContext, fileSystem @*/;
/**
* Destroy macro context.
* @param mc macro context (NULL uses global context).
*/
void rpmFreeMacros (/*@null@*/ MacroContext mc)
/*@globals rpmGlobalMacroContext@*/
/*@modifies mc, rpmGlobalMacroContext @*/;
typedef enum rpmCompressedMagic_e {
COMPRESSED_NOT = 0, /*!< not compressed */
COMPRESSED_OTHER = 1, /*!< gzip can handle */
COMPRESSED_BZIP2 = 2, /*!< bzip2 can handle */
COMPRESSED_ZIP = 3 /*!< unzip can handle */
} rpmCompressedMagic;
/**
* Return type of compression used in file.
* @param file name of file
* @retval compressed address of compression type
* @return 0 on success, 1 on I/O error
*/
int isCompressed (const char * file,
/*@out@*/ rpmCompressedMagic * compressed)
/*@globals fileSystem@*/
/*@modifies *compressed, fileSystem @*/;
/**
* Return (malloc'ed) concatenated macro expansion(s).
* @param arg macro(s) to expand (NULL terminates list)
* @return macro expansion (malloc'ed)
*/
char * rpmExpand (/*@null@*/ const char * arg, ...)
/*@globals rpmGlobalMacroContext @*/
/*@modifies rpmGlobalMacroContext @*/;
/**
* Canonicalize file path.
* @param path path to canonicalize (in-place)
* @return canonicalized path (malloc'ed)
*/
/*@null@*/ char * rpmCleanPath (/*@null@*/ char * path)
/*@modifies *path @*/;
/**
* Return (malloc'ed) expanded, canonicalized, file path.
* @param path macro(s) to expand (NULL terminates list)
* @return canonicalized path (malloc'ed)
*/
/*@-redecl@*/ /* LCL: shrug */
const char * rpmGetPath (/*@null@*/ const char * path, ...)
/*@globals rpmGlobalMacroContext @*/
/*@modifies rpmGlobalMacroContext @*/;
/*@=redecl@*/
/**
* Merge 3 args into path, any or all of which may be a url.
* The leading part of the first URL encountered is used
* for the result, other URL prefixes are discarded, permitting
* a primitive form of URL inheiritance.
* @param urlroot root URL (often path to chroot, or NULL)
* @param urlmdir directory URL (often a directory, or NULL)
* @param urlfile file URL (often a file, or NULL)
* @return expanded, merged, canonicalized path (malloc'ed)
*/
/*@-redecl@*/ /* LCL: shrug */
const char * rpmGenPath (/*@null@*/ const char * urlroot,
/*@null@*/ const char * urlmdir,
/*@null@*/ const char * urlfile)
/*@globals rpmGlobalMacroContext @*/
/*@modifies rpmGlobalMacroContext @*/;
/*@=redecl@*/
/**
* Return macro expansion as a numeric value.
* Boolean values ('Y' or 'y' returns 1, 'N' or 'n' returns 0)
* are permitted as well. An undefined macro returns 0.
* @param arg macro to expand
* @return numeric value
*/
int rpmExpandNumeric (const char * arg)
/*@globals rpmGlobalMacroContext @*/
/*@modifies rpmGlobalMacroContext @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _H_ MACRO_ */ #endif /* _H_ MACRO_ */
 End of changes. 10 change blocks. 
38 lines changed or deleted 200 lines changed or added


 rpmspec.h   rpmspec.h 
#ifndef _H_SPEC_ #ifndef _H_SPEC_
#define _H_SPEC_ #define _H_SPEC_
/** \file build/rpmspec.h /** \ingroup rpmbuild
* \file build/rpmspec.h
* The Spec and Package data structures used during build. * The Spec and Package data structures used during build.
*/ */
/** \ingroup rpmbuild
*/
typedef struct SpecStruct *Spec; typedef struct SpecStruct *Spec;
#include "rpmmacro.h"
#if 0
struct ReqProvTrigger {
int flags;
char *name;
char *version;
int index; /* Only used for triggers */
struct ReqProvTrigger *next;
};
#endif
/** */ /** \ingroup rpmbuild
*/
struct TriggerFileEntry { struct TriggerFileEntry {
/*@{*/
int index; int index;
/*@only@*/ char *fileName; /*@only@*/ char * fileName;
/*@only@*/ char *script; /*@only@*/ char * script;
/*@only@*/ char *prog; /*@only@*/ char * prog;
/*@owned@*/ struct TriggerFileEntry *next; /*@owned@*/ struct TriggerFileEntry * next;
/*@}*/
}; };
#define RPMBUILD_ISSOURCE 1 #define RPMBUILD_ISSOURCE (1 << 0)
#define RPMBUILD_ISPATCH (1 << 1) #define RPMBUILD_ISPATCH (1 << 1)
#define RPMBUILD_ISICON (1 << 2) #define RPMBUILD_ISICON (1 << 2)
#define RPMBUILD_ISNO (1 << 3) #define RPMBUILD_ISNO (1 << 3)
#define RPMBUILD_DEFAULT_LANG "C" #define RPMBUILD_DEFAULT_LANG "C"
/** */ /** \ingroup rpmbuild
*/
struct Source { struct Source {
/*@{*/ /*@owned@*/ char * fullSource;
/*@owned@*/ char *fullSource; /*@dependent@*/ char * source; /* Pointer into fullSource */
/*@dependent@*/ char *source; /* Pointer into fullSource */
int flags; int flags;
int num; int num;
/*@owned@*/ struct Source *next; /*@owned@*/ struct Source * next;
/*@}*/
}; };
/** */ /** \ingroup rpmbuild
*/
/*@-typeuse@*/
typedef struct ReadLevelEntry { typedef struct ReadLevelEntry {
/*@{*/
int reading; int reading;
/*@dependent@*/ struct ReadLevelEntry *next; /*@dependent@*/
/*@}*/ struct ReadLevelEntry * next;
} RLE_t; } RLE_t;
/*@=typeuse@*/
/** */ /** \ingroup rpmbuild
*/
typedef struct OpenFileInfo { typedef struct OpenFileInfo {
/*@{*/ /*@only@*/ const char * fileName;
/*@only@*/ char *fileName;
FD_t fd; FD_t fd;
int lineNum; int lineNum;
char readBuf[BUFSIZ]; char readBuf[BUFSIZ];
/*@dependent@*/ char *readPtr; /*@dependent@*/
/*@owned@*/ struct OpenFileInfo *next; char * readPtr;
/*@}*/ /*@owned@*/
struct OpenFileInfo * next;
} OFI_t; } OFI_t;
/** */ /** \ingroup rpmbuild
struct spectag { */
/*@{*/ typedef struct spectag_s {
int t_tag; int t_tag;
int t_startx; int t_startx;
int t_nlines; int t_nlines;
/*@only@*/ const char *t_lang; /*@only@*/ const char * t_lang;
/*@only@*/ const char *t_msgid; /*@only@*/ const char * t_msgid;
/*@}*/ } * spectag;
};
/** */ /** \ingroup rpmbuild
struct spectags { */
/*@{*/ typedef struct spectags_s {
/*@owned@*/ struct spectag *st_t; /*@owned@*/ spectag st_t;
int st_nalloc; int st_nalloc;
int st_ntags; int st_ntags;
/*@}*/ } * spectags;
};
/** */ /** \ingroup rpmbuild
struct speclines { */
/*@{*/ typedef struct speclines_s {
/*@only@*/ char **sl_lines; /*@only@*/ char **sl_lines;
int sl_nalloc; int sl_nalloc;
int sl_nlines; int sl_nlines;
/*@}*/ } * speclines;
};
/** The structure used to store values parsed from a spec file. */ /** \ingroup rpmbuild
* The structure used to store values parsed from a spec file.
*/
struct SpecStruct { struct SpecStruct {
/*@{*/ /*@only@*/ const char * specFile; /*!< Name of the spec file. */
/*@only@*/ const char *specFile; /*!< Name of the spec file. */ /*@only@*/ const char * sourceRpmName;
/*@only@*/ const char *sourceRpmName; /*@only@*/ const char * buildRootURL;
/*@only@*/ const char * buildSubdir;
/*@only@*/ const char * rootURL;
/*@owned@*/ struct speclines *sl; /*@owned@*/ /*@null@*/ speclines sl;
/*@owned@*/ struct spectags *st; /*@owned@*/ /*@null@*/ spectags st;
/*@owned@*/ struct OpenFileInfo *fileStack; /*@owned@*/ struct OpenFileInfo * fileStack;
char lbuf[BUFSIZ]; char lbuf[4*BUFSIZ];
char nextpeekc; char nextpeekc;
/*@dependent@*/ char *nextline; /*@dependent@*/ char * nextline;
/*@dependent@*/ char *line; /*@dependent@*/ char * line;
int lineNum; int lineNum;
/*@owned@*/ struct ReadLevelEntry *readStack; /*@owned@*/ struct ReadLevelEntry * readStack;
/*@refcounted@*/ Header buildRestrictions; /*@refcounted@*/ Header buildRestrictions;
/*@owned@*/ struct SpecStruct **buildArchitectureSpecs; /*@owned@*/ /*@null@*/ struct SpecStruct ** BASpecs;
/*@only@*/ const char ** buildArchitectures; /*@only@*/ /*@null@*/ const char ** BANames;
int buildArchitectureCount; int BACount;
int inBuildArchitectures; int recursing; /*!< parse is recursive? */
int force; int force;
int anyarch; int anyarch;
int gotBuildRootURL; int gotBuildRootURL;
/*@only@*/ const char *buildRootURL;
/*@only@*/ const char *buildSubdir;
char *passPhrase; /*@null@*/ char * passPhrase;
int timeCheck; int timeCheck;
char *cookie; /*@null@*/ const char * cookie;
/*@owned@*/ struct Source *sources; /*@owned@*/ struct Source * sources;
int numSources; int numSources;
int noSource; int noSource;
/*@refcounted@*/ Header sourceHeader; /*@refcounted@*/
int sourceCpioCount; Header sourceHeader;
/*@owned@*/ struct cpioFileMapping *sourceCpioList; /*@owned@*/
void * sourceCpioList;
/*@dependent@*/ struct MacroContext *macros; /*@dependent@*/ /*@null@*/ MacroContext macros;
/*@only@*/ const char *rootURL; /*@only@*/ StringBuf prep; /*!< %prep scriptlet. */
/*@only@*/ StringBuf prep; /*!< %prep scriptlet. */ /*@only@*/ StringBuf build; /*!< %build scriptlet. */
/*@only@*/ StringBuf build; /*!< %build scriptlet. */ /*@only@*/ StringBuf install; /*!< %install scriptlet. */
/*@only@*/ StringBuf install; /*!< %install scriptlet. */ /*@only@*/ StringBuf clean; /*!< %clean scriptlet. */
/*@only@*/ StringBuf clean; /*!< %clean scriptlet. */
/*@owned@*/ struct PackageStruct *packages; /*!< Package list. * /*@owned@*/ struct PackageStruct * packages; /*!< Package list. */
/
/*@}*/
}; };
/** The structure used to store values for a package. */ /** \ingroup rpmbuild
* The structure used to store values for a package.
*/
struct PackageStruct { struct PackageStruct {
/*@{*/ /*@refcounted@*/
/*@refcounted@*/ Header header; Header header;
int cpioCount; /*@owned@*/
/*@owned@*/ struct cpioFileMapping *cpioList; void * cpioList;
/*@owned@*/ struct Source *icon; /*@owned@*/ struct Source * icon;
int autoReq; int autoReq;
int autoProv; int autoProv;
char *preInFile; /*!< %pre scriptlet. */ /*@only@*/ const char * preInFile; /*!< %pre scriptlet. */
char *postInFile; /*!< %post scriptlet. */ /*@only@*/ const char * postInFile; /*!< %post scriptlet. */
char *preUnFile; /*!< %preun scriptlet. */ /*@only@*/ const char * preUnFile; /*!< %preun scriptlet. */
char *postUnFile; /*!< %postun scriptlet. */ /*@only@*/ const char * postUnFile; /*!< %postun scriptlet. */
char *verifyFile; /*!< %verifyscript scriptlet. */ /*@only@*/ const char * verifyFile; /*!< %verifyscript scriptlet. */
/*@only@*/ StringBuf specialDoc;
#if 0 /*@only@*/ StringBuf specialDoc;
struct ReqProvTrigger *triggers;
char *triggerScripts;
#endif
/*@only@*/ struct TriggerFileEntry *triggerFiles; /*@only@*/ struct TriggerFileEntry * triggerFiles;
/*@only@*/ const char *fileFile; /*@only@*/ const char * fileFile;
/*@only@*/ StringBuf fileList; /* If NULL, package will not be written /*@only@*/ StringBuf fileList; /* If NULL, package will not be written */
*/
/*@dependent@*/ struct PackageStruct *next; /*@dependent@*/ struct PackageStruct * next;
/*@}*/
}; };
/** */ /** \ingroup rpmbuild
typedef struct PackageStruct *Package; */
typedef struct PackageStruct * Package;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/*@only@*/ Spec newSpec(void); /** \ingroup rpmbuild
void freeSpec(/*@only@*/ Spec spec); * Create and initialize Spec structure.
extern void (*freeSpecVec) (Spec spec); /* XXX FIXME */ * @return spec spec file control structure
*/
/*@only@*/ Spec newSpec(void)
/*@globals rpmGlobalMacroContext @*/
/*@modifies rpmGlobalMacroContext @*/;
struct OpenFileInfo * newOpenFileInfo(void); /** \ingroup rpmbuild
struct spectag *stashSt(Spec spec, Header h, int tag, const char *lang); * Destroy Spec structure.
* @param spec spec file control structure
* @return NULL always
*/
/*@null@*/ Spec freeSpec(/*@only@*/ /*@null@*/ Spec spec)
/*@globals fileSystem @*/
/*@modifies spec, fileSystem @*/;
int addSource(Spec spec, Package pkg, const char *field, int tag); /** \ingroup rpmbuild
int parseNoSource(Spec spec, const char *field, int tag); * @param spec spec file control structure
* @return NULL always
*/
/*@-declundef@*/
extern /*@null@*/ Spec (*freeSpecVec) (Spec spec) /* XXX FIXME */
/*@globals fileSystem @*/
/*@modifies spec, fileSystem @*/;
/*@=declundef@*/
/** \ingroup rpmbuild
*/
struct OpenFileInfo * newOpenFileInfo(void) /*@*/;
/** \ingroup rpmbuild
* @param spec spec file control structure
*/
spectag stashSt(Spec spec, Header h, int tag, const char * lang)
/*@modifies spec->st @*/;
/** \ingroup rpmbuild
* @param spec spec file control structure
*/
int addSource(Spec spec, Package pkg, const char * field, int tag)
/*@globals rpmGlobalMacroContext @*/
/*@modifies spec->sources, spec->numSources,
spec->st, spec->macros,
pkg->icon,
rpmGlobalMacroContext @*/;
/** \ingroup rpmbuild
* @param spec spec file control structure
*/
int parseNoSource(Spec spec, const char * field, int tag)
/*@modifies nothing @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _H_SPEC_ */ #endif /* _H_SPEC_ */
 End of changes. 51 change blocks. 
123 lines changed or deleted 152 lines changed or added


 rpmurl.h   rpmurl.h 
#ifndef H_RPMURL #ifndef H_RPMURL
#define H_RPMURL #define H_RPMURL
/** \ingroup rpmio
* \file rpmio/rpmurl.h
*/
#include <assert.h> #include <assert.h>
typedef enum { /**
URL_IS_UNKNOWN = 0, * Supported URL types.
URL_IS_DASH = 1, */
URL_IS_PATH = 2, typedef enum urltype_e {
URL_IS_FTP = 3, URL_IS_UNKNOWN = 0, /*!< unknown (aka a file) */
URL_IS_HTTP = 4 URL_IS_DASH = 1, /*!< stdin/stdout */
URL_IS_PATH = 2, /*!< file://... */
URL_IS_FTP = 3, /*!< ftp://... */
URL_IS_HTTP = 4 /*!< http://... */
} urltype; } urltype;
#define URLMAGIC 0xd00b1ed0 #define URLMAGIC 0xd00b1ed0
#define URLSANE(u) assert(u && u->magic == URLMAGIC) #define URLSANE(u) assert(u && u->magic == URLMAGIC)
typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo { typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo_s * urlinfo;
/*@refs@*/ int nrefs; /**
const char * url; /* copy of original url */ * URL control structure.
*/
struct urlinfo_s {
/*@refs@*/ int nrefs; /*!< no. of references */
/*@owned@*/ /*@null@*/
const char * url; /*!< copy of original url */
/*@owned@*/ /*@null@*/
const char * service; const char * service;
/*@owned@*/ /*@null@*/
const char * user; const char * user;
/*@owned@*/ /*@null@*/
const char * password; const char * password;
/*@owned@*/ /*@null@*/
const char * host; const char * host;
/*@owned@*/ /*@null@*/
const char * portstr; const char * portstr;
const char * proxyu; /* FTP: proxy user */ /*@owned@*/ /*@null@*/
const char * proxyh; /* FTP/HTTP: proxy host */ const char * proxyu; /*!< FTP: proxy user */
int proxyp; /* FTP/HTTP: proxy port */ /*@owned@*/ /*@null@*/
const char * proxyh; /*!< FTP/HTTP: proxy host */
int proxyp; /*!< FTP/HTTP: proxy port */
int port; int port;
int urltype; int urltype;
FD_t ctrl; /* control channel */ FD_t ctrl; /*!< control channel */
FD_t data; /* per-xfer data channel */ FD_t data; /*!< per-xfer data channel */
int bufAlloced; /* sizeof I/O buffer */ int bufAlloced; /*!< sizeof I/O buffer */
char *buf; /* I/O buffer */ /*@owned@*/ char * buf; /*!< I/O buffer */
int openError; /* Type of open failure */ int openError; /*!< Type of open failure */
int httpVersion; int httpVersion;
int httpHasRange; int httpHasRange;
int magic; int magic;
} *urlinfo; };
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
extern int url_iobuf_size; /*@unchecked@*/
extern int _url_count; /*!< No. of cached URL's. */
urlinfo urlLink(urlinfo u, const char * msg); /*@unchecked@*/
urlinfo XurlLink(urlinfo u, const char * msg, const char * file, uns /*@only@*/ /*@null@*/
igned line); extern urlinfo * _url_cache; /*!< URL cache. */
#define urlLink(_u, _msg) XurlLink(_u, _msg, __FILE__, __LINE__)
urlinfo urlNew(const char * msg); /*@unchecked@*/
urlinfo XurlNew(const char * msg, const char * file, unsigned line); extern int _url_iobuf_size; /*!< Initial size of URL I/O buffer. */
#define RPMURL_IOBUF_SIZE 4096
/*@unchecked@*/
extern int _url_debug; /*!< URL debugging? */
#define RPMURL_DEBUG_IO 0x40000000
#define RPMURL_DEBUG_REFS 0x20000000
/**
* Create a URL control structure instance.
* @param msg debugging identifier (unused)
* @return new instance
*/
/*@unused@*/ urlinfo urlNew(const char * msg) /*@*/;
/** @todo Remove debugging entry from the ABI. */
urlinfo XurlNew(const char * msg, const char * file, unsigned line)
/*@*/;
#define urlNew(_msg) XurlNew(_msg, __FILE__, __LINE__) #define urlNew(_msg) XurlNew(_msg, __FILE__, __LINE__)
urlinfo urlFree( /*@killref@*/ urlinfo u, const char * msg); /**
urlinfo XurlFree( /*@killref@*/ urlinfo u, const char * msg, const c * Reference a URL control structure instance.
har * file, unsigned line); * @param u URL control structure
* @param msg debugging identifier (unused)
* @return referenced instance
*/
/*@unused@*/ urlinfo urlLink(urlinfo u, const char * msg)
/*@modifies u @*/;
/** @todo Remove debugging entry from the ABI. */
urlinfo XurlLink(urlinfo u, const char * msg, const char * file, uns
igned line)
/*@modifies u @*/;
#define urlLink(_u, _msg) XurlLink(_u, _msg, __FILE__, __LINE__)
/**
* Dereference a URL control structure instance.
* @param u URL control structure
* @param msg debugging identifier (unused)
* @return dereferenced instance (NULL if freed)
*/
/*@unused@*/ urlinfo urlFree( /*@killref@*/ urlinfo u, const char * msg)
/*@modifies u @*/;
/** @todo Remove debugging entry from the ABI. */
urlinfo XurlFree( /*@killref@*/ urlinfo u, const char * msg,
const char * file, unsigned line)
/*@globals fileSystem@*/
/*@modifies u, fileSystem @*/;
#define urlFree(_u, _msg) XurlFree(_u, _msg, __FILE__, __LINE__) #define urlFree(_u, _msg) XurlFree(_u, _msg, __FILE__, __LINE__)
void urlFreeCache(void); /**
* Free cached URL control structures.
*/
void urlFreeCache(void)
/*@globals _url_cache, _url_count, fileSystem @*/
/*@modifies _url_cache, _url_count, fileSystem @*/;
urltype urlIsURL(const char * url); /**
int urlPath(const char * url, /*@out@*/ const char ** pathp); * Return type of URL.
int urlSplit(const char * url, /*@out@*/ urlinfo * u); * @param url url string
* @return type of url
*/
urltype urlIsURL(const char * url)
/*@*/;
int urlGetFile(const char * url, const char * dest); /**
* Return path component of URL.
* @param url url string
* @retval pathp pointer to path component of url
* @return type of url
*/
urltype urlPath(const char * url, /*@out@*/ const char ** pathp)
/*@modifies *pathp @*/;
/**
* Parse URL string into a control structure.
* @param url url string
* @retval uret address of new control instance pointer
* @return 0 on success, -1 on error
*/
int urlSplit(const char * url, /*@out@*/ urlinfo * uret)
/*@modifies *uret @*/;
/**
* Copy data from URL to local file.
* @param url url string of source
* @param dest file name of destination
* @return 0 on success, otherwise FTPERR_* code
*/
int urlGetFile(const char * url, /*@null@*/ const char * dest)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* H_RPMURL */ #endif /* H_RPMURL */
 End of changes. 17 change blocks. 
33 lines changed or deleted 130 lines changed or added


 stringbuf.h   stringbuf.h 
#ifndef _STRINGBUF_H_ #ifndef _STRINGBUF_H_
#define _STRINGBUF_H_ #define _STRINGBUF_H_
/** \file lib/stringbuf.h
*
*/
/**
*/
typedef /*@abstract@*/ struct StringBufRec *StringBuf; typedef /*@abstract@*/ struct StringBufRec *StringBuf;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/*@only@*/ StringBuf newStringBuf(void); /**
void freeStringBuf( /*@only@*/ StringBuf sb); */
void truncStringBuf(StringBuf sb); /*@only@*/ StringBuf newStringBuf(void)
/*@observer@*/ char *getStringBuf(StringBuf sb); /*@*/;
void stripTrailingBlanksStringBuf(StringBuf sb);
/**
*/
/*@null@*/ StringBuf freeStringBuf( /*@only@*/ /*@null@*/ StringBuf sb)
/*@modifies sb @*/;
/**
*/
/*@unused@*/
void truncStringBuf(StringBuf sb)
/*@modifies sb @*/;
/**
*/
/*@observer@*/ char * getStringBuf(StringBuf sb)
/*@*/;
/**
*/
void stripTrailingBlanksStringBuf(StringBuf sb)
/*@modifies sb @*/;
/**
*/
#define appendStringBuf(sb, s) appendStringBufAux(sb, s, 0) #define appendStringBuf(sb, s) appendStringBufAux(sb, s, 0)
/**
*/
#define appendLineStringBuf(sb, s) appendStringBufAux(sb, s, 1) #define appendLineStringBuf(sb, s) appendStringBufAux(sb, s, 1)
void appendStringBufAux(StringBuf sb, const char *s, int nl); /**
*/
void appendStringBufAux(StringBuf sb, const char * s, int nl)
/*@modifies sb @*/;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _STRINGBUF_H_ */ #endif /* _STRINGBUF_H_ */
 End of changes. 5 change blocks. 
6 lines changed or deleted 40 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/