[7bb9b53] | 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 | */
|
---|
[5273eb6] | 33 | /** @file String manipulation.
|
---|
[7bb9b53] | 34 | */
|
---|
| 35 |
|
---|
| 36 | #ifndef POSIX_STRING_H_
|
---|
| 37 | #define POSIX_STRING_H_
|
---|
| 38 |
|
---|
| 39 | #include <mem.h>
|
---|
| 40 | #include <str.h>
|
---|
| 41 |
|
---|
[ef6dd3f] | 42 | /* available in str.h
|
---|
| 43 | *
|
---|
| 44 | * char *strtok(char *restrict, const char *restrict);
|
---|
| 45 | * char *strtok_r(char *restrict, const char *restrict, char **restrict);
|
---|
| 46 | *
|
---|
| 47 | * available in mem.h
|
---|
| 48 | *
|
---|
| 49 | * void *memset(void *, int, size_t);
|
---|
| 50 | * void *memcpy(void *, const void *, size_t);
|
---|
| 51 | * void *memmove(void *, const void *, size_t);
|
---|
| 52 | *
|
---|
[6921178] | 53 | * TODO: not implemented due to missing locale support
|
---|
[ef6dd3f] | 54 | *
|
---|
| 55 | * int strcoll_l(const char *, const char *, locale_t);
|
---|
| 56 | * char *strerror_l(int, locale_t);
|
---|
| 57 | * size_t strxfrm_l(char *restrict, const char *restrict, size_t, locale_t);
|
---|
| 58 | */
|
---|
| 59 |
|
---|
[7bb9b53] | 60 | #ifndef NULL
|
---|
| 61 | #define NULL ((void *) 0)
|
---|
| 62 | #endif
|
---|
| 63 |
|
---|
| 64 | /* Copying and Concatenation */
|
---|
| 65 | extern char *posix_strcpy(char *restrict dest, const char *restrict src);
|
---|
| 66 | extern char *posix_strncpy(char *restrict dest, const char *restrict src, size_t n);
|
---|
[ef6dd3f] | 67 | extern char *posix_stpcpy(char *restrict dest, const char *restrict src);
|
---|
| 68 | extern char *posix_stpncpy(char *restrict dest, const char *restrict src, size_t n);
|
---|
[7bb9b53] | 69 | extern char *posix_strcat(char *restrict dest, const char *restrict src);
|
---|
| 70 | extern char *posix_strncat(char *restrict dest, const char *restrict src, size_t n);
|
---|
[ef6dd3f] | 71 | extern void *posix_memccpy(void *restrict dest, const void *restrict src, int c, size_t n);
|
---|
[7bb9b53] | 72 | extern char *posix_strdup(const char *s);
|
---|
[ef6dd3f] | 73 | extern char *posix_strndup(const char *s, size_t n);
|
---|
[7bb9b53] | 74 |
|
---|
| 75 | /* String/Array Comparison */
|
---|
| 76 | extern int posix_memcmp(const void *mem1, const void *mem2, size_t n);
|
---|
| 77 | extern int posix_strcmp(const char *s1, const char *s2);
|
---|
| 78 | extern int posix_strncmp(const char *s1, const char *s2, size_t n);
|
---|
| 79 |
|
---|
| 80 | /* Search Functions */
|
---|
| 81 | extern void *posix_memchr(const void *mem, int c, size_t n);
|
---|
| 82 | extern char *posix_strchr(const char *s, int c);
|
---|
| 83 | extern char *posix_strrchr(const char *s, int c);
|
---|
[517cedc0] | 84 | extern char *gnu_strchrnul(const char *s, int c);
|
---|
[7bb9b53] | 85 | extern char *posix_strpbrk(const char *s1, const char *s2);
|
---|
| 86 | extern size_t posix_strcspn(const char *s1, const char *s2);
|
---|
| 87 | extern size_t posix_strspn(const char *s1, const char *s2);
|
---|
| 88 | extern char *posix_strstr(const char *s1, const char *s2);
|
---|
| 89 |
|
---|
| 90 | /* Collation Functions */
|
---|
| 91 | extern int posix_strcoll(const char *s1, const char *s2);
|
---|
| 92 | extern size_t posix_strxfrm(char *restrict s1, const char *restrict s2, size_t n);
|
---|
| 93 |
|
---|
| 94 | /* Error Messages */
|
---|
| 95 | extern char *posix_strerror(int errnum);
|
---|
[ef6dd3f] | 96 | extern int posix_strerror_r(int errnum, char *buf, size_t bufsz);
|
---|
[7bb9b53] | 97 |
|
---|
| 98 | /* String Length */
|
---|
| 99 | extern size_t posix_strlen(const char *s);
|
---|
[ef6dd3f] | 100 | extern size_t posix_strnlen(const char *s, size_t n);
|
---|
[7bb9b53] | 101 |
|
---|
[5273eb6] | 102 | /* Signal Messages */
|
---|
[d3ce33fa] | 103 | extern char *posix_strsignal(int signum);
|
---|
| 104 |
|
---|
[4cf8ca6] | 105 | /* Legacy Declarations */
|
---|
[da084d9] | 106 | #ifndef POSIX_STRINGS_H_
|
---|
[b4d6252] | 107 | extern int posix_ffs(int i);
|
---|
[458d356] | 108 | extern int posix_strcasecmp(const char *s1, const char *s2);
|
---|
| 109 | extern int posix_strncasecmp(const char *s1, const char *s2, size_t n);
|
---|
[da084d9] | 110 | #endif
|
---|
[b4d6252] | 111 |
|
---|
[4d10fc8] | 112 | #ifndef LIBPOSIX_INTERNAL
|
---|
| 113 | #define strcpy posix_strcpy
|
---|
| 114 | #define strncpy posix_strncpy
|
---|
[ef6dd3f] | 115 | #define stpcpy posix_stpcpy
|
---|
| 116 | #define stpncpy posix_stpncpy
|
---|
[4d10fc8] | 117 | #define strcat posix_strcat
|
---|
| 118 | #define strncat posix_strncat
|
---|
[ef6dd3f] | 119 | #define memccpy posix_memccpy
|
---|
[4d10fc8] | 120 | #define strdup posix_strdup
|
---|
[ef6dd3f] | 121 | #define strndup posix_strndup
|
---|
[4d10fc8] | 122 |
|
---|
| 123 | #define memcmp posix_memcmp
|
---|
| 124 | #define strcmp posix_strcmp
|
---|
| 125 | #define strncmp posix_strncmp
|
---|
| 126 |
|
---|
| 127 | #define memchr posix_memchr
|
---|
| 128 | #define strchr posix_strchr
|
---|
| 129 | #define strrchr posix_strrchr
|
---|
[517cedc0] | 130 | #define strchrnul gnu_strchrnul
|
---|
[4d10fc8] | 131 | #define strpbrk posix_strpbrk
|
---|
| 132 | #define strcspn posix_strcspn
|
---|
| 133 | #define strspn posix_strspn
|
---|
| 134 | #define strstr posix_strstr
|
---|
| 135 |
|
---|
| 136 | #define strcoll posix_strcoll
|
---|
| 137 | #define strxfrm posix_strxfrm
|
---|
| 138 |
|
---|
| 139 | #define strerror posix_strerror
|
---|
[ef6dd3f] | 140 | #define strerror_r posix_strerror_r
|
---|
[4d10fc8] | 141 |
|
---|
| 142 | #define strlen posix_strlen
|
---|
[ef6dd3f] | 143 | #define strnlen posix_strnlen
|
---|
[b4d6252] | 144 |
|
---|
[d3ce33fa] | 145 | #define strsignal posix_strsignal
|
---|
| 146 |
|
---|
[b4d6252] | 147 | #define ffs posix_ffs
|
---|
[458d356] | 148 | #define strcasecmp posix_strcasecmp
|
---|
| 149 | #define strncasecmp posix_strncasecmp
|
---|
[4d10fc8] | 150 | #endif
|
---|
[7bb9b53] | 151 |
|
---|
| 152 | #endif // POSIX_STRING_H_
|
---|
| 153 |
|
---|
| 154 | /** @}
|
---|
| 155 | */
|
---|