Wireshark  4.3.0
The Wireshark network protocol analyzer
buffer.h
Go to the documentation of this file.
1 
9 #ifndef __W_BUFFER_H__
10 #define __W_BUFFER_H__
11 
12 #include <inttypes.h>
13 #include <stddef.h>
14 #include "ws_symbol_export.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
19 
20 #define SOME_FUNCTIONS_ARE_DEFINES
21 
22 typedef struct Buffer {
23  uint8_t *data;
24  size_t allocated;
25  size_t start;
26  size_t first_free;
27 } Buffer;
28 
29 WS_DLL_PUBLIC
30 void ws_buffer_init(Buffer* buffer, size_t space);
31 WS_DLL_PUBLIC
32 void ws_buffer_free(Buffer* buffer);
33 WS_DLL_PUBLIC
34 void ws_buffer_assure_space(Buffer* buffer, size_t space);
35 WS_DLL_PUBLIC
36 void ws_buffer_append(Buffer* buffer, uint8_t *from, size_t bytes);
37 WS_DLL_PUBLIC
38 void ws_buffer_remove_start(Buffer* buffer, size_t bytes);
39 WS_DLL_PUBLIC
40 void ws_buffer_cleanup(void);
41 
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))
49 #else
50  WS_DLL_PUBLIC
51  void ws_buffer_clean(Buffer* buffer);
52  WS_DLL_PUBLIC
53  void ws_buffer_increase_length(Buffer* buffer, size_t bytes);
54  WS_DLL_PUBLIC
55  size_t ws_buffer_length(Buffer* buffer);
56  WS_DLL_PUBLIC
57  uint8_t* ws_buffer_start_ptr(Buffer* buffer);
58  WS_DLL_PUBLIC
59  uint8_t* ws_buffer_end_ptr(Buffer* buffer);
60  WS_DLL_PUBLIC
61  void ws_buffer_append_buffer(Buffer* buffer, Buffer* src_buffer);
62 #endif
63 
64 #ifdef __cplusplus
65 }
66 #endif /* __cplusplus */
67 
68 #endif
WS_DLL_PUBLIC void ws_buffer_remove_start(Buffer *buffer, size_t bytes)
Definition: buffer.c:113
Definition: buffer.h:22
Definition: mcast_stream.h:30