str.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 Martin Decky
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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  * TODO: Get rid of this.
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 

Generated on Thu Jun 2 07:45:47 2011 for HelenOS/USB by  doxygen 1.4.7