mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-30 13:01:23 +03:00
channel: Reformat ssh_channel_new()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
@@ -76,44 +76,47 @@ static ssh_channel channel_from_msg(ssh_session session, ssh_buffer packet);
|
|||||||
*
|
*
|
||||||
* @return A pointer to a newly allocated channel, NULL on error.
|
* @return A pointer to a newly allocated channel, NULL on error.
|
||||||
*/
|
*/
|
||||||
ssh_channel ssh_channel_new(ssh_session session) {
|
ssh_channel ssh_channel_new(ssh_session session)
|
||||||
ssh_channel channel = NULL;
|
{
|
||||||
|
ssh_channel channel = NULL;
|
||||||
|
|
||||||
if(session == NULL) {
|
if (session == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel = malloc(sizeof(struct ssh_channel_struct));
|
channel = malloc(sizeof(struct ssh_channel_struct));
|
||||||
if (channel == NULL) {
|
if (channel == NULL) {
|
||||||
ssh_set_error_oom(session);
|
ssh_set_error_oom(session);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(channel,0,sizeof(struct ssh_channel_struct));
|
memset(channel,0,sizeof(struct ssh_channel_struct));
|
||||||
|
|
||||||
channel->stdout_buffer = ssh_buffer_new();
|
channel->stdout_buffer = ssh_buffer_new();
|
||||||
if (channel->stdout_buffer == NULL) {
|
if (channel->stdout_buffer == NULL) {
|
||||||
ssh_set_error_oom(session);
|
ssh_set_error_oom(session);
|
||||||
SAFE_FREE(channel);
|
SAFE_FREE(channel);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel->stderr_buffer = ssh_buffer_new();
|
channel->stderr_buffer = ssh_buffer_new();
|
||||||
if (channel->stderr_buffer == NULL) {
|
if (channel->stderr_buffer == NULL) {
|
||||||
ssh_set_error_oom(session);
|
ssh_set_error_oom(session);
|
||||||
ssh_buffer_free(channel->stdout_buffer);
|
ssh_buffer_free(channel->stdout_buffer);
|
||||||
SAFE_FREE(channel);
|
SAFE_FREE(channel);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel->session = session;
|
channel->session = session;
|
||||||
channel->exit_status = -1;
|
channel->exit_status = -1;
|
||||||
channel->flags = SSH_CHANNEL_FLAG_NOT_BOUND;
|
channel->flags = SSH_CHANNEL_FLAG_NOT_BOUND;
|
||||||
|
|
||||||
if(session->channels == NULL) {
|
if (session->channels == NULL) {
|
||||||
session->channels = ssh_list_new();
|
session->channels = ssh_list_new();
|
||||||
}
|
}
|
||||||
ssh_list_prepend(session->channels, channel);
|
|
||||||
return channel;
|
ssh_list_prepend(session->channels, channel);
|
||||||
|
|
||||||
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user