28 lines
814 B
C
28 lines
814 B
C
#ifndef _STR_BUF_H_
|
|
#define _STR_BUF_H_
|
|
|
|
typedef struct { char *buf; int dsize, rdpos, wrpos; char sep; } Str_Buf;
|
|
|
|
#define str_get_str(BUF,RES) str_nget_str(BUF,RES,sizeof(RES))
|
|
|
|
/* input */
|
|
void str_get_start(Str_Buf *buf);
|
|
char *str_nget_str(Str_Buf *buf, char *result, int reslen);
|
|
int str_get_int(Str_Buf *buf, int *res);
|
|
int str_get_float(Str_Buf *buf, float *res);
|
|
int str_get_end(Str_Buf *buf);
|
|
|
|
/* output */
|
|
void str_put_start(Str_Buf *buf);
|
|
int str_put_str(Str_Buf *buf, const char *str);
|
|
int str_put_int(Str_Buf *buf, int val);
|
|
int str_put_float(Str_Buf *buf, float val);
|
|
|
|
/* common */
|
|
#define STR_NOSEPARATOR ((char)1)
|
|
Str_Buf *str_create_buf(size_t size, char separator);
|
|
void str_link_buf(Str_Buf *buf, char *str, int size, char separator);
|
|
void str_free_buf(Str_Buf *buf);
|
|
|
|
#endif /* _STR_BUF_H_ */
|