X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fstring.h;h=b49370edb056b33c1bfc2cac8d2c065b66041467;hb=f1155256f7a168f5e2c0097cb4e7197b79c4f041;hp=b5faa9ac2afcd7cec12ea155f803d656cebd691f;hpb=c681101e384bb5633396364586b0d3667238d755;p=libucw.git diff --git a/ucw/string.h b/ucw/string.h index b5faa9ac..b49370ed 100644 --- a/ucw/string.h +++ b/ucw/string.h @@ -2,7 +2,7 @@ * UCW Library -- String Routines * * (c) 2006 Pavel Charvat - * (c) 2007--2011 Martin Mares + * (c) 2007--2012 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. @@ -11,20 +11,36 @@ #ifndef _UCW_STRING_H #define _UCW_STRING_H +#ifdef CONFIG_UCW_CLEAN_ABI +#define hex_to_mem ucw_hex_to_mem +#define mem_to_hex ucw_mem_to_hex +#define str_count_char ucw_str_count_char +#define str_format_flags ucw_str_format_flags +#define str_has_prefix ucw_str_has_prefix +#define str_has_suffix ucw_str_has_suffix +#define str_hier_prefix ucw_str_hier_prefix +#define str_hier_suffix ucw_str_hier_suffix +#define str_match_pattern ucw_str_match_pattern +#define str_match_pattern_nocase ucw_str_match_pattern_nocase +#define str_sepsplit ucw_str_sepsplit +#define str_unesc ucw_str_unesc +#define str_wordsplit ucw_str_wordsplit +#endif + /* string.c */ #ifdef CONFIG_DARWIN -uns strnlen(const char *str, uns n); +size_t strnlen(const char *str, size_t n); // NOAPI #endif /** * Format a set of flag bits. When the i-th bit of @flags is 1, * set the i-th character of @dest to @fmt[i], otherwise to '-'. **/ -char *str_format_flags(char *dest, const char *fmt, uns flags); +char *str_format_flags(char *dest, const char *fmt, uint flags); /** Counts occurrences of @chr in @str. **/ -uns str_count_char(const char *str, uns chr); +size_t str_count_char(const char *str, uns chr); /* str-esc.c */ @@ -44,7 +60,7 @@ char *str_unesc(char *dest, const char *src); * When there are more than @max fields in @str, the first @max fields * are processed and -1 is returned. **/ -int str_sepsplit(char *str, uns sep, char **rec, uns max); +int str_sepsplit(char *str, uint sep, char **rec, uint max); /** * Split @str to words separated by white-space characters. The spaces @@ -57,7 +73,7 @@ int str_sepsplit(char *str, uns sep, char **rec, uns max); * Fields surrounded by double quotes are also recognized. They can contain * spaces, but no mechanism for escaping embedded quotes is defined. **/ -int str_wordsplit(char *str, char **rec, uns max); +int str_wordsplit(char *str, char **rec, uint max); /* str-(i)match.c: Matching of shell patterns */ @@ -78,14 +94,14 @@ int str_match_pattern_nocase(const char *patt, const char *str); * not be separated), possibly OR-ed with `MEM_TO_HEX_UPCASE` when upper-case * characters should be used. **/ -void mem_to_hex(char *dest, const byte *src, uns bytes, uns flags); +void mem_to_hex(char *dest, const byte *src, size_t bytes, uns flags); /** * An inverse function to @mem_to_hex(). Takes a hexdump of at most @max_bytes * bytes and stores the bytes to a buffer starting at @dest. Returns a pointer * at the first character after the dump. **/ -const char *hex_to_mem(byte *dest, const char *src, uns max_bytes, uns flags); +const char *hex_to_mem(byte *dest, const char *src, size_t max_bytes, uns flags); // Bottom 8 bits of flags are an optional separator of bytes, the rest is: #define MEM_TO_HEX_UPCASE 0x100 @@ -110,7 +126,7 @@ int str_has_suffix(const char *str, const char *suffix); /** Tests if @str ends * - "/" is a prefix, * - "" is a prefix. **/ -int str_hier_prefix(const char *str, const char *prefix, uns sep); -int str_hier_suffix(const char *str, const char *suffix, uns sep); /** Like @str_hier_prefix(), but for suffixes. **/ +int str_hier_prefix(const char *str, const char *prefix, uint sep); +int str_hier_suffix(const char *str, const char *suffix, uint sep); /** Like @str_hier_prefix(), but for suffixes. **/ #endif