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_IFDIR: c_ulong = 0o040000;
181 pub const LIBSSH2_SFTP_S_IFREG: c_ulong = 0o100000;
182 pub const LIBSSH2_SFTP_S_IFLNK: c_ulong = 0o120000;
183
184 pub const LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL: c_int = 0;
185 pub const LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE: c_int = 1;
186 pub const LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE: c_int = 2;
187
188 pub const LIBSSH2_SESSION_BLOCK_INBOUND: c_int = 1;
189 pub const LIBSSH2_SESSION_BLOCK_OUTBOUND: c_int = 2;
190
191 pub enum LIBSSH2_SESSION {}
192 pub enum LIBSSH2_AGENT {}
193 pub enum LIBSSH2_CHANNEL {}
194 pub enum LIBSSH2_LISTENER {}
195 pub enum LIBSSH2_KNOWNHOSTS {}
196 pub enum LIBSSH2_SFTP {}
197 pub enum LIBSSH2_SFTP_HANDLE {}
198
199 pub type libssh2_int64_t = i64;
200 pub type libssh2_uint64_t = u64;
201
202 // libssh2_struct_stat is a typedef for libc::stat on all platforms, however,
203 // Windows has a bunch of legacy around struct stat that makes things more
204 // complicated to validate with systest.
205 // The most reasonable looking solution to this is a newtype that derefs
206 // to libc::stat.
207 // We cannot use `pub struct libssh2_struct_stat(pub libc::stat)` because
208 // that triggers a `no tuple structs in FFI` error.
209 #[repr(C)]
210 pub struct libssh2_struct_stat(libc::stat);
211
212 impl std::ops::Deref for libssh2_struct_stat {
213 type Target = libc::stat;
214
deref(&self) -> &Self::Target215 fn deref(&self) -> &Self::Target {
216 &self.0
217 }
218 }
219
220 #[repr(C)]
221 pub struct libssh2_agent_publickey {
222 pub magic: c_uint,
223 pub node: *mut c_void,
224 pub blob: *mut c_uchar,
225 pub blob_len: size_t,
226 pub comment: *mut c_char,
227 }
228
229 #[repr(C)]
230 pub struct libssh2_knownhost {
231 pub magic: c_uint,
232 pub node: *mut c_void,
233 pub name: *mut c_char,
234 pub key: *mut c_char,
235 pub typemask: c_int,
236 }
237
238 #[repr(C)]
239 #[derive(Copy, Clone)]
240 pub struct LIBSSH2_SFTP_ATTRIBUTES {
241 pub flags: c_ulong,
242 pub filesize: libssh2_uint64_t,
243 pub uid: c_ulong,
244 pub gid: c_ulong,
245 pub permissions: c_ulong,
246 pub atime: c_ulong,
247 pub mtime: c_ulong,
248 }
249
250 #[repr(C)]
251 #[derive(Copy, Clone)]
252 pub struct LIBSSH2_SFTP_STATVFS {
253 pub f_bsize: libssh2_uint64_t,
254 pub f_frsize: libssh2_uint64_t,
255 pub f_blocks: libssh2_uint64_t,
256 pub f_bfree: libssh2_uint64_t,
257 pub f_bavail: libssh2_uint64_t,
258 pub f_files: libssh2_uint64_t,
259 pub f_ffree: libssh2_uint64_t,
260 pub f_favail: libssh2_uint64_t,
261 pub f_fsid: libssh2_uint64_t,
262 pub f_flag: libssh2_uint64_t,
263 pub f_namemax: libssh2_uint64_t,
264 }
265
266 pub type LIBSSH2_ALLOC_FUNC = extern "C" fn(size_t, *mut *mut c_void) -> *mut c_void;
267 pub type LIBSSH2_FREE_FUNC = extern "C" fn(*mut c_void, *mut *mut c_void);
268 pub type LIBSSH2_REALLOC_FUNC = extern "C" fn(*mut c_void, size_t, *mut *mut c_void) -> *mut c_void;
269 pub type LIBSSH2_PASSWD_CHANGEREQ_FUNC = extern "C" fn(
270 sess: *mut LIBSSH2_SESSION,
271 newpw: *mut *mut c_char,
272 newpw_len: *mut c_int,
273 abstrakt: *mut *mut c_void,
274 );
275
276 pub type LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC = extern "C" fn(
277 username: *const c_char,
278 username_len: c_int,
279 instruction: *const c_char,
280 instruction_len: c_int,
281 num_prompts: c_int,
282 prompts: *const LIBSSH2_USERAUTH_KBDINT_PROMPT,
283 responses: *mut LIBSSH2_USERAUTH_KBDINT_RESPONSE,
284 abstrakt: *mut *mut c_void,
285 );
286
287 #[repr(C)]
288 pub struct LIBSSH2_USERAUTH_KBDINT_PROMPT {
289 pub text: *mut c_char,
290 pub length: c_uint,
291 pub echo: c_uchar,
292 }
293
294 #[repr(C)]
295 pub struct LIBSSH2_USERAUTH_KBDINT_RESPONSE {
296 pub text: *mut c_char,
297 pub length: c_uint,
298 }
299
300 #[cfg(unix)]
301 pub type libssh2_socket_t = c_int;
302 #[cfg(all(windows, target_pointer_width = "32"))]
303 pub type libssh2_socket_t = u32;
304 #[cfg(all(windows, target_pointer_width = "64"))]
305 pub type libssh2_socket_t = u64;
306
307 extern "C" {
308 // misc
libssh2_init(flag: c_int) -> c_int309 pub fn libssh2_init(flag: c_int) -> c_int;
libssh2_exit()310 pub fn libssh2_exit();
libssh2_free(sess: *mut LIBSSH2_SESSION, ptr: *mut c_void)311 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_char312 pub fn libssh2_hostkey_hash(session: *mut LIBSSH2_SESSION, hash_type: c_int) -> *const c_char;
313
314 // 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_SESSION315 pub fn libssh2_session_init_ex(
316 alloc: Option<LIBSSH2_ALLOC_FUNC>,
317 free: Option<LIBSSH2_FREE_FUNC>,
318 realloc: Option<LIBSSH2_REALLOC_FUNC>,
319 abstrakt: *mut c_void,
320 ) -> *mut LIBSSH2_SESSION;
libssh2_session_abstract(session: *mut LIBSSH2_SESSION) -> *mut *mut c_void321 pub fn libssh2_session_abstract(session: *mut LIBSSH2_SESSION) -> *mut *mut c_void;
libssh2_session_free(sess: *mut LIBSSH2_SESSION) -> c_int322 pub fn libssh2_session_free(sess: *mut LIBSSH2_SESSION) -> c_int;
libssh2_session_banner_get(sess: *mut LIBSSH2_SESSION) -> *const c_char323 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_int324 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_int325 pub fn libssh2_session_disconnect_ex(
326 sess: *mut LIBSSH2_SESSION,
327 reason: c_int,
328 description: *const c_char,
329 lang: *const c_char,
330 ) -> c_int;
libssh2_session_flag(sess: *mut LIBSSH2_SESSION, flag: c_int, value: c_int) -> c_int331 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_int332 pub fn libssh2_session_get_blocking(session: *mut LIBSSH2_SESSION) -> c_int;
libssh2_session_get_timeout(sess: *mut LIBSSH2_SESSION) -> c_long333 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_char334 pub fn libssh2_session_hostkey(
335 sess: *mut LIBSSH2_SESSION,
336 len: *mut size_t,
337 kind: *mut c_int,
338 ) -> *const c_char;
libssh2_session_method_pref( sess: *mut LIBSSH2_SESSION, method_type: c_int, prefs: *const c_char, ) -> c_int339 pub fn libssh2_session_method_pref(
340 sess: *mut LIBSSH2_SESSION,
341 method_type: c_int,
342 prefs: *const c_char,
343 ) -> c_int;
libssh2_session_methods(sess: *mut LIBSSH2_SESSION, method_type: c_int) -> *const c_char344 pub fn libssh2_session_methods(sess: *mut LIBSSH2_SESSION, method_type: c_int)
345 -> *const c_char;
libssh2_session_set_blocking(session: *mut LIBSSH2_SESSION, blocking: c_int)346 pub fn libssh2_session_set_blocking(session: *mut LIBSSH2_SESSION, blocking: c_int);
libssh2_session_set_timeout(session: *mut LIBSSH2_SESSION, timeout: c_long)347 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_int348 pub fn libssh2_session_supported_algs(
349 session: *mut LIBSSH2_SESSION,
350 method_type: c_int,
351 algs: *mut *mut *const c_char,
352 ) -> c_int;
libssh2_session_last_error( sess: *mut LIBSSH2_SESSION, msg: *mut *mut c_char, len: *mut c_int, want_buf: c_int, ) -> c_int353 pub fn libssh2_session_last_error(
354 sess: *mut LIBSSH2_SESSION,
355 msg: *mut *mut c_char,
356 len: *mut c_int,
357 want_buf: c_int,
358 ) -> c_int;
libssh2_session_handshake(sess: *mut LIBSSH2_SESSION, socket: libssh2_socket_t) -> c_int359 pub fn libssh2_session_handshake(sess: *mut LIBSSH2_SESSION, socket: libssh2_socket_t)
360 -> c_int;
libssh2_keepalive_config( sess: *mut LIBSSH2_SESSION, want_reply: c_int, interval: c_uint, )361 pub fn libssh2_keepalive_config(
362 sess: *mut LIBSSH2_SESSION,
363 want_reply: c_int,
364 interval: c_uint,
365 );
libssh2_keepalive_send(sess: *mut LIBSSH2_SESSION, seconds_to_next: *mut c_int) -> c_int366 pub fn libssh2_keepalive_send(sess: *mut LIBSSH2_SESSION, seconds_to_next: *mut c_int)
367 -> c_int;
libssh2_session_block_directions(sess: *mut LIBSSH2_SESSION) -> c_int368 pub fn libssh2_session_block_directions(sess: *mut LIBSSH2_SESSION) -> c_int;
369
370 // agent
libssh2_agent_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_AGENT371 pub fn libssh2_agent_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_AGENT;
libssh2_agent_free(agent: *mut LIBSSH2_AGENT)372 pub fn libssh2_agent_free(agent: *mut LIBSSH2_AGENT);
libssh2_agent_connect(agent: *mut LIBSSH2_AGENT) -> c_int373 pub fn libssh2_agent_connect(agent: *mut LIBSSH2_AGENT) -> c_int;
libssh2_agent_disconnect(agent: *mut LIBSSH2_AGENT) -> c_int374 pub fn libssh2_agent_disconnect(agent: *mut LIBSSH2_AGENT) -> c_int;
libssh2_agent_list_identities(agent: *mut LIBSSH2_AGENT) -> c_int375 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_int376 pub fn libssh2_agent_get_identity(
377 agent: *mut LIBSSH2_AGENT,
378 store: *mut *mut libssh2_agent_publickey,
379 prev: *mut libssh2_agent_publickey,
380 ) -> c_int;
libssh2_agent_userauth( agent: *mut LIBSSH2_AGENT, username: *const c_char, identity: *mut libssh2_agent_publickey, ) -> c_int381 pub fn libssh2_agent_userauth(
382 agent: *mut LIBSSH2_AGENT,
383 username: *const c_char,
384 identity: *mut libssh2_agent_publickey,
385 ) -> c_int;
386
387 // channels
libssh2_channel_free(chan: *mut LIBSSH2_CHANNEL) -> c_int388 pub fn libssh2_channel_free(chan: *mut LIBSSH2_CHANNEL) -> c_int;
libssh2_channel_close(chan: *mut LIBSSH2_CHANNEL) -> c_int389 pub fn libssh2_channel_close(chan: *mut LIBSSH2_CHANNEL) -> c_int;
libssh2_channel_wait_closed(chan: *mut LIBSSH2_CHANNEL) -> c_int390 pub fn libssh2_channel_wait_closed(chan: *mut LIBSSH2_CHANNEL) -> c_int;
libssh2_channel_wait_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int391 pub fn libssh2_channel_wait_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int;
libssh2_channel_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int392 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_int393 pub fn libssh2_channel_process_startup(
394 chan: *mut LIBSSH2_CHANNEL,
395 req: *const c_char,
396 req_len: c_uint,
397 msg: *const c_char,
398 msg_len: c_uint,
399 ) -> c_int;
libssh2_channel_flush_ex(chan: *mut LIBSSH2_CHANNEL, streamid: c_int) -> c_int400 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_t401 pub fn libssh2_channel_write_ex(
402 chan: *mut LIBSSH2_CHANNEL,
403 stream_id: c_int,
404 buf: *const c_char,
405 buflen: size_t,
406 ) -> 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_int407 pub fn libssh2_channel_get_exit_signal(
408 chan: *mut LIBSSH2_CHANNEL,
409 exitsignal: *mut *mut c_char,
410 exitsignal_len: *mut size_t,
411 errmsg: *mut *mut c_char,
412 errmsg_len: *mut size_t,
413 langtag: *mut *mut c_char,
414 langtag_len: *mut size_t,
415 ) -> c_int;
libssh2_channel_get_exit_status(chan: *mut LIBSSH2_CHANNEL) -> c_int416 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_CHANNEL417 pub fn libssh2_channel_open_ex(
418 sess: *mut LIBSSH2_SESSION,
419 channel_type: *const c_char,
420 channel_type_len: c_uint,
421 window_size: c_uint,
422 packet_size: c_uint,
423 message: *const c_char,
424 message_len: c_uint,
425 ) -> *mut LIBSSH2_CHANNEL;
libssh2_channel_read_ex( chan: *mut LIBSSH2_CHANNEL, stream_id: c_int, buf: *mut c_char, buflen: size_t, ) -> ssize_t426 pub fn libssh2_channel_read_ex(
427 chan: *mut LIBSSH2_CHANNEL,
428 stream_id: c_int,
429 buf: *mut c_char,
430 buflen: size_t,
431 ) -> 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_int432 pub fn libssh2_channel_setenv_ex(
433 chan: *mut LIBSSH2_CHANNEL,
434 var: *const c_char,
435 varlen: c_uint,
436 val: *const c_char,
437 vallen: c_uint,
438 ) -> c_int;
libssh2_channel_send_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int439 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_int440 pub fn libssh2_channel_request_pty_ex(
441 chan: *mut LIBSSH2_CHANNEL,
442 term: *const c_char,
443 termlen: c_uint,
444 modes: *const c_char,
445 modeslen: c_uint,
446 width: c_int,
447 height: c_int,
448 width_px: c_int,
449 height_px: c_int,
450 ) -> 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_int451 pub fn libssh2_channel_request_pty_size_ex(
452 chan: *mut LIBSSH2_CHANNEL,
453 width: c_int,
454 height: c_int,
455 width_px: c_int,
456 height_px: c_int,
457 ) -> c_int;
libssh2_channel_window_read_ex( chan: *mut LIBSSH2_CHANNEL, read_avail: *mut c_ulong, window_size_initial: *mut c_ulong, ) -> c_ulong458 pub fn libssh2_channel_window_read_ex(
459 chan: *mut LIBSSH2_CHANNEL,
460 read_avail: *mut c_ulong,
461 window_size_initial: *mut c_ulong,
462 ) -> c_ulong;
libssh2_channel_window_write_ex( chan: *mut LIBSSH2_CHANNEL, window_size_initial: *mut c_ulong, ) -> c_ulong463 pub fn libssh2_channel_window_write_ex(
464 chan: *mut LIBSSH2_CHANNEL,
465 window_size_initial: *mut c_ulong,
466 ) -> c_ulong;
libssh2_channel_receive_window_adjust2( chan: *mut LIBSSH2_CHANNEL, adjust: c_ulong, force: c_uchar, window: *mut c_uint, ) -> c_int467 pub fn libssh2_channel_receive_window_adjust2(
468 chan: *mut LIBSSH2_CHANNEL,
469 adjust: c_ulong,
470 force: c_uchar,
471 window: *mut c_uint,
472 ) -> 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_CHANNEL473 pub fn libssh2_channel_direct_tcpip_ex(
474 ses: *mut LIBSSH2_SESSION,
475 host: *const c_char,
476 port: c_int,
477 shost: *const c_char,
478 sport: c_int,
479 ) -> *mut LIBSSH2_CHANNEL;
libssh2_channel_forward_accept(listener: *mut LIBSSH2_LISTENER) -> *mut LIBSSH2_CHANNEL480 pub fn libssh2_channel_forward_accept(listener: *mut LIBSSH2_LISTENER) -> *mut LIBSSH2_CHANNEL;
libssh2_channel_forward_cancel(listener: *mut LIBSSH2_LISTENER) -> c_int481 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_LISTENER482 pub fn libssh2_channel_forward_listen_ex(
483 sess: *mut LIBSSH2_SESSION,
484 host: *const c_char,
485 port: c_int,
486 bound_port: *mut c_int,
487 queue_maxsize: c_int,
488 ) -> *mut LIBSSH2_LISTENER;
libssh2_channel_handle_extended_data2( channel: *mut LIBSSH2_CHANNEL, mode: c_int, ) -> c_int489 pub fn libssh2_channel_handle_extended_data2(
490 channel: *mut LIBSSH2_CHANNEL,
491 mode: c_int,
492 ) -> c_int;
libssh2_channel_request_auth_agent(channel: *mut LIBSSH2_CHANNEL) -> c_int493 pub fn libssh2_channel_request_auth_agent(channel: *mut LIBSSH2_CHANNEL) -> c_int;
494
495 // userauth
libssh2_userauth_authenticated(sess: *mut LIBSSH2_SESSION) -> c_int496 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_char497 pub fn libssh2_userauth_list(
498 sess: *mut LIBSSH2_SESSION,
499 username: *const c_char,
500 username_len: c_uint,
501 ) -> *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_int502 pub fn libssh2_userauth_hostbased_fromfile_ex(
503 sess: *mut LIBSSH2_SESSION,
504 username: *const c_char,
505 username_len: c_uint,
506 publickey: *const c_char,
507 privatekey: *const c_char,
508 passphrase: *const c_char,
509 hostname: *const c_char,
510 hostname_len: c_uint,
511 local_username: *const c_char,
512 local_len: c_uint,
513 ) -> 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_int514 pub fn libssh2_userauth_publickey_fromfile_ex(
515 sess: *mut LIBSSH2_SESSION,
516 username: *const c_char,
517 username_len: c_uint,
518 publickey: *const c_char,
519 privatekey: *const c_char,
520 passphrase: *const c_char,
521 ) -> 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_int522 pub fn libssh2_userauth_publickey_frommemory(
523 sess: *mut LIBSSH2_SESSION,
524 username: *const c_char,
525 username_len: size_t,
526 publickeydata: *const c_char,
527 publickeydata_len: size_t,
528 privatekeydata: *const c_char,
529 privatekeydata_len: size_t,
530 passphrase: *const c_char,
531 ) -> 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_int532 pub fn libssh2_userauth_password_ex(
533 session: *mut LIBSSH2_SESSION,
534 username: *const c_char,
535 username_len: c_uint,
536 password: *const c_char,
537 password_len: c_uint,
538 password_change_cb: Option<LIBSSH2_PASSWD_CHANGEREQ_FUNC>,
539 ) -> 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_int540 pub fn libssh2_userauth_keyboard_interactive_ex(
541 session: *mut LIBSSH2_SESSION,
542 username: *const c_char,
543 username_len: c_uint,
544 callback: Option<LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC>,
545 ) -> c_int;
546
547 // knownhost
libssh2_knownhost_free(hosts: *mut LIBSSH2_KNOWNHOSTS)548 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_int549 pub fn libssh2_knownhost_addc(
550 hosts: *mut LIBSSH2_KNOWNHOSTS,
551 host: *const c_char,
552 salt: *const c_char,
553 key: *const c_char,
554 keylen: size_t,
555 comment: *const c_char,
556 commentlen: size_t,
557 typemask: c_int,
558 store: *mut *mut libssh2_knownhost,
559 ) -> 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_int560 pub fn libssh2_knownhost_check(
561 hosts: *mut LIBSSH2_KNOWNHOSTS,
562 host: *const c_char,
563 key: *const c_char,
564 keylen: size_t,
565 typemask: c_int,
566 knownhost: *mut *mut libssh2_knownhost,
567 ) -> 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_int568 pub fn libssh2_knownhost_checkp(
569 hosts: *mut LIBSSH2_KNOWNHOSTS,
570 host: *const c_char,
571 port: c_int,
572 key: *const c_char,
573 keylen: size_t,
574 typemask: c_int,
575 knownhost: *mut *mut libssh2_knownhost,
576 ) -> c_int;
libssh2_knownhost_del( hosts: *mut LIBSSH2_KNOWNHOSTS, entry: *mut libssh2_knownhost, ) -> c_int577 pub fn libssh2_knownhost_del(
578 hosts: *mut LIBSSH2_KNOWNHOSTS,
579 entry: *mut libssh2_knownhost,
580 ) -> c_int;
libssh2_knownhost_get( hosts: *mut LIBSSH2_KNOWNHOSTS, store: *mut *mut libssh2_knownhost, prev: *mut libssh2_knownhost, ) -> c_int581 pub fn libssh2_knownhost_get(
582 hosts: *mut LIBSSH2_KNOWNHOSTS,
583 store: *mut *mut libssh2_knownhost,
584 prev: *mut libssh2_knownhost,
585 ) -> c_int;
libssh2_knownhost_readfile( hosts: *mut LIBSSH2_KNOWNHOSTS, filename: *const c_char, kind: c_int, ) -> c_int586 pub fn libssh2_knownhost_readfile(
587 hosts: *mut LIBSSH2_KNOWNHOSTS,
588 filename: *const c_char,
589 kind: c_int,
590 ) -> c_int;
libssh2_knownhost_readline( hosts: *mut LIBSSH2_KNOWNHOSTS, line: *const c_char, len: size_t, kind: c_int, ) -> c_int591 pub fn libssh2_knownhost_readline(
592 hosts: *mut LIBSSH2_KNOWNHOSTS,
593 line: *const c_char,
594 len: size_t,
595 kind: c_int,
596 ) -> c_int;
libssh2_knownhost_writefile( hosts: *mut LIBSSH2_KNOWNHOSTS, filename: *const c_char, kind: c_int, ) -> c_int597 pub fn libssh2_knownhost_writefile(
598 hosts: *mut LIBSSH2_KNOWNHOSTS,
599 filename: *const c_char,
600 kind: c_int,
601 ) -> 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_int602 pub fn libssh2_knownhost_writeline(
603 hosts: *mut LIBSSH2_KNOWNHOSTS,
604 known: *mut libssh2_knownhost,
605 buffer: *mut c_char,
606 buflen: size_t,
607 outlen: *mut size_t,
608 kind: c_int,
609 ) -> c_int;
libssh2_knownhost_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_KNOWNHOSTS610 pub fn libssh2_knownhost_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_KNOWNHOSTS;
611
612 // scp
613 #[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_CHANNEL614 pub fn libssh2_scp_recv(
615 sess: *mut LIBSSH2_SESSION,
616 path: *const c_char,
617 sb: *mut libc::stat,
618 ) -> *mut LIBSSH2_CHANNEL;
619
libssh2_scp_recv2( sess: *mut LIBSSH2_SESSION, path: *const c_char, sb: *mut libssh2_struct_stat, ) -> *mut LIBSSH2_CHANNEL620 pub fn libssh2_scp_recv2(
621 sess: *mut LIBSSH2_SESSION,
622 path: *const c_char,
623 sb: *mut libssh2_struct_stat,
624 ) -> *mut LIBSSH2_CHANNEL;
625
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_CHANNEL626 pub fn libssh2_scp_send64(
627 sess: *mut LIBSSH2_SESSION,
628 path: *const c_char,
629 mode: c_int,
630 size: libssh2_int64_t,
631 mtime: libc::time_t,
632 atime: libc::time_t,
633 ) -> *mut LIBSSH2_CHANNEL;
634
635 // sftp
libssh2_sftp_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_SFTP636 pub fn libssh2_sftp_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_SFTP;
libssh2_sftp_shutdown(sftp: *mut LIBSSH2_SFTP) -> c_int637 pub fn libssh2_sftp_shutdown(sftp: *mut LIBSSH2_SFTP) -> c_int;
libssh2_sftp_last_error(sftp: *mut LIBSSH2_SFTP) -> c_ulong638 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_HANDLE639 pub fn libssh2_sftp_open_ex(
640 sftp: *mut LIBSSH2_SFTP,
641 filename: *const c_char,
642 filename_len: c_uint,
643 flags: c_ulong,
644 mode: c_long,
645 open_type: c_int,
646 ) -> *mut LIBSSH2_SFTP_HANDLE;
libssh2_sftp_close_handle(handle: *mut LIBSSH2_SFTP_HANDLE) -> c_int647 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_int648 pub fn libssh2_sftp_mkdir_ex(
649 sftp: *mut LIBSSH2_SFTP,
650 path: *const c_char,
651 path_len: c_uint,
652 mode: c_long,
653 ) -> c_int;
libssh2_sftp_fsync(handle: *mut LIBSSH2_SFTP_HANDLE) -> c_int654 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_int655 pub fn libssh2_sftp_fstat_ex(
656 handle: *mut LIBSSH2_SFTP_HANDLE,
657 attrs: *mut LIBSSH2_SFTP_ATTRIBUTES,
658 setstat: c_int,
659 ) -> c_int;
libssh2_sftp_fstatvfs( handle: *mut LIBSSH2_SFTP_HANDLE, attrs: *mut LIBSSH2_SFTP_STATVFS, ) -> c_int660 pub fn libssh2_sftp_fstatvfs(
661 handle: *mut LIBSSH2_SFTP_HANDLE,
662 attrs: *mut LIBSSH2_SFTP_STATVFS,
663 ) -> 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_int664 pub fn libssh2_sftp_stat_ex(
665 sftp: *mut LIBSSH2_SFTP,
666 path: *const c_char,
667 path_len: c_uint,
668 stat_type: c_int,
669 attrs: *mut LIBSSH2_SFTP_ATTRIBUTES,
670 ) -> c_int;
libssh2_sftp_read( handle: *mut LIBSSH2_SFTP_HANDLE, buf: *mut c_char, len: size_t, ) -> ssize_t671 pub fn libssh2_sftp_read(
672 handle: *mut LIBSSH2_SFTP_HANDLE,
673 buf: *mut c_char,
674 len: size_t,
675 ) -> 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_int676 pub fn libssh2_sftp_symlink_ex(
677 sftp: *mut LIBSSH2_SFTP,
678 path: *const c_char,
679 path_len: c_uint,
680 target: *mut c_char,
681 target_len: c_uint,
682 link_type: c_int,
683 ) -> 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_int684 pub fn libssh2_sftp_rename_ex(
685 sftp: *mut LIBSSH2_SFTP,
686 src: *const c_char,
687 src_len: c_uint,
688 dst: *const c_char,
689 dst_len: c_uint,
690 flags: c_long,
691 ) -> c_int;
libssh2_sftp_rmdir_ex( sftp: *mut LIBSSH2_SFTP, path: *const c_char, path_len: c_uint, ) -> c_int692 pub fn libssh2_sftp_rmdir_ex(
693 sftp: *mut LIBSSH2_SFTP,
694 path: *const c_char,
695 path_len: c_uint,
696 ) -> c_int;
libssh2_sftp_write( handle: *mut LIBSSH2_SFTP_HANDLE, buffer: *const c_char, len: size_t, ) -> ssize_t697 pub fn libssh2_sftp_write(
698 handle: *mut LIBSSH2_SFTP_HANDLE,
699 buffer: *const c_char,
700 len: size_t,
701 ) -> ssize_t;
libssh2_sftp_tell64(handle: *mut LIBSSH2_SFTP_HANDLE) -> libssh2_uint64_t702 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)703 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_int704 pub fn libssh2_sftp_readdir_ex(
705 handle: *mut LIBSSH2_SFTP_HANDLE,
706 buffer: *mut c_char,
707 buffer_len: size_t,
708 longentry: *mut c_char,
709 longentry_len: size_t,
710 attrs: *mut LIBSSH2_SFTP_ATTRIBUTES,
711 ) -> c_int;
libssh2_sftp_unlink_ex( sftp: *mut LIBSSH2_SFTP, filename: *const c_char, filename_len: c_uint, ) -> c_int712 pub fn libssh2_sftp_unlink_ex(
713 sftp: *mut LIBSSH2_SFTP,
714 filename: *const c_char,
715 filename_len: c_uint,
716 ) -> c_int;
717 }
718
719 #[test]
smoke()720 fn smoke() {
721 unsafe { libssh2_init(0) };
722 }
723
724 #[doc(hidden)]
issue_14344_workaround()725 pub fn issue_14344_workaround() {}
726
init()727 pub fn init() {
728 use std::sync::Once;
729
730 static INIT: Once = Once::new();
731 INIT.call_once(|| unsafe {
732 platform_init();
733 assert_eq!(libc::atexit(shutdown), 0);
734 });
735 extern "C" fn shutdown() {
736 unsafe {
737 libssh2_exit();
738 }
739 }
740
741 #[cfg(unix)]
742 unsafe fn platform_init() {
743 // On Unix we want to funnel through openssl_sys to initialize OpenSSL,
744 // so be sure to tell libssh2 to not do its own thing as we've already
745 // taken care of it.
746 openssl_sys::init();
747 assert_eq!(libssh2_init(LIBSSH2_INIT_NO_CRYPTO), 0);
748 }
749
750 #[cfg(windows)]
751 unsafe fn platform_init() {
752 // On Windows we want to be sure to tell libssh2 to initialize
753 // everything, as we're not managing crypto elsewhere ourselves. Also to
754 // fix alexcrichton/git2-rs#202
755 assert_eq!(libssh2_init(0), 0);
756 }
757 }
758