/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2009 Index Data
+ * Copyright (C) 1995-2011 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 <config.h>
#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
#include <string.h>
#include <errno.h>
#include <stddef.h>
-#include <yaz/nmem.h>
+#include <yaz/errno.h>
#ifdef WIN32
#include <windows.h>
errno = v;
}
-void yaz_strerror(char *buf, int max)
+void yaz_strerror(char *buf, size_t bufsz)
{
#ifdef WIN32
DWORD err;
err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default lang */
(LPTSTR) buf,
- max-1,
+ bufsz-1,
NULL);
}
else
/* 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()));