mirror of
https://github.com/upa/mscp.git
synced 2026-02-15 01:34:44 +08:00
cleanup copy codes
This commit is contained in:
37
src/ssh.c
37
src/ssh.c
@@ -243,3 +243,40 @@ void ssh_sftp_close(sftp_session sftp)
|
||||
ssh_disconnect(ssh);
|
||||
ssh_free(ssh);
|
||||
}
|
||||
|
||||
|
||||
/* from libssh/src/channels.c:
|
||||
*
|
||||
* All implementations MUST be able to process packets with an
|
||||
* uncompressed payload length of 32768 bytes or less and a total packet
|
||||
* size of 35000 bytes or less.
|
||||
*/
|
||||
#define CHANNEL_MAX_PACKET 32768
|
||||
|
||||
int sftp_write2(sftp_file sf, const void *buf, size_t len)
|
||||
{
|
||||
int n, ret, nbytes;
|
||||
|
||||
for (nbytes = 0; nbytes < len;) {
|
||||
ret = sftp_write(sf, buf + nbytes,
|
||||
min(len - nbytes, CHANNEL_MAX_PACKET));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
nbytes += ret;
|
||||
}
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
int sftp_read2(sftp_file sf, void *buf, size_t len)
|
||||
{
|
||||
int n, ret, nbytes;
|
||||
|
||||
for (nbytes = 0; nbytes < len;) {
|
||||
ret = sftp_read(sf, buf + nbytes,
|
||||
min(len - nbytes, CHANNEL_MAX_PACKET));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
nbytes += ret;
|
||||
}
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user