]> git.sur5r.net Git - openldap/blob - include/ac/string.h
96056c2aa0125b009637d4bc1be8a4d2dd9e7f32
[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         /* we should actually create <ac/stdlib.h> */
30 #       ifdef HAVE_MALLOC_H
31 #               include <malloc.h>
32 #       endif
33
34 #       ifndef HAVE_STRRCHR
35 #               undef strchr
36 #               define strchr index
37 #               undef strrchr
38 #               define strrchr rindex
39 #       endif
40
41 #       ifndef HAVE_MEMCPY
42 #               undef memcpy
43 #               define memcpy(d, s, n)          ((void) bcopy ((s), (d), (n)))
44 #               undef memmove
45 #               define memmove(d, s, n)         ((void) bcopy ((s), (d), (n)))
46 #       endif
47 #endif
48
49 /* use ldap_pvt_strtok instead of strtok or strtok_r! */
50 extern char *ldap_pvt_strtok( char *str, const char *delim, char **pos );
51
52 extern char *ldap_pvt_strdup( const char * s );
53 #ifndef HAVE_STRDUP
54         /* strdup() is missing, declare our own version */
55 #       undef strdup
56 #       define strdup(s) ldap_pvt_strdup(s)
57 #else
58         /* some systems fail to declare strdup */
59         extern char *(strdup)();
60 #endif
61
62 /*
63  * some systems fail to declare strcasecmp() and strncasecmp()
64  * we need them declared so we can obtain pointers to them
65  */
66 extern int (strcasecmp)();
67 extern int (strncasecmp)();
68
69 #ifndef SAFEMEMCPY
70 #       if defined( HAVE_MEMMOVE )
71 #               define SAFEMEMCPY( d, s, n )    memmove((d), (s), (n))
72 #       elif defined( HAVE_BCOPY )
73 #               define SAFEMEMCPY( d, s, n )    bcopy((s), (d), (n))
74 #       else
75                 /* nothing left but memcpy() */
76 #               define SAFEMEMCPY( d, s, n )    memcpy((d), (s), (n))
77 #       endif
78 #endif
79
80
81 #endif /* _AC_STRING_H */