# lib/header.h File Reference

An rpm header carries all information about a package. More...

`#include <stdio.h>`
`#include <rpmio.h>`
`#include <hdrinline.h>`

Go to the source code of this file.

## Data Structures

struct | headerTagTableEntry_s
struct | headerSprintfExtension_s
union | hRET_s
struct | HE_s
struct | HV_s

## Defines

#define | RPM_MIN_TYPE 0
#define | RPM_MAX_TYPE 9
#define | HEADER_IMAGE 61
| Header private tags.
#define | HEADER_SIGNATURES 62
#define | HEADER_IMMUTABLE 63
#define | HEADER_REGIONS 64
#define | HEADER_I18NTABLE 100
#define | HEADER_SIGBASE 256
#define | HEADER_TAGBASE 1000

## Typedefs

typedef int | int_32
typedef short int | int_16
typedef char | int_8
typedef unsigned int | uint_32
typedef unsigned short | uint_16
typedef const char * | errmsg_t
typedef int_32 * | hTAG_t
typedef int_32 * | hTYP_t
typedef const void * | hPTR_t
typedef int_32 * | hCNT_t
typedef struct headerToken * | Header
typedef struct headerIteratorS * | HeaderIterator
typedef struct headerTagTableEntry_s * | headerTagTableEntry
| Associate tag names with numeric values.
typedef char *(* | headerTagFormatFunction )(int_32 type, const void *data, char *formatPrefix, int padding, int element)
| HEADER_EXT_TAG format function prototype.
typedef int(* | headerTagTagFunction )(Header h, hTYP_t type, hPTR_t *data, hCNT_t count, int *freeData)
| HEADER_EXT_FORMAT format function prototype.
typedef struct headerSprintfExtension_s * | headerSprintfExtension
| Define header tag output formats.
typedef enum rpmTagType_e | rpmTagType
| The basic types of data in tags from headers.
typedef enum rpmSubTagType_e | rpmSubTagType
| New rpm data types under consideration/development.
typedef union hRET_s * | hRET_t
typedef struct HE_s * | HE_t
typedef Header(* | HDRnew )(void)
| Create new (empty) header instance.
typedef Header(* | HDRfree )(Header h)
| Dereference a header instance.
typedef Header(* | HDRlink )(Header h)
| Reference a header instance.
typedef Header(* | HDRunlink )(Header h)
| Dereference a header instance.
typedef void(* | HDRsort )(Header h)
| Sort tags in header.
typedef void(* | HDRunsort )(Header h)
| Restore tags in header to original ordering.
typedef unsigned int(* | HDRsizeof )(Header h, enum hMagic magicp)
| Return size of on-disk header representation in bytes.
typedef void *(* | HDRunload )(Header h)
| Convert header to on-disk representation.
typedef Header(* | HDRreload )(Header h, int tag)
| Convert header to on-disk representation, and then reload.
typedef Header(* | HDRcopy )(Header h)
| Duplicate a header.
typedef Header(* | HDRload )(void *uh)
| Convert header to in-memory representation.
typedef Header(* | HDRcopyload )(const void *uh)
| Make a copy and convert header to in-memory representation.
typedef Header(* | HDRhdrread )(FD_t fd, enum hMagic magicp)
| Read (and load) header from file handle.
typedef int(* | HDRhdrwrite )(FD_t fd, Header h, enum hMagic magicp)
| Write (with unload) header to file handle.
typedef int(* | HDRisentry )(Header h, int_32 tag)
| Check if tag is in header.
typedef void *(* | HDRfreetag )(Header h, const void *data, rpmTagType type)
| Free data allocated when retrieved from header.
typedef int(* | HDRget )(Header h, int_32 tag, hTYP_t type, void **p, hCNT_t c)
| Retrieve tag value.
typedef int(* | HDRgetmin )(Header h, int_32 tag, hTYP_t type, hPTR_t *p, hCNT_t c)
| Retrieve tag value using header internal array.
typedef int(* | HDRadd )(Header h, int_32 tag, int_32 type, const void *p, int_32 c)
| Add tag to header.
typedef int(* | HDRappend )(Header h, int_32 tag, int_32 type, const void *p, int_32 c)
| Append element to tag array in header.
typedef int(* | HDRaddorappend )(Header h, int_32 tag, int_32 type, const void *p, int_32 c)
| Add or append element to tag array in header.
typedef int(* | HDRaddi18n )(Header h, int_32 tag, const char *string, const char *lang)
| Add locale specific tag to header.
typedef int(* | HDRmodify )(Header h, int_32 tag, int_32 type, const void *p, int_32 c)
| Modify tag in header.
typedef int(* | HDRremove )(Header h, int_32 tag)
| Delete tag in header.
typedef char *(* | HDRhdrsprintf )(Header h, const char *fmt, const struct headerTagTableEntry_s *tags, const struct headerSprintfExtension_s *extensions, errmsg_t *errmsg)
| Return formatted output string from header tags.
typedef void(* | HDRcopytags )(Header headerFrom, Header headerTo, hTAG_t tagstocopy)
| Duplicate tag values from one header into another.
typedef HeaderIterator(* | HDRfreeiter )(HeaderIterator hi)
| Destroy header tag iterator.
typedef HeaderIterator(* | HDRinititer )(Header h)
| Create header tag iterator.
typedef int(* | HDRnextiter )(HeaderIterator hi, hTAG_t tag, hTYP_t type, hPTR_t *p, hCNT_t c)
| Return next tag from header.
typedef struct HV_s * | HV_t
| Header method vectors.

## Enumerations

enum | headerSprintfExtenstionType { HEADER_EXT_LAST = 0, HEADER_EXT_FORMAT, HEADER_EXT_MORE, HEADER_EXT_TAG }
enum | hMagic { HEADER_MAGIC_NO = 0, HEADER_MAGIC_YES = 1 }
| Include calculation for 8 bytes of (magic, 0)? More...
enum | rpmTagType_e { RPM_NULL_TYPE = 0, RPM_CHAR_TYPE = 1, RPM_INT8_TYPE = 2, RPM_INT16_TYPE = 3, RPM_INT32_TYPE = 4, RPM_STRING_TYPE = 6, RPM_BIN_TYPE = 7, RPM_STRING_ARRAY_TYPE = 8, RPM_I18NSTRING_TYPE }
| The basic types of data in tags from headers. More...
enum | rpmSubTagType_e { RPM_REGION_TYPE = -10, RPM_BIN_ARRAY_TYPE = -11, RPM_XREF_TYPE = -12 }
| New rpm data types under consideration/development. More...

## Functions

static void * | headerFreeData (const void *data, rpmTagType type)
| Free data allocated when retrieved from header.

## Variables

struct headerSprintfExtension_s | headerDefaultFormats []
| Supported default header tag output formats.

## Detailed Description

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.

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 region". 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(), etc.) 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.

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.

Definition in file header.h.

## Define Documentation

#define HEADER_I18NTABLE 100

Definition at line 258 of file header.h.

#define HEADER_IMAGE 61

Header private tags.

Note:
  General use tags should start at 1000 (RPM's tag space starts there).

Definition at line 254 of file header.h.

#define HEADER_IMMUTABLE 63

Definition at line 256 of file header.h.

#define HEADER_REGIONS 64

Definition at line 257 of file header.h.

#define HEADER_SIGBASE 256

Definition at line 259 of file header.h.

#define HEADER_SIGNATURES 62

Definition at line 255 of file header.h.

#define HEADER_TAGBASE 1000

Definition at line 260 of file header.h.

#define RPM_MAX_TYPE 9

#define RPM_MIN_TYPE 0

## Typedef Documentation

typedef int_32* hCNT_t

Definition at line 119 of file header.h.

typedef struct HE_s * HE_t

typedef const void* hPTR_t

Definition at line 118 of file header.h.

typedef union hRET_s * hRET_t

typedef int_32* hTYP_t

Definition at line 117 of file header.h.

typedef short int int_16

Definition at line 102 of file header.h.

typedef int int_32

Definition at line 101 of file header.h.

typedef char int_8

Definition at line 103 of file header.h.

typedef unsigned short uint_16

Definition at line 106 of file header.h.

typedef unsigned int uint_32

Definition at line 105 of file header.h.