32 clock_t bufrdeco_clock_start, bufrdeco_clock_end;
50char *
bufrdeco_get_version (
char *version,
size_t dversion,
char *build,
size_t dbuild,
char *builder,
size_t dbuilder,
51 int *version_major,
int *version_minor,
int *version_patch )
53 int major = 0, minor = 0, patch = 0;
57 if ( version == NULL )
60 snprintf ( version, dversion,
"%s",
VERSION );
62 sscanf ( version,
"%d.%d.%d", &major, &minor, &patch );
67#if defined(__INTEL_COMPILER)
68 used += snprintf ( build + used, dbuild - used,
"using INTEL C compiler icc %d.%d ", __INTEL_COMPILER, __INTEL_COMPILER_UPDATE );
69#elif defined(__clang_version__)
70 used += snprintf ( build + used, dbuild - used,
"using clang C compiler ", __clang_version__ );
71#elif defined(__GNUC__)
72 used += snprintf ( build + used, dbuild - used,
"using GNU C compiler gcc %d.%d.%d ", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ );
73#elif defined(_MSC_VER)
74 used += snprintf ( build + used, dbuild - used,
"using MICROSOFT C compiler %d ", _MSC_VER );
76 used += snprintf ( build + used, dbuild - used,
"using an unknown C compiler " );
78 snprintf ( build + used, dbuild - used,
"at %s %s",__DATE__,__TIME__ );
82#ifdef BUILD_USING_CMAKE
88 *version_major = major;
90 *version_minor = minor;
92 *version_patch = patch;
143 memset ( b, 0,
sizeof (
struct bufrdeco ) );
151 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Cannot allocate space for tables\n", __func__ );
162 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Cannot allocate space for expanded tree of descriptors\n", __func__ );
199 memset ( b, 0,
sizeof (
struct bufrdeco ) );
211 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Cannot allocate space for expanded tree of descriptors\n", __func__ );
338 f = fopen ( filename,
"w" );
367 if ( stat ( filename, &st ) < 0 )
373 f = fopen ( filename,
"r" );
400 uint32_t mask0 = b->
mask;
404 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): The index of target subset is over the bufr subsets (%d)\n", __func__, b->
sec3.
subsets );
411 printf (
"# Compressed\n");
443 printf (
"# Go to parse for subset %lu waiting %lu\n", b->
state.
subset, nset);
455 printf (
"# Finally going to target parse for subset %lu\n", b->
state.
subset);
int bufrdeco_reset(struct bufrdeco *b)
Reset an struct bufrdeco. This is needed when changing to another bufr.
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()
int bufrdeco_set_out_stream(FILE *out, struct bufrdeco *b)
Set the library normal output stream.
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.
int bufrdeco_close(struct bufrdeco *b)
Free all allocated memory. Needed when no more task to do with bufrdeco library.
int bufrdeco_set_err_stream(FILE *err, struct bufrdeco *b)
Set the error stream.
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_write_subset_offset_bits(struct bufrdeco *b, char *filename)
Write offset bit array for subsets in a non-compressed bufr.
int bufrdeco_parse_tree(struct bufrdeco *b)
Parse the tree of descriptors without expand the replicators.
int bufrdeco_read_subset_offset_bits(struct bufrdeco *b, char *filename)
Write offset bit array for subsets in a non-compressed 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.
int bufrdeco_init(struct bufrdeco *b)
Inits and allocate memory for a struct bufrdeco.
Include header file for bufrdeco library.
int bufrdeco_init_tables(struct bufr_tables **t)
Init a struct bufr_tables allocating space.
uint32_t buf_t
Type to set offsets and dimension of arrays or counters used in bufrdeco.
struct bufrdeco_subset_sequence_data * bufrdeco_get_subset_sequence_data(struct bufrdeco *b)
Parse and get a struct bufrdeco_subset_sequence_data.
#define bufrdeco_assert(__my_expr__)
Check a expression and exit if it fails.
int bufrdeco_free_subset_sequence_data(struct bufrdeco_subset_sequence_data *ba)
Free the memory for sequence array in a struct bufrdeco_subset_sequence_data.
int bufrdeco_init_expanded_tree(struct bufrdeco_expanded_tree **t)
Init a struct bufrdeco_expanded_tree allocating space.
#define strncpy_safe(_target_, _src_, _dim_)
Macro to make safely a strcpy when we know in calling function the size of string target directly.
int bufrdeco_free_tables(struct bufr_tables **t)
Frees the allocated space for a struct bufr_tables.
int bufr_write_subset_offset_bits(FILE *f, struct bufrdeco_subset_bit_offsets *off)
Write offset bit array for subsets in a non-compressed bufr.
int bufrdeco_free_cache_tables(struct bufr_tables_cache *c)
deallocate and clean a bufr_tables_cache
int bufrdeco_free_bitmap_array(struct bufrdeco_bitmap_array *a)
Free an allocated bitmap array.
#define BUFRDECO_OUTPUT_JSON_SUBSET_DATA
Bit mask to the member mask of struct bufrdeco to print bufr subset data in json format.
int bufr_read_subset_offset_bits(FILE *f, struct bufrdeco_subset_bit_offsets *off)
Write offset bit array for subsets in a non-compressed bufr.
#define bufrdeco_assert_with_return_val(__my_expr__, __returnval__)
Check a expression and returns a given value if it fails.
int bufrdeco_parse_tree_recursive(struct bufrdeco *b, struct bufr_sequence *father, buf_t father_idesc, const char *key)
Parse the descriptor tree in a recursive way.
#define BUFRDECO_PATH_LENGTH
Length for files/directory path strings.
#define BUFRDECO_USE_TABLES_CACHE
Bit mask to the member mask of struct bufrdeco to mark the use of bufr_tables cache.
int bufrdeco_free_expanded_tree(struct bufrdeco_expanded_tree **t)
Frees the allocated space for a struct bufrdeco_expanded_tree.
int bufrdeco_parse_compressed(struct bufrdeco_compressed_data_references *r, struct bufrdeco *b)
Preliminary parse of a compressed data bufr.
int bufrdeco_extract_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_file()
int bufrdeco_free_compressed_data_references(struct bufrdeco_compressed_data_references *rf)
Free the memory allocated for array of references in a struct bufrdeco_compressed_data_references.
int bufrdeco_decode_data_subset(struct bufrdeco *b)
User interface to decode a BUFR subset.
Struct to store the cache of structs bufr_tables.
Contains all tables needed to parse a bufr file.
buf_t ofs[BUFR_MAX_SUBSETS]
Contains all the information for a subset in a expanded squence This is a version to use with bufrdec...
This struct contains all needed data to parse and decode a BUFR file.
struct bufrdeco_bitmap_array bitmap
struct bufrdeco_subset_sequence_data seq
struct bufr_tables_cache cache
struct bufrdeco_compressed_data_references refs
struct bufrdeco_subset_bit_offsets offsets
struct bufrdeco_decoding_data_state state
struct bufr_tables * tables
char bufrtables_dir[BUFRDECO_PATH_LENGTH]
struct bufrdeco_expanded_tree * tree