diff options
Diffstat (limited to 'Build/source/libs/zziplib/zziplib-0.13.58/zzip/err.c')
-rw-r--r-- | Build/source/libs/zziplib/zziplib-0.13.58/zzip/err.c | 76 |
1 files changed, 44 insertions, 32 deletions
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/err.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/err.c index 2f05bb92247..1ba869bd9af 100644 --- a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/err.c +++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/err.c @@ -1,3 +1,4 @@ + /* * Author: * Guido Draheim <guidod@gmx.de> @@ -11,7 +12,7 @@ * of the Mozilla Public License 1.1 */ -#include <zzip/lib.h> /* exported... */ +#include <zzip/lib.h> /* exported... */ #include <zlib.h> #include <string.h> @@ -19,6 +20,7 @@ #include <zzip/file.h> +/* *INDENT-OFF* */ static struct errlistentry { int code; const char* mesg; } errlist[] = { @@ -39,6 +41,8 @@ errlist[] = { ZZIP_DIR_LARGEFILE, "Directory is largefile variant" }, { 0, 0 }, }; +/* *INDENT-ON* */ + #define errlistSIZE (sizeof(errlist)/sizeof(*errlist)) @@ -50,29 +54,30 @@ errlist[] = * or it can be an error code from => libzzip, which is an * negative value lower than => ZZIP_ERROR */ -zzip_char_t* +zzip_char_t * zzip_strerror(int errcode) { - if (errcode < ZZIP_ERROR && errcode > ZZIP_ERROR-32) - { - struct errlistentry* err = errlist; - for (; err->mesg ; err++) - { - if (err->code == errcode) - return err->mesg; - } - errcode = EINVAL; - } - - if (errcode < 0) - { - if (errcode == -1) - return strerror(errcode); - else - return zError(errcode); - } - - return strerror (errcode); + if (errcode < ZZIP_ERROR && errcode > ZZIP_ERROR - 32) + { + struct errlistentry *err = errlist; + + for (; err->mesg; err++) + { + if (err->code == errcode) + return err->mesg; + } + errcode = EINVAL; + } + + if (errcode < 0) + { + if (errcode == -1) + return strerror(errcode); + else + return zError(errcode); + } + + return strerror(errcode); } /** => zzip_strerror @@ -80,13 +85,15 @@ zzip_strerror(int errcode) * runs it through => zzip_strerror to obtain the static string * describing the error. */ -zzip_char_t* -zzip_strerror_of(ZZIP_DIR* dir) +zzip_char_t * +zzip_strerror_of(ZZIP_DIR * dir) { - if (! dir) return strerror (errno); + if (! dir) + return strerror(errno); return zzip_strerror(dir->errcode); } +/* *INDENT-OFF* */ static struct errnolistentry { int code; int e_no; } errnolist[] = { @@ -126,6 +133,7 @@ errnolist[] = { ZZIP_UNDEF, EINVAL }, { 0, 0 }, }; +/* *INDENT-ON* */ /** * map the error code to a system error code. This is used @@ -137,16 +145,20 @@ errnolist[] = int zzip_errno(int errcode) { - if (errcode >= -1) return errno; - - { struct errnolistentry* err = errnolist; - for (; err->code ; err++) + if (errcode >= -1) + { + return errno; + } else + { + struct errnolistentry *err = errnolist; + + for (; err->code; err++) { - if (err->code == errcode) - return err->e_no; + if (err->code == errcode) + return err->e_no; } + return EINVAL; } - return EINVAL; } /* |