drpm
A library for making, reading and applying deltarpm packages
Typedefs | Functions
DRPM Read

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

Typedefs

typedef struct drpm drpm
 DeltaRPM package info.
 

Functions

int drpm_destroy (drpm **delta)
 Frees memory allocated by drpm_read(). More...
 
int drpm_get_string (drpm *delta, int tag, char **target)
 Fetches information representable as a string. More...
 
int drpm_get_uint (drpm *delta, int tag, unsigned *target)
 Fetches information representable as an unsigned integer. More...
 
int drpm_get_ullong (drpm *delta, int tag, unsigned long long *target)
 Fetches information representable as an unsigned long long integer. More...
 
int drpm_get_ulong (drpm *delta, int tag, unsigned long *target)
 Fetches information representable as an unsigned long integer. More...
 
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. More...
 
int drpm_read (drpm **delta, const char *filename)
 Reads information from a DeltaRPM. More...
 

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()

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;
}
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()

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");
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()

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);
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()

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);
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()

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);
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()

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);
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()

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;
}
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.