aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-07-24 22:15:33 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2009-07-24 22:15:33 +0200
commit2bc8819e8f68014ba35d03e56393e4d0c16386f8 (patch)
treefc0b96589e24be0b1029b501ea8697b2d92d24f7
parent23b6c95e04adeff7cf49d7d8dffc74f1e3e4bc60 (diff)
downloadlibssh-2bc8819e8f68014ba35d03e56393e4d0c16386f8.tar.gz
libssh-2bc8819e8f68014ba35d03e56393e4d0c16386f8.tar.xz
libssh-2bc8819e8f68014ba35d03e56393e4d0c16386f8.zip
Changes all CHANNEL * to ssh_channel
-rw-r--r--include/libssh/libssh.h56
-rw-r--r--include/libssh/priv.h22
-rw-r--r--include/libssh/server.h4
-rw-r--r--include/libssh/sftp.h4
-rw-r--r--libssh/channels.c114
-rw-r--r--libssh/channels1.c16
-rw-r--r--libssh/connect.c2
-rw-r--r--libssh/messages.c4
-rw-r--r--libssh/sftp.c2
-rw-r--r--sample.c10
-rw-r--r--samplesshd.c2
11 files changed, 118 insertions, 118 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index 6124c7d0..73ea536d 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -76,8 +76,8 @@ typedef struct ssh_string_struct STRING;
typedef struct ssh_buffer_struct BUFFER;
typedef struct ssh_public_key_struct PUBLIC_KEY;
typedef struct ssh_private_key_struct PRIVATE_KEY;
-#endif
typedef struct ssh_channel_struct CHANNEL;
+#endif
typedef struct ssh_agent_struct AGENT;
//#endif
@@ -257,7 +257,7 @@ ssh_string ssh_get_pubkey(SSH_SESSION *session);
/* in connect.c */
int ssh_fd_poll(SSH_SESSION *session,int *write, int *except);
-int ssh_select(CHANNEL **channels, CHANNEL **outchannels, socket_t maxfd,
+int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
fd_set *readfds, struct timeval *timeout);
void publickey_free(ssh_public_key key);
@@ -276,37 +276,37 @@ int ssh_write_knownhost(SSH_SESSION *session);
/* in channels.c */
-CHANNEL *channel_new(SSH_SESSION *session);
-int channel_open_forward(CHANNEL *channel, const char *remotehost,
+ssh_channel channel_new(SSH_SESSION *session);
+int channel_open_forward(ssh_channel channel, const char *remotehost,
int remoteport, const char *sourcehost, int localport);
-int channel_open_session(CHANNEL *channel);
-void channel_free(CHANNEL *channel);
-int channel_request_pty(CHANNEL *channel);
-int channel_request_pty_size(CHANNEL *channel, const char *term,
+int channel_open_session(ssh_channel channel);
+void channel_free(ssh_channel channel);
+int channel_request_pty(ssh_channel channel);
+int channel_request_pty_size(ssh_channel channel, const char *term,
int cols, int rows);
-int channel_change_pty_size(CHANNEL *channel,int cols,int rows);
-int channel_request_shell(CHANNEL *channel);
-int channel_request_subsystem(CHANNEL *channel, const char *system);
-int channel_request_env(CHANNEL *channel, const char *name, const char *value);
-int channel_request_exec(CHANNEL *channel, const char *cmd);
-int channel_request_sftp(CHANNEL *channel);
-int channel_write(CHANNEL *channel, const void *data, u32 len);
-int channel_send_eof(CHANNEL *channel);
-int channel_is_eof(CHANNEL *channel);
-int channel_read(CHANNEL *channel, void *dest, u32 count, int is_stderr);
-int channel_read_buffer(CHANNEL *channel, ssh_buffer buffer, u32 count,
+int channel_change_pty_size(ssh_channel channel,int cols,int rows);
+int channel_request_shell(ssh_channel channel);
+int channel_request_subsystem(ssh_channel channel, const char *system);
+int channel_request_env(ssh_channel channel, const char *name, const char *value);
+int channel_request_exec(ssh_channel channel, const char *cmd);
+int channel_request_sftp(ssh_channel channel);
+int channel_write(ssh_channel channel, const void *data, u32 len);
+int channel_send_eof(ssh_channel channel);
+int channel_is_eof(ssh_channel channel);
+int channel_read(ssh_channel channel, void *dest, u32 count, int is_stderr);
+int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, u32 count,
int is_stderr);
-int channel_poll(CHANNEL *channel, int is_stderr);
-int channel_close(CHANNEL *channel);
-void channel_set_blocking(CHANNEL *channel, int blocking);
-int channel_read_nonblocking(CHANNEL *channel, void *dest, u32 count,
+int channel_poll(ssh_channel channel, int is_stderr);
+int channel_close(ssh_channel channel);
+void channel_set_blocking(ssh_channel channel, int blocking);
+int channel_read_nonblocking(ssh_channel channel, void *dest, u32 count,
int is_stderr);
-int channel_is_open(CHANNEL *channel);
-int channel_is_closed(CHANNEL *channel);
-int channel_select(CHANNEL **readchans, CHANNEL **writechans, CHANNEL **exceptchans, struct
+int channel_is_open(ssh_channel channel);
+int channel_is_closed(ssh_channel channel);
+int channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct
timeval * timeout);
-SSH_SESSION *channel_get_session(CHANNEL *channel);
-int channel_get_exit_status(CHANNEL *channel);
+SSH_SESSION *channel_get_session(ssh_channel channel);
+int channel_get_exit_status(ssh_channel channel);
/* in options.c */
/**
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index be7185d5..b951cbcd 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -378,7 +378,7 @@ struct ssh_session {
CRYPTO *current_crypto;
CRYPTO *next_crypto; /* next_crypto is going to be used after a SSH2_MSG_NEWKEYS */
- CHANNEL *channels; /* linked list of channels */
+ ssh_channel channels; /* linked list of channels */
int maxchannel;
int exec_channel_opened; /* version 1 only. more
info in channels1.c */
@@ -441,7 +441,7 @@ struct ssh_service_request {
struct ssh_channel_request {
int type;
- CHANNEL *channel;
+ ssh_channel channel;
u8 want_reply;
/* pty-req type specifics */
char *TERM;
@@ -678,11 +678,11 @@ ssh_string ssh_sign_session_id(SSH_SESSION *session, ssh_private_key privatekey)
ssh_string ssh_encrypt_rsa1(SSH_SESSION *session, ssh_string data, ssh_public_key key);
/* channel.c */
void channel_handle(SSH_SESSION *session, int type);
-CHANNEL *channel_new(SSH_SESSION *session);
-int channel_default_bufferize(CHANNEL *channel, void *data, int len,
+ssh_channel channel_new(SSH_SESSION *session);
+int channel_default_bufferize(ssh_channel channel, void *data, int len,
int is_stderr);
u32 ssh_channel_new_id(SSH_SESSION *session);
-CHANNEL *ssh_channel_from_local(SSH_SESSION *session, u32 id);
+ssh_channel ssh_channel_from_local(SSH_SESSION *session, u32 id);
/* options.c */
@@ -788,14 +788,14 @@ const void *_ssh_list_get_head(struct ssh_list *list);
/* channels1.c */
-int channel_open_session1(CHANNEL *channel);
-int channel_request_pty_size1(CHANNEL *channel, const char *terminal,
+int channel_open_session1(ssh_channel channel);
+int channel_request_pty_size1(ssh_channel channel, const char *terminal,
int cols, int rows);
-int channel_change_pty_size1(CHANNEL *channel, int cols, int rows);
-int channel_request_shell1(CHANNEL *channel);
-int channel_request_exec1(CHANNEL *channel, const char *cmd);
+int channel_change_pty_size1(ssh_channel channel, int cols, int rows);
+int channel_request_shell1(ssh_channel channel);
+int channel_request_exec1(ssh_channel channel, const char *cmd);
int channel_handle1(SSH_SESSION *session, int type);
-int channel_write1(CHANNEL *channel, const void *data, int len);
+int channel_write1(ssh_channel channel, const void *data, int len);
/* session.c */
diff --git a/include/libssh/server.h b/include/libssh/server.h
index 915edd8d..0fa8c1b2 100644
--- a/include/libssh/server.h
+++ b/include/libssh/server.h
@@ -162,9 +162,9 @@ char *ssh_message_auth_password(SSH_MESSAGE *msg);
int ssh_message_auth_reply_success(SSH_MESSAGE *msg,int partial);
int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods);
-CHANNEL *ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg);
+ssh_channel ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg);
-CHANNEL *ssh_message_channel_request_channel(SSH_MESSAGE *msg);
+ssh_channel ssh_message_channel_request_channel(SSH_MESSAGE *msg);
// returns the TERM env variable
char *ssh_message_channel_request_pty_term(SSH_MESSAGE *msg);
char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg);
diff --git a/include/libssh/sftp.h b/include/libssh/sftp.h
index e747e881..987c4635 100644
--- a/include/libssh/sftp.h
+++ b/include/libssh/sftp.h
@@ -60,7 +60,7 @@ extern "C" {
typedef struct sftp_session_struct {
SSH_SESSION *session;
- CHANNEL *channel;
+ ssh_channel channel;
int server_version;
int client_version;
int version;
@@ -622,7 +622,7 @@ int sftp_server_version(SFTP_SESSION *sftp);
*
* @return A new sftp server session.
*/
-SFTP_SESSION *sftp_server_new(SSH_SESSION *session, CHANNEL *chan);
+SFTP_SESSION *sftp_server_new(SSH_SESSION *session, ssh_channel chan);
/**
* @brief Intialize the sftp server.
diff --git a/libssh/channels.c b/libssh/channels.c
index e78aa40c..3e578122 100644
--- a/libssh/channels.c
+++ b/libssh/channels.c
@@ -55,14 +55,14 @@
*
* @return A pointer to a newly allocated channel, NULL on error.
*/
-CHANNEL *channel_new(SSH_SESSION *session) {
- CHANNEL *channel = NULL;
+ssh_channel channel_new(SSH_SESSION *session) {
+ ssh_channel channel = NULL;
- channel = malloc(sizeof(CHANNEL));
+ channel = malloc(sizeof(struct ssh_channel_struct));
if (channel == NULL) {
return NULL;
}
- memset(channel,0,sizeof(CHANNEL));
+ memset(channel,0,sizeof(struct ssh_channel_struct));
channel->stdout_buffer = buffer_new();
if (channel->stdout_buffer == NULL) {
@@ -106,7 +106,7 @@ u32 ssh_channel_new_id(SSH_SESSION *session) {
return ++(session->maxchannel);
}
-static int channel_open(CHANNEL *channel, const char *type_c, int window,
+static int channel_open(ssh_channel channel, const char *type_c, int window,
int maxpacket, ssh_buffer payload) {
SSH_SESSION *session = channel->session;
ssh_string type = NULL;
@@ -233,9 +233,9 @@ static int channel_open(CHANNEL *channel, const char *type_c, int window,
}
/* get ssh channel from local session? */
-CHANNEL *ssh_channel_from_local(SSH_SESSION *session, u32 id) {
- CHANNEL *initchan = session->channels;
- CHANNEL *channel;
+ssh_channel ssh_channel_from_local(SSH_SESSION *session, u32 id) {
+ ssh_channel initchan = session->channels;
+ ssh_channel channel;
/* We assume we are always the local */
if (initchan == NULL) {
@@ -252,7 +252,7 @@ CHANNEL *ssh_channel_from_local(SSH_SESSION *session, u32 id) {
return channel;
}
-static int grow_window(SSH_SESSION *session, CHANNEL *channel, int minimumsize) {
+static int grow_window(SSH_SESSION *session, ssh_channel channel, int minimumsize) {
u32 new_window = minimumsize > WINDOWBASE ? minimumsize : WINDOWBASE;
enter_function();
@@ -286,8 +286,8 @@ error:
return -1;
}
-static CHANNEL *channel_from_msg(SSH_SESSION *session) {
- CHANNEL *channel;
+static ssh_channel channel_from_msg(SSH_SESSION *session) {
+ ssh_channel channel;
u32 chan;
if (buffer_get_u32(session->in_buffer, &chan) != sizeof(u32)) {
@@ -307,7 +307,7 @@ static CHANNEL *channel_from_msg(SSH_SESSION *session) {
}
static void channel_rcv_change_window(SSH_SESSION *session) {
- CHANNEL *channel;
+ ssh_channel channel;
u32 bytes;
int rc;
@@ -341,7 +341,7 @@ static void channel_rcv_change_window(SSH_SESSION *session) {
/* is_stderr is set to 1 if the data are extended, ie stderr */
static void channel_rcv_data(SSH_SESSION *session,int is_stderr) {
- CHANNEL *channel;
+ ssh_channel channel;
ssh_string str;
size_t len;
@@ -407,7 +407,7 @@ static void channel_rcv_data(SSH_SESSION *session,int is_stderr) {
}
static void channel_rcv_eof(SSH_SESSION *session) {
- CHANNEL *channel;
+ ssh_channel channel;
enter_function();
@@ -429,7 +429,7 @@ static void channel_rcv_eof(SSH_SESSION *session) {
}
static void channel_rcv_close(SSH_SESSION *session) {
- CHANNEL *channel;
+ ssh_channel channel;
enter_function();
@@ -468,7 +468,7 @@ static void channel_rcv_close(SSH_SESSION *session) {
}
static void channel_rcv_request(SSH_SESSION *session) {
- CHANNEL *channel;
+ ssh_channel channel;
ssh_string request_s;
char *request;
u32 status;
@@ -592,7 +592,7 @@ void channel_handle(SSH_SESSION *session, int type){
*
* FIXME is the window changed?
*/
-int channel_default_bufferize(CHANNEL *channel, void *data, int len,
+int channel_default_bufferize(ssh_channel channel, void *data, int len,
int is_stderr) {
struct ssh_session *session = channel->session;
@@ -642,7 +642,7 @@ int channel_default_bufferize(CHANNEL *channel, void *data, int len,
* @see channel_request_shell()
* @see channel_request_exec()
*/
-int channel_open_session(CHANNEL *channel) {
+int channel_open_session(ssh_channel channel) {
#ifdef HAVE_SSH1
if (channel->session->version == 1) {
return channel_open_session1(channel);
@@ -670,7 +670,7 @@ int channel_open_session(CHANNEL *channel) {
* @return SSH_OK on success\n
* SSH_ERROR on error
*/
-int channel_open_forward(CHANNEL *channel, const char *remotehost,
+int channel_open_forward(ssh_channel channel, const char *remotehost,
int remoteport, const char *sourcehost, int localport) {
SSH_SESSION *session = channel->session;
ssh_buffer payload = NULL;
@@ -721,7 +721,7 @@ error:
*
* @warning Any data unread on this channel will be lost.
*/
-void channel_free(CHANNEL *channel) {
+void channel_free(ssh_channel channel) {
SSH_SESSION *session = channel->session;
enter_function();
@@ -751,7 +751,7 @@ void channel_free(CHANNEL *channel) {
buffer_free(channel->stderr_buffer);
/* debug trick to catch use after frees */
- memset(channel, 'X', sizeof(CHANNEL));
+ memset(channel, 'X', sizeof(struct ssh_channel_struct));
SAFE_FREE(channel);
leave_function();
@@ -770,7 +770,7 @@ void channel_free(CHANNEL *channel) {
* @see channel_close()
* @see channel_free()
*/
-int channel_send_eof(CHANNEL *channel){
+int channel_send_eof(ssh_channel channel){
SSH_SESSION *session = channel->session;
int rc = SSH_ERROR;
@@ -813,7 +813,7 @@ error:
* @see channel_free()
* @see channel_eof()
*/
-int channel_close(CHANNEL *channel){
+int channel_close(ssh_channel channel){
SSH_SESSION *session = channel->session;
int rc = 0;
@@ -865,7 +865,7 @@ error:
*
* @see channel_read()
*/
-int channel_write(CHANNEL *channel, const void *data, u32 len) {
+int channel_write(ssh_channel channel, const void *data, u32 len) {
SSH_SESSION *session = channel->session;
int origlen = len;
int effectivelen;
@@ -955,7 +955,7 @@ error:
*
* @see channel_is_closed()
*/
-int channel_is_open(CHANNEL *channel) {
+int channel_is_open(ssh_channel channel) {
return (channel->open != 0 && channel->session->alive != 0);
}
@@ -968,7 +968,7 @@ int channel_is_open(CHANNEL *channel) {
*
* @see channel_is_open()
*/
-int channel_is_closed(CHANNEL *channel) {
+int channel_is_closed(ssh_channel channel) {
return (channel->open == 0 || channel->session->alive == 0);
}
@@ -979,7 +979,7 @@ int channel_is_closed(CHANNEL *channel) {
*
* @return 0 if there is no EOF, nonzero otherwise.
*/
-int channel_is_eof(CHANNEL *channel) {
+int channel_is_eof(ssh_channel channel) {
if ((channel->stdout_buffer &&
buffer_get_rest_len(channel->stdout_buffer) > 0) ||
(channel->stderr_buffer &&
@@ -1000,11 +1000,11 @@ int channel_is_eof(CHANNEL *channel) {
* @bug This functionnality is still under development and
* doesn't work correctly.
*/
-void channel_set_blocking(CHANNEL *channel, int blocking) {
+void channel_set_blocking(ssh_channel channel, int blocking) {
channel->blocking = (blocking == 0 ? 0 : 1);
}
-static int channel_request(CHANNEL *channel, const char *request,
+static int channel_request(ssh_channel channel, const char *request,
ssh_buffer buffer, int reply) {
SSH_SESSION *session = channel->session;
ssh_string req = NULL;
@@ -1082,7 +1082,7 @@ error:
*
* @return SSH_SUCCESS on success, SSH_ERROR on error.
*/
-int channel_request_pty_size(CHANNEL *channel, const char *terminal,
+int channel_request_pty_size(ssh_channel channel, const char *terminal,
int col, int row) {
SSH_SESSION *session = channel->session;
ssh_string term = NULL;
@@ -1135,7 +1135,7 @@ error:
*
* @see channel_request_pty_size()
*/
-int channel_request_pty(CHANNEL *channel) {
+int channel_request_pty(ssh_channel channel) {
return channel_request_pty_size(channel, "xterm", 80, 24);
}
@@ -1152,7 +1152,7 @@ int channel_request_pty(CHANNEL *channel) {
* sure any other libssh function using the same channel/session
* is running at same time (not 100% threadsafe).
*/
-int channel_change_pty_size(CHANNEL *channel, int cols, int rows) {
+int channel_change_pty_size(ssh_channel channel, int cols, int rows) {
SSH_SESSION *session = channel->session;
ssh_buffer buffer = NULL;
int rc = SSH_ERROR;
@@ -1194,7 +1194,7 @@ error:
*
* @returns SSH_SUCCESS on success, SSH_ERROR on error.
*/
-int channel_request_shell(CHANNEL *channel) {
+int channel_request_shell(ssh_channel channel) {
#ifdef HAVE_SSH1
if (channel->version == 1) {
return channel_request_shell1(channel);
@@ -1214,7 +1214,7 @@ int channel_request_shell(CHANNEL *channel) {
*
* @warning You normally don't have to call it for sftp, see sftp_new().
*/
-int channel_request_subsystem(CHANNEL *channel, const char *sys) {
+int channel_request_subsystem(ssh_channel channel, const char *sys) {
ssh_buffer buffer = NULL;
ssh_string subsystem = NULL;
int rc = SSH_ERROR;
@@ -1241,7 +1241,7 @@ error:
return rc;
}
-int channel_request_sftp( CHANNEL *channel){
+int channel_request_sftp( ssh_channel channel){
return channel_request_subsystem(channel, "sftp");
}
@@ -1258,7 +1258,7 @@ int channel_request_sftp( CHANNEL *channel){
*
* @warning Some environement variables may be refused by security reasons.
* */
-int channel_request_env(CHANNEL *channel, const char *name, const char *value) {
+int channel_request_env(ssh_channel channel, const char *name, const char *value) {
ssh_buffer buffer = NULL;
ssh_string str = NULL;
int rc = SSH_ERROR;
@@ -1309,7 +1309,7 @@ error:
*
* @see channel_request_shell()
*/
-int channel_request_exec(CHANNEL *channel, const char *cmd) {
+int channel_request_exec(ssh_channel channel, const char *cmd) {
ssh_buffer buffer = NULL;
ssh_string command = NULL;
int rc = SSH_ERROR;
@@ -1359,7 +1359,7 @@ error:
*
* @return The number of bytes read, 0 on end of file or SSH_ERROR on error.
*/
-int channel_read_buffer(CHANNEL *channel, ssh_buffer buffer, u32 count,
+int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, u32 count,
int is_stderr) {
SSH_SESSION *session=channel->session;
ssh_buffer stdbuf = channel->stdout_buffer;
@@ -1468,7 +1468,7 @@ int channel_read_buffer(CHANNEL *channel, ssh_buffer buffer, u32 count,
* @warning The read function using a buffer has been renamed to
* channel_read_buffer().
*/
-int channel_read(CHANNEL *channel, void *dest, u32 count, int is_stderr) {
+int channel_read(ssh_channel channel, void *dest, u32 count, int is_stderr) {
SSH_SESSION *session = channel->session;
ssh_buffer stdbuf = channel->stdout_buffer;
u32 len;
@@ -1566,7 +1566,7 @@ int channel_read(CHANNEL *channel, void *dest, u32 count, int is_stderr) {
*
* @see channel_is_eof()
*/
-int channel_read_nonblocking(CHANNEL *channel, void *dest, u32 count,
+int channel_read_nonblocking(ssh_channel channel, void *dest, u32 count,
int is_stderr) {
SSH_SESSION *session = channel->session;
u32 to_read;
@@ -1604,7 +1604,7 @@ int channel_read_nonblocking(CHANNEL *channel, void *dest, u32 count,
*
* @see channel_is_eof()
*/
-int channel_poll(CHANNEL *channel, int is_stderr){
+int channel_poll(ssh_channel channel, int is_stderr){
SSH_SESSION *session = channel->session;
ssh_buffer stdbuf = channel->stdout_buffer;
@@ -1636,7 +1636,7 @@ int channel_poll(CHANNEL *channel, int is_stderr){
*
* @return The session pointer.
*/
-SSH_SESSION *channel_get_session(CHANNEL *channel) {
+SSH_SESSION *channel_get_session(ssh_channel channel) {
return channel->session;
}
@@ -1649,7 +1649,7 @@ SSH_SESSION *channel_get_session(CHANNEL *channel) {
* @return -1 if no exit status has been returned or eof not sent,
* the exit status othewise.
*/
-int channel_get_exit_status(CHANNEL *channel) {
+int channel_get_exit_status(ssh_channel channel) {
if (channel->local_eof == 0) {
return -1;
}
@@ -1676,9 +1676,9 @@ int channel_get_exit_status(CHANNEL *channel) {
* This is made in two parts: protocol select and network select. The protocol
* select does not use the network functions at all
*/
-static int channel_protocol_select(CHANNEL **rchans, CHANNEL **wchans,
- CHANNEL **echans, CHANNEL **rout, CHANNEL **wout, CHANNEL **eout) {
- CHANNEL *chan;
+static int channel_protocol_select(ssh_channel *rchans, ssh_channel *wchans,
+ ssh_channel *echans, ssh_channel *rout, ssh_channel *wout, ssh_channel *eout) {
+ ssh_channel chan;
int i;
int j = 0;
@@ -1725,7 +1725,7 @@ static int channel_protocol_select(CHANNEL **rchans, CHANNEL **wchans,
}
/* Just count number of pointers in the array */
-static int count_ptrs(CHANNEL **ptrs) {
+static int count_ptrs(ssh_channel *ptrs) {
int c;
for (c = 0; ptrs[c] != NULL; c++)
;
@@ -1754,10 +1754,10 @@ static int count_ptrs(CHANNEL **ptrs) {
* @return SSH_SUCCESS operation successful\n
* SSH_EINTR select(2) syscall was interrupted, relaunch the function
*/
-int channel_select(CHANNEL **readchans, CHANNEL **writechans,
- CHANNEL **exceptchans, struct timeval * timeout) {
- CHANNEL **rchans, **wchans, **echans;
- CHANNEL *dummy = NULL;
+int channel_select(ssh_channel *readchans, ssh_channel *writechans,
+ ssh_channel *exceptchans, struct timeval * timeout) {
+ ssh_channel *rchans, **wchans, **echans;
+ ssh_channel dummy = NULL;
fd_set rset;
fd_set wset;
fd_set eset;
@@ -1784,18 +1784,18 @@ int channel_select(CHANNEL **readchans, CHANNEL **writechans,
}
/* Prepare the outgoing temporary arrays */
- rchans = malloc(sizeof(CHANNEL *) * (count_ptrs(readchans) + 1));
+ rchans = malloc(sizeof(ssh_channel ) * (count_ptrs(readchans) + 1));
if (rchans == NULL) {
return SSH_ERROR;
}
- wchans = malloc(sizeof(CHANNEL *) * (count_ptrs(writechans) + 1));
+ wchans = malloc(sizeof(ssh_channel ) * (count_ptrs(writechans) + 1));
if (wchans == NULL) {
SAFE_FREE(rchans);
return SSH_ERROR;
}
- echans = malloc(sizeof(CHANNEL *) * (count_ptrs(exceptchans) + 1));
+ echans = malloc(sizeof(ssh_channel ) * (count_ptrs(exceptchans) + 1));
if (echans == NULL) {
SAFE_FREE(rchans);
SAFE_FREE(wchans);
@@ -1811,9 +1811,9 @@ int channel_select(CHANNEL **readchans, CHANNEL **writechans,
rchans, wchans, echans);
if (rchans[0] != NULL || wchans[0] != NULL || echans[0] != NULL) {
/* We've got one without doing any select overwrite the begining arrays */
- memcpy(readchans, rchans, (count_ptrs(rchans) + 1) * sizeof(CHANNEL *));
- memcpy(writechans, wchans, (count_ptrs(wchans) + 1) * sizeof(CHANNEL *));
- memcpy(exceptchans, echans, (count_ptrs(echans) + 1) * sizeof(CHANNEL *));
+ memcpy(readchans, rchans, (count_ptrs(rchans) + 1) * sizeof(ssh_channel ));
+ memcpy(writechans, wchans, (count_ptrs(wchans) + 1) * sizeof(ssh_channel ));
+ memcpy(exceptchans, echans, (count_ptrs(echans) + 1) * sizeof(ssh_channel ));
SAFE_FREE(rchans);
SAFE_FREE(wchans);
SAFE_FREE(echans);
diff --git a/libssh/channels1.c b/libssh/channels1.c
index 5c80f670..c3db8447 100644
--- a/libssh/channels1.c
+++ b/libssh/channels1.c
@@ -40,7 +40,7 @@
* protocol.
*/
-int channel_open_session1(CHANNEL *chan) {
+int channel_open_session1(ssh_channel chan) {
/*
* We guess we are requesting an *exec* channel. It can only have one exec
* channel. So we abort with an error if we need more than one.
@@ -73,7 +73,7 @@ int channel_open_session1(CHANNEL *chan) {
* much simplier under ssh2. I just hope the defaults values are ok ...
*/
-int channel_request_pty_size1(CHANNEL *channel, const char *terminal, int col,
+int channel_request_pty_size1(ssh_channel channel, const char *terminal, int col,
int row) {
SSH_SESSION *session = channel->session;
ssh_string str = NULL;
@@ -126,7 +126,7 @@ int channel_request_pty_size1(CHANNEL *channel, const char *terminal, int col,
return -1;
}
-int channel_change_pty_size1(CHANNEL *channel, int cols, int rows) {
+int channel_change_pty_size1(ssh_channel channel, int cols, int rows) {
SSH_SESSION *session = channel->session;
if (buffer_add_u8(session->out_buffer, SSH_CMSG_WINDOW_SIZE) < 0 ||
@@ -163,7 +163,7 @@ int channel_change_pty_size1(CHANNEL *channel, int cols, int rows) {
return -1;
}
-int channel_request_shell1(CHANNEL *channel) {
+int channel_request_shell1(ssh_channel channel) {
SSH_SESSION *session = channel->session;
if (buffer_add_u8(session->out_buffer,SSH_CMSG_EXEC_SHELL) < 0) {
@@ -179,7 +179,7 @@ int channel_request_shell1(CHANNEL *channel) {
return 0;
}
-int channel_request_exec1(CHANNEL *channel, const char *cmd) {
+int channel_request_exec1(ssh_channel channel, const char *cmd) {
SSH_SESSION *session = channel->session;
ssh_string command = NULL;
@@ -205,7 +205,7 @@ int channel_request_exec1(CHANNEL *channel, const char *cmd) {
}
static int channel_rcv_data1(SSH_SESSION *session, int is_stderr) {
- CHANNEL *channel = session->channels;
+ ssh_channel channel = session->channels;
ssh_string str = NULL;
str = buffer_get_ssh_string(session->in_buffer);
@@ -229,7 +229,7 @@ static int channel_rcv_data1(SSH_SESSION *session, int is_stderr) {
}
static int channel_rcv_close1(SSH_SESSION *session) {
- CHANNEL *channel = session->channels;
+ ssh_channel channel = session->channels;
u32 status;
buffer_get_u32(session->in_buffer, &status);
@@ -273,7 +273,7 @@ int channel_handle1(SSH_SESSION *session, int type) {
return 0;
}
-int channel_write1(CHANNEL *channel, const void *data, int len) {
+int channel_write1(ssh_channel channel, const void *data, int len) {
SSH_SESSION *session = channel->session;
int origlen = len;
int effectivelen;
diff --git a/libssh/connect.c b/libssh/connect.c
index 91ec0297..d24cbfcf 100644
--- a/libssh/connect.c
+++ b/libssh/connect.c
@@ -353,7 +353,7 @@ socket_t ssh_connect_host(SSH_SESSION *session, const char *host,
*
* @see select(2)
*/
-int ssh_select(CHANNEL **channels, CHANNEL **outchannels, socket_t maxfd,
+int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
fd_set *readfds, struct timeval *timeout) {
struct timeval zerotime;
fd_set localset, localset2;
diff --git a/libssh/messages.c b/libssh/messages.c
index f562d8d7..5c87aa2a 100644
--- a/libssh/messages.c
+++ b/libssh/messages.c
@@ -391,9 +391,9 @@ error:
return NULL;
}
-CHANNEL *ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg) {
+ssh_channel ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg) {
SSH_SESSION *session = msg->session;
- CHANNEL *chan = NULL;
+ ssh_channel chan = NULL;
enter_function();
diff --git a/libssh/sftp.c b/libssh/sftp.c
index 7d585271..2d3cee2a 100644
--- a/libssh/sftp.c
+++ b/libssh/sftp.c
@@ -93,7 +93,7 @@ SFTP_SESSION *sftp_new(SSH_SESSION *session){
}
#ifdef WITH_SERVER
-SFTP_SESSION *sftp_server_new(SSH_SESSION *session, CHANNEL *chan){
+SFTP_SESSION *sftp_server_new(SSH_SESSION *session, ssh_channel chan){
SFTP_SESSION *sftp = NULL;
sftp = malloc(sizeof(SFTP_SESSION));
diff --git a/sample.c b/sample.c
index b98e750c..2d725dc5 100644
--- a/sample.c
+++ b/sample.c
@@ -109,7 +109,7 @@ static void do_exit(int i) {
exit(0);
}
-CHANNEL *chan;
+ssh_channel chan;
int signal_delayed=0;
static void sigwindowchanged(int i){
@@ -129,12 +129,12 @@ static void sizechanged(void){
// printf("Changed pty size\n");
setsignal();
}
-static void select_loop(SSH_SESSION *session,CHANNEL *channel){
+static void select_loop(SSH_SESSION *session,ssh_channel channel){
fd_set fds;
struct timeval timeout;
char buffer[10];
ssh_buffer readbuf=buffer_new();
- CHANNEL *channels[2];
+ ssh_channel channels[2];
int lus;
int eof=0;
int maxfd;
@@ -229,7 +229,7 @@ static void select_loop(SSH_SESSION *session,CHANNEL *channel){
static void shell(SSH_SESSION *session){
- CHANNEL *channel;
+ ssh_channel channel;
struct termios terminal_local;
int interactive=isatty(0);
channel = channel_new(session);
@@ -260,7 +260,7 @@ static void shell(SSH_SESSION *session){
}
static void batch_shell(SSH_SESSION *session){
- CHANNEL *channel;
+ ssh_channel channel;
char buffer[1024];
int i,s=0;
for(i=0;i<MAXCMD && cmds[i];++i)
diff --git a/samplesshd.c b/samplesshd.c
index 10a29fc4..c5d6243f 100644
--- a/samplesshd.c
+++ b/samplesshd.c
@@ -44,7 +44,7 @@ int main(int argc, char **argv){
SSH_SESSION *session;
SSH_BIND *ssh_bind;
SSH_MESSAGE *message;
- CHANNEL *chan=0;
+ ssh_channel chan=0;
ssh_buffer buf;
int auth=0;
int sftp=0;