blob: b4f332ca4b594272b831faa89691706c978866d4 (
plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#include <stdio.h>
#include <stdarg.h>
#include <curl/curl.h>
char* url = NULL;
void* data = NULL;
#ifdef curl_easy_setopt
#undef curl_easy_setopt
#endif
CURLcode curl_global_init(long flags)
{
puts("[MOCK] curl_global_init(...)");
return CURLE_OK;
}
CURL* curl_easy_init()
{
puts("[MOCK] curl_easy_init(...)");
return NULL;
}
CURLcode curl_easy_setopt(CURL *handle, CURLoption option, ...)
{
puts("[MOCK] curl_easy_setopt(...)");
va_list arg;
va_start(arg, option);
switch (option)
{
case CURLOPT_URL:
url = va_arg(arg, char*);
printf("CURLOPT_URL\t%s\n", url);
break;
case CURLOPT_WRITEDATA:
data = va_arg(arg, void*);
printf("CURLOPT_WRITEDATA\t%p\n", data);
break;
default:
break;
}
va_end(arg);
return CURLE_OK;
}
CURLcode curl_easy_perform(CURL *easy_handle)
{
puts("[MOCK] curl_easy_perform(...)");
return CURLE_OK;
}
#ifdef curl_easy_getinfo
#undef curl_easy_getinfo
#endif
CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...)
{
puts("[MOCK] curl_easy_getinfo(...)");
if (info == CURLINFO_RESPONSE_CODE)
{
va_list arg;
va_start(arg, info);
long* http_code = va_arg(arg, long*);
*http_code = 200;
va_end(arg);
}
return CURLE_OK;
}
const char* curl_easy_strerror(CURLcode error)
{
puts("[MOCK] curl_easy_strerror(...)");
return "error";
}
void curl_easy_cleanup(CURL *handle)
{
puts("[MOCK] curl_easy_cleanup(...)");
}
void curl_global_cleanup()
{
puts("[MOCK] curl_global_cleanup(...)");
}
|