1 #![doc(html_root_url = "http://alexcrichton.com/ssh2-rs")]
2 #![allow(bad_style)]
3 #![allow(unused_extern_crates)]
4 
5 extern crate libc;
6 
7 extern crate libz_sys;
8 #[cfg(unix)]
9 extern crate openssl_sys;
10 
11 use libc::ssize_t;
12 use libc::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_void, size_t};
13 
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;
29 
30 pub const LIBSSH2_FLAG_SIGPIPE: c_int = 1;
31 pub const LIBSSH2_FLAG_COMPRESS: c_int = 2;
32 
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;
40 
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 
52 pub const LIBSSH2_CHANNEL_PACKET_DEFAULT: c_uint = 32768;
53 pub const LIBSSH2_CHANNEL_WINDOW_DEFAULT: c_uint = 2 * 1024 * 1024;
54 
55 pub const LIBSSH2_ERROR_BANNER_RECV: c_int = -2;
56 pub const LIBSSH2_ERROR_BANNER_SEND: c_int = -3;
57 pub const LIBSSH2_ERROR_INVALID_MAC: c_int = -4;
58 pub const LIBSSH2_ERROR_KEX_FAILURE: c_int = -5;
59 pub const LIBSSH2_ERROR_ALLOC: c_int = -6;
60 pub const LIBSSH2_ERROR_SOCKET_SEND: c_int = -7;
61 pub const LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE: c_int = -8;
62 pub const LIBSSH2_ERROR_TIMEOUT: c_int = -9;
63 pub const LIBSSH2_ERROR_HOSTKEY_INIT: c_int = -10;
64 pub const LIBSSH2_ERROR_HOSTKEY_SIGN: c_int = -11;
65 pub const LIBSSH2_ERROR_DECRYPT: c_int = -12;
66 pub const LIBSSH2_ERROR_SOCKET_DISCONNECT: c_int = -13;
67 pub const LIBSSH2_ERROR_PROTO: c_int = -14;
68 pub const LIBSSH2_ERROR_PASSWORD_EXPIRED: c_int = -15;
69 pub const LIBSSH2_ERROR_FILE: c_int = -16;
70 pub const LIBSSH2_ERROR_METHOD_NONE: c_int = -17;
71 pub const LIBSSH2_ERROR_AUTHENTICATION_FAILED: c_int = -18;
72 pub const LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED: c_int = LIBSSH2_ERROR_AUTHENTICATION_FAILED;
73 pub const LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED: c_int = -19;
74 pub const LIBSSH2_ERROR_CHANNEL_OUTOFORDER: c_int = -20;
75 pub const LIBSSH2_ERROR_CHANNEL_FAILURE: c_int = -21;
76 pub const LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED: c_int = -22;
77 pub const LIBSSH2_ERROR_CHANNEL_UNKNOWN: c_int = -23;
78 pub const LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED: c_int = -24;
79 pub const LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED: c_int = -25;
80 pub const LIBSSH2_ERROR_CHANNEL_CLOSED: c_int = -26;
81 pub const LIBSSH2_ERROR_CHANNEL_EOF_SENT: c_int = -27;
82 pub const LIBSSH2_ERROR_SCP_PROTOCOL: c_int = -28;
83 pub const LIBSSH2_ERROR_ZLIB: c_int = -29;
84 pub const LIBSSH2_ERROR_SOCKET_TIMEOUT: c_int = -30;
85 pub const LIBSSH2_ERROR_SFTP_PROTOCOL: c_int = -31;
86 pub const LIBSSH2_ERROR_REQUEST_DENIED: c_int = -32;
87 pub const LIBSSH2_ERROR_METHOD_NOT_SUPPORTED: c_int = -33;
88 pub const LIBSSH2_ERROR_INVAL: c_int = -34;
89 pub const LIBSSH2_ERROR_INVALID_POLL_TYPE: c_int = -35;
90 pub const LIBSSH2_ERROR_PUBLICKEY_PROTOCOL: c_int = -36;
91 pub const LIBSSH2_ERROR_EAGAIN: c_int = -37;
92 pub const LIBSSH2_ERROR_BUFFER_TOO_SMALL: c_int = -38;
93 pub const LIBSSH2_ERROR_BAD_USE: c_int = -39;
94 pub const LIBSSH2_ERROR_COMPRESS: c_int = -40;
95 pub const LIBSSH2_ERROR_OUT_OF_BOUNDARY: c_int = -41;
96 pub const LIBSSH2_ERROR_AGENT_PROTOCOL: c_int = -42;
97 pub const LIBSSH2_ERROR_SOCKET_RECV: c_int = -43;
98 pub const LIBSSH2_ERROR_ENCRYPT: c_int = -44;
99 pub const LIBSSH2_ERROR_BAD_SOCKET: c_int = -45;
100 pub const LIBSSH2_ERROR_KNOWN_HOSTS: c_int = -46;
101 
102 pub const LIBSSH2_FX_EOF: c_int = 1;
103 pub const LIBSSH2_FX_NO_SUCH_FILE: c_int = 2;
104 pub const LIBSSH2_FX_PERMISSION_DENIED: c_int = 3;
105 pub const LIBSSH2_FX_FAILURE: c_int = 4;
106 pub const LIBSSH2_FX_BAD_MESSAGE: c_int = 5;
107 pub const LIBSSH2_FX_NO_CONNECTION: c_int = 6;
108 pub const LIBSSH2_FX_CONNECTION_LOST: c_int = 7;
109 pub const LIBSSH2_FX_OP_UNSUPPORTED: c_int = 8;
110 pub const LIBSSH2_FX_INVALID_HANDLE: c_int = 9;
111 pub const LIBSSH2_FX_NO_SUCH_PATH: c_int = 10;
112 pub const LIBSSH2_FX_FILE_ALREADY_EXISTS: c_int = 11;
113 pub const LIBSSH2_FX_WRITE_PROTECT: c_int = 12;
114 pub const LIBSSH2_FX_NO_MEDIA: c_int = 13;
115 pub const LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM: c_int = 14;
116 pub const LIBSSH2_FX_QUOTA_EXCEEDED: c_int = 15;
117 pub const LIBSSH2_FX_UNKNOWN_PRINCIPAL: c_int = 16;
118 pub const LIBSSH2_FX_LOCK_CONFLICT: c_int = 17;
119 pub const LIBSSH2_FX_DIR_NOT_EMPTY: c_int = 18;
120 pub const LIBSSH2_FX_NOT_A_DIRECTORY: c_int = 19;
121 pub const LIBSSH2_FX_INVALID_FILENAME: c_int = 20;
122 pub const LIBSSH2_FX_LINK_LOOP: c_int = 21;
123 
124 pub const LIBSSH2_HOSTKEY_HASH_MD5: c_int = 1;
125 pub const LIBSSH2_HOSTKEY_HASH_SHA1: c_int = 2;
126 pub const LIBSSH2_HOSTKEY_HASH_SHA256: c_int = 3;
127 
128 pub const LIBSSH2_KNOWNHOST_FILE_OPENSSH: c_int = 1;
129 
130 pub const LIBSSH2_KNOWNHOST_CHECK_MATCH: c_int = 0;
131 pub const LIBSSH2_KNOWNHOST_CHECK_MISMATCH: c_int = 1;
132 pub const LIBSSH2_KNOWNHOST_CHECK_NOTFOUND: c_int = 2;
133 pub const LIBSSH2_KNOWNHOST_CHECK_FAILURE: c_int = 3;
134 
135 pub const LIBSSH2_KNOWNHOST_TYPE_PLAIN: c_int = 1;
136 pub const LIBSSH2_KNOWNHOST_TYPE_SHA1: c_int = 2;
137 pub const LIBSSH2_KNOWNHOST_TYPE_CUSTOM: c_int = 3;
138 pub const LIBSSH2_KNOWNHOST_KEYENC_RAW: c_int = 1 << 16;
139 pub const LIBSSH2_KNOWNHOST_KEYENC_BASE64: c_int = 2 << 16;
140 pub const LIBSSH2_KNOWNHOST_KEY_RSA1: c_int = 1 << 18;
141 pub const LIBSSH2_KNOWNHOST_KEY_SSHRSA: c_int = 2 << 18;
142 pub const LIBSSH2_KNOWNHOST_KEY_SSHDSS: c_int = 3 << 18;
143 pub const LIBSSH2_KNOWNHOST_KEY_ECDSA_256: c_int = 4 << 18;
144 pub const LIBSSH2_KNOWNHOST_KEY_ECDSA_384: c_int = 5 << 18;
145 pub const LIBSSH2_KNOWNHOST_KEY_ECDSA_521: c_int = 6 << 18;
146 pub const LIBSSH2_KNOWNHOST_KEY_ED25519: c_int = 7 << 18;
147 pub const LIBSSH2_KNOWNHOST_KEY_UNKNOWN: c_int = 15 << 18;
148 
149 pub const LIBSSH2_FXF_READ: c_ulong = 0x00000001;
150 pub const LIBSSH2_FXF_WRITE: c_ulong = 0x00000002;
151 pub const LIBSSH2_FXF_APPEND: c_ulong = 0x00000004;
152 pub const LIBSSH2_FXF_CREAT: c_ulong = 0x00000008;
153 pub const LIBSSH2_FXF_TRUNC: c_ulong = 0x00000010;
154 pub const LIBSSH2_FXF_EXCL: c_ulong = 0x00000020;
155 
156 pub const LIBSSH2_SFTP_OPENFILE: c_int = 0;
157 pub const LIBSSH2_SFTP_OPENDIR: c_int = 1;
158 
159 pub const LIBSSH2_SFTP_ATTR_SIZE: c_ulong = 0x00000001;
160 pub const LIBSSH2_SFTP_ATTR_UIDGID: c_ulong = 0x00000002;
161 pub const LIBSSH2_SFTP_ATTR_PERMISSIONS: c_ulong = 0x00000004;
162 pub const LIBSSH2_SFTP_ATTR_ACMODTIME: c_ulong = 0x00000008;
163 pub const LIBSSH2_SFTP_ATTR_EXTENDED: c_ulong = 0x80000000;
164 
165 pub const LIBSSH2_SFTP_STAT: c_int = 0;
166 pub const LIBSSH2_SFTP_LSTAT: c_int = 1;
167 pub const LIBSSH2_SFTP_SETSTAT: c_int = 2;
168 
169 pub const LIBSSH2_SFTP_SYMLINK: c_int = 0;
170 pub const LIBSSH2_SFTP_READLINK: c_int = 1;
171 pub const LIBSSH2_SFTP_REALPATH: c_int = 2;
172 
173 pub const LIBSSH2_SFTP_RENAME_OVERWRITE: c_long = 0x1;
174 pub const LIBSSH2_SFTP_RENAME_ATOMIC: c_long = 0x2;
175 pub const LIBSSH2_SFTP_RENAME_NATIVE: c_long = 0x4;
176 
177 pub const LIBSSH2_INIT_NO_CRYPTO: c_int = 0x1;
178 
179 pub const LIBSSH2_SFTP_S_IFMT: c_ulong = 0o170000;
180 pub const LIBSSH2_SFTP_S_IFIFO: c_ulong = 0o010000;
181 pub const LIBSSH2_SFTP_S_IFCHR: c_ulong = 0o020000;
182 pub const LIBSSH2_SFTP_S_IFDIR: c_ulong = 0o040000;
183 pub const LIBSSH2_SFTP_S_IFBLK: c_ulong = 0o060000;
184 pub const LIBSSH2_SFTP_S_IFREG: c_ulong = 0o100000;
185 pub const LIBSSH2_SFTP_S_IFLNK: c_ulong = 0o120000;
186 pub const LIBSSH2_SFTP_S_IFSOCK: c_ulong = 0o140000;
187 
188 pub const LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL: c_int = 0;
189 pub const LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE: c_int = 1;
190 pub const LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE: c_int = 2;
191 
192 pub const LIBSSH2_SESSION_BLOCK_INBOUND: c_int = 1;
193 pub const LIBSSH2_SESSION_BLOCK_OUTBOUND: c_int = 2;
194 
195 pub const  LIBSSH2_TRACE_TRANS : c_int = 1<<1;
196 pub const  LIBSSH2_TRACE_KEX   : c_int = 1<<2;
197 pub const  LIBSSH2_TRACE_AUTH  : c_int = 1<<3;
198 pub const  LIBSSH2_TRACE_CONN  : c_int = 1<<4;
199 pub const  LIBSSH2_TRACE_SCP   : c_int = 1<<5;
200 pub const  LIBSSH2_TRACE_SFTP  : c_int = 1<<6;
201 pub const  LIBSSH2_TRACE_ERROR : c_int = 1<<7;
202 pub const  LIBSSH2_TRACE_PUBLICKEY : c_int = 1<<8;
203 pub const  LIBSSH2_TRACE_SOCKET : c_int = 1<<9;
204 pub enum LIBSSH2_SESSION {}
205 pub enum LIBSSH2_AGENT {}
206 pub enum LIBSSH2_CHANNEL {}
207 pub enum LIBSSH2_LISTENER {}
208 pub enum LIBSSH2_KNOWNHOSTS {}
209 pub enum LIBSSH2_SFTP {}
210 pub enum LIBSSH2_SFTP_HANDLE {}
211 
212 pub type libssh2_int64_t = i64;
213 pub type libssh2_uint64_t = u64;
214 
215 // libssh2_struct_stat is a typedef for libc::stat on all platforms, however,
216 // Windows has a bunch of legacy around struct stat that makes things more
217 // complicated to validate with systest.
218 // The most reasonable looking solution to this is a newtype that derefs
219 // to libc::stat.
220 // We cannot use `pub struct libssh2_struct_stat(pub libc::stat)` because
221 // that triggers a `no tuple structs in FFI` error.
222 #[repr(C)]
223 pub struct libssh2_struct_stat(libc::stat);
224 
225 impl std::ops::Deref for libssh2_struct_stat {
226     type Target = libc::stat;
227 
deref(&self) -> &Self::Target228     fn deref(&self) -> &Self::Target {
229         &self.0
230     }
231 }
232 
233 #[repr(C)]
234 pub struct libssh2_agent_publickey {
235     pub magic: c_uint,
236     pub node: *mut c_void,
237     pub blob: *mut c_uchar,
238     pub blob_len: size_t,
239     pub comment: *mut c_char,
240 }
241 
242 #[repr(C)]
243 pub struct libssh2_knownhost {
244     pub magic: c_uint,
245     pub node: *mut c_void,
246     pub name: *mut c_char,
247     pub key: *mut c_char,
248     pub typemask: c_int,
249 }
250 
251 #[repr(C)]
252 #[derive(Copy, Clone)]
253 pub struct LIBSSH2_SFTP_ATTRIBUTES {
254     pub flags: c_ulong,
255     pub filesize: libssh2_uint64_t,
256     pub uid: c_ulong,
257     pub gid: c_ulong,
258     pub permissions: c_ulong,
259     pub atime: c_ulong,
260     pub mtime: c_ulong,
261 }
262 
263 #[repr(C)]
264 #[derive(Copy, Clone)]
265 pub struct LIBSSH2_SFTP_STATVFS {
266     pub f_bsize: libssh2_uint64_t,
267     pub f_frsize: libssh2_uint64_t,
268     pub f_blocks: libssh2_uint64_t,
269     pub f_bfree: libssh2_uint64_t,
270     pub f_bavail: libssh2_uint64_t,
271     pub f_files: libssh2_uint64_t,
272     pub f_ffree: libssh2_uint64_t,
273     pub f_favail: libssh2_uint64_t,
274     pub f_fsid: libssh2_uint64_t,
275     pub f_flag: libssh2_uint64_t,
276     pub f_namemax: libssh2_uint64_t,
277 }
278 
279 pub type LIBSSH2_ALLOC_FUNC = extern "C" fn(size_t, *mut *mut c_void) -> *mut c_void;
280 pub type LIBSSH2_FREE_FUNC = extern "C" fn(*mut c_void, *mut *mut c_void);
281 pub type LIBSSH2_REALLOC_FUNC = extern "C" fn(*mut c_void, size_t, *mut *mut c_void) -> *mut c_void;
282 pub type LIBSSH2_PASSWD_CHANGEREQ_FUNC = extern "C" fn(
283     sess: *mut LIBSSH2_SESSION,
284     newpw: *mut *mut c_char,
285     newpw_len: *mut c_int,
286     abstrakt: *mut *mut c_void,
287 );
288 
289 pub type LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC = extern "C" fn(
290     username: *const c_char,
291     username_len: c_int,
292     instruction: *const c_char,
293     instruction_len: c_int,
294     num_prompts: c_int,
295     prompts: *const LIBSSH2_USERAUTH_KBDINT_PROMPT,
296     responses: *mut LIBSSH2_USERAUTH_KBDINT_RESPONSE,
297     abstrakt: *mut *mut c_void,
298 );
299 
300 #[repr(C)]
301 pub struct LIBSSH2_USERAUTH_KBDINT_PROMPT {
302     pub text: *mut c_char,
303     pub length: c_uint,
304     pub echo: c_uchar,
305 }
306 
307 #[repr(C)]
308 pub struct LIBSSH2_USERAUTH_KBDINT_RESPONSE {
309     pub text: *mut c_char,
310     pub length: c_uint,
311 }
312 
313 #[cfg(unix)]
314 pub type libssh2_socket_t = c_int;
315 #[cfg(all(windows, target_pointer_width = "32"))]
316 pub type libssh2_socket_t = u32;
317 #[cfg(all(windows, target_pointer_width = "64"))]
318 pub type libssh2_socket_t = u64;
319 
320 extern "C" {
321     // misc
libssh2_init(flag: c_int) -> c_int322     pub fn libssh2_init(flag: c_int) -> c_int;
libssh2_exit()323     pub fn libssh2_exit();
libssh2_free(sess: *mut LIBSSH2_SESSION, ptr: *mut c_void)324     pub fn libssh2_free(sess: *mut LIBSSH2_SESSION, ptr: *mut c_void);
libssh2_hostkey_hash(session: *mut LIBSSH2_SESSION, hash_type: c_int) -> *const c_char325     pub fn libssh2_hostkey_hash(session: *mut LIBSSH2_SESSION, hash_type: c_int) -> *const c_char;
libssh2_trace(session: *mut LIBSSH2_SESSION, bitmask: c_int) -> c_int326     pub fn libssh2_trace(session: *mut LIBSSH2_SESSION, bitmask: c_int) -> c_int;
327 
328     // session
libssh2_session_init_ex( alloc: Option<LIBSSH2_ALLOC_FUNC>, free: Option<LIBSSH2_FREE_FUNC>, realloc: Option<LIBSSH2_REALLOC_FUNC>, abstrakt: *mut c_void, ) -> *mut LIBSSH2_SESSION329     pub fn libssh2_session_init_ex(
330         alloc: Option<LIBSSH2_ALLOC_FUNC>,
331         free: Option<LIBSSH2_FREE_FUNC>,
332         realloc: Option<LIBSSH2_REALLOC_FUNC>,
333         abstrakt: *mut c_void,
334     ) -> *mut LIBSSH2_SESSION;
libssh2_session_abstract(session: *mut LIBSSH2_SESSION) -> *mut *mut c_void335     pub fn libssh2_session_abstract(session: *mut LIBSSH2_SESSION) -> *mut *mut c_void;
libssh2_session_free(sess: *mut LIBSSH2_SESSION) -> c_int336     pub fn libssh2_session_free(sess: *mut LIBSSH2_SESSION) -> c_int;
libssh2_session_banner_get(sess: *mut LIBSSH2_SESSION) -> *const c_char337     pub fn libssh2_session_banner_get(sess: *mut LIBSSH2_SESSION) -> *const c_char;
libssh2_session_banner_set(sess: *mut LIBSSH2_SESSION, banner: *const c_char) -> c_int338     pub fn libssh2_session_banner_set(sess: *mut LIBSSH2_SESSION, banner: *const c_char) -> c_int;
libssh2_session_disconnect_ex( sess: *mut LIBSSH2_SESSION, reason: c_int, description: *const c_char, lang: *const c_char, ) -> c_int339     pub fn libssh2_session_disconnect_ex(
340         sess: *mut LIBSSH2_SESSION,
341         reason: c_int,
342         description: *const c_char,
343         lang: *const c_char,
344     ) -> c_int;
libssh2_session_flag(sess: *mut LIBSSH2_SESSION, flag: c_int, value: c_int) -> c_int345     pub fn libssh2_session_flag(sess: *mut LIBSSH2_SESSION, flag: c_int, value: c_int) -> c_int;
libssh2_session_get_blocking(session: *mut LIBSSH2_SESSION) -> c_int346     pub fn libssh2_session_get_blocking(session: *mut LIBSSH2_SESSION) -> c_int;
libssh2_session_get_timeout(sess: *mut LIBSSH2_SESSION) -> c_long347     pub fn libssh2_session_get_timeout(sess: *mut LIBSSH2_SESSION) -> c_long;
libssh2_session_hostkey( sess: *mut LIBSSH2_SESSION, len: *mut size_t, kind: *mut c_int, ) -> *const c_char348     pub fn libssh2_session_hostkey(
349         sess: *mut LIBSSH2_SESSION,
350         len: *mut size_t,
351         kind: *mut c_int,
352     ) -> *const c_char;
libssh2_session_method_pref( sess: *mut LIBSSH2_SESSION, method_type: c_int, prefs: *const c_char, ) -> c_int353     pub fn libssh2_session_method_pref(
354         sess: *mut LIBSSH2_SESSION,
355         method_type: c_int,
356         prefs: *const c_char,
357     ) -> c_int;
libssh2_session_methods(sess: *mut LIBSSH2_SESSION, method_type: c_int) -> *const c_char358     pub fn libssh2_session_methods(sess: *mut LIBSSH2_SESSION, method_type: c_int)
359         -> *const c_char;
libssh2_session_set_blocking(session: *mut LIBSSH2_SESSION, blocking: c_int)360     pub fn libssh2_session_set_blocking(session: *mut LIBSSH2_SESSION, blocking: c_int);
libssh2_session_set_timeout(session: *mut LIBSSH2_SESSION, timeout: c_long)361     pub fn libssh2_session_set_timeout(session: *mut LIBSSH2_SESSION, timeout: c_long);
libssh2_session_supported_algs( session: *mut LIBSSH2_SESSION, method_type: c_int, algs: *mut *mut *const c_char, ) -> c_int362     pub fn libssh2_session_supported_algs(
363         session: *mut LIBSSH2_SESSION,
364         method_type: c_int,
365         algs: *mut *mut *const c_char,
366     ) -> c_int;
libssh2_session_last_errno(sess: *mut LIBSSH2_SESSION) -> c_int367     pub fn libssh2_session_last_errno(sess: *mut LIBSSH2_SESSION) -> c_int;
libssh2_session_last_error( sess: *mut LIBSSH2_SESSION, msg: *mut *mut c_char, len: *mut c_int, want_buf: c_int, ) -> c_int368     pub fn libssh2_session_last_error(
369         sess: *mut LIBSSH2_SESSION,
370         msg: *mut *mut c_char,
371         len: *mut c_int,
372         want_buf: c_int,
373     ) -> c_int;
libssh2_session_handshake(sess: *mut LIBSSH2_SESSION, socket: libssh2_socket_t) -> c_int374     pub fn libssh2_session_handshake(sess: *mut LIBSSH2_SESSION, socket: libssh2_socket_t)
375         -> c_int;
libssh2_keepalive_config( sess: *mut LIBSSH2_SESSION, want_reply: c_int, interval: c_uint, )376     pub fn libssh2_keepalive_config(
377         sess: *mut LIBSSH2_SESSION,
378         want_reply: c_int,
379         interval: c_uint,
380     );
libssh2_keepalive_send(sess: *mut LIBSSH2_SESSION, seconds_to_next: *mut c_int) -> c_int381     pub fn libssh2_keepalive_send(sess: *mut LIBSSH2_SESSION, seconds_to_next: *mut c_int)
382         -> c_int;
libssh2_session_block_directions(sess: *mut LIBSSH2_SESSION) -> c_int383     pub fn libssh2_session_block_directions(sess: *mut LIBSSH2_SESSION) -> c_int;
384 
385     // agent
libssh2_agent_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_AGENT386     pub fn libssh2_agent_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_AGENT;
libssh2_agent_free(agent: *mut LIBSSH2_AGENT)387     pub fn libssh2_agent_free(agent: *mut LIBSSH2_AGENT);
libssh2_agent_connect(agent: *mut LIBSSH2_AGENT) -> c_int388     pub fn libssh2_agent_connect(agent: *mut LIBSSH2_AGENT) -> c_int;
libssh2_agent_disconnect(agent: *mut LIBSSH2_AGENT) -> c_int389     pub fn libssh2_agent_disconnect(agent: *mut LIBSSH2_AGENT) -> c_int;
libssh2_agent_list_identities(agent: *mut LIBSSH2_AGENT) -> c_int390     pub fn libssh2_agent_list_identities(agent: *mut LIBSSH2_AGENT) -> c_int;
libssh2_agent_get_identity( agent: *mut LIBSSH2_AGENT, store: *mut *mut libssh2_agent_publickey, prev: *mut libssh2_agent_publickey, ) -> c_int391     pub fn libssh2_agent_get_identity(
392         agent: *mut LIBSSH2_AGENT,
393         store: *mut *mut libssh2_agent_publickey,
394         prev: *mut libssh2_agent_publickey,
395     ) -> c_int;
libssh2_agent_userauth( agent: *mut LIBSSH2_AGENT, username: *const c_char, identity: *mut libssh2_agent_publickey, ) -> c_int396     pub fn libssh2_agent_userauth(
397         agent: *mut LIBSSH2_AGENT,
398         username: *const c_char,
399         identity: *mut libssh2_agent_publickey,
400     ) -> c_int;
401 
402     // channels
libssh2_channel_free(chan: *mut LIBSSH2_CHANNEL) -> c_int403     pub fn libssh2_channel_free(chan: *mut LIBSSH2_CHANNEL) -> c_int;
libssh2_channel_close(chan: *mut LIBSSH2_CHANNEL) -> c_int404     pub fn libssh2_channel_close(chan: *mut LIBSSH2_CHANNEL) -> c_int;
libssh2_channel_wait_closed(chan: *mut LIBSSH2_CHANNEL) -> c_int405     pub fn libssh2_channel_wait_closed(chan: *mut LIBSSH2_CHANNEL) -> c_int;
libssh2_channel_wait_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int406     pub fn libssh2_channel_wait_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int;
libssh2_channel_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int407     pub fn libssh2_channel_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int;
libssh2_channel_process_startup( chan: *mut LIBSSH2_CHANNEL, req: *const c_char, req_len: c_uint, msg: *const c_char, msg_len: c_uint, ) -> c_int408     pub fn libssh2_channel_process_startup(
409         chan: *mut LIBSSH2_CHANNEL,
410         req: *const c_char,
411         req_len: c_uint,
412         msg: *const c_char,
413         msg_len: c_uint,
414     ) -> c_int;
libssh2_channel_flush_ex(chan: *mut LIBSSH2_CHANNEL, streamid: c_int) -> c_int415     pub fn libssh2_channel_flush_ex(chan: *mut LIBSSH2_CHANNEL, streamid: c_int) -> c_int;
libssh2_channel_write_ex( chan: *mut LIBSSH2_CHANNEL, stream_id: c_int, buf: *const c_char, buflen: size_t, ) -> ssize_t416     pub fn libssh2_channel_write_ex(
417         chan: *mut LIBSSH2_CHANNEL,
418         stream_id: c_int,
419         buf: *const c_char,
420         buflen: size_t,
421     ) -> ssize_t;
libssh2_channel_get_exit_signal( chan: *mut LIBSSH2_CHANNEL, exitsignal: *mut *mut c_char, exitsignal_len: *mut size_t, errmsg: *mut *mut c_char, errmsg_len: *mut size_t, langtag: *mut *mut c_char, langtag_len: *mut size_t, ) -> c_int422     pub fn libssh2_channel_get_exit_signal(
423         chan: *mut LIBSSH2_CHANNEL,
424         exitsignal: *mut *mut c_char,
425         exitsignal_len: *mut size_t,
426         errmsg: *mut *mut c_char,
427         errmsg_len: *mut size_t,
428         langtag: *mut *mut c_char,
429         langtag_len: *mut size_t,
430     ) -> c_int;
libssh2_channel_get_exit_status(chan: *mut LIBSSH2_CHANNEL) -> c_int431     pub fn libssh2_channel_get_exit_status(chan: *mut LIBSSH2_CHANNEL) -> c_int;
libssh2_channel_open_ex( sess: *mut LIBSSH2_SESSION, channel_type: *const c_char, channel_type_len: c_uint, window_size: c_uint, packet_size: c_uint, message: *const c_char, message_len: c_uint, ) -> *mut LIBSSH2_CHANNEL432     pub fn libssh2_channel_open_ex(
433         sess: *mut LIBSSH2_SESSION,
434         channel_type: *const c_char,
435         channel_type_len: c_uint,
436         window_size: c_uint,
437         packet_size: c_uint,
438         message: *const c_char,
439         message_len: c_uint,
440     ) -> *mut LIBSSH2_CHANNEL;
libssh2_channel_read_ex( chan: *mut LIBSSH2_CHANNEL, stream_id: c_int, buf: *mut c_char, buflen: size_t, ) -> ssize_t441     pub fn libssh2_channel_read_ex(
442         chan: *mut LIBSSH2_CHANNEL,
443         stream_id: c_int,
444         buf: *mut c_char,
445         buflen: size_t,
446     ) -> ssize_t;
libssh2_channel_setenv_ex( chan: *mut LIBSSH2_CHANNEL, var: *const c_char, varlen: c_uint, val: *const c_char, vallen: c_uint, ) -> c_int447     pub fn libssh2_channel_setenv_ex(
448         chan: *mut LIBSSH2_CHANNEL,
449         var: *const c_char,
450         varlen: c_uint,
451         val: *const c_char,
452         vallen: c_uint,
453     ) -> c_int;
libssh2_channel_send_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int454     pub fn libssh2_channel_send_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int;
libssh2_channel_request_pty_ex( chan: *mut LIBSSH2_CHANNEL, term: *const c_char, termlen: c_uint, modes: *const c_char, modeslen: c_uint, width: c_int, height: c_int, width_px: c_int, height_px: c_int, ) -> c_int455     pub fn libssh2_channel_request_pty_ex(
456         chan: *mut LIBSSH2_CHANNEL,
457         term: *const c_char,
458         termlen: c_uint,
459         modes: *const c_char,
460         modeslen: c_uint,
461         width: c_int,
462         height: c_int,
463         width_px: c_int,
464         height_px: c_int,
465     ) -> c_int;
libssh2_channel_request_pty_size_ex( chan: *mut LIBSSH2_CHANNEL, width: c_int, height: c_int, width_px: c_int, height_px: c_int, ) -> c_int466     pub fn libssh2_channel_request_pty_size_ex(
467         chan: *mut LIBSSH2_CHANNEL,
468         width: c_int,
469         height: c_int,
470         width_px: c_int,
471         height_px: c_int,
472     ) -> c_int;
libssh2_channel_window_read_ex( chan: *mut LIBSSH2_CHANNEL, read_avail: *mut c_ulong, window_size_initial: *mut c_ulong, ) -> c_ulong473     pub fn libssh2_channel_window_read_ex(
474         chan: *mut LIBSSH2_CHANNEL,
475         read_avail: *mut c_ulong,
476         window_size_initial: *mut c_ulong,
477     ) -> c_ulong;
libssh2_channel_window_write_ex( chan: *mut LIBSSH2_CHANNEL, window_size_initial: *mut c_ulong, ) -> c_ulong478     pub fn libssh2_channel_window_write_ex(
479         chan: *mut LIBSSH2_CHANNEL,
480         window_size_initial: *mut c_ulong,
481     ) -> c_ulong;
libssh2_channel_receive_window_adjust2( chan: *mut LIBSSH2_CHANNEL, adjust: c_ulong, force: c_uchar, window: *mut c_uint, ) -> c_int482     pub fn libssh2_channel_receive_window_adjust2(
483         chan: *mut LIBSSH2_CHANNEL,
484         adjust: c_ulong,
485         force: c_uchar,
486         window: *mut c_uint,
487     ) -> c_int;
libssh2_channel_direct_tcpip_ex( ses: *mut LIBSSH2_SESSION, host: *const c_char, port: c_int, shost: *const c_char, sport: c_int, ) -> *mut LIBSSH2_CHANNEL488     pub fn libssh2_channel_direct_tcpip_ex(
489         ses: *mut LIBSSH2_SESSION,
490         host: *const c_char,
491         port: c_int,
492         shost: *const c_char,
493         sport: c_int,
494     ) -> *mut LIBSSH2_CHANNEL;
libssh2_channel_forward_accept(listener: *mut LIBSSH2_LISTENER) -> *mut LIBSSH2_CHANNEL495     pub fn libssh2_channel_forward_accept(listener: *mut LIBSSH2_LISTENER) -> *mut LIBSSH2_CHANNEL;
libssh2_channel_forward_cancel(listener: *mut LIBSSH2_LISTENER) -> c_int496     pub fn libssh2_channel_forward_cancel(listener: *mut LIBSSH2_LISTENER) -> c_int;
libssh2_channel_forward_listen_ex( sess: *mut LIBSSH2_SESSION, host: *const c_char, port: c_int, bound_port: *mut c_int, queue_maxsize: c_int, ) -> *mut LIBSSH2_LISTENER497     pub fn libssh2_channel_forward_listen_ex(
498         sess: *mut LIBSSH2_SESSION,
499         host: *const c_char,
500         port: c_int,
501         bound_port: *mut c_int,
502         queue_maxsize: c_int,
503     ) -> *mut LIBSSH2_LISTENER;
libssh2_channel_handle_extended_data2( channel: *mut LIBSSH2_CHANNEL, mode: c_int, ) -> c_int504     pub fn libssh2_channel_handle_extended_data2(
505         channel: *mut LIBSSH2_CHANNEL,
506         mode: c_int,
507     ) -> c_int;
libssh2_channel_request_auth_agent(channel: *mut LIBSSH2_CHANNEL) -> c_int508     pub fn libssh2_channel_request_auth_agent(channel: *mut LIBSSH2_CHANNEL) -> c_int;
509 
510     // userauth
libssh2_userauth_authenticated(sess: *mut LIBSSH2_SESSION) -> c_int511     pub fn libssh2_userauth_authenticated(sess: *mut LIBSSH2_SESSION) -> c_int;
libssh2_userauth_list( sess: *mut LIBSSH2_SESSION, username: *const c_char, username_len: c_uint, ) -> *mut c_char512     pub fn libssh2_userauth_list(
513         sess: *mut LIBSSH2_SESSION,
514         username: *const c_char,
515         username_len: c_uint,
516     ) -> *mut c_char;
libssh2_userauth_hostbased_fromfile_ex( sess: *mut LIBSSH2_SESSION, username: *const c_char, username_len: c_uint, publickey: *const c_char, privatekey: *const c_char, passphrase: *const c_char, hostname: *const c_char, hostname_len: c_uint, local_username: *const c_char, local_len: c_uint, ) -> c_int517     pub fn libssh2_userauth_hostbased_fromfile_ex(
518         sess: *mut LIBSSH2_SESSION,
519         username: *const c_char,
520         username_len: c_uint,
521         publickey: *const c_char,
522         privatekey: *const c_char,
523         passphrase: *const c_char,
524         hostname: *const c_char,
525         hostname_len: c_uint,
526         local_username: *const c_char,
527         local_len: c_uint,
528     ) -> c_int;
libssh2_userauth_publickey_fromfile_ex( sess: *mut LIBSSH2_SESSION, username: *const c_char, username_len: c_uint, publickey: *const c_char, privatekey: *const c_char, passphrase: *const c_char, ) -> c_int529     pub fn libssh2_userauth_publickey_fromfile_ex(
530         sess: *mut LIBSSH2_SESSION,
531         username: *const c_char,
532         username_len: c_uint,
533         publickey: *const c_char,
534         privatekey: *const c_char,
535         passphrase: *const c_char,
536     ) -> c_int;
libssh2_userauth_publickey_frommemory( sess: *mut LIBSSH2_SESSION, username: *const c_char, username_len: size_t, publickeydata: *const c_char, publickeydata_len: size_t, privatekeydata: *const c_char, privatekeydata_len: size_t, passphrase: *const c_char, ) -> c_int537     pub fn libssh2_userauth_publickey_frommemory(
538         sess: *mut LIBSSH2_SESSION,
539         username: *const c_char,
540         username_len: size_t,
541         publickeydata: *const c_char,
542         publickeydata_len: size_t,
543         privatekeydata: *const c_char,
544         privatekeydata_len: size_t,
545         passphrase: *const c_char,
546     ) -> c_int;
libssh2_userauth_password_ex( session: *mut LIBSSH2_SESSION, username: *const c_char, username_len: c_uint, password: *const c_char, password_len: c_uint, password_change_cb: Option<LIBSSH2_PASSWD_CHANGEREQ_FUNC>, ) -> c_int547     pub fn libssh2_userauth_password_ex(
548         session: *mut LIBSSH2_SESSION,
549         username: *const c_char,
550         username_len: c_uint,
551         password: *const c_char,
552         password_len: c_uint,
553         password_change_cb: Option<LIBSSH2_PASSWD_CHANGEREQ_FUNC>,
554     ) -> c_int;
libssh2_userauth_keyboard_interactive_ex( session: *mut LIBSSH2_SESSION, username: *const c_char, username_len: c_uint, callback: Option<LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC>, ) -> c_int555     pub fn libssh2_userauth_keyboard_interactive_ex(
556         session: *mut LIBSSH2_SESSION,
557         username: *const c_char,
558         username_len: c_uint,
559         callback: Option<LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC>,
560     ) -> c_int;
561 
562     // knownhost
libssh2_knownhost_free(hosts: *mut LIBSSH2_KNOWNHOSTS)563     pub fn libssh2_knownhost_free(hosts: *mut LIBSSH2_KNOWNHOSTS);
libssh2_knownhost_addc( hosts: *mut LIBSSH2_KNOWNHOSTS, host: *const c_char, salt: *const c_char, key: *const c_char, keylen: size_t, comment: *const c_char, commentlen: size_t, typemask: c_int, store: *mut *mut libssh2_knownhost, ) -> c_int564     pub fn libssh2_knownhost_addc(
565         hosts: *mut LIBSSH2_KNOWNHOSTS,
566         host: *const c_char,
567         salt: *const c_char,
568         key: *const c_char,
569         keylen: size_t,
570         comment: *const c_char,
571         commentlen: size_t,
572         typemask: c_int,
573         store: *mut *mut libssh2_knownhost,
574     ) -> c_int;
libssh2_knownhost_check( hosts: *mut LIBSSH2_KNOWNHOSTS, host: *const c_char, key: *const c_char, keylen: size_t, typemask: c_int, knownhost: *mut *mut libssh2_knownhost, ) -> c_int575     pub fn libssh2_knownhost_check(
576         hosts: *mut LIBSSH2_KNOWNHOSTS,
577         host: *const c_char,
578         key: *const c_char,
579         keylen: size_t,
580         typemask: c_int,
581         knownhost: *mut *mut libssh2_knownhost,
582     ) -> c_int;
libssh2_knownhost_checkp( hosts: *mut LIBSSH2_KNOWNHOSTS, host: *const c_char, port: c_int, key: *const c_char, keylen: size_t, typemask: c_int, knownhost: *mut *mut libssh2_knownhost, ) -> c_int583     pub fn libssh2_knownhost_checkp(
584         hosts: *mut LIBSSH2_KNOWNHOSTS,
585         host: *const c_char,
586         port: c_int,
587         key: *const c_char,
588         keylen: size_t,
589         typemask: c_int,
590         knownhost: *mut *mut libssh2_knownhost,
591     ) -> c_int;
libssh2_knownhost_del( hosts: *mut LIBSSH2_KNOWNHOSTS, entry: *mut libssh2_knownhost, ) -> c_int592     pub fn libssh2_knownhost_del(
593         hosts: *mut LIBSSH2_KNOWNHOSTS,
594         entry: *mut libssh2_knownhost,
595     ) -> c_int;
libssh2_knownhost_get( hosts: *mut LIBSSH2_KNOWNHOSTS, store: *mut *mut libssh2_knownhost, prev: *mut libssh2_knownhost, ) -> c_int596     pub fn libssh2_knownhost_get(
597         hosts: *mut LIBSSH2_KNOWNHOSTS,
598         store: *mut *mut libssh2_knownhost,
599         prev: *mut libssh2_knownhost,
600     ) -> c_int;
libssh2_knownhost_readfile( hosts: *mut LIBSSH2_KNOWNHOSTS, filename: *const c_char, kind: c_int, ) -> c_int601     pub fn libssh2_knownhost_readfile(
602         hosts: *mut LIBSSH2_KNOWNHOSTS,
603         filename: *const c_char,
604         kind: c_int,
605     ) -> c_int;
libssh2_knownhost_readline( hosts: *mut LIBSSH2_KNOWNHOSTS, line: *const c_char, len: size_t, kind: c_int, ) -> c_int606     pub fn libssh2_knownhost_readline(
607         hosts: *mut LIBSSH2_KNOWNHOSTS,
608         line: *const c_char,
609         len: size_t,
610         kind: c_int,
611     ) -> c_int;
libssh2_knownhost_writefile( hosts: *mut LIBSSH2_KNOWNHOSTS, filename: *const c_char, kind: c_int, ) -> c_int612     pub fn libssh2_knownhost_writefile(
613         hosts: *mut LIBSSH2_KNOWNHOSTS,
614         filename: *const c_char,
615         kind: c_int,
616     ) -> c_int;
libssh2_knownhost_writeline( hosts: *mut LIBSSH2_KNOWNHOSTS, known: *mut libssh2_knownhost, buffer: *mut c_char, buflen: size_t, outlen: *mut size_t, kind: c_int, ) -> c_int617     pub fn libssh2_knownhost_writeline(
618         hosts: *mut LIBSSH2_KNOWNHOSTS,
619         known: *mut libssh2_knownhost,
620         buffer: *mut c_char,
621         buflen: size_t,
622         outlen: *mut size_t,
623         kind: c_int,
624     ) -> c_int;
libssh2_knownhost_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_KNOWNHOSTS625     pub fn libssh2_knownhost_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_KNOWNHOSTS;
626 
627     // scp
628     #[deprecated(note = "dangerously unsafe on windows, use libssh2_scp_recv2 instead")]
libssh2_scp_recv( sess: *mut LIBSSH2_SESSION, path: *const c_char, sb: *mut libc::stat, ) -> *mut LIBSSH2_CHANNEL629     pub fn libssh2_scp_recv(
630         sess: *mut LIBSSH2_SESSION,
631         path: *const c_char,
632         sb: *mut libc::stat,
633     ) -> *mut LIBSSH2_CHANNEL;
634 
libssh2_scp_recv2( sess: *mut LIBSSH2_SESSION, path: *const c_char, sb: *mut libssh2_struct_stat, ) -> *mut LIBSSH2_CHANNEL635     pub fn libssh2_scp_recv2(
636         sess: *mut LIBSSH2_SESSION,
637         path: *const c_char,
638         sb: *mut libssh2_struct_stat,
639     ) -> *mut LIBSSH2_CHANNEL;
640 
libssh2_scp_send64( sess: *mut LIBSSH2_SESSION, path: *const c_char, mode: c_int, size: libssh2_int64_t, mtime: libc::time_t, atime: libc::time_t, ) -> *mut LIBSSH2_CHANNEL641     pub fn libssh2_scp_send64(
642         sess: *mut LIBSSH2_SESSION,
643         path: *const c_char,
644         mode: c_int,
645         size: libssh2_int64_t,
646         mtime: libc::time_t,
647         atime: libc::time_t,
648     ) -> *mut LIBSSH2_CHANNEL;
649 
650     // sftp
libssh2_sftp_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_SFTP651     pub fn libssh2_sftp_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_SFTP;
libssh2_sftp_shutdown(sftp: *mut LIBSSH2_SFTP) -> c_int652     pub fn libssh2_sftp_shutdown(sftp: *mut LIBSSH2_SFTP) -> c_int;
libssh2_sftp_last_error(sftp: *mut LIBSSH2_SFTP) -> c_ulong653     pub fn libssh2_sftp_last_error(sftp: *mut LIBSSH2_SFTP) -> c_ulong;
libssh2_sftp_open_ex( sftp: *mut LIBSSH2_SFTP, filename: *const c_char, filename_len: c_uint, flags: c_ulong, mode: c_long, open_type: c_int, ) -> *mut LIBSSH2_SFTP_HANDLE654     pub fn libssh2_sftp_open_ex(
655         sftp: *mut LIBSSH2_SFTP,
656         filename: *const c_char,
657         filename_len: c_uint,
658         flags: c_ulong,
659         mode: c_long,
660         open_type: c_int,
661     ) -> *mut LIBSSH2_SFTP_HANDLE;
libssh2_sftp_close_handle(handle: *mut LIBSSH2_SFTP_HANDLE) -> c_int662     pub fn libssh2_sftp_close_handle(handle: *mut LIBSSH2_SFTP_HANDLE) -> c_int;
libssh2_sftp_mkdir_ex( sftp: *mut LIBSSH2_SFTP, path: *const c_char, path_len: c_uint, mode: c_long, ) -> c_int663     pub fn libssh2_sftp_mkdir_ex(
664         sftp: *mut LIBSSH2_SFTP,
665         path: *const c_char,
666         path_len: c_uint,
667         mode: c_long,
668     ) -> c_int;
libssh2_sftp_fsync(handle: *mut LIBSSH2_SFTP_HANDLE) -> c_int669     pub fn libssh2_sftp_fsync(handle: *mut LIBSSH2_SFTP_HANDLE) -> c_int;
libssh2_sftp_fstat_ex( handle: *mut LIBSSH2_SFTP_HANDLE, attrs: *mut LIBSSH2_SFTP_ATTRIBUTES, setstat: c_int, ) -> c_int670     pub fn libssh2_sftp_fstat_ex(
671         handle: *mut LIBSSH2_SFTP_HANDLE,
672         attrs: *mut LIBSSH2_SFTP_ATTRIBUTES,
673         setstat: c_int,
674     ) -> c_int;
libssh2_sftp_fstatvfs( handle: *mut LIBSSH2_SFTP_HANDLE, attrs: *mut LIBSSH2_SFTP_STATVFS, ) -> c_int675     pub fn libssh2_sftp_fstatvfs(
676         handle: *mut LIBSSH2_SFTP_HANDLE,
677         attrs: *mut LIBSSH2_SFTP_STATVFS,
678     ) -> c_int;
libssh2_sftp_stat_ex( sftp: *mut LIBSSH2_SFTP, path: *const c_char, path_len: c_uint, stat_type: c_int, attrs: *mut LIBSSH2_SFTP_ATTRIBUTES, ) -> c_int679     pub fn libssh2_sftp_stat_ex(
680         sftp: *mut LIBSSH2_SFTP,
681         path: *const c_char,
682         path_len: c_uint,
683         stat_type: c_int,
684         attrs: *mut LIBSSH2_SFTP_ATTRIBUTES,
685     ) -> c_int;
libssh2_sftp_read( handle: *mut LIBSSH2_SFTP_HANDLE, buf: *mut c_char, len: size_t, ) -> ssize_t686     pub fn libssh2_sftp_read(
687         handle: *mut LIBSSH2_SFTP_HANDLE,
688         buf: *mut c_char,
689         len: size_t,
690     ) -> ssize_t;
libssh2_sftp_symlink_ex( sftp: *mut LIBSSH2_SFTP, path: *const c_char, path_len: c_uint, target: *mut c_char, target_len: c_uint, link_type: c_int, ) -> c_int691     pub fn libssh2_sftp_symlink_ex(
692         sftp: *mut LIBSSH2_SFTP,
693         path: *const c_char,
694         path_len: c_uint,
695         target: *mut c_char,
696         target_len: c_uint,
697         link_type: c_int,
698     ) -> c_int;
libssh2_sftp_rename_ex( sftp: *mut LIBSSH2_SFTP, src: *const c_char, src_len: c_uint, dst: *const c_char, dst_len: c_uint, flags: c_long, ) -> c_int699     pub fn libssh2_sftp_rename_ex(
700         sftp: *mut LIBSSH2_SFTP,
701         src: *const c_char,
702         src_len: c_uint,
703         dst: *const c_char,
704         dst_len: c_uint,
705         flags: c_long,
706     ) -> c_int;
libssh2_sftp_rmdir_ex( sftp: *mut LIBSSH2_SFTP, path: *const c_char, path_len: c_uint, ) -> c_int707     pub fn libssh2_sftp_rmdir_ex(
708         sftp: *mut LIBSSH2_SFTP,
709         path: *const c_char,
710         path_len: c_uint,
711     ) -> c_int;
libssh2_sftp_write( handle: *mut LIBSSH2_SFTP_HANDLE, buffer: *const c_char, len: size_t, ) -> ssize_t712     pub fn libssh2_sftp_write(
713         handle: *mut LIBSSH2_SFTP_HANDLE,
714         buffer: *const c_char,
715         len: size_t,
716     ) -> ssize_t;
libssh2_sftp_tell64(handle: *mut LIBSSH2_SFTP_HANDLE) -> libssh2_uint64_t717     pub fn libssh2_sftp_tell64(handle: *mut LIBSSH2_SFTP_HANDLE) -> libssh2_uint64_t;
libssh2_sftp_seek64(handle: *mut LIBSSH2_SFTP_HANDLE, off: libssh2_uint64_t)718     pub fn libssh2_sftp_seek64(handle: *mut LIBSSH2_SFTP_HANDLE, off: libssh2_uint64_t);
libssh2_sftp_readdir_ex( handle: *mut LIBSSH2_SFTP_HANDLE, buffer: *mut c_char, buffer_len: size_t, longentry: *mut c_char, longentry_len: size_t, attrs: *mut LIBSSH2_SFTP_ATTRIBUTES, ) -> c_int719     pub fn libssh2_sftp_readdir_ex(
720         handle: *mut LIBSSH2_SFTP_HANDLE,
721         buffer: *mut c_char,
722         buffer_len: size_t,
723         longentry: *mut c_char,
724         longentry_len: size_t,
725         attrs: *mut LIBSSH2_SFTP_ATTRIBUTES,
726     ) -> c_int;
libssh2_sftp_unlink_ex( sftp: *mut LIBSSH2_SFTP, filename: *const c_char, filename_len: c_uint, ) -> c_int727     pub fn libssh2_sftp_unlink_ex(
728         sftp: *mut LIBSSH2_SFTP,
729         filename: *const c_char,
730         filename_len: c_uint,
731     ) -> c_int;
732 }
733 
734 #[test]
smoke()735 fn smoke() {
736     unsafe { libssh2_init(0) };
737 }
738 
739 #[doc(hidden)]
issue_14344_workaround()740 pub fn issue_14344_workaround() {}
741 
init()742 pub fn init() {
743     use std::sync::Once;
744 
745     static INIT: Once = Once::new();
746     INIT.call_once(|| unsafe {
747         platform_init();
748         assert_eq!(libc::atexit(shutdown), 0);
749     });
750     extern "C" fn shutdown() {
751         unsafe {
752             libssh2_exit();
753         }
754     }
755 
756     #[cfg(unix)]
757     unsafe fn platform_init() {
758         // On Unix we want to funnel through openssl_sys to initialize OpenSSL,
759         // so be sure to tell libssh2 to not do its own thing as we've already
760         // taken care of it.
761         openssl_sys::init();
762         assert_eq!(libssh2_init(LIBSSH2_INIT_NO_CRYPTO), 0);
763     }
764 
765     #[cfg(windows)]
766     unsafe fn platform_init() {
767         // On Windows we want to be sure to tell libssh2 to initialize
768         // everything, as we're not managing crypto elsewhere ourselves. Also to
769         // fix alexcrichton/git2-rs#202
770         assert_eq!(libssh2_init(0), 0);
771     }
772 }
773