Get rid of messy 'pending cb' code - instead use
string lists
This commit is contained in:
parent
028b0592f5
commit
939b78753a
|
@ -1640,7 +1640,7 @@ static bool zlib_extract_core_callback(const char *name, const char *valid_exts,
|
||||||
return true;
|
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;
|
FILE *f;
|
||||||
const char* file_ext = NULL;
|
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_clear(g_extern.msg_queue);
|
||||||
msg_queue_push(g_extern.msg_queue, msg, 1, 90);
|
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_clear(g_extern.http_msg_queue);
|
||||||
msg_queue_push(g_extern.http_msg_queue, core_path, 0, 1);
|
msg_queue_push(g_extern.http_msg_queue, core_path, 0, 1);
|
||||||
|
|
||||||
net_http_set_pending_cb(cb_core_updater_download);
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
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 char core_updater_list_label[PATH_MAX_LENGTH];
|
||||||
static unsigned core_updater_list_type;
|
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_;
|
char *data = (char*)data_;
|
||||||
file_list_t *list = NULL;
|
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,
|
fill_pathname_join(url_path, g_settings.network.buildbot_url,
|
||||||
".index", sizeof(url_path));
|
".index", sizeof(url_path));
|
||||||
|
|
||||||
|
strlcat(url_path, "|cb_core_updater_list", sizeof(url_path));
|
||||||
|
|
||||||
msg_queue_clear(g_extern.http_msg_queue);
|
msg_queue_clear(g_extern.http_msg_queue);
|
||||||
msg_queue_push(g_extern.http_msg_queue, url_path, 0, 1);
|
msg_queue_push(g_extern.http_msg_queue, url_path, 0, 1);
|
||||||
|
|
||||||
net_http_set_pending_cb(cb_core_updater_list);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
49
runloop.c
49
runloop.c
|
@ -879,23 +879,8 @@ static int rarch_main_iterate_quit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
|
int cb_core_updater_download(void *data_, size_t len);
|
||||||
static http_cb_t pending_cb;
|
int cb_core_updater_list(void *data_, size_t len);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rarch_main_iterate_http_transfer:
|
* 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)
|
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);
|
const char *url = msg_queue_pull(g_extern.http_msg_queue);
|
||||||
|
|
||||||
if (!url)
|
if (!url)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Can only deal with one HTTP transfer at a time for now */
|
/* Can only deal with one HTTP transfer at a time for now */
|
||||||
if (g_extern.http_handle)
|
if (g_extern.http_handle)
|
||||||
return -1;
|
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)
|
if (!g_extern.http_handle)
|
||||||
{
|
{
|
||||||
RARCH_ERR("Could not create new HTTP session handle.\n");
|
RARCH_ERR("Could not create new HTTP session handle.\n");
|
||||||
|
string_list_free(str_list);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_extern.http_cb = net_http_get_pending_cb();
|
g_extern.http_cb = NULL;
|
||||||
|
|
||||||
net_http_clear_pending_cb();
|
|
||||||
|
|
||||||
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue