]> git.sur5r.net Git - openldap/blob - include/ac/string.h
Add prototypes for strerror/strerror_r.
[openldap] / include / ac / string.h
1 /* Generic string.h */
2 /*
3  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted only
7  * as authorized by the OpenLDAP Public License.  A copy of this
8  * license is available at http://www.OpenLDAP.org/license.html or
9  * in file LICENSE in the top-level directory of the distribution.
10  */
11
12 #ifndef _AC_STRING_H
13 #define _AC_STRING_H
14
15 #ifdef STDC_HEADERS
16 #       include <string.h>
17
18 #else
19 #       ifdef HAVE_STRING_H
20 #               include <string.h>
21 #       elif HAVE_STRINGS_H
22 #               include <strings.h>
23 #       endif
24
25 #       ifdef HAVE_MEMORY_H
26 #               include <memory.h>
27 #       endif
28
29 #       ifndef HAVE_STRRCHR
30 #               undef strchr
31 #               define strchr index
32 #               undef strrchr
33 #               define strrchr rindex
34 #       endif
35
36 #       ifndef HAVE_MEMCPY
37 #               undef memcpy
38 #               define memcpy(d, s, n)          ((void) bcopy ((s), (d), (n)))
39 #               undef memmove
40 #               define memmove(d, s, n)         ((void) bcopy ((s), (d), (n)))
41 #       endif
42 #endif
43
44 /* use ldap_pvt_strtok instead of strtok or strtok_r! */
45 LDAP_F(char *) ldap_pvt_strtok LDAP_P((
46         char *str, const char *delim, char **pos ));
47
48 LDAP_F(char *) ldap_pvt_strdup LDAP_P((
49         const char * s ));
50
51 #ifndef HAVE_STRDUP
52         /* strdup() is missing, declare our own version */
53 #       undef strdup
54 #       define strdup(s) ldap_pvt_strdup(s)
55 #else
56         /* some systems fail to declare strdup */
57         extern char *(strdup)();
58 #endif
59
60 /*
61  * some systems fail to declare strcasecmp() and strncasecmp()
62  * we need them declared so we can obtain pointers to them
63  */
64 extern int (strcasecmp)();
65 extern int (strncasecmp)();
66
67 #ifndef SAFEMEMCPY
68 #       if defined( HAVE_MEMMOVE )
69 #               define SAFEMEMCPY( d, s, n )    memmove((d), (s), (n))
70 #       elif defined( HAVE_BCOPY )
71 #               define SAFEMEMCPY( d, s, n )    bcopy((s), (d), (n))
72 #       else
73                 /* nothing left but memcpy() */
74 #               define SAFEMEMCPY( d, s, n )    memcpy((d), (s), (n))
75 #       endif
76 #endif
77
78 #endif /* _AC_STRING_H */