bufr2synop 0.24.0
|
This file has the code of useful routines for library bufrdeco. More...
#include "bufrdeco.h"
Go to the source code of this file.
Functions | |
buf_t | get_bits_as_char_array2 (char *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length) |
buf_t | get_bits_as_char_array (char *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length) |
uint32_t | get_bits_as_uint32_t2 (uint32_t *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length) |
Read bits from an array of uint8_t and set them as an uint32_t. More... | |
uint32_t | get_bits_as_uint32_t (uint32_t *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length) |
int | get_table_b_reference_from_uint32_t (int32_t *target, uint8_t bits, uint32_t source) |
Get an int32_t from bits according with bufr criteria to change the reference of a descritor. Most significant bit in source is sign. More... | |
uint32_t | two_bytes_to_uint32 (const uint8_t *source) |
returns the uint32_t value from an array of two bytes, most significant first More... | |
uint32_t | three_bytes_to_uint32 (const uint8_t *source) |
returns the uint32_t value from an array of three bytes, most significant first More... | |
int | uint32_t_to_descriptor (struct bufr_descriptor *d, uint32_t id) |
parse an integer with a descriptor fom bufr ECWMF libary More... | |
int | two_bytes_to_descriptor (struct bufr_descriptor *d, const uint8_t *source) |
set a struct bufr_descriptor from two consecutive bytes in bufr file More... | |
char * | bufr_charray_to_string (char *s, char *buf, size_t size) |
get a null termitated c-string from an array of unsigned chars More... | |
char * | bufr_adjust_string (char *s) |
Supress trailing blanks of a string. More... | |
int | is_a_delayed_descriptor (struct bufr_descriptor *d) |
check if a descriptor is a delayed descriptor More... | |
int | is_a_short_delayed_descriptor (struct bufr_descriptor *d) |
check if a descriptor is a short delayed descriptor More... | |
int | is_a_local_descriptor (struct bufr_descriptor *d) |
check if a descriptor is a local descriptor More... | |
char * | get_formatted_value_from_escale (char *fmt, size_t dim, int32_t escale, double val) |
gets a string with formatted value depending of scale More... | |
char * | get_formatted_value_from_escale2 (char *fmt, size_t dim, int32_t escale, double val) |
gets a string with formatted value depending of scale More... | |
int | bufrdeco_add_to_bitmap (struct bufrdeco_bitmap *bm, buf_t index_to, buf_t index_by) |
Push a bitmap element in a bufrdeco_bitmap. More... | |
int | get_bitmaped_info (struct bufrdeco_bitmap_related_vars *brv, uint32_t target, struct bufrdeco *b) |
Get bitmap info searching into bitmaps. More... | |
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. More... | |
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. More... | |
Variables | |
uint8_t | bitf [8] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01} |
uint8_t | biti [8] = {0xFF,0x7f,0x3f,0x1F,0x0F,0x07,0x03,0x01} |
uint8_t | bitk [8] = {0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff} |
This file has the code of useful routines for library bufrdeco.
Definition in file bufrdeco_utils.c.
char * bufr_adjust_string | ( | char * | s | ) |
Supress trailing blanks of a string.
s | string to process |
Definition at line 333 of file bufrdeco_utils.c.
Referenced by bufrdeco_print_json_object_atom_data(), bufrdeco_print_json_tree_recursive(), and main().
char * bufr_charray_to_string | ( | char * | s, |
char * | buf, | ||
size_t | size | ||
) |
get a null termitated c-string from an array of unsigned chars
s | resulting string |
buf | pointer to first element in array |
size | number of chars in array |
Definition at line 316 of file bufrdeco_utils.c.
Referenced by main().
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.
f | file pointer opened by caller |
off | pointer to the struct bufrdeco_subset_bit_offsets with the data to write into file |
Definition at line 577 of file bufrdeco_utils.c.
References bufrdeco_assert_with_return_val, bufrdeco_subset_bit_offsets::nr, and bufrdeco_subset_bit_offsets::ofs.
Referenced by bufrdeco_read_subset_offset_bits().
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.
f | file pointer opened by caller |
off | pointer to the struct bufrdeco_subset_bit_offsets with the data to write into file |
Definition at line 555 of file bufrdeco_utils.c.
References bufrdeco_assert_with_return_val, bufrdeco_subset_bit_offsets::nr, and bufrdeco_subset_bit_offsets::ofs.
Referenced by bufrdeco_write_subset_offset_bits().
int bufrdeco_add_to_bitmap | ( | struct bufrdeco_bitmap * | bm, |
buf_t | index_to, | ||
buf_t | index_by | ||
) |
Push a bitmap element in a bufrdeco_bitmap.
bm | target struct bufrdeco_bitmap where to push |
index_to | index of the bufrdeco_bitmap which this is bitmapping to |
index_by | index of the bufrdeco_bitmap which this is bitmapped by |
Definition at line 461 of file bufrdeco_utils.c.
References bufrdeco_bitmap::bitmap_to, bufrdeco_bitmap::bitmaped_by, BUFR_MAX_BITMAP_PRESENT_DATA, and bufrdeco_bitmap::nb.
Referenced by bufrdeco_decode_replicated_subsequence(), and bufrdeco_decode_replicated_subsequence_compressed().
int get_bitmaped_info | ( | struct bufrdeco_bitmap_related_vars * | brv, |
uint32_t | target, | ||
struct bufrdeco * | b | ||
) |
Get bitmap info searching into bitmaps.
brv | pointer to struct bufrdeco_bitmap_related_vars where to set the results |
target | The key to find in array of bitmaps |
b | pointer to the current struct bufrdeco |
Definition at line 484 of file bufrdeco_utils.c.
References bufrdeco::bitmap, bufrdeco_bitmap::bitmap_to, bufrdeco_bitmap::bitmaped_by, bufrdeco_bitmap_related_vars::bitmaped_by, bufrdeco_bitmap_array::bmap, bufrdeco_bitmap::dstat, bufrdeco_bitmap_related_vars::dstat, bufrdeco_bitmap::nb, bufrdeco_bitmap_related_vars::nb, bufrdeco_bitmap_array::nba, bufrdeco_bitmap_related_vars::nba, bufrdeco_bitmap::nds, bufrdeco_bitmap::nq, bufrdeco_bitmap::ns1, bufrdeco_bitmap_related_vars::qualified_by, bufrdeco_bitmap::quality, bufrdeco_bitmap::retain, bufrdeco_bitmap_related_vars::retained, bufrdeco_bitmap::stat1, bufrdeco_bitmap_related_vars::stat1, bufrdeco_bitmap_related_vars::stat1_desc, bufrdeco_bitmap::subs, bufrdeco_bitmap_related_vars::substituted, and bufrdeco_bitmap_related_vars::target.
buf_t get_bits_as_char_array | ( | char * | target, |
uint8_t * | has_data, | ||
uint8_t * | source, | ||
buf_t * | bit0_offset, | ||
buf_t | bit_length | ||
) |
Definition at line 86 of file bufrdeco_utils.c.
Referenced by bufrdeco_get_atom_data_from_compressed_data_ref(), bufrdeco_parse_f2_compressed(), bufrdeco_parse_f2_descriptor(), bufrdeco_tableB_compressed(), and bufrdeco_tableB_val().
buf_t get_bits_as_char_array2 | ( | char * | target, |
uint8_t * | has_data, | ||
uint8_t * | source, | ||
buf_t * | bit0_offset, | ||
buf_t | bit_length | ||
) |
Definition at line 40 of file bufrdeco_utils.c.
References bitf.
uint32_t get_bits_as_uint32_t | ( | uint32_t * | target, |
uint8_t * | has_data, | ||
uint8_t * | source, | ||
buf_t * | bit0_offset, | ||
buf_t | bit_length | ||
) |
Definition at line 182 of file bufrdeco_utils.c.
References biti, and get_bits_as_uint32_t2().
Referenced by bufrdeco_get_atom_data_from_compressed_data_ref(), bufrdeco_parse_f2_compressed(), bufrdeco_tableB_compressed(), and bufrdeco_tableB_val().
size_t get_bits_as_uint32_t2 | ( | uint32_t * | target, |
uint8_t * | has_data, | ||
uint8_t * | source, | ||
buf_t * | bit0_offset, | ||
buf_t | bit_length | ||
) |
Read bits from an array of uint8_t and set them as an uint32_t.
target | uint32_t pointer where to set the result |
has_data | Output flags to check whether is missing data. If 0 then data is missing, othewise has data |
source | array of uint8_t elements. Most significant bit of first element is the bit offset reference |
bit0_offset | Bit offset |
bit_length | Lenght (in bits) for the chunck to extract |
This is a version which extract bit a bit. For more than about 8 bits should be used the algorithm in get_bits_as_uint32_t
Definition at line 135 of file bufrdeco_utils.c.
References bitf.
Referenced by get_bits_as_uint32_t().
char * get_formatted_value_from_escale | ( | char * | fmt, |
size_t | dim, | ||
int32_t | escale, | ||
double | val | ||
) |
gets a string with formatted value depending of scale
fmt | The output target string |
dim | Size of available space (bytes) to write the result |
escale | value scale in descriptor |
val | double to printf |
Definition at line 410 of file bufrdeco_utils.c.
Referenced by bufrdeco_print_atom_data(), and bufrdeco_print_atom_data_html().
char * get_formatted_value_from_escale2 | ( | char * | fmt, |
size_t | dim, | ||
int32_t | escale, | ||
double | val | ||
) |
gets a string with formatted value depending of scale
fmt | The output target string |
dim | Size of available space (bytes) to write the result |
escale | value scale in descriptor |
val | double to printf |
Differs from get_formatted_value_from_escale that no blanks are written
Definition at line 436 of file bufrdeco_utils.c.
Referenced by bufrdeco_print_json_object_atom_data().
int get_table_b_reference_from_uint32_t | ( | int32_t * | target, |
uint8_t | bits, | ||
uint32_t | source | ||
) |
Get an int32_t from bits according with bufr criteria to change the reference of a descritor. Most significant bit in source is sign.
target | int32_t as result |
bits | number of bits to consider |
source | uint32_T with the data to transform |
Definition at line 221 of file bufrdeco_utils.c.
Referenced by bufrdeco_tableB_compressed(), and bufrdeco_tableB_val().
int is_a_delayed_descriptor | ( | struct bufr_descriptor * | d | ) |
check if a descriptor is a delayed descriptor
d | pointer to a struct bufr_descriptor to check |
Definition at line 351 of file bufrdeco_utils.c.
References bufr_descriptor::f, bufr_descriptor::x, and bufr_descriptor::y.
Referenced by bufrdeco_fprint_tree_recursive(), bufrdeco_print_json_tree_recursive(), and bufrdeco_tableB_compressed().
int is_a_local_descriptor | ( | struct bufr_descriptor * | d | ) |
check if a descriptor is a local descriptor
d | pointer to a struct bufr_descriptor to check |
Definition at line 388 of file bufrdeco_utils.c.
References bufr_descriptor::f, and bufr_descriptor::x.
Referenced by bufrdeco_get_atom_data_from_compressed_data_ref(), bufrdeco_tableB_compressed(), and bufrdeco_tableB_val().
int is_a_short_delayed_descriptor | ( | struct bufr_descriptor * | d | ) |
check if a descriptor is a short delayed descriptor
d | pointer to a struct bufr_descriptor to check |
Definition at line 369 of file bufrdeco_utils.c.
References bufr_descriptor::f, bufr_descriptor::x, and bufr_descriptor::y.
Referenced by bufrdeco_fprint_tree_recursive(), bufrdeco_print_json_tree_recursive(), and bufrdeco_tableB_compressed().
uint32_t three_bytes_to_uint32 | ( | const uint8_t * | source | ) |
returns the uint32_t value from an array of three bytes, most significant first
source | pointer to source uint8_t |
Definition at line 265 of file bufrdeco_utils.c.
Referenced by bufrdeco_read_buffer().
int two_bytes_to_descriptor | ( | struct bufr_descriptor * | d, |
const uint8_t * | source | ||
) |
set a struct bufr_descriptor from two consecutive bytes in bufr file
source | pointer to first byte (most significant) |
d | pointer to the resulting descriptor |
Definition at line 297 of file bufrdeco_utils.c.
References bufr_descriptor::c, bufr_descriptor::f, bufr_descriptor::x, and bufr_descriptor::y.
Referenced by bufrdeco_read_buffer().
uint32_t two_bytes_to_uint32 | ( | const uint8_t * | source | ) |
returns the uint32_t value from an array of two bytes, most significant first
source | pointer to source uint8_t |
Definition at line 250 of file bufrdeco_utils.c.
Referenced by bufrdeco_read_buffer().
int uint32_t_to_descriptor | ( | struct bufr_descriptor * | d, |
uint32_t | id | ||
) |
parse an integer with a descriptor fom bufr ECWMF libary
d | pointer to a struct bufr_descriptor where to set the result on output |
id | integer with the descriptor from ewcwf |
Definition at line 278 of file bufrdeco_utils.c.
References bufr_descriptor::c, bufr_descriptor::f, bufr_descriptor::x, and bufr_descriptor::y.
Referenced by bufr_find_tableB_index(), bufr_find_tableC_csv_index(), bufr_read_tableB(), bufr_read_tableC(), bufr_read_tableD(), bufrdeco_tableD_get_descriptors_array(), and main().
uint8_t bitf[8] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01} |
Mask a single bit of a byte
Definition at line 26 of file bufrdeco_utils.c.
Referenced by get_bits_as_char_array2(), and get_bits_as_uint32_t2().
uint8_t biti[8] = {0xFF,0x7f,0x3f,0x1F,0x0F,0x07,0x03,0x01} |
Mask remaining bits in a byte (less significant)
Definition at line 27 of file bufrdeco_utils.c.
Referenced by get_bits_as_char_array(), and get_bits_as_uint32_t().
uint8_t bitk[8] = {0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff} |
Mask first bits in a byte (most significant)
Definition at line 28 of file bufrdeco_utils.c.
Referenced by get_bits_as_char_array().