TaPAS  0.2
Functions
genepi-io.h File Reference

Useful functions used to serialize GENEPI sets. More...

#include <stdio.h>
#include <genepi/genepi-common.h>

Go to the source code of this file.

Functions

int genepi_io_write_uint8 (FILE *out, uint8_t i, int *perr)
 Write an 8-bit unsigned integer on the out stream. More...
 
int genepi_io_write_int8 (FILE *out, int8_t i, int *perr)
 Write an 8-bit signed integer on the out stream. More...
 
int genepi_io_write_uint16 (FILE *out, uint16_t i, int *perr)
 Write a 16-bit unsigned integer on the out stream. More...
 
int genepi_io_write_int16 (FILE *out, int16_t i, int *perr)
 Write a 16-bit signed integer on the out stream. More...
 
int genepi_io_write_uint32 (FILE *out, uint32_t i, int *perr)
 Write a 32-bit unsigned integer on the out stream. More...
 
int genepi_io_write_int32 (FILE *out, int32_t i, int *perr)
 Write a 32-bit signed integer on the out stream. More...
 
int genepi_io_write_string (FILE *out, const char *s, int *perr)
 Write a string on the out stream. The string s can be null in which case the NULL value will be reloaded by the read_string function. More...
 
int genepi_io_write_buffer (FILE *out, const void *buf, size_t size, int *perr)
 Write the content of the buffer buf on the out stream. Oppositely to strings the given buffer must not be NULL. More...
 
int genepi_io_read_uint8 (FILE *in, uint8_t *pi, int *perr)
 Read an 8-bit unsigned integer on the in stream. The signedness of the integer is not checked. More...
 
int genepi_io_read_int8 (FILE *in, int8_t *pi, int *perr)
 Read an 8-bit signed integer on the in stream. The signedness of the integer is not checked. More...
 
int genepi_io_read_uint16 (FILE *in, uint16_t *pi, int *perr)
 Read a 16-bit unsigned integer on the in stream. The signedness of the integer is not checked. More...
 
int genepi_io_read_int16 (FILE *in, int16_t *pi, int *perr)
 Read a 16-bit signed integer on the in stream. The signedness of the integer is not checked. More...
 
int genepi_io_read_uint32 (FILE *in, uint32_t *pi, int *perr)
 Read a 32-bit unsigned integer on the in stream. The signedness of the integer is not checked. More...
 
int genepi_io_read_int32 (FILE *in, int32_t *pi, int *perr)
 Read a 32-bit signed integer on the in stream. The signedness of the integer is not checked. More...
 
int genepi_io_read_string (FILE *in, char **ps, int *perr)
 Read a string on the in stream. The readed string might be NULL. More...
 
int genepi_io_read_buffer (FILE *in, void *buf, size_t size, int *perr)
 Read size bytes the in stream. More...
 

Detailed Description

Useful functions used to serialize GENEPI sets.

This module gathers functions that write some primitive C type into a FILE stream. In particular these functions take care of endianness of integers.

Each function returns the number of bytes actually written on or readed from the stream. If an error occurs then a genepi_io_error value is stored into *perr. If a function is called with a *perr that is negative then the function simply returns 0.

Remarks
The number of bytes written on the stream is not necessarily equal to the size of the data.

Definition in file genepi-io.h.

Function Documentation

int genepi_io_read_buffer ( FILE *  in,
void *  buf,
size_t  size,
int *  perr 
)

Read size bytes the in stream.

Parameters
inthe input stream
bufa pointer to buffer receiving the readed bytes
sizethe number of bytes to read.
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes readed on the stream in
int genepi_io_read_int16 ( FILE *  in,
int16_t *  pi,
int *  perr 
)

Read a 16-bit signed integer on the in stream. The signedness of the integer is not checked.

Parameters
inthe input stream
pia pointer to the variable which receive the readed value
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes readed on the stream in
int genepi_io_read_int32 ( FILE *  in,
int32_t *  pi,
int *  perr 
)

Read a 32-bit signed integer on the in stream. The signedness of the integer is not checked.

Parameters
inthe input stream
pia pointer to the variable which receive the readed value
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes readed on the stream in
int genepi_io_read_int8 ( FILE *  in,
int8_t *  pi,
int *  perr 
)

Read an 8-bit signed integer on the in stream. The signedness of the integer is not checked.

Parameters
inthe input stream
pia pointer to the variable which receive the readed value
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes readed on the stream in
int genepi_io_read_string ( FILE *  in,
char **  ps,
int *  perr 
)

Read a string on the in stream. The readed string might be NULL.

Parameters
inthe input stream
psa pointer to the variable which receive the readed string
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes readed on the stream in
int genepi_io_read_uint16 ( FILE *  in,
uint16_t *  pi,
int *  perr 
)

Read a 16-bit unsigned integer on the in stream. The signedness of the integer is not checked.

Parameters
inthe input stream
pia pointer to the variable which receive the readed value
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes readed on the stream in
int genepi_io_read_uint32 ( FILE *  in,
uint32_t *  pi,
int *  perr 
)

Read a 32-bit unsigned integer on the in stream. The signedness of the integer is not checked.

Parameters
inthe input stream
pia pointer to the variable which receive the readed value
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes readed on the stream in
int genepi_io_read_uint8 ( FILE *  in,
uint8_t *  pi,
int *  perr 
)

Read an 8-bit unsigned integer on the in stream. The signedness of the integer is not checked.

Parameters
inthe input stream
pia pointer to the variable which receive the readed value
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes readed on the stream in
int genepi_io_write_buffer ( FILE *  out,
const void *  buf,
size_t  size,
int *  perr 
)

Write the content of the buffer buf on the out stream. Oppositely to strings the given buffer must not be NULL.

Parameters
outthe ouput stream
bufthe written buffer
sizethe size of buffer, in bytes
perra pointer to the error flag
Precondition
out != NULL
buf != NULL
perr != NULL
Returns
the number of bytes written on the stream out
int genepi_io_write_int16 ( FILE *  out,
int16_t  i,
int *  perr 
)

Write a 16-bit signed integer on the out stream.

Parameters
outthe ouput stream
ithe written integer
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes written on the stream out
int genepi_io_write_int32 ( FILE *  out,
int32_t  i,
int *  perr 
)

Write a 32-bit signed integer on the out stream.

Parameters
outthe ouput stream
ithe written integer
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes written on the stream out
int genepi_io_write_int8 ( FILE *  out,
int8_t  i,
int *  perr 
)

Write an 8-bit signed integer on the out stream.

Parameters
outthe ouput stream
ithe written integer
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes written on the stream out
int genepi_io_write_string ( FILE *  out,
const char *  s,
int *  perr 
)

Write a string on the out stream. The string s can be null in which case the NULL value will be reloaded by the read_string function.

Parameters
outthe ouput stream
sthe string
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes written on the stream out
int genepi_io_write_uint16 ( FILE *  out,
uint16_t  i,
int *  perr 
)

Write a 16-bit unsigned integer on the out stream.

Parameters
outthe ouput stream
ithe written integer
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes written on the stream out
int genepi_io_write_uint32 ( FILE *  out,
uint32_t  i,
int *  perr 
)

Write a 32-bit unsigned integer on the out stream.

Parameters
outthe ouput stream
ithe written integer
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes written on the stream out
int genepi_io_write_uint8 ( FILE *  out,
uint8_t  i,
int *  perr 
)

Write an 8-bit unsigned integer on the out stream.

Parameters
outthe ouput stream
ithe written integer
perra pointer to the error flag
Precondition
out != NULL
perr != NULL
Returns
the number of bytes written on the stream out