This module provides a unified interface to read and write messages to files in various formats.
Format-specific implementation is not provided by this module, but other libraries can implement format specific read and write functions and register them with dba_file.
#include <dballe/core/rawmsg.h>
Go to the source code of this file.
Typedefs | |
| typedef struct _dba_file * | dba_file |
| Opaque structure representing a file with meteorological data. | |
Functions | |
| dba_err | dba_file_create (dba_encoding type, const char *name, const char *mode, dba_file *file) |
| Create a dba_file structure. | |
| void | dba_file_delete (dba_file file) |
| Delete a dba_file. | |
| dba_encoding | dba_file_type (dba_file file) |
| Get the type of the dba_file. | |
| const char * | dba_file_name (dba_file file) |
| Get the name of the dba_file. | |
| dba_err | dba_file_read (dba_file file, dba_rawmsg msg, int *found) |
| Read a message from the file. | |
| dba_err | dba_file_write (dba_file file, dba_rawmsg msg) |
| Write the encoded message data to the file. | |
| dba_err dba_file_create | ( | dba_encoding | type, | |
| const char * | name, | |||
| const char * | mode, | |||
| dba_file * | file | |||
| ) |
Create a dba_file structure.
| type | The type of data contained in the file. If -1 is passed, then dba_file_create will attempt to autodetect the file type from its first byte. | |
| name | The name of the file to access. "(stdin)", "(stdout)" and "(stderr)" are special file names, that will use the corresponding stream instead of open a file. | |
| mode | The opening mode of the file, as used by fopen. |
| file | The new file, to be deallocated with dba_file_delete() |
References _dba_file::close_on_exit, dba_error_consistency, dba_error_notfound, dba_error_unimplemented, DBA_RUN_OR_GOTO, _dba_file::fd, _dba_file::idx, _dba_file::name, and _dba_file::type.
| void dba_file_delete | ( | dba_file | file | ) |
Delete a dba_file.
| file | The file to delete. |
References _dba_file::close_on_exit, _dba_file::fd, _dba_file::fun_delete, and _dba_file::name.
| const char* dba_file_name | ( | dba_file | file | ) |
Get the name of the dba_file.
| file | The dba_file to query. |
References _dba_file::name.
| dba_err dba_file_read | ( | dba_file | file, | |
| dba_rawmsg | msg, | |||
| int * | found | |||
| ) |
Read a message from the file.
| file | dba_file to read from | |
| msg | The dba_rawmsg that will hold the data. |
| found | Will be set to true if a message has been found in the file, else to false. |
References dba_error_unimplemented, DBA_RUN_OR_RETURN, _dba_file::fun_read, _dba_file::idx, and _dba_file::type.
| dba_encoding dba_file_type | ( | dba_file | file | ) |
Get the type of the dba_file.
| file | The dba_file to query. |
References _dba_file::type.
| dba_err dba_file_write | ( | dba_file | file, | |
| dba_rawmsg | msg | |||
| ) |
Write the encoded message data to the file.
| file | The dba_file to write to | |
| msg | The dba_rawmsg with the encoded data to write |
References dba_error_unimplemented, DBA_RUN_OR_RETURN, _dba_file::fun_write, _dba_file::idx, and _dba_file::type.
1.5.5