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