str.h
#ifndef STR__H__
#define STR__H__
#include <stdarg.h>
#include "sysdeps.h"
#define STR_BLOCKSIZE 16
struct str
{
char* s;
unsigned len;
unsigned size;
};
typedef struct str str;
struct str_sortentry
{
const char* str;
unsigned long len;
};
typedef struct str_sortentry str_sortentry;
extern const char str_lcase_digits[36] __DEPRECATED__;
extern const char str_ucase_digits[36] __DEPRECATED__;
int str_init(str* s);
int str_alloc(str* s, unsigned size, int copy);
#define str_ready(S,SZ) str_alloc(S,SZ,0)
#define str_realloc(S,SZ) str_alloc(S,SZ,1)
void str_free(str* s);
int str_truncate(str* s, unsigned len);
int str_copy(str* s, const str* in);
int str_copys(str* s, const char* in);
int str_copyb(str* s, const char* in, unsigned len);
int str_copyf(str* s, const char* format, ...);
int str_copyfv(str* s, const char* format, va_list ap);
int str_copyns(str* s, unsigned int count, ...);
int str_copy2s(str* s, const char* a, const char* b);
int str_copy3s(str* s, const char* a, const char* b, const char* c);
int str_copy4s(str* s, const char* a, const char* b, const char* c, const char* d);
int str_copy5s(str* s, const char* a, const char* b, const char* c, const char* d, const char* e);
int str_copy6s(str* s, const char* a, const char* b, const char* c, const char* d, const char* e, const char* f);
int str_cat(str* s, const str* in);
int str_cats(str* s, const char* in);
int str_catc(str* s, char in);
int str_catb(str* s, const char* in, unsigned len);
int str_catf(str* s, const char* format, ...);
int str_catfv(str* s, const char* format, va_list ap);
int str_cati(str* s, long in);
int str_catiw(str* s, long in, unsigned width, char pad);
int str_catu(str* s, unsigned long in);
int str_catuw(str* s, unsigned long in, unsigned width, char pad);
int str_catx(str* s, unsigned long in);
int str_catxw(str* s, unsigned long in, unsigned width, char pad);
int str_catill(str* s, long long in);
int str_catiwll(str* s, long long in, unsigned width, char pad);
int str_catull(str* s, unsigned long long in);
int str_catuwll(str* s, unsigned long long in, unsigned width, char pad);
int str_catxll(str* s, unsigned long long in);
int str_catxwll(str* s, unsigned long long in, unsigned width, char pad);
int str_catsnumw(str* s, long in, unsigned width, char pad,
unsigned base, const char* digits);
int str_catunumw(str* s, unsigned long in, unsigned width, char pad,
unsigned base, const char* digits);
int str_catsllnumw(str* s, long long in, unsigned width, char pad,
unsigned base, const char* digits);
int str_catullnumw(str* s, unsigned long long in, unsigned width, char pad,
unsigned base, const char* digits);
int str_catns(str* s, unsigned int count, ...);
int str_cat2s(str* s, const char* a, const char* b);
int str_cat3s(str* s, const char* a, const char* b, const char* c);
int str_cat4s(str* s, const char* a, const char* b, const char* c, const char* d);
int str_cat5s(str* s, const char* a, const char* b, const char* c, const char* d, const char* e);
int str_cat6s(str* s, const char* a, const char* b, const char* c, const char* d, const char* e, const char* f);
int str_join(str* s, char sep, const str* t);
int str_joins(str* s, char sep, const char* in);
int str_joinb(str* s, char sep, const char* in, unsigned len);
/* @{ */
void str_lower(str* s);
void str_upper(str* s);
long str_subst(str* s, char from, char to);
void str_lstrip(str* s);
void str_rstrip(str* s);
#define str_strip(S) (str_rstrip(S), str_lstrip(S))
void str_lcut(str* s, unsigned count);
void str_rcut(str* s, unsigned count);
int str_sort(str* s, char sep, long count,
int (*fn)(const str_sortentry* a, const str_sortentry* b));
int str_splice(str* s, unsigned start, unsigned len, const str* r);
int str_splices(str* s, unsigned start, unsigned len, const char* r);
int str_spliceb(str* s, unsigned start, unsigned len,
const char* r, unsigned rlen);
long str_xlate(str* s, const char* from, const char* to, unsigned nchars);
int str_cmp(const str* a, unsigned aoffset, const str* b, unsigned boffset);
int str_cmps(const str* a, unsigned offset, const char* b);
int str_cmpb(const str* a, unsigned offset, const char* b, unsigned len);
int str_diff(const str* a, const str* b);
int str_diffs(const str* a, const char* b);
int str_diffb(const str* a, const char* b, unsigned len);
int str_start(const str* a, const str* b);
int str_starts(const str* a, const char* b);
int str_startb(const str* a, const char* b, unsigned len);
int str_case_start(const str* a, const str* b);
int str_case_starts(const str* a, const char* b);
int str_case_startb(const str* a, const char* b, unsigned len);
int str_end(const str* a, const str* b);
int str_ends(const str* a, const char* b);
int str_endb(const str* a, const char* b, unsigned len);
int str_case_end(const str* a, const str* b);
int str_case_ends(const str* a, const char* b);
int str_case_endb(const str* a, const char* b, unsigned len);
void str_buildmap(int map[256], const char* list);
unsigned str_count(const str* s, char ch);
unsigned str_countof(const str* s, const char* list);
#define str_findfirst(S,C) str_findnext(S,C,0)
#define str_findfirstof(S,L) str_findnextof(S,L,0)
#define str_findfirstnot(S,L) str_findnextnot(S,L,0)
#define str_findlast(S,C) str_findprev(S,C,-1)
#define str_findlastof(S,L) str_findprevof(S,L,-1)
#define str_findlastnot(S,L) str_findprevof(S,L,-1)
int str_findnext(const str* s, char ch, unsigned pos);
int str_findnextof(const str* s, const char* list, unsigned pos);
int str_findnextnot(const str* s, const char* list, unsigned pos);
int str_findprev(const str* s, char ch, unsigned pos);
int str_findprevof(const str* s, const char* list, unsigned pos);
int str_findprevnot(const str* s, const char* list, unsigned pos);
int str_match(const str* s, const str* pattern);
int str_matchb(const str* s, const char* pptr, unsigned plen);
int str_matchs(const str* s, const char* pattern);
int str_case_match(const str* s, const str* pattern);
int str_case_matchb(const str* s, const char* pptr, unsigned plen);
int str_case_matchs(const str* s, const char* pattern);
int str_glob(const str* s, const str* pattern);
int str_globb(const str* s, const char* pptr, unsigned plen);
int str_globs(const str* s, const char* pattern);
int str_case_glob(const str* s, const str* pattern);
int str_case_globb(const str* s, const char* pptr, unsigned plen);
int str_case_globs(const str* s, const char* pattern);
#endif
str_findnextof
int str_findnextof(const str *s, const char *list, unsigned pos)
Definition findnextof.c:22
str_catunumw
int str_catunumw(str *s, unsigned long in, unsigned width, char pad, unsigned base, const char *digits)
Definition catunum.c:22
str_catxw
int str_catxw(str *s, unsigned long in, unsigned width, char pad)
Definition catxw.c:22
str_copy2s
int str_copy2s(str *s, const char *a, const char *b)
Definition copy2s.c:22
str_rstrip
void str_rstrip(str *s)
Definition rstrip.c:22
str_copys
int str_copys(str *s, const char *in)
Definition copy.c:28
str_sort
int str_sort(str *s, char sep, long count, int(*fn)(const str_sortentry *a, const str_sortentry *b))
Definition sort.c:51
str_cmps
int str_cmps(const str *a, unsigned offset, const char *b)
Definition cmp.c:34
str_copy6s
int str_copy6s(str *s, const char *a, const char *b, const char *c, const char *d, const char *e, const char *f)
Definition copy6s.c:22
str_truncate
int str_truncate(str *s, unsigned len)
Definition truncate.c:27
str_catx
int str_catx(str *s, unsigned long in)
Definition catxw.c:28
str_cats
int str_cats(str *s, const char *in)
Definition cat.c:28
str_findnext
int str_findnext(const str *s, char ch, unsigned pos)
Definition findnext.c:22
str_upper
void str_upper(str *s)
Definition upper.c:22
str_catf
int str_catf(str *s, const char *format,...)
Definition catf.c:40
str_catsllnumw
int str_catsllnumw(str *s, long long in, unsigned width, char pad, unsigned base, const char *digits)
Definition catsllnum.c:23
str_case_match
int str_case_match(const str *s, const str *pattern)
Definition case_match.c:57
str_copyb
int str_copyb(str *s, const char *in, unsigned len)
Definition copy.c:34
str_copyns
int str_copyns(str *s, unsigned int count,...)
Definition copyns.c:23
str_joins
int str_joins(str *s, char sep, const char *in)
Definition join.c:28
str_starts
int str_starts(const str *a, const char *b)
Definition start.c:23
str_catiw
int str_catiw(str *s, long in, unsigned width, char pad)
Definition catiw.c:28
str_findprevof
int str_findprevof(const str *s, const char *list, unsigned pos)
Definition findprevof.c:22
str_lcut
void str_lcut(str *s, unsigned count)
Definition cut.c:30
str_matchs
int str_matchs(const str *s, const char *pattern)
Definition str/match.c:55
str_countof
unsigned str_countof(const str *s, const char *list)
Definition countof.c:21
str_end
int str_end(const str *a, const str *b)
Definition end.c:29
str_match
int str_match(const str *s, const str *pattern)
Definition str/match.c:49
str_case_startb
int str_case_startb(const str *a, const char *b, unsigned len)
Definition case_start.c:24
str_cmpb
int str_cmpb(const str *a, unsigned offset, const char *b, unsigned len)
Definition cmp.c:40
str_xlate
long str_xlate(str *s, const char *from, const char *to, unsigned nchars)
Definition xlate.c:24
str_diffs
int str_diffs(const str *a, const char *b)
Definition diff.c:35
str_case_end
int str_case_end(const str *a, const str *b)
Definition case_end.c:45
str_init
int str_init(str *s)
Definition init.c:22
str_case_endb
int str_case_endb(const str *a, const char *b, unsigned len)
Definition case_end.c:24
str_copy5s
int str_copy5s(str *s, const char *a, const char *b, const char *c, const char *d, const char *e)
Definition copy5s.c:22
str_cat5s
int str_cat5s(str *s, const char *a, const char *b, const char *c, const char *d, const char *e)
Definition cat5s.c:22
str_count
unsigned str_count(const str *s, char ch)
Definition count.c:21
str_copy3s
int str_copy3s(str *s, const char *a, const char *b, const char *c)
Definition copy3s.c:22
str_catiwll
int str_catiwll(str *s, long long in, unsigned width, char pad)
Definition catiwll.c:29
str_catns
int str_catns(str *s, unsigned int count,...)
Definition catns.c:23
str_copyfv
int str_copyfv(str *s, const char *format, va_list ap)
Definition copyf.c:22
str_catuwll
int str_catuwll(str *s, unsigned long long in, unsigned width, char pad)
Definition catuwll.c:29
str_cat
int str_cat(str *s, const str *in)
Definition cat.c:22
str_diff
int str_diff(const str *a, const str *b)
Definition diff.c:29
str_case_start
int str_case_start(const str *a, const str *b)
Definition case_start.c:45
str_subst
long str_subst(str *s, char from, char to)
Definition subst.c:24
str_catb
int str_catb(str *s, const char *in, unsigned len)
Definition cat.c:43
str_catfv
int str_catfv(str *s, const char *format, va_list ap)
Definition catf.c:22
str_catu
int str_catu(str *s, unsigned long in)
Definition catuw.c:28
str_case_matchs
int str_case_matchs(const str *s, const char *pattern)
Definition case_match.c:63
str_diffb
int str_diffb(const str *a, const char *b, unsigned len)
Definition diff.c:41
str_case_matchb
int str_case_matchb(const str *s, const char *pptr, unsigned plen)
Definition case_match.c:24
str_case_starts
int str_case_starts(const str *a, const char *b)
Definition case_start.c:39
str_buildmap
void str_buildmap(int map[256], const char *list)
Definition buildmap.c:27
str_copy
int str_copy(str *s, const str *in)
Definition copy.c:22
str_catull
int str_catull(str *s, unsigned long long in)
Definition catuwll.c:22
str_lstrip
void str_lstrip(str *s)
Definition lstrip.c:23
str_cat4s
int str_cat4s(str *s, const char *a, const char *b, const char *c, const char *d)
Definition cat4s.c:22
str_free
void str_free(str *s)
Definition free.c:24
str_copyf
int str_copyf(str *s, const char *format,...)
Definition copyf.c:40
str_ends
int str_ends(const str *a, const char *b)
Definition end.c:23
str_rcut
void str_rcut(str *s, unsigned count)
Definition cut.c:22
str_lower
void str_lower(str *s)
Definition lower.c:22
str_cat3s
int str_cat3s(str *s, const char *a, const char *b, const char *c)
Definition cat3s.c:22
str_catxwll
int str_catxwll(str *s, unsigned long long in, unsigned width, char pad)
Definition catxwll.c:29
str_catullnumw
int str_catullnumw(str *s, unsigned long long in, unsigned width, char pad, unsigned base, const char *digits)
Definition catullnum.c:23
str_alloc
int str_alloc(str *s, unsigned size, int copy)
Definition alloc.c:32
str_endb
int str_endb(const str *a, const char *b, unsigned len)
Definition end.c:35
str_cat6s
int str_cat6s(str *s, const char *a, const char *b, const char *c, const char *d, const char *e, const char *f)
Definition cat6s.c:22
str_start
int str_start(const str *a, const str *b)
Definition start.c:29
str_findprev
int str_findprev(const str *s, char ch, unsigned pos)
Definition findprev.c:21
str_copy4s
int str_copy4s(str *s, const char *a, const char *b, const char *c, const char *d)
Definition copy4s.c:22
str_ucase_digits
const char str_ucase_digits[36]
Definition digits.c:7
str_matchb
int str_matchb(const str *s, const char *pptr, unsigned plen)
Definition str/match.c:23
str_catuw
int str_catuw(str *s, unsigned long in, unsigned width, char pad)
Definition catuw.c:22
str_catc
int str_catc(str *s, char in)
Definition cat.c:34
str_joinb
int str_joinb(str *s, char sep, const char *in, unsigned len)
Definition join.c:34
str_catxll
int str_catxll(str *s, unsigned long long in)
Definition catxwll.c:22
str_cati
int str_cati(str *s, long in)
Definition catiw.c:22
str_case_ends
int str_case_ends(const str *a, const char *b)
Definition case_end.c:39
str_catsnumw
int str_catsnumw(str *s, long in, unsigned width, char pad, unsigned base, const char *digits)
Definition catsnum.c:22
str_cmp
int str_cmp(const str *a, unsigned aoffset, const str *b, unsigned boffset)
Definition cmp.c:28
str_startb
int str_startb(const str *a, const char *b, unsigned len)
Definition start.c:35
str_cat2s
int str_cat2s(str *s, const char *a, const char *b)
Definition cat2s.c:22
str_join
int str_join(str *s, char sep, const str *t)
Definition join.c:22
str_catill
int str_catill(str *s, long long in)
Definition catiwll.c:22
str_sortentry
Definition str.h:52
str_sortentry::len
unsigned long len
Definition str.h:56
str_sortentry::str
const char * str
Definition str.h:54
str
Definition str.h:31
str::s
char * s
Definition str.h:36
str::size
unsigned size
Definition str.h:42
str::len
unsigned len
Definition str.h:40