Skip to content

Instantly share code, notes, and snippets.

@msehnout
Created May 12, 2021 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msehnout/2d660bcffed57406ed4181cea585a34c to your computer and use it in GitHub Desktop.
Save msehnout/2d660bcffed57406ed4181cea585a34c to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <glib.h>
#include <librepo/repoconf.h>
int main() {
printf("Testing librepo\n");
LrYumRepoConfs *confs = lr_yum_repoconfs_init();
GError *error = NULL;
const char *repofile = "/etc/yum.repos.d/redhat.repo";
gboolean success = lr_yum_repoconfs_parse(confs, repofile, &error);
if (!success) {
printf("Failed to load the repo file\n");
}
error = NULL;
GSList *repos = lr_yum_repoconfs_get_list(confs, &error);
if (!success) {
printf("...\n");
}
for (GSList *elem = repos; elem; elem = g_slist_next(elem)) {
error = NULL;
char *name = (char *)calloc('\0', 1000);
success = lr_yum_repoconf_getinfo(elem->data, &error, LR_YRC_NAME, &name);
if (!success) {
printf("Failed to load config options\n");
} else {
printf("Name: %s\n", name);
}
}
lr_yum_repoconfs_free(confs);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment