1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
Copyright (C) 2008 Andreas Baumann <abaumann@yahoo.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WOLF_STRING_H
#define WOLF_STRING_H
/**
* @addtogroup wolf_port Porting
* @{
*/
/**
* @file string.h
* @brief nivelate things found in string.h, strings.h
* @author Andreas Baumann <abaumann@yahoo.com>
*/
#include "port/sys.h"
#include <string.h>
/* on some platforms we must also include the old strings.h to get
* functions like str(n)casecmp */
#ifdef HAVE_STRINGS_H
#include <strings.h> /* for strcasecmp and strncasecmp */
#endif
#include <sys/types.h> /* for size_t */
#if defined _WIN32
#include <memory.h> /* for memcpy */
#endif
#if !defined HAVE_STRDUP || defined TEST_STRDUP
char *wolf_port_strdup( const char *s );
#endif
#if !defined HAVE_STRDUP
#define strdup wolf_port_strdup
#endif
#if !defined HAVE_STRERROR_R || defined TEST_STRERROR_R
int wolf_port_strerror_r( int num, char *buf, size_t buflen );
#endif
#if !defined HAVE_STRERROR_R
#define strerror_r( errnum, buf, buflen ) wolf_port_strerror_r( errnum, buf, buflen )
#endif
#if !defined HAVE_STRCASECMP || defined TEST_STRCASECMP
int wolf_port_strcasecmp( const char *s1, const char *s2 );
#endif
#if !defined HAVE_STRCASECMP
#define strcasecmp( s1, s2 ) wolf_port_strcasecmp( s1, s2 )
#endif
#if !defined HAVE_STRNCASECMP || defined TEST_STRNCASECMP
int wolf_port_strncasecmp( const char *s1, const char *s2, size_t n );
#endif
#if !defined HAVE_STRNCASECMP
#define strncasecmp( s1, s2, n ) wolf_port_strncasecmp( s1, s2, n )
#endif
#if !defined HAVE_STRLCPY || defined TEST_STRLCPY
size_t wolf_port_strlcpy( char *d, const char *s, size_t bufsize );
#endif
#if !defined HAVE_STRLCPY
#define strlcpy( d, s, bufsize ) wolf_port_strlcpy( d, s, bufsize )
#else
#if defined MUST_DEFINE_STRLCPY_PROTOTYPE
size_t strlcpy( char *d, const char *s, size_t bufsize );
#endif
#endif
#if !defined HAVE_STRLCAT || defined TEST_STRLCAT
size_t wolf_port_strlcat( char *d, const char *s, size_t bufsize );
#endif
#if !defined HAVE_STRLCAT
#define strlcat( d, s, bufsize ) wolf_port_strlcat( d, s, bufsize )
#else
#if defined MUST_DEFINE_STRLCAT_PROTOTYPE
size_t strlcat( char *d, const char *s, size_t bufsize );
#endif
#endif
/** @} */ /* @addtogroup wolf_port */
#endif /* ifndef WOLF_STRING_H */
|