Back to index

openldap  2.4.31
errno.h
Go to the documentation of this file.
00001 /* Generic errno.h */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 1998-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 
00017 #ifndef _AC_ERRNO_H
00018 #define _AC_ERRNO_H
00019 
00020 #if defined( HAVE_ERRNO_H )
00021 # include <errno.h>
00022 #elif defined( HAVE_SYS_ERRNO_H )
00023 # include <sys/errno.h>
00024 #endif
00025 
00026 #ifndef HAVE_SYS_ERRLIST
00027        /* no sys_errlist */
00028 #      define        sys_nerr      0
00029 #      define        sys_errlist   ((char **)0)
00030 #elif defined( DECL_SYS_ERRLIST )
00031        /* have sys_errlist but need declaration */
00032        LDAP_LIBC_V(int)      sys_nerr;
00033        LDAP_LIBC_V(char)    *sys_errlist[];
00034 #endif
00035 
00036 #undef _AC_ERRNO_UNKNOWN
00037 #define _AC_ERRNO_UNKNOWN "unknown error"
00038 
00039 #ifdef HAVE_SYS_ERRLIST
00040        /* this is thread safe */
00041 #      define STRERROR(e) ( (e) > -1 && (e) < sys_nerr \
00042                      ? sys_errlist[(e)] : _AC_ERRNO_UNKNOWN )
00043 
00044 #elif defined( HAVE_STRERROR )
00045        /* this may not be thread safe */
00046        /* and, yes, some implementations of strerror may return NULL */
00047 #      define STRERROR(e) ( strerror(e) \
00048               ? strerror(e) : _AC_ERRNO_UNKNOWN )
00049 
00050 #else
00051        /* this is thread safe */
00052 #      define STRERROR(e) ( _AC_ERRNO_UNKNOWN )
00053 #endif
00054 
00055 #endif /* _AC_ERRNO_H */