mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09:00
Improve sftp_reply_names_add.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@625 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -654,8 +654,8 @@ STRING *sftp_handle_alloc(SFTP_SESSION *sftp, void *info);
|
|||||||
int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr);
|
int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr);
|
||||||
void *sftp_handle(SFTP_SESSION *sftp, STRING *handle);
|
void *sftp_handle(SFTP_SESSION *sftp, STRING *handle);
|
||||||
int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, u32 status, char *message);
|
int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, u32 status, char *message);
|
||||||
int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, char *file, char *longname,
|
int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, const char *file,
|
||||||
SFTP_ATTRIBUTES *attr);
|
const char *longname, SFTP_ATTRIBUTES *attr);
|
||||||
int sftp_reply_names(SFTP_CLIENT_MESSAGE *msg);
|
int sftp_reply_names(SFTP_CLIENT_MESSAGE *msg);
|
||||||
int sftp_reply_data(SFTP_CLIENT_MESSAGE *msg, void *data, int len);
|
int sftp_reply_data(SFTP_CLIENT_MESSAGE *msg, void *data, int len);
|
||||||
void sftp_handle_remove(SFTP_SESSION *sftp, void *handle);
|
void sftp_handle_remove(SFTP_SESSION *sftp, void *handle);
|
||||||
|
|||||||
@@ -294,19 +294,42 @@ int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, char *file, char *longname,
|
int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, const char *file,
|
||||||
SFTP_ATTRIBUTES *attr){
|
const char *longname, SFTP_ATTRIBUTES *attr) {
|
||||||
STRING *name=string_from_char(file);
|
STRING *name;
|
||||||
if(!msg->attrbuf)
|
|
||||||
msg->attrbuf=buffer_new();
|
name = string_from_char(file);
|
||||||
buffer_add_ssh_string(msg->attrbuf,name);
|
if (name == NULL) {
|
||||||
free(name);
|
return -1;
|
||||||
name=string_from_char(longname);
|
}
|
||||||
buffer_add_ssh_string(msg->attrbuf,name);
|
|
||||||
free(name);
|
if (msg->attrbuf == NULL) {
|
||||||
buffer_add_attributes(msg->attrbuf,attr);
|
msg->attrbuf = buffer_new();
|
||||||
msg->attr_num++;
|
if (msg->attrbuf == NULL) {
|
||||||
return 0;
|
string_free(name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buffer_add_ssh_string(msg->attrbuf, name) < 0) {
|
||||||
|
string_free(name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
string_free(name);
|
||||||
|
name = string_from_char(longname);
|
||||||
|
if (name == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (buffer_add_ssh_string(msg->attrbuf,name) < 0 ||
|
||||||
|
buffer_add_attributes(msg->attrbuf,attr) < 0) {
|
||||||
|
string_free(name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
string_free(name);
|
||||||
|
msg->attr_num++;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sftp_reply_names(SFTP_CLIENT_MESSAGE *msg){
|
int sftp_reply_names(SFTP_CLIENT_MESSAGE *msg){
|
||||||
|
|||||||
Reference in New Issue
Block a user