From 314e61e545a95896e51415fcc38faa5bff4af40d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 24 Aug 2009 22:27:11 +0200 Subject: [PATCH] change transport to use unified error codes I added three new public error codes, and then modified the return codes we use in the transport layer to use the generic error codes so that there won't be any risk of internal confusions due to different error code sets. --- include/libssh2.h | 3 +++ src/libssh2_priv.h | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/libssh2.h b/include/libssh2.h index 8c97dc60..8274eda5 100644 --- a/include/libssh2.h +++ b/include/libssh2.h @@ -356,6 +356,9 @@ typedef struct _LIBSSH2_POLLFD { #define LIBSSH2_ERROR_PUBLICKEY_PROTOCOL -36 #define LIBSSH2_ERROR_EAGAIN -37 #define LIBSSH2_ERROR_BUFFER_TOO_SMALL -38 +#define LIBSSH2_ERROR_BAD_USE -39 +#define LIBSSH2_ERROR_COMPRESS -40 +#define LIBSSH2_ERROR_OUT_OF_BOUNDARY -41 /* Session API */ LIBSSH2_API LIBSSH2_SESSION * diff --git a/src/libssh2_priv.h b/src/libssh2_priv.h index d845d286..7dedfe29 100644 --- a/src/libssh2_priv.h +++ b/src/libssh2_priv.h @@ -1154,18 +1154,19 @@ ssize_t _libssh2_send(libssh2_socket_t socket, const void *buffer, size_t length int _libssh2_wait_socket(LIBSSH2_SESSION *session); -/* CAUTION: some of these error codes are returned in the public API and is - there known with other #defined names from the public header file. They - should not be changed. */ +/* These started out as private return codes for the transport layer, but was + converted to using the library-wide return codes to easy propagation of the + error reasons all over etc without risking mixups. The PACKET_* names are + left only to reduce the impact of changing the code all over.*/ -#define PACKET_TIMEOUT -7 -#define PACKET_BADUSE -6 -#define PACKET_COMPRESS -5 -#define PACKET_TOOBIG -4 -#define PACKET_ENOMEM -3 +#define PACKET_TIMEOUT LIBSSH2_ERROR_TIMEOUT +#define PACKET_BADUSE LIBSSH2_ERROR_BAD_USE +#define PACKET_COMPRESS LIBSSH2_ERROR_COMPRESS +#define PACKET_TOOBIG LIBSSH2_ERROR_OUT_OF_BOUNDARY +#define PACKET_ENOMEM LIBSSH2_ERROR_ALLOC #define PACKET_EAGAIN LIBSSH2_ERROR_EAGAIN -#define PACKET_FAIL -1 -#define PACKET_NONE 0 +#define PACKET_FAIL LIBSSH2_ERROR_SOCKET_NONE +#define PACKET_NONE LIBSSH2_ERROR_NONE libssh2pack_t _libssh2_packet_read(LIBSSH2_SESSION * session);