diff --git a/include/freerdp/utils/ringbuffer.h b/include/freerdp/utils/ringbuffer.h index 1ec00c514..b22b30786 100644 --- a/include/freerdp/utils/ringbuffer.h +++ b/include/freerdp/utils/ringbuffer.h @@ -25,6 +25,8 @@ #define __RINGBUFFER_H___ #include +#include + /** @brief ring buffer meta data */ struct _RingBuffer { @@ -45,28 +47,32 @@ struct _DataChunk { }; typedef struct _DataChunk DataChunk; +#ifdef __cplusplus +extern "C" { +#endif + /** initialise a ringbuffer * @param initialSize the initial capacity of the ringBuffer * @return if the initialisation was successful */ -BOOL ringbuffer_init(RingBuffer *rb, size_t initialSize); +FREERDP_API BOOL ringbuffer_init(RingBuffer *rb, size_t initialSize); /** destroys internal data used by this ringbuffer * @param ringbuffer */ -void ringbuffer_destroy(RingBuffer *ringbuffer); +FREERDP_API void ringbuffer_destroy(RingBuffer *ringbuffer); /** computes the space used in this ringbuffer * @param ringbuffer * @return the number of bytes stored in that ringbuffer */ -size_t ringbuffer_used(const RingBuffer *ringbuffer); +FREERDP_API size_t ringbuffer_used(const RingBuffer *ringbuffer); /** returns the capacity of the ring buffer * @param ringbuffer * @return the capacity of this ring buffer */ -size_t ringbuffer_capacity(const RingBuffer *ringbuffer); +FREERDP_API size_t ringbuffer_capacity(const RingBuffer *ringbuffer); /** writes some bytes in the ringbuffer, if the data doesn't fit, the ringbuffer * is resized automatically @@ -76,7 +82,7 @@ size_t ringbuffer_capacity(const RingBuffer *ringbuffer); * @param sz the size of the data to add * @return if the operation was successful, it could fail in case of OOM during realloc() */ -BOOL ringbuffer_write(RingBuffer *rb, const BYTE *ptr, size_t sz); +FREERDP_API BOOL ringbuffer_write(RingBuffer *rb, const BYTE *ptr, size_t sz); /** ensures that we have sz bytes available at the write head, and return a pointer @@ -86,7 +92,7 @@ BOOL ringbuffer_write(RingBuffer *rb, const BYTE *ptr, size_t sz); * @param sz the size to ensure * @return a pointer on the write head, or NULL in case of OOM */ -BYTE *ringbuffer_ensure_linear_write(RingBuffer *rb, size_t sz); +FREERDP_API BYTE *ringbuffer_ensure_linear_write(RingBuffer *rb, size_t sz); /** move ahead the write head in case some byte were written directly by using * a pointer retrieved via ringbuffer_ensure_linear_write(). This function is @@ -97,7 +103,7 @@ BYTE *ringbuffer_ensure_linear_write(RingBuffer *rb, size_t sz); * @param sz the number of bytes that have been written * @return if the operation was successful, FALSE is sz is too big */ -BOOL ringbuffer_commit_written_bytes(RingBuffer *rb, size_t sz); +FREERDP_API BOOL ringbuffer_commit_written_bytes(RingBuffer *rb, size_t sz); /** peeks the buffer chunks for sz bytes and returns how many chunks are filled. @@ -108,7 +114,7 @@ BOOL ringbuffer_commit_written_bytes(RingBuffer *rb, size_t sz); * @param sz the requested size * @return the number of chunks used for reading sz bytes */ -int ringbuffer_peek(const RingBuffer *rb, DataChunk chunks[2], size_t sz); +FREERDP_API int ringbuffer_peek(const RingBuffer *rb, DataChunk chunks[2], size_t sz); /** move ahead the read head in case some byte were read using ringbuffer_peek() * This function is used to commit the bytes that were effectively consumed. @@ -116,7 +122,11 @@ int ringbuffer_peek(const RingBuffer *rb, DataChunk chunks[2], size_t sz); * @param rb the ring buffer * @param sz the */ -void ringbuffer_commit_read_bytes(RingBuffer *rb, size_t sz); +FREERDP_API void ringbuffer_commit_read_bytes(RingBuffer *rb, size_t sz); +#ifdef __cplusplus +} +#endif + #endif /* __RINGBUFFER_H___ */ diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index 6676382fc..ee9e5099f 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -85,7 +85,7 @@ static int transport_bio_buffered_write(BIO* bio, const char* buf, int num) /* we directly append extra bytes in the xmit buffer, this could be prevented * but for now it makes the code more simple. */ - if (buf && num && !ringbuffer_write(&tcp->xmitBuffer, buf, num)) + if (buf && num && !ringbuffer_write(&tcp->xmitBuffer, (const BYTE *)buf, num)) { fprintf(stderr, "%s: an error occured when writing(toWrite=%d)\n", __FUNCTION__, num); return -1;