~ubuntu-branches/ubuntu/precise/openarena/precise

« back to all changes in this revision

Viewing changes to code/client/cl_curl.c

  • Committer: Bazaar Package Importer
  • Author(s): Ansgar Burchardt
  • Date: 2008-09-05 21:14:51 UTC
  • mfrom: (1.2.1 upstream) (2.1.5 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080905211451-243bmbl6l6gdav7l
* Remove non-free code/tools/lcc (Closes: #496346)
  + Remove hunk from patch 10_fix_build_and_binary_on_alpha
  + debian/rules: Add BUILD_GAME_QVM=0 to $(MAKE) call
    (thanks to Peter De Wachter)
* Remove code/libs containing binary libraries for Mac OS X and Win32
* debian/copyright: Explain which parts of upstream's sources were removed
* debian/rules: replace ${source:Upstream-Version} by 0.7.7
  because the variable also contains the `+dfsg1' part
* Add -fsigned-char to compiler options (Closes: #487970)
  (thanks to Peter De Wachter)
* Add myself to Uploaders
* debian/control: Remove article from beginning of short description,
  don't start short description with a capital letter
* debian/openarena.6: Escape minus signs
  + fixes lintian warnings: hyphen-used-as-minus-sign

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
===========================================================================
21
21
*/
22
22
 
23
 
#if USE_CURL
 
23
#ifdef USE_CURL
24
24
#include "client.h"
25
25
cvar_t *cl_cURLLib;
26
26
 
27
 
#if USE_CURL_DLOPEN
28
 
 
29
 
#if USE_SDL_VIDEO
30
 
#include "SDL.h"
31
 
#include "SDL_loadso.h"
32
 
#define OBJTYPE void *
33
 
#define OBJLOAD(x) SDL_LoadObject(x)
34
 
#define SYMLOAD(x,y) SDL_LoadFunction(x,y)
35
 
#define OBJFREE(x) SDL_UnloadObject(x)
36
 
 
37
 
#elif defined _WIN32
38
 
#include <windows.h>
39
 
#define OBJTYPE HMODULE
40
 
#define OBJLOAD(x) LoadLibrary(x)
41
 
#define SYMLOAD(x,y) GetProcAddress(x,y)
42
 
#define OBJFREE(x) FreeLibrary(x)
43
 
 
44
 
#elif defined __linux__ || defined __FreeBSD__ || defined MACOS_X || defined __sun
45
 
#include <dlfcn.h>
46
 
#define OBJTYPE void *
47
 
#define OBJLOAD(x) dlopen(x, RTLD_LAZY | RTLD_GLOBAL)
48
 
#define SYMLOAD(x,y) dlsym(x,y)
49
 
#define OBJFREE(x) dlclose(x)
50
 
#else
51
 
 
52
 
#error "Your platform has no lib loading code or it is disabled"
53
 
#endif
54
 
 
55
 
#if defined __linux__ || defined __FreeBSD__ || defined MACOS_X
56
 
#include <unistd.h>
57
 
#include <sys/types.h>
58
 
#endif
 
27
#ifdef USE_CURL_DLOPEN
 
28
#include "../sys/sys_loadlib.h"
59
29
 
60
30
char* (*qcurl_version)(void);
61
31
 
85
55
                                                int *msgs_in_queue);
86
56
const char *(*qcurl_multi_strerror)(CURLMcode);
87
57
 
88
 
static OBJTYPE cURLLib = NULL;
 
58
static void *cURLLib = NULL;
89
59
 
90
60
/*
91
61
=================
96
66
{
97
67
        void *rv;
98
68
 
99
 
        rv = SYMLOAD(cURLLib, str);
 
69
        rv = Sys_LoadFunction(cURLLib, str);
100
70
        if(!rv)
101
71
        {
102
72
                Com_Printf("Can't load symbol %s\n", str);
105
75
        }
106
76
        else
107
77
        {
108
 
                Com_DPrintf("Loaded symbol %s (0x%08X)\n", str, rv);
 
78
                Com_DPrintf("Loaded symbol %s (0x%p)\n", str, rv);
109
79
        return rv;
110
80
        }
111
81
}
118
88
*/
119
89
qboolean CL_cURL_Init()
120
90
{
121
 
#if USE_CURL_DLOPEN
 
91
#ifdef USE_CURL_DLOPEN
122
92
        if(cURLLib)
123
93
                return qtrue;
124
94
 
125
95
 
126
96
        Com_Printf("Loading \"%s\"...", cl_cURLLib->string);
127
 
        if( (cURLLib = OBJLOAD(cl_cURLLib->string)) == 0 )
 
97
        if( (cURLLib = Sys_LoadLibrary(cl_cURLLib->string)) == 0 )
128
98
        {
129
99
#ifdef _WIN32
130
100
                return qfalse;
131
101
#else
132
102
                char fn[1024];
133
 
                getcwd(fn, sizeof(fn));
134
 
                strncat(fn, "/", sizeof(fn));
135
 
                strncat(fn, cl_cURLLib->string, sizeof(fn));
136
 
 
137
 
                if( (cURLLib = OBJLOAD(fn)) == 0 )
 
103
 
 
104
                Q_strncpyz( fn, Sys_Cwd( ), sizeof( fn ) );
 
105
                strncat(fn, "/", sizeof(fn)-strlen(fn)-1);
 
106
                strncat(fn, cl_cURLLib->string, sizeof(fn)-strlen(fn)-1);
 
107
 
 
108
                if((cURLLib = Sys_LoadLibrary(fn)) == 0)
138
109
                {
 
110
#ifdef ALTERNATE_CURL_LIB
 
111
                        // On some linux distributions there is no libcurl.so.3, but only libcurl.so.4. That one works too.
 
112
                        if( (cURLLib = Sys_LoadLibrary(ALTERNATE_CURL_LIB)) == 0 )
 
113
                        {
 
114
                                return qfalse;
 
115
                        }
 
116
#else
139
117
                        return qfalse;
 
118
#endif
140
119
                }
141
120
#endif /* _WIN32 */
142
121
        }
186
165
void CL_cURL_Shutdown( void )
187
166
{
188
167
        CL_cURL_Cleanup();
189
 
#if USE_CURL_DLOPEN
 
168
#ifdef USE_CURL_DLOPEN
190
169
        if(cURLLib)
191
170
        {
192
 
                OBJFREE(cURLLib);
 
171
                Sys_UnloadLibrary(cURLLib);
193
172
                cURLLib = NULL;
194
173
        }
195
174
        qcurl_easy_init = NULL;
298
277
                CL_cURL_CallbackProgress);
299
278
        qcurl_easy_setopt(clc.downloadCURL, CURLOPT_PROGRESSDATA, NULL);
300
279
        qcurl_easy_setopt(clc.downloadCURL, CURLOPT_FAILONERROR, 1);
 
280
        qcurl_easy_setopt(clc.downloadCURL, CURLOPT_FOLLOWLOCATION, 1);
 
281
        qcurl_easy_setopt(clc.downloadCURL, CURLOPT_MAXREDIRS, 5);
301
282
        clc.downloadCURLM = qcurl_multi_init(); 
302
283
        if(!clc.downloadCURLM) {
303
284
                qcurl_easy_cleanup(clc.downloadCURL);
347
328
 
348
329
                qcurl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE,
349
330
                        &code); 
350
 
                Com_Error(ERR_DROP, "Download Error: %s Code: %d URL: %s",
 
331
                Com_Error(ERR_DROP, "Download Error: %s Code: %ld URL: %s",
351
332
                        qcurl_easy_strerror(msg->data.result),
352
333
                        code, clc.downloadURL);
353
334
        }