bufr2synop 0.24.0
|
This file has the code for library bufrdeco API functions. More...
Go to the source code of this file.
Macros | |
#define | CONFIG_H |
Functions | |
char * | bufrdeco_get_version (char *version, size_t dversion, char *build, size_t dbuild, char *builder, size_t dbuilder, int *version_major, int *version_minor, int *version_patch) |
int | bufrdeco_parse_tree (struct bufrdeco *b) |
Parse the tree of descriptors without expand the replicators. More... | |
int | bufrdeco_init (struct bufrdeco *b) |
Inits and allocate memory for a struct bufrdeco. More... | |
int | bufrdeco_reset (struct bufrdeco *b) |
Reset an struct bufrdeco. This is needed when changing to another bufr. More... | |
int | bufrdeco_set_out_stream (FILE *out, struct bufrdeco *b) |
Set the library normal output stream. More... | |
int | bufrdeco_set_err_stream (FILE *err, struct bufrdeco *b) |
Set the error stream. More... | |
int | bufrdeco_close (struct bufrdeco *b) |
Free all allocated memory. Needed when no more task to do with bufrdeco library. More... | |
int | bufrdeco_set_tables_dir (struct bufrdeco *b, char *tables_dir) |
Sets the directory path for BUFR tables. Needed if it is not any default directories. More... | |
int | bufrdeco_get_bufr (struct bufrdeco *b, char *filename) |
Read file and try to find a bufr report inserted in. Once found do the same that bufrdeco_read_bufr() More... | |
int | bufrdeco_write_subset_offset_bits (struct bufrdeco *b, char *filename) |
Write offset bit array for subsets in a non-compressed bufr. More... | |
int | bufrdeco_read_subset_offset_bits (struct bufrdeco *b, char *filename) |
Write offset bit array for subsets in a non-compressed bufr. More... | |
struct bufrdeco_subset_sequence_data * | bufrdeco_get_target_subset_sequence_data (buf_t nset, struct bufrdeco *b) |
Prepare the struct bufrdeco to get data from the solicited subset. More... | |
This file has the code for library bufrdeco API functions.
Definition in file bufrdeco.c.
#define CONFIG_H |
Definition at line 26 of file bufrdeco.c.
int bufrdeco_close | ( | struct bufrdeco * | b | ) |
Free all allocated memory. Needed when no more task to do with bufrdeco library.
b | pointer to the target struct |
This function must be called at the end when no more calls to bufrdeco library is needed
b->out and b->err must be closed by caller if are not the default stdout or stderr
Definition at line 259 of file bufrdeco.c.
References bufrdeco::bitmap, bufrdeco_assert, bufrdeco_free_bitmap_array(), bufrdeco_free_cache_tables(), bufrdeco_free_compressed_data_references(), bufrdeco_free_expanded_tree(), bufrdeco_free_subset_sequence_data(), bufrdeco_free_tables(), BUFRDECO_USE_TABLES_CACHE, bufrdeco::cache, bufrdeco::mask, bufrdeco::refs, bufrdeco::seq, bufrdeco::tables, and bufrdeco::tree.
Referenced by main().
int bufrdeco_get_bufr | ( | struct bufrdeco * | b, |
char * | filename | ||
) |
Read file and try to find a bufr report inserted in. Once found do the same that bufrdeco_read_bufr()
b | pointer to struct bufrdeco |
filename | complete path of BUFR file |
This function does the folowing tasks:
Definition at line 315 of file bufrdeco.c.
References bufrdeco_assert_with_return_val, and bufrdeco_extract_bufr().
struct bufrdeco_subset_sequence_data * bufrdeco_get_target_subset_sequence_data | ( | buf_t | nset, |
struct bufrdeco * | b | ||
) |
Prepare the struct bufrdeco to get data from the solicited subset.
nset | index of subset we want to parse and get data. First subset in a BUFR file has index 0. |
b | pointer to the struct bufrdeco |
Definition at line 396 of file bufrdeco.c.
References bufrdeco_assert, bufrdeco_decode_data_subset(), bufrdeco_get_subset_sequence_data(), BUFRDECO_OUTPUT_JSON_SUBSET_DATA, bufrdeco_parse_compressed(), bufr_sec3::compressed, bufrdeco::error, bufrdeco::mask, bufrdeco_compressed_data_references::nd, bufrdeco_subset_bit_offsets::nr, bufrdeco::offsets, bufrdeco_subset_bit_offsets::ofs, bufrdeco::refs, bufrdeco::sec3, bufrdeco::state, bufrdeco_decoding_data_state::subset, and bufr_sec3::subsets.
Referenced by main().
char * bufrdeco_get_version | ( | char * | version, |
size_t | dversion, | ||
char * | build, | ||
size_t | dbuild, | ||
char * | builder, | ||
size_t | dbuilder, | ||
int * | version_major, | ||
int * | version_minor, | ||
int * | version_patch | ||
) |
Definition at line 50 of file bufrdeco.c.
References strncpy_safe, and VERSION.
Referenced by bufrtotac_print_version().
int bufrdeco_init | ( | struct bufrdeco * | b | ) |
Inits and allocate memory for a struct bufrdeco.
b | pointer to the target struct |
This function only must be called once. When finished the function bufrdeco_close must be called to free all needed memory
Definition at line 138 of file bufrdeco.c.
References bufrdeco_assert, bufrdeco_init_expanded_tree(), bufrdeco_init_tables(), bufrdeco::err, bufrdeco::error, bufrdeco::out, bufrdeco::tables, and bufrdeco::tree.
Referenced by main().
int bufrdeco_parse_tree | ( | struct bufrdeco * | b | ) |
Parse the tree of descriptors without expand the replicators.
b | Pointer to the source struct bufrdeco |
This is the user function to parse the descriptor structure of a BUFR report. This is the first task we need to perform after read the bufr report with the aid of bufrdeco_read_bufr function.
At the end we will get an array of structs bufr_sequence defining the tree
A sequence layer is needed when parsing expanded descriptor sec3 and sec4
First bufr_sequence is the sequence of descriptors in sec3 after byte 8. This is a bufr_sequence in level 0.
When a sequence descriptor is found in a layer, the sequence entries found in table D form this descriptor is a son bufr_sequence. This son has then a father and also can have one or more sons. The index level is incremented by one every step it go into decendents.
And so we go in a recursive way up to the end.
Definition at line 120 of file bufrdeco.c.
References bufrdeco_assert, and bufrdeco_parse_tree_recursive().
Referenced by main().
int bufrdeco_read_subset_offset_bits | ( | struct bufrdeco * | b, |
char * | filename | ||
) |
Write offset bit array for subsets in a non-compressed bufr.
filename | complete path of input file to open |
b | pointer to the struct bufrdeco |
Definition at line 358 of file bufrdeco.c.
References bufr_read_subset_offset_bits(), bufrdeco_assert_with_return_val, and bufrdeco::offsets.
Referenced by main().
int bufrdeco_reset | ( | struct bufrdeco * | b | ) |
Reset an struct bufrdeco. This is needed when changing to another bufr.
b | pointer to the target struct to be resed with another bufrfile |
This function must be called when parsing another BUFR report without calling bufrdeco_close and bufrdeco_init. It
Definition at line 180 of file bufrdeco.c.
References bufrdeco::bitmap, bufrdeco_assert, bufrdeco_free_bitmap_array(), bufrdeco_free_compressed_data_references(), bufrdeco_free_expanded_tree(), bufrdeco_free_subset_sequence_data(), bufrdeco_init_expanded_tree(), bufrdeco::cache, bufrdeco::err, bufrdeco::error, bufrdeco::mask, bufrdeco::out, bufrdeco::refs, bufrdeco::seq, bufrdeco::tables, and bufrdeco::tree.
Referenced by main().
int bufrdeco_set_err_stream | ( | FILE * | err, |
struct bufrdeco * | b | ||
) |
Set the error stream.
err | stream opened by caller |
b | pointer to current active struct bufrdeco |
Without calling to this funcion, the default is stderr
Definition at line 242 of file bufrdeco.c.
References bufrdeco::out.
int bufrdeco_set_out_stream | ( | FILE * | out, |
struct bufrdeco * | b | ||
) |
Set the library normal output stream.
out | stream opened by caller |
b | pointer to current active struct bufrdeco |
Without calling to this funcion, the default is stdout
Definition at line 227 of file bufrdeco.c.
References bufrdeco::out.
int bufrdeco_set_tables_dir | ( | struct bufrdeco * | b, |
char * | tables_dir | ||
) |
Sets the directory path for BUFR tables. Needed if it is not any default directories.
b | pointer to the target struct |
tables_dir | Source path of tables directory |
The default directories are '/usr/share/bufr2synop' and '/usr/local/share/bufr2synop'
Definition at line 291 of file bufrdeco.c.
References bufrdeco_assert_with_return_val, BUFRDECO_PATH_LENGTH, bufrdeco::bufrtables_dir, and strncpy_safe.
int bufrdeco_write_subset_offset_bits | ( | struct bufrdeco * | b, |
char * | filename | ||
) |
Write offset bit array for subsets in a non-compressed bufr.
filename | complete path of output file to open |
b | pointer to the struct bufrdeco |
Definition at line 330 of file bufrdeco.c.
References bufr_write_subset_offset_bits(), bufrdeco_assert_with_return_val, and bufrdeco::offsets.
Referenced by main().