1 #![doc(html_root_url = "http://alexcrichton.com/ssh2-rs")]
3 #![allow(unused_extern_crates)]
9 extern crate openssl_sys
;
12 use libc
::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_void, size_t}
;
14 pub const SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT
: c_int
= 1;
15 pub const SSH_DISCONNECT_PROTOCOL_ERROR
: c_int
= 2;
16 pub const SSH_DISCONNECT_KEY_EXCHANGE_FAILED
: c_int
= 3;
17 pub const SSH_DISCONNECT_RESERVED
: c_int
= 4;
18 pub const SSH_DISCONNECT_MAC_ERROR
: c_int
= 5;
19 pub const SSH_DISCONNECT_COMPRESSION_ERROR
: c_int
= 6;
20 pub const SSH_DISCONNECT_SERVICE_NOT_AVAILABLE
: c_int
= 7;
21 pub const SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED
: c_int
= 8;
22 pub const SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE
: c_int
= 9;
23 pub const SSH_DISCONNECT_CONNECTION_LOST
: c_int
= 10;
24 pub const SSH_DISCONNECT_BY_APPLICATION
: c_int
= 11;
25 pub const SSH_DISCONNECT_TOO_MANY_CONNECTIONS
: c_int
= 12;
26 pub const SSH_DISCONNECT_AUTH_CANCELLED_BY_USER
: c_int
= 13;
27 pub const SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE
: c_int
= 14;
28 pub const SSH_DISCONNECT_ILLEGAL_USER_NAME
: c_int
= 15;
30 pub const LIBSSH2_FLAG_SIGPIPE
: c_int
= 1;
31 pub const LIBSSH2_FLAG_COMPRESS
: c_int
= 2;
33 pub const LIBSSH2_HOSTKEY_TYPE_UNKNOWN
: c_int
= 0;
34 pub const LIBSSH2_HOSTKEY_TYPE_RSA
: c_int
= 1;
35 pub const LIBSSH2_HOSTKEY_TYPE_DSS
: c_int
= 2;
36 pub const LIBSSH2_HOSTKEY_TYPE_ECDSA_256
: c_int
= 3;
37 pub const LIBSSH2_HOSTKEY_TYPE_ECDSA_384
: c_int
= 4;
38 pub const LIBSSH2_HOSTKEY_TYPE_ECDSA_521
: c_int
= 5;
39 pub const LIBSSH2_HOSTKEY_TYPE_ED25519
: c_int
= 6;
41 pub const LIBSSH2_METHOD_KEX
: c_int
= 0;
42 pub const LIBSSH2_METHOD_HOSTKEY
: c_int
= 1;
43 pub const LIBSSH2_METHOD_CRYPT_CS
: c_int
= 2;
44 pub const LIBSSH2_METHOD_CRYPT_SC
: c_int
= 3;
45 pub const LIBSSH2_METHOD_MAC_CS
: c_int
= 4;
46 pub const LIBSSH2_METHOD_MAC_SC
: c_int
= 5;
47 pub const LIBSSH2_METHOD_COMP_CS
: c_int
= 6;
48 pub const LIBSSH2_METHOD_COMP_SC
: c_int
= 7;
49 pub const LIBSSH2_METHOD_LANG_CS
: c_int
= 8;
50 pub const LIBSSH2_METHOD_LANG_SC
: c_int
= 9;
51 pub const LIBSSH2_METHOD_SIGN_ALGO
: c_int
= 10;
53 pub const LIBSSH2_CHANNEL_PACKET_DEFAULT
: c_uint
= 32768;
54 pub const LIBSSH2_CHANNEL_WINDOW_DEFAULT
: c_uint
= 2 * 1024 * 1024;
56 pub const LIBSSH2_ERROR_BANNER_RECV
: c_int
= -2;
57 pub const LIBSSH2_ERROR_BANNER_SEND
: c_int
= -3;
58 pub const LIBSSH2_ERROR_INVALID_MAC
: c_int
= -4;
59 pub const LIBSSH2_ERROR_KEX_FAILURE
: c_int
= -5;
60 pub const LIBSSH2_ERROR_ALLOC
: c_int
= -6;
61 pub const LIBSSH2_ERROR_SOCKET_SEND
: c_int
= -7;
62 pub const LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE
: c_int
= -8;
63 pub const LIBSSH2_ERROR_TIMEOUT
: c_int
= -9;
64 pub const LIBSSH2_ERROR_HOSTKEY_INIT
: c_int
= -10;
65 pub const LIBSSH2_ERROR_HOSTKEY_SIGN
: c_int
= -11;
66 pub const LIBSSH2_ERROR_DECRYPT
: c_int
= -12;
67 pub const LIBSSH2_ERROR_SOCKET_DISCONNECT
: c_int
= -13;
68 pub const LIBSSH2_ERROR_PROTO
: c_int
= -14;
69 pub const LIBSSH2_ERROR_PASSWORD_EXPIRED
: c_int
= -15;
70 pub const LIBSSH2_ERROR_FILE
: c_int
= -16;
71 pub const LIBSSH2_ERROR_METHOD_NONE
: c_int
= -17;
72 pub const LIBSSH2_ERROR_AUTHENTICATION_FAILED
: c_int
= -18;
73 pub const LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED
: c_int
= LIBSSH2_ERROR_AUTHENTICATION_FAILED
;
74 pub const LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED
: c_int
= -19;
75 pub const LIBSSH2_ERROR_CHANNEL_OUTOFORDER
: c_int
= -20;
76 pub const LIBSSH2_ERROR_CHANNEL_FAILURE
: c_int
= -21;
77 pub const LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED
: c_int
= -22;
78 pub const LIBSSH2_ERROR_CHANNEL_UNKNOWN
: c_int
= -23;
79 pub const LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED
: c_int
= -24;
80 pub const LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED
: c_int
= -25;
81 pub const LIBSSH2_ERROR_CHANNEL_CLOSED
: c_int
= -26;
82 pub const LIBSSH2_ERROR_CHANNEL_EOF_SENT
: c_int
= -27;
83 pub const LIBSSH2_ERROR_SCP_PROTOCOL
: c_int
= -28;
84 pub const LIBSSH2_ERROR_ZLIB
: c_int
= -29;
85 pub const LIBSSH2_ERROR_SOCKET_TIMEOUT
: c_int
= -30;
86 pub const LIBSSH2_ERROR_SFTP_PROTOCOL
: c_int
= -31;
87 pub const LIBSSH2_ERROR_REQUEST_DENIED
: c_int
= -32;
88 pub const LIBSSH2_ERROR_METHOD_NOT_SUPPORTED
: c_int
= -33;
89 pub const LIBSSH2_ERROR_INVAL
: c_int
= -34;
90 pub const LIBSSH2_ERROR_INVALID_POLL_TYPE
: c_int
= -35;
91 pub const LIBSSH2_ERROR_PUBLICKEY_PROTOCOL
: c_int
= -36;
92 pub const LIBSSH2_ERROR_EAGAIN
: c_int
= -37;
93 pub const LIBSSH2_ERROR_BUFFER_TOO_SMALL
: c_int
= -38;
94 pub const LIBSSH2_ERROR_BAD_USE
: c_int
= -39;
95 pub const LIBSSH2_ERROR_COMPRESS
: c_int
= -40;
96 pub const LIBSSH2_ERROR_OUT_OF_BOUNDARY
: c_int
= -41;
97 pub const LIBSSH2_ERROR_AGENT_PROTOCOL
: c_int
= -42;
98 pub const LIBSSH2_ERROR_SOCKET_RECV
: c_int
= -43;
99 pub const LIBSSH2_ERROR_ENCRYPT
: c_int
= -44;
100 pub const LIBSSH2_ERROR_BAD_SOCKET
: c_int
= -45;
101 pub const LIBSSH2_ERROR_KNOWN_HOSTS
: c_int
= -46;
102 pub const LIBSSH2_ERROR_CHANNEL_WINDOW_FULL
: c_int
= -47;
103 pub const LIBSSH2_ERROR_KEYFILE_AUTH_FAILED
: c_int
= -48;
104 pub const LIBSSH2_ERROR_RANDGEN
: c_int
= -49;
105 pub const LIBSSH2_ERROR_MISSING_USERAUTH_BANNER
: c_int
= -50;
106 pub const LIBSSH2_ERROR_ALGO_UNSUPPORTED
: c_int
= -51;
108 pub const LIBSSH2_FX_EOF
: c_int
= 1;
109 pub const LIBSSH2_FX_NO_SUCH_FILE
: c_int
= 2;
110 pub const LIBSSH2_FX_PERMISSION_DENIED
: c_int
= 3;
111 pub const LIBSSH2_FX_FAILURE
: c_int
= 4;
112 pub const LIBSSH2_FX_BAD_MESSAGE
: c_int
= 5;
113 pub const LIBSSH2_FX_NO_CONNECTION
: c_int
= 6;
114 pub const LIBSSH2_FX_CONNECTION_LOST
: c_int
= 7;
115 pub const LIBSSH2_FX_OP_UNSUPPORTED
: c_int
= 8;
116 pub const LIBSSH2_FX_INVALID_HANDLE
: c_int
= 9;
117 pub const LIBSSH2_FX_NO_SUCH_PATH
: c_int
= 10;
118 pub const LIBSSH2_FX_FILE_ALREADY_EXISTS
: c_int
= 11;
119 pub const LIBSSH2_FX_WRITE_PROTECT
: c_int
= 12;
120 pub const LIBSSH2_FX_NO_MEDIA
: c_int
= 13;
121 pub const LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM
: c_int
= 14;
122 pub const LIBSSH2_FX_QUOTA_EXCEEDED
: c_int
= 15;
123 pub const LIBSSH2_FX_UNKNOWN_PRINCIPAL
: c_int
= 16;
124 pub const LIBSSH2_FX_LOCK_CONFLICT
: c_int
= 17;
125 pub const LIBSSH2_FX_DIR_NOT_EMPTY
: c_int
= 18;
126 pub const LIBSSH2_FX_NOT_A_DIRECTORY
: c_int
= 19;
127 pub const LIBSSH2_FX_INVALID_FILENAME
: c_int
= 20;
128 pub const LIBSSH2_FX_LINK_LOOP
: c_int
= 21;
130 pub const LIBSSH2_HOSTKEY_HASH_MD5
: c_int
= 1;
131 pub const LIBSSH2_HOSTKEY_HASH_SHA1
: c_int
= 2;
132 pub const LIBSSH2_HOSTKEY_HASH_SHA256
: c_int
= 3;
134 pub const LIBSSH2_KNOWNHOST_FILE_OPENSSH
: c_int
= 1;
136 pub const LIBSSH2_KNOWNHOST_CHECK_MATCH
: c_int
= 0;
137 pub const LIBSSH2_KNOWNHOST_CHECK_MISMATCH
: c_int
= 1;
138 pub const LIBSSH2_KNOWNHOST_CHECK_NOTFOUND
: c_int
= 2;
139 pub const LIBSSH2_KNOWNHOST_CHECK_FAILURE
: c_int
= 3;
141 pub const LIBSSH2_KNOWNHOST_TYPE_PLAIN
: c_int
= 1;
142 pub const LIBSSH2_KNOWNHOST_TYPE_SHA1
: c_int
= 2;
143 pub const LIBSSH2_KNOWNHOST_TYPE_CUSTOM
: c_int
= 3;
144 pub const LIBSSH2_KNOWNHOST_KEYENC_RAW
: c_int
= 1 << 16;
145 pub const LIBSSH2_KNOWNHOST_KEYENC_BASE64
: c_int
= 2 << 16;
146 pub const LIBSSH2_KNOWNHOST_KEY_RSA1
: c_int
= 1 << 18;
147 pub const LIBSSH2_KNOWNHOST_KEY_SSHRSA
: c_int
= 2 << 18;
148 pub const LIBSSH2_KNOWNHOST_KEY_SSHDSS
: c_int
= 3 << 18;
149 pub const LIBSSH2_KNOWNHOST_KEY_ECDSA_256
: c_int
= 4 << 18;
150 pub const LIBSSH2_KNOWNHOST_KEY_ECDSA_384
: c_int
= 5 << 18;
151 pub const LIBSSH2_KNOWNHOST_KEY_ECDSA_521
: c_int
= 6 << 18;
152 pub const LIBSSH2_KNOWNHOST_KEY_ED25519
: c_int
= 7 << 18;
153 pub const LIBSSH2_KNOWNHOST_KEY_UNKNOWN
: c_int
= 15 << 18;
155 pub const LIBSSH2_FXF_READ
: c_ulong
= 0x00000001;
156 pub const LIBSSH2_FXF_WRITE
: c_ulong
= 0x00000002;
157 pub const LIBSSH2_FXF_APPEND
: c_ulong
= 0x00000004;
158 pub const LIBSSH2_FXF_CREAT
: c_ulong
= 0x00000008;
159 pub const LIBSSH2_FXF_TRUNC
: c_ulong
= 0x00000010;
160 pub const LIBSSH2_FXF_EXCL
: c_ulong
= 0x00000020;
162 pub const LIBSSH2_SFTP_OPENFILE
: c_int
= 0;
163 pub const LIBSSH2_SFTP_OPENDIR
: c_int
= 1;
165 pub const LIBSSH2_SFTP_ATTR_SIZE
: c_ulong
= 0x00000001;
166 pub const LIBSSH2_SFTP_ATTR_UIDGID
: c_ulong
= 0x00000002;
167 pub const LIBSSH2_SFTP_ATTR_PERMISSIONS
: c_ulong
= 0x00000004;
168 pub const LIBSSH2_SFTP_ATTR_ACMODTIME
: c_ulong
= 0x00000008;
169 pub const LIBSSH2_SFTP_ATTR_EXTENDED
: c_ulong
= 0x80000000;
171 pub const LIBSSH2_SFTP_STAT
: c_int
= 0;
172 pub const LIBSSH2_SFTP_LSTAT
: c_int
= 1;
173 pub const LIBSSH2_SFTP_SETSTAT
: c_int
= 2;
175 pub const LIBSSH2_SFTP_SYMLINK
: c_int
= 0;
176 pub const LIBSSH2_SFTP_READLINK
: c_int
= 1;
177 pub const LIBSSH2_SFTP_REALPATH
: c_int
= 2;
179 pub const LIBSSH2_SFTP_RENAME_OVERWRITE
: c_long
= 0x1;
180 pub const LIBSSH2_SFTP_RENAME_ATOMIC
: c_long
= 0x2;
181 pub const LIBSSH2_SFTP_RENAME_NATIVE
: c_long
= 0x4;
183 pub const LIBSSH2_INIT_NO_CRYPTO
: c_int
= 0x1;
185 pub const LIBSSH2_SFTP_S_IFMT
: c_ulong
= 0o170000;
186 pub const LIBSSH2_SFTP_S_IFIFO
: c_ulong
= 0o010000;
187 pub const LIBSSH2_SFTP_S_IFCHR
: c_ulong
= 0o020000;
188 pub const LIBSSH2_SFTP_S_IFDIR
: c_ulong
= 0o040000;
189 pub const LIBSSH2_SFTP_S_IFBLK
: c_ulong
= 0o060000;
190 pub const LIBSSH2_SFTP_S_IFREG
: c_ulong
= 0o100000;
191 pub const LIBSSH2_SFTP_S_IFLNK
: c_ulong
= 0o120000;
192 pub const LIBSSH2_SFTP_S_IFSOCK
: c_ulong
= 0o140000;
194 pub const LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL
: c_int
= 0;
195 pub const LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE
: c_int
= 1;
196 pub const LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE
: c_int
= 2;
198 pub const LIBSSH2_SESSION_BLOCK_INBOUND
: c_int
= 1;
199 pub const LIBSSH2_SESSION_BLOCK_OUTBOUND
: c_int
= 2;
201 pub const LIBSSH2_TRACE_TRANS
: c_int
= 1<<1;
202 pub const LIBSSH2_TRACE_KEX
: c_int
= 1<<2;
203 pub const LIBSSH2_TRACE_AUTH
: c_int
= 1<<3;
204 pub const LIBSSH2_TRACE_CONN
: c_int
= 1<<4;
205 pub const LIBSSH2_TRACE_SCP
: c_int
= 1<<5;
206 pub const LIBSSH2_TRACE_SFTP
: c_int
= 1<<6;
207 pub const LIBSSH2_TRACE_ERROR
: c_int
= 1<<7;
208 pub const LIBSSH2_TRACE_PUBLICKEY
: c_int
= 1<<8;
209 pub const LIBSSH2_TRACE_SOCKET
: c_int
= 1<<9;
210 pub enum LIBSSH2_SESSION {}
211 pub enum LIBSSH2_AGENT {}
212 pub enum LIBSSH2_CHANNEL {}
213 pub enum LIBSSH2_LISTENER {}
214 pub enum LIBSSH2_KNOWNHOSTS {}
215 pub enum LIBSSH2_SFTP {}
216 pub enum LIBSSH2_SFTP_HANDLE {}
218 pub type libssh2_int64_t
= i64;
219 pub type libssh2_uint64_t
= u64;
221 // libssh2_struct_stat is a typedef for libc::stat on all platforms, however,
222 // Windows has a bunch of legacy around struct stat that makes things more
223 // complicated to validate with systest.
224 // The most reasonable looking solution to this is a newtype that derefs
226 // We cannot use `pub struct libssh2_struct_stat(pub libc::stat)` because
227 // that triggers a `no tuple structs in FFI` error.
229 pub struct libssh2_struct_stat(libc
::stat
);
231 impl std
::ops
::Deref
for libssh2_struct_stat
{
232 type Target
= libc
::stat
;
234 fn deref(&self) -> &Self::Target
{
240 pub struct libssh2_agent_publickey
{
242 pub node
: *mut c_void
,
243 pub blob
: *mut c_uchar
,
244 pub blob_len
: size_t
,
245 pub comment
: *mut c_char
,
249 pub struct libssh2_knownhost
{
251 pub node
: *mut c_void
,
252 pub name
: *mut c_char
,
253 pub key
: *mut c_char
,
258 #[derive(Copy, Clone)]
259 pub struct LIBSSH2_SFTP_ATTRIBUTES
{
261 pub filesize
: libssh2_uint64_t
,
264 pub permissions
: c_ulong
,
270 #[derive(Copy, Clone)]
271 pub struct LIBSSH2_SFTP_STATVFS
{
272 pub f_bsize
: libssh2_uint64_t
,
273 pub f_frsize
: libssh2_uint64_t
,
274 pub f_blocks
: libssh2_uint64_t
,
275 pub f_bfree
: libssh2_uint64_t
,
276 pub f_bavail
: libssh2_uint64_t
,
277 pub f_files
: libssh2_uint64_t
,
278 pub f_ffree
: libssh2_uint64_t
,
279 pub f_favail
: libssh2_uint64_t
,
280 pub f_fsid
: libssh2_uint64_t
,
281 pub f_flag
: libssh2_uint64_t
,
282 pub f_namemax
: libssh2_uint64_t
,
285 pub type LIBSSH2_ALLOC_FUNC
= extern "C" fn(size_t
, *mut *mut c_void
) -> *mut c_void
;
286 pub type LIBSSH2_FREE_FUNC
= extern "C" fn(*mut c_void
, *mut *mut c_void
);
287 pub type LIBSSH2_REALLOC_FUNC
= extern "C" fn(*mut c_void
, size_t
, *mut *mut c_void
) -> *mut c_void
;
288 pub type LIBSSH2_PASSWD_CHANGEREQ_FUNC
= extern "C" fn(
289 sess
: *mut LIBSSH2_SESSION
,
290 newpw
: *mut *mut c_char
,
291 newpw_len
: *mut c_int
,
292 abstrakt
: *mut *mut c_void
,
295 pub type LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC
= extern "C" fn(
296 username
: *const c_char
,
298 instruction
: *const c_char
,
299 instruction_len
: c_int
,
301 prompts
: *const LIBSSH2_USERAUTH_KBDINT_PROMPT
,
302 responses
: *mut LIBSSH2_USERAUTH_KBDINT_RESPONSE
,
303 abstrakt
: *mut *mut c_void
,
307 pub struct LIBSSH2_USERAUTH_KBDINT_PROMPT
{
308 pub text
: *mut c_uchar
,
314 pub struct LIBSSH2_USERAUTH_KBDINT_RESPONSE
{
315 pub text
: *mut c_char
,
320 pub type libssh2_socket_t
= c_int
;
321 #[cfg(all(windows, target_pointer_width = "32"))]
322 pub type libssh2_socket_t
= u32;
323 #[cfg(all(windows, target_pointer_width = "64"))]
324 pub type libssh2_socket_t
= u64;
328 pub fn libssh2_init(flag
: c_int
) -> c_int
;
329 pub fn libssh2_exit();
330 pub fn libssh2_free(sess
: *mut LIBSSH2_SESSION
, ptr
: *mut c_void
);
331 pub fn libssh2_hostkey_hash(session
: *mut LIBSSH2_SESSION
, hash_type
: c_int
) -> *const c_char
;
332 pub fn libssh2_trace(session
: *mut LIBSSH2_SESSION
, bitmask
: c_int
) -> c_int
;
335 pub fn libssh2_session_init_ex(
336 alloc
: Option
<LIBSSH2_ALLOC_FUNC
>,
337 free
: Option
<LIBSSH2_FREE_FUNC
>,
338 realloc
: Option
<LIBSSH2_REALLOC_FUNC
>,
339 abstrakt
: *mut c_void
,
340 ) -> *mut LIBSSH2_SESSION
;
341 pub fn libssh2_session_abstract(session
: *mut LIBSSH2_SESSION
) -> *mut *mut c_void
;
342 pub fn libssh2_session_free(sess
: *mut LIBSSH2_SESSION
) -> c_int
;
343 pub fn libssh2_session_banner_get(sess
: *mut LIBSSH2_SESSION
) -> *const c_char
;
344 pub fn libssh2_session_banner_set(sess
: *mut LIBSSH2_SESSION
, banner
: *const c_char
) -> c_int
;
345 pub fn libssh2_session_disconnect_ex(
346 sess
: *mut LIBSSH2_SESSION
,
348 description
: *const c_char
,
351 pub fn libssh2_session_flag(sess
: *mut LIBSSH2_SESSION
, flag
: c_int
, value
: c_int
) -> c_int
;
352 pub fn libssh2_session_get_blocking(session
: *mut LIBSSH2_SESSION
) -> c_int
;
353 pub fn libssh2_session_get_timeout(sess
: *mut LIBSSH2_SESSION
) -> c_long
;
354 pub fn libssh2_session_hostkey(
355 sess
: *mut LIBSSH2_SESSION
,
359 pub fn libssh2_session_method_pref(
360 sess
: *mut LIBSSH2_SESSION
,
362 prefs
: *const c_char
,
364 pub fn libssh2_session_methods(sess
: *mut LIBSSH2_SESSION
, method_type
: c_int
)
366 pub fn libssh2_session_set_blocking(session
: *mut LIBSSH2_SESSION
, blocking
: c_int
);
367 pub fn libssh2_session_set_timeout(session
: *mut LIBSSH2_SESSION
, timeout
: c_long
);
368 pub fn libssh2_session_supported_algs(
369 session
: *mut LIBSSH2_SESSION
,
371 algs
: *mut *mut *const c_char
,
373 pub fn libssh2_session_last_errno(sess
: *mut LIBSSH2_SESSION
) -> c_int
;
374 pub fn libssh2_session_last_error(
375 sess
: *mut LIBSSH2_SESSION
,
376 msg
: *mut *mut c_char
,
380 pub fn libssh2_session_handshake(sess
: *mut LIBSSH2_SESSION
, socket
: libssh2_socket_t
)
382 pub fn libssh2_keepalive_config(
383 sess
: *mut LIBSSH2_SESSION
,
387 pub fn libssh2_keepalive_send(sess
: *mut LIBSSH2_SESSION
, seconds_to_next
: *mut c_int
)
389 pub fn libssh2_session_block_directions(sess
: *mut LIBSSH2_SESSION
) -> c_int
;
392 pub fn libssh2_agent_init(sess
: *mut LIBSSH2_SESSION
) -> *mut LIBSSH2_AGENT
;
393 pub fn libssh2_agent_free(agent
: *mut LIBSSH2_AGENT
);
394 pub fn libssh2_agent_connect(agent
: *mut LIBSSH2_AGENT
) -> c_int
;
395 pub fn libssh2_agent_disconnect(agent
: *mut LIBSSH2_AGENT
) -> c_int
;
396 pub fn libssh2_agent_list_identities(agent
: *mut LIBSSH2_AGENT
) -> c_int
;
397 pub fn libssh2_agent_get_identity(
398 agent
: *mut LIBSSH2_AGENT
,
399 store
: *mut *mut libssh2_agent_publickey
,
400 prev
: *mut libssh2_agent_publickey
,
402 pub fn libssh2_agent_userauth(
403 agent
: *mut LIBSSH2_AGENT
,
404 username
: *const c_char
,
405 identity
: *mut libssh2_agent_publickey
,
409 pub fn libssh2_channel_free(chan
: *mut LIBSSH2_CHANNEL
) -> c_int
;
410 pub fn libssh2_channel_close(chan
: *mut LIBSSH2_CHANNEL
) -> c_int
;
411 pub fn libssh2_channel_wait_closed(chan
: *mut LIBSSH2_CHANNEL
) -> c_int
;
412 pub fn libssh2_channel_wait_eof(chan
: *mut LIBSSH2_CHANNEL
) -> c_int
;
413 pub fn libssh2_channel_eof(chan
: *mut LIBSSH2_CHANNEL
) -> c_int
;
414 pub fn libssh2_channel_process_startup(
415 chan
: *mut LIBSSH2_CHANNEL
,
421 pub fn libssh2_channel_flush_ex(chan
: *mut LIBSSH2_CHANNEL
, streamid
: c_int
) -> c_int
;
422 pub fn libssh2_channel_write_ex(
423 chan
: *mut LIBSSH2_CHANNEL
,
428 pub fn libssh2_channel_get_exit_signal(
429 chan
: *mut LIBSSH2_CHANNEL
,
430 exitsignal
: *mut *mut c_char
,
431 exitsignal_len
: *mut size_t
,
432 errmsg
: *mut *mut c_char
,
433 errmsg_len
: *mut size_t
,
434 langtag
: *mut *mut c_char
,
435 langtag_len
: *mut size_t
,
437 pub fn libssh2_channel_get_exit_status(chan
: *mut LIBSSH2_CHANNEL
) -> c_int
;
438 pub fn libssh2_channel_open_ex(
439 sess
: *mut LIBSSH2_SESSION
,
440 channel_type
: *const c_char
,
441 channel_type_len
: c_uint
,
444 message
: *const c_char
,
446 ) -> *mut LIBSSH2_CHANNEL
;
447 pub fn libssh2_channel_read_ex(
448 chan
: *mut LIBSSH2_CHANNEL
,
453 pub fn libssh2_channel_setenv_ex(
454 chan
: *mut LIBSSH2_CHANNEL
,
460 pub fn libssh2_channel_send_eof(chan
: *mut LIBSSH2_CHANNEL
) -> c_int
;
461 pub fn libssh2_channel_request_pty_ex(
462 chan
: *mut LIBSSH2_CHANNEL
,
465 modes
: *const c_char
,
472 pub fn libssh2_channel_request_pty_size_ex(
473 chan
: *mut LIBSSH2_CHANNEL
,
479 pub fn libssh2_channel_window_read_ex(
480 chan
: *mut LIBSSH2_CHANNEL
,
481 read_avail
: *mut c_ulong
,
482 window_size_initial
: *mut c_ulong
,
484 pub fn libssh2_channel_window_write_ex(
485 chan
: *mut LIBSSH2_CHANNEL
,
486 window_size_initial
: *mut c_ulong
,
488 pub fn libssh2_channel_receive_window_adjust2(
489 chan
: *mut LIBSSH2_CHANNEL
,
494 pub fn libssh2_channel_direct_tcpip_ex(
495 ses
: *mut LIBSSH2_SESSION
,
498 shost
: *const c_char
,
500 ) -> *mut LIBSSH2_CHANNEL
;
501 pub fn libssh2_channel_forward_accept(listener
: *mut LIBSSH2_LISTENER
) -> *mut LIBSSH2_CHANNEL
;
502 pub fn libssh2_channel_forward_cancel(listener
: *mut LIBSSH2_LISTENER
) -> c_int
;
503 pub fn libssh2_channel_forward_listen_ex(
504 sess
: *mut LIBSSH2_SESSION
,
507 bound_port
: *mut c_int
,
508 queue_maxsize
: c_int
,
509 ) -> *mut LIBSSH2_LISTENER
;
510 pub fn libssh2_channel_handle_extended_data2(
511 channel
: *mut LIBSSH2_CHANNEL
,
514 pub fn libssh2_channel_request_auth_agent(channel
: *mut LIBSSH2_CHANNEL
) -> c_int
;
517 pub fn libssh2_userauth_banner(sess
: *mut LIBSSH2_SESSION
, banner
: *mut *mut c_char
) -> c_int
;
518 pub fn libssh2_userauth_authenticated(sess
: *mut LIBSSH2_SESSION
) -> c_int
;
519 pub fn libssh2_userauth_list(
520 sess
: *mut LIBSSH2_SESSION
,
521 username
: *const c_char
,
522 username_len
: c_uint
,
524 pub fn libssh2_userauth_hostbased_fromfile_ex(
525 sess
: *mut LIBSSH2_SESSION
,
526 username
: *const c_char
,
527 username_len
: c_uint
,
528 publickey
: *const c_char
,
529 privatekey
: *const c_char
,
530 passphrase
: *const c_char
,
531 hostname
: *const c_char
,
532 hostname_len
: c_uint
,
533 local_username
: *const c_char
,
536 pub fn libssh2_userauth_publickey_fromfile_ex(
537 sess
: *mut LIBSSH2_SESSION
,
538 username
: *const c_char
,
539 username_len
: c_uint
,
540 publickey
: *const c_char
,
541 privatekey
: *const c_char
,
542 passphrase
: *const c_char
,
544 pub fn libssh2_userauth_publickey_frommemory(
545 sess
: *mut LIBSSH2_SESSION
,
546 username
: *const c_char
,
547 username_len
: size_t
,
548 publickeydata
: *const c_char
,
549 publickeydata_len
: size_t
,
550 privatekeydata
: *const c_char
,
551 privatekeydata_len
: size_t
,
552 passphrase
: *const c_char
,
554 pub fn libssh2_userauth_password_ex(
555 session
: *mut LIBSSH2_SESSION
,
556 username
: *const c_char
,
557 username_len
: c_uint
,
558 password
: *const c_char
,
559 password_len
: c_uint
,
560 password_change_cb
: Option
<LIBSSH2_PASSWD_CHANGEREQ_FUNC
>,
562 pub fn libssh2_userauth_keyboard_interactive_ex(
563 session
: *mut LIBSSH2_SESSION
,
564 username
: *const c_char
,
565 username_len
: c_uint
,
566 callback
: Option
<LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC
>,
570 pub fn libssh2_knownhost_free(hosts
: *mut LIBSSH2_KNOWNHOSTS
);
571 pub fn libssh2_knownhost_addc(
572 hosts
: *mut LIBSSH2_KNOWNHOSTS
,
577 comment
: *const c_char
,
580 store
: *mut *mut libssh2_knownhost
,
582 pub fn libssh2_knownhost_check(
583 hosts
: *mut LIBSSH2_KNOWNHOSTS
,
588 knownhost
: *mut *mut libssh2_knownhost
,
590 pub fn libssh2_knownhost_checkp(
591 hosts
: *mut LIBSSH2_KNOWNHOSTS
,
597 knownhost
: *mut *mut libssh2_knownhost
,
599 pub fn libssh2_knownhost_del(
600 hosts
: *mut LIBSSH2_KNOWNHOSTS
,
601 entry
: *mut libssh2_knownhost
,
603 pub fn libssh2_knownhost_get(
604 hosts
: *mut LIBSSH2_KNOWNHOSTS
,
605 store
: *mut *mut libssh2_knownhost
,
606 prev
: *mut libssh2_knownhost
,
608 pub fn libssh2_knownhost_readfile(
609 hosts
: *mut LIBSSH2_KNOWNHOSTS
,
610 filename
: *const c_char
,
613 pub fn libssh2_knownhost_readline(
614 hosts
: *mut LIBSSH2_KNOWNHOSTS
,
619 pub fn libssh2_knownhost_writefile(
620 hosts
: *mut LIBSSH2_KNOWNHOSTS
,
621 filename
: *const c_char
,
624 pub fn libssh2_knownhost_writeline(
625 hosts
: *mut LIBSSH2_KNOWNHOSTS
,
626 known
: *mut libssh2_knownhost
,
632 pub fn libssh2_knownhost_init(sess
: *mut LIBSSH2_SESSION
) -> *mut LIBSSH2_KNOWNHOSTS
;
635 #[deprecated(note = "dangerously unsafe on windows, use libssh2_scp_recv2 instead")]
636 pub fn libssh2_scp_recv(
637 sess
: *mut LIBSSH2_SESSION
,
640 ) -> *mut LIBSSH2_CHANNEL
;
642 pub fn libssh2_scp_recv2(
643 sess
: *mut LIBSSH2_SESSION
,
645 sb
: *mut libssh2_struct_stat
,
646 ) -> *mut LIBSSH2_CHANNEL
;
648 pub fn libssh2_scp_send64(
649 sess
: *mut LIBSSH2_SESSION
,
652 size
: libssh2_int64_t
,
655 ) -> *mut LIBSSH2_CHANNEL
;
658 pub fn libssh2_sftp_init(sess
: *mut LIBSSH2_SESSION
) -> *mut LIBSSH2_SFTP
;
659 pub fn libssh2_sftp_shutdown(sftp
: *mut LIBSSH2_SFTP
) -> c_int
;
660 pub fn libssh2_sftp_last_error(sftp
: *mut LIBSSH2_SFTP
) -> c_ulong
;
661 pub fn libssh2_sftp_open_ex(
662 sftp
: *mut LIBSSH2_SFTP
,
663 filename
: *const c_char
,
664 filename_len
: c_uint
,
668 ) -> *mut LIBSSH2_SFTP_HANDLE
;
669 pub fn libssh2_sftp_close_handle(handle
: *mut LIBSSH2_SFTP_HANDLE
) -> c_int
;
670 pub fn libssh2_sftp_mkdir_ex(
671 sftp
: *mut LIBSSH2_SFTP
,
676 pub fn libssh2_sftp_fsync(handle
: *mut LIBSSH2_SFTP_HANDLE
) -> c_int
;
677 pub fn libssh2_sftp_fstat_ex(
678 handle
: *mut LIBSSH2_SFTP_HANDLE
,
679 attrs
: *mut LIBSSH2_SFTP_ATTRIBUTES
,
682 pub fn libssh2_sftp_fstatvfs(
683 handle
: *mut LIBSSH2_SFTP_HANDLE
,
684 attrs
: *mut LIBSSH2_SFTP_STATVFS
,
686 pub fn libssh2_sftp_stat_ex(
687 sftp
: *mut LIBSSH2_SFTP
,
691 attrs
: *mut LIBSSH2_SFTP_ATTRIBUTES
,
693 pub fn libssh2_sftp_read(
694 handle
: *mut LIBSSH2_SFTP_HANDLE
,
698 pub fn libssh2_sftp_symlink_ex(
699 sftp
: *mut LIBSSH2_SFTP
,
706 pub fn libssh2_sftp_rename_ex(
707 sftp
: *mut LIBSSH2_SFTP
,
714 pub fn libssh2_sftp_rmdir_ex(
715 sftp
: *mut LIBSSH2_SFTP
,
719 pub fn libssh2_sftp_write(
720 handle
: *mut LIBSSH2_SFTP_HANDLE
,
721 buffer
: *const c_char
,
724 pub fn libssh2_sftp_tell64(handle
: *mut LIBSSH2_SFTP_HANDLE
) -> libssh2_uint64_t
;
725 pub fn libssh2_sftp_seek64(handle
: *mut LIBSSH2_SFTP_HANDLE
, off
: libssh2_uint64_t
);
726 pub fn libssh2_sftp_readdir_ex(
727 handle
: *mut LIBSSH2_SFTP_HANDLE
,
730 longentry
: *mut c_char
,
731 longentry_len
: size_t
,
732 attrs
: *mut LIBSSH2_SFTP_ATTRIBUTES
,
734 pub fn libssh2_sftp_unlink_ex(
735 sftp
: *mut LIBSSH2_SFTP
,
736 filename
: *const c_char
,
737 filename_len
: c_uint
,
743 unsafe { libssh2_init(0) }
;
747 pub fn issue_14344_workaround() {}
752 static INIT
: Once
= Once
::new();
753 INIT
.call_once(|| unsafe {
755 assert_eq
!(libc
::atexit(shutdown
), 0);
757 extern "C" fn shutdown() {
764 unsafe fn platform_init() {
765 // On Unix we want to funnel through openssl_sys to initialize OpenSSL,
766 // so be sure to tell libssh2 to not do its own thing as we've already
769 assert_eq
!(libssh2_init(LIBSSH2_INIT_NO_CRYPTO
), 0);
773 unsafe fn platform_init() {
774 // On Windows we want to be sure to tell libssh2 to initialize
775 // everything, as we're not managing crypto elsewhere ourselves. Also to
776 // fix alexcrichton/git2-rs#202
777 assert_eq
!(libssh2_init(0), 0);