TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags
[wireshark-sm.git] / wsutil / buffer.h
blob628d324cc9102eb0b889f424ec69d75c72121156
1 /** @file
3 * Wiretap Library
4 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
9 #ifndef __W_BUFFER_H__
10 #define __W_BUFFER_H__
12 #include <inttypes.h>
13 #include <stddef.h>
14 #include "ws_symbol_export.h"
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
20 #define SOME_FUNCTIONS_ARE_DEFINES
22 typedef struct Buffer {
23 uint8_t *data;
24 size_t allocated;
25 size_t start;
26 size_t first_free;
27 } Buffer;
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);
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
64 #ifdef __cplusplus
66 #endif /* __cplusplus */
68 #endif