void
-cr_free_metadata_location(struct cr_MetadataLocation *ml)
+cr_metadatalocation_free(struct cr_MetadataLocation *ml)
{
if (!ml) {
return;
struct cr_MetadataLocation *
-parse_repomd(const char *repomd_path, const char *repopath, int ignore_sqlite)
+cr_parse_repomd(const char *repomd_path, const char *repopath, int ignore_sqlite)
{
int ret;
xmlChar *name;
struct cr_MetadataLocation *
-get_local_metadata(const char *in_repopath, int ignore_sqlite)
+cr_get_local_metadata(const char *in_repopath, int ignore_sqlite)
{
struct cr_MetadataLocation *ret = NULL;
return ret;
}
- ret = parse_repomd(repomd, repopath, ignore_sqlite);
+ ret = cr_parse_repomd(repomd, repopath, ignore_sqlite);
g_free(repomd);
g_free(repopath);
struct cr_MetadataLocation *
-get_remote_metadata(const char *repopath, int ignore_sqlite)
+cr_get_remote_metadata(const char *repopath, int ignore_sqlite)
{
gchar *url = NULL;
gchar *tmp_repomd = NULL;
// Parse downloaded repomd.xml
- r_location = parse_repomd(tmp_repomd, repopath, ignore_sqlite);
+ r_location = cr_parse_repomd(tmp_repomd, repopath, ignore_sqlite);
if (!r_location) {
g_critical("%s: repomd.xml parser failed on %s", __func__, tmp_repomd);
goto get_remote_metadata_cleanup;
// Parse downloaded data
- ret = get_local_metadata(tmp_dir, ignore_sqlite);
+ ret = cr_get_local_metadata(tmp_dir, ignore_sqlite);
if (ret) {
ret->tmp_dir = g_strdup(tmp_dir);
}
g_free(url);
curl_easy_cleanup(handle);
if (!ret) cr_remove_dir(tmp_dir);
- if (r_location) cr_free_metadata_location(r_location);
+ if (r_location) cr_metadatalocation_free(r_location);
return ret;
}
struct cr_MetadataLocation *
-cr_get_metadata_location(const char *in_repopath, int ignore_sqlite)
+cr_locate_metadata(const char *in_repopath, int ignore_sqlite)
{
struct cr_MetadataLocation *ret = NULL;
g_str_has_prefix(repopath, "https://"))
{
// Download data via curl
- ret = get_remote_metadata(repopath, ignore_sqlite);
+ ret = cr_get_remote_metadata(repopath, ignore_sqlite);
} else {
const char *path = repopath;
if (g_str_has_prefix(repopath, "file://")) {
path = repopath+7;
}
- ret = get_local_metadata(path, ignore_sqlite);
+ ret = cr_get_local_metadata(path, ignore_sqlite);
}
if (ret) {
// Return list of non-null pointers on strings in the passed structure
GSList *
-get_list_of_md_locations (struct cr_MetadataLocation *ml)
+cr_get_list_of_md_locations (struct cr_MetadataLocation *ml)
{
GSList *list = NULL;
void
-free_list_of_md_locations(GSList *list)
+cr_free_list_of_md_locations(GSList *list)
{
if (list) {
g_slist_free(list);
// Remove all metadata listed in repomd.xml
- ml = cr_get_metadata_location(repopath, 0);
+ ml = cr_locate_metadata(repopath, 0);
if (ml) {
- GSList *list = get_list_of_md_locations(ml);
+ GSList *list = cr_get_list_of_md_locations(ml);
GSList *element;
for (element=list; element; element=element->next) {
}
}
- free_list_of_md_locations(list);
- cr_free_metadata_location(ml);
+ cr_free_list_of_md_locations(list);
+ cr_metadatalocation_free(ml);
}
void
-free_old_file(gpointer data)
+cr_free_old_file(gpointer data)
{
OldFile *old_file = (OldFile *) data;
g_free(old_file->path);
gint
-cmp_old_repodata_files(gconstpointer a, gconstpointer b)
+cr_cmp_old_repodata_files(gconstpointer a, gconstpointer b)
{
if (((OldFile *) a)->mtime < ((OldFile *) b)->mtime)
return 1;
void
-stat_and_insert(const gchar *dirname, const gchar *filename, GSList **list)
+cr_stat_and_insert(const gchar *dirname, const gchar *filename, GSList **list)
{
struct stat buf;
OldFile *old_file;
old_file = g_malloc0(sizeof(OldFile));
old_file->mtime = buf.st_mtime;
old_file->path = path;
- *list = g_slist_insert_sorted(*list, old_file, cmp_old_repodata_files);
+ *list = g_slist_insert_sorted(*list, old_file, cr_cmp_old_repodata_files);
}
int
-remove_listed_files(GSList *list, int retain)
+cr_remove_listed_files(GSList *list, int retain)
{
int removed = 0;
GSList *el;
name_without_suffix = g_strndup(file, (dot - file));
if (g_str_has_suffix(name_without_suffix, "primary.xml")) {
- stat_and_insert(full_repopath, file, &pri_lst);
+ cr_stat_and_insert(full_repopath, file, &pri_lst);
} else if (g_str_has_suffix(name_without_suffix, "primary.sqlite")) {
- stat_and_insert(full_repopath, file, &pri_db_lst);
+ cr_stat_and_insert(full_repopath, file, &pri_db_lst);
} else if (g_str_has_suffix(name_without_suffix, "filelists.xml")) {
- stat_and_insert(full_repopath, file, &fil_lst);
+ cr_stat_and_insert(full_repopath, file, &fil_lst);
} else if (g_str_has_suffix(name_without_suffix, "filelists.sqlite")) {
- stat_and_insert(full_repopath, file, &fil_db_lst);
+ cr_stat_and_insert(full_repopath, file, &fil_db_lst);
} else if (g_str_has_suffix(name_without_suffix, "other.xml")) {
- stat_and_insert(full_repopath, file, &oth_lst);
+ cr_stat_and_insert(full_repopath, file, &oth_lst);
} else if (g_str_has_suffix(name_without_suffix, "other.sqlite")) {
- stat_and_insert(full_repopath, file, &oth_db_lst);
+ cr_stat_and_insert(full_repopath, file, &oth_db_lst);
}
g_free(name_without_suffix);
}
g_free(repomd_path);
g_free(full_repopath);
- remove_listed_files(pri_lst, retain);
- remove_listed_files(pri_db_lst, retain);
- remove_listed_files(fil_lst, retain);
- remove_listed_files(fil_db_lst, retain);
- remove_listed_files(oth_lst, retain);
- remove_listed_files(oth_db_lst, retain);
-
- cr_slist_free_full(pri_lst, free_old_file);
- cr_slist_free_full(pri_db_lst, free_old_file);
- cr_slist_free_full(fil_lst, free_old_file);
- cr_slist_free_full(fil_db_lst, free_old_file);
- cr_slist_free_full(oth_lst, free_old_file);
- cr_slist_free_full(oth_db_lst, free_old_file);
+ cr_remove_listed_files(pri_lst, retain);
+ cr_remove_listed_files(pri_db_lst, retain);
+ cr_remove_listed_files(fil_lst, retain);
+ cr_remove_listed_files(fil_db_lst, retain);
+ cr_remove_listed_files(oth_lst, retain);
+ cr_remove_listed_files(oth_db_lst, retain);
+
+ cr_slist_free_full(pri_lst, cr_free_old_file);
+ cr_slist_free_full(pri_db_lst, cr_free_old_file);
+ cr_slist_free_full(fil_lst, cr_free_old_file);
+ cr_slist_free_full(fil_db_lst, cr_free_old_file);
+ cr_slist_free_full(oth_lst, cr_free_old_file);
+ cr_slist_free_full(oth_db_lst, cr_free_old_file);
return 0;
}
gboolean cr_download_failed = FALSE;
for (element = cmd_options->repo_list; element; element = g_slist_next(element)) {
- struct cr_MetadataLocation *loc = cr_get_metadata_location((gchar *) element->data, 1);
+ struct cr_MetadataLocation *loc = cr_locate_metadata((gchar *) element->data, 1);
if (!loc) {
g_warning("Downloading of repodata failed: %s", (gchar *) element->data);
cr_download_failed = TRUE;
// Remove downloaded metadata and free structures
for (element = local_repos; element; element = g_slist_next(element)) {
struct cr_MetadataLocation *loc = (struct cr_MetadataLocation *) element->data;
- cr_free_metadata_location(loc);
+ cr_metadatalocation_free(loc);
}
return 1;
}
if (cmd_options->noarch_repo_url) {
struct cr_MetadataLocation *noarch_ml;
- noarch_ml = cr_get_metadata_location(cmd_options->noarch_repo_url, 1);
+ noarch_ml = cr_locate_metadata(cmd_options->noarch_repo_url, 1);
noarch_metadata = cr_new_metadata(CR_HT_KEY_FILENAME, 0, NULL);
// Base paths in output of original createrepo doesn't have trailing '/'
g_error("Cannot load noarch repo: \"%s\"", noarch_ml->repomd);
cr_destroy_metadata(noarch_metadata);
// TODO cleanup
- cr_free_metadata_location(noarch_ml);
+ cr_metadatalocation_free(noarch_ml);
return 1;
}
}
g_free(noarch_repopath);
- cr_free_metadata_location(noarch_ml);
+ cr_metadatalocation_free(noarch_ml);
}
for (element = local_repos; element; element = g_slist_next(element)) {
struct cr_MetadataLocation *loc = (struct cr_MetadataLocation *) element->data;
- cr_free_metadata_location(loc);
+ cr_metadatalocation_free(loc);
}
g_slist_free (local_repos);