diff --git a/Makefile b/Makefile index 94cc07d7..91cc2cae 100644 --- a/Makefile +++ b/Makefile @@ -179,16 +179,8 @@ ifndef USE_OPENAL_DLOPEN USE_OPENAL_DLOPEN=1 endif -ifndef USE_CURL -USE_CURL=1 -endif - -ifndef USE_CURL_DLOPEN - ifdef MINGW - USE_CURL_DLOPEN=0 - else - USE_CURL_DLOPEN=1 - endif +ifndef USE_HTTP +USE_HTTP=1 endif ifndef USE_CODEC_VORBIS @@ -424,11 +416,9 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu") endif endif - ifeq ($(USE_CURL),1) + ifeq ($(USE_HTTP),1) CLIENT_CFLAGS += $(CURL_CFLAGS) - ifneq ($(USE_CURL_DLOPEN),1) - CLIENT_LIBS += $(CURL_LIBS) - endif + CLIENT_LIBS += $(CURL_LIBS) endif ifeq ($(USE_MUMBLE),1) @@ -583,11 +573,9 @@ ifeq ($(PLATFORM),darwin) endif endif - ifeq ($(USE_CURL),1) + ifeq ($(USE_HTTP),1) CLIENT_CFLAGS += $(CURL_CFLAGS) - ifneq ($(USE_CURL_DLOPEN),1) - CLIENT_LIBS += $(CURL_LIBS) - endif + CLIENT_LIBS += $(CURL_LIBS) endif BASE_CFLAGS += -D_THREAD_SAFE=1 @@ -761,21 +749,7 @@ ifdef MINGW FREETYPE_CFLAGS = -Ifreetype2 endif - ifeq ($(USE_CURL),1) - CLIENT_CFLAGS += $(CURL_CFLAGS) - ifneq ($(USE_CURL_DLOPEN),1) - ifeq ($(USE_LOCAL_HEADERS),1) - CLIENT_CFLAGS += -DCURL_STATICLIB - ifeq ($(ARCH),x86_64) - CLIENT_LIBS += $(LIBSDIR)/win64/libcurl.a -lcrypt32 - else - CLIENT_LIBS += $(LIBSDIR)/win32/libcurl.a -lcrypt32 - endif - else - CLIENT_LIBS += $(CURL_LIBS) - endif - endif - endif + USE_HTTP=0 ifeq ($(ARCH),x86) # build 32bit @@ -851,11 +825,9 @@ ifeq ($(PLATFORM),freebsd) endif endif - ifeq ($(USE_CURL),1) + ifeq ($(USE_HTTP),1) CLIENT_CFLAGS += $(CURL_CFLAGS) - ifeq ($(USE_CURL_DLOPEN),1) - CLIENT_LIBS += $(CURL_LIBS) - endif + CLIENT_LIBS += $(CURL_LIBS) endif # cross-compiling tweaks @@ -915,9 +887,9 @@ ifeq ($(PLATFORM),openbsd) endif endif - ifeq ($(USE_CURL),1) + ifeq ($(USE_HTTP),1) CLIENT_CFLAGS += $(CURL_CFLAGS) - USE_CURL_DLOPEN=0 + CLIENT_LIBS += $(CURL_LIBS) endif # no shm_open on OpenBSD @@ -940,12 +912,6 @@ ifeq ($(PLATFORM),openbsd) CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS) endif endif - - ifeq ($(USE_CURL),1) - ifneq ($(USE_CURL_DLOPEN),1) - CLIENT_LIBS += $(CURL_LIBS) - endif - endif else # ifeq openbsd ############################################################################# @@ -1268,11 +1234,8 @@ ifeq ($(USE_OPENAL),1) endif endif -ifeq ($(USE_CURL),1) - CLIENT_CFLAGS += -DUSE_CURL - ifeq ($(USE_CURL_DLOPEN),1) - CLIENT_CFLAGS += -DUSE_CURL_DLOPEN - endif +ifeq ($(USE_HTTP),1) + CLIENT_CFLAGS += -DUSE_HTTP endif ifeq ($(USE_VOIP),1) @@ -1950,7 +1913,7 @@ Q3OBJ = \ $(B)/client/qal.o \ $(B)/client/snd_openal.o \ \ - $(B)/client/cl_curl.o \ + $(B)/client/cl_http_curl.o \ \ $(B)/client/sv_bot.o \ $(B)/client/sv_ccmds.o \ @@ -3246,7 +3209,6 @@ ifdef MINGW SDLDLL=$(SDLDLL) \ USE_RENDERER_DLOPEN=$(USE_RENDERER_DLOPEN) \ USE_OPENAL_DLOPEN=$(USE_OPENAL_DLOPEN) \ - USE_CURL_DLOPEN=$(USE_CURL_DLOPEN) \ USE_INTERNAL_OPUS=$(USE_INTERNAL_OPUS) \ USE_INTERNAL_ZLIB=$(USE_INTERNAL_ZLIB) \ USE_INTERNAL_JPEG=$(USE_INTERNAL_JPEG) diff --git a/README.md b/README.md index 8ba398ff..ab64a631 100644 --- a/README.md +++ b/README.md @@ -154,8 +154,7 @@ Makefile.local: MISSIONPACK_CFLAGS - custom CFLAGS for missionpack (default '-DMISSIONPACK') USE_OPENAL - use OpenAL where available USE_OPENAL_DLOPEN - link with OpenAL at runtime - USE_CURL - use libcurl for http/ftp download support - USE_CURL_DLOPEN - link with libcurl at runtime + USE_HTTP - enable http download support USE_CODEC_VORBIS - enable Ogg Vorbis support USE_CODEC_OPUS - enable Ogg Opus support USE_MUMBLE - enable Mumble support @@ -208,7 +207,7 @@ set using command line arguments: cl_aviFrameRate - the framerate to use when capturing video cl_aviMotionJpeg - use the mjpeg codec when capturing video cl_guidServerUniq - makes cl_guid unique for each server - cl_cURLLib - filename of cURL library to load + cl_cURLLib - filename of cURL library to load (non-Windows) cl_consoleKeys - space delimited list of key names or characters that toggle the console cl_mouseAccelStyle - Set to 1 for QuakeLive mouse acceleration diff --git a/code/client/cl_curl.h b/code/client/cl_curl.h deleted file mode 100644 index f0a7bf6d..00000000 --- a/code/client/cl_curl.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2006 Tony J. White (tjw@tjw.org) - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - - -#ifndef __QCURL_H__ -#define __QCURL_H__ - -#include "../qcommon/q_shared.h" -#include "../qcommon/qcommon.h" - -#ifdef USE_LOCAL_HEADERS - #include "../curl-8.15.0/include/curl/curl.h" -#else - #include -#endif - -#ifdef USE_CURL_DLOPEN -#ifdef WIN32 - #define DEFAULT_CURL_LIB "libcurl-4.dll" - #define ALTERNATE_CURL_LIB "libcurl-3.dll" -#elif defined(__APPLE__) - #define DEFAULT_CURL_LIB "libcurl.dylib" -#else - #define DEFAULT_CURL_LIB "libcurl.so.4" - #define ALTERNATE_CURL_LIB "libcurl.so.3" -#endif - -extern cvar_t *cl_cURLLib; - -extern char* (*qcurl_version)(void); - -extern CURL* (*qcurl_easy_init)(void); -extern CURLcode (*qcurl_easy_setopt)(CURL *curl, CURLoption option, ...); -extern CURLcode (*qcurl_easy_perform)(CURL *curl); -extern void (*qcurl_easy_cleanup)(CURL *curl); -extern CURLcode (*qcurl_easy_getinfo)(CURL *curl, CURLINFO info, ...); -extern void (*qcurl_easy_reset)(CURL *curl); -extern const char *(*qcurl_easy_strerror)(CURLcode); - -extern CURLM* (*qcurl_multi_init)(void); -extern CURLMcode (*qcurl_multi_add_handle)(CURLM *multi_handle, - CURL *curl_handle); -extern CURLMcode (*qcurl_multi_remove_handle)(CURLM *multi_handle, - CURL *curl_handle); -extern CURLMcode (*qcurl_multi_fdset)(CURLM *multi_handle, - fd_set *read_fd_set, - fd_set *write_fd_set, - fd_set *exc_fd_set, - int *max_fd); -extern CURLMcode (*qcurl_multi_perform)(CURLM *multi_handle, - int *running_handles); -extern CURLMcode (*qcurl_multi_cleanup)(CURLM *multi_handle); -extern CURLMsg *(*qcurl_multi_info_read)(CURLM *multi_handle, - int *msgs_in_queue); -extern const char *(*qcurl_multi_strerror)(CURLMcode); -#else -#define qcurl_version curl_version - -#define qcurl_easy_init curl_easy_init -#define qcurl_easy_setopt curl_easy_setopt -#define qcurl_easy_perform curl_easy_perform -#define qcurl_easy_cleanup curl_easy_cleanup -#define qcurl_easy_getinfo curl_easy_getinfo -#define qcurl_easy_duphandle curl_easy_duphandle -#define qcurl_easy_reset curl_easy_reset -#define qcurl_easy_strerror curl_easy_strerror - -#define qcurl_multi_init curl_multi_init -#define qcurl_multi_add_handle curl_multi_add_handle -#define qcurl_multi_remove_handle curl_multi_remove_handle -#define qcurl_multi_fdset curl_multi_fdset -#define qcurl_multi_perform curl_multi_perform -#define qcurl_multi_cleanup curl_multi_cleanup -#define qcurl_multi_info_read curl_multi_info_read -#define qcurl_multi_strerror curl_multi_strerror -#endif - -qboolean CL_cURL_Init( void ); -void CL_cURL_Shutdown( void ); -void CL_cURL_BeginDownload( const char *localName, const char *remoteURL ); -void CL_cURL_PerformDownload( void ); -void CL_cURL_Cleanup( void ); -#endif // __QCURL_H__ diff --git a/code/client/cl_http.h b/code/client/cl_http.h new file mode 100644 index 00000000..a8005784 --- /dev/null +++ b/code/client/cl_http.h @@ -0,0 +1,34 @@ +/* +=========================================================================== +Copyright (C) 2006 Tony J. White (tjw@tjw.org) + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_HTTP_H__ +#define __CL_HTTP_H__ + +#include "../qcommon/q_shared.h" + +qboolean CL_HTTP_Init( void ); +qboolean CL_HTTP_Available( void ); +void CL_HTTP_Shutdown( void ); +void CL_HTTP_BeginDownload( const char *localName, const char *remoteURL ); +void CL_HTTP_PerformDownload( void ); + +#endif // __CL_HTTP_H__ diff --git a/code/client/cl_curl.c b/code/client/cl_http_curl.c similarity index 72% rename from code/client/cl_curl.c rename to code/client/cl_http_curl.c index bec34632..3e513eea 100644 --- a/code/client/cl_curl.c +++ b/code/client/cl_http_curl.c @@ -20,10 +20,23 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#ifdef USE_CURL +#ifdef USE_HTTP + #include "client.h" -#ifdef USE_CURL_DLOPEN +#ifdef USE_LOCAL_HEADERS + #include "curl/curl.h" +#else + #include +#endif + +#ifdef __APPLE__ + #define DEFAULT_CURL_LIB "libcurl.dylib" +#else + #define DEFAULT_CURL_LIB "libcurl.so.4" + #define ALTERNATE_CURL_LIB "libcurl.so.3" +#endif + #include "../sys/sys_loadlib.h" cvar_t *cl_cURLLib; @@ -57,6 +70,10 @@ CURLMsg *(*qcurl_multi_info_read)(CURLM *multi_handle, const char *(*qcurl_multi_strerror)(CURLMcode); static void *cURLLib = NULL; +static qboolean cURLSymbolLoadFailed = qfalse; + +static CURL *downloadCURL = NULL; +static CURLM *downloadCURLM = NULL; /* ================= @@ -71,7 +88,7 @@ static void *GPA(char *str) if(!rv) { Com_Printf("Can't load symbol %s\n", str); - clc.cURLEnabled = qfalse; + cURLSymbolLoadFailed = qtrue; return NULL; } else @@ -80,19 +97,18 @@ static void *GPA(char *str) return rv; } } -#endif /* USE_CURL_DLOPEN */ /* ================= -CL_cURL_Init +CL_HTTP_Init ================= */ -qboolean CL_cURL_Init() +qboolean CL_HTTP_Init() { -#ifdef USE_CURL_DLOPEN if(cURLLib) return qtrue; + cl_cURLLib = Cvar_Get("cl_cURLLib", DEFAULT_CURL_LIB, CVAR_ARCHIVE | CVAR_PROTECTED); Com_Printf("Loading \"%s\"...", cl_cURLLib->string); if(!(cURLLib = Sys_LoadDll(cl_cURLLib->string, qtrue))) @@ -104,7 +120,7 @@ qboolean CL_cURL_Init() return qfalse; } - clc.cURLEnabled = qtrue; + cURLSymbolLoadFailed = qfalse; qcurl_version = GPA("curl_version"); @@ -126,30 +142,62 @@ qboolean CL_cURL_Init() qcurl_multi_info_read = GPA("curl_multi_info_read"); qcurl_multi_strerror = GPA("curl_multi_strerror"); - if(!clc.cURLEnabled) + if(cURLSymbolLoadFailed) { - CL_cURL_Shutdown(); + CL_HTTP_Shutdown(); Com_Printf("FAIL One or more symbols not found\n"); return qfalse; } Com_Printf("OK\n"); return qtrue; -#else - clc.cURLEnabled = qtrue; - return qtrue; -#endif /* USE_CURL_DLOPEN */ } /* ================= -CL_cURL_Shutdown +CL_HTTP_Available ================= */ -void CL_cURL_Shutdown( void ) +qboolean CL_HTTP_Available() +{ + return cURLLib != NULL; +} + +static void CL_cURL_Cleanup(void) +{ + if(downloadCURLM) { + CURLMcode result; + + if(downloadCURL) { + result = qcurl_multi_remove_handle(downloadCURLM, + downloadCURL); + if(result != CURLM_OK) { + Com_DPrintf("qcurl_multi_remove_handle failed: %s\n", qcurl_multi_strerror(result)); + } + qcurl_easy_cleanup(downloadCURL); + } + result = qcurl_multi_cleanup(downloadCURLM); + if(result != CURLM_OK) { + Com_DPrintf("CL_cURL_Cleanup: qcurl_multi_cleanup failed: %s\n", qcurl_multi_strerror(result)); + } + downloadCURLM = NULL; + downloadCURL = NULL; + } + else if(downloadCURL) { + qcurl_easy_cleanup(downloadCURL); + downloadCURL = NULL; + } +} + +/* +================= +CL_HTTP_Shutdown +================= +*/ +void CL_HTTP_Shutdown( void ) { CL_cURL_Cleanup(); -#ifdef USE_CURL_DLOPEN + if(cURLLib) { Sys_UnloadLibrary(cURLLib); @@ -171,33 +219,6 @@ void CL_cURL_Shutdown( void ) qcurl_multi_cleanup = NULL; qcurl_multi_info_read = NULL; qcurl_multi_strerror = NULL; -#endif /* USE_CURL_DLOPEN */ -} - -void CL_cURL_Cleanup(void) -{ - if(clc.downloadCURLM) { - CURLMcode result; - - if(clc.downloadCURL) { - result = qcurl_multi_remove_handle(clc.downloadCURLM, - clc.downloadCURL); - if(result != CURLM_OK) { - Com_DPrintf("qcurl_multi_remove_handle failed: %s\n", qcurl_multi_strerror(result)); - } - qcurl_easy_cleanup(clc.downloadCURL); - } - result = qcurl_multi_cleanup(clc.downloadCURLM); - if(result != CURLM_OK) { - Com_DPrintf("CL_cURL_Cleanup: qcurl_multi_cleanup failed: %s\n", qcurl_multi_strerror(result)); - } - clc.downloadCURLM = NULL; - clc.downloadCURL = NULL; - } - else if(clc.downloadCURL) { - qcurl_easy_cleanup(clc.downloadCURL); - clc.downloadCURL = NULL; - } } static int CL_cURL_CallbackProgress(void *clientp, curl_off_t dltotal, curl_off_t dlnow, @@ -243,13 +264,13 @@ CURLcode qcurl_easy_setopt_warn(CURL *curl, CURLoption option, ...) return result; } -void CL_cURL_BeginDownload( const char *localName, const char *remoteURL ) +void CL_HTTP_BeginDownload( const char *localName, const char *remoteURL ) { CURLMcode result; - clc.cURLUsed = qtrue; + clc.httpUsed = qtrue; Com_Printf("URL: %s\n", remoteURL); - Com_DPrintf("***** CL_cURL_BeginDownload *****\n" + Com_DPrintf("***** CL_HTTP_BeginDownload *****\n" "Localname: %s\n" "RemoteURL: %s\n" "****************************\n", localName, remoteURL); @@ -268,81 +289,81 @@ void CL_cURL_BeginDownload( const char *localName, const char *remoteURL ) clc.downloadBlock = 0; // Starting new file clc.downloadCount = 0; - clc.downloadCURL = qcurl_easy_init(); - if(!clc.downloadCURL) { - Com_Error(ERR_DROP, "CL_cURL_BeginDownload: qcurl_easy_init() " + downloadCURL = qcurl_easy_init(); + if(!downloadCURL) { + Com_Error(ERR_DROP, "CL_HTTP_BeginDownload: qcurl_easy_init() " "failed"); return; } clc.download = FS_SV_FOpenFileWrite(clc.downloadTempName); if(!clc.download) { - Com_Error(ERR_DROP, "CL_cURL_BeginDownload: failed to open " + Com_Error(ERR_DROP, "CL_HTTP_BeginDownload: failed to open " "%s for writing", clc.downloadTempName); return; } if(com_developer->integer) - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_VERBOSE, 1); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_URL, clc.downloadURL); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_TRANSFERTEXT, 0); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_REFERER, va("ioQ3://%s", + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_VERBOSE, 1); + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_URL, clc.downloadURL); + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_TRANSFERTEXT, 0); + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_REFERER, va("ioQ3://%s", NET_AdrToString(clc.serverAddress))); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_USERAGENT, va("%s %s", + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_USERAGENT, va("%s %s", Q3_VERSION, qcurl_version())); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_WRITEFUNCTION, + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_WRITEFUNCTION, CL_cURL_CallbackWrite); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_WRITEDATA, &clc.download); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_NOPROGRESS, 0); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_XFERINFOFUNCTION, + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_WRITEDATA, &clc.download); + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_NOPROGRESS, 0); + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_XFERINFOFUNCTION, CL_cURL_CallbackProgress); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_PROGRESSDATA, NULL); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_FAILONERROR, 1); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_FOLLOWLOCATION, 1); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_MAXREDIRS, 5); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_PROTOCOLS_STR, "http,https"); - qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_BUFFERSIZE, CURL_MAX_READ_SIZE); - clc.downloadCURLM = qcurl_multi_init(); - if(!clc.downloadCURLM) { - qcurl_easy_cleanup(clc.downloadCURL); - clc.downloadCURL = NULL; - Com_Error(ERR_DROP, "CL_cURL_BeginDownload: qcurl_multi_init() " + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_PROGRESSDATA, NULL); + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_FAILONERROR, 1); + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_FOLLOWLOCATION, 1); + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_MAXREDIRS, 5); + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_PROTOCOLS_STR, "http,https"); + qcurl_easy_setopt_warn(downloadCURL, CURLOPT_BUFFERSIZE, CURL_MAX_READ_SIZE); + downloadCURLM = qcurl_multi_init(); + if(!downloadCURLM) { + qcurl_easy_cleanup(downloadCURL); + downloadCURL = NULL; + Com_Error(ERR_DROP, "CL_HTTP_BeginDownload: qcurl_multi_init() " "failed"); return; } - result = qcurl_multi_add_handle(clc.downloadCURLM, clc.downloadCURL); + result = qcurl_multi_add_handle(downloadCURLM, downloadCURL); if(result != CURLM_OK) { - qcurl_easy_cleanup(clc.downloadCURL); - clc.downloadCURL = NULL; - Com_Error(ERR_DROP,"CL_cURL_BeginDownload: qcurl_multi_add_handle() failed: %s", qcurl_multi_strerror(result)); + qcurl_easy_cleanup(downloadCURL); + downloadCURL = NULL; + Com_Error(ERR_DROP,"CL_HTTP_BeginDownload: qcurl_multi_add_handle() failed: %s", qcurl_multi_strerror(result)); return; } if(!(clc.sv_allowDownload & DLF_NO_DISCONNECT) && - !clc.cURLDisconnected) { + !clc.disconnectedForHttpDownload) { CL_AddReliableCommand("disconnect", qtrue); CL_WritePacket(); CL_WritePacket(); CL_WritePacket(); - clc.cURLDisconnected = qtrue; + clc.disconnectedForHttpDownload = qtrue; } } -void CL_cURL_PerformDownload(void) +void CL_HTTP_PerformDownload(void) { CURLMcode res; CURLMsg *msg; int c; int i = 0; - res = qcurl_multi_perform(clc.downloadCURLM, &c); + res = qcurl_multi_perform(downloadCURLM, &c); while(res == CURLM_CALL_MULTI_PERFORM && i < 100) { - res = qcurl_multi_perform(clc.downloadCURLM, &c); + res = qcurl_multi_perform(downloadCURLM, &c); i++; } if(res == CURLM_CALL_MULTI_PERFORM) return; - msg = qcurl_multi_info_read(clc.downloadCURLM, &c); + msg = qcurl_multi_info_read(downloadCURLM, &c); if(msg == NULL) { return; } @@ -363,4 +384,5 @@ void CL_cURL_PerformDownload(void) CL_NextDownload(); } -#endif /* USE_CURL */ + +#endif /* USE_HTTP */ diff --git a/code/client/cl_main.c b/code/client/cl_main.c index 6c257952..3e36106c 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -1210,8 +1210,8 @@ void CL_ShutdownAll(qboolean shutdownRef) if(clc.demorecording) CL_StopRecord_f(); -#ifdef USE_CURL - CL_cURL_Shutdown(); +#ifdef USE_HTTP + CL_HTTP_Shutdown(); #endif // clear sounds S_DisableSounds(); @@ -2088,17 +2088,17 @@ Called when all downloading has been completed */ void CL_DownloadsComplete( void ) { -#ifdef USE_CURL - // if we downloaded with cURL - if(clc.cURLUsed) { - clc.cURLUsed = qfalse; - CL_cURL_Shutdown(); - if( clc.cURLDisconnected ) { +#ifdef USE_HTTP + // if we downloaded with HTTP + if(clc.httpUsed) { + clc.httpUsed = qfalse; + CL_HTTP_Shutdown(); + if( clc.disconnectedForHttpDownload ) { if(clc.downloadRestart) { FS_Restart(clc.checksumFeed); clc.downloadRestart = qfalse; } - clc.cURLDisconnected = qfalse; + clc.disconnectedForHttpDownload = qfalse; CL_Reconnect_f(); return; } @@ -2193,7 +2193,7 @@ void CL_NextDownload(void) { char *s; char *remoteName, *localName; - qboolean useCURL = qfalse; + qboolean usedHTTP = qfalse; // A download has finished, check whether this matches a referenced checksum if(*clc.downloadName) @@ -2230,7 +2230,7 @@ void CL_NextDownload(void) *s++ = 0; else s = localName + strlen(localName); // point at the nul byte -#ifdef USE_CURL +#ifdef USE_HTTP if(!(cl_allowDownload->integer & DLF_NO_REDIRECT)) { if(clc.sv_allowDownload & DLF_NO_REDIRECT) { Com_Printf("WARNING: server does not " @@ -2243,14 +2243,10 @@ void CL_NextDownload(void) "download redirection, but does not " "have sv_dlURL set\n"); } - else if(!CL_cURL_Init()) { - Com_Printf("WARNING: could not load " - "cURL library\n"); - } - else { - CL_cURL_BeginDownload(localName, va("%s/%s", + else if(CL_HTTP_Available()) { + CL_HTTP_BeginDownload(localName, va("%s/%s", clc.sv_dlURL, remoteName)); - useCURL = qtrue; + usedHTTP = qtrue; } } else if(!(clc.sv_allowDownload & DLF_NO_REDIRECT)) { @@ -2259,8 +2255,8 @@ void CL_NextDownload(void) "configuration (cl_allowDownload is %d)\n", cl_allowDownload->integer); } -#endif /* USE_CURL */ - if(!useCURL) { +#endif /* USE_HTTP */ + if(!usedHTTP) { if((cl_allowDownload->integer & DLF_NO_UDP)) { Com_Error(ERR_DROP, "UDP Downloads are " "disabled on your client. " @@ -2934,13 +2930,13 @@ void CL_Frame ( int msec ) { return; } -#ifdef USE_CURL - if(clc.downloadCURLM) { - CL_cURL_PerformDownload(); +#ifdef USE_HTTP + if(clc.httpUsed) { + CL_HTTP_PerformDownload(); // we can't process frames normally when in disconnected // download mode since the ui vm expects clc.state to be // CA_CONNECTED - if(clc.cURLDisconnected) { + if(clc.disconnectedForHttpDownload) { cls.realFrametime = msec; cls.frametime = msec; cls.realtime += cls.frametime; @@ -3559,9 +3555,6 @@ void CL_Init( void ) { cl_showMouseRate = Cvar_Get ("cl_showmouserate", "0", 0); cl_allowDownload = Cvar_Get ("cl_allowDownload", "0", CVAR_ARCHIVE); -#ifdef USE_CURL_DLOPEN - cl_cURLLib = Cvar_Get("cl_cURLLib", DEFAULT_CURL_LIB, CVAR_ARCHIVE | CVAR_PROTECTED); -#endif cl_conXOffset = Cvar_Get ("cl_conXOffset", "0", 0); #ifdef __APPLE__ @@ -3656,6 +3649,11 @@ void CL_Init( void ) { cl_voipProtocol = Cvar_Get ("cl_voipProtocol", cl_voip->integer ? "opus" : "", CVAR_USERINFO | CVAR_ROM); #endif +#ifdef USE_HTTP + if(!CL_HTTP_Init()) { + Com_Printf("WARNING: couldn't initialize HTTP download support\n"); + } +#endif // cgame might not be initialized before menu is used Cvar_Get ("cg_viewsize", "100", CVAR_ARCHIVE ); diff --git a/code/client/client.h b/code/client/client.h index 0d3e1c33..e458b4f8 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -30,9 +30,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../cgame/cg_public.h" #include "../game/bg_public.h" -#ifdef USE_CURL -#include "cl_curl.h" -#endif /* USE_CURL */ +#ifdef USE_HTTP +#include "cl_http.h" +#endif /* USE_HTTP */ #ifdef USE_VOIP #include @@ -198,14 +198,11 @@ typedef struct { fileHandle_t download; char downloadTempName[MAX_OSPATH]; char downloadName[MAX_OSPATH]; -#ifdef USE_CURL - qboolean cURLEnabled; - qboolean cURLUsed; - qboolean cURLDisconnected; +#ifdef USE_HTTP + qboolean httpUsed; + qboolean disconnectedForHttpDownload; char downloadURL[MAX_OSPATH]; - CURL *downloadCURL; - CURLM *downloadCURLM; -#endif /* USE_CURL */ +#endif /* USE_HTTP */ int sv_allowDownload; char sv_dlURL[MAX_CVAR_VALUE_STRING]; int downloadNumber; diff --git a/code/libs/win32/libcurl.a b/code/libs/win32/libcurl.a deleted file mode 100644 index 47f4d284..00000000 Binary files a/code/libs/win32/libcurl.a and /dev/null differ diff --git a/code/libs/win64/libcurl.a b/code/libs/win64/libcurl.a deleted file mode 100644 index d343d480..00000000 Binary files a/code/libs/win64/libcurl.a and /dev/null differ diff --git a/misc/linux/server_compile.sh b/misc/linux/server_compile.sh index b4e10377..c116149e 100644 --- a/misc/linux/server_compile.sh +++ b/misc/linux/server_compile.sh @@ -4,7 +4,7 @@ set -e export BUILD_CLIENT="${BUILD_CLIENT:-0}" export BUILD_SERVER="${BUILD_SERVER:-1}" -export USE_CURL="${USE_CURL:-1}" +export USE_HTTP="${USE_HTTP:-1}" export USE_CODEC_OPUS="${USE_CODEC_OPUS:-1}" export USE_VOIP="${USE_VOIP:-1}" export COPYDIR="${COPYDIR:-~/ioquake3}" diff --git a/misc/nsis/Makefile b/misc/nsis/Makefile index a17d2a45..4c253163 100644 --- a/misc/nsis/Makefile +++ b/misc/nsis/Makefile @@ -19,9 +19,6 @@ endif ifndef USE_OPENAL_DLOPEN USE_OPENAL_DLOPEN=1 endif -ifndef USE_CURL_DLOPEN -USE_CURL_DLOPEN=0 -endif ifndef USE_INTERNAL_ZLIB USE_INTERNAL_ZLIB=1 endif @@ -50,9 +47,6 @@ endif ifeq ($(USE_OPENAL_DLOPEN),1) DEFINES+= -DUSE_OPENAL_DLOPEN endif -ifeq ($(USE_CURL_DLOPEN),1) - DEFINES+= -DUSE_CURL_DLOPEN -endif ifeq ($(USE_INTERNAL_ZLIB),1) DEFINES+= -DUSE_INTERNAL_ZLIB endif diff --git a/misc/nsis/ioquake3.nsi.in b/misc/nsis/ioquake3.nsi.in index a4bf5cb5..a405f877 100644 --- a/misc/nsis/ioquake3.nsi.in +++ b/misc/nsis/ioquake3.nsi.in @@ -155,16 +155,6 @@ Section "OpenAL-Soft library" OpenAL SectionEnd !endif -!ifdef USE_CURL_DLOPEN -Section "libcurl" libcurl - - SetOutPath $INSTDIR - - File "libcurl-4.dll" - -SectionEnd -!endif - ;-------------------------------- ; Uninstaller @@ -210,9 +200,6 @@ Section "Uninstall" !ifdef USE_OPENAL_DLOPEN Delete $INSTDIR\OpenAL32.dll !endif -!ifdef USE_CURL_DLOPEN - Delete $INSTDIR\libcurl-4.dll -!endif Delete $INSTDIR\uninstall.exe @@ -235,7 +222,4 @@ SectionEnd !ifdef USE_OPENAL_DLOPEN !insertmacro MUI_DESCRIPTION_TEXT ${OpenAL} "Advanced audio mixer that supports surround sound." !endif -!ifdef USE_CURL_DLOPEN - !insertmacro MUI_DESCRIPTION_TEXT ${libcurl} "Used for HTTP file downloads." -!endif !insertmacro MUI_FUNCTION_DESCRIPTION_END