]> git.sur5r.net Git - openldap/blob - ac/string.h
Do not require ac/string.h for lber_pvt.h
[openldap] / ac / string.h
1 /* Generic string.h */
2
3 #ifndef _AC_STRING_H
4 #define _AC_STRING_H
5
6 #ifdef STDC_HEADERS
7 #       include <string.h>
8
9 #else
10 #       ifdef HAVE_STRING_H
11 #               include <string.h>
12 #       elif HAVE_STRINGS_H
13 #               include <strings.h>
14 #       endif
15
16 #       ifdef HAVE_MEMORY_H
17 #               include <memory.h>
18 #       endif
19
20         /* we should actually create <ac/stdlib.h> */
21 #       ifdef HAVE_MALLOC_H
22 #               include <malloc.h>
23 #       endif
24
25 #       ifndef HAVE_STRRCHR
26 #               define strchr index
27 #               define strrchr rindex
28 #       endif
29
30 #       ifndef HAVE_MEMCPY
31 #               define memcpy(d, s, n)                  bcopy ((s), (d), (n))
32 #               define memmove(d, s, n)                 bcopy ((s), (d), (n))
33 #       endif
34 #endif
35
36 #ifndef HAVE_STRDUP
37         /* strdup() is missing, declare our own version */
38         extern char *strdup( const char *s );
39 #else
40         /* some systems fail to declare strdup altogether */
41         extern char *strdup();
42 #endif
43
44 /*
45  * some systems fail to declare strcasecmp() and strncasecmp()
46  * we need them defined so we obtain pointers to them
47  */
48 extern int strcasecmp(), strncasecmp();
49
50 #ifndef SAFEMEMCPY
51 #       if defined( HAVE_MEMMOVE )
52 #               define SAFEMEMCPY( d, s, n )    memmove((d), (s), (n))
53 #       elif defined( HAVE_BCOPY )
54 #               define SAFEMEMCPY( d, s, n )    bcopy((s), (d), (n))
55 #       else
56                 /* nothing left but memcpy() */
57 #               define SAFEMEMCPY( d, s, n )    memcpy((d), (s), (n))
58 #       endif
59 #endif
60
61
62 #endif /* _AC_STRING_H */