1 /* 2 * reimplementation of Daniel Bernstein's unix library. 3 * placed in the public domain by Uwe Ohse, uwe@ohse.de. 4 */ 5 #ifndef STRALLOC_H 6 #define STRALLOC_H 7 8 #include "gen_alloc.h" 9 GEN_ALLOC_typedef(stralloc,char,s,len,a) 10 11 #define STRALLOC_INIT {0,0,0} 12 13 extern int stralloc_ready(stralloc *,unsigned int space); 14 extern int stralloc_readyplus(stralloc *,unsigned int morespace); 15 extern void stralloc_free(stralloc *); /* extension, uo */ 16 17 extern int stralloc_copy(stralloc *target,const stralloc *source); 18 extern int stralloc_cat(stralloc *target,const stralloc *source); 19 20 extern int stralloc_copys(stralloc *,const char *); 21 extern int stralloc_cats(stralloc *,const char *); 22 23 extern int stralloc_copyb(stralloc *,const char *,unsigned int len); 24 extern int stralloc_catb(stralloc *,const char *,unsigned int len); 25 26 /* the next one takes a pointer to 1 char */ 27 extern int stralloc_append(stralloc *,const char *); 28 #define stralloc_0(sa) stralloc_append(sa,"") 29 30 extern int stralloc_starts(stralloc *,const char *); 31 extern int stralloc_case_starts(stralloc *,const char *); /* extension. uo */ 32 33 extern int stralloc_catulong0(stralloc *,unsigned long,unsigned int); 34 extern int stralloc_catlong0(stralloc *,long,unsigned int); 35 36 #define stralloc_catlong(sa,l) (stralloc_catlong0((sa),(l),0)) 37 #define stralloc_catuint0(sa,i,n) (stralloc_catulong0((sa),(i),(n))) 38 #define stralloc_catint0(sa,i,n) (stralloc_catlong0((sa),(i),(n))) 39 #define stralloc_catint(sa,i) (stralloc_catlong0((sa),(i),0)) 40 41 #endif 42