Changed SILC code to use new SRT and SCT APIs.
[silc.git] / lib / silcsftp / sftp_util.c
index 6aa40dbe9aff2dd28db61a40ac91df48ac0442ad..6ec07bba94c2aec6b414bde5dcaa5cdf8f7f0cfb 100644 (file)
@@ -4,7 +4,7 @@
 
   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
@@ -90,7 +90,8 @@ SilcBuffer silc_sftp_packet_encode_vp(SilcSFTPPacket packet,
 
 /* 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,
@@ -111,7 +112,7 @@ SilcSFTPPacket silc_sftp_packet_decode(SilcBuffer packet,
     return 0;
 
   if (len > (silc_buffer_len(packet) - 5))
-    return 0;
+    return -1;
 
   silc_buffer_pull(packet, 5);
   ret = silc_buffer_unformat(packet,
@@ -474,7 +475,7 @@ void silc_sftp_name_free(SilcSFTPName name)
 
 /* Maps errno to SFTP status message. */
 
-SilcSFTPStatus silc_sftp_map_errno(int err)
+SilcSFTPStatus silc_sftp_map_errno(SilcResult err)
 {
   SilcSFTPStatus ret;
 
@@ -482,18 +483,15 @@ SilcSFTPStatus silc_sftp_map_errno(int err)
   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: