4 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
6 * SPDX-License-Identifier: GPL-2.0-or-later
10 #define __W_BUFFER_H__
14 #include "ws_symbol_export.h"
18 #endif /* __cplusplus */
20 #define SOME_FUNCTIONS_ARE_DEFINES
22 typedef struct Buffer
{
30 void ws_buffer_init(Buffer
* buffer
, size_t space
);
32 void ws_buffer_free(Buffer
* buffer
);
34 void ws_buffer_assure_space(Buffer
* buffer
, size_t space
);
36 void ws_buffer_append(Buffer
* buffer
, uint8_t *from
, size_t bytes
);
38 void ws_buffer_remove_start(Buffer
* buffer
, size_t bytes
);
40 void ws_buffer_cleanup(void);
42 #ifdef SOME_FUNCTIONS_ARE_DEFINES
43 # define ws_buffer_clean(buffer) ws_buffer_remove_start((buffer), ws_buffer_length(buffer))
44 # define ws_buffer_increase_length(buffer,bytes) (buffer)->first_free += (bytes)
45 # define ws_buffer_length(buffer) ((buffer)->first_free - (buffer)->start)
46 # define ws_buffer_start_ptr(buffer) ((buffer)->data + (buffer)->start)
47 # define ws_buffer_end_ptr(buffer) ((buffer)->data + (buffer)->first_free)
48 # define ws_buffer_append_buffer(buffer,src_buffer) ws_buffer_append((buffer), ws_buffer_start_ptr(src_buffer), ws_buffer_length(src_buffer))
51 void ws_buffer_clean(Buffer
* buffer
);
53 void ws_buffer_increase_length(Buffer
* buffer
, size_t bytes
);
55 size_t ws_buffer_length(Buffer
* buffer
);
57 uint8_t* ws_buffer_start_ptr(Buffer
* buffer
);
59 uint8_t* ws_buffer_end_ptr(Buffer
* buffer
);
61 void ws_buffer_append_buffer(Buffer
* buffer
, Buffer
* src_buffer
);
66 #endif /* __cplusplus */