file.h File Reference


Detailed Description

File I/O for files containing meterorological messages.

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


Function Documentation

dba_err dba_file_create ( dba_encoding  type,
const char *  name,
const char *  mode,
dba_file file 
)

Create a dba_file structure.

Parameters:
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.
Return values:
file The new file, to be deallocated with dba_file_delete()
Returns:
The error indicator for the function. See error.h

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.

Parameters:
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.

Parameters:
file The dba_file to query.
Returns:
The file name.

References _dba_file::name.

dba_err dba_file_read ( dba_file  file,
dba_rawmsg  msg,
int *  found 
)

Read a message from the file.

Parameters:
file dba_file to read from
msg The dba_rawmsg that will hold the data.
Return values:
found Will be set to true if a message has been found in the file, else to false.
Returns:
The error indicator for the function. See error.h

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.

Parameters:
file The dba_file to query.
Returns:
The file encoding.

References _dba_file::type.

dba_err dba_file_write ( dba_file  file,
dba_rawmsg  msg 
)

Write the encoded message data to the file.

Parameters:
file The dba_file to write to
msg The dba_rawmsg with the encoded data to write
Returns:
The error indicator for the function. See error.h

References dba_error_unimplemented, DBA_RUN_OR_RETURN, _dba_file::fun_write, _dba_file::idx, and _dba_file::type.


Generated on Sun May 25 13:56:33 2008 for libdballe by  doxygen 1.5.5