/*
 * Created by jiaqiang.ye@lnxall.com
 *
 * Simple buffer management for LNXALL applications
 *
 * 2024/07/02
 */

#ifndef LNXALL_BUFFER_H
#define LNXALL_BUFFER_H 1
#ifdef __cplusplus
extern "C" {
#endif

struct lnxall_buff {
	char *                        bufptr;
	unsigned int                  curlen;
	unsigned int                  maxlen;
};

#define LNAXLL_BUFFER_MIN         2048
void lbuff_free(struct lnxall_buff * bufp);

int lbuff_init(struct lnxall_buff * bufp, int init_len);

int lbuff_setlen(struct lnxall_buff * bufp, int curlen);

int lbuff_sprintf(struct lnxall_buff * bufp, const char * fmtstr, ...)
	__attribute__((format(printf, 2, 3)));

int lbuff_append(struct lnxall_buff * bufp,
	const char * p, int applen);

#ifdef __cplusplus
}
#endif
#endif
