GNUnet  0.11.x
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 200 of file bio.c.

204 {
205  size_t pos = 0;
206  size_t min;
207  ssize_t ret;
208 
209  do
210  {
211  min = h->have - h->pos;
212  if (0 < min)
213  {
214  if (len - pos < min)
215  min = len - pos;
216  GNUNET_memcpy (&result[pos], &h->buffer[h->pos], min);
217  h->pos += min;
218  pos += min;
219  }
220  if (len == pos)
221  return GNUNET_OK;
222  GNUNET_assert (((off_t) h->have) == h->pos);
223  ret = GNUNET_DISK_file_read (h->fd, h->buffer, h->size);
224  if (-1 == ret)
225  {
226  GNUNET_asprintf (&h->emsg,
227  _ ("Error reading `%s' from file: %s"),
228  what,
229  strerror (errno));
230  return GNUNET_SYSERR;
231  }
232  if (0 == ret)
233  {
234  GNUNET_asprintf (&h->emsg,
235  _ ("Error reading `%s' from file: %s"),
236  what,
237  _ ("End of file"));
238  return GNUNET_SYSERR;
239  }
240  h->pos = 0;
241  h->have = ret;
242  }
243  while (pos < len);
244  return GNUNET_OK;
245 }
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.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
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_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 258 of file bio.c.

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

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

722 {
723  size_t min;
724  size_t pos = 0;
725  char *buffer = (char *) h->buffer;
726 
727  if (NULL == h->fd)
728  {
729  GNUNET_asprintf (&h->emsg,
730  _ ("Error while writing `%s' to file: %s"),
731  what,
732  _ ("No associated file"));
733  return GNUNET_SYSERR;
734  }
735 
736  do
737  {
738  min = h->size - h->have;
739  if (len - pos < min)
740  min = len - pos;
741  GNUNET_memcpy (&buffer[h->have], &source[pos], min);
742  pos += min;
743  h->have += min;
744  if (len == pos)
745  return GNUNET_OK;
746  GNUNET_assert (h->have == h->size);
747  if (GNUNET_OK != GNUNET_BIO_flush (h))
748  {
749  char *tmp = h->emsg;
750  GNUNET_asprintf (&h->emsg,
751  _ ("Error while writing `%s' to file: %s"),
752  what,
753  tmp);
754  GNUNET_free (tmp);
755  return GNUNET_SYSERR;
756  }
757  }
758  while (pos < len);
759  GNUNET_break (0);
760  return GNUNET_OK;
761 }
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:655
#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 774 of file bio.c.

778 {
779  GNUNET_buffer_write ((struct GNUNET_Buffer *) h->buffer, source, len);
780  h->have += len;
781  return GNUNET_OK;
782 }
void GNUNET_buffer_write(struct GNUNET_Buffer *buf, const char *data, size_t len)
Write bytes to the buffer.
Definition: buffer.c:86
Common buffer management functions.

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

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

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

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

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

1077 {
1078  struct GNUNET_CONTAINER_MetaData **result = target;
1079  return GNUNET_BIO_read_meta_data (h, what, result);
1080 }
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:389
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 1116 of file bio.c.

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

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

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

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

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

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

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

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

1367 {
1368  const struct GNUNET_CONTAINER_MetaData *m = source;
1369  return GNUNET_BIO_write_meta_data (h, what, m);
1370 }
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:856

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

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

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

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