]> git.sur5r.net Git - openldap/blob - include/ac/string.h
Silence warning in prev commit
[openldap] / include / ac / string.h
1 /* Generic string.h */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2003 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_STRING_H
15 #define _AC_STRING_H
16
17 #ifdef STDC_HEADERS
18 #       include <string.h>
19
20 #else
21 #       ifdef HAVE_STRING_H
22 #               include <string.h>
23 #       endif
24 #       if defined(HAVE_STRINGS_H) && (!defined(HAVE_STRING_H) || defined(BOTH_STRINGS_H))
25 #               include <strings.h>
26 #       endif
27
28 #       ifdef HAVE_MEMORY_H
29 #               include <memory.h>
30 #       endif
31
32 #       ifndef HAVE_STRRCHR
33 #               undef strchr
34 #               define strchr index
35 #               undef strrchr
36 #               define strrchr rindex
37 #       endif
38
39 #       ifndef HAVE_MEMCPY
40 #               undef memcpy
41 #               define memcpy(d, s, n)          ((void) bcopy ((s), (d), (n)))
42 #               undef memmove
43 #               define memmove(d, s, n)         ((void) bcopy ((s), (d), (n)))
44 #       endif
45 #endif
46
47 /* use ldap_pvt_strtok instead of strtok or strtok_r! */
48 LDAP_F(char *) ldap_pvt_strtok LDAP_P(( char *str,
49         const char *delim, char **pos ));
50
51 #ifndef HAVE_STRDUP
52         /* strdup() is missing, declare our own version */
53 #       undef strdup
54 #       define strdup(s) ber_strdup(s)
55 #elif !defined(_WIN32)
56         /* some systems fail to declare strdup */
57         /* Windows does not require this declaration */
58         LDAP_LIBC_F(char *) (strdup)();
59 #endif
60
61 /*
62  * some systems fail to declare strcasecmp() and strncasecmp()
63  * we need them declared so we can obtain pointers to them
64  */
65
66 /* we don't want these declared for Windows or Mingw */
67 #ifndef _WIN32
68 int (strcasecmp)();
69 int (strncasecmp)();
70 #endif
71
72 #ifndef SAFEMEMCPY
73 #       if defined( HAVE_MEMMOVE )
74 #               define SAFEMEMCPY( d, s, n )    memmove((d), (s), (n))
75 #       elif defined( HAVE_BCOPY )
76 #               define SAFEMEMCPY( d, s, n )    bcopy((s), (d), (n))
77 #       else
78                 /* nothing left but memcpy() */
79 #               define SAFEMEMCPY( d, s, n )    memcpy((d), (s), (n))
80 #       endif
81 #endif
82
83 #define AC_MEMCPY( d, s, n ) (SAFEMEMCPY((d),(s),(n)))
84 #define AC_FMEMCPY( d, s, n ) do { \
85                 if((n) == 1) *((char*)(d)) = *((char*)(s)); \
86                 else AC_MEMCPY( (d), (s), (n) ); \
87         } while(0)
88
89 #endif /* _AC_STRING_H */