(task_http.c) Cleanups

This commit is contained in:
twinaphex 2015-08-06 04:08:20 +02:00
parent 2ea5dda564
commit 52c2e76ec8
2 changed files with 11 additions and 25 deletions

View File

@ -71,17 +71,12 @@ int cb_core_content_list(void *data_, size_t len);
static http_handle_t *http_ptr; static http_handle_t *http_ptr;
void *rarch_main_data_http_get_ptr(void)
{
return http_ptr;
}
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
static int zlib_extract_core_callback(const char *name, const char *valid_exts, static int zlib_extract_core_callback(const char *name, const char *valid_exts,
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size, const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
uint32_t crc32, void *userdata) uint32_t crc32, void *userdata)
{ {
char path[PATH_MAX_LENGTH] = {0}; char path[PATH_MAX_LENGTH];
/* Make directory */ /* Make directory */
fill_pathname_join(path, (const char*)userdata, name, sizeof(path)); fill_pathname_join(path, (const char*)userdata, name, sizeof(path));
@ -122,9 +117,9 @@ error:
static int cb_generic_download(void *data, size_t len, static int cb_generic_download(void *data, size_t len,
const char *dir_path) const char *dir_path)
{ {
char msg[PATH_MAX_LENGTH];
char output_path[PATH_MAX_LENGTH];
const char *file_ext = NULL; const char *file_ext = NULL;
char output_path[PATH_MAX_LENGTH] = {0};
char msg[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
if (!data) if (!data)
@ -361,7 +356,7 @@ static int cb_http_conn_default(void *data_, size_t len)
**/ **/
static int rarch_main_data_http_iterate_poll(http_handle_t *http) static int rarch_main_data_http_iterate_poll(http_handle_t *http)
{ {
char elem0[PATH_MAX_LENGTH] = {0}; char elem0[PATH_MAX_LENGTH];
struct string_list *str_list = NULL; struct string_list *str_list = NULL;
const char *url = msg_queue_pull(http->msg_queue); const char *url = msg_queue_pull(http->msg_queue);
@ -374,9 +369,7 @@ static int rarch_main_data_http_iterate_poll(http_handle_t *http)
str_list = string_split(url, "|"); str_list = string_split(url, "|");
if (!str_list) if (!str_list || (str_list->size < 1))
goto error;
if (str_list->size < 1)
goto error; goto error;
strlcpy(elem0, str_list->elems[0].data, sizeof(elem0)); strlcpy(elem0, str_list->elems[0].data, sizeof(elem0));
@ -428,7 +421,7 @@ static int rarch_main_data_http_iterate_transfer(void *data)
if (percent > 0) if (percent > 0)
{ {
char tmp[PATH_MAX_LENGTH] = {0}; char tmp[PATH_MAX_LENGTH];
snprintf(tmp, sizeof(tmp), "%s: %d%%", snprintf(tmp, sizeof(tmp), "%s: %d%%",
msg_hash_to_str(MSG_DOWNLOAD_PROGRESS), msg_hash_to_str(MSG_DOWNLOAD_PROGRESS),
percent); percent);
@ -443,8 +436,7 @@ static int rarch_main_data_http_iterate_transfer(void *data)
void rarch_main_data_http_iterate(bool is_thread) void rarch_main_data_http_iterate(bool is_thread)
{ {
http_handle_t *http = (http_handle_t*) http_handle_t *http = (http_handle_t*)http_ptr;
rarch_main_data_http_get_ptr();
if (!http) if (!http)
return; return;
@ -477,8 +469,7 @@ void rarch_main_data_http_iterate(bool is_thread)
void rarch_main_data_http_init_msg_queue(void) void rarch_main_data_http_init_msg_queue(void)
{ {
http_handle_t *http = (http_handle_t*) http_handle_t *http = (http_handle_t*)http_ptr;
rarch_main_data_http_get_ptr();
if (!http) if (!http)
return; return;
@ -489,8 +480,7 @@ void rarch_main_data_http_init_msg_queue(void)
msg_queue_t *rarch_main_data_http_get_msg_queue_ptr(void) msg_queue_t *rarch_main_data_http_get_msg_queue_ptr(void)
{ {
http_handle_t *http = (http_handle_t*) http_handle_t *http = (http_handle_t*)http_ptr;
rarch_main_data_http_get_ptr();
if (!http) if (!http)
return NULL; return NULL;
return http->msg_queue; return http->msg_queue;
@ -498,8 +488,7 @@ msg_queue_t *rarch_main_data_http_get_msg_queue_ptr(void)
void *rarch_main_data_http_get_handle(void) void *rarch_main_data_http_get_handle(void)
{ {
http_handle_t *http = (http_handle_t*) http_handle_t *http = (http_handle_t*)http_ptr;
rarch_main_data_http_get_ptr();
if (!http) if (!http)
return NULL; return NULL;
if (http->handle == NULL) if (http->handle == NULL)
@ -509,8 +498,7 @@ void *rarch_main_data_http_get_handle(void)
void *rarch_main_data_http_conn_get_handle(void) void *rarch_main_data_http_conn_get_handle(void)
{ {
http_handle_t *http = (http_handle_t*) http_handle_t *http = (http_handle_t*)http_ptr;
rarch_main_data_http_get_ptr();
if (!http) if (!http)
return NULL; return NULL;
if (http->connection.handle == NULL) if (http->connection.handle == NULL)

View File

@ -63,8 +63,6 @@ void *rarch_main_data_http_conn_get_handle(void);
void rarch_main_data_http_uninit(void); void rarch_main_data_http_uninit(void);
void rarch_main_data_http_init(void); void rarch_main_data_http_init(void);
void *rarch_main_data_http_get_ptr(void);
#endif #endif
#ifdef HAVE_RPNG #ifdef HAVE_RPNG