forked from love2d/lua-https
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinktimeLibraryLoader.cpp
More file actions
66 lines (52 loc) · 1.41 KB
/
LinktimeLibraryLoader.cpp
File metadata and controls
66 lines (52 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "../common/config.h"
#include "../common/LibraryLoader.h"
#ifdef HTTPS_LIBRARY_LOADER_LINKTIME
#include <cstring>
#ifdef HTTPS_BACKEND_CURL
#include <curl/curl.h>
static char CurlHandle;
#endif
#if defined(HTTPS_BACKEND_OPENSSL) || defined(HTTPS_BACKEND_ANDROID)
# error "Selected backends that are not compatible with this loader"
#endif
namespace LibraryLoader
{
handle *OpenLibrary(const char *name)
{
#ifdef HTTPS_BACKEND_CURL
if (strstr(name, "libcurl") == name)
return reinterpret_cast<handle *>(&CurlHandle);
#endif
return nullptr;
}
void CloseLibrary(handle *)
{
}
handle* GetCurrentProcessHandle()
{
return nullptr;
}
function *GetFunction(handle *handle, const char *name)
{
#define RETURN_MATCHING_FUNCTION(func) \
if (strcmp(name, #func) == 0) \
return reinterpret_cast<function *>(&func);
#ifdef HTTPS_BACKEND_CURL
if (handle == &CurlHandle)
{
RETURN_MATCHING_FUNCTION(curl_global_init);
RETURN_MATCHING_FUNCTION(curl_global_cleanup);
RETURN_MATCHING_FUNCTION(curl_easy_init);
RETURN_MATCHING_FUNCTION(curl_easy_cleanup);
RETURN_MATCHING_FUNCTION(curl_easy_setopt);
RETURN_MATCHING_FUNCTION(curl_easy_perform);
RETURN_MATCHING_FUNCTION(curl_easy_getinfo);
RETURN_MATCHING_FUNCTION(curl_slist_append);
RETURN_MATCHING_FUNCTION(curl_slist_free_all);
}
#endif
#undef RETURN_MATCHING_FUNCTION
return nullptr;
}
}
#endif // HTTPS_LIBRARY_LOADER_LINKTIME