fehQlibs 26
Qlibs
Loading...
Searching...
No Matches
stralloc.h
Go to the documentation of this file.
1#ifndef STRALLOC_H
2#define STRALLOC_H
3
4/*
5 * Revision 20210307, Erwin Hoffmann
6 * -
7*/
8
9#include <sys/types.h>
10
11/* stralloc is the internal data structure all functions are working on.
12 * s is the string.
13 * len is the used length of the string.
14 * a is the allocated length of the string.
15 */
16
17typedef struct stralloc {
18 char* s;
19 size_t len;
20 size_t a;
22
23//extern int stralloc_ready(stralloc *,unsigned int);
24extern int stralloc_ready(stralloc *sa,size_t len);
25//extern int stralloc_readyplus(stralloc *,unsigned int);
26extern int stralloc_readyplus(stralloc *sa,size_t len);
27extern int stralloc_copy(stralloc *,stralloc *);
28extern int stralloc_cat(stralloc *,stralloc *);
29extern int stralloc_copys(stralloc *,const char *);
30extern int stralloc_cats(stralloc *,const char *);
31extern int stralloc_copyb(stralloc *,const char *,unsigned int);
32extern int stralloc_catb(stralloc *,const char *,unsigned int);
33//extern int stralloc_append(stralloc *,char *); /* beware: this takes a pointer to 1 char */
34extern int stralloc_append(stralloc *sa,const char *in); /* beware: this takes a pointer to 1 char */
35extern int stralloc_starts(stralloc *,const char *);
36
37#define stralloc_0(sa) stralloc_append(sa,"")
38
39extern int stralloc_catulong0(stralloc *,unsigned long,unsigned int);
40extern int stralloc_catlong0(stralloc *,long,unsigned int);
41
42extern void stralloc_free(stralloc *);
43
44#define stralloc_catlong(sa,l) (stralloc_catlong0((sa),(l),0))
45#define stralloc_catuint0(sa,i,n) (stralloc_catulong0((sa),(i),(n)))
46#define stralloc_catint0(sa,i,n) (stralloc_catlong0((sa),(i),(n)))
47#define stralloc_catint(sa,i) (stralloc_catlong0((sa),(i),0))
48
49#endif
int stralloc_copy(stralloc *, stralloc *)
Definition: stralloc.c:41
int stralloc_starts(stralloc *, const char *)
Definition: stralloc.c:14
int stralloc_catb(stralloc *, const char *, unsigned int)
Definition: stralloc.c:26
int stralloc_catlong0(stralloc *, long, unsigned int)
Definition: stralloc.c:103
int stralloc_append(stralloc *sa, const char *in)
Definition: stralloc.c:112
int stralloc_copyb(stralloc *, const char *, unsigned int)
Definition: stralloc.c:70
int stralloc_cat(stralloc *, stralloc *)
Definition: stralloc.c:21
int stralloc_ready(stralloc *sa, size_t len)
Definition: stralloc.c:47
int stralloc_cats(stralloc *, const char *)
Definition: stralloc.c:36
int stralloc_catulong0(stralloc *, unsigned long, unsigned int)
Definition: stralloc.c:84
int stralloc_readyplus(stralloc *sa, size_t len)
Definition: stralloc.c:61
int stralloc_copys(stralloc *, const char *)
Definition: stralloc.c:79
void stralloc_free(stralloc *)
Definition: stralloc.c:122
size_t len
Definition: stralloc.h:19
size_t a
Definition: stralloc.h:20
char * s
Definition: stralloc.h:18