-
Notifications
You must be signed in to change notification settings - Fork 0
/
libssh.nim
1197 lines (1125 loc) · 56.8 KB
/
libssh.nim
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{.deadCodeElim: on.}
when defined(Windows):
const
libsshSONAME = "ssh.dll"
elif defined(MacOSX):
const
libsshSONAME = "libssh.dylib"
else:
const
libsshSONAME = "libssh.so"
type
timeval* = object
mode_t* = cint
fd_set* = ptr object
uid_t* = cint
gid_t* = cint
ssize_t* = cint
sftp_ext_struct* = ptr object
template SSH_STRINGIFY*(s: untyped): untyped =
SSH_TOSTRING(s)
template SSH_VERSION_INT*(a, b, c: untyped): untyped =
((a) shl 16 or (b) shl 8 or (c))
template SSH_VERSION*(a, b, c: untyped): untyped =
$a & "." & $b & "." & $c
const
LIBSSH_VERSION_MAJOR* = 0
LIBSSH_VERSION_MINOR* = 9
LIBSSH_VERSION_MICRO* = 0
LIBSSH_VERSION_INT* = SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, LIBSSH_VERSION_MINOR,
LIBSSH_VERSION_MICRO)
LIBSSH_VERSION* = SSH_VERSION(LIBSSH_VERSION_MAJOR, LIBSSH_VERSION_MINOR,
LIBSSH_VERSION_MICRO)
type
ssh_counter_struct* {.bycopy.} = object
in_bytes*: uint64
out_bytes*: uint64
in_packets*: uint64
out_packets*: uint64
ssh_counter* = ptr object
ssh_agent* = ptr object
ssh_buffer* = ptr object
ssh_channel* = ptr object
ssh_message* = ptr object
ssh_pcap_file* = ptr object
ssh_key* = ptr object
ssh_scp* = ptr object
ssh_session* = ptr object
ssh_string* = ptr object
ssh_event* = ptr object
ssh_connector* = ptr object
ssh_gssapi_creds* = pointer
socket_t* = cint
ssh_kex_types_e* {.size: sizeof(cint).} = enum
SSH_KEX = 0, SSH_HOSTKEYS, SSH_CRYPT_C_S, SSH_CRYPT_S_C, SSH_MAC_C_S, SSH_MAC_S_C,
SSH_COMP_C_S, SSH_COMP_S_C, SSH_LANG_C_S, SSH_LANG_S_C
const
SSH_CRYPT* = 2
SSH_MAC* = 3
SSH_COMP* = 4
SSH_LANG* = 5
type
ssh_auth_e* {.size: sizeof(cint).} = enum
SSH_AUTH_ERROR = -1, SSH_AUTH_SUCCESS = 0, SSH_AUTH_DENIED, SSH_AUTH_PARTIAL,
SSH_AUTH_INFO, SSH_AUTH_AGAIN
const
SSH_AUTH_METHOD_UNKNOWN* = 0
SSH_AUTH_METHOD_NONE* = 0x00000001
SSH_AUTH_METHOD_PASSWORD* = 0x00000002
SSH_AUTH_METHOD_PUBLICKEY* = 0x00000004
SSH_AUTH_METHOD_HOSTBASED* = 0x00000008
SSH_AUTH_METHOD_INTERACTIVE* = 0x00000010
SSH_AUTH_METHOD_GSSAPI_MIC* = 0x00000020
type
ssh_requests_e* {.size: sizeof(cint).} = enum
SSH_REQUEST_AUTH = 1, SSH_REQUEST_CHANNEL_OPEN, SSH_REQUEST_CHANNEL,
SSH_REQUEST_SERVICE, SSH_REQUEST_GLOBAL
type
ssh_channel_type_e* {.size: sizeof(cint).} = enum
SSH_CHANNEL_UNKNOWN = 0, SSH_CHANNEL_SESSION, SSH_CHANNEL_DIRECT_TCPIP,
SSH_CHANNEL_FORWARDED_TCPIP, SSH_CHANNEL_X11, SSH_CHANNEL_AUTH_AGENT
type
ssh_channel_requests_e* {.size: sizeof(cint).} = enum
SSH_CHANNEL_REQUEST_UNKNOWN = 0, SSH_CHANNEL_REQUEST_PTY,
SSH_CHANNEL_REQUEST_EXEC, SSH_CHANNEL_REQUEST_SHELL, SSH_CHANNEL_REQUEST_ENV,
SSH_CHANNEL_REQUEST_SUBSYSTEM, SSH_CHANNEL_REQUEST_WINDOW_CHANGE,
SSH_CHANNEL_REQUEST_X11
type
ssh_global_requests_e* {.size: sizeof(cint).} = enum
SSH_GLOBAL_REQUEST_UNKNOWN = 0, SSH_GLOBAL_REQUEST_TCPIP_FORWARD,
SSH_GLOBAL_REQUEST_CANCEL_TCPIP_FORWARD, SSH_GLOBAL_REQUEST_KEEPALIVE
type
ssh_publickey_state_e* {.size: sizeof(cint).} = enum
SSH_PUBLICKEY_STATE_ERROR = -1, SSH_PUBLICKEY_STATE_NONE = 0,
SSH_PUBLICKEY_STATE_VALID = 1, SSH_PUBLICKEY_STATE_WRONG = 2
const
SSH_CLOSED* = 0x00000001
SSH_READ_PENDING* = 0x00000002
SSH_CLOSED_ERROR* = 0x00000004
SSH_WRITE_PENDING* = 0x00000008
type
ssh_server_known_e* {.size: sizeof(cint).} = enum
SSH_SERVER_ERROR = -1, SSH_SERVER_NOT_KNOWN = 0, SSH_SERVER_KNOWN_OK,
SSH_SERVER_KNOWN_CHANGED, SSH_SERVER_FOUND_OTHER, SSH_SERVER_FILE_NOT_FOUND
type
ssh_known_hosts_e* {.size: sizeof(cint).} = enum
SSH_KNOWN_HOSTS_ERROR = -2, SSH_KNOWN_HOSTS_NOT_FOUND = -1,
SSH_KNOWN_HOSTS_UNKNOWN = 0, SSH_KNOWN_HOSTS_OK, SSH_KNOWN_HOSTS_CHANGED,
SSH_KNOWN_HOSTS_OTHER
const
MD5_DIGEST_LEN* = 16
type
ssh_error_types_e* {.size: sizeof(cint).} = enum
SSH_NO_ERROR = 0, SSH_REQUEST_DENIED, SSH_FATAL, SSH_EINTR
type
ssh_keytypes_e* {.size: sizeof(cint).} = enum
SSH_KEYTYPE_UNKNOWN = 0, SSH_KEYTYPE_DSS = 1, SSH_KEYTYPE_RSA, SSH_KEYTYPE_RSA1,
SSH_KEYTYPE_ECDSA, SSH_KEYTYPE_ED25519, SSH_KEYTYPE_DSS_CERT01,
SSH_KEYTYPE_RSA_CERT01, SSH_KEYTYPE_ECDSA_P256, SSH_KEYTYPE_ECDSA_P384,
SSH_KEYTYPE_ECDSA_P521, SSH_KEYTYPE_ECDSA_P256_CERT01,
SSH_KEYTYPE_ECDSA_P384_CERT01, SSH_KEYTYPE_ECDSA_P521_CERT01,
SSH_KEYTYPE_ED25519_CERT01
type
ssh_keycmp_e* {.size: sizeof(cint).} = enum
SSH_KEY_CMP_PUBLIC = 0, SSH_KEY_CMP_PRIVATE
const
SSH_ADDRSTRLEN* = 46
type
ssh_knownhosts_entry* {.bycopy.} = object
hostname*: cstring
unparsed*: cstring
publickey*: ssh_key
comment*: cstring
const
SSH_OK* = 0
SSH_ERROR* = -1
SSH_AGAIN* = -2
SSH_EOF* = -127
const
SSH_LOG_NOLOG* = 0
SSH_LOG_WARNING* = 1
SSH_LOG_PROTOCOL* = 2
SSH_LOG_PACKET* = 3
SSH_LOG_FUNCTIONS* = 4
const
SSH_LOG_RARE* = SSH_LOG_WARNING
SSH_LOG_NONE* = 0
SSH_LOG_WARN* = 1
SSH_LOG_INFO* = 2
SSH_LOG_DEBUG* = 3
SSH_LOG_TRACE* = 4
type
ssh_options_e* {.size: sizeof(cint).} = enum
SSH_OPTIONS_HOST, SSH_OPTIONS_PORT, SSH_OPTIONS_PORT_STR, SSH_OPTIONS_FD,
SSH_OPTIONS_USER, SSH_OPTIONS_SSH_DIR, SSH_OPTIONS_IDENTITY,
SSH_OPTIONS_ADD_IDENTITY, SSH_OPTIONS_KNOWNHOSTS, SSH_OPTIONS_TIMEOUT,
SSH_OPTIONS_TIMEOUT_USEC, SSH_OPTIONS_SSH1, SSH_OPTIONS_SSH2,
SSH_OPTIONS_LOG_VERBOSITY, SSH_OPTIONS_LOG_VERBOSITY_STR,
SSH_OPTIONS_CIPHERS_C_S, SSH_OPTIONS_CIPHERS_S_C, SSH_OPTIONS_COMPRESSION_C_S,
SSH_OPTIONS_COMPRESSION_S_C, SSH_OPTIONS_PROXYCOMMAND, SSH_OPTIONS_BINDADDR,
SSH_OPTIONS_STRICTHOSTKEYCHECK, SSH_OPTIONS_COMPRESSION,
SSH_OPTIONS_COMPRESSION_LEVEL, SSH_OPTIONS_KEY_EXCHANGE, SSH_OPTIONS_HOSTKEYS,
SSH_OPTIONS_GSSAPI_SERVER_IDENTITY, SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY,
SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS, SSH_OPTIONS_HMAC_C_S,
SSH_OPTIONS_HMAC_S_C, SSH_OPTIONS_PASSWORD_AUTH, SSH_OPTIONS_PUBKEY_AUTH,
SSH_OPTIONS_KBDINT_AUTH, SSH_OPTIONS_GSSAPI_AUTH,
SSH_OPTIONS_GLOBAL_KNOWNHOSTS, SSH_OPTIONS_NODELAY,
SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES, SSH_OPTIONS_PROCESS_CONFIG,
SSH_OPTIONS_REKEY_DATA, SSH_OPTIONS_REKEY_TIME
const
SSH_SCP_WRITE* = 0
SSH_SCP_READ* = 1
SSH_SCP_RECURSIVE* = 0x00000010
type
ssh_scp_request_types* {.size: sizeof(cint).} = enum
SSH_SCP_REQUEST_NEWDIR = 1, SSH_SCP_REQUEST_NEWFILE, SSH_SCP_REQUEST_EOF,
SSH_SCP_REQUEST_ENDDIR, SSH_SCP_REQUEST_WARNING
type
ssh_connector_flags_e* {.size: sizeof(cint).} = enum
SSH_CONNECTOR_STDOUT = 1, SSH_CONNECTOR_STDERR = 2, SSH_CONNECTOR_BOTH = 3
proc ssh_blocking_flush*(session: ssh_session; timeout: cint): cint {.cdecl,
importc: "ssh_blocking_flush", dynlib: libsshSONAME.}
proc ssh_channel_accept_x11*(channel: ssh_channel; timeout_ms: cint): ssh_channel {.
cdecl, importc: "ssh_channel_accept_x11", dynlib: libsshSONAME.}
proc ssh_channel_change_pty_size*(channel: ssh_channel; cols: cint; rows: cint): cint {.
cdecl, importc: "ssh_channel_change_pty_size", dynlib: libsshSONAME.}
proc ssh_channel_close*(channel: ssh_channel): cint {.cdecl,
importc: "ssh_channel_close", dynlib: libsshSONAME.}
proc ssh_channel_free*(channel: ssh_channel) {.cdecl, importc: "ssh_channel_free",
dynlib: libsshSONAME.}
proc ssh_channel_get_exit_status*(channel: ssh_channel): cint {.cdecl,
importc: "ssh_channel_get_exit_status", dynlib: libsshSONAME.}
proc ssh_channel_get_session*(channel: ssh_channel): ssh_session {.cdecl,
importc: "ssh_channel_get_session", dynlib: libsshSONAME.}
proc ssh_channel_is_closed*(channel: ssh_channel): cint {.cdecl,
importc: "ssh_channel_is_closed", dynlib: libsshSONAME.}
proc ssh_channel_is_eof*(channel: ssh_channel): cint {.cdecl,
importc: "ssh_channel_is_eof", dynlib: libsshSONAME.}
proc ssh_channel_is_open*(channel: ssh_channel): cint {.cdecl,
importc: "ssh_channel_is_open", dynlib: libsshSONAME.}
proc ssh_channel_new*(session: ssh_session): ssh_channel {.cdecl,
importc: "ssh_channel_new", dynlib: libsshSONAME.}
proc ssh_channel_open_auth_agent*(channel: ssh_channel): cint {.cdecl,
importc: "ssh_channel_open_auth_agent", dynlib: libsshSONAME.}
proc ssh_channel_open_forward*(channel: ssh_channel; remotehost: cstring;
remoteport: cint; sourcehost: cstring; localport: cint): cint {.
cdecl, importc: "ssh_channel_open_forward", dynlib: libsshSONAME.}
proc ssh_channel_open_forward_unix*(channel: ssh_channel; remotepath: cstring;
sourcehost: cstring; localport: cint): cint {.
cdecl, importc: "ssh_channel_open_forward_unix", dynlib: libsshSONAME.}
proc ssh_channel_open_session*(channel: ssh_channel): cint {.cdecl,
importc: "ssh_channel_open_session", dynlib: libsshSONAME.}
proc ssh_channel_open_x11*(channel: ssh_channel; orig_addr: cstring; orig_port: cint): cint {.
cdecl, importc: "ssh_channel_open_x11", dynlib: libsshSONAME.}
proc ssh_channel_poll*(channel: ssh_channel; is_stderr: cint): cint {.cdecl,
importc: "ssh_channel_poll", dynlib: libsshSONAME.}
proc ssh_channel_poll_timeout*(channel: ssh_channel; timeout: cint; is_stderr: cint): cint {.
cdecl, importc: "ssh_channel_poll_timeout", dynlib: libsshSONAME.}
proc ssh_channel_read*(channel: ssh_channel; dest: pointer; count: uint32;
is_stderr: cint): cint {.cdecl, importc: "ssh_channel_read",
dynlib: libsshSONAME.}
proc ssh_channel_read_timeout*(channel: ssh_channel; dest: pointer; count: uint32;
is_stderr: cint; timeout_ms: cint): cint {.cdecl,
importc: "ssh_channel_read_timeout", dynlib: libsshSONAME.}
proc ssh_channel_read_nonblocking*(channel: ssh_channel; dest: pointer;
count: uint32; is_stderr: cint): cint {.cdecl,
importc: "ssh_channel_read_nonblocking", dynlib: libsshSONAME.}
proc ssh_channel_request_env*(channel: ssh_channel; name: cstring; value: cstring): cint {.
cdecl, importc: "ssh_channel_request_env", dynlib: libsshSONAME.}
proc ssh_channel_request_exec*(channel: ssh_channel; cmd: cstring): cint {.cdecl,
importc: "ssh_channel_request_exec", dynlib: libsshSONAME.}
proc ssh_channel_request_pty*(channel: ssh_channel): cint {.cdecl,
importc: "ssh_channel_request_pty", dynlib: libsshSONAME.}
proc ssh_channel_request_pty_size*(channel: ssh_channel; term: cstring; cols: cint;
rows: cint): cint {.cdecl,
importc: "ssh_channel_request_pty_size", dynlib: libsshSONAME.}
proc ssh_channel_request_shell*(channel: ssh_channel): cint {.cdecl,
importc: "ssh_channel_request_shell", dynlib: libsshSONAME.}
proc ssh_channel_request_send_signal*(channel: ssh_channel; signum: cstring): cint {.
cdecl, importc: "ssh_channel_request_send_signal", dynlib: libsshSONAME.}
proc ssh_channel_request_send_break*(channel: ssh_channel; length: uint32): cint {.
cdecl, importc: "ssh_channel_request_send_break", dynlib: libsshSONAME.}
proc ssh_channel_request_sftp*(channel: ssh_channel): cint {.cdecl,
importc: "ssh_channel_request_sftp", dynlib: libsshSONAME.}
proc ssh_channel_request_subsystem*(channel: ssh_channel; subsystem: cstring): cint {.
cdecl, importc: "ssh_channel_request_subsystem", dynlib: libsshSONAME.}
proc ssh_channel_request_x11*(channel: ssh_channel; single_connection: cint;
protocol: cstring; cookie: cstring; screen_number: cint): cint {.
cdecl, importc: "ssh_channel_request_x11", dynlib: libsshSONAME.}
proc ssh_channel_request_auth_agent*(channel: ssh_channel): cint {.cdecl,
importc: "ssh_channel_request_auth_agent", dynlib: libsshSONAME.}
proc ssh_channel_send_eof*(channel: ssh_channel): cint {.cdecl,
importc: "ssh_channel_send_eof", dynlib: libsshSONAME.}
proc ssh_channel_select*(readchans: ssh_channel; writechans: ssh_channel;
exceptchans: ssh_channel; timeout: ptr timeval): cint {.
cdecl, importc: "ssh_channel_select", dynlib: libsshSONAME.}
proc ssh_channel_set_blocking*(channel: ssh_channel; blocking: cint) {.cdecl,
importc: "ssh_channel_set_blocking", dynlib: libsshSONAME.}
proc ssh_channel_set_counter*(channel: ssh_channel; counter: ssh_counter) {.cdecl,
importc: "ssh_channel_set_counter", dynlib: libsshSONAME.}
proc ssh_channel_write*(channel: ssh_channel; data: pointer; len: uint32): cint {.
cdecl, importc: "ssh_channel_write", dynlib: libsshSONAME.}
proc ssh_channel_write_stderr*(channel: ssh_channel; data: pointer; len: uint32): cint {.
cdecl, importc: "ssh_channel_write_stderr", dynlib: libsshSONAME.}
proc ssh_channel_window_size*(channel: ssh_channel): uint32 {.cdecl,
importc: "ssh_channel_window_size", dynlib: libsshSONAME.}
proc ssh_basename*(path: cstring): cstring {.cdecl, importc: "ssh_basename",
dynlib: libsshSONAME.}
proc ssh_clean_pubkey_hash*(hash: ptr cstring) {.cdecl,
importc: "ssh_clean_pubkey_hash", dynlib: libsshSONAME.}
proc ssh_connect*(session: ssh_session): cint {.cdecl, importc: "ssh_connect",
dynlib: libsshSONAME.}
proc ssh_connector_new*(session: ssh_session): ssh_connector {.cdecl,
importc: "ssh_connector_new", dynlib: libsshSONAME.}
proc ssh_connector_free*(connector: ssh_connector) {.cdecl,
importc: "ssh_connector_free", dynlib: libsshSONAME.}
proc ssh_connector_set_in_channel*(connector: ssh_connector; channel: ssh_channel;
flags: ssh_connector_flags_e): cint {.cdecl,
importc: "ssh_connector_set_in_channel", dynlib: libsshSONAME.}
proc ssh_connector_set_out_channel*(connector: ssh_connector; channel: ssh_channel;
flags: ssh_connector_flags_e): cint {.cdecl,
importc: "ssh_connector_set_out_channel", dynlib: libsshSONAME.}
proc ssh_connector_set_in_fd*(connector: ssh_connector; fd: socket_t) {.cdecl,
importc: "ssh_connector_set_in_fd", dynlib: libsshSONAME.}
proc ssh_connector_set_out_fd*(connector: ssh_connector; fd: socket_t) {.cdecl,
importc: "ssh_connector_set_out_fd", dynlib: libsshSONAME.}
proc ssh_copyright*(): cstring {.cdecl, importc: "ssh_copyright", dynlib: libsshSONAME.}
proc ssh_disconnect*(session: ssh_session) {.cdecl, importc: "ssh_disconnect",
dynlib: libsshSONAME.}
proc ssh_dirname*(path: cstring): cstring {.cdecl, importc: "ssh_dirname",
dynlib: libsshSONAME.}
proc ssh_finalize*(): cint {.cdecl, importc: "ssh_finalize", dynlib: libsshSONAME.}
proc ssh_channel_accept_forward*(session: ssh_session; timeout_ms: cint;
destination_port: ptr cint): ssh_channel {.cdecl,
importc: "ssh_channel_accept_forward", dynlib: libsshSONAME.}
proc ssh_channel_cancel_forward*(session: ssh_session; address: cstring; port: cint): cint {.
cdecl, importc: "ssh_channel_cancel_forward", dynlib: libsshSONAME.}
proc ssh_channel_listen_forward*(session: ssh_session; address: cstring; port: cint;
bound_port: ptr cint): cint {.cdecl,
importc: "ssh_channel_listen_forward", dynlib: libsshSONAME.}
proc ssh_free*(session: ssh_session) {.cdecl, importc: "ssh_free",
dynlib: libsshSONAME.}
proc ssh_get_disconnect_message*(session: ssh_session): cstring {.cdecl,
importc: "ssh_get_disconnect_message", dynlib: libsshSONAME.}
proc ssh_get_error*(error: pointer): cstring {.cdecl, importc: "ssh_get_error",
dynlib: libsshSONAME.}
proc ssh_get_error_code*(error: pointer): cint {.cdecl,
importc: "ssh_get_error_code", dynlib: libsshSONAME.}
proc ssh_get_fd*(session: ssh_session): socket_t {.cdecl, importc: "ssh_get_fd",
dynlib: libsshSONAME.}
proc ssh_get_hexa*(what: cstring; len: csize): cstring {.cdecl,
importc: "ssh_get_hexa", dynlib: libsshSONAME.}
proc ssh_get_issue_banner*(session: ssh_session): cstring {.cdecl,
importc: "ssh_get_issue_banner", dynlib: libsshSONAME.}
proc ssh_get_openssh_version*(session: ssh_session): cint {.cdecl,
importc: "ssh_get_openssh_version", dynlib: libsshSONAME.}
proc ssh_get_server_publickey*(session: ssh_session; key: ssh_key): cint {.cdecl,
importc: "ssh_get_server_publickey", dynlib: libsshSONAME.}
type
ssh_publickey_hash_type* {.size: sizeof(cint).} = enum
SSH_PUBLICKEY_HASH_SHA1, SSH_PUBLICKEY_HASH_MD5, SSH_PUBLICKEY_HASH_SHA256
proc ssh_get_publickey_hash*(key: ssh_key; `type`: ssh_publickey_hash_type;
hash: ptr cstring; hlen: ptr csize): cint {.cdecl,
importc: "ssh_get_publickey_hash", dynlib: libsshSONAME.}
proc ssh_get_pubkey_hash*(session: ssh_session; hash: ptr cstring): cint {.cdecl,
importc: "ssh_get_pubkey_hash", dynlib: libsshSONAME.}
proc ssh_forward_accept*(session: ssh_session; timeout_ms: cint): ssh_channel {.cdecl,
importc: "ssh_forward_accept", dynlib: libsshSONAME.}
proc ssh_forward_cancel*(session: ssh_session; address: cstring; port: cint): cint {.
cdecl, importc: "ssh_forward_cancel", dynlib: libsshSONAME.}
proc ssh_forward_listen*(session: ssh_session; address: cstring; port: cint;
bound_port: ptr cint): cint {.cdecl,
importc: "ssh_forward_listen", dynlib: libsshSONAME.}
proc ssh_get_publickey*(session: ssh_session; key: ssh_key): cint {.cdecl,
importc: "ssh_get_publickey", dynlib: libsshSONAME.}
proc ssh_write_knownhost*(session: ssh_session): cint {.cdecl,
importc: "ssh_write_knownhost", dynlib: libsshSONAME.}
proc ssh_dump_knownhost*(session: ssh_session): cstring {.cdecl,
importc: "ssh_dump_knownhost", dynlib: libsshSONAME.}
proc ssh_is_server_known*(session: ssh_session): cint {.cdecl,
importc: "ssh_is_server_known", dynlib: libsshSONAME.}
proc ssh_print_hexa*(descr: cstring; what: cstring; len: csize) {.cdecl,
importc: "ssh_print_hexa", dynlib: libsshSONAME.}
proc ssh_get_random*(where: pointer; len: cint; strong: cint): cint {.cdecl,
importc: "ssh_get_random", dynlib: libsshSONAME.}
proc ssh_get_version*(session: ssh_session): cint {.cdecl,
importc: "ssh_get_version", dynlib: libsshSONAME.}
proc ssh_get_status*(session: ssh_session): cint {.cdecl, importc: "ssh_get_status",
dynlib: libsshSONAME.}
proc ssh_get_poll_flags*(session: ssh_session): cint {.cdecl,
importc: "ssh_get_poll_flags", dynlib: libsshSONAME.}
proc ssh_init*(): cint {.cdecl, importc: "ssh_init", dynlib: libsshSONAME.}
proc ssh_is_blocking*(session: ssh_session): cint {.cdecl,
importc: "ssh_is_blocking", dynlib: libsshSONAME.}
proc ssh_is_connected*(session: ssh_session): cint {.cdecl,
importc: "ssh_is_connected", dynlib: libsshSONAME.}
proc ssh_knownhosts_entry_free*(entry: ssh_knownhosts_entry) {.cdecl,
importc: "ssh_knownhosts_entry_free", dynlib: libsshSONAME.}
template SSH_KNOWNHOSTS_ENTRY_FREE*(e: untyped): void =
while true:
if (e) != nil:
ssh_knownhosts_entry_free(e)
e = nil
if not 0:
break
proc ssh_known_hosts_parse_line*(host: cstring; line: cstring;
entry: ptr ssh_knownhosts_entry): cint {.cdecl,
importc: "ssh_known_hosts_parse_line", dynlib: libsshSONAME.}
proc ssh_session_has_known_hosts_entry*(session: ssh_session): ssh_known_hosts_e {.
cdecl, importc: "ssh_session_has_known_hosts_entry", dynlib: libsshSONAME.}
proc ssh_session_export_known_hosts_entry*(session: ssh_session;
pentry_string: cstringArray): cint {.cdecl, importc: "ssh_session_export_known_hosts_entry",
dynlib: libsshSONAME.}
proc ssh_session_update_known_hosts*(session: ssh_session): cint {.cdecl,
importc: "ssh_session_update_known_hosts", dynlib: libsshSONAME.}
proc ssh_session_get_known_hosts_entry*(session: ssh_session;
pentry: ptr ssh_knownhosts_entry): ssh_known_hosts_e {.
cdecl, importc: "ssh_session_get_known_hosts_entry", dynlib: libsshSONAME.}
proc ssh_session_is_known_server*(session: ssh_session): ssh_known_hosts_e {.cdecl,
importc: "ssh_session_is_known_server", dynlib: libsshSONAME.}
proc ssh_set_log_level*(level: cint): cint {.cdecl, importc: "ssh_set_log_level",
dynlib: libsshSONAME.}
proc ssh_get_log_level*(): cint {.cdecl, importc: "ssh_get_log_level",
dynlib: libsshSONAME.}
proc ssh_get_log_userdata*(): pointer {.cdecl, importc: "ssh_get_log_userdata",
dynlib: libsshSONAME.}
proc ssh_set_log_userdata*(data: pointer): cint {.cdecl,
importc: "ssh_set_log_userdata", dynlib: libsshSONAME.}
proc x_ssh_log*(verbosity: cint; function: cstring; format: cstring) {.varargs, cdecl,
importc: "x_ssh_log", dynlib: libsshSONAME.}
proc ssh_log*(session: ssh_session; prioriry: cint; format: cstring) {.varargs, cdecl,
importc: "ssh_log", dynlib: libsshSONAME.}
proc ssh_message_channel_request_open_reply_accept*(msg: ssh_message): ssh_channel {.
cdecl, importc: "ssh_message_channel_request_open_reply_accept",
dynlib: libsshSONAME.}
proc ssh_message_channel_request_open_reply_accept_channel*(msg: ssh_message;
chan: ssh_channel): cint {.cdecl, importc: "ssh_message_channel_request_open_reply_accept_channel",
dynlib: libsshSONAME.}
proc ssh_message_channel_request_reply_success*(msg: ssh_message): cint {.cdecl,
importc: "ssh_message_channel_request_reply_success", dynlib: libsshSONAME.}
template SSH_MESSAGE_FREE*(x: untyped): void =
while true:
if (x) != nil:
ssh_message_free(x)
(x) = nil
if not 0:
break
proc ssh_message_free*(msg: ssh_message) {.cdecl, importc: "ssh_message_free",
dynlib: libsshSONAME.}
proc ssh_message_get*(session: ssh_session): ssh_message {.cdecl,
importc: "ssh_message_get", dynlib: libsshSONAME.}
proc ssh_message_subtype*(msg: ssh_message): cint {.cdecl,
importc: "ssh_message_subtype", dynlib: libsshSONAME.}
proc ssh_message_type*(msg: ssh_message): cint {.cdecl, importc: "ssh_message_type",
dynlib: libsshSONAME.}
proc ssh_mkdir*(pathname: cstring; mode: mode_t): cint {.cdecl, importc: "ssh_mkdir",
dynlib: libsshSONAME.}
proc ssh_new*(): ssh_session {.cdecl, importc: "ssh_new", dynlib: libsshSONAME.}
proc ssh_options_copy*(src: ssh_session; dest: ssh_session): cint {.cdecl,
importc: "ssh_options_copy", dynlib: libsshSONAME.}
proc ssh_options_getopt*(session: ssh_session; argcptr: ptr cint; argv: cstringArray): cint {.
cdecl, importc: "ssh_options_getopt", dynlib: libsshSONAME.}
proc ssh_options_parse_config*(session: ssh_session; filename: cstring): cint {.cdecl,
importc: "ssh_options_parse_config", dynlib: libsshSONAME.}
proc ssh_options_set*(session: ssh_session; `type`: ssh_options_e; value: pointer): cint {.
cdecl, importc: "ssh_options_set", dynlib: libsshSONAME.}
proc ssh_options_get*(session: ssh_session; `type`: ssh_options_e;
value: cstringArray): cint {.cdecl, importc: "ssh_options_get",
dynlib: libsshSONAME.}
proc ssh_options_get_port*(session: ssh_session; port_target: ptr cuint): cint {.cdecl,
importc: "ssh_options_get_port", dynlib: libsshSONAME.}
proc ssh_pcap_file_close*(pcap: ssh_pcap_file): cint {.cdecl,
importc: "ssh_pcap_file_close", dynlib: libsshSONAME.}
proc ssh_pcap_file_free*(pcap: ssh_pcap_file) {.cdecl,
importc: "ssh_pcap_file_free", dynlib: libsshSONAME.}
proc ssh_pcap_file_new*(): ssh_pcap_file {.cdecl, importc: "ssh_pcap_file_new",
dynlib: libsshSONAME.}
proc ssh_pcap_file_open*(pcap: ssh_pcap_file; filename: cstring): cint {.cdecl,
importc: "ssh_pcap_file_open", dynlib: libsshSONAME.}
type
ssh_auth_callback* = proc (prompt: cstring; buf: cstring; len: csize; echo: cint;
verify: cint; userdata: pointer): cint {.cdecl.}
proc ssh_key_new*(): ssh_key {.cdecl, importc: "ssh_key_new", dynlib: libsshSONAME.}
template SSH_KEY_FREE*(x: untyped): void =
while true:
if (x) != nil:
ssh_key_free(x)
x = nil
if not 0:
break
proc ssh_key_free*(key: ssh_key) {.cdecl, importc: "ssh_key_free",
dynlib: libsshSONAME.}
proc ssh_key_type*(key: ssh_key): ssh_keytypes_e {.cdecl, importc: "ssh_key_type",
dynlib: libsshSONAME.}
proc ssh_key_type_to_char*(`type`: ssh_keytypes_e): cstring {.cdecl,
importc: "ssh_key_type_to_char", dynlib: libsshSONAME.}
proc ssh_key_type_from_name*(name: cstring): ssh_keytypes_e {.cdecl,
importc: "ssh_key_type_from_name", dynlib: libsshSONAME.}
proc ssh_key_is_public*(k: ssh_key): cint {.cdecl, importc: "ssh_key_is_public",
dynlib: libsshSONAME.}
proc ssh_key_is_private*(k: ssh_key): cint {.cdecl, importc: "ssh_key_is_private",
dynlib: libsshSONAME.}
proc ssh_key_cmp*(k1: ssh_key; k2: ssh_key; what: ssh_keycmp_e): cint {.cdecl,
importc: "ssh_key_cmp", dynlib: libsshSONAME.}
proc ssh_pki_generate*(`type`: ssh_keytypes_e; parameter: cint; pkey: ssh_key): cint {.
cdecl, importc: "ssh_pki_generate", dynlib: libsshSONAME.}
proc ssh_pki_import_privkey_base64*(b64_key: cstring; passphrase: cstring;
auth_fn: ssh_auth_callback; auth_data: pointer;
pkey: ssh_key): cint {.cdecl,
importc: "ssh_pki_import_privkey_base64", dynlib: libsshSONAME.}
proc ssh_pki_export_privkey_base64*(privkey: ssh_key; passphrase: cstring;
auth_fn: ssh_auth_callback; auth_data: pointer;
b64_key: cstringArray): cint {.cdecl,
importc: "ssh_pki_export_privkey_base64", dynlib: libsshSONAME.}
proc ssh_pki_import_privkey_file*(filename: cstring; passphrase: cstring;
auth_fn: ssh_auth_callback; auth_data: pointer;
pkey: ssh_key): cint {.cdecl,
importc: "ssh_pki_import_privkey_file", dynlib: libsshSONAME.}
proc ssh_pki_export_privkey_file*(privkey: ssh_key; passphrase: cstring;
auth_fn: ssh_auth_callback; auth_data: pointer;
filename: cstring): cint {.cdecl,
importc: "ssh_pki_export_privkey_file", dynlib: libsshSONAME.}
proc ssh_pki_copy_cert_to_privkey*(cert_key: ssh_key; privkey: ssh_key): cint {.cdecl,
importc: "ssh_pki_copy_cert_to_privkey", dynlib: libsshSONAME.}
proc ssh_pki_import_pubkey_base64*(b64_key: cstring; `type`: ssh_keytypes_e;
pkey: ssh_key): cint {.cdecl,
importc: "ssh_pki_import_pubkey_base64", dynlib: libsshSONAME.}
proc ssh_pki_import_pubkey_file*(filename: cstring; pkey: ssh_key): cint {.cdecl,
importc: "ssh_pki_import_pubkey_file", dynlib: libsshSONAME.}
proc ssh_pki_import_cert_base64*(b64_cert: cstring; `type`: ssh_keytypes_e;
pkey: ssh_key): cint {.cdecl,
importc: "ssh_pki_import_cert_base64", dynlib: libsshSONAME.}
proc ssh_pki_import_cert_file*(filename: cstring; pkey: ssh_key): cint {.cdecl,
importc: "ssh_pki_import_cert_file", dynlib: libsshSONAME.}
proc ssh_pki_export_privkey_to_pubkey*(privkey: ssh_key; pkey: ssh_key): cint {.
cdecl, importc: "ssh_pki_export_privkey_to_pubkey", dynlib: libsshSONAME.}
proc ssh_pki_export_pubkey_base64*(key: ssh_key; b64_key: cstringArray): cint {.cdecl,
importc: "ssh_pki_export_pubkey_base64", dynlib: libsshSONAME.}
proc ssh_pki_export_pubkey_file*(key: ssh_key; filename: cstring): cint {.cdecl,
importc: "ssh_pki_export_pubkey_file", dynlib: libsshSONAME.}
proc ssh_pki_key_ecdsa_name*(key: ssh_key): cstring {.cdecl,
importc: "ssh_pki_key_ecdsa_name", dynlib: libsshSONAME.}
proc ssh_get_fingerprint_hash*(`type`: ssh_publickey_hash_type; hash: cstring;
len: csize): cstring {.cdecl,
importc: "ssh_get_fingerprint_hash", dynlib: libsshSONAME.}
proc ssh_print_hash*(`type`: ssh_publickey_hash_type; hash: cstring; len: csize) {.
cdecl, importc: "ssh_print_hash", dynlib: libsshSONAME.}
proc ssh_send_ignore*(session: ssh_session; data: cstring): cint {.cdecl,
importc: "ssh_send_ignore", dynlib: libsshSONAME.}
proc ssh_send_debug*(session: ssh_session; message: cstring; always_display: cint): cint {.
cdecl, importc: "ssh_send_debug", dynlib: libsshSONAME.}
proc ssh_gssapi_set_creds*(session: ssh_session; creds: ssh_gssapi_creds) {.cdecl,
importc: "ssh_gssapi_set_creds", dynlib: libsshSONAME.}
proc ssh_scp_accept_request*(scp: ssh_scp): cint {.cdecl,
importc: "ssh_scp_accept_request", dynlib: libsshSONAME.}
proc ssh_scp_close*(scp: ssh_scp): cint {.cdecl, importc: "ssh_scp_close",
dynlib: libsshSONAME.}
proc ssh_scp_deny_request*(scp: ssh_scp; reason: cstring): cint {.cdecl,
importc: "ssh_scp_deny_request", dynlib: libsshSONAME.}
proc ssh_scp_free*(scp: ssh_scp) {.cdecl, importc: "ssh_scp_free",
dynlib: libsshSONAME.}
proc ssh_scp_init*(scp: ssh_scp): cint {.cdecl, importc: "ssh_scp_init",
dynlib: libsshSONAME.}
proc ssh_scp_leave_directory*(scp: ssh_scp): cint {.cdecl,
importc: "ssh_scp_leave_directory", dynlib: libsshSONAME.}
proc ssh_scp_new*(session: ssh_session; mode: cint; location: cstring): ssh_scp {.cdecl,
importc: "ssh_scp_new", dynlib: libsshSONAME.}
proc ssh_scp_pull_request*(scp: ssh_scp): cint {.cdecl,
importc: "ssh_scp_pull_request", dynlib: libsshSONAME.}
proc ssh_scp_push_directory*(scp: ssh_scp; dirname: cstring; mode: cint): cint {.cdecl,
importc: "ssh_scp_push_directory", dynlib: libsshSONAME.}
proc ssh_scp_push_file*(scp: ssh_scp; filename: cstring; size: csize; perms: cint): cint {.
cdecl, importc: "ssh_scp_push_file", dynlib: libsshSONAME.}
proc ssh_scp_push_file64*(scp: ssh_scp; filename: cstring; size: uint64; perms: cint): cint {.
cdecl, importc: "ssh_scp_push_file64", dynlib: libsshSONAME.}
proc ssh_scp_read*(scp: ssh_scp; buffer: pointer; size: csize): cint {.cdecl,
importc: "ssh_scp_read", dynlib: libsshSONAME.}
proc ssh_scp_request_get_filename*(scp: ssh_scp): cstring {.cdecl,
importc: "ssh_scp_request_get_filename", dynlib: libsshSONAME.}
proc ssh_scp_request_get_permissions*(scp: ssh_scp): cint {.cdecl,
importc: "ssh_scp_request_get_permissions", dynlib: libsshSONAME.}
proc ssh_scp_request_get_size*(scp: ssh_scp): csize {.cdecl,
importc: "ssh_scp_request_get_size", dynlib: libsshSONAME.}
proc ssh_scp_request_get_size64*(scp: ssh_scp): uint64 {.cdecl,
importc: "ssh_scp_request_get_size64", dynlib: libsshSONAME.}
proc ssh_scp_request_get_warning*(scp: ssh_scp): cstring {.cdecl,
importc: "ssh_scp_request_get_warning", dynlib: libsshSONAME.}
proc ssh_scp_write*(scp: ssh_scp; buffer: pointer; len: csize): cint {.cdecl,
importc: "ssh_scp_write", dynlib: libsshSONAME.}
proc ssh_select*(channels: ssh_channel; outchannels: ssh_channel;
maxfd: socket_t; readfds: ptr fd_set; timeout: ptr timeval): cint {.
cdecl, importc: "ssh_select", dynlib: libsshSONAME.}
proc ssh_service_request*(session: ssh_session; service: cstring): cint {.cdecl,
importc: "ssh_service_request", dynlib: libsshSONAME.}
proc ssh_set_agent_channel*(session: ssh_session; channel: ssh_channel): cint {.cdecl,
importc: "ssh_set_agent_channel", dynlib: libsshSONAME.}
proc ssh_set_agent_socket*(session: ssh_session; fd: socket_t): cint {.cdecl,
importc: "ssh_set_agent_socket", dynlib: libsshSONAME.}
proc ssh_set_blocking*(session: ssh_session; blocking: cint) {.cdecl,
importc: "ssh_set_blocking", dynlib: libsshSONAME.}
proc ssh_set_counters*(session: ssh_session; scounter: ssh_counter;
rcounter: ssh_counter) {.cdecl, importc: "ssh_set_counters",
dynlib: libsshSONAME.}
proc ssh_set_fd_except*(session: ssh_session) {.cdecl, importc: "ssh_set_fd_except",
dynlib: libsshSONAME.}
proc ssh_set_fd_toread*(session: ssh_session) {.cdecl, importc: "ssh_set_fd_toread",
dynlib: libsshSONAME.}
proc ssh_set_fd_towrite*(session: ssh_session) {.cdecl,
importc: "ssh_set_fd_towrite", dynlib: libsshSONAME.}
proc ssh_silent_disconnect*(session: ssh_session) {.cdecl,
importc: "ssh_silent_disconnect", dynlib: libsshSONAME.}
proc ssh_set_pcap_file*(session: ssh_session; pcapfile: ssh_pcap_file): cint {.cdecl,
importc: "ssh_set_pcap_file", dynlib: libsshSONAME.}
proc ssh_userauth_none*(session: ssh_session; username: cstring): cint {.cdecl,
importc: "ssh_userauth_none", dynlib: libsshSONAME.}
proc ssh_userauth_list*(session: ssh_session; username: cstring): cint {.cdecl,
importc: "ssh_userauth_list", dynlib: libsshSONAME.}
proc ssh_userauth_try_publickey*(session: ssh_session; username: cstring;
pubkey: ssh_key): cint {.cdecl,
importc: "ssh_userauth_try_publickey", dynlib: libsshSONAME.}
proc ssh_userauth_publickey*(session: ssh_session; username: cstring;
privkey: ssh_key): cint {.cdecl,
importc: "ssh_userauth_publickey", dynlib: libsshSONAME.}
proc ssh_userauth_agent*(session: ssh_session; username: cstring): cint {.cdecl,
importc: "ssh_userauth_agent", dynlib: libsshSONAME.}
proc ssh_userauth_publickey_auto*(session: ssh_session; username: cstring;
passphrase: cstring): cint {.cdecl,
importc: "ssh_userauth_publickey_auto", dynlib: libsshSONAME.}
proc ssh_userauth_password*(session: ssh_session; username: cstring;
password: cstring): cint {.cdecl,
importc: "ssh_userauth_password", dynlib: libsshSONAME.}
proc ssh_userauth_kbdint*(session: ssh_session; user: cstring; submethods: cstring): cint {.
cdecl, importc: "ssh_userauth_kbdint", dynlib: libsshSONAME.}
proc ssh_userauth_kbdint_getinstruction*(session: ssh_session): cstring {.cdecl,
importc: "ssh_userauth_kbdint_getinstruction", dynlib: libsshSONAME.}
proc ssh_userauth_kbdint_getname*(session: ssh_session): cstring {.cdecl,
importc: "ssh_userauth_kbdint_getname", dynlib: libsshSONAME.}
proc ssh_userauth_kbdint_getnprompts*(session: ssh_session): cint {.cdecl,
importc: "ssh_userauth_kbdint_getnprompts", dynlib: libsshSONAME.}
proc ssh_userauth_kbdint_getprompt*(session: ssh_session; i: cuint; echo: cstring): cstring {.
cdecl, importc: "ssh_userauth_kbdint_getprompt", dynlib: libsshSONAME.}
proc ssh_userauth_kbdint_getnanswers*(session: ssh_session): cint {.cdecl,
importc: "ssh_userauth_kbdint_getnanswers", dynlib: libsshSONAME.}
proc ssh_userauth_kbdint_getanswer*(session: ssh_session; i: cuint): cstring {.cdecl,
importc: "ssh_userauth_kbdint_getanswer", dynlib: libsshSONAME.}
proc ssh_userauth_kbdint_setanswer*(session: ssh_session; i: cuint; answer: cstring): cint {.
cdecl, importc: "ssh_userauth_kbdint_setanswer", dynlib: libsshSONAME.}
proc ssh_userauth_gssapi*(session: ssh_session): cint {.cdecl,
importc: "ssh_userauth_gssapi", dynlib: libsshSONAME.}
proc ssh_version*(req_version: cint): cstring {.cdecl, importc: "ssh_version",
dynlib: libsshSONAME.}
proc ssh_string_burn*(str: ssh_string) {.cdecl, importc: "ssh_string_burn",
dynlib: libsshSONAME.}
proc ssh_string_copy*(str: ssh_string): ssh_string {.cdecl,
importc: "ssh_string_copy", dynlib: libsshSONAME.}
proc ssh_string_data*(str: ssh_string): pointer {.cdecl, importc: "ssh_string_data",
dynlib: libsshSONAME.}
proc ssh_string_fill*(str: ssh_string; data: pointer; len: csize): cint {.cdecl,
importc: "ssh_string_fill", dynlib: libsshSONAME.}
template SSH_STRING_FREE*(x: untyped): void =
while true:
if (x) != nil:
ssh_string_free(x)
x = nil
if not 0:
break
proc ssh_string_free*(str: ssh_string) {.cdecl, importc: "ssh_string_free",
dynlib: libsshSONAME.}
proc ssh_string_from_char*(what: cstring): ssh_string {.cdecl,
importc: "ssh_string_from_char", dynlib: libsshSONAME.}
proc ssh_string_len*(str: ssh_string): csize {.cdecl, importc: "ssh_string_len",
dynlib: libsshSONAME.}
proc ssh_string_new*(size: csize): ssh_string {.cdecl, importc: "ssh_string_new",
dynlib: libsshSONAME.}
proc ssh_string_get_char*(str: ssh_string): cstring {.cdecl,
importc: "ssh_string_get_char", dynlib: libsshSONAME.}
proc ssh_string_to_char*(str: ssh_string): cstring {.cdecl,
importc: "ssh_string_to_char", dynlib: libsshSONAME.}
template SSH_STRING_FREE_CHAR*(x: untyped): void =
while true:
if (x) != nil:
ssh_string_free_char(x)
x = nil
if not 0:
break
proc ssh_string_free_char*(s: cstring) {.cdecl, importc: "ssh_string_free_char",
dynlib: libsshSONAME.}
proc ssh_getpass*(prompt: cstring; buf: cstring; len: csize; echo: cint; verify: cint): cint {.
cdecl, importc: "ssh_getpass", dynlib: libsshSONAME.}
type
ssh_event_callback* = proc (fd: socket_t; revents: cint; userdata: pointer): cint {.
cdecl.}
proc ssh_event_new*(): ssh_event {.cdecl, importc: "ssh_event_new",
dynlib: libsshSONAME.}
proc ssh_event_add_fd*(event: ssh_event; fd: socket_t; events: cshort;
cb: ssh_event_callback; userdata: pointer): cint {.cdecl,
importc: "ssh_event_add_fd", dynlib: libsshSONAME.}
proc ssh_event_add_session*(event: ssh_event; session: ssh_session): cint {.cdecl,
importc: "ssh_event_add_session", dynlib: libsshSONAME.}
proc ssh_event_add_connector*(event: ssh_event; connector: ssh_connector): cint {.
cdecl, importc: "ssh_event_add_connector", dynlib: libsshSONAME.}
proc ssh_event_dopoll*(event: ssh_event; timeout: cint): cint {.cdecl,
importc: "ssh_event_dopoll", dynlib: libsshSONAME.}
proc ssh_event_remove_fd*(event: ssh_event; fd: socket_t): cint {.cdecl,
importc: "ssh_event_remove_fd", dynlib: libsshSONAME.}
proc ssh_event_remove_session*(event: ssh_event; session: ssh_session): cint {.cdecl,
importc: "ssh_event_remove_session", dynlib: libsshSONAME.}
proc ssh_event_remove_connector*(event: ssh_event; connector: ssh_connector): cint {.
cdecl, importc: "ssh_event_remove_connector", dynlib: libsshSONAME.}
proc ssh_event_free*(event: ssh_event) {.cdecl, importc: "ssh_event_free",
dynlib: libsshSONAME.}
proc ssh_get_clientbanner*(session: ssh_session): cstring {.cdecl,
importc: "ssh_get_clientbanner", dynlib: libsshSONAME.}
proc ssh_get_serverbanner*(session: ssh_session): cstring {.cdecl,
importc: "ssh_get_serverbanner", dynlib: libsshSONAME.}
proc ssh_get_kex_algo*(session: ssh_session): cstring {.cdecl,
importc: "ssh_get_kex_algo", dynlib: libsshSONAME.}
proc ssh_get_cipher_in*(session: ssh_session): cstring {.cdecl,
importc: "ssh_get_cipher_in", dynlib: libsshSONAME.}
proc ssh_get_cipher_out*(session: ssh_session): cstring {.cdecl,
importc: "ssh_get_cipher_out", dynlib: libsshSONAME.}
proc ssh_get_hmac_in*(session: ssh_session): cstring {.cdecl,
importc: "ssh_get_hmac_in", dynlib: libsshSONAME.}
proc ssh_get_hmac_out*(session: ssh_session): cstring {.cdecl,
importc: "ssh_get_hmac_out", dynlib: libsshSONAME.}
proc ssh_buffer_new*(): ssh_buffer {.cdecl, importc: "ssh_buffer_new",
dynlib: libsshSONAME.}
proc ssh_buffer_free*(buffer: ssh_buffer) {.cdecl, importc: "ssh_buffer_free",
dynlib: libsshSONAME.}
template SSH_BUFFER_FREE*(x: untyped): void =
while true:
if (x) != nil:
ssh_buffer_free(x)
x = nil
if not 0:
break
proc ssh_buffer_reinit*(buffer: ssh_buffer): cint {.cdecl,
importc: "ssh_buffer_reinit", dynlib: libsshSONAME.}
proc ssh_buffer_add_data*(buffer: ssh_buffer; data: pointer; len: uint32): cint {.
cdecl, importc: "ssh_buffer_add_data", dynlib: libsshSONAME.}
proc ssh_buffer_get_data*(buffer: ssh_buffer; data: pointer; requestedlen: uint32): uint32 {.
cdecl, importc: "ssh_buffer_get_data", dynlib: libsshSONAME.}
proc ssh_buffer_get*(buffer: ssh_buffer): pointer {.cdecl, importc: "ssh_buffer_get",
dynlib: libsshSONAME.}
proc ssh_buffer_get_len*(buffer: ssh_buffer): uint32 {.cdecl,
importc: "ssh_buffer_get_len", dynlib: libsshSONAME.}
const
SFTP_H* = true
LIBSFTP_VERSION* = 3
type
sftp_attributes* = ptr sftp_attributes_struct
sftp_client_message* = ptr sftp_client_message_struct
sftp_dir* = ptr sftp_dir_struct
sftp_ext* = ptr sftp_ext_struct
sftp_file* = ptr sftp_file_struct
sftp_message* = ptr sftp_message_struct
sftp_packet* = ptr sftp_packet_struct
sftp_request_queue* = ptr sftp_request_queue_struct
sftp_session* = ptr sftp_session_struct
sftp_status_message* = ptr sftp_status_message_struct
sftp_statvfs_t* = ptr sftp_statvfs_struct
sftp_session_struct* {.bycopy.} = object
session*: ssh_session
channel*: ssh_channel
server_version*: cint
client_version*: cint
version*: cint
queue*: sftp_request_queue
id_counter*: uint32
errnum*: cint
handles*: ptr pointer
ext*: sftp_ext
read_packet*: sftp_packet
sftp_packet_struct* {.bycopy.} = object
sftp*: sftp_session
`type`*: uint8
payload*: ssh_buffer
sftp_file_struct* {.bycopy.} = object
sftp*: sftp_session
name*: cstring
offset*: uint64
handle*: ssh_string
eof*: cint
nonblocking*: cint
sftp_dir_struct* {.bycopy.} = object
sftp*: sftp_session
name*: cstring
handle*: ssh_string
buffer*: ssh_buffer
count*: uint32
eof*: cint
sftp_message_struct* {.bycopy.} = object
sftp*: sftp_session
packet_type*: uint8
payload*: ssh_buffer
id*: uint32
sftp_client_message_struct* {.bycopy.} = object
sftp*: sftp_session
`type`*: uint8
id*: uint32
filename*: cstring
flags*: uint32
attr*: sftp_attributes
handle*: ssh_string
offset*: uint64
len*: uint32
attr_num*: cint
attrbuf*: ssh_buffer
data*: ssh_string
complete_message*: ssh_buffer
str_data*: cstring
submessage*: cstring
sftp_request_queue_struct* {.bycopy.} = object
next*: sftp_request_queue
message*: sftp_message
sftp_status_message_struct* {.bycopy.} = object
id*: uint32
status*: uint32
error_unused*: ssh_string
lang_unused*: ssh_string
errormsg*: cstring
langmsg*: cstring
sftp_attributes_struct* {.bycopy.} = object
name*: cstring
longname*: cstring
flags*: uint32
`type`*: uint8
size*: uint64
uid*: uint32
gid*: uint32
owner*: cstring
group*: cstring
permissions*: uint32
atime64*: uint64
atime*: uint32
atime_nseconds*: uint32
createtime*: uint64
createtime_nseconds*: uint32
mtime64*: uint64
mtime*: uint32
mtime_nseconds*: uint32
acl*: ssh_string
extended_count*: uint32
extended_type*: ssh_string
extended_data*: ssh_string
sftp_statvfs_struct* {.bycopy.} = object
f_bsize*: uint64
f_frsize*: uint64
f_blocks*: uint64
f_bfree*: uint64
f_bavail*: uint64
f_files*: uint64
f_ffree*: uint64
f_favail*: uint64
f_fsid*: uint64
f_flag*: uint64
f_namemax*: uint64
proc sftp_new*(session: ssh_session): sftp_session {.cdecl, importc: "sftp_new",
dynlib: libsshSONAME.}
proc sftp_new_channel*(session: ssh_session; channel: ssh_channel): sftp_session {.
cdecl, importc: "sftp_new_channel", dynlib: libsshSONAME.}
proc sftp_free*(sftp: sftp_session) {.cdecl, importc: "sftp_free",
dynlib: libsshSONAME.}
proc sftp_init*(sftp: sftp_session): cint {.cdecl, importc: "sftp_init",
dynlib: libsshSONAME.}
proc sftp_get_error*(sftp: sftp_session): cint {.cdecl, importc: "sftp_get_error",
dynlib: libsshSONAME.}
proc sftp_extensions_get_count*(sftp: sftp_session): cuint {.cdecl,
importc: "sftp_extensions_get_count", dynlib: libsshSONAME.}
proc sftp_extensions_get_name*(sftp: sftp_session; indexn: cuint): cstring {.cdecl,
importc: "sftp_extensions_get_name", dynlib: libsshSONAME.}
proc sftp_extensions_get_data*(sftp: sftp_session; indexn: cuint): cstring {.cdecl,
importc: "sftp_extensions_get_data", dynlib: libsshSONAME.}
proc sftp_extension_supported*(sftp: sftp_session; name: cstring; data: cstring): cint {.
cdecl, importc: "sftp_extension_supported", dynlib: libsshSONAME.}
proc sftp_opendir*(session: sftp_session; path: cstring): sftp_dir {.cdecl,
importc: "sftp_opendir", dynlib: libsshSONAME.}
proc sftp_readdir*(session: sftp_session; dir: sftp_dir): sftp_attributes {.cdecl,
importc: "sftp_readdir", dynlib: libsshSONAME.}
proc sftp_dir_eof*(dir: sftp_dir): cint {.cdecl, importc: "sftp_dir_eof",
dynlib: libsshSONAME.}
proc sftp_stat*(session: sftp_session; path: cstring): sftp_attributes {.cdecl,
importc: "sftp_stat", dynlib: libsshSONAME.}
proc sftp_lstat*(session: sftp_session; path: cstring): sftp_attributes {.cdecl,
importc: "sftp_lstat", dynlib: libsshSONAME.}
proc sftp_fstat*(file: sftp_file): sftp_attributes {.cdecl, importc: "sftp_fstat",
dynlib: libsshSONAME.}
proc sftp_attributes_free*(file: sftp_attributes) {.cdecl,
importc: "sftp_attributes_free", dynlib: libsshSONAME.}
proc sftp_closedir*(dir: sftp_dir): cint {.cdecl, importc: "sftp_closedir",
dynlib: libsshSONAME.}
proc sftp_close*(file: sftp_file): cint {.cdecl, importc: "sftp_close",
dynlib: libsshSONAME.}
proc sftp_open*(session: sftp_session; file: cstring; accesstype: cint; mode: mode_t): sftp_file {.
cdecl, importc: "sftp_open", dynlib: libsshSONAME.}
proc sftp_file_set_nonblocking*(handle: sftp_file) {.cdecl,
importc: "sftp_file_set_nonblocking", dynlib: libsshSONAME.}
proc sftp_file_set_blocking*(handle: sftp_file) {.cdecl,
importc: "sftp_file_set_blocking", dynlib: libsshSONAME.}
proc sftp_read*(file: sftp_file; buf: pointer; count: csize): ssize_t {.cdecl,
importc: "sftp_read", dynlib: libsshSONAME.}
proc sftp_async_read_begin*(file: sftp_file; len: uint32): cint {.cdecl,
importc: "sftp_async_read_begin", dynlib: libsshSONAME.}
proc sftp_async_read*(file: sftp_file; data: pointer; len: uint32; id: uint32): cint {.
cdecl, importc: "sftp_async_read", dynlib: libsshSONAME.}
proc sftp_write*(file: sftp_file; buf: pointer; count: csize): ssize_t {.cdecl,
importc: "sftp_write", dynlib: libsshSONAME.}
proc sftp_seek*(file: sftp_file; new_offset: uint32): cint {.cdecl,
importc: "sftp_seek", dynlib: libsshSONAME.}
proc sftp_seek64*(file: sftp_file; new_offset: uint64): cint {.cdecl,
importc: "sftp_seek64", dynlib: libsshSONAME.}
proc sftp_tell*(file: sftp_file): culong {.cdecl, importc: "sftp_tell",
dynlib: libsshSONAME.}
proc sftp_tell64*(file: sftp_file): uint64 {.cdecl, importc: "sftp_tell64",
dynlib: libsshSONAME.}
proc sftp_rewind*(file: sftp_file) {.cdecl, importc: "sftp_rewind",
dynlib: libsshSONAME.}
proc sftp_unlink*(sftp: sftp_session; file: cstring): cint {.cdecl,
importc: "sftp_unlink", dynlib: libsshSONAME.}
proc sftp_rmdir*(sftp: sftp_session; directory: cstring): cint {.cdecl,
importc: "sftp_rmdir", dynlib: libsshSONAME.}
proc sftp_mkdir*(sftp: sftp_session; directory: cstring; mode: mode_t): cint {.cdecl,
importc: "sftp_mkdir", dynlib: libsshSONAME.}
proc sftp_rename*(sftp: sftp_session; original: cstring; newname: cstring): cint {.
cdecl, importc: "sftp_rename", dynlib: libsshSONAME.}
proc sftp_setstat*(sftp: sftp_session; file: cstring; attr: sftp_attributes): cint {.
cdecl, importc: "sftp_setstat", dynlib: libsshSONAME.}
proc sftp_chown*(sftp: sftp_session; file: cstring; owner: uid_t; group: gid_t): cint {.
cdecl, importc: "sftp_chown", dynlib: libsshSONAME.}
proc sftp_chmod*(sftp: sftp_session; file: cstring; mode: mode_t): cint {.cdecl,
importc: "sftp_chmod", dynlib: libsshSONAME.}
proc sftp_utimes*(sftp: sftp_session; file: cstring; times: ptr timeval): cint {.cdecl,
importc: "sftp_utimes", dynlib: libsshSONAME.}
proc sftp_symlink*(sftp: sftp_session; target: cstring; dest: cstring): cint {.cdecl,
importc: "sftp_symlink", dynlib: libsshSONAME.}
proc sftp_readlink*(sftp: sftp_session; path: cstring): cstring {.cdecl,
importc: "sftp_readlink", dynlib: libsshSONAME.}
proc sftp_statvfs*(sftp: sftp_session; path: cstring): sftp_statvfs_t {.cdecl,
importc: "sftp_statvfs", dynlib: libsshSONAME.}
proc sftp_fstatvfs*(file: sftp_file): sftp_statvfs_t {.cdecl,
importc: "sftp_fstatvfs", dynlib: libsshSONAME.}
proc sftp_statvfs_free*(statvfs_o: sftp_statvfs_t) {.cdecl,
importc: "sftp_statvfs_free", dynlib: libsshSONAME.}
proc sftp_fsync*(file: sftp_file): cint {.cdecl, importc: "sftp_fsync",
dynlib: libsshSONAME.}
proc sftp_canonicalize_path*(sftp: sftp_session; path: cstring): cstring {.cdecl,
importc: "sftp_canonicalize_path", dynlib: libsshSONAME.}
proc sftp_server_version*(sftp: sftp_session): cint {.cdecl,
importc: "sftp_server_version", dynlib: libsshSONAME.}
const
SFTP_HANDLES* = 256
proc sftp_packet_read*(sftp: sftp_session): sftp_packet {.cdecl,
importc: "sftp_packet_read", dynlib: libsshSONAME.}
proc sftp_packet_write*(sftp: sftp_session; `type`: uint8; payload: ssh_buffer): cint {.
cdecl, importc: "sftp_packet_write", dynlib: libsshSONAME.}
proc sftp_packet_free*(packet: sftp_packet) {.cdecl, importc: "sftp_packet_free",
dynlib: libsshSONAME.}
proc buffer_add_attributes*(buffer: ssh_buffer; attr: sftp_attributes): cint {.cdecl,
importc: "buffer_add_attributes", dynlib: libsshSONAME.}
proc sftp_parse_attr*(session: sftp_session; buf: ssh_buffer; expectname: cint): sftp_attributes {.
cdecl, importc: "sftp_parse_attr", dynlib: libsshSONAME.}
proc sftp_get_client_message*(sftp: sftp_session): sftp_client_message {.cdecl,
importc: "sftp_get_client_message", dynlib: libsshSONAME.}
proc sftp_client_message_free*(msg: sftp_client_message) {.cdecl,
importc: "sftp_client_message_free", dynlib: libsshSONAME.}
proc sftp_client_message_get_type*(msg: sftp_client_message): uint8 {.cdecl,
importc: "sftp_client_message_get_type", dynlib: libsshSONAME.}
proc sftp_client_message_get_filename*(msg: sftp_client_message): cstring {.cdecl,
importc: "sftp_client_message_get_filename", dynlib: libsshSONAME.}