Skip to content

Commit

Permalink
Merge pull request #2007 from JD557/native-windows-support
Browse files Browse the repository at this point in the history
Add Windows support to the Curl backend
  • Loading branch information
adamw committed Nov 26, 2023
2 parents 63ee890 + 273451a commit 0ce7e08
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 14 additions & 2 deletions core/src/main/scalanative/sttp/client4/curl/internal/CCurl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@ package sttp.client4.curl.internal
import sttp.client4.curl.internal.CurlCode.CurlCode

import scala.scalanative.unsafe._
import scala.scalanative.meta.LinktimeInfo.isWindows

private[curl] trait Curl {}

private[curl] trait Mime {}

private[curl] trait MimePart {}

@link("curl")
private[curl] object libcurlPlatformCompat {
@extern @link("libcurl") @link("crypt32")
private object libcurlWin64 extends CCurl

@extern @link("curl")
private object libcurlDefault extends CCurl

val instance: CCurl =
if (isWindows) libcurlWin64
else libcurlDefault
}

@extern
private[curl] object CCurl {
private[curl] trait CCurl {
@name("curl_easy_init")
def init: Ptr[Curl] = extern

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ package object internal {
type CurlSlist = CStruct2[CString, Ptr[_]]
type CurlFetch = CStruct2[CString, CSize]
val CurlZeroTerminated = -1L

private[curl] final val CCurl = libcurlPlatformCompat.instance
}

0 comments on commit 0ce7e08

Please sign in to comment.