GNUnet 0.25.2-12-g8d1cef5f6
 
Loading...
Searching...
No Matches
gnunet_buffer_lib.h
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
31#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__)
32#error "Only <gnunet_util_lib.h> can be included directly."
33#endif
34
35#ifndef GNUNET_BUFFER_LIB_H
36#define GNUNET_BUFFER_LIB_H
37
48{
52 size_t capacity;
53
57 size_t position;
58
62 char *mem;
63
68};
69
70
80void
82 size_t capacity);
83
84
91void
93
94
101void
103 size_t n);
104
105
116void
118 const char *data,
119 size_t len);
120
121
130void
132 const char *str);
133
134
144void
146 const void *data,
147 size_t data_len);
148
149
158void
160 const char *str);
161
162
173void
175 const char *fmt,
176 ...)
177__attribute__ ((format (printf, 2, 3)));
178
179
190void
192 const char *fmt,
193 va_list args);
194
195
206char *
208
209
219void *
221 size_t *size);
222
223
231void
233
234
235#endif
236
/* end of group addition */
static char * data
The data to insert into the dht.
struct GNUNET_PQ_ResultSpec __attribute__
char * GNUNET_buffer_reap_str(struct GNUNET_Buffer *buf)
Clear the buffer and return the string it contained.
Definition buffer.c:89
void GNUNET_buffer_write_data_encoded(struct GNUNET_Buffer *buf, const void *data, size_t data_len)
Write data encoded via GNUNET_STRINGS_data_to_string to the buffer.
Definition buffer.c:201
void GNUNET_buffer_large(struct GNUNET_Buffer *buf)
Informs the buffer library to expect this buffer to be potentially very large (exceeding GNUNET_mallo...
void GNUNET_buffer_ensure_remaining(struct GNUNET_Buffer *buf, size_t n)
Make sure that at least n bytes remaining in the buffer.
Definition buffer.c:40
void * GNUNET_buffer_reap(struct GNUNET_Buffer *buf, size_t *size)
Clear the buffer and return its contents.
Definition buffer.c:109
void GNUNET_buffer_write_fstr(struct GNUNET_Buffer *buf, const char *fmt,...) __attribute__((format(printf
Write a 0-terminated formatted string to a buffer, excluding the 0-terminator.
void void GNUNET_buffer_write_vfstr(struct GNUNET_Buffer *buf, const char *fmt, va_list args)
Write a 0-terminated formatted string to a buffer, excluding the 0-terminator.
Definition buffer.c:169
void GNUNET_buffer_write(struct GNUNET_Buffer *buf, const char *data, size_t len)
Write bytes to the buffer.
Definition buffer.c:63
void GNUNET_buffer_prealloc(struct GNUNET_Buffer *buf, size_t capacity)
Initialize a buffer with the given capacity.
Definition buffer.c:26
void GNUNET_buffer_write_path(struct GNUNET_Buffer *buf, const char *str)
Write a path component to a buffer, ensuring that there is exactly one slash between the previous con...
Definition buffer.c:133
void GNUNET_buffer_write_str(struct GNUNET_Buffer *buf, const char *str)
Write a 0-terminated string to a buffer, excluding the 0-terminator.
Definition buffer.c:77
void GNUNET_buffer_clear(struct GNUNET_Buffer *buf)
Free the backing memory of the given buffer.
Definition buffer.c:123
static unsigned int size
Size of the "table".
Definition peer.c:68
Dynamically growing buffer.
size_t capacity
Capacity of the buffer.
int warn_grow
Log a warning if the buffer is grown over its initially allocated capacity.
size_t position
Current write position.
char * mem
Backing memory.
const char * str
Definition time.c:1252