source: mainline/uspace/lib/posix/string.h@ 4d10fc8

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 4d10fc8 was 4d10fc8, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 14 years ago

Add LIBPOSIX_INTERNAL macro to avoid unnecessary undefines

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 * Copyright (c) 2011 Petr Koupy
3 * Copyright (c) 2011 Jiri Zarevucky
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup libposix
31 * @{
32 */
33/** @file
34 */
35
36#ifndef POSIX_STRING_H_
37#define POSIX_STRING_H_
38
39#include <mem.h>
40#include <str.h>
41
42#ifndef NULL
43 #define NULL ((void *) 0)
44#endif
45
46/* Copying and Concatenation */
47extern char *posix_strcpy(char *restrict dest, const char *restrict src);
48extern char *posix_strncpy(char *restrict dest, const char *restrict src, size_t n);
49extern char *posix_strcat(char *restrict dest, const char *restrict src);
50extern char *posix_strncat(char *restrict dest, const char *restrict src, size_t n);
51extern void *posix_mempcpy(void *restrict dest, const void *restrict src, size_t n);
52extern char *posix_strdup(const char *s);
53
54/* String/Array Comparison */
55extern int posix_memcmp(const void *mem1, const void *mem2, size_t n);
56extern int posix_strcmp(const char *s1, const char *s2);
57extern int posix_strncmp(const char *s1, const char *s2, size_t n);
58extern int posix_strcasecmp(const char *s1, const char *s2);
59extern int posix_strncasecmp(const char *s1, const char *s2, size_t n);
60
61/* Search Functions */
62extern void *posix_memchr(const void *mem, int c, size_t n);
63extern void *posix_rawmemchr(const void *mem, int c);
64extern char *posix_strchr(const char *s, int c);
65extern char *posix_strrchr(const char *s, int c);
66extern char *posix_strpbrk(const char *s1, const char *s2);
67extern size_t posix_strcspn(const char *s1, const char *s2);
68extern size_t posix_strspn(const char *s1, const char *s2);
69extern char *posix_strstr(const char *s1, const char *s2);
70
71/* Collation Functions */
72extern int posix_strcoll(const char *s1, const char *s2);
73extern size_t posix_strxfrm(char *restrict s1, const char *restrict s2, size_t n);
74
75/* Error Messages */
76extern char *posix_strerror(int errnum);
77
78/* String Length */
79extern size_t posix_strlen(const char *s);
80
81#ifndef LIBPOSIX_INTERNAL
82 #define strcpy posix_strcpy
83 #define strncpy posix_strncpy
84 #define strcat posix_strcat
85 #define strncat posix_strncat
86 #define mempcpy posix_mempcpy
87 #define strdup posix_strdup
88
89 #define memcmp posix_memcmp
90 #define strcmp posix_strcmp
91 #define strncmp posix_strncmp
92 #define strcasecmp posix_strcasecmp
93 #define strncasecmp posix_strncasecmp
94
95 #define memchr posix_memchr
96 #define rawmemchr posix_rawmemchr
97 #define strchr posix_strchr
98 #define strrchr posix_strrchr
99 #define strpbrk posix_strpbrk
100 #define strcspn posix_strcspn
101 #define strspn posix_strspn
102 #define strstr posix_strstr
103
104 #define strcoll posix_strcoll
105 #define strxfrm posix_strxfrm
106
107 #define strerror posix_strerror
108
109 #define strlen posix_strlen
110#endif
111
112#endif // POSIX_STRING_H_
113
114/** @}
115 */
Note: See TracBrowser for help on using the repository browser.