/* * sxbuf.h - shared growable buffer + tiny string helpers used by every * module of plugin_fetch. Implementation in sxbuf.c. */ #ifndef SX_FETCH_BUF_H #define SX_FETCH_BUF_H #include #include typedef struct { char *p; size_t n; size_t cap; } buf_t; void buf_init(buf_t *b); void buf_free(buf_t *b); void buf_add(buf_t *b, const char *s); void buf_bput(buf_t *b, const char *s, size_t n); void buf_addf(buf_t *b, const char *fmt, ...); void *sx_malloc(size_t n); char *sx_strdup(const char *s); void url_decode(char *s); int get_query_val(const char *qs, const char *key, char *out, size_t outsz); void json_escape(FILE *out, const char *s); /* Case-insensitive compare with no platform dependency: MinGW spells these * _stricmp, glibc/musl hide them behind , and we only ever need * these two. ASCII only, locale-independent (which is what an HTTP header * name and a content-type want anyway). Implementation in sxbuf.c. */ int sx_strncasecmp(const char *a, const char *b, size_t n); int sx_strcasecmp(const char *a, const char *b); #endif /* SX_FETCH_BUF_H */