diff --git a/Makefile.common b/Makefile.common index 38228a7521..18a90a43db 100644 --- a/Makefile.common +++ b/Makefile.common @@ -622,7 +622,8 @@ endif ifeq ($(HAVE_NETWORKING), 1) DEFINES += -DHAVE_NETWORKING - OBJ += net_compat.o + OBJ += net_compat.o \ + net_http.o ifneq ($(findstring Win32,$(OS)),) LIBS += -lws2_32 @@ -630,8 +631,7 @@ ifeq ($(HAVE_NETWORKING), 1) ifeq ($(HAVE_NETPLAY), 1) DEFINES += -DHAVE_NETPLAY -DHAVE_NETWORK_CMD - OBJ += netplay.o \ - net_http.o + OBJ += netplay.o endif endif diff --git a/general.h b/general.h index 7795ab6848..a1973fa9f3 100644 --- a/general.h +++ b/general.h @@ -59,7 +59,7 @@ #include "command.h" #endif -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING #include "net_http.h" #endif @@ -391,7 +391,7 @@ typedef struct rarch_resolution #define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024) #define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024) -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING typedef int (*http_cb_t )(void *data, size_t len); #endif @@ -579,7 +579,7 @@ struct global #endif msg_queue_t *msg_queue; -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING msg_queue_t *http_msg_queue; http_t *http_handle; http_cb_t http_cb; @@ -784,7 +784,7 @@ static inline void rarch_fail(int error_code, const char *error) longjmp(g_extern.error_sjlj_context, error_code); } -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING void net_http_set_pending_cb(http_cb_t cb); #endif diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 5e986a2fb3..8d55dc78a9 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -28,7 +28,7 @@ #include "../retroarch.h" #include "../performance.h" -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING #include "../net_http.h" #endif @@ -1325,7 +1325,7 @@ static int action_ok_save_state(const char *path, return generic_action_ok_command(RARCH_CMD_RESUME); } -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING /* HACK - we have to find some way to pass state inbetween * function pointer callback functions that don't necessarily * call each other. */ @@ -1364,7 +1364,7 @@ static int cb_core_manager_download(void *data_, size_t len) static int action_ok_core_manager_list(const char *path, const char *label, unsigned type, size_t idx) { -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING char core_path[PATH_MAX_LENGTH], msg[PATH_MAX_LENGTH]; fill_pathname_join(core_path, g_settings.network.buildbot_url, path, sizeof(core_path)); @@ -2876,7 +2876,7 @@ static int deferred_push_disk_options(void *data, void *userdata, return 0; } -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING static void print_buf_lines(file_list_t *list, char *buf, int buf_size, unsigned type) { @@ -2955,7 +2955,7 @@ static int cb_core_manager_list(void *data_, size_t len) static int deferred_push_core_manager_list(void *data, void *userdata, const char *path, const char *label, unsigned type) { -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING char url_path[PATH_MAX_LENGTH]; strlcpy(core_manager_list_path, path, @@ -2970,7 +2970,7 @@ static int deferred_push_core_manager_list(void *data, void *userdata, file_list_t *list = (file_list_t*)data; menu_list_clear(list); -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING menu_list_push(list, "Buildbot URL not configured.", "", 0, 0); @@ -2985,7 +2985,7 @@ static int deferred_push_core_manager_list(void *data, void *userdata, return 0; } -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING rarch_main_command(RARCH_CMD_NETWORK_INIT); fill_pathname_join(url_path, g_settings.network.buildbot_url, diff --git a/net_compat.c b/net_compat.c index e2cb0d40be..5b5296ce58 100644 --- a/net_compat.c +++ b/net_compat.c @@ -153,3 +153,52 @@ int socket_receive_all_blocking(int fd, void *data_, size_t size) return true; } + +/** + * network_init: + * + * Platform specific socket library initialization. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool network_init(void) +{ +#ifdef _WIN32 + WSADATA wsaData; +#endif + static bool inited = false; + if (inited) + return true; + +#if defined(_WIN32) + if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) + { + network_deinit(); + return false; + } + RARCH_LOG("WSA Initialized.\n"); +#elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) + cellSysmoduleLoadModule(CELL_SYSMODULE_NET); + sys_net_initialize_network(); +#else + signal(SIGPIPE, SIG_IGN); /* Do not like SIGPIPE killing our app. */ +#endif + + inited = true; + return true; +} + +/** + * network_deinit: + * + * Deinitialize platform specific socket libraries. + **/ +void network_deinit(void) +{ +#if defined(_WIN32) + WSACleanup(); +#elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) + sys_net_finalize_network(); + cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); +#endif +} diff --git a/net_compat.h b/net_compat.h index 8e5ca89814..83af97bbc2 100644 --- a/net_compat.h +++ b/net_compat.h @@ -155,5 +155,21 @@ int socket_send_all_blocking(int fd, const void *data_, size_t size); int socket_receive_all_blocking(int fd, void *data_, size_t size); +/** + * network_init: + * + * Platform specific socket library initialization. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool network_init(void); + +/** + * network_deinit: + * + * Deinitialize platform specific socket libraries. + **/ +void network_deinit(void); + #endif diff --git a/netplay.c b/netplay.c index 16db644802..9c99ba6432 100644 --- a/netplay.c +++ b/netplay.c @@ -780,55 +780,6 @@ static bool init_udp_socket(netplay_t *netplay, const char *server, return true; } -/** - * network_init: - * - * Platform specific socket library initialization. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool network_init(void) -{ -#ifdef _WIN32 - WSADATA wsaData; -#endif - static bool inited = false; - if (inited) - return true; - -#if defined(_WIN32) - if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) - { - network_deinit(); - return false; - } - RARCH_LOG("WSA Initialized.\n"); -#elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) - cellSysmoduleLoadModule(CELL_SYSMODULE_NET); - sys_net_initialize_network(); -#else - signal(SIGPIPE, SIG_IGN); /* Do not like SIGPIPE killing our app. */ -#endif - - inited = true; - return true; -} - -/** - * network_deinit: - * - * Deinitialize platform specific socket libraries. - **/ -void network_deinit(void) -{ -#if defined(_WIN32) - WSACleanup(); -#elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) - sys_net_finalize_network(); - cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); -#endif -} - static bool init_socket(netplay_t *netplay, const char *server, uint16_t port) { if (!network_init()) diff --git a/netplay.h b/netplay.h index 8f3a142c5f..38df9f5f45 100644 --- a/netplay.h +++ b/netplay.h @@ -44,22 +44,6 @@ int16_t input_state_spectate(unsigned port, unsigned device, int16_t input_state_spectate_client(unsigned port, unsigned device, unsigned idx, unsigned id); -/** - * network_init: - * - * Platform specific socket library initialization. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool network_init(void); - -/** - * network_deinit: - * - * Deinitialize platform specific socket libraries. - **/ -void network_deinit(void); - /** * netplay_new: * @server : IP address of server. diff --git a/retroarch.c b/retroarch.c index 6625de8fc0..40143e1df8 100644 --- a/retroarch.c +++ b/retroarch.c @@ -49,6 +49,11 @@ #include "menu/menu_input.h" #endif +#ifdef HAVE_NETWORKING +#include "net_compat.h" +#include "net_http.h" +#endif + #ifdef HAVE_NETPLAY #include "netplay.h" #endif @@ -2934,7 +2939,7 @@ bool rarch_main_command(unsigned cmd) rarch_main_command(RARCH_CMD_MSG_QUEUE_DEINIT); if (!g_extern.msg_queue) rarch_assert(g_extern.msg_queue = msg_queue_new(8)); -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING if (!g_extern.http_msg_queue) rarch_assert(g_extern.http_msg_queue = msg_queue_new(8)); #endif @@ -2959,12 +2964,12 @@ bool rarch_main_command(unsigned cmd) #endif break; case RARCH_CMD_NETWORK_DEINIT: -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING network_deinit(); #endif break; case RARCH_CMD_NETWORK_INIT: -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING network_init(); #endif break; diff --git a/runloop.c b/runloop.c index e876cb4ff3..370b8526b7 100644 --- a/runloop.c +++ b/runloop.c @@ -32,6 +32,10 @@ #include "netplay.h" #endif +#ifdef HAVE_NETWORKING +#include "net_http.h" +#endif + /* Convenience macros. */ #define check_oneshot_func(trigger_input) (check_is_oneshot(BIT64_GET(trigger_input, RARCH_FRAMEADVANCE), BIT64_GET(trigger_input, RARCH_REWIND))) #define check_slowmotion_func(input) (check_slowmotion(BIT64_GET(input, RARCH_SLOWMOTION))) @@ -866,7 +870,7 @@ static int rarch_main_iterate_quit(void) return -1; } -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING static http_cb_t pending_cb; @@ -996,7 +1000,7 @@ int rarch_main_iterate(void) do_pre_state_checks(input, old_input, trigger_input); -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING if (g_extern.http_handle) { if (!rarch_main_iterate_http_transfer()) diff --git a/settings_data.c b/settings_data.c index 02e6614308..0583cd373e 100644 --- a/settings_data.c +++ b/settings_data.c @@ -3351,7 +3351,7 @@ static bool setting_data_append_list_main_menu_options( settings_data_list_current_add_flags(list, list_info, SD_FLAG_BROWSER_ACTION); #endif -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING CONFIG_ACTION( "core_manager_list", "Core Update Manager", @@ -5457,7 +5457,7 @@ static bool setting_data_append_list_core_manager_options( rarch_setting_t **list, rarch_setting_info_t *list_info) { -#ifdef HAVE_NETPLAY +#ifdef HAVE_NETWORKING rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info;