Skip to content

Commit

Permalink
curl.patch
Browse files Browse the repository at this point in the history
  • Loading branch information
yjh0502 committed Jan 14, 2023
1 parent d2fa08e commit fb8c1ca
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 14 deletions.
10 changes: 5 additions & 5 deletions Assets/curl-unity/Native/Lib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ public static class Lib
public static extern CURLE curl_easy_perform(IntPtr easyPtr);

[DllImport(LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
public static extern CURLE curl_easy_getinfo(IntPtr easyPtr, CURLINFO info, ref long arg);
public static extern CURLE curl_easy_getinfo_ptr(IntPtr easyPtr, CURLINFO info, ref long arg);
[DllImport(LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
public static extern CURLE curl_easy_getinfo(IntPtr easyPtr, CURLINFO info, ref double arg);
public static extern CURLE curl_easy_getinfo_ptr(IntPtr easyPtr, CURLINFO info, ref double arg);
[DllImport(LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
public static extern CURLE curl_easy_getinfo(IntPtr easyPtr, CURLINFO info, ref IntPtr arg);

public static extern CURLE curl_easy_getinfo_ptr(IntPtr easyPtr, CURLINFO info, ref IntPtr arg);
[DllImport(LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr curl_easy_escape(IntPtr easyPtr, string data, long length = 0);
[DllImport(LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
Expand Down Expand Up @@ -137,4 +137,4 @@ public static class Lib
public static extern CURLSH curl_share_cleanup(IntPtr sharePtr);
#endregion
}
}
}
18 changes: 9 additions & 9 deletions Assets/curl-unity/Scripts/CurlEasy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class CurlEasy : IDisposable
public string message { get; private set; }
public bool running { get; private set; }
public PerformCallback performCallback { get; set; }
public ProgressCallback progressCallback { get; set; }
public ProgressCallback progressCallback { get; set; }
public bool debug { get; set; }
public CurlDecoder decoder { get; set; }

Expand Down Expand Up @@ -239,20 +239,20 @@ public CURLE SetOpt(CURLOPT options, Delegates.ProgressFunction value)
public CURLE GetInfo(CURLINFO info, out long value)
{
value = 0;
return Lib.curl_easy_getinfo(easyPtr, info, ref value);
return Lib.curl_easy_getinfo_ptr(easyPtr, info, ref value);
}

public CURLE GetInfo(CURLINFO info, out double value)
{
value = 0;
return Lib.curl_easy_getinfo(easyPtr, info, ref value);
return Lib.curl_easy_getinfo_ptr(easyPtr, info, ref value);
}

public CURLE GetInfo(CURLINFO info, out string value)
{
value = null;
IntPtr ptr = IntPtr.Zero;
var result = Lib.curl_easy_getinfo(easyPtr, info, ref ptr);
var result = Lib.curl_easy_getinfo_ptr(easyPtr, info, ref ptr);
if (ptr != IntPtr.Zero)
{
value = Marshal.PtrToStringAnsi(ptr);
Expand All @@ -264,7 +264,7 @@ public CURLE GetInfo(CURLINFO info, out CurlSlist value)
{
value = null;
IntPtr ptr = IntPtr.Zero;
var result = Lib.curl_easy_getinfo(easyPtr, info, ref ptr);
var result = Lib.curl_easy_getinfo_ptr(easyPtr, info, ref ptr);
value = new CurlSlist(ptr);
return result;
}
Expand Down Expand Up @@ -401,7 +401,7 @@ private void Prepare()
SetOpt(CURLOPT.URL, uri.AbsoluteUri);

var upperMethod = method.ToUpper();
switch (upperMethod)
switch(upperMethod)
{
case "GET":
SetOpt(CURLOPT.HTTPGET, true);
Expand All @@ -418,8 +418,8 @@ private void Prepare()
}

SetOpt(CURLOPT.HTTP_VERSION, (long)HTTPVersion.VERSION_2TLS);
SetOpt(CURLOPT.PIPEWAIT, true);

SetOpt(CURLOPT.PIPEWAIT, true);
SetOpt(CURLOPT.SSL_VERIFYHOST, !insecure);
SetOpt(CURLOPT.SSL_VERIFYPEER, !insecure);

Expand Down Expand Up @@ -862,4 +862,4 @@ public static explicit operator CurlEasy(IntPtr ptr)
return new CurlEasy(ptr);
}
}
}
}
8 changes: 8 additions & 0 deletions build/curl/curl-7.87.0/lib/easy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,3 +1339,11 @@ CURLcode curl_easy_upkeep(struct Curl_easy *data)
return CURLE_OK;
}
}

/* IL2CPP Compatible */
/* !checksrc! disable LONGLINE all */
CURL_EXTERN CURLcode curl_easy_getinfo_ptr(struct Curl_easy *data, CURLINFO info, void **arg)
{
return curl_easy_getinfo(data, info, arg);
}
/* !checksrc! enable LONGLINE */
113 changes: 113 additions & 0 deletions build/curl/curl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
diff --git b/build/curl/curl-7.87.0/include/curl/easy.h a/build/curl/curl-7.87.0/include/curl/easy.h
index 98ee8888..0540948b 100644
--- b/build/curl/curl-7.87.0/include/curl/easy.h
+++ a/build/curl/curl-7.87.0/include/curl/easy.h
@@ -118,6 +118,12 @@ CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
*/
CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl);

+/* !checksrc! disable LONGLINE all */
+CURL_EXTERN CURLcode curl_easy_setopt_str(CURL *curl, CURLoption option, const char *arg);
+CURL_EXTERN CURLcode curl_easy_setopt_int(CURL *curl, CURLoption option, long arg);
+CURL_EXTERN CURLcode curl_easy_setopt_ptr(CURL *curl, CURLoption option, void *arg);
+/* !checksrc! enable LONGLINE */
+
#ifdef __cplusplus
} /* end of extern "C" */
#endif
diff --git b/build/curl/curl-7.87.0/lib/easy.c a/build/curl/curl-7.87.0/lib/easy.c
index d7f93be1..f58968bf 100644
--- b/build/curl/curl-7.87.0/lib/easy.c
+++ a/build/curl/curl-7.87.0/lib/easy.c
@@ -1339,3 +1339,11 @@ CURLcode curl_easy_upkeep(struct Curl_easy *data)
return CURLE_OK;
}
}
+
+/* IL2CPP Compatible */
+/* !checksrc! disable LONGLINE all */
+CURL_EXTERN CURLcode curl_easy_getinfo_ptr(struct Curl_easy *data, CURLINFO info, void **arg)
+{
+ return curl_easy_getinfo(data, info, arg);
+}
+/* !checksrc! enable LONGLINE */
diff --git b/build/curl/curl-7.87.0/lib/multi.c a/build/curl/curl-7.87.0/lib/multi.c
index b96ee7c7..cd0709a4 100644
--- b/build/curl/curl-7.87.0/lib/multi.c
+++ a/build/curl/curl-7.87.0/lib/multi.c
@@ -3743,3 +3743,25 @@ unsigned int Curl_multi_max_concurrent_streams(struct Curl_multi *multi)
DEBUGASSERT(multi);
return multi->max_concurrent_streams;
}
+
+
+/* IL2CPP Compatible */
+/* !checksrc! disable LONGLINE all */
+CURL_EXTERN CURLMcode curl_multi_setopt_int(CURLM *multi_handle,
+ CURLMoption option, int arg)
+{
+ return curl_multi_setopt(multi_handle, option, arg);
+}
+
+CURL_EXTERN CURLMcode curl_multi_setopt_str(CURLM *multi_handle,
+ CURLMoption option, const char *arg)
+{
+ return curl_multi_setopt(multi_handle, option, arg);
+}
+
+CURL_EXTERN CURLMcode curl_multi_setopt_ptr(CURLM *multi_handle,
+ CURLMoption option, void *arg)
+{
+ return curl_multi_setopt(multi_handle, option, arg);
+}
+/* !checksrc! enable LONGLINE */
diff --git b/build/curl/curl-7.87.0/lib/setopt.c a/build/curl/curl-7.87.0/lib/setopt.c
index b77e95b4..0ac9c215 100644
--- b/build/curl/curl-7.87.0/lib/setopt.c
+++ a/build/curl/curl-7.87.0/lib/setopt.c
@@ -3152,3 +3152,19 @@ CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...)
va_end(arg);
return result;
}
+
+/* IL2CPP Compatible */
+/* !checksrc! disable LONGLINE all */
+CURL_EXTERN CURLcode curl_easy_setopt_str(struct Curl_easy *data, CURLoption tag, const char *arg)
+{
+ return curl_easy_setopt(data, tag, arg);
+}
+CURL_EXTERN CURLcode curl_easy_setopt_int(struct Curl_easy *data, CURLoption tag, long arg)
+{
+ return curl_easy_setopt(data, tag, arg);
+}
+CURL_EXTERN CURLcode curl_easy_setopt_ptr(struct Curl_easy *data, CURLoption tag, void *arg)
+{
+ return curl_easy_setopt(data, tag, arg);
+}
+/* !checksrc! enable LONGLINE */
diff --git b/build/curl/curl-7.87.0/lib/share.c a/build/curl/curl-7.87.0/lib/share.c
index 1a083e72..415f8536 100644
--- b/build/curl/curl-7.87.0/lib/share.c
+++ a/build/curl/curl-7.87.0/lib/share.c
@@ -260,3 +260,21 @@ Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)

return CURLSHE_OK;
}
+
+/* IL2CPP Compatible */
+/* !checksrc! disable LONGLINE all */
+CURL_EXTERN CURLSHcode curl_share_setopt_int(CURLSH *share, CURLSHoption option, int arg)
+{
+ return curl_share_setopt(share, option, arg);
+}
+
+CURL_EXTERN CURLSHcode curl_share_setopt_str(CURLSH *share, CURLSHoption option, const char *arg)
+{
+ return curl_share_setopt(share, option, arg);
+}
+
+CURL_EXTERN CURLSHcode curl_share_setopt_ptr(CURLSH *share, CURLSHoption option, void *arg)
+{
+ return curl_share_setopt(share, option, arg);
+}
+/* !checksrc! enable LONGLINE */

0 comments on commit fb8c1ca

Please sign in to comment.