createrepo_c library 1.2.1 C library for metadata manipulation

Typedefs | Enumerations | Functions
Load metadata API.

Module for loading yum xml metadata. More...

## 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_HREF, 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)

## 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

## ◆ cr_Metadata

typedef struct _cr_Metadata cr_Metadata

Metadata object

Definition at line 86 of file load_metadata.h.

## Enumeration Type Documentation

## ◆ cr_HashTableKey

enum cr_HashTableKey

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_HREF | pkg location
CR_HT_KEY_SENTINEL | last element, terminator, ..

Definition at line 59 of file load_metadata.h.

## ◆ cr_HashTableKeyDupAction

enum cr_HashTableKeyDupAction

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 75 of file load_metadata.h.

## Function Documentation

## ◆ cr_metadata_free()

void cr_metadata_free | ( | cr_Metadata * | md | ) |

Destroy metadata.

Parameters

  md | cr_Metadata object

## ◆ cr_metadata_hashtable()

GHashTable* cr_metadata_hashtable | ( | cr_Metadata * | md | ) |

Return hashtable from a cr_Metadata

Parameters

  md | cr_Metadata object.

Returns
  Pointer to internal GHashTable.

## ◆ cr_metadata_key()

cr_HashTableKey cr_metadata_key | ( | cr_Metadata * | md | ) |

Return cr_HashTableKey from a cr_Metadata

Parameters

  md | cr_Metadata object.

Returns
  Key type

## ◆ cr_metadata_load_xml()

int cr_metadata_load_xml | ( | cr_Metadata * | md,
|  | struct cr_MetadataLocation * | ml,
|  | GError ** | err
| ) |  |

Load metadata from the specified location.

Parameters

  md | metadata object
  ml | metadata location
  err | GError **

Returns
  cr_Error code

## ◆ cr_metadata_locate_and_load_xml()

int cr_metadata_locate_and_load_xml | ( | cr_Metadata * | md,
|  | const char * | repopath,
|  | GError ** | err
| ) |  |

Locate and load metadata from the specified path.

Parameters

  md | metadata object
  repopath | path to repo (to directory with repodata/ subdir)
  err | GError **

Returns
  cr_Error code

## ◆ cr_metadata_new()

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

  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.

Returns
  empty cr_Metadata object

## ◆ cr_metadata_set_dupaction()

gboolean cr_metadata_set_dupaction | ( | cr_Metadata * | md,
|  | cr_HashTableKeyDupAction | dupaction
| ) |  |

Set action how to deal with duplicated items.

cr_Metadata
struct _cr_Metadata cr_Metadata
Definition: load_metadata.h:86
cr_metadata_hashtable
GHashTable * cr_metadata_hashtable(cr_Metadata *md)
cr_metadata_new
cr_Metadata * cr_metadata_new(cr_HashTableKey key, int use_single_chunk, GSList *pkglist)
cr_metadata_locate_and_load_xml
int cr_metadata_locate_and_load_xml(cr_Metadata *md, const char *repopath, GError **err)
CR_HT_KEY_FILENAME
@ CR_HT_KEY_FILENAME
Definition: load_metadata.h:63