diff options
Diffstat (limited to 'include/libssh')
-rw-r--r-- | include/libssh/buffer.h | 5 | ||||
-rw-r--r-- | include/libssh/channels.h | 2 | ||||
-rw-r--r-- | include/libssh/legacy.h | 98 | ||||
-rw-r--r-- | include/libssh/libssh.h | 104 | ||||
-rw-r--r-- | include/libssh/libsshpp.hpp | 6 |
5 files changed, 152 insertions, 63 deletions
diff --git a/include/libssh/buffer.h b/include/libssh/buffer.h index 648a5b2..dec1173 100644 --- a/include/libssh/buffer.h +++ b/include/libssh/buffer.h @@ -22,6 +22,7 @@ #ifndef BUFFER_H_ #define BUFFER_H_ +#include "libssh/libssh.h" /* Describes a buffer state */ struct ssh_buffer_struct { char *data; @@ -30,6 +31,10 @@ struct ssh_buffer_struct { uint32_t pos; }; +LIBSSH_API void ssh_buffer_free(ssh_buffer buffer); +LIBSSH_API void *ssh_buffer_get_begin(ssh_buffer buffer); +LIBSSH_API uint32_t ssh_buffer_get_len(ssh_buffer buffer); +LIBSSH_API ssh_buffer ssh_buffer_new(void); int buffer_add_ssh_string(ssh_buffer buffer, ssh_string string); int buffer_add_u8(ssh_buffer buffer, uint8_t data); int buffer_add_u16(ssh_buffer buffer, uint16_t data); diff --git a/include/libssh/channels.h b/include/libssh/channels.h index 56e660f..7d8a05b 100644 --- a/include/libssh/channels.h +++ b/include/libssh/channels.h @@ -78,7 +78,7 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_failure); SSH_PACKET_CALLBACK(ssh_request_success); SSH_PACKET_CALLBACK(ssh_request_denied); -ssh_channel channel_new(ssh_session session); +ssh_channel ssh_channel_new(ssh_session session); int channel_default_bufferize(ssh_channel channel, void *data, int len, int is_stderr); uint32_t ssh_channel_new_id(ssh_session session); diff --git a/include/libssh/legacy.h b/include/libssh/legacy.h new file mode 100644 index 0000000..33ed357 --- /dev/null +++ b/include/libssh/legacy.h @@ -0,0 +1,98 @@ +/* + * This file is part of the SSH Library + * + * Copyright (c) 2010 by Aris Adamantiadis + * + * The SSH Library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or (at your + * option) any later version. + * + * The SSH Library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the SSH Library; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +/* Since libssh.h includes legacy.h, it's important that libssh.h is included + * first. we don't define LEGACY_H now because we want it to be defined when + * included from libssh.h + */ + +#include "libssh/libssh.h" + +#ifndef LEGACY_H_ +#define LEGACY_H_ +LIBSSH_API void buffer_free(ssh_buffer buffer); +LIBSSH_API void *buffer_get(ssh_buffer buffer); +LIBSSH_API uint32_t buffer_get_len(ssh_buffer buffer); +LIBSSH_API ssh_buffer buffer_new(void); + +LIBSSH_API ssh_channel channel_accept_x11(ssh_channel channel, int timeout_ms); +LIBSSH_API int channel_change_pty_size(ssh_channel channel,int cols,int rows); +LIBSSH_API ssh_channel channel_forward_accept(ssh_session session, int timeout_ms); +LIBSSH_API int channel_close(ssh_channel channel); +LIBSSH_API int channel_forward_cancel(ssh_session session, const char *address, int port); +LIBSSH_API int channel_forward_listen(ssh_session session, const char *address, int port, int *bound_port); +LIBSSH_API void channel_free(ssh_channel channel); +LIBSSH_API int channel_get_exit_status(ssh_channel channel); +LIBSSH_API ssh_session channel_get_session(ssh_channel channel); +LIBSSH_API int channel_is_closed(ssh_channel channel); +LIBSSH_API int channel_is_eof(ssh_channel channel); +LIBSSH_API int channel_is_open(ssh_channel channel); +LIBSSH_API ssh_channel channel_new(ssh_session session); +LIBSSH_API int channel_open_forward(ssh_channel channel, const char *remotehost, + int remoteport, const char *sourcehost, int localport); +LIBSSH_API int channel_open_session(ssh_channel channel); +LIBSSH_API int channel_poll(ssh_channel channel, int is_stderr); +LIBSSH_API int channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr); + +LIBSSH_API int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, uint32_t count, + int is_stderr); + +LIBSSH_API int channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count, + int is_stderr); +LIBSSH_API int channel_request_env(ssh_channel channel, const char *name, const char *value); +LIBSSH_API int channel_request_exec(ssh_channel channel, const char *cmd); +LIBSSH_API int channel_request_pty(ssh_channel channel); +LIBSSH_API int channel_request_pty_size(ssh_channel channel, const char *term, + int cols, int rows); +LIBSSH_API int channel_request_shell(ssh_channel channel); +LIBSSH_API int channel_request_send_signal(ssh_channel channel, const char *signum); +LIBSSH_API int channel_request_sftp(ssh_channel channel); +LIBSSH_API int channel_request_subsystem(ssh_channel channel, const char *subsystem); +LIBSSH_API int channel_request_x11(ssh_channel channel, int single_connection, const char *protocol, + const char *cookie, int screen_number); +LIBSSH_API int channel_send_eof(ssh_channel channel); +LIBSSH_API int channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct + timeval * timeout); +LIBSSH_API void channel_set_blocking(ssh_channel channel, int blocking); +LIBSSH_API int channel_write(ssh_channel channel, const void *data, uint32_t len); + +LIBSSH_API void privatekey_free(ssh_private_key prv); +LIBSSH_API ssh_private_key privatekey_from_file(ssh_session session, const char *filename, + int type, const char *passphrase); +LIBSSH_API void publickey_free(ssh_public_key key); +LIBSSH_API int ssh_publickey_to_file(ssh_session session, const char *file, + ssh_string pubkey, int type); +LIBSSH_API ssh_string publickey_from_file(ssh_session session, const char *filename, + int *type); +LIBSSH_API ssh_public_key publickey_from_privatekey(ssh_private_key prv); +LIBSSH_API ssh_string publickey_to_string(ssh_public_key key); + +LIBSSH_API void string_burn(ssh_string str); +LIBSSH_API ssh_string string_copy(ssh_string str); +LIBSSH_API void *string_data(ssh_string str); +LIBSSH_API int string_fill(ssh_string str, const void *data, size_t len); +LIBSSH_API void string_free(ssh_string str); +LIBSSH_API ssh_string string_from_char(const char *what); +LIBSSH_API size_t string_len(ssh_string str); +LIBSSH_API ssh_string string_new(size_t size); +LIBSSH_API char *string_to_char(ssh_string str); + +#endif /* LEGACY_H_ */ diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index d3ba186..d2ad0e4 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -307,60 +307,43 @@ enum ssh_scp_request_types { SSH_SCP_REQUEST_WARNING }; -LIBSSH_API void buffer_free(ssh_buffer buffer); -LIBSSH_API void *buffer_get(ssh_buffer buffer); -LIBSSH_API uint32_t buffer_get_len(ssh_buffer buffer); -LIBSSH_API ssh_buffer buffer_new(void); - -LIBSSH_API ssh_channel channel_accept_x11(ssh_channel channel, int timeout_ms); -LIBSSH_API int channel_change_pty_size(ssh_channel channel,int cols,int rows); -LIBSSH_API ssh_channel channel_forward_accept(ssh_session session, int timeout_ms); -LIBSSH_API int channel_close(ssh_channel channel); -LIBSSH_API int channel_forward_cancel(ssh_session session, const char *address, int port); -LIBSSH_API int channel_forward_listen(ssh_session session, const char *address, int port, int *bound_port); -LIBSSH_API void channel_free(ssh_channel channel); -LIBSSH_API int channel_get_exit_status(ssh_channel channel); -LIBSSH_API ssh_session channel_get_session(ssh_channel channel); -LIBSSH_API int channel_is_closed(ssh_channel channel); -LIBSSH_API int channel_is_eof(ssh_channel channel); -LIBSSH_API int channel_is_open(ssh_channel channel); -LIBSSH_API ssh_channel channel_new(ssh_session session); -LIBSSH_API int channel_open_forward(ssh_channel channel, const char *remotehost, +LIBSSH_API ssh_channel ssh_channel_accept_x11(ssh_channel channel, int timeout_ms); +LIBSSH_API int ssh_channel_change_pty_size(ssh_channel channel,int cols,int rows); +LIBSSH_API ssh_channel ssh_channel_forward_accept(ssh_session session, int timeout_ms); +LIBSSH_API int ssh_channel_close(ssh_channel channel); +LIBSSH_API int ssh_channel_forward_cancel(ssh_session session, const char *address, int port); +LIBSSH_API int ssh_channel_forward_listen(ssh_session session, const char *address, int port, int *bound_port); +LIBSSH_API void ssh_channel_free(ssh_channel channel); +LIBSSH_API int ssh_channel_get_exit_status(ssh_channel channel); +LIBSSH_API ssh_session ssh_channel_get_session(ssh_channel channel); +LIBSSH_API int ssh_channel_is_closed(ssh_channel channel); +LIBSSH_API int ssh_channel_is_eof(ssh_channel channel); +LIBSSH_API int ssh_channel_is_open(ssh_channel channel); +LIBSSH_API ssh_channel ssh_channel_new(ssh_session session); +LIBSSH_API int ssh_channel_open_forward(ssh_channel channel, const char *remotehost, int remoteport, const char *sourcehost, int localport); -LIBSSH_API int channel_open_session(ssh_channel channel); -LIBSSH_API int channel_poll(ssh_channel channel, int is_stderr); -LIBSSH_API int channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr); -LIBSSH_API int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, uint32_t count, +LIBSSH_API int ssh_channel_open_session(ssh_channel channel); +LIBSSH_API int ssh_channel_poll(ssh_channel channel, int is_stderr); +LIBSSH_API int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr); +LIBSSH_API int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count, int is_stderr); -LIBSSH_API int channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count, - int is_stderr); -LIBSSH_API int channel_request_env(ssh_channel channel, const char *name, const char *value); -LIBSSH_API int channel_request_exec(ssh_channel channel, const char *cmd); -LIBSSH_API int channel_request_pty(ssh_channel channel); -LIBSSH_API int channel_request_pty_size(ssh_channel channel, const char *term, +LIBSSH_API int ssh_channel_request_env(ssh_channel channel, const char *name, const char *value); +LIBSSH_API int ssh_channel_request_exec(ssh_channel channel, const char *cmd); +LIBSSH_API int ssh_channel_request_pty(ssh_channel channel); +LIBSSH_API int ssh_channel_request_pty_size(ssh_channel channel, const char *term, int cols, int rows); -LIBSSH_API int channel_request_shell(ssh_channel channel); -LIBSSH_API int channel_request_send_signal(ssh_channel channel, const char *signum); -LIBSSH_API int channel_request_sftp(ssh_channel channel); -LIBSSH_API int channel_request_subsystem(ssh_channel channel, const char *subsystem); -LIBSSH_API int channel_request_x11(ssh_channel channel, int single_connection, const char *protocol, +LIBSSH_API int ssh_channel_request_shell(ssh_channel channel); +LIBSSH_API int ssh_channel_request_send_signal(ssh_channel channel, const char *signum); +LIBSSH_API int ssh_channel_request_sftp(ssh_channel channel); +LIBSSH_API int ssh_channel_request_subsystem(ssh_channel channel, const char *subsystem); +LIBSSH_API int ssh_channel_request_x11(ssh_channel channel, int single_connection, const char *protocol, const char *cookie, int screen_number); -LIBSSH_API int channel_send_eof(ssh_channel channel); -LIBSSH_API int channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct +LIBSSH_API int ssh_channel_send_eof(ssh_channel channel); +LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct timeval * timeout); -LIBSSH_API void channel_set_blocking(ssh_channel channel, int blocking); -LIBSSH_API int channel_write(ssh_channel channel, const void *data, uint32_t len); - -LIBSSH_API void privatekey_free(ssh_private_key prv); -LIBSSH_API ssh_private_key privatekey_from_file(ssh_session session, const char *filename, - int type, const char *passphrase); -LIBSSH_API void publickey_free(ssh_public_key key); -LIBSSH_API int ssh_publickey_to_file(ssh_session session, const char *file, - ssh_string pubkey, int type); -LIBSSH_API ssh_string publickey_from_file(ssh_session session, const char *filename, - int *type); -LIBSSH_API ssh_public_key publickey_from_privatekey(ssh_private_key prv); -LIBSSH_API ssh_string publickey_to_string(ssh_public_key key); +LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking); +LIBSSH_API int ssh_channel_write(ssh_channel channel, const void *data, uint32_t len); + LIBSSH_API int ssh_try_publickey_from_file(ssh_session session, const char *keyfile, ssh_string *publickey, int *type); @@ -457,16 +440,19 @@ LIBSSH_API int ssh_userauth_privatekey_file(ssh_session session, const char *use LIBSSH_API const char *ssh_version(int req_version); LIBSSH_API int ssh_write_knownhost(ssh_session session); -LIBSSH_API void string_burn(ssh_string str); -LIBSSH_API ssh_string string_copy(ssh_string str); -LIBSSH_API void *string_data(ssh_string str); -LIBSSH_API int string_fill(ssh_string str, const void *data, size_t len); -LIBSSH_API void string_free(ssh_string str); -LIBSSH_API ssh_string string_from_char(const char *what); -LIBSSH_API size_t string_len(ssh_string str); -LIBSSH_API ssh_string string_new(size_t size); -LIBSSH_API char *string_to_char(ssh_string str); - +LIBSSH_API void ssh_string_burn(ssh_string str); +LIBSSH_API ssh_string ssh_string_copy(ssh_string str); +LIBSSH_API void *ssh_string_data(ssh_string str); +LIBSSH_API int ssh_string_fill(ssh_string str, const void *data, size_t len); +LIBSSH_API void ssh_string_free(ssh_string str); +LIBSSH_API ssh_string ssh_string_from_char(const char *what); +LIBSSH_API size_t ssh_string_len(ssh_string str); +LIBSSH_API ssh_string ssh_string_new(size_t size); +LIBSSH_API char *ssh_string_to_char(ssh_string str); + +#ifndef LIBSSH_LEGACY_0_4 +#include "libssh/legacy.h" +#endif #ifdef __cplusplus } diff --git a/include/libssh/libsshpp.hpp b/include/libssh/libsshpp.hpp index 086e8e2..c3d93e2 100644 --- a/include/libssh/libsshpp.hpp +++ b/include/libssh/libsshpp.hpp @@ -174,11 +174,11 @@ private: class Channel { public: Channel(Session &session){ - channel=channel_new(session.getCSession()); + channel=ssh_channel_new(session.getCSession()); this->session=&session; } ~Channel(){ - channel_free(channel); + ssh_channel_free(channel); channel=NULL; } int acceptX11(int timeout_ms); @@ -223,7 +223,7 @@ public: if(is_stderr){ ret=channel_write_stderr(channel,data,len); } else { - ret=channel_write(channel,data,len); + ret=ssh_channel_write(channel,data,len); } if(ret==SSH_ERROR) ssh_throw(ret); |