Library for structured binary data I/O
Macros | Functions
bdio.c File Reference

Main file for bdio-library. More...

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <pwd.h>
#include <time.h>
#include <bdio.h>
Include dependency graph for bdio.c:

Macros

#define BDIO_MAGIC   0x7ffbd07e
 
#define BDIO_VERSION   1
 
#define BDIO_MAX_RECORD_LENGTH   1048575 /* 2^20-1 */
 
#define BDIO_MAX_LONG_RECORD_LENGTH   268435455 /* 2^28-1 */
 
#define BDIO_BUF_SIZE   1048576
 
#define BDIO_MAX_HOST_LENGTH   256
 
#define BDIO_MAX_USER_LENGTH   33
 
#define BDIO_MAX_PINFO_LENGTH   3505
 
#define HEADER_INT(fmt, uinfo, len)
 
#define HEADER_INT_LONG(fmt, uinfo, len)
 

Functions

int flush_buf (BDIO *fh)
 
int min (int a, int b)
 
int buf_write (unsigned char *dat, int n, BDIO *fh)
 
void bdio_perror (const char *s, BDIO *fh)
 Print an error string to BDIO.msg. More...
 
void bdio_pferror (const char *s, BDIO *fh)
 Print an error string to BDIO.msg. More...
 
BDIObdio_open (const char *file, const char *mode, char *protocol_info)
 Open a bdio file in mode 'r' (read), 'w' (write) or 'a' (append). More...
 
int bdio_close (BDIO *fh)
 Close a bdio file. More...
 
void bdio_set_dflt_msg (FILE *stream)
 Set the default stream for error messages. More...
 
void bdio_set_dflt_verbose (int v)
 Change the behavior for reporting of errors. More...
 
int bdio_set_verbose (int v, BDIO *fh)
 Set bdio file fh to verbose (v>0) or silent (v==0) More...
 
int bdio_set_msg (FILE *stream, BDIO *fh)
 Set the stream for error messages in fh to stream. More...
 
char * bdio_get_hchost (BDIO *fh)
 Get the host on which the last header was created. More...
 
char * bdio_get_hcuser (BDIO *fh)
 Get the user name who created the last header. More...
 
char * bdio_get_hmhost (BDIO *fh)
 Get the host on which the last header was most recently modified. More...
 
char * bdio_get_hmuser (BDIO *fh)
 Get the user name who modified the last header most recently. More...
 
char * bdio_get_hpinfo (BDIO *fh)
 Get the protocol info of the last header. More...
 
int bdio_get_hversion (BDIO *fh)
 Get version number in last header. More...
 
int bdio_get_hcnt (BDIO *fh)
 Get number of headers read or written so far (including current) More...
 
int bdio_get_hcdate (BDIO *fh)
 Get the time of creation of the last header. More...
 
int bdio_get_hmdate (BDIO *fh)
 Get the time of the most recent modification of the last header. More...
 
int bdio_get_ruinfo (BDIO *fh)
 Get the user info of the current record. More...
 
int bdio_get_rfmt (BDIO *fh)
 Get format of current record (written or read). More...
 
uint64_t bdio_get_rlen (BDIO *fh)
 Get length of data content of current record (written or read). More...
 
int bdio_get_rcnt (BDIO *fh)
 Get number of records read or written so far (including current) More...
 
int bdio_is_in_record (BDIO *fh)
 Returns 1 if fh is in a record and 0 otherwise. More...
 
int bdio_is_in_header (BDIO *fh)
 Returns 1 if fh is in a header and 0 otherwise. More...
 
int bdio_append_record (int fmt, int uinfo, BDIO *fh)
 If the last item in the file was a record: position the stream at the end of it. Otherwise EOF is returned. More...
 
int bdio_seek_record (BDIO *fh)
 Position bdio stream to start of next record and read its header. More...
 
size_t bdio_read (void *buf, size_t nb, BDIO *fh)
 Read nb bytes from fh into buf. More...
 
size_t bdio_read_f32 (float *buf, size_t nb, BDIO *fh)
 brief Read nb bytes from fh into buf. nb must be a multiple of 4. More...
 
size_t bdio_read_f64 (double *buf, size_t nb, BDIO *fh)
 brief Read nb bytes from fh into buf. nb must be a multiple of 8. More...
 
size_t bdio_read_int32 (int32_t *buf, size_t nb, BDIO *fh)
 brief Read nb bytes from fh into buf. nb must be a multiple of 4. More...
 
size_t bdio_read_int64 (int64_t *buf, size_t nb, BDIO *fh)
 brief Read nb bytes from fh into buf. nb must be a multiple of 8. More...
 
int bdio_start_record (int fmt, int uinfo, BDIO *fh)
 Position bdio stream after the current record and start writing a new record with specified format and uinfo. More...
 
size_t bdio_write (void *ptr, size_t nb, BDIO *fh)
 Write nb bytes from ptr to fh. More...
 
size_t bdio_write_f32 (float *ptr, size_t nb, BDIO *fh)
 Write nb bytes from ptr to fh. More...
 
size_t bdio_write_f64 (double *ptr, size_t nb, BDIO *fh)
 Write nb bytes from ptr to fh. More...
 
size_t bdio_write_int32 (int32_t *ptr, size_t nb, BDIO *fh)
 Write nb bytes from ptr to fh. More...
 
size_t bdio_write_int64 (int64_t *ptr, size_t nb, BDIO *fh)
 Write nb bytes from ptr to fh. More...
 
int bdio_flush_record (BDIO *fh)
 Finalize the current record and set fh to BDIO_N_STATE. More...
 

Detailed Description

Main file for bdio-library.

Details & license

Version
1.0
Author
Tomasz Korzec, Hubert Simma
Date
2013-2018

Macro Definition Documentation

#define HEADER_INT (   fmt,
  uinfo,
  len 
)
Value:
( 0x00000001 /* magic=1 */ \
| ((fmt) << 4) /* format */ \
| ((uinfo) << 8) /* user info */ \
| (((len)-4) <<12) /* record length */ \
)
#define HEADER_INT_LONG (   fmt,
  uinfo,
  len 
)
Value:
( 0x0000000000000001 /* magic=1 */ \
| 0x0000000000000008 /* long rec */ \
| ((fmt) << 4) /* format */ \
| ((uinfo) << 8) /* user info */ \
| (((uint64_t)(len)-8) <<12) /* record length */ \
)

Function Documentation

int bdio_append_record ( int  fmt,
int  uinfo,
BDIO fh 
)

If the last item in the file was a record: position the stream at the end of it. Otherwise EOF is returned.

The specified format and uinfo must match the last record's values.
fails if

  • fh is a null pointer
  • fh is in state BDIO_E_STATE
  • fh is not in write/append mode
  • fmt does not match last record's value
  • info does not match last record's value
  • fh is not in BDIO_N_STATE
    Returns
    Upon success 0 is returned, otherwise EOF is returned.
    Parameters
    [in]fmtSupported formats are
    format content
    BDIO_ASC_EXEC for ASCII data containing shell scripts
    BDIO_ASC_XML for ASCII data containing XML
    BDIO_ASC_GENERIC for generic ASCII data
    BDIO_BIN_GENERIC for generic binary data
    BDIO_BIN_INT32BE for big endian 32 bit integers
    BDIO_BIN_INT32LE for little endian 32 bit integers
    BDIO_BIN_INT64BE for big endian 64 bit integers
    BDIO_BIN_INT64LE for little endian 64 bit integers
    BDIO_BIN_F32BE for big endian single precision floats
    BDIO_BIN_F32LE for little endian single precision floats
    BDIO_BIN_F64BE for big endian double precision floats
    BDIO_BIN_F64LE for little endian double precision floats
    BDIO_BIN_INT32 for 32 bit integers stored in last record's endianness
    BDIO_BIN_INT64 for 64 bit integers stored in last record's endianness
    BDIO_BIN_F32 for single precision floats in last record's endianness
    BDIO_BIN_F64 for double precision floats in last record's endianness
    [in]uinfois a number between 0 and 15 specified by the user.
    [in]fhpointer to a BDIO file descriptor structure.
int bdio_close ( BDIO fh)

Close a bdio file.

If the file has been opened in write or append mode this function must be called also to guarantee that the last written record is correctly flushed (update of the record length).

bdio_close fails if

  • fclose fails,
  • fh is a NULL pointer
  • fh is in state BDIO_E_STATE.

In the last case bdio_close will close the file without flushing.

Returns
Upon successful completion 0 is returned. Otherwise, EOF is returned In either case any further access (including another call to bdio_close) to fh results in undefined behavior.
Parameters
[in]fhpointer to a BDIO file descriptor structure

Here is the call graph for this function:

int bdio_flush_record ( BDIO fh)

Finalize the current record and set fh to BDIO_N_STATE.

If fh is open in write/append mode:
If state is BDIO_R_STATE, the current record is finalized by flushing, writing the length into the record-header, moving the file pointer to the end of the file and changing the state to BDIO_N_STATE

If state is BDIO_H_STATE, the header record is finalized by flushing and setting the state to BDIO_N_STATE

If state is BDIO_N_STATE, nothing is done

A call to this function is usually not necessary. A call is advised only before engaging in operations that may lead to a crash or early termination, But even then, calling bdio_close would be preferred.

Fails if

  • fh is a null pointer
  • fh is in state BDIO_E_STATE
  • fh is not in write/append mode
  • fflush, ftell, fwrite or fseek fail
    Returns
    Upon successful completion 0 is returned. Otherwise, EOF is returned.
    Parameters
    [in]fhpointer to a BDIO file descriptor structure.

Here is the caller graph for this function:

int bdio_get_hcdate ( BDIO fh)

Get the time of creation of the last header.

Fails if fh is invalid or in error state

Returns
unix time (seconds since Jan 01 1970)
Parameters
[in]fhpointer to a BDIO file descriptor structure.
char* bdio_get_hchost ( BDIO fh)

Get the host on which the last header was created.

Fails if fh is invalid or in error state

Returns
0-terminated string with a host name
Parameters
[in]fhpointer to a BDIO file descriptor structure.
int bdio_get_hcnt ( BDIO fh)

Get number of headers read or written so far (including current)

Fails if fh is a null pointer or if fh is in state BDIO_E_STATE

Returns
Upon success the number of headers is returned. Upon failure EOF is returned.
Parameters
[in]fhpointer to a BDIO file descriptor structure.
char* bdio_get_hcuser ( BDIO fh)

Get the user name who created the last header.

Fails if fh is invalid or in error state

Returns
0-terminated string with a user name
Parameters
[in]fhpointer to a BDIO file descriptor structure.
int bdio_get_hmdate ( BDIO fh)

Get the time of the most recent modification of the last header.

Fails if fh is invalid or in error state

Returns
unix time (seconds since Jan 01 1970)
Parameters
[in]fhpointer to a BDIO file descriptor structure.
char* bdio_get_hmhost ( BDIO fh)

Get the host on which the last header was most recently modified.

Fails if fh is invalid or in error state

Returns
0-terminated string with a host name
Parameters
[in]fhpointer to a BDIO file descriptor structure.
char* bdio_get_hmuser ( BDIO fh)

Get the user name who modified the last header most recently.

Fails if fh is invalid or in error state

Returns
0-terminated string with a user name
Parameters
[in]fhpointer to a BDIO file descriptor structure.
char* bdio_get_hpinfo ( BDIO fh)

Get the protocol info of the last header.

Fails if fh is invalid or in error state

Returns
0-terminated string with a protocol info
Parameters
[in]fhpointer to a BDIO file descriptor structure.
int bdio_get_hversion ( BDIO fh)

Get version number in last header.

Fails if fh is invalid or in error state

Returns
Upon success the integer version number is returned. Upon failure EOF is returned
Parameters
[in]fhpointer to a BDIO file descriptor structure.
int bdio_get_rcnt ( BDIO fh)

Get number of records read or written so far (including current)

Fails if fh is a null pointer or if fh is in state BDIO_E_STATE

Returns
Upon success the number of records is returned. Upon failure EOF is returned.
Parameters
[in]fhpointer to a BDIO file descriptor structure.
int bdio_get_rfmt ( BDIO fh)

Get format of current record (written or read).

Fails if fh is a null pointer or if fh is not in state BDIO_R_STATE

Returns
If fh is in state BDIO_R_STATE the format of the record is returned.
If fh is not in a record or if an error occurs, EOF is returned.
Parameters
[in]fhpointer to a BDIO file descriptor structure.
uint64_t bdio_get_rlen ( BDIO fh)

Get length of data content of current record (written or read).

Fails if fh if is a null pointer or if fh is in state BDIO_E_STATE

Returns
Upon success the length is returned. Upon failure EOF is returned.
If fh is currently not in a record, 0 is returned
Parameters
[in]fhpointer to a BDIO file descriptor structure.
int bdio_get_ruinfo ( BDIO fh)

Get the user info of the current record.

Fails if fh is invalid or in error state

Returns
user info, integer between 0 and 15
Parameters
[in]fhpointer to a BDIO file descriptor structure.
int bdio_is_in_header ( BDIO fh)

Returns 1 if fh is in a header and 0 otherwise.

Fails if fh is invalid

Returns
1 if fh->state is BDIO_H_STATE and 0 otherwise
Parameters
[in]fhpointer to a BDIO file descriptor structure
int bdio_is_in_record ( BDIO fh)

Returns 1 if fh is in a record and 0 otherwise.

Fails if fh is invalid

Returns
1 if fh->state is BDIO_R_STATE and 0 otherwise
Parameters
[in]fhpointer to a BDIO file descriptor structure
BDIO* bdio_open ( const char *  file,
const char *  mode,
char *  protocol_info 
)

Open a bdio file in mode 'r' (read), 'w' (write) or 'a' (append).

In read mode, the header record is read and checked. The stream remains positioned in the header record, therefore bdio_seek_record must be called to enter the next record. protocol_info may be NULL, but if it is not NULL, it must match the protocol_info string of the first header.

In write mode, the header record is written. The stream remains positioned in the header record, therefore bdio_start_record must be called to start a new record. protocol_info must be a 0-terminated string (at least "").

In append mode, the header records are read and checked. The stream is positioned at the end of the last header or after the last record, therefore bdio_start_record or bdio_append_record (only possible if the last item was a record) must be called to start a new record. If the file is not empty, protocol_info may be NULL - if not NULL it must match the one of the last header. If the file is empty, protocol_info must be a 0-terminated string.

The maximal length protocol_info may have is: XXXX TODO <–

bdio_open fails if

  • there is not enough memory for the buffers,
  • an invalid mode was specified,
  • the machine has an unknown endianness,
  • there was an I/O error during reading/writing of the header,
  • the header is not a valid bdio header,
  • protocol_info fails to fulfill the requirements,
  • fopen, fclose, fwrite, fread, ftell fail for some reason.
    Returns
    Upon successful completion bdio_open returns a pointer to a bdio file structure. Otherwise, NULL is returned
    Parameters
    [in]file0-terminated string specifying the file name
    [in]modea bdio file mode, can be BDIO_R_MODE, BDIO_W_MODE or BDIO_A_MODE
    [in]protocol_info0-terminated string specifying the protocol-info

Here is the call graph for this function:

void bdio_perror ( const char *  s,
BDIO fh 
)

Print an error string to BDIO.msg.

Print the string pointed to by s followed by the description of the last error that occured to BDIO.msg.
If s is NULL, only the description of the last error is printed.

The function fails if fh is invalid or if the error-stream associated with fh is invalid.

Parameters
[in]s0-terminated string with user-provided error message
[in]fhpointer to a BDIO file descriptor structure
void bdio_pferror ( const char *  s,
BDIO fh 
)

Print an error string to BDIO.msg.

Print the string pointed to by s followed by the description of the first error that occured to BDIO.msg.
If s is NULL, only the description of the first error is printed.

The function fails if fh is invalid or if the error-stream associated with fh is invalid.

Parameters
[in]s0-terminated string with user-provided error message
[in]fhpointer to a BDIO file descriptor structure
size_t bdio_read ( void *  buf,
size_t  nb,
BDIO fh 
)

Read nb bytes from fh into buf.

Independent of the endiannes of the machine and the record type, exactly the bytes from the file are copied. If a byte-swap is necessary, the user is responsible for doing it.

Fails if -fh is a null pointer -fh is in state BDIO_E_STATE -fh is not in read mode -nb is too large -fread fails

Returns
Returns the number of bytes read.
If an error occurs, or the end of the current record or the file is reached, the return value is a short item count (or zero).
Parameters
[in]bufpointer to a location where the read data is copied to.
[in]nbnumber of bytes to be read.
[in]fhpointer to a BDIO file descriptor structure.

Here is the caller graph for this function:

size_t bdio_read_f32 ( float *  buf,
size_t  nb,
BDIO fh 
)

brief Read nb bytes from fh into buf. nb must be a multiple of 4.

If the endianness of the machine differs from the one of the current record, the byte order of the read data is swapped. If this swapping is not desired the general bdio_read should be used.

Fails if

  • fh is a null pointer
  • fh is in state BDIO_E_STATE
  • bdio_fread fails
    Returns
    Returns the number of bytes read.
    If an error occurs, or the end of the current record or the file is reached, the return value is a short item count (or zero).
    Parameters
    [in]buffloat-pointer to a location where the read data is copied to.
    [in]nbnumber of bytes to be read (multiple of 4).
    [in]fhpointer to a BDIO file descriptor structure.

Here is the call graph for this function:

size_t bdio_read_f64 ( double *  buf,
size_t  nb,
BDIO fh 
)

brief Read nb bytes from fh into buf. nb must be a multiple of 8.

If the endianness of the machine differs from the one of the current record, the byte order of the read data is swapped. If this swapping is not desired the general bdio_read should be used.

Fails if

  • fh is a null pointer
  • fh is in state BDIO_E_STATE
  • bdio_fread fails
    Returns
    Returns the number of bytes read.
    If an error occurs, or the end of the current record or the file is reached, the return value is a short item count (or zero).
    Parameters
    [in]bufdouble-pointer to a location where the read data is copied to.
    [in]nbnumber of bytes to be read (multiple of 8).
    [in]fhpointer to a BDIO file descriptor structure.

Here is the call graph for this function:

size_t bdio_read_int32 ( int32_t *  buf,
size_t  nb,
BDIO fh 
)

brief Read nb bytes from fh into buf. nb must be a multiple of 4.

If the endianness of the machine differs from the one of the current record, the byte order of the read data is swapped. If this swapping is not desired the general bdio_read should be used.

Fails if

  • fh is a null pointer
  • fh is in state BDIO_E_STATE
  • bdio_fread fails
    Returns
    Returns the number of bytes read.
    If an error occurs, or the end of the current record or the file is reached, the return value is a short item count (or zero).
    Parameters
    [in]bufint32_t-pointer to a location where the read data is copied to.
    [in]nbnumber of bytes to be read (multiple of 4).
    [in]fhpointer to a BDIO file descriptor structure.

Here is the call graph for this function:

size_t bdio_read_int64 ( int64_t *  buf,
size_t  nb,
BDIO fh 
)

brief Read nb bytes from fh into buf. nb must be a multiple of 8.

If the endianness of the machine differs from the one of the current record, the byte order of the read data is swapped. If this swapping is not desired the general bdio_read should be used.

Fails if

  • fh is a null pointer
  • fh is in state BDIO_E_STATE
  • bdio_fread fails
    Returns
    Returns the number of bytes read.
    If an error occurs, or the end of the current record or the file is reached, the return value is a short item count (or zero).
    Parameters
    [in]bufint64_t-pointer to a location where the read data is copied to.
    [in]nbnumber of bytes to be read (multiple of 8).
    [in]fhpointer to a BDIO file descriptor structure.

Here is the call graph for this function:

int bdio_seek_record ( BDIO fh)

Position bdio stream to start of next record and read its header.

fails if

  • fh is a null pointer
  • fh is in state BDIO_E_STATE
  • fh is not in read mode
  • fseek or fread fail
    Returns
    Upon success 0 is returned, otherwise EOF is returned. Upon end of file, EOF is returned.
    Parameters
    [in]fhpointer to a BDIO file descriptor structure.

Here is the caller graph for this function:

void bdio_set_dflt_msg ( FILE *  stream)

Set the default stream for error messages.

Parameters
[in]streampointer to a file into which error messages should be printed by default for any newly opened bdio file.
void bdio_set_dflt_verbose ( int  v)

Change the behavior for reporting of errors.

Set the default for newly opened bdio files to verbose (v !=0 ) or silent (v==0)

Fails if v is negative

Parameters
[in]vnew default behavior
int bdio_set_msg ( FILE *  stream,
BDIO fh 
)

Set the stream for error messages in fh to stream.

Fails if fh is invalid or stream is NULL

Returns
Upon successfull completion 0 is returned. Otherwise EOF is returned.
Parameters
[in]streampointer to a file into which error messages associated with bdio file fh are printed
[in]fhpointer to a BDIO file descriptor structure.
int bdio_set_verbose ( int  v,
BDIO fh 
)

Set bdio file fh to verbose (v>0) or silent (v==0)

Fails if fh is invalid or in error state or v is negative

Returns
Upon successfull completion 0 is returned. Otherwise EOF is returned
Parameters
[in]vv==0 means silent mode and v>0 means verbose mode
[in]fhpointer to a BDIO file descriptor structure.
int bdio_start_record ( int  fmt,
int  uinfo,
BDIO fh 
)

Position bdio stream after the current record and start writing a new record with specified format and uinfo.

Fails if

  • fh is a null pointer
  • fh is in state BDIO_E_STATE
  • fh is not in write/append mode
  • fmt has an illegal value
  • info has an illegal value
  • the endianness of the system can not be determined
  • bdio_flush_record fails
    Returns
    Upon success 0 is returned, otherwise EOF is returned.
    Parameters
    [in]fmtsupported formats are
    format content
    BDIO_ASC_EXEC for ASCII data containing shell scripts
    BDIO_ASC_XML for ASCII data containing XML
    BDIO_ASC_GENERIC for generic ASCII data
    BDIO_BIN_GENERIC for generic binary data
    BDIO_BIN_INT32BE for big endian 32 bit integers
    BDIO_BIN_INT32LE for little endian 32 bit integers
    BDIO_BIN_INT64BE for big endian 64 bit integers
    BDIO_BIN_INT64LE for little endian 64 bit integers
    BDIO_BIN_F32BE for big endian single precision floats
    BDIO_BIN_F32LE for little endian single precision floats
    BDIO_BIN_F64BE for big endian double precision floats
    BDIO_BIN_F64LE for little endian double precision floats
    BDIO_BIN_INT32 for 32 bit integers stored in machine endianness
    BDIO_BIN_INT64 for 64 bit integers stored in machine endianness
    BDIO_BIN_F32 for single precision floats in machine endianness
    BDIO_BIN_F64 for double precision floats in machine endianness
    [in]uinfois a number between 0 and 15 specified by the user.
    [in]fhpointer to a BDIO file descriptor structure.

Here is the call graph for this function:

size_t bdio_write ( void *  ptr,
size_t  nb,
BDIO fh 
)

Write nb bytes from ptr to fh.

nb must be a multiple of the record's data-type-size (e.g. multiple of 8 for BDIO_BIN_F64) Independent of the endianness of the current record, EXACTLY the data pointed to by ptr is written into the file. The user is responsible for the correct byte order. If automatic correct byte ordering is desired, the functions bdio_write_f32, bdio_write_f64, bdio_write_i32 and bdio_write_i64 should be used.

Fails if

  • fh if is a null pointer
  • fh is in state BDIO_E_STATE
  • fh is not in write/append mode
  • fwrite fails
    Returns
    Returns number of bytes written. If an error occurs the return value is a short item count (or zero).
    Parameters
    [in]ptrpointer to data which is to be written.
    [in]nbnumber of bytes to be written. Must be a multiple of the size of the record's data-type. E.g. multiple of 4 for BDIO_BIN_F32 records.
    [in]fhpointer to a BDIO file descriptor structure.

Here is the caller graph for this function:

size_t bdio_write_f32 ( float *  ptr,
size_t  nb,
BDIO fh 
)

Write nb bytes from ptr to fh.

nb must be a multiple of 4. If the endiannes of the machine differs from the one of the current record, the byte order of the data in ptr is swapped before writing. If this automatic swapping is not desired, the general bdio_write should be used.

Fails if

  • fh if is a null pointer
  • fh is in state BDIO_E_STATE
  • bdio_write fails
    Returns
    Returns number of bytes written. If an error occurs the return value is a short item count (or zero).
    Parameters
    [in]ptrpointer to float data which is to be written.
    [in]nbnumber of bytes to be written. Must be a multiple of 4.
    [in]fhpointer to a BDIO file descriptor structure.

Here is the call graph for this function:

size_t bdio_write_f64 ( double *  ptr,
size_t  nb,
BDIO fh 
)

Write nb bytes from ptr to fh.

nb must be a multiple of 8. If the endiannes of the machine differs from the one of the current record, the byte order of the data in ptr is swapped before writing. If this automatic swapping is not desired, the general bdio_write should be used.

Fails if

  • fh if is a null pointer
  • fh is in state BDIO_E_STATE
  • bdio_write fails
    Returns
    Returns number of bytes written. If an error occurs the return value is a short item count (or zero).
    Parameters
    [in]ptrpointer to double data which is to be written.
    [in]nbnumber of bytes to be written. Must be a multiple of 8.
    [in]fhpointer to a BDIO file descriptor structure.

Here is the call graph for this function:

size_t bdio_write_int32 ( int32_t *  ptr,
size_t  nb,
BDIO fh 
)

Write nb bytes from ptr to fh.

nb must be a multiple of 4. If the endiannes of the machine differs from the one of the current record, the byte order of the data in ptr is swapped before writing. If this automatic swapping is not desired, the general bdio_write should be used.

Fails if

  • fh if is a null pointer
  • fh is in state BDIO_E_STATE
  • bdio_write fails
    Returns
    Returns number of bytes written. If an error occurs the return value is a short item count (or zero).
    Parameters
    [in]ptrpointer to int32_t data which is to be written.
    [in]nbnumber of bytes to be written. Must be a multiple of 4.
    [in]fhpointer to a BDIO file descriptor structure.

Here is the call graph for this function:

size_t bdio_write_int64 ( int64_t *  ptr,
size_t  nb,
BDIO fh 
)

Write nb bytes from ptr to fh.

nb must be a multiple of 8. If the endiannes of the machine differs from the one of the current record, the byte order of the data in ptr is swapped before writing. If this automatic swapping is not desired, the general bdio_write should be used.

Fails if

  • fh if is a null pointer
  • fh is in state BDIO_E_STATE
  • bdio_write fails
    Returns
    Returns number of bytes written. If an error occurs the return value is a short item count (or zero).
    Parameters
    [in]ptrpointer to int64_t data which is to be written.
    [in]nbnumber of bytes to be written. Must be a multiple of 8.
    [in]fhpointer to a BDIO file descriptor structure.

Here is the call graph for this function: