GNUnet 0.22.2
bio.c File Reference

functions for buffering IO More...

#include "platform.h"
#include "gnunet_util_lib.h"
Include dependency graph for bio.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_BIO_ReadHandle
 Handle for buffered reading. More...
 
struct  GNUNET_BIO_WriteHandle
 Handle for buffered writing. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "util-bio", __VA_ARGS__)
 
#define PATH_MAX   4096
 Assumed maximum path length (for source file names). More...
 
#define BIO_BUFFER_SIZE   65536
 Size for I/O buffers. More...
 

Enumerations

enum  IOType { IO_FILE = 0 , IO_BUFFER }
 Enum used internally to know how buffering is handled. More...
 

Functions

struct GNUNET_BIO_ReadHandleGNUNET_BIO_read_open_file (const char *fn)
 Open a file for reading. More...
 
struct GNUNET_BIO_ReadHandleGNUNET_BIO_read_open_buffer (void *buffer, size_t size)
 Create a handle from an existing allocated buffer. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg)
 Close an open handle. More...
 
void GNUNET_BIO_read_set_error (struct GNUNET_BIO_ReadHandle *h, const char *emsg)
 Set read error to handle. More...
 
static int read_from_file (struct GNUNET_BIO_ReadHandle *h, const char *what, char *result, size_t len)
 Function used internally to read the contents of a file into a buffer. More...
 
static int read_from_buffer (struct GNUNET_BIO_ReadHandle *h, const char *what, char *result, size_t len)
 Function used internally to read the content of a buffer into a buffer. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what, void *result, size_t len)
 Read some contents into a buffer. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, char **result, size_t max_length)
 Read 0-terminated string. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, const char *what, float *f)
 Read a float. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, const char *what, double *f)
 Read a double. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, const char *what, int32_t *i)
 Read an (u)int32_t. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_read_int64 (struct GNUNET_BIO_ReadHandle *h, const char *what, int64_t *i)
 Read an (u)int64_t. More...
 
struct GNUNET_BIO_WriteHandleGNUNET_BIO_write_open_file (const char *fn)
 Open a file for writing. More...
 
struct GNUNET_BIO_WriteHandleGNUNET_BIO_write_open_buffer (void)
 Create a handle backed by an in-memory buffer. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg)
 Close an IO handle. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h)
 Force a file-based buffered writer to flush its buffer. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h, char **emsg, void **contents, size_t *size)
 Get the IO handle's contents. More...
 
static enum GNUNET_GenericReturnValue write_to_file (struct GNUNET_BIO_WriteHandle *h, const char *what, const char *source, size_t len)
 Function used internally to write the contents of a buffer into a file. More...
 
static int write_to_buffer (struct GNUNET_BIO_WriteHandle *h, const char *what, const char *source, size_t len)
 Function used internally to write the contents of a buffer to another buffer. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const char *what, const void *buffer, size_t n)
 Write a buffer to a handle. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, const char *what, const char *s)
 Write a 0-terminated string. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, const char *what, float f)
 Write a float. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, const char *what, double f)
 Write a double. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, const char *what, int32_t i)
 Write an (u)int32_t. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, const char *what, int64_t i)
 Write an (u)int64_t. More...
 
static int read_spec_handler_object (void *cls, struct GNUNET_BIO_ReadHandle *h, const char *what, void *target, size_t target_size)
 Function used internally to read some bytes from within a read spec. More...
 
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_object (const char *what, void *result, size_t len)
 Create the specification to read a certain amount of bytes. More...
 
static int read_spec_handler_string (void *cls, struct GNUNET_BIO_ReadHandle *h, const char *what, void *target, size_t target_size)
 Function used internally to read a string from within a read spec. More...
 
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_string (const char *what, char **result, size_t max_length)
 Create the specification to read a 0-terminated string. More...
 
static int read_spec_handler_int32 (void *cls, struct GNUNET_BIO_ReadHandle *h, const char *what, void *target, size_t target_size)
 Function used internally to read an (u)int32_t from within a read spec. More...
 
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_int32 (const char *what, int32_t *i)
 Create the specification to read an (u)int32_t. More...
 
static int read_spec_handler_int64 (void *cls, struct GNUNET_BIO_ReadHandle *h, const char *what, void *target, size_t target_size)
 Function used internally to read an (u)int64_t from within a read spec. More...
 
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_int64 (const char *what, int64_t *i)
 Create the specification to read an (u)int64_t. More...
 
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_float (const char *what, float *f)
 Create the specification to read a float. More...
 
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_double (const char *what, double *f)
 Create the specification to read a double. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_read_spec_commit (struct GNUNET_BIO_ReadHandle *h, struct GNUNET_BIO_ReadSpec *rs)
 Execute the read specifications in order. More...
 
static int write_spec_handler_object (void *cls, struct GNUNET_BIO_WriteHandle *h, const char *what, void *source, size_t source_size)
 Function used internally to write some bytes from within a write spec. More...
 
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_object (const char *what, void *source, size_t size)
 Create the specification to read some bytes. More...
 
static int write_spec_handler_string (void *cls, struct GNUNET_BIO_WriteHandle *h, const char *what, void *source, size_t source_size)
 Function used internally to write a 0-terminated string from within a write spec. More...
 
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_string (const char *what, const char *s)
 Create the specification to write a 0-terminated string. More...
 
static int write_spec_handler_int32 (void *cls, struct GNUNET_BIO_WriteHandle *h, const char *what, void *source, size_t source_size)
 Function used internally to write an (u)int32_t from within a write spec. More...
 
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_int32 (const char *what, int32_t *i)
 Create the specification to write an (u)int32_t. More...
 
static int write_spec_handler_int64 (void *cls, struct GNUNET_BIO_WriteHandle *h, const char *what, void *source, size_t source_size)
 Function used internally to write an (u)int64_t from within a write spec. More...
 
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_int64 (const char *what, int64_t *i)
 Create the specification to write an (u)int64_t. More...
 
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_float (const char *what, float *f)
 Create the specification to write a float. More...
 
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_double (const char *what, double *f)
 Create the specification to write an double. More...
 
enum GNUNET_GenericReturnValue GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h, struct GNUNET_BIO_WriteSpec *ws)
 Execute the write specifications in order. More...
 

Detailed Description

functions for buffering IO

Author
Christian Grothoff

Definition in file bio.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "util-bio", __VA_ARGS__)

Definition at line 29 of file bio.c.

◆ PATH_MAX

#define PATH_MAX   4096

Assumed maximum path length (for source file names).

Definition at line 35 of file bio.c.

◆ BIO_BUFFER_SIZE

#define BIO_BUFFER_SIZE   65536

Size for I/O buffers.

Definition at line 42 of file bio.c.

Enumeration Type Documentation

◆ IOType

enum IOType

Enum used internally to know how buffering is handled.

The idea is that by using an enum, BIO can be extended to support other kinds of "backend" for buffering (or just formatted I/O.)

Enumerator
IO_FILE 

The handle uses a file to read/write data.

IO_BUFFER 

The data is stored entirely in memory.

Definition at line 51 of file bio.c.

52{
56 IO_FILE = 0,
57
62};
@ IO_BUFFER
The data is stored entirely in memory.
Definition: bio.c:61
@ IO_FILE
The handle uses a file to read/write data.
Definition: bio.c:56

Function Documentation

◆ read_from_file()

static int read_from_file ( struct GNUNET_BIO_ReadHandle h,
const char *  what,
char *  result,
size_t  len 
)
static

Function used internally to read the contents of a file into a buffer.

Parameters
hthe IO handle to read from
whatdescribes what is being read (for error message creation)
resultthe buffer to write the data to
lenthe number of bytes to read
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 204 of file bio.c.

208{
209 size_t pos = 0;
210 size_t min;
211 ssize_t ret;
212
213 do
214 {
215 min = h->have - h->pos;
216 if (0 < min)
217 {
218 if (len - pos < min)
219 min = len - pos;
220 GNUNET_memcpy (&result[pos], &h->buffer[h->pos], min);
221 h->pos += min;
222 pos += min;
223 }
224 if (len == pos)
225 return GNUNET_OK;
226 GNUNET_assert (((off_t) h->have) == h->pos);
227 ret = GNUNET_DISK_file_read (h->fd, h->buffer, h->size);
228 if (-1 == ret)
229 {
230 GNUNET_asprintf (&h->emsg,
231 _ ("Error reading `%s' from file: %s"),
232 what,
233 strerror (errno));
234 return GNUNET_SYSERR;
235 }
236 if (0 == ret)
237 {
238 GNUNET_asprintf (&h->emsg,
239 _ ("Error reading `%s' from file: %s"),
240 what,
241 _ ("End of file"));
242 return GNUNET_SYSERR;
243 }
244 h->pos = 0;
245 h->have = ret;
246 }
247 while (pos < len);
248 return GNUNET_OK;
249}
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
static int ret
Final status code.
Definition: gnunet-arm.c:93
static int result
Global testing status.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:646
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define min(x, y)
#define _(String)
GNU gettext support macro.
Definition: platform.h:178

References _, GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_file_read(), GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, h, min, GNUNET_BIO_ReadHandle::pos, result, and ret.

Referenced by GNUNET_BIO_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_from_buffer()

static int read_from_buffer ( struct GNUNET_BIO_ReadHandle h,
const char *  what,
char *  result,
size_t  len 
)
static

Function used internally to read the content of a buffer into a buffer.

Parameters
hthe IO handle to read from
whatdescribes what is being read (for error message creation)
resultthe buffer to write the result to
lenthe number of bytes to read
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 262 of file bio.c.

266{
267 if ((h->size < len) || (h->size - h->pos < len))
268 {
269 GNUNET_asprintf (&h->emsg,
270 _ ("Error while reading `%s' from buffer: %s"),
271 what,
272 _ ("Not enough data left"));
273 return GNUNET_SYSERR;
274 }
275 GNUNET_memcpy (result, h->buffer + h->pos, len);
276 h->pos += len;
277 return GNUNET_OK;
278}

References _, GNUNET_asprintf(), GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, h, and result.

Referenced by GNUNET_BIO_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_to_file()

static enum GNUNET_GenericReturnValue write_to_file ( struct GNUNET_BIO_WriteHandle h,
const char *  what,
const char *  source,
size_t  len 
)
static

Function used internally to write the contents of a buffer into a file.

Parameters
hthe IO handle to write to
whatdescribes what is being written (for error message creation)
sourcethe buffer to write
lenthe number of bytes to write
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 673 of file bio.c.

677{
678 size_t min;
679 size_t pos = 0;
680 char *buffer = (char *) h->buffer;
681
682 if (NULL == h->fd)
683 {
684 GNUNET_asprintf (&h->emsg,
685 _ ("Error while writing `%s' to file: %s"),
686 what,
687 _ ("No associated file"));
688 return GNUNET_SYSERR;
689 }
690
691 do
692 {
693 min = h->size - h->have;
694 if (len - pos < min)
695 min = len - pos;
696 GNUNET_memcpy (&buffer[h->have], &source[pos], min);
697 pos += min;
698 h->have += min;
699 if (len == pos)
700 return GNUNET_OK;
701 GNUNET_assert (h->have == h->size);
703 {
704 char *tmp = h->emsg;
705 GNUNET_asprintf (&h->emsg,
706 _ ("Error while writing `%s' to file: %s"),
707 what,
708 tmp);
709 GNUNET_free (tmp);
710 return GNUNET_SYSERR;
711 }
712 }
713 while (pos < len);
714 GNUNET_break (0);
715 return GNUNET_OK;
716}
static GstElement * source
Appsrc instance into which we write data for the pipeline.
enum GNUNET_GenericReturnValue GNUNET_BIO_flush(struct GNUNET_BIO_WriteHandle *h)
Force a file-based buffered writer to flush its buffer.
Definition: bio.c:607
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_free(ptr)
Wrapper around free.

References _, GNUNET_BIO_WriteHandle::buffer, GNUNET_asprintf(), GNUNET_assert, GNUNET_BIO_flush(), GNUNET_break, GNUNET_free, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, h, min, and source.

Referenced by GNUNET_BIO_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_to_buffer()

static int write_to_buffer ( struct GNUNET_BIO_WriteHandle h,
const char *  what,
const char *  source,
size_t  len 
)
static

Function used internally to write the contents of a buffer to another buffer.

Parameters
hthe IO handle to write to
whatdescribes what is being written (for error message creation)
sourcethe buffer to write
lenthe number of bytes to write
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 729 of file bio.c.

733{
734 GNUNET_buffer_write ((struct GNUNET_Buffer *) h->buffer, source, len);
735 h->have += len;
736 return GNUNET_OK;
737}
void GNUNET_buffer_write(struct GNUNET_Buffer *buf, const char *data, size_t len)
Write bytes to the buffer.
Definition: buffer.c:86
Dynamically growing buffer.

References GNUNET_buffer_write(), GNUNET_OK, h, and source.

Referenced by GNUNET_BIO_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_spec_handler_object()

static int read_spec_handler_object ( void *  cls,
struct GNUNET_BIO_ReadHandle h,
const char *  what,
void *  target,
size_t  target_size 
)
static

Function used internally to read some bytes from within a read spec.

Parameters
clsignored, always NULL
hthe IO handle to read from
whatwhat is being read (for error message creation)
targetwhere to store the data
target_sizehow many bytes to read
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 887 of file bio.c.

892{
893 return GNUNET_BIO_read (h, what, target, target_size);
894}
enum GNUNET_GenericReturnValue GNUNET_BIO_read(struct GNUNET_BIO_ReadHandle *h, const char *what, void *result, size_t len)
Read some contents into a buffer.
Definition: bio.c:291

References GNUNET_BIO_read(), and h.

Referenced by GNUNET_BIO_read_spec_object().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_spec_handler_string()

static int read_spec_handler_string ( void *  cls,
struct GNUNET_BIO_ReadHandle h,
const char *  what,
void *  target,
size_t  target_size 
)
static

Function used internally to read a string from within a read spec.

Parameters
clsignored, always NULL
hthe IO handle to read from
whatwhat is being read (for error message creation)
targetwhere to store the data
target_sizehow many bytes to read
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 933 of file bio.c.

938{
939 char **result = target;
940 return GNUNET_BIO_read_string (h, what, result, target_size);
941}
enum GNUNET_GenericReturnValue GNUNET_BIO_read_string(struct GNUNET_BIO_ReadHandle *h, const char *what, char **result, size_t max_length)
Read 0-terminated string.
Definition: bio.c:330

References GNUNET_BIO_read_string(), h, result, GNUNET_BIO_ReadSpec::target, and GNUNET_BIO_ReadSpec::what.

Referenced by GNUNET_BIO_read_spec_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_spec_handler_int32()

static int read_spec_handler_int32 ( void *  cls,
struct GNUNET_BIO_ReadHandle h,
const char *  what,
void *  target,
size_t  target_size 
)
static

Function used internally to read an (u)int32_t from within a read spec.

Parameters
clsignored, always NULL
hthe IO handle to read from
whatwhat is being read (for error message creation)
targetwhere to store the data
target_sizeignored
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 980 of file bio.c.

985{
986 int32_t *result = target;
987 return GNUNET_BIO_read_int32 (h, what, result);
988}
enum GNUNET_GenericReturnValue GNUNET_BIO_read_int32(struct GNUNET_BIO_ReadHandle *h, const char *what, int32_t *i)
Read an (u)int32_t.
Definition: bio.c:427

References GNUNET_BIO_read_int32(), h, result, GNUNET_BIO_ReadSpec::target, and GNUNET_BIO_ReadSpec::what.

Referenced by GNUNET_BIO_read_spec_float(), and GNUNET_BIO_read_spec_int32().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_spec_handler_int64()

static int read_spec_handler_int64 ( void *  cls,
struct GNUNET_BIO_ReadHandle h,
const char *  what,
void *  target,
size_t  target_size 
)
static

Function used internally to read an (u)int64_t from within a read spec.

Parameters
clsignored, always NULL
hthe IO handle to read from
whatwhat is being read (for error message creation)
targetwhere to store the data
target_sizeignored
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 1024 of file bio.c.

1029{
1030 int64_t *result = target;
1031 return GNUNET_BIO_read_int64 (h, what, result);
1032}
enum GNUNET_GenericReturnValue GNUNET_BIO_read_int64(struct GNUNET_BIO_ReadHandle *h, const char *what, int64_t *i)
Read an (u)int64_t.
Definition: bio.c:449

References GNUNET_BIO_read_int64(), h, result, GNUNET_BIO_ReadSpec::target, and GNUNET_BIO_ReadSpec::what.

Referenced by GNUNET_BIO_read_spec_double(), and GNUNET_BIO_read_spec_int64().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_spec_handler_object()

static int write_spec_handler_object ( void *  cls,
struct GNUNET_BIO_WriteHandle h,
const char *  what,
void *  source,
size_t  source_size 
)
static

Function used internally to write some bytes from within a write spec.

Parameters
clsignored, always NULL
hthe IO handle to write to
whatwhat is being written (for error message creation)
sourcethe data to write
source_sizehow many bytes to write
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 1133 of file bio.c.

1138{
1139 return GNUNET_BIO_write (h, what, source, source_size);
1140}
enum GNUNET_GenericReturnValue GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const char *what, const void *buffer, size_t n)
Write a buffer to a handle.
Definition: bio.c:750

References GNUNET_BIO_write(), h, source, and GNUNET_BIO_ReadSpec::what.

Referenced by GNUNET_BIO_write_spec_object().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_spec_handler_string()

static int write_spec_handler_string ( void *  cls,
struct GNUNET_BIO_WriteHandle h,
const char *  what,
void *  source,
size_t  source_size 
)
static

Function used internally to write a 0-terminated string from within a write spec.

Parameters
clsignored, always NULL
hthe IO handle to write to
whatwhat is being written (for error message creation)
sourcethe data to write
source_sizeignored
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 1180 of file bio.c.

1185{
1186 const char *s = source;
1187 return GNUNET_BIO_write_string (h, what, s);
1188}
enum GNUNET_GenericReturnValue GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *what, const char *s)
Write a 0-terminated string.
Definition: bio.c:787

References GNUNET_BIO_write_string(), h, source, and GNUNET_BIO_WriteSpec::what.

Referenced by GNUNET_BIO_write_spec_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_spec_handler_int32()

static int write_spec_handler_int32 ( void *  cls,
struct GNUNET_BIO_WriteHandle h,
const char *  what,
void *  source,
size_t  source_size 
)
static

Function used internally to write an (u)int32_t from within a write spec.

Parameters
clsignored, always NULL
hthe IO handle to write to
whatwhat is being written (for error message creation)
sourcethe data to write
source_sizeignored
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 1225 of file bio.c.

1230{
1231 int32_t i = *(int32_t *) source;
1232 return GNUNET_BIO_write_int32 (h, what, i);
1233}
enum GNUNET_GenericReturnValue GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, const char *what, int32_t i)
Write an (u)int32_t.
Definition: bio.c:845

References GNUNET_BIO_write_int32(), h, source, and GNUNET_BIO_WriteSpec::what.

Referenced by GNUNET_BIO_write_spec_float(), and GNUNET_BIO_write_spec_int32().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_spec_handler_int64()

static int write_spec_handler_int64 ( void *  cls,
struct GNUNET_BIO_WriteHandle h,
const char *  what,
void *  source,
size_t  source_size 
)
static

Function used internally to write an (u)int64_t from within a write spec.

Parameters
clsignored, always NULL
hthe IO handle to write to
whatwhat is being written (for error message creation)
sourcethe data to write
source_sizeignored
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 1270 of file bio.c.

1275{
1276 int64_t i = *(int64_t *) source;
1277 return GNUNET_BIO_write_int64 (h, what, i);
1278}
enum GNUNET_GenericReturnValue GNUNET_BIO_write_int64(struct GNUNET_BIO_WriteHandle *h, const char *what, int64_t i)
Write an (u)int64_t.
Definition: bio.c:865

References GNUNET_BIO_write_int64(), h, source, and GNUNET_BIO_WriteSpec::what.

Referenced by GNUNET_BIO_write_spec_double(), and GNUNET_BIO_write_spec_int64().

Here is the call graph for this function:
Here is the caller graph for this function: