drpm
A library for making, reading and applying deltarpm packages
Loading...
Searching...
No Matches
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]optsStructure specifying options for drpm_make().
[in]mbytesPermitted 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_VISIBLE const char * drpm_strerror(int error)
Returns description of error code as a string.
#define DRPM_ERR_OK
no error
Definition drpm.h:73
DRPM_VISIBLE int drpm_read(drpm **delta, const char *filename)
Reads information from a DeltaRPM.
struct drpm drpm
DeltaRPM package info.
Definition drpm.h:164
Parameters
[out]deltaDeltaRPM to be filled with info.
[in]filenameName 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");
#define DRPM_TAG_TYPE
delta type
Definition drpm.h:125
#define DRPM_TYPE_STANDARD
standard deltarpm
Definition drpm.h:90
DRPM_VISIBLE int drpm_get_uint(drpm *delta, int tag, unsigned *target)
Fetches information representable as an unsigned integer.
Parameters
[in]deltaDeltaRPM containing required info.
[in]tagIdentifies which info is required.
[out]targetTagged 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);
#define DRPM_TAG_TGTSIZE
target size
Definition drpm.h:130
DRPM_VISIBLE int drpm_get_ulong(drpm *delta, int tag, unsigned long *target)
Fetches information representable as an unsigned long integer.
Parameters
[in]deltaDeltarpm containing required info.
[in]tagIdentifies which info is required.
[out]targetTagged 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);
#define DRPM_TAG_INTDATALEN
length of internal data
Definition drpm.h:141
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]deltaDeltarpm containing required info.
[in]tagIdentifies which info is required.
[out]targetTagged 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);
#define DRPM_TAG_TGTNEVR
target NEVR (name-epoch:version-release)
Definition drpm.h:129
DRPM_VISIBLE int drpm_get_string(drpm *delta, int tag, char **target)
Fetches information representable as a string.
Parameters
[in]deltaDeltarpm containing required info.
[in]tagIdentifies which info is required.
[out]targetTagged 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);
#define DRPM_TAG_EXTCOPIES
copies from external data (offset adjustment of external copy & length of external copy)
Definition drpm.h:139
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]deltaDeltarpm containing required info.
[in]tagIdentifies which info is required.
[out]targetTagged info will be copied here.
[out]sizeSize 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_VISIBLE int drpm_destroy(drpm **delta)
Frees memory allocated by drpm_read().
Parameters
[out]deltaDeltarpm that is to be freed.
Returns
Error code.
Warning
delta should have been previously initialized with drpm_read(), otherwise behaviour is undefined.