diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index bd6b7e3744..7620758046 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -1640,7 +1640,7 @@ static bool zlib_extract_core_callback(const char *name, const char *valid_exts, return true; } -static int cb_core_updater_download(void *data_, size_t len) +int cb_core_updater_download(void *data_, size_t len) { FILE *f; const char* file_ext = NULL; @@ -1700,10 +1700,10 @@ static int action_ok_core_updater_list(const char *path, msg_queue_clear(g_extern.msg_queue); msg_queue_push(g_extern.msg_queue, msg, 1, 90); + strlcat(core_path, "|cb_core_updater_download", sizeof(core_path)); + msg_queue_clear(g_extern.http_msg_queue); msg_queue_push(g_extern.http_msg_queue, core_path, 0, 1); - - net_http_set_pending_cb(cb_core_updater_download); #endif return 0; } @@ -3610,7 +3610,7 @@ static char core_updater_list_path[PATH_MAX_LENGTH]; static char core_updater_list_label[PATH_MAX_LENGTH]; static unsigned core_updater_list_type; -static int cb_core_updater_list(void *data_, size_t len) +int cb_core_updater_list(void *data_, size_t len) { char *data = (char*)data_; file_list_t *list = NULL; @@ -3676,10 +3676,10 @@ static int deferred_push_core_updater_list(void *data, void *userdata, fill_pathname_join(url_path, g_settings.network.buildbot_url, ".index", sizeof(url_path)); + strlcat(url_path, "|cb_core_updater_list", sizeof(url_path)); + msg_queue_clear(g_extern.http_msg_queue); msg_queue_push(g_extern.http_msg_queue, url_path, 0, 1); - - net_http_set_pending_cb(cb_core_updater_list); #endif return 0; diff --git a/runloop.c b/runloop.c index fcb73d1dcf..74c3983343 100644 --- a/runloop.c +++ b/runloop.c @@ -879,23 +879,8 @@ static int rarch_main_iterate_quit(void) } #ifdef HAVE_NETWORKING - -static http_cb_t pending_cb; - -void net_http_set_pending_cb(http_cb_t cb) -{ - pending_cb = cb; -} - -static http_cb_t net_http_get_pending_cb(void) -{ - return pending_cb; -} - -static void net_http_clear_pending_cb(void) -{ - pending_cb = NULL; -} +int cb_core_updater_download(void *data_, size_t len); +int cb_core_updater_list(void *data_, size_t len); /** * rarch_main_iterate_http_transfer: @@ -953,26 +938,48 @@ static int rarch_main_iterate_http_parse(void) **/ static int rarch_main_iterate_http_poll(void) { + char elem0[PATH_MAX_LENGTH], elem1[PATH_MAX_LENGTH]; + struct string_list *str_list = NULL; const char *url = msg_queue_pull(g_extern.http_msg_queue); if (!url) return -1; + /* Can only deal with one HTTP transfer at a time for now */ if (g_extern.http_handle) return -1; - g_extern.http_handle = net_http_new(url); + str_list = string_split(url, "|"); + + if (!str_list) + return -1; + + if (str_list->size > 0) + strlcpy(elem0, str_list->elems[0].data, sizeof(elem0)); + if (str_list->size > 1) + strlcpy(elem1, str_list->elems[1].data, sizeof(elem1)); + + g_extern.http_handle = net_http_new(elem0); if (!g_extern.http_handle) { RARCH_ERR("Could not create new HTTP session handle.\n"); + string_list_free(str_list); return -1; } - g_extern.http_cb = net_http_get_pending_cb(); - - net_http_clear_pending_cb(); + g_extern.http_cb = NULL; + if (elem1[0] != '\0') + { + if (!strcmp(elem1, "cb_core_updater_download")) + g_extern.http_cb = &cb_core_updater_download; + if (!strcmp(elem1, "cb_core_updater_list")) + g_extern.http_cb = &cb_core_updater_list; + } + + string_list_free(str_list); + return 0; } #endif