00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00035 #ifndef LIBC_STR_H_
00036 #define LIBC_STR_H_
00037
00038 #include <mem.h>
00039 #include <sys/types.h>
00040 #include <bool.h>
00041
00042 #define U_SPECIAL '?'
00043
00045 #define STR_NO_LIMIT ((size_t) -1)
00046
00048 #define STR_BOUNDS(length) ((length) << 2)
00049
00050 extern wchar_t str_decode(const char *str, size_t *offset, size_t sz);
00051 extern int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t sz);
00052
00053 extern size_t str_size(const char *str);
00054 extern size_t wstr_size(const wchar_t *str);
00055
00056 extern size_t str_lsize(const char *str, size_t max_len);
00057 extern size_t wstr_lsize(const wchar_t *str, size_t max_len);
00058
00059 extern size_t str_length(const char *str);
00060 extern size_t wstr_length(const wchar_t *wstr);
00061
00062 extern size_t str_nlength(const char *str, size_t size);
00063 extern size_t wstr_nlength(const wchar_t *str, size_t size);
00064
00065 extern bool ascii_check(wchar_t ch);
00066 extern bool chr_check(wchar_t ch);
00067
00068 extern int str_cmp(const char *s1, const char *s2);
00069 extern int str_lcmp(const char *s1, const char *s2, size_t max_len);
00070
00071 extern void str_cpy(char *dest, size_t size, const char *src);
00072 extern void str_ncpy(char *dest, size_t size, const char *src, size_t n);
00073 extern void str_append(char *dest, size_t size, const char *src);
00074
00075 extern void wstr_to_str(char *dest, size_t size, const wchar_t *src);
00076 extern char *wstr_to_astr(const wchar_t *src);
00077 extern void str_to_wstr(wchar_t *dest, size_t dlen, const char *src);
00078
00079 extern char *str_chr(const char *str, wchar_t ch);
00080 extern char *str_rchr(const char *str, wchar_t ch);
00081
00082 extern bool wstr_linsert(wchar_t *str, wchar_t ch, size_t pos, size_t max_pos);
00083 extern bool wstr_remove(wchar_t *str, size_t pos);
00084
00085 extern char *str_dup(const char *);
00086 extern char *str_ndup(const char *, size_t max_size);
00087
00088 extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *);
00089 extern int str_size_t(const char *, char **, unsigned int, bool, size_t *);
00090
00091 extern void order_suffix(const uint64_t, uint64_t *, char *);
00092 extern void bin_order_suffix(const uint64_t, uint64_t *, const char **, bool);
00093
00094
00095
00096
00097
00098 extern int stricmp(const char *, const char *);
00099
00100 extern long int strtol(const char *, char **, int);
00101 extern unsigned long strtoul(const char *, char **, int);
00102
00103 extern char * strtok_r(char *, const char *, char **);
00104 extern char * strtok(char *, const char *);
00105
00106 #endif
00107