From 3176cf3439315a7e871c048ee8238098dc220731 Mon Sep 17 00:00:00 2001 From: robertabcd Date: Sat, 13 Oct 2012 06:09:58 +0000 Subject: Forgot to commit some header files git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5705 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- pttbbs/include/buffer.h | 23 +++++++++++++++++++++++ pttbbs/include/thttp.h | 26 ++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 pttbbs/include/buffer.h create mode 100644 pttbbs/include/thttp.h diff --git a/pttbbs/include/buffer.h b/pttbbs/include/buffer.h new file mode 100644 index 00000000..6a004a68 --- /dev/null +++ b/pttbbs/include/buffer.h @@ -0,0 +1,23 @@ +#ifndef BUFFER_H +# define BUFFER_H +#include + +#define BUFFER_MIN_INCREMENT (4096) + +typedef struct buffer { + int allocated; + int length; + uint8_t *pool; +} BUFFER; + +int buffer_init(BUFFER *b, int initial_size); +int buffer_cleanup(BUFFER *b); +int buffer_append(BUFFER *b, const void *data, int size); +int buffer_grow(BUFFER *b, int desired_size); +int buffer_length(BUFFER *b); +void *buffer_get(BUFFER *b, int offset); +int buffer_read_from_func( + BUFFER *b, int (*readfunc)(void *ctx, void *buf, int maxread), + void *ctx); + +#endif diff --git a/pttbbs/include/thttp.h b/pttbbs/include/thttp.h new file mode 100644 index 00000000..7e5fb88d --- /dev/null +++ b/pttbbs/include/thttp.h @@ -0,0 +1,26 @@ +#ifndef THTTP_H +# define THTTP_H + +typedef struct THTTP { + int fd; + int (*read)(struct THTTP *t, void *buffer, int size); + int (*write)(struct THTTP *t, const void *buffer, int size); + BUFFER bresp; + int code; + int content_at; + int content_length; + int failed; + int timeout_read; + int timeout_connect; +} THTTP; + +int thttp_init(THTTP *t); +int thttp_cleanup(THTTP *t); +void thttp_set_connect_timeout(THTTP *t, int microsecond); +void thttp_set_io_timeout(THTTP *t, int microsecond); +int thttp_get(THTTP *t, const char *addr, const char *uri, const char *host); +int thttp_code(THTTP *t); +void *thttp_get_content(THTTP *t); +int thttp_content_length(THTTP *t); + +#endif -- cgit v1.2.3