Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 - 2007 Pekka Riikonen
+ Copyright (C) 2001 - 2008 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* Decodes the SFTP packet data `packet' and return the SFTP packet type.
The payload of the packet is returned to the `payload' pointer. Returns
- 0 if error occurred during decoding. */
+ 0 if error occurred during decoding and -1 if partial packet was
+ received. */
SilcSFTPPacket silc_sftp_packet_decode(SilcBuffer packet,
unsigned char **payload,
return 0;
if (len > (silc_buffer_len(packet) - 5))
- return 0;
+ return -1;
silc_buffer_pull(packet, 5);
ret = silc_buffer_unformat(packet,
/* Maps errno to SFTP status message. */
-SilcSFTPStatus silc_sftp_map_errno(int err)
+SilcSFTPStatus silc_sftp_map_errno(SilcResult err)
{
SilcSFTPStatus ret;
case 0:
ret = SILC_SFTP_STATUS_OK;
break;
- case ENOENT:
- case ENOTDIR:
- case EBADF:
+ case SILC_ERR_NOT_DIRECTORY:
+ case SILC_ERR_NO_SUCH_FILE:
+ case SILC_ERR_BAD_FD:
ret = SILC_SFTP_STATUS_NO_SUCH_FILE;
break;
- case EPERM:
- case EACCES:
- case EFAULT:
+ case SILC_ERR_PERMISSION_DENIED:
ret = SILC_SFTP_STATUS_PERMISSION_DENIED;
break;
- case ENAMETOOLONG:
- case EINVAL:
+ case SILC_ERR_INVALID_ARGUMENT:
ret = SILC_SFTP_STATUS_BAD_MESSAGE;
break;
default: