void free_options(struct CmdOptions *options) { g_free(options->basedir); g_free(options->location_base); g_free(options->outputdir); g_free(options->pkglist); g_free(options->checksum); g_free(options->compress_type); g_free(options->groupfile); g_free(options->groupfile_fullpath); g_free(options->revision); g_free(options->retain_old_md_by_age); g_free(options->cachedir); g_free(options->checksum_cachedir); g_strfreev(options->excludes); g_strfreev(options->includepkg); g_strfreev(options->distro_tags); g_strfreev(options->content_tags); g_strfreev(options->repo_tags); g_strfreev(options->oldpackagedirs); cr_slist_free_full(options->include_pkgs, g_free); cr_slist_free_full(options->exclude_masks, (GDestroyNotify) g_pattern_spec_free); cr_slist_free_full(options->l_update_md_paths, g_free); cr_slist_free_full(options->distro_cpeids, g_free); cr_slist_free_full(options->distro_values, g_free); g_slist_free(options->oldpackagedirs_paths); }
void cr_repomd_free(cr_Repomd *repomd) { if (!repomd) return; cr_slist_free_full(repomd->records, (GDestroyNotify) cr_repomd_record_free ); g_slist_free(repomd->repo_tags); cr_slist_free_full(repomd->distro_tags, (GDestroyNotify) g_free); g_slist_free(repomd->content_tags); g_string_chunk_free(repomd->chunk); g_free(repomd); }
int main(int argc, char **argv) { gboolean ret = TRUE; RawCmdOptions options; GError *err = NULL; // Parse arguments parse_arguments(&argc, &argv, &options, &err); if (err) { g_printerr("%s\n", err->message); print_usage(); g_error_free(err); exit(EXIT_FAILURE); } // Set logging cr_setup_logging(FALSE, options.verbose); // Print version if required if (options.version) { printf("Version: %s\n", cr_version_string_with_features()); exit(EXIT_SUCCESS); } // Check arguments check_arguments(&options, &err); if (err) { g_printerr("%s\n", err->message); print_usage(); g_error_free(err); exit(EXIT_FAILURE); } // Emit debug message with version g_debug("Version: %s", cr_version_string_with_features()); // Prepare list of tasks to do gchar *repodatadir = NULL; GSList *modifyrepotasks = NULL; if (!options.batchfile && !options.remove && argc == 3) { // three arguments (prog, metadata, repodata_dir) repodatadir = argv[2]; ret = cmd_options_to_task(&modifyrepotasks, &options, argv[1], &err); } else if (options.batchfile && argc == 2) { // two arguments (prog, repodata_dir) repodatadir = argv[1]; ret = cr_modifyrepo_parse_batchfile(options.batchfile, &modifyrepotasks, &err); } else if (!options.batchfile && options.remove && argc == 2) { // two arguments (prog, repodata_dir) repodatadir = argv[1]; ret = cmd_options_to_task(&modifyrepotasks, &options, NULL, &err); } else { // Bad arguments print_usage(); exit(EXIT_FAILURE); } if (!ret) { g_printerr("%s\n", err->message); g_error_free(err); exit(EXIT_FAILURE); } // Process the tasks ret = cr_modifyrepo(modifyrepotasks, repodatadir, &err); cr_slist_free_full(modifyrepotasks, (GDestroyNotify)cr_modifyrepotask_free); if (!ret) { g_printerr("%s\n", err->message); g_error_free(err); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); }
int main(int argc, char **argv) { gboolean ret = TRUE; RawCmdOptions options; GError *err = NULL; // Parse arguments parse_arguments(&argc, &argv, &options, &err); if (err) { g_printerr("%s\n", err->message); print_usage(); g_error_free(err); exit(EXIT_FAILURE); } // Set logging g_log_set_default_handler(cr_log_fn, NULL); if (options.verbose) { // Verbose mode GLogLevelFlags levels = G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_WARNING; g_log_set_handler(NULL, levels, cr_log_fn, NULL); g_log_set_handler("C_CREATEREPOLIB", levels, cr_log_fn, NULL); } else { // Standard mode GLogLevelFlags levels = G_LOG_LEVEL_DEBUG; g_log_set_handler(NULL, levels, cr_null_log_fn, NULL); g_log_set_handler("C_CREATEREPOLIB", levels, cr_null_log_fn, NULL); } // Print version if required if (options.version) { printf("Version: %d.%d.%d\n", CR_VERSION_MAJOR, CR_VERSION_MINOR, CR_VERSION_PATCH); exit(EXIT_SUCCESS); } // Check arguments check_arguments(&options, &err); if (err) { g_printerr("%s\n", err->message); print_usage(); g_error_free(err); exit(EXIT_FAILURE); } g_thread_init(NULL); // Initialize threading // Prepare list of tasks to do gchar *repodatadir = NULL; GSList *modifyrepotasks = NULL; if (!options.batchfile && !options.remove && argc == 3) { // three arguments (prog, metadata, repodata_dir) repodatadir = argv[2]; ret = cmd_options_to_task(&modifyrepotasks, &options, argv[1], &err); } else if (options.batchfile && argc == 2) { // two arguments (prog, repodata_dir) repodatadir = argv[1]; ret = cr_modifyrepo_parse_batchfile(options.batchfile, &modifyrepotasks, &err); } else if (!options.batchfile && options.remove && argc == 2) { // two arguments (prog, repodata_dir) repodatadir = argv[1]; ret = cmd_options_to_task(&modifyrepotasks, &options, NULL, &err); } else { // Bad arguments print_usage(); exit(EXIT_FAILURE); } if (!ret) { g_printerr("%s\n", err->message); g_error_free(err); exit(EXIT_FAILURE); } // Process the tasks ret = cr_modifyrepo(modifyrepotasks, repodatadir, &err); cr_slist_free_full(modifyrepotasks, (GDestroyNotify)cr_modifyrepotask_free); if (!ret) { g_printerr("%s\n", err->message); g_error_free(err); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); }