aboutsummaryrefslogtreecommitdiff
path: root/tests/libssh2.nim
blob: 172f6ae92891df348b6c6710a1209e98f6a898e5 (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
import nimterop/[build, cimport]

const
  outdir = getProjectCacheDir("libssh2")

getHeader(
  header = "libssh2.h",
  conanuri = "libssh2/$1",
  jbburi = "libssh2/1.9.0",
  outdir = outdir
)

cOverride:
  type
    stat = object
    stat64 = object
    SOCKET = object

when not libssh2Static:
  cImport(libssh2Path, recurse = true, dynlib = "libssh2LPath", flags = "-f:ast2 -c -E_ -F_")

  when not defined(Windows) and not isDefined(libssh2JBB):
    proc zlibVersion(): cstring {.importc, dynlib: libssh2LPath.}
else:
  cImport(libssh2Path, recurse = true, flags = "-f:ast2 -c -E_ -F_")

  when not defined(Windows) and not isDefined(libssh2JBB):
    proc zlibVersion(): cstring {.importc.}

  {.passL: "-lpthread".}

assert libssh2_init(0) == 0

let
  session = libssh2_session_init_ex(nil, nil, nil, nil)

if session == nil:
  quit(1)

libssh2_session_set_blocking(session, 0.cint)

echo "zlib version = " & (block:
  when not defined(Windows) and not isDefined(libssh2JBB):
    $zlibVersion()
  else:
    ""
)