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_Metadata * | cr_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) |
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 struct _cr_Metadata cr_Metadata |
Metadata object
Definition at line 85 of file load_metadata.h.
| enum cr_HashTableKey |
Package attribute used as key in the hashtable.
| 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.
| 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.
| void cr_metadata_free | ( | cr_Metadata * | md | ) |
Destroy metadata.
| md | cr_Metadata object |
| GHashTable* cr_metadata_hashtable | ( | cr_Metadata * | md | ) |
Return hashtable from a cr_Metadata
| md | cr_Metadata object. |
| cr_HashTableKey cr_metadata_key | ( | cr_Metadata * | md | ) |
Return cr_HashTableKey from a cr_Metadata
| md | cr_Metadata object. |
| int cr_metadata_load_xml | ( | cr_Metadata * | md, | |
| struct cr_MetadataLocation * | ml, | |||
| GError ** | err | |||
| ) |
Load metadata from the specified location.
| md | metadata object | |
| ml | metadata location | |
| err | GError ** |
| int cr_metadata_locate_and_load_xml | ( | cr_Metadata * | md, | |
| const char * | repopath, | |||
| GError ** | err | |||
| ) |
Locate and load metadata from the specified path.
| md | metadata object | |
| repopath | path to repo (to directory with repodata/ subdir) | |
| err | GError ** |
| 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.
| key | key specifies which value will be (is) used as key in hash table | |
| use_single_chunk | use 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. | |
| pkglist | load only packages which base filename is in this list. If param is NULL all packages are loaded. |
| gboolean cr_metadata_set_dupaction | ( | cr_Metadata * | md, | |
| cr_HashTableKeyDupAction | dupaction | |||
| ) |
Set action how to deal with duplicated items.
1.6.1