diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/libmbpk.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/libmbpk.c b/src/libmbpk.c index 477dd97..4045fe2 100644 --- a/src/libmbpk.c +++ b/src/libmbpk.c @@ -5,6 +5,7 @@ #include "ini.h" #include <string.h> #include <sys/stat.h> +#include <curl/curl.h> #define MBPK_DB_DIR "/var/lib/mbpk" #define MBPK_REPO_DIR "/var/lib/mbpk-repo" @@ -73,10 +74,13 @@ static int repo_conf_handler(void* user, const char* section, const char* name, int mbpk_update_repositories(void) { /* Declarations */ - int i; struct stat st; + int i; + mbpk_repository *repo; + CURL* curl; + CURLcode result; + char* repo_ini_url; - /* Parse repo config */ repo_count = 0; if (ini_parse(MBPK_REPO_CONFIG, repo_conf_handler, NULL) < 0) { return MBPK_REPO_FAIL; @@ -89,7 +93,31 @@ int mbpk_update_repositories(void) { } for (i = 0; i < repo_count; i++) { - printf("Debug\n"); + repo = repos[i]; + printf("[libmbpk debug] processing repo %s\n", repo->name); + result = curl_global_init(CURL_GLOBAL_ALL); + if (result != CURLE_OK) { + return MBPK_CURL_INIT_FAIL; + } + + curl = curl_easy_init(); + if (curl) { + curl_easy_setopt(curl, CURLOPT_URL, repo->url); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); /* follow redirects */ + + result = curl_easy_perform(curl); + + if (result != CURLE_OK) { + printf("[libmbpk debug] perform cURL failed\n"); + return MBPK_CURL_PERFORM_FAIL; + } + + curl_easy_cleanup(curl); + } else { + curl_global_cleanup(); + return MBPK_CURL_INIT_FAIL; + } + curl_global_cleanup(); } return MBPK_OK; |
