source: mainline/uspace/lib/posix/string.h@ 491e1ee

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 491e1ee was 4f4b4e7, checked in by Petr Koupy <petr.koupy@…>, 14 years ago

Coding style and file structure unified.
_exit moved to unistd.h.

  • Property mode set to 100644
File size: 4.8 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/* 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 *
53 * unimplemented due to missing locales
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 */
60
61// TODO: provide *_l once there is locale.h
62
63#ifndef NULL
64 #define NULL ((void *) 0)
65#endif
66
67/* Copying and Concatenation */
68extern char *posix_strcpy(char *restrict dest, const char *restrict src);
69extern char *posix_strncpy(char *restrict dest, const char *restrict src, size_t n);
70extern char *posix_stpcpy(char *restrict dest, const char *restrict src);
71extern char *posix_stpncpy(char *restrict dest, const char *restrict src, size_t n);
72extern char *posix_strcat(char *restrict dest, const char *restrict src);
73extern char *posix_strncat(char *restrict dest, const char *restrict src, size_t n);
74extern void *posix_memccpy(void *restrict dest, const void *restrict src, int c, size_t n);
75extern char *posix_strdup(const char *s);
76extern char *posix_strndup(const char *s, size_t n);
77
78/* String/Array Comparison */
79extern int posix_memcmp(const void *mem1, const void *mem2, size_t n);
80extern int posix_strcmp(const char *s1, const char *s2);
81extern int posix_strncmp(const char *s1, const char *s2, size_t n);
82
83/* Search Functions */
84extern void *posix_memchr(const void *mem, int c, size_t n);
85extern char *posix_strchr(const char *s, int c);
86extern char *posix_strrchr(const char *s, int c);
87extern char *posix_strpbrk(const char *s1, const char *s2);
88extern size_t posix_strcspn(const char *s1, const char *s2);
89extern size_t posix_strspn(const char *s1, const char *s2);
90extern char *posix_strstr(const char *s1, const char *s2);
91
92/* Collation Functions */
93extern int posix_strcoll(const char *s1, const char *s2);
94extern size_t posix_strxfrm(char *restrict s1, const char *restrict s2, size_t n);
95
96/* Error Messages */
97extern char *posix_strerror(int errnum);
98extern int posix_strerror_r(int errnum, char *buf, size_t bufsz);
99
100/* String Length */
101extern size_t posix_strlen(const char *s);
102extern size_t posix_strnlen(const char *s, size_t n);
103
104#ifndef LIBPOSIX_INTERNAL
105 #define strcpy posix_strcpy
106 #define strncpy posix_strncpy
107 #define stpcpy posix_stpcpy
108 #define stpncpy posix_stpncpy
109 #define strcat posix_strcat
110 #define strncat posix_strncat
111 #define memccpy posix_memccpy
112 #define strdup posix_strdup
113 #define strndup posix_strndup
114
115 #define memcmp posix_memcmp
116 #define strcmp posix_strcmp
117 #define strncmp posix_strncmp
118
119 #define memchr posix_memchr
120 #define strchr posix_strchr
121 #define strrchr posix_strrchr
122 #define strpbrk posix_strpbrk
123 #define strcspn posix_strcspn
124 #define strspn posix_strspn
125 #define strstr posix_strstr
126
127 #define strcoll posix_strcoll
128 #define strxfrm posix_strxfrm
129
130 #define strerror posix_strerror
131 #define strerror_r posix_strerror_r
132 #define strsignal(i) ((char *) "SIGNonSense: There are no signals in HelenOS.")
133
134 #define strlen posix_strlen
135 #define strnlen posix_strnlen
136#endif
137
138#endif // POSIX_STRING_H_
139
140/** @}
141 */
Note: See TracBrowser for help on using the repository browser.