diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-12-13 11:24:26 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-12-13 11:24:26 -0800 |
commit | 225d720d6e9b473c7d6498e811b3f412472cc9ce (patch) | |
tree | b3f1b4f97a43a09dfddd060b0b4f8696e496f739 /src/buffer.h | |
parent | 831bf6de49ae58bd3630f40bdb6f8bc5371a33dd (diff) |
Removed cmark_ prefix on chunk and strbuf.
This isn't needed any more since we don't expose these in the API.
Diffstat (limited to 'src/buffer.h')
-rw-r--r-- | src/buffer.h | 132 |
1 files changed, 34 insertions, 98 deletions
diff --git a/src/buffer.h b/src/buffer.h index 7401b22..c827ea8 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -4,7 +4,6 @@ #include <stddef.h> #include <stdarg.h> #include "config.h" -#include "cmark_export.h" #ifdef __cplusplus extern "C" { @@ -13,15 +12,13 @@ extern "C" { typedef struct { unsigned char *ptr; int asize, size; -} cmark_strbuf; +} strbuf; -CMARK_EXPORT -extern unsigned char cmark_strbuf__initbuf[]; +extern unsigned char strbuf__initbuf[]; -CMARK_EXPORT -extern unsigned char cmark_strbuf__oom[]; +extern unsigned char strbuf__oom[]; -#define CMARK_GH_BUF_INIT { cmark_strbuf__initbuf, 0, 0 } +#define GH_BUF_INIT { strbuf__initbuf, 0, 0 } /** * Initialize a strbuf structure. @@ -29,8 +26,7 @@ extern unsigned char cmark_strbuf__oom[]; * For the cases where GH_BUF_INIT cannot be used to do static * initialization. */ -CMARK_EXPORT -void cmark_strbuf_init(cmark_strbuf *buf, int initial_size); +void strbuf_init(strbuf *buf, int initial_size); /** * Attempt to grow the buffer to hold at least `target_size` bytes. @@ -40,8 +36,7 @@ void cmark_strbuf_init(cmark_strbuf *buf, int initial_size); * existing buffer content will be preserved, but calling code must handle * that buffer was not expanded. */ -CMARK_EXPORT -int cmark_strbuf_try_grow(cmark_strbuf *buf, int target_size, bool mark_oom); +int strbuf_try_grow(strbuf *buf, int target_size, bool mark_oom); /** * Grow the buffer to hold at least `target_size` bytes. @@ -51,13 +46,10 @@ int cmark_strbuf_try_grow(cmark_strbuf *buf, int target_size, bool mark_oom); * * @return 0 on success or -1 on failure */ -CMARK_EXPORT -int cmark_strbuf_grow(cmark_strbuf *buf, int target_size); +int strbuf_grow(strbuf *buf, int target_size); -CMARK_EXPORT -void cmark_strbuf_free(cmark_strbuf *buf); -CMARK_EXPORT -void cmark_strbuf_swap(cmark_strbuf *buf_a, cmark_strbuf *buf_b); +void strbuf_free(strbuf *buf); +void strbuf_swap(strbuf *buf_a, strbuf *buf_b); /** * Test if there have been any reallocation failures with this strbuf. @@ -70,28 +62,22 @@ void cmark_strbuf_swap(cmark_strbuf *buf_a, cmark_strbuf *buf_b); * * @return false if no error, true if allocation error */ -CMARK_EXPORT -bool cmark_strbuf_oom(const cmark_strbuf *buf); +bool strbuf_oom(const strbuf *buf); -CMARK_EXPORT -size_t cmark_strbuf_len(const cmark_strbuf *buf); +size_t strbuf_len(const strbuf *buf); -CMARK_EXPORT -int cmark_strbuf_cmp(const cmark_strbuf *a, const cmark_strbuf *b); +int strbuf_cmp(const strbuf *a, const strbuf *b); -CMARK_EXPORT -void cmark_strbuf_attach(cmark_strbuf *buf, unsigned char *ptr, int asize); -CMARK_EXPORT -unsigned char *cmark_strbuf_detach(cmark_strbuf *buf); -CMARK_EXPORT -void cmark_strbuf_copy_cstr(char *data, int datasize, const cmark_strbuf *buf); +void strbuf_attach(strbuf *buf, unsigned char *ptr, int asize); +unsigned char *strbuf_detach(strbuf *buf); +void strbuf_copy_cstr(char *data, int datasize, const strbuf *buf); -static inline const char *cmark_strbuf_cstr(const cmark_strbuf *buf) +static inline const char *strbuf_cstr(const strbuf *buf) { return (char *)buf->ptr; } -#define cmark_strbuf_at(buf, n) ((buf)->ptr[n]) +#define strbuf_at(buf, n) ((buf)->ptr[n]) /* * Functions below that return int value error codes will return 0 on @@ -101,74 +87,24 @@ static inline const char *cmark_strbuf_cstr(const cmark_strbuf *buf) * return code of these functions and call them in a series then just call * strbuf_oom at the end. */ -CMARK_EXPORT -int cmark_strbuf_set(cmark_strbuf *buf, const unsigned char *data, int len); -CMARK_EXPORT -int cmark_strbuf_sets(cmark_strbuf *buf, const char *string); -CMARK_EXPORT -int cmark_strbuf_putc(cmark_strbuf *buf, int c); -CMARK_EXPORT -int cmark_strbuf_put(cmark_strbuf *buf, const unsigned char *data, int len); -CMARK_EXPORT -int cmark_strbuf_puts(cmark_strbuf *buf, const char *string); -CMARK_EXPORT -int cmark_strbuf_printf(cmark_strbuf *buf, const char *format, ...) +int strbuf_set(strbuf *buf, const unsigned char *data, int len); +int strbuf_sets(strbuf *buf, const char *string); +int strbuf_putc(strbuf *buf, int c); +int strbuf_put(strbuf *buf, const unsigned char *data, int len); +int strbuf_puts(strbuf *buf, const char *string); +int strbuf_printf(strbuf *buf, const char *format, ...) CMARK_ATTRIBUTE((format (printf, 2, 3))); -CMARK_EXPORT -int cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap); -CMARK_EXPORT -void cmark_strbuf_clear(cmark_strbuf *buf); - -CMARK_EXPORT -int cmark_strbuf_strchr(const cmark_strbuf *buf, int c, int pos); -CMARK_EXPORT -int cmark_strbuf_strrchr(const cmark_strbuf *buf, int c, int pos); -CMARK_EXPORT -void cmark_strbuf_drop(cmark_strbuf *buf, int n); -CMARK_EXPORT -void cmark_strbuf_truncate(cmark_strbuf *buf, int len); -CMARK_EXPORT -void cmark_strbuf_rtrim(cmark_strbuf *buf); -CMARK_EXPORT -void cmark_strbuf_trim(cmark_strbuf *buf); -CMARK_EXPORT -void cmark_strbuf_normalize_whitespace(cmark_strbuf *s); -CMARK_EXPORT -void cmark_strbuf_unescape(cmark_strbuf *s); - -// Convenience macros -#define strbuf cmark_strbuf -#define strbuf__initbuf cmark_strbuf__initbuf -#define strbuf__oom cmark_strbuf__oom -#define GH_BUF_INIT CMARK_GH_BUF_INIT -#define strbuf_init cmark_strbuf_init -#define strbuf_try_grow cmark_strbuf_try_grow -#define strbuf_grow cmark_strbuf_grow -#define strbuf_free cmark_strbuf_free -#define strbuf_swap cmark_strbuf_swap -#define strbuf_oom cmark_strbuf_oom -#define strbuf_len cmark_strbuf_len -#define strbuf_cmp cmark_strbuf_cmp -#define strbuf_attach cmark_strbuf_attach -#define strbuf_detach cmark_strbuf_detach -#define strbuf_copy_cstr cmark_strbuf_copy_cstr -#define strbuf_at cmark_strbuf_at -#define strbuf_set cmark_strbuf_set -#define strbuf_sets cmark_strbuf_sets -#define strbuf_putc cmark_strbuf_putc -#define strbuf_put cmark_strbuf_put -#define strbuf_puts cmark_strbuf_puts -#define strbuf_printf cmark_strbuf_printf -#define strbuf_vprintf cmark_strbuf_vprintf -#define strbuf_clear cmark_strbuf_clear -#define strbuf_strchr cmark_strbuf_strchr -#define strbuf_strrchr cmark_strbuf_strrchr -#define strbuf_drop cmark_strbuf_drop -#define strbuf_truncate cmark_strbuf_truncate -#define strbuf_rtrim cmark_strbuf_rtrim -#define strbuf_trim cmark_strbuf_trim -#define strbuf_normalize_whitespace cmark_strbuf_normalize_whitespace -#define strbuf_unescape cmark_strbuf_unescape +int strbuf_vprintf(strbuf *buf, const char *format, va_list ap); +void strbuf_clear(strbuf *buf); + +int strbuf_strchr(const strbuf *buf, int c, int pos); +int strbuf_strrchr(const strbuf *buf, int c, int pos); +void strbuf_drop(strbuf *buf, int n); +void strbuf_truncate(strbuf *buf, int len); +void strbuf_rtrim(strbuf *buf); +void strbuf_trim(strbuf *buf); +void strbuf_normalize_whitespace(strbuf *s); +void strbuf_unescape(strbuf *s); #ifdef __cplusplus } |