# lib/package.c File Reference

`#include "system.h"`
`#include <netinet/in.h>`
`#include <rpmlib.h>`
`#include "misc.h"`
`#include "rpmlead.h"`
`#include "signature.h"`
`#include "debug.h"`

Go to the source code of this file.

## Defines

#define | alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))

## Functions

void | headerMergeLegacySigs (Header h, const Header sig)
| Translate and merge legacy signature tags into header.
Header | headerRegenSigHeader (const Header h)
| Regenerate signature header.
static rpmRC | readPackageHeaders (FD_t fd, struct rpmlead *leadPtr, Header *sigs, Header *hdrPtr)
| Retrieve package components from file handle.
rpmRC | rpmReadPackageInfo (FD_t fd, Header *sigp, Header *hdrp)
| Return package signatures and header from file handle.
rpmRC | rpmReadPackageHeader (FD_t fd, Header *hdrp, int *isSource, int *major, int *minor)
| Return package header and lead info from file handle.

## Detailed Description

Definition in file package.c.

## Define Documentation

#define alloca_strdup | ( | _s |  | ) | strcpy(alloca(strlen(_s)+1), (_s))

| Definition at line 16 of file package.c.

## Function Documentation

static rpmRC readPackageHeaders | ( | FD_t | fd,
|  | struct rpmlead * | leadPtr,
|  | Header * | sigs,
|  | Header * | hdrPtr
| ) | `[static]`

Retrieve package components from file handle.

Parameters:

  | fd | file handle
  | leadPtr | address of lead (or NULL)
  | sigs | address of signatures (or NULL)
  | hdrPtr | address of header (or NULL)

Returns:
  rpmRC return code

Definition at line 128 of file package.c.

References _, alloca_strdup, compressFilelist(), Fileno(), HEADER_MAGIC_NO, HEADER_MAGIC_YES, headerAddEntry(), headerFree(), headerGetEntry(), headerIsEntry(), headerRead(), headerRemoveEntry(), providePackageNVR(), readLead(), RPM_INT32_TYPE, RPM_STRING_ARRAY_TYPE, RPMERR_NEWPACKAGE, rpmError, rpmFreeSignature(), RPMLEAD_MAGIC0, RPMLEAD_MAGIC1, RPMLEAD_MAGIC2, RPMLEAD_MAGIC3, RPMLEAD_SOURCE, RPMRC_BADMAGIC, RPMRC_FAIL, RPMRC_OK, rpmReadSignature(), RPMTAG_DEFAULTPREFIX, RPMTAG_FILEGIDS, RPMTAG_FILEGROUPNAME, RPMTAG_FILEUIDS, RPMTAG_FILEUSERNAME, RPMTAG_PREFIXES, RPMTAG_SOURCEPACKAGE, and stripTrailingChar().

Referenced by rpmReadPackageHeader(), and rpmReadPackageInfo().

rpmRC rpmReadPackageHeader | ( | FD_t | fd,
|  | Header * | hdrp,
|  | int * | isSource,
|  | int * | major,
|  | int * | minor
| ) |

Return package header and lead info from file handle.

Parameters:

  | fd | file handle

Return values:

  | hdrp | address of header (or NULL)
  | isSource | address to return lead source flag (or NULL)
  | major | address to return lead major (or NULL)
  | minor | address to return lead minor (or NULL)

Returns:
  rpmRC return code

Definition at line 249 of file package.c.

References headerMergeLegacySigs(), rpmlead::major, rpmlead::minor, readPackageHeaders(), rpmFreeSignature(), RPMLEAD_SOURCE, RPMRC_OK, and rpmlead::type.

Referenced by IDTXglob(), main(), rpmInstallSourcePackage(), and rpmQueryVerify().

rpmRC rpmReadPackageInfo | ( | FD_t | fd,
|  | Header * | sigp,
|  | Header * | hdrp
| ) |

Return package signatures and header from file handle.

Deprecated:
  Signature tags are appended to header in rpm-4.0.2.

Todo:
  Eliminate.

Parameters:

  | fd | file handle

Return values:

  | sigp | address of signature header (or NULL)
  | hdrp | address of header (or NULL)

Returns:
  rpmRC return code

Definition at line 237 of file package.c.

References headerMergeLegacySigs(), readPackageHeaders(), and RPMRC_OK.

Referenced by readRPM(), and rpmHeaderFromPackage().