X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ferrno.c;h=8e8cd59f2151534276e5c7684c71815f9f028db7;hp=6cadb0415e14587dd15c1da9d98cf5576871f47e;hb=77c5a4fca8b516fd39b8ba213daed17a465a6b2a;hpb=f0128dd11d08d79384a97a13e44476769b061f4f diff --git a/src/errno.c b/src/errno.c index 6cadb04..8e8cd59 100644 --- a/src/errno.c +++ b/src/errno.c @@ -1,18 +1,19 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2009 Index Data + * Copyright (C) 1995-2012 Index Data * See the file LICENSE for details. */ /** * \file errno.c * \brief errno utilities + * + * This file unlike other files in YAZ core is thread-aware, due to + * the use errno. */ #if HAVE_CONFIG_H #include #endif -/* prepare for threads.. even in non-threaded appliactions. - The yaz_errno/yaz_set_errno is part of core YAZ and shared */ #ifndef _REENTRANT #define _REENTRANT #endif @@ -21,7 +22,7 @@ #include #include #include -#include +#include #ifdef WIN32 #include @@ -37,7 +38,7 @@ void yaz_set_errno(int v) errno = v; } -void yaz_strerror(char *buf, int max) +void yaz_strerror(char *buf, size_t bufsz) { #ifdef WIN32 DWORD err; @@ -53,7 +54,7 @@ void yaz_strerror(char *buf, int max) err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default lang */ (LPTSTR) buf, - max-1, + bufsz-1, NULL); } else @@ -62,7 +63,7 @@ void yaz_strerror(char *buf, int max) /* UNIX */ #if HAVE_STRERROR_R *buf = '\0'; - strerror_r(errno, buf, max); + strerror_r(errno, buf, bufsz); /* if buffer is unset - use strerror anyway (GLIBC bug) */ if (*buf == '\0') strcpy(buf, strerror(yaz_errno()));