From 8d6e5811f2850540628f2023b394372fb33caa11 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 21 Jan 2015 01:56:59 +0100 Subject: [PATCH] Refactors --- http_intf.c | 28 ++++++++++++++++++++++++---- http_intf.h | 22 ++++++++++++++++++++++ menu/menu_entries_cbs.c | 4 ++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/http_intf.c b/http_intf.c index 62a8a8df27..35c2b526ae 100644 --- a/http_intf.c +++ b/http_intf.c @@ -23,6 +23,28 @@ #include +/** + * http_get_file: + * @url : URL to file. + * @buf : Buffer. + * @len : Size of @buf. + * + * Loads the contents of a file at specified URL into + * buffer @buf. Sets length of data buffer as well. + * + * Returns: HTTP return code on success, otherwise + * negative on failure. + **/ +http_retcode http_get_file(char *url, char **buf, int *len) +{ + char *urlfilename = NULL; + + if (!http_parse_url(url, &urlfilename)) + return ERRRDDT; + + return http_get(urlfilename, buf, len, NULL); +} + /** * http_download_file: * @url : URL to file. @@ -40,11 +62,9 @@ bool http_download_file(char *url, const char *output_dir, int len; FILE *f; char output_path[PATH_MAX_LENGTH]; - char *buf, *urlfilename = NULL; + char *buf; - http_parse_url(url, &urlfilename); - - status = http_get(urlfilename, &buf, &len, NULL); + status = http_get_file(url, &buf, &len); if (status < 0) { diff --git a/http_intf.h b/http_intf.h index cd35735b21..2bcaaca50b 100644 --- a/http_intf.h +++ b/http_intf.h @@ -21,6 +21,10 @@ #include "netplay_compat.h" #include "http_lib.h" +#ifdef __cplusplus +extern "C" { +#endif + enum { HTTP_INTF_ERROR = 0, @@ -30,6 +34,20 @@ enum HTTP_INTF_HEAD }; +/** + * http_get_file: + * @url : URL to file. + * @buf : Buffer. + * @len : Size of @buf. + * + * Loads the contents of a file at specified URL into + * buffer @buf. Sets length of data buffer as well. + * + * Returns: HTTP return code on success, otherwise + * negative on failure. + **/ +http_retcode http_get_file(char *url, char **buf, int *len); + /** * http_download_file: * @url : URL to file. @@ -45,4 +63,8 @@ bool http_download_file(char *url, const char *output_dir, int http_intf_command(unsigned mode, char *url); +#ifdef __cplusplus +} +#endif + #endif diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 317149335a..a173f97535 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -28,7 +28,9 @@ #include "../retroarch.h" #include "../performance.h" +#ifdef HAVE_NETPLAY #include "../http_intf.h" +#endif #include "../input/input_remapping.h" #ifdef GEKKO @@ -803,10 +805,12 @@ static int generic_action_ok_command(unsigned cmd) static int action_ok_core_manager_list(const char *path, const char *label, unsigned type, size_t idx) { +#ifdef HAVE_NETPLAY char url[] = "http://buildbot.libretro.com/nightly/android/latest/armeabi-v7a/2048_libretro.so.zip"; if (!http_download_file(url, g_settings.libretro_info_path, "2048_libretro.so.zip")) return -1; +#endif return 0; }