Correctly export ringbuffer function and fix a warning
This commit is contained in:
parent
2b1a27b9b6
commit
3200baca4b
@ -25,6 +25,8 @@
|
|||||||
#define __RINGBUFFER_H___
|
#define __RINGBUFFER_H___
|
||||||
|
|
||||||
#include <winpr/wtypes.h>
|
#include <winpr/wtypes.h>
|
||||||
|
#include <freerdp/api.h>
|
||||||
|
|
||||||
|
|
||||||
/** @brief ring buffer meta data */
|
/** @brief ring buffer meta data */
|
||||||
struct _RingBuffer {
|
struct _RingBuffer {
|
||||||
@ -45,28 +47,32 @@ struct _DataChunk {
|
|||||||
};
|
};
|
||||||
typedef struct _DataChunk DataChunk;
|
typedef struct _DataChunk DataChunk;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/** initialise a ringbuffer
|
/** initialise a ringbuffer
|
||||||
* @param initialSize the initial capacity of the ringBuffer
|
* @param initialSize the initial capacity of the ringBuffer
|
||||||
* @return if the initialisation was successful
|
* @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
|
/** destroys internal data used by this ringbuffer
|
||||||
* @param ringbuffer
|
* @param ringbuffer
|
||||||
*/
|
*/
|
||||||
void ringbuffer_destroy(RingBuffer *ringbuffer);
|
FREERDP_API void ringbuffer_destroy(RingBuffer *ringbuffer);
|
||||||
|
|
||||||
/** computes the space used in this ringbuffer
|
/** computes the space used in this ringbuffer
|
||||||
* @param ringbuffer
|
* @param ringbuffer
|
||||||
* @return the number of bytes stored in that 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
|
/** returns the capacity of the ring buffer
|
||||||
* @param ringbuffer
|
* @param ringbuffer
|
||||||
* @return the capacity of this ring buffer
|
* @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
|
/** writes some bytes in the ringbuffer, if the data doesn't fit, the ringbuffer
|
||||||
* is resized automatically
|
* is resized automatically
|
||||||
@ -76,7 +82,7 @@ size_t ringbuffer_capacity(const RingBuffer *ringbuffer);
|
|||||||
* @param sz the size of the data to add
|
* @param sz the size of the data to add
|
||||||
* @return if the operation was successful, it could fail in case of OOM during realloc()
|
* @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
|
/** 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
|
* @param sz the size to ensure
|
||||||
* @return a pointer on the write head, or NULL in case of OOM
|
* @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
|
/** 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
|
* 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
|
* @param sz the number of bytes that have been written
|
||||||
* @return if the operation was successful, FALSE is sz is too big
|
* @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.
|
/** 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
|
* @param sz the requested size
|
||||||
* @return the number of chunks used for reading sz bytes
|
* @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()
|
/** 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.
|
* 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 rb the ring buffer
|
||||||
* @param sz the
|
* @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___ */
|
#endif /* __RINGBUFFER_H___ */
|
||||||
|
@ -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
|
/* we directly append extra bytes in the xmit buffer, this could be prevented
|
||||||
* but for now it makes the code more simple.
|
* 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);
|
fprintf(stderr, "%s: an error occured when writing(toWrite=%d)\n", __FUNCTION__, num);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user