nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /* buffer.h
2 *
3 * Wiretap Library
4 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 */
21  
22 #ifndef __W_BUFFER_H__
23 #define __W_BUFFER_H__
24  
25 #include <glib.h>
26 #include "ws_symbol_export.h"
27  
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31  
32 #define SOME_FUNCTIONS_ARE_DEFINES
33  
34 typedef struct Buffer {
35 guint8 *data;
36 gsize allocated;
37 gsize start;
38 gsize first_free;
39 } Buffer;
40  
41 WS_DLL_PUBLIC
42 void ws_buffer_init(Buffer* buffer, gsize space);
43 WS_DLL_PUBLIC
44 void ws_buffer_free(Buffer* buffer);
45 WS_DLL_PUBLIC
46 void ws_buffer_assure_space(Buffer* buffer, gsize space);
47 WS_DLL_PUBLIC
48 void ws_buffer_append(Buffer* buffer, guint8 *from, gsize bytes);
49 WS_DLL_PUBLIC
50 void ws_buffer_remove_start(Buffer* buffer, gsize bytes);
51  
52 #ifdef SOME_FUNCTIONS_ARE_DEFINES
53 # define ws_buffer_clean(buffer) ws_buffer_remove_start((buffer), ws_buffer_length(buffer))
54 # define ws_buffer_increase_length(buffer,bytes) (buffer)->first_free += (bytes)
55 # define ws_buffer_length(buffer) ((buffer)->first_free - (buffer)->start)
56 # define ws_buffer_start_ptr(buffer) ((buffer)->data + (buffer)->start)
57 # define ws_buffer_end_ptr(buffer) ((buffer)->data + (buffer)->first_free)
58 # define ws_buffer_append_buffer(buffer,src_buffer) ws_buffer_append((buffer), ws_buffer_start_ptr(src_buffer), ws_buffer_length(src_buffer))
59 #else
60 void ws_buffer_clean(Buffer* buffer);
61 void ws_buffer_increase_length(Buffer* buffer, unsigned int bytes);
62 unsigned int ws_buffer_length(Buffer* buffer);
63 guint8* ws_buffer_start_ptr(Buffer* buffer);
64 guint8* ws_buffer_end_ptr(Buffer* buffer);
65 void ws_buffer_append_buffer(Buffer* buffer, Buffer* src_buffer);
66 #endif
67  
68 #ifdef __cplusplus
69 }
70 #endif /* __cplusplus */
71  
72 #endif