1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-07-16 08:41:51 +03:00

Make the transfer buffer size configurable

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I5052bac703b5a0c289ca5c28569cadeb54d3d507
This commit is contained in:
Xiang Xiao
2021-05-10 02:00:24 +08:00
committed by Jakub Jelen
parent 14276f0b51
commit dbe504ea0a
11 changed files with 53 additions and 15 deletions

View File

@ -29,11 +29,13 @@ clients must be made or how a client should react.
#include "examples_common.h"
#ifdef WITH_SFTP
#ifndef BUF_SIZE
#define BUF_SIZE 65536
#endif
static int verbosity;
static char *destination;
#define DATALEN 65536
static void do_sftp(ssh_session session) {
sftp_session sftp = sftp_new(session);
sftp_dir dir;
@ -44,7 +46,7 @@ static void do_sftp(ssh_session session) {
sftp_file to;
int len = 1;
unsigned int i;
char data[DATALEN] = {0};
char data[BUF_SIZE] = {0};
char *lnk;
unsigned int count;
@ -223,9 +225,9 @@ static void do_sftp(ssh_session session) {
to = sftp_open(sftp, "/tmp/grosfichier", O_WRONLY|O_CREAT, 0644);
for (i = 0; i < 1000; ++i) {
len = sftp_write(to, data, DATALEN);
len = sftp_write(to, data, sizeof(data));
printf("wrote %d bytes\n", len);
if (len != DATALEN) {
if (len != sizeof(data)) {
printf("chunk %d : %d (%s)\n", i, len, ssh_get_error(session));
}
}