Previous: Reading Data from the /rdb File, Up: Reading Data from the /rdb File


A.6.1 rdb_col_read_st

Grab columns of data from an /rdb data file.

Synopsis

     #include <mst_rdb/mst_rdb.h>
     
     
     
int rdb_col_read_st( FILE *fin, rdbHeader *hdr, DataColumnMap_st const *map, void *data );

Parameters

FILE *fin
the stream to parse
rdbHeader *hdr
the rdb file description
DataColumnMap_st const *map
the columns to read
void *data
where to stow the data. must be pointer to an appropriate struct

Description

The rdb_col_read_st function extracts data from an /rdb file on a stream. It reads the next record on the stream, extracting data via the specified column mapping and fills in a user supplied structure.

An NULL string is returned if an RDB_String column contains no data, the user must still free the pointer to the NULL string. An empty RDB_Num column is flagged as an error if it is supposed to contain data. Empty lines are ignored.

When reading string arguments, this routine places into the target data structure a pointer to a dynamically allocated string area, into which the string is copied. When the user is finished using the string, this area should be freed.

Returns

The routine returns 1 if it successfully read data, 0 upon end of data. If the number of columns in the record is not the same as in the header, or if a (numeric) column contains garbage, a message is printed to stderr and the program is halted.

Author

Diab Jerius, Richard J. Edgar