From: Tomas Mlcoch Date: Wed, 28 Mar 2012 07:29:08 +0000 (+0200) Subject: remove unused metadata_parser_2.c X-Git-Tag: upstream/0.2.1~465 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ef079f475308361a18f5961af1c8b6504a04c95f;p=services%2Fcreaterepo_c.git remove unused metadata_parser_2.c --- diff --git a/src/load_metadata_2.c b/src/load_metadata_2.c deleted file mode 100644 index c62d02b..0000000 --- a/src/load_metadata_2.c +++ /dev/null @@ -1,1075 +0,0 @@ -#include -#include -#include -#include -#include "package.h" -#include "logging.h" -#include "misc.h" -#include "load_metadata.h" -#include "load_metadata_2.h" -#include "compression_wrapper.h" - -#undef MODULE -#define MODULE "load_metadata_2: " - -#define CHUNK_SIZE 8192 -#define PKGS_REALLOC_STEP 2000 - - -typedef enum { - NONE_ELEM, - NAME_ELEM, - ARCH_ELEM, - CHECKSUM_ELEM, - SUMMARY_ELEM, - DESCRIPTION_ELEM, - PACKAGER_ELEM, - URL_ELEM, - RPM_LICENSE_ELEM, - RPM_VENDOR_ELEM, - RPM_GROUP_ELEM, - RPM_BUILDHOST_ELEM, - RPM_SOURCERPM_ELEM, - FILE_ELEM, - FILE_DIR_ELEM, - FILE_GHOST_ELEM, - CHANGELOG_ELEM -} PrimaryTextElement; - - -typedef enum { - ROOT, - METADATA, - PACKAGE, - FORMAT, - PROVIDES, - CONFLICTS, - OBSOLETES, - REQUIRES, - // filelists - FILELISTS, - // other - OTHERDATA -} PrimaryParserContext; - - - -struct PrimaryParserData { - int total_pkgs; - int actual_pkg; - int pkgs_size; - Package **pkgs; - - GString *current_string; - GHashTable *hashtable; - Package *pkg; - PrimaryParserContext context; - PrimaryTextElement last_elem; -}; - - - -void free_values_2(gpointer data) -{ - package_free((Package *) data); -} - - - -GHashTable *new_metadata_hashtable() -{ - GHashTable *hashtable = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, free_values_2); - return hashtable; -} - - - -void destroy_metadata_hashtable(GHashTable *hashtable) -{ - if (hashtable) { - g_hash_table_destroy (hashtable); - } -} - - -// primary.xml parser handlers - -void pri_start_handler(void *data, const char *el, const char **attr) { - struct PrimaryParserData *ppd = (struct PrimaryParserData *) data; - Package *pkg = ppd->pkg; - int i; - - // and are most frequently used tags in primary.xml - - // - if (!strcmp(el, "file")) { - ppd->last_elem = FILE_ELEM; - - // - } else if (!strcmp(el, "rpm:entry")) { - Dependency *dependency; - dependency = dependency_new(); - - for (i = 0; attr[i]; i += 2) { - if (!strcmp(attr[i], "name")) { - dependency->name = g_string_chunk_insert(pkg->chunk, attr[i+1]); - } else if (!strcmp(attr[i], "flags")) { - dependency->flags = g_string_chunk_insert(pkg->chunk, attr[i+1]); - } else if (!strcmp(attr[i], "epoch")) { - dependency->epoch = g_string_chunk_insert(pkg->chunk, attr[i+1]); - } else if (!strcmp(attr[i], "ver")) { - dependency->version = g_string_chunk_insert(pkg->chunk, attr[i+1]); - } else if (!strcmp(attr[i], "rel")) { - dependency->release = g_string_chunk_insert(pkg->chunk, attr[i+1]); - } else if (!strcmp(attr[i], "pre")) { - if (!strcmp(attr[i+1], "0") || !strcmp(attr[i+1], "FALSE")) { - dependency->pre = FALSE; - } else { - dependency->pre = TRUE; - } - } else { - g_warning(MODULE"%s: Unknown attribute \"%s\"", __func__, attr[i]); - } - } - - switch (ppd->context) { - case PROVIDES: - pkg->provides = g_slist_prepend(pkg->provides, dependency); - break; - case CONFLICTS: - pkg->conflicts = g_slist_prepend(pkg->conflicts, dependency); - break; - case OBSOLETES: - pkg->obsoletes = g_slist_prepend(pkg->obsoletes, dependency); - break; - case REQUIRES: - pkg->requires = g_slist_prepend(pkg->requires, dependency); - break; - default: - g_free(dependency); - g_warning(MODULE"%s: Bad context (%d) for rpm:entry", __func__, ppd->context); - break; - } - - // - } else if (!strcmp(el, "package")) { - // Check sanity - if (ppd->context != METADATA) { - g_critical(MODULE"%s: Package element: Bad XML context!", __func__); - return; - } - if (ppd->pkg) { - g_critical(MODULE"%s: Package element: Pkg pointer is not NULL", __func__); - return; - } - - ppd->context = PACKAGE; - ppd->pkg = package_new(); - - // - } else if (!strcmp(el, "name")) { - ppd->last_elem = NAME_ELEM; - - // - } else if (!strcmp(el, "arch")) { - ppd->last_elem = ARCH_ELEM; - - // - } else if (!strcmp(el, "version")) { - for (i = 0; attr[i]; i += 2) { - if (!strcmp(attr[i], "epoch")) { - pkg->epoch = g_string_chunk_insert(pkg->chunk, attr[i+1]); - } else if (!strcmp(attr[i], "ver")) { - pkg->version = g_string_chunk_insert(pkg->chunk, attr[i+1]); - } else if (!strcmp(attr[i], "rel")) { - pkg->release = g_string_chunk_insert(pkg->chunk, attr[i+1]); - } else { - g_warning(MODULE"%s: Unknown attribute \"%s\"", __func__, attr[i]); - } - } - - // - } else if (!strcmp(el, "checksum")) { - ppd->last_elem = CHECKSUM_ELEM; - - for (i = 0; attr[i]; i += 2) { - if (!strcmp(attr[i], "type")) { - pkg->checksum_type = g_string_chunk_insert(pkg->chunk, attr[i+1]); - } - } - - // - } else if (!strcmp(el, "summary")) { - ppd->last_elem = SUMMARY_ELEM; - - // - } else if (!strcmp(el, "description")) { - ppd->last_elem = DESCRIPTION_ELEM; - - // - } else if (!strcmp(el, "packager")) { - ppd->last_elem = PACKAGER_ELEM; - - // - } else if (!strcmp(el, "url")) { - ppd->last_elem = URL_ELEM; - - //