createrepo_c library  0.9.1
C library for metadata manipulation
Load metadata API.

Typedefs

typedef struct _cr_Metadata cr_Metadata
 

Enumerations

enum  cr_HashTableKey {
  CR_HT_KEY_DEFAULT, CR_HT_KEY_HASH = CR_HT_KEY_DEFAULT, CR_HT_KEY_NAME, CR_HT_KEY_FILENAME,
  CR_HT_KEY_SENTINEL
}
 
enum  cr_HashTableKeyDupAction { CR_HT_DUPACT_KEEPFIRST = 0, CR_HT_DUPACT_REMOVEALL, CR_HT_DUPACT_SENTINEL }
 

Functions

cr_HashTableKey cr_metadata_key (cr_Metadata *md)
 
GHashTable * cr_metadata_hashtable (cr_Metadata *md)
 
cr_Metadatacr_metadata_new (cr_HashTableKey key, int use_single_chunk, GSList *pkglist)
 
gboolean cr_metadata_set_dupaction (cr_Metadata *md, cr_HashTableKeyDupAction dupaction)
 
void cr_metadata_free (cr_Metadata *md)
 
int cr_metadata_load_xml (cr_Metadata *md, struct cr_MetadataLocation *ml, GError **err)
 
int cr_metadata_locate_and_load_xml (cr_Metadata *md, const char *repopath, GError **err)
 

Detailed Description

Module for loading yum xml metadata.

Example:

int ret;
cr_Metadata *oldmetadata;
GHashTable hashtable;
// Create new metadata object
oldmetadata = cr_metadata_new(CR_HT_KEY_FILENAME, 1, NULL);
// Load metadata (path to directory which contains repodata/ subdir)
ret = cr_metadata_locate_and_load_xml(oldmetadata, "/foo/bar/repo/")
// Check return code
if (ret != CR_LOAD_METADATA_OK) exit(1);
// Get hash table with all loaded packages (key is package relative path)
hashtable = cr_metadata_hashtable(oldmetadata);
// What to do with hashtable?
// See: http://developer.gnome.org/glib/2.30/glib-Hash-Tables.html

Typedef Documentation

typedef struct _cr_Metadata cr_Metadata

Metadata object

Definition at line 85 of file load_metadata.h.

Enumeration Type Documentation

Package attribute used as key in the hashtable.

Enumerator
CR_HT_KEY_DEFAULT 

default = pkg hash

CR_HT_KEY_HASH 

pkg hash (cr_Package ->pkgId)

CR_HT_KEY_NAME 

pkg name (cr_Package ->name)

CR_HT_KEY_FILENAME 

pkg filename (cr_Package ->location_href)

CR_HT_KEY_SENTINEL 

last element, terminator, ..

Definition at line 59 of file load_metadata.h.

Internally, and by default, the loaded metadata are indexed by pkgId (pkg's hash). But when you select different attribute for indexing (see cr_HashTableKey). The situation that multiple packages has the same (key) attribute. This enum lists provided methos for resolution of such conflicts.

Enumerator
CR_HT_DUPACT_KEEPFIRST 

First encontered item wins, other will be removed - Default

CR_HT_DUPACT_REMOVEALL 

Remove all conflicting items.

CR_HT_DUPACT_SENTINEL 

Last element, terminator, ...

Definition at line 74 of file load_metadata.h.

Function Documentation

void cr_metadata_free ( cr_Metadata md)

Destroy metadata.

Parameters
mdcr_Metadata object
GHashTable* cr_metadata_hashtable ( cr_Metadata md)

Return hashtable from a cr_Metadata

Parameters
mdcr_Metadata object.
Returns
Pointer to internal GHashTable.
cr_HashTableKey cr_metadata_key ( cr_Metadata md)

Return cr_HashTableKey from a cr_Metadata

Parameters
mdcr_Metadata object.
Returns
Key type
int cr_metadata_load_xml ( cr_Metadata md,
struct cr_MetadataLocation ml,
GError **  err 
)

Load metadata from the specified location.

Parameters
mdmetadata object
mlmetadata location
errGError **
Returns
cr_Error code
int cr_metadata_locate_and_load_xml ( cr_Metadata md,
const char *  repopath,
GError **  err 
)

Locate and load metadata from the specified path.

Parameters
mdmetadata object
repopathpath to repo (to directory with repodata/ subdir)
errGError **
Returns
cr_Error code
cr_Metadata* cr_metadata_new ( cr_HashTableKey  key,
int  use_single_chunk,
GSList *  pkglist 
)

Create new (empty) metadata hashtable. It is NOT thread safe to load data into single cr_Metadata from multiple threads. But non modifying access to the loaded data in cr_Metadata is thread safe.

Parameters
keykey specifies which value will be (is) used as key in hash table
use_single_chunkuse only one string chunk (all loaded packages share one string chunk in the cr_Metadata object) Packages will not be standalone objects. This option leads to less memory consumption.
pkglistload only packages which base filename is in this list. If param is NULL all packages are loaded.
Returns
empty cr_Metadata object
gboolean cr_metadata_set_dupaction ( cr_Metadata md,
cr_HashTableKeyDupAction  dupaction 
)

Set action how to deal with duplicated items.