2
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
4
4
using System ;
5
+ using System . Runtime . InteropServices ;
6
+
7
+ using size_t = System . UInt64 ;
8
+ using curl_socket_t = System . Int32 ;
5
9
6
10
internal static partial class Interop
7
11
{
8
12
internal static partial class libcurl
9
13
{
14
+ // Class for constants defined for the global flags in curl.h
15
+ internal static partial class CurlGlobalFlags
16
+ {
17
+ internal const long CURL_GLOBAL_SSL = 1L ;
18
+ internal const long CURL_GLOBAL_WIN32 = 2L ;
19
+ internal const long CURL_GLOBAL_ALL = ( CURL_GLOBAL_SSL | CURL_GLOBAL_WIN32 ) ;
20
+ }
21
+
10
22
// Class for constants defined for the enum CURLoption in curl.h
11
23
internal static partial class CURLoption
12
24
{
13
25
// Curl options are of the format <type base> + <n>
14
26
private const int CurlOptionLongBase = 0 ;
15
27
private const int CurlOptionObjectPointBase = 10000 ;
28
+ private const int CurlOptionFunctionPointBase = 20000 ;
16
29
17
- internal const int CURLOPT_URL = CurlOptionObjectPointBase + 2 ;
30
+ internal const int CURLOPT_NOBODY = CurlOptionLongBase + 44 ;
31
+ internal const int CURLOPT_UPLOAD = CurlOptionLongBase + 46 ;
18
32
internal const int CURLOPT_FOLLOWLOCATION = CurlOptionLongBase + 52 ;
19
33
internal const int CURLOPT_PROXYPORT = CurlOptionLongBase + 59 ;
20
34
internal const int CURLOPT_PROXYTYPE = CurlOptionLongBase + 101 ;
21
35
22
36
internal const int CURLOPT_WRITEDATA = CurlOptionObjectPointBase + 1 ;
37
+ internal const int CURLOPT_URL = CurlOptionObjectPointBase + 2 ;
23
38
internal const int CURLOPT_PROXY = CurlOptionObjectPointBase + 4 ;
24
39
internal const int CURLOPT_PROXYUSERPWD = CurlOptionObjectPointBase + 6 ;
40
+ internal const int CURLOPT_READDATA = CurlOptionObjectPointBase + 9 ;
41
+ internal const int CURLOPT_HTTPHEADER = CurlOptionObjectPointBase + 23 ;
42
+ internal const int CURLOPT_HEADERDATA = CurlOptionObjectPointBase + 29 ;
25
43
internal const int CURLOPT_ACCEPTENCODING = CurlOptionObjectPointBase + 102 ;
44
+ internal const int CURLOPT_PRIVATE = CurlOptionObjectPointBase + 103 ;
45
+ internal const int CURLOPT_IOCTLDATA = CurlOptionObjectPointBase + 131 ;
46
+
47
+ internal const int CURLOPT_WRITEFUNCTION = CurlOptionFunctionPointBase + 11 ;
48
+ internal const int CURLOPT_READFUNCTION = CurlOptionFunctionPointBase + 12 ;
49
+ internal const int CURLOPT_HEADERFUNCTION = CurlOptionFunctionPointBase + 79 ;
50
+ internal const int CURLOPT_IOCTLFUNCTION = CurlOptionFunctionPointBase + 130 ;
51
+ }
52
+
53
+ // Class for constants defined for the enum CURLMoption in multi.h
54
+ internal static partial class CURLMoption
55
+ {
56
+ // Curl options are of the format <type base> + <n>
57
+ private const int CurlOptionObjectPointBase = 10000 ;
58
+ private const int CurlOptionFunctionPointBase = 20000 ;
59
+
60
+ internal const int CURLMOPT_TIMERDATA = CurlOptionObjectPointBase + 5 ;
61
+
62
+ internal const int CURLMOPT_SOCKETFUNCTION = CurlOptionFunctionPointBase + 1 ;
63
+ internal const int CURLMOPT_TIMERFUNCTION = CurlOptionFunctionPointBase + 4 ;
26
64
}
27
65
28
66
// Class for constants defined for the enum CURLINFO in curl.h
29
67
internal static partial class CURLINFO
30
68
{
31
69
// Curl info are of the format <type base> + <n>
32
- private const int CurlInfoLongBase = 0x200000 ;
33
- internal const int CURLINFO_RESPONSE_CODE = CurlInfoLongBase + 2 ;
70
+ private const int CurlInfoStringBase = 0x100000 ;
71
+
72
+ internal const int CURLINFO_PRIVATE = CurlInfoStringBase + 21 ;
34
73
}
35
74
36
75
// Class for constants defined for the enum curl_proxytype in curl.h
@@ -44,5 +83,87 @@ internal static partial class CURLcode
44
83
{
45
84
internal const int CURLE_OK = 0 ;
46
85
}
86
+
87
+ // Class for constants defined for the enum CURLMcode in multi.h
88
+ internal static partial class CURLMcode
89
+ {
90
+ internal const int CURLM_OK = 0 ;
91
+ }
92
+
93
+ // Class for constants defined for the enum curlioerr in curl.h
94
+ internal static partial class curlioerr
95
+ {
96
+ internal const int CURLIOE_OK = 0 ;
97
+ internal const int CURLIOE_UNKNOWNCMD = 1 ;
98
+ internal const int CURLIOE_FAILRESTART = 2 ;
99
+ }
100
+
101
+ // Class for constants defined for the enum curliocmd in curl.h
102
+ internal static partial class curliocmd
103
+ {
104
+ internal const int CURLIOCMD_RESTARTREAD = 1 ;
105
+ }
106
+
107
+ // Class for CURL_POLL_* macros in multi.h
108
+ internal static partial class CurlPoll
109
+ {
110
+ internal const int CURL_POLL_REMOVE = 4 ;
111
+ }
112
+
113
+ // Class for CURL_CSELECT_* macros in multi.h
114
+ internal static partial class CurlSelect
115
+ {
116
+ internal const int CURL_CSELECT_IN = 1 ;
117
+ internal const int CURL_CSELECT_OUT = 2 ;
118
+ }
119
+
120
+ // Class for constants defined for the enum CURLMSG in multi.h
121
+ internal static partial class CURLMSG
122
+ {
123
+ internal const int CURLMSG_DONE = 1 ;
124
+ }
125
+
126
+ // Type definition of CURLMsg from multi.h
127
+ [ StructLayout ( LayoutKind . Explicit ) ]
128
+ internal struct CURLMsg
129
+ {
130
+ [ FieldOffset ( 0 ) ]
131
+ internal int msg ;
132
+ [ FieldOffset ( 8 ) ]
133
+ internal IntPtr easy_handle ;
134
+ [ FieldOffset ( 16 ) ]
135
+ internal IntPtr data ;
136
+ [ FieldOffset ( 16 ) ]
137
+ internal int result ;
138
+ }
139
+
140
+ public delegate int curl_socket_callback (
141
+ IntPtr handle ,
142
+ curl_socket_t sockfd ,
143
+ int what ,
144
+ IntPtr context ,
145
+ IntPtr sockptr ) ;
146
+
147
+ public delegate int curl_multi_timer_callback (
148
+ IntPtr handle ,
149
+ long timeout_ms ,
150
+ IntPtr context ) ;
151
+
152
+ public delegate size_t curl_readwrite_callback (
153
+ IntPtr buffer ,
154
+ size_t size ,
155
+ size_t nitems ,
156
+ IntPtr context ) ;
157
+
158
+ public unsafe delegate size_t curl_unsafe_write_callback (
159
+ byte * buffer ,
160
+ size_t size ,
161
+ size_t nitems ,
162
+ IntPtr context ) ;
163
+
164
+ public delegate int curl_ioctl_callback (
165
+ IntPtr handle ,
166
+ int cmd ,
167
+ IntPtr context ) ;
47
168
}
48
169
}
0 commit comments