GNUnet  0.17.6
Data Structures | Macros | Enumerations | Functions
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...
 
#define MAX_META_DATA   (1024 * 1024)
 Maximum size allowed for meta data written/read from disk. 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...
 
int GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg)
 Close an open 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...
 
int GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what, void *result, size_t len)
 Read some contents into a buffer. More...
 
int GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, char **result, size_t max_length)
 Read 0-terminated string. More...
 
int GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *what, struct GNUNET_CONTAINER_MetaData **result)
 Read a metadata container. More...
 
int GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, const char *what, float *f)
 Read a float. More...
 
int GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, const char *what, double *f)
 Read a double. More...
 
int GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, const char *what, int32_t *i)
 Read an (u)int32_t. More...
 
int 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...
 
int GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg)
 Close an IO handle. More...
 
int GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h)
 Force a file-based buffered writer to flush its buffer. More...
 
int 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 int 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...
 
int GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const char *what, const void *buffer, size_t n)
 Write a buffer to a handle. More...
 
int GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, const char *what, const char *s)
 Write a 0-terminated string. More...
 
int GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h, const char *what, const struct GNUNET_CONTAINER_MetaData *m)
 Write a metadata container. More...
 
int GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, const char *what, float f)
 Write a float. More...
 
int GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, const char *what, double f)
 Write a double. More...
 
int GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, const char *what, int32_t i)
 Write an (u)int32_t. More...
 
int 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_meta_data (void *cls, struct GNUNET_BIO_ReadHandle *h, const char *what, void *target, size_t target_size)
 Function used internally to read a metadata container from within a read spec. More...
 
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_meta_data (const char *what, struct GNUNET_CONTAINER_MetaData **result)
 Create the specification to read a metadata container. 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...
 
int 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_meta_data (void *cls, struct GNUNET_BIO_WriteHandle *h, const char *what, void *source, size_t source_size)
 Function used internally to write a metadata container from within a write spec. More...
 
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_meta_data (const char *what, const struct GNUNET_CONTAINER_MetaData *m)
 Create the specification to write a metadata container. 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...
 
int 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 28 of file bio.c.

◆ PATH_MAX

#define PATH_MAX   4096

Assumed maximum path length (for source file names).

Definition at line 34 of file bio.c.

◆ BIO_BUFFER_SIZE

#define BIO_BUFFER_SIZE   65536

Size for I/O buffers.

Definition at line 41 of file bio.c.

◆ MAX_META_DATA

#define MAX_META_DATA   (1024 * 1024)

Maximum size allowed for meta data written/read from disk.

File-sharing limits to 64k, so this should be rather generous.

Definition at line 47 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 56 of file bio.c.

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

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 201 of file bio.c.

205 {
206  size_t pos = 0;
207  size_t min;
208  ssize_t ret;
209 
210  do
211  {
212  min = h->have - h->pos;
213  if (0 < min)
214  {
215  if (len - pos < min)
216  min = len - pos;
217  GNUNET_memcpy (&result[pos], &h->buffer[h->pos], min);
218  h->pos += min;
219  pos += min;
220  }
221  if (len == pos)
222  return GNUNET_OK;
223  GNUNET_assert (((off_t) h->have) == h->pos);
224  ret = GNUNET_DISK_file_read (h->fd, h->buffer, h->size);
225  if (-1 == ret)
226  {
227  GNUNET_asprintf (&h->emsg,
228  _ ("Error reading `%s' from file: %s"),
229  what,
230  strerror (errno));
231  return GNUNET_SYSERR;
232  }
233  if (0 == ret)
234  {
235  GNUNET_asprintf (&h->emsg,
236  _ ("Error reading `%s' from file: %s"),
237  what,
238  _ ("End of file"));
239  return GNUNET_SYSERR;
240  }
241  h->pos = 0;
242  h->have = ret;
243  }
244  while (pos < len);
245  return GNUNET_OK;
246 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
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:622
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
Definition: gnunet_common.h:99
@ GNUNET_SYSERR
Definition: gnunet_common.h:97
#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:177

References _, GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_file_read(), GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, h, len, 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 259 of file bio.c.

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

References _, GNUNET_asprintf(), GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, h, len, 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 int 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 719 of file bio.c.

723 {
724  size_t min;
725  size_t pos = 0;
726  char *buffer = (char *) h->buffer;
727 
728  if (NULL == h->fd)
729  {
730  GNUNET_asprintf (&h->emsg,
731  _ ("Error while writing `%s' to file: %s"),
732  what,
733  _ ("No associated file"));
734  return GNUNET_SYSERR;
735  }
736 
737  do
738  {
739  min = h->size - h->have;
740  if (len - pos < min)
741  min = len - pos;
742  GNUNET_memcpy (&buffer[h->have], &source[pos], min);
743  pos += min;
744  h->have += min;
745  if (len == pos)
746  return GNUNET_OK;
747  GNUNET_assert (h->have == h->size);
748  if (GNUNET_OK != GNUNET_BIO_flush (h))
749  {
750  char *tmp = h->emsg;
751  GNUNET_asprintf (&h->emsg,
752  _ ("Error while writing `%s' to file: %s"),
753  what,
754  tmp);
755  GNUNET_free (tmp);
756  return GNUNET_SYSERR;
757  }
758  }
759  while (pos < len);
760  GNUNET_break (0);
761  return GNUNET_OK;
762 }
static GstElement * source
Appsrc instance into which we write data for the pipeline.
int GNUNET_BIO_flush(struct GNUNET_BIO_WriteHandle *h)
Force a file-based buffered writer to flush its buffer.
Definition: bio.c:656
#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, len, 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 775 of file bio.c.

779 {
780  GNUNET_buffer_write ((struct GNUNET_Buffer *) h->buffer, source, len);
781  h->have += len;
782  return GNUNET_OK;
783 }
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, len, 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 979 of file bio.c.

984 {
985  return GNUNET_BIO_read (h, what, target, target_size);
986 }
int 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:288

◆ 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 1025 of file bio.c.

1030 {
1031  char **result = target;
1032  return GNUNET_BIO_read_string (h, what, result, target_size);
1033 }
int 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:327

◆ read_spec_handler_meta_data()

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

Function used internally to read a metadata container 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 on error

Definition at line 1073 of file bio.c.

1078 {
1079  struct GNUNET_CONTAINER_MetaData **result = target;
1080  return GNUNET_BIO_read_meta_data (h, what, result);
1081 }
int GNUNET_BIO_read_meta_data(struct GNUNET_BIO_ReadHandle *h, const char *what, struct GNUNET_CONTAINER_MetaData **result)
Read a metadata container.
Definition: bio.c:390
Meta data to associate with a file, directory or namespace.

◆ 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 1117 of file bio.c.

1122 {
1123  int32_t *result = target;
1124  return GNUNET_BIO_read_int32 (h, what, result);
1125 }
int GNUNET_BIO_read_int32(struct GNUNET_BIO_ReadHandle *h, const char *what, int32_t *i)
Read an (u)int32_t.
Definition: bio.c:479

◆ 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 1161 of file bio.c.

1166 {
1167  int64_t *result = target;
1168  return GNUNET_BIO_read_int64 (h, what, result);
1169 }
int GNUNET_BIO_read_int64(struct GNUNET_BIO_ReadHandle *h, const char *what, int64_t *i)
Read an (u)int64_t.
Definition: bio.c:501

◆ 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 1270 of file bio.c.

1275 {
1276  return GNUNET_BIO_write (h, what, source, source_size);
1277 }
int 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:796

◆ 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 1317 of file bio.c.

1322 {
1323  const char *s = source;
1324  return GNUNET_BIO_write_string (h, what, s);
1325 }
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *what, const char *s)
Write a 0-terminated string.
Definition: bio.c:833

◆ write_spec_handler_meta_data()

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

Function used internally to write a metadata container 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 1363 of file bio.c.

1368 {
1369  const struct GNUNET_CONTAINER_MetaData *m = source;
1370  return GNUNET_BIO_write_meta_data (h, what, m);
1371 }
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
int GNUNET_BIO_write_meta_data(struct GNUNET_BIO_WriteHandle *h, const char *what, const struct GNUNET_CONTAINER_MetaData *m)
Write a metadata container.
Definition: bio.c:857

◆ 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 1408 of file bio.c.

1413 {
1414  int32_t i = *(int32_t *) source;
1415  return GNUNET_BIO_write_int32 (h, what, i);
1416 }
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, const char *what, int32_t i)
Write an (u)int32_t.
Definition: bio.c:937

◆ 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 1453 of file bio.c.

1458 {
1459  int64_t i = *(int64_t *) source;
1460  return GNUNET_BIO_write_int64 (h, what, i);
1461 }
int GNUNET_BIO_write_int64(struct GNUNET_BIO_WriteHandle *h, const char *what, int64_t i)
Write an (u)int64_t.
Definition: bio.c:957