sftp: more flexibility on channels

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Aris Adamantiadis
2013-06-02 18:40:13 +02:00
committed by Andreas Schneider
parent 7e7910a1ca
commit 31a129ee9e
3 changed files with 51 additions and 4 deletions

View File

@@ -149,6 +149,37 @@ sftp_session sftp_new(ssh_session session){
return sftp;
}
sftp_session sftp_new_channel(ssh_session session, ssh_channel channel){
sftp_session sftp;
if (session == NULL) {
return NULL;
}
enter_function();
sftp = malloc(sizeof(struct sftp_session_struct));
if (sftp == NULL) {
ssh_set_error_oom(session);
leave_function();
return NULL;
}
ZERO_STRUCTP(sftp);
sftp->ext = sftp_ext_new();
if (sftp->ext == NULL) {
ssh_set_error_oom(session);
SAFE_FREE(sftp);
leave_function();
return NULL;
}
sftp->session = session;
sftp->channel = channel;
leave_function();
return sftp;
}
#ifdef WITH_SERVER
sftp_session sftp_server_new(ssh_session session, ssh_channel chan){
sftp_session sftp = NULL;

View File

@@ -263,9 +263,10 @@ void sftp_client_message_set_filename(sftp_client_message msg, const char *newna
msg->filename = strdup(newname);
}
char *sftp_client_message_get_data(sftp_client_message msg){
char *str = ssh_string_to_char(msg->data);
return str;
const char *sftp_client_message_get_data(sftp_client_message msg){
if (msg->str_data == NULL)
msg->str_data = ssh_string_to_char(msg->data);
return msg->str_data;
}
uint32_t sftp_client_message_get_flags(sftp_client_message msg){
@@ -282,6 +283,7 @@ void sftp_client_message_free(sftp_client_message msg) {
ssh_string_free(msg->handle);
sftp_attributes_free(msg->attr);
ssh_buffer_free(msg->complete_message);
SAFE_FREE(msg->str_data);
ZERO_STRUCTP(msg);
SAFE_FREE(msg);
}