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.

Referenced by GNUNET_BIO_read_open_file(), and GNUNET_BIO_write_open_file().

◆ 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.

Referenced by GNUNET_BIO_read_meta_data(), and GNUNET_BIO_write_meta_data().

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 };
The handle uses a file to read/write data.
Definition: bio.c:61
The data is stored entirely in memory.
Definition: bio.c:66

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.

References _, GNUNET_BIO_ReadHandle::buffer, GNUNET_BIO_ReadHandle::emsg, GNUNET_BIO_ReadHandle::fd, GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_file_read(), GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, GNUNET_BIO_ReadHandle::have, min, GNUNET_BIO_ReadHandle::pos, ret, and GNUNET_BIO_ReadHandle::size.

Referenced by GNUNET_BIO_read().

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 }
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:602
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_DISK_FileHandle * fd
Handle to a file on disk, if type is IO_FILE.
Definition: bio.c:83
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
size_t size
Total size of buffer.
Definition: bio.c:103
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
size_t have
Number of bytes available in buffer.
Definition: bio.c:98
static int result
Global testing status.
char * buffer
I/O buffer.
Definition: bio.c:93
off_t pos
Current read offset in buffer.
Definition: bio.c:108
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define min(x, y)
char * emsg
Error message, NULL if there were no errors.
Definition: bio.c:88
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
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.

References _, GNUNET_BIO_ReadHandle::buffer, GNUNET_BIO_ReadHandle::emsg, GNUNET_asprintf(), GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, len, GNUNET_BIO_ReadHandle::pos, and GNUNET_BIO_ReadHandle::size.

Referenced by GNUNET_BIO_read().

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 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
size_t size
Total size of buffer.
Definition: bio.c:103
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
static int result
Global testing status.
char * buffer
I/O buffer.
Definition: bio.c:93
off_t pos
Current read offset in buffer.
Definition: bio.c:108
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
char * emsg
Error message, NULL if there were no errors.
Definition: bio.c:88
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
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.

References _, GNUNET_BIO_ReadHandle::buffer, GNUNET_BIO_WriteHandle::buffer, GNUNET_BIO_WriteHandle::emsg, GNUNET_BIO_WriteHandle::fd, GNUNET_asprintf(), GNUNET_assert, GNUNET_BIO_flush(), GNUNET_break, GNUNET_free, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, GNUNET_BIO_WriteHandle::have, min, GNUNET_BIO_ReadHandle::pos, and GNUNET_BIO_WriteHandle::size.

Referenced by GNUNET_BIO_write().

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 }
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_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_DISK_FileHandle * fd
Handle to a file on disk, if type is IO_FILE.
Definition: bio.c:526
void * buffer
I/O buffer.
Definition: bio.c:538
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
size_t have
Number of bytes available in buffer.
Definition: bio.c:543
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
#define min(x, y)
char * emsg
Error message, NULL if there were no errors.
Definition: bio.c:531
size_t size
Total size of buffer.
Definition: bio.c:548
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
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.

References GNUNET_BIO_WriteHandle::buffer, GNUNET_buffer_write(), GNUNET_OK, GNUNET_BIO_WriteHandle::have, and len.

Referenced by GNUNET_BIO_write().

778 {
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
void * buffer
I/O buffer.
Definition: bio.c:538
size_t have
Number of bytes available in buffer.
Definition: bio.c:543
static GstElement * source
Appsrc instance into which we write data for the pipeline.
Common buffer management functions.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
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.

References GNUNET_BIO_read().

Referenced by GNUNET_BIO_read_spec_object().

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

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

Referenced by GNUNET_BIO_read_spec_string().

1029 {
1030  char **result = target;
1031  return GNUNET_BIO_read_string (h, what, result, target_size);
1032 }
static int result
Global testing status.
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

References GNUNET_BIO_read_meta_data(), and result.

Referenced by GNUNET_BIO_read_spec_meta_data().

1077 {
1078  struct GNUNET_CONTAINER_MetaData **result = target;
1079  return GNUNET_BIO_read_meta_data (h, what, result);
1080 }
Meta data to associate with a file, directory or namespace.
static int result
Global testing status.
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
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 1116 of file bio.c.

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

Referenced by GNUNET_BIO_read_spec_float(), and GNUNET_BIO_read_spec_int32().

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
static int result
Global testing status.
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 1160 of file bio.c.

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

Referenced by GNUNET_BIO_read_spec_double(), and GNUNET_BIO_read_spec_int64().

1165 {
1166  int64_t *result = target;
1167  return GNUNET_BIO_read_int64 (h, what, result);
1168 }
static int result
Global testing status.
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
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 1269 of file bio.c.

References GNUNET_BIO_write().

Referenced by GNUNET_BIO_write_spec_object().

1274 {
1275  return GNUNET_BIO_write (h, what, source, source_size);
1276 }
static GstElement * source
Appsrc instance into which we write data for the pipeline.
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
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 1316 of file bio.c.

References GNUNET_BIO_write_string(), and source.

Referenced by GNUNET_BIO_write_spec_string().

1321 {
1322  const char *s = source;
1323  return GNUNET_BIO_write_string (h, what, s);
1324 }
static GstElement * source
Appsrc instance into which we write data for the pipeline.
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

References GNUNET_BIO_write_meta_data(), m, and source.

Referenced by GNUNET_BIO_write_spec_meta_data().

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
Meta data to associate with a file, directory or namespace.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
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
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 1407 of file bio.c.

References GNUNET_BIO_write_int32().

Referenced by GNUNET_BIO_write_spec_float(), and GNUNET_BIO_write_spec_int32().

1412 {
1413  int32_t i = *(int32_t *) source;
1414  return GNUNET_BIO_write_int32 (h, what, i);
1415 }
static GstElement * source
Appsrc instance into which we write data for the pipeline.
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
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 1452 of file bio.c.

References GNUNET_BIO_write_int64().

Referenced by GNUNET_BIO_write_spec_double(), and GNUNET_BIO_write_spec_int64().

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
static GstElement * source
Appsrc instance into which we write data for the pipeline.
Here is the call graph for this function:
Here is the caller graph for this function: