]> git.sur5r.net Git - openldap/blob - include/ac/errno.h
Import headers with updated notices
[openldap] / include / ac / errno.h
1 /* Generic errno.h */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2001 The OpenLDAP Foundation, Redwood City, California, USA
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.  A copy of this license is available at
10  * http://www.OpenLDAP.org/license.html or in file LICENSE in the
11  * top-level directory of the distribution.
12  */
13
14 #ifndef _AC_ERRNO_H
15 #define _AC_ERRNO_H
16
17 #if defined( HAVE_ERRNO_H )
18 # include <errno.h>
19 #elif defined( HAVE_SYS_ERRNO_H )
20 # include <sys/errno.h>
21 #endif
22
23 #ifndef HAVE_SYS_ERRLIST
24         /* no sys_errlist */
25 #       define          sys_nerr        0
26 #       define          sys_errlist     ((char **)0)
27 #elif DECL_SYS_ERRLIST 
28         /* have sys_errlist but need declaration */
29         LDAP_LIBC_V(int)      sys_nerr;
30         LDAP_LIBC_V(char)    *sys_errlist[];
31 #endif
32
33 #undef _AC_ERRNO_UNKNOWN
34 #define _AC_ERRNO_UNKNOWN "unknown error"
35
36 #ifdef HAVE_SYS_ERRLIST
37         /* this is thread safe */
38 #       define  STRERROR(e) ( (e) > -1 && (e) < sys_nerr \
39                         ? sys_errlist[(e)] : _AC_ERRNO_UNKNOWN )
40
41 #elif defined( HAVE_STRERROR )
42         /* this may not be thread safe */
43         /* and, yes, some implementations of strerror may return NULL */
44 #       define  STRERROR(e) ( strerror(e) \
45                 ? strerror(e) : _AC_ERRNO_UNKNOWN )
46
47 #else
48         /* this is thread safe */
49 #       define  STRERROR(e) ( _AC_ERRNO_UNKNOWN )
50 #endif
51
52 #endif /* _AC_ERRNO_H */