drpm: DRPM Read

drpm A library for making, reading and applying deltarpm packages

Loading...
Searching...
No Matches
Typedefs | Functions
DRPM Read

Tools for extracting information from DeltaRPM files. More...

## Typedefs
typedef struct drpm | drpm
| DeltaRPM package info.

## Functions
DRPM_VISIBLE int | drpm_destroy (drpm **delta)
| Frees memory allocated by drpm_read().
DRPM_VISIBLE int | drpm_get_string (drpm *delta, int tag, char **target)
| Fetches information representable as a string.
DRPM_VISIBLE int | drpm_get_uint (drpm *delta, int tag, unsigned *target)
| Fetches information representable as an unsigned integer.
DRPM_VISIBLE int | drpm_get_ullong (drpm *delta, int tag, unsigned long long *target)
| Fetches information representable as an unsigned long long integer.
DRPM_VISIBLE int | drpm_get_ulong (drpm *delta, int tag, unsigned long *target)
| Fetches information representable as an unsigned long integer.
DRPM_VISIBLE int | drpm_get_ulong_array (drpm *delta, int tag, unsigned long **target, unsigned long *size)
| Fetches information representable as an array of unsigned long integers.
DRPM_VISIBLE int | drpm_read (drpm **delta, const char *filename)
| Reads information from a DeltaRPM.

## Detailed Description

Tools for extracting information from DeltaRPM files.

Limits memory usage.

As drpm_make() normally needs about three to four times the size of the rpm's uncompressed payload, this option may be used to enable a sliding block algorithm that needs `mbytes` megabytes of memory. This trades memory usage with the size of the created DeltaRPM.

Parameters

  [out] | opts | Structure specifying options for drpm_make().
  [in] | mbytes | Permitted memory usage in megabytes.

Returns
  Error code.

See also
  drpm_make()

## Function Documentation

## ◆ drpm_read()

DRPM_VISIBLE int drpm_read | ( | drpm ** | delta,
|  | const char * | filename )

Reads information from a DeltaRPM.

Reads information from DeltaRPM package `filename` into `*delta`. Example of usage:

drpm *delta = NULL;
int error = drpm_read(&delta, "foo.drpm");
if (error != DRPM_ERR_OK) {
fprintf(stderr, "drpm error: %s\n", drpm_strerror(error));
return;
}
drpm_strerror
DRPM_VISIBLE const char * drpm_strerror(int error)
Returns description of error code as a string.
DRPM_ERR_OK
#define DRPM_ERR_OK
no error
Definition drpm.h:73
drpm_read
DRPM_VISIBLE int drpm_read(drpm **delta, const char *filename)
Reads information from a DeltaRPM.
drpm
struct drpm drpm
DeltaRPM package info.
Definition drpm.h:164

Parameters

  [out] | delta | DeltaRPM to be filled with info.
  [in] | filename | Name of DeltaRPM file whose data is to be read.

Returns
  Error code.

Note
  Memory allocated by calling drpm_read() should later be freed by calling drpm_destroy().

## ◆ drpm_get_uint()

DRPM_VISIBLE int drpm_get_uint | ( | drpm * | delta,
|  | int | tag,
|  | unsigned * | target )

Fetches information representable as an unsigned integer.

Fetches information identified by `tag` from `delta` and copies it to address pointed to by `target`.

Example of usage:

unsigned type;
int error = drpm_get_uint(delta, DRPM_TAG_TYPE, &type);
if (error != DRPM_ERR_OK) {
fprintf(stderr, "drpm error: %s\n", drpm_strerror(error));
return;
}
printf("This is a %s deltarpm\n", (type == DRPM_TYPE_STANDARD) ? "standard" : "rpm-only");
DRPM_TAG_TYPE
#define DRPM_TAG_TYPE
delta type
Definition drpm.h:125
DRPM_TYPE_STANDARD
#define DRPM_TYPE_STANDARD
standard deltarpm
Definition drpm.h:90
drpm_get_uint
DRPM_VISIBLE int drpm_get_uint(drpm *delta, int tag, unsigned *target)
Fetches information representable as an unsigned integer.

Parameters

  [in] | delta | DeltaRPM containing required info.
  [in] | tag | Identifies which info is required.
  [out] | target | Tagged info will be copied here.

Returns
  error number

Warning
  `delta` should have been previously initialized with drpm_read(), otherwise behaviour is undefined.

See also
  DRPM_TAG_VERSION
  DRPM_TAG_TYPE
  DRPM_TAG_COMP
  DRPM_TAG_TGTCOMP

## ◆ drpm_get_ulong()

DRPM_VISIBLE int drpm_get_ulong | ( | drpm * | delta,
|  | int | tag,
|  | unsigned long * | target )

Fetches information representable as an unsigned long integer.

Fetches information identified by `tag` from `delta` and copies it to address pointed to by `target`.

Example of usage:

unsigned long tgt_size;
int error = drpm_get_ulong(delta, DRPM_TAG_TGTSIZE, &tgt_size);
if (error != DRPM_ERR_OK) {
fprintf(stderr, "drpm error: %s\n", drpm_strerror(error));
return;
}
printf("Size of new RPM: %lu\n", tgt_size);
DRPM_TAG_TGTSIZE
#define DRPM_TAG_TGTSIZE
target size
Definition drpm.h:130
drpm_get_ulong
DRPM_VISIBLE int drpm_get_ulong(drpm *delta, int tag, unsigned long *target)
Fetches information representable as an unsigned long integer.

Parameters

  [in] | delta | Deltarpm containing required info.
  [in] | tag | Identifies which info is required.
  [out] | target | Tagged info will be copied here.

Returns
  Error code.

Warning
  `delta` should have been previously initialized with drpm_read(), otherwise behaviour is undefined.

See also
  DRPM_TAG_TGTSIZE
  DRPM_TAG_TGTHEADERLEN
  DRPM_TAG_PAYLOADFMTOFF

## ◆ drpm_get_ullong()

DRPM_VISIBLE int drpm_get_ullong | ( | drpm * | delta,
|  | int | tag,
|  | unsigned long long * | target )

Fetches information representable as an unsigned long long integer.

Fetches information identified by `tag` from `delta` and copies it to address pointed to by `target`.

Example of usage:

unsigned long long int_data_len;
int error = drpm_get_ullong(delta, DRPM_TAG_INTDATALEN, &int_data_len);
if (error != DRPM_ERR_OK) {
fprintf(stderr, "drpm error: %s\n", drpm_strerror(error));
return;
}
printf("Length of internal data: %llu\n", int_data_len);
DRPM_TAG_INTDATALEN
#define DRPM_TAG_INTDATALEN
length of internal data
Definition drpm.h:141
drpm_get_ullong
DRPM_VISIBLE int drpm_get_ullong(drpm *delta, int tag, unsigned long long *target)
Fetches information representable as an unsigned long long integer.

Parameters

  [in] | delta | Deltarpm containing required info.
  [in] | tag | Identifies which info is required.
  [out] | target | Tagged info will be copied here.

Returns
  Error code.

Warning
  `delta` should have been previously initialized with drpm_read(), otherwise behaviour is undefined.

See also
  DRPM_TAG_EXTDATALEN
  DRPM_TAG_INTDATALEN

## ◆ drpm_get_string()

DRPM_VISIBLE int drpm_get_string | ( | drpm * | delta,
|  | int | tag,
|  | char ** | target )

Fetches information representable as a string.

Fetches string-type information identified by `tag` from `delta`, copies it to space previously allocated by the function itself and saves the address to `*target`.

Example of usage:

char *tgt_nevr;
int error = drpm_get_string(delta, DRPM_TAG_TGTNEVR, &tgt_nevr);
if (error != DRPM_ERR_OK) {
fprintf(stderr, "drpm error: %s\n", drpm_strerror(error));
return;
}
printf("Target NEVR: %s\n", tgt_nevr);
free(tgt_nevr);
DRPM_TAG_TGTNEVR
#define DRPM_TAG_TGTNEVR
target NEVR (name-epoch:version-release)
Definition drpm.h:129
drpm_get_string
DRPM_VISIBLE int drpm_get_string(drpm *delta, int tag, char **target)
Fetches information representable as a string.

Parameters

  [in] | delta | Deltarpm containing required info.
  [in] | tag | Identifies which info is required.
  [out] | target | Tagged info will be copied here.

Returns
  Error code.

Note
  `*target` should be freed manually by the user when no longer needed.

Warning
  `delta` should have been previously initialized with drpm_read(), otherwise behaviour is undefined.

See also
  DRPM_TAG_FILENAME
  DRPM_TAG_SEQUENCE
  DRPM_TAG_SRCNEVR
  DRPM_TAG_TGTNEVR
  DRPM_TAG_TGTMD5
  DRPM_TAG_TGTCOMPPARAM
  DRPM_TAG_TGTLEAD

## ◆ drpm_get_ulong_array()

DRPM_VISIBLE int drpm_get_ulong_array | ( | drpm * | delta,
|  | int | tag,
|  | unsigned long ** | target,
|  | unsigned long * | size )

Fetches information representable as an array of unsigned long integers.

Fetches information identified by `tag` from `delta`, copies it to space previously allocated by the function itself, saves the address to `*target` and stores size in `*size`.

Example of usage:

unsigned long *ext_copies;
unsigned long ext_copies_size;
int error = drpm_get_ulong_array(delta, DRPM_TAG_EXTCOPIES, &ext_copies, &ext_copies_size);
if (error != DRPM_ERR_OK) {
fprintf(stderr, "drpm error: %s\n", drpm_strerror(error));
return;
}
for (unsigned long i = 1; i < ext_copies_size; i += 2)
printf("External copy: offset adjustment = %lu, length = %lu\n", ext_copies[i-1], ext_copies[i]);
free(ext_copies);
DRPM_TAG_EXTCOPIES
#define DRPM_TAG_EXTCOPIES
copies from external data (offset adjustment of external copy & length of external copy)
Definition drpm.h:139
drpm_get_ulong_array
DRPM_VISIBLE int drpm_get_ulong_array(drpm *delta, int tag, unsigned long **target, unsigned long *size)
Fetches information representable as an array of unsigned long integers.

Parameters

  [in] | delta | Deltarpm containing required info.
  [in] | tag | Identifies which info is required.
  [out] | target | Tagged info will be copied here.
  [out] | size | Size of array will be copied here.

Returns
  Error code.

Note
  `*target` should be freed manually by the user when no longer needed.

Warning
  `delta` should have been previously initialized with drpm_read(), otherwise behaviour is undefined.

See also
  DRPM_TAG_ADJELEMS
  DRPM_TAG_INTCOPIES
  DRPM_TAG_EXTCOPIES

## ◆ drpm_destroy()

DRPM_VISIBLE int drpm_destroy | ( | drpm ** | delta | ) |

Frees memory allocated by drpm_read().

Frees memory pointed to by `*delta` and sets `*delta` to `NULL`.

Example of usage:

int error = drpm_destroy(&delta);
if (error != DRPM_ERR_OK) {
fprintf(stderr, "drpm error: %s\n", drpm_strerror(error));
return;
}
drpm_destroy
DRPM_VISIBLE int drpm_destroy(drpm **delta)
Frees memory allocated by drpm_read().

Parameters

  [out] | delta | Deltarpm that is to be freed.

Returns
  Error code.

Warning
  `delta` should have been previously initialized with drpm_read(), otherwise behaviour is undefined.