[16da5f8e] | 1 | /*
|
---|
| 2 | * Copyright (c) 2001-2004 Jakub Jermar
|
---|
[d066259] | 3 | * Copyright (c) 2005 Martin Decky
|
---|
| 4 | * Copyright (c) 2011 Oleg Romanenko
|
---|
[16da5f8e] | 5 | * All rights reserved.
|
---|
| 6 | *
|
---|
| 7 | * Redistribution and use in source and binary forms, with or without
|
---|
| 8 | * modification, are permitted provided that the following conditions
|
---|
| 9 | * are met:
|
---|
| 10 | *
|
---|
| 11 | * - Redistributions of source code must retain the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer.
|
---|
| 13 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 14 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 15 | * documentation and/or other materials provided with the distribution.
|
---|
| 16 | * - The name of the author may not be used to endorse or promote products
|
---|
| 17 | * derived from this software without specific prior written permission.
|
---|
| 18 | *
|
---|
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 29 | */
|
---|
| 30 |
|
---|
[174156fd] | 31 | /** @addtogroup kernel_generic
|
---|
[16da5f8e] | 32 | * @{
|
---|
| 33 | */
|
---|
| 34 | /** @file
|
---|
| 35 | */
|
---|
| 36 |
|
---|
[19f857a] | 37 | #ifndef KERN_STR_H_
|
---|
| 38 | #define KERN_STR_H_
|
---|
[16da5f8e] | 39 |
|
---|
[d066259] | 40 | #include <errno.h>
|
---|
[525c5ac] | 41 | #include <stdbool.h>
|
---|
[83dab11] | 42 | #include <stddef.h>
|
---|
| 43 | #include <stdint.h>
|
---|
[16da5f8e] | 44 |
|
---|
[d066259] | 45 | /* Common Unicode characters */
|
---|
[28a5ebd] | 46 | #define U_SPECIAL '?'
|
---|
[c8bf88d] | 47 |
|
---|
| 48 | #define U_LEFT_ARROW 0x2190
|
---|
| 49 | #define U_UP_ARROW 0x2191
|
---|
| 50 | #define U_RIGHT_ARROW 0x2192
|
---|
| 51 | #define U_DOWN_ARROW 0x2193
|
---|
| 52 |
|
---|
| 53 | #define U_PAGE_UP 0x21de
|
---|
| 54 | #define U_PAGE_DOWN 0x21df
|
---|
| 55 |
|
---|
| 56 | #define U_HOME_ARROW 0x21f1
|
---|
| 57 | #define U_END_ARROW 0x21f2
|
---|
| 58 |
|
---|
| 59 | #define U_NULL 0x2400
|
---|
| 60 | #define U_ESCAPE 0x241b
|
---|
| 61 | #define U_DELETE 0x2421
|
---|
| 62 |
|
---|
| 63 | #define U_CURSOR 0x2588
|
---|
| 64 |
|
---|
[d066259] | 65 | /** No size limit constant */
|
---|
[b888d5f] | 66 | #define STR_NO_LIMIT ((size_t) -1)
|
---|
| 67 |
|
---|
[d066259] | 68 | /** Maximum size of a string containing @c length characters */
|
---|
| 69 | #define STR_BOUNDS(length) ((length) << 2)
|
---|
[74c8da2c] | 70 |
|
---|
[28a5ebd] | 71 | extern char32_t str_decode(const char *, size_t *, size_t);
|
---|
| 72 | extern errno_t chr_encode(char32_t, char *, size_t *, size_t);
|
---|
[b888d5f] | 73 |
|
---|
[28a5ebd] | 74 | extern size_t str_size(const char *);
|
---|
| 75 | extern size_t wstr_size(const char32_t *);
|
---|
[b888d5f] | 76 |
|
---|
[28a5ebd] | 77 | extern size_t str_lsize(const char *, size_t);
|
---|
| 78 | extern size_t wstr_lsize(const char32_t *, size_t);
|
---|
[74c8da2c] | 79 |
|
---|
[28a5ebd] | 80 | extern size_t str_length(const char *);
|
---|
| 81 | extern size_t wstr_length(const char32_t *);
|
---|
[82bb9c1] | 82 |
|
---|
[28a5ebd] | 83 | extern size_t str_nlength(const char *, size_t);
|
---|
| 84 | extern size_t wstr_nlength(const char32_t *, size_t);
|
---|
[74c8da2c] | 85 |
|
---|
[28a5ebd] | 86 | extern bool ascii_check(char32_t);
|
---|
| 87 | extern bool chr_check(char32_t);
|
---|
[b888d5f] | 88 |
|
---|
[28a5ebd] | 89 | extern int str_cmp(const char *, const char *);
|
---|
| 90 | extern int str_lcmp(const char *, const char *, size_t);
|
---|
[b888d5f] | 91 |
|
---|
[28a5ebd] | 92 | extern void str_cpy(char *, size_t, const char *);
|
---|
| 93 | extern void str_ncpy(char *, size_t, const char *, size_t);
|
---|
| 94 | extern void wstr_to_str(char *, size_t, const char32_t *);
|
---|
[06b785f] | 95 |
|
---|
[28a5ebd] | 96 | extern char *str_chr(const char *, char32_t);
|
---|
[16da5f8e] | 97 |
|
---|
[28a5ebd] | 98 | extern bool wstr_linsert(char32_t *, char32_t, size_t, size_t);
|
---|
| 99 | extern bool wstr_remove(char32_t *, size_t);
|
---|
[20f1597] | 100 |
|
---|
[28a5ebd] | 101 | extern char *str_dup(const char *);
|
---|
| 102 | extern char *str_ndup(const char *, size_t);
|
---|
[d066259] | 103 |
|
---|
| 104 | extern errno_t str_uint64_t(const char *, char **, unsigned int, bool,
|
---|
| 105 | uint64_t *);
|
---|
[30a5470] | 106 |
|
---|
[933cadf] | 107 | extern void order_suffix(const uint64_t, uint64_t *, char *);
|
---|
| 108 | extern void bin_order_suffix(const uint64_t, uint64_t *, const char **, bool);
|
---|
[e535eeb] | 109 |
|
---|
[28a5ebd] | 110 | extern const char *str_error(errno_t);
|
---|
| 111 | extern const char *str_error_name(errno_t);
|
---|
[62ca560] | 112 |
|
---|
[16da5f8e] | 113 | #endif
|
---|
| 114 |
|
---|
| 115 | /** @}
|
---|
| 116 | */
|
---|