50 if ( tc->
path[0] == 0 )
59 printf (
"# Reused table %s\n", tc->
path);
64 strcpy ( caux, tc->
path );
66 strcpy ( tc->
path, caux );
67 if ( ( t = fopen ( tc->
path,
"r" ) ) == NULL )
69 snprintf ( b->
error, sizeof ( b->
error ),
"Unable to open table C file '%s'\n", tc->
path );
82 snprintf ( b->
error, sizeof ( b->
error ),
"Error parsing csv line from table C file '%s'. Found %d fields in line %u \n", tc->
path, nt, i );
88 if ( tk[1][0] == 0 || strchr ( tk[1],
'-' ) != NULL || strstr ( tk[1],
"All" ) != NULL )
93 ix = strtoul ( tk[0], &c, 10 );
95 strcpy ( tc->
item[i].
key, tk[0] );
100 tc->
item[i].
ival = strtoul ( tk[1], &c, 10 );
106 if ( tc->
num[desc.
x] == 0 )
110 if ( tc->
y_ref[desc.
x][desc.
y] == 0 )
114 ( tc->
num[desc.
x] ) ++;
143 ix = strtoul ( key, &
c, 10 );
146 for ( i = i0 ; i < i0 + tc->
num[desc.
x] ; i++ )
172 bufrdeco_assert ( tc != NULL && expl != NULL && index != NULL && d != NULL);
201 uint64_t ival, uint8_t nbits )
204 uint64_t test, test0;
210 if ( tc->
num[d->
x] == 0 )
222 for ( j = 0, test0 = 1 ; j < nbits && ( tc->
item[i].
x == d->
x ) && ( tc->
item[i].
y == d->
y ) ; i++ )
233 used += snprintf ( expl + used, dim - used,
"|" );
234 used += snprintf ( expl + used, dim - used,
"%s", tc->
item[i].
description );
239 test = test0 << ( nbits - v );
241 if ( v && ( test & ival ) != 0 )
243 used += snprintf ( expl + used, dim - used,
"|" );
244 used += snprintf ( expl + used, dim - used,
"%s", tc->
item[i].
description );
Include header file for bufrdeco library.
uint32_t buf_t
Type to set offsets and dimension of arrays or counters used in bufrdeco.
#define bufrdeco_assert(__my_expr__)
Check a expression and exit if it fails.
#define BUFR_EXPLAINED_LENGTH
Maximum length for a explained descriptor string.
#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 uint32_t_to_descriptor(struct bufr_descriptor *d, uint32_t id)
parse an integer with a descriptor fom bufr ECWMF libary
#define CSV_MAXL
Maximum length in a string to be parsed as csv.
#define BUFR_MAXLINES_TABLEC
The maximum expected lines in a Table C file.
int parse_csv_line(int *nt, char *tk[], char *lin)
Parse a csv line.
int bufr_read_tableC(struct bufrdeco *b)
Reads a file with table C content (Code table and bit flags) according with csv WMO format.
char * bufrdeco_explained_table_val(char *expl, size_t dim, struct bufr_tableC *tc, uint32_t *index, struct bufr_descriptor *d, uint32_t ival)
char * bufrdeco_explained_flag_val(char *expl, size_t dim, struct bufr_tableC *tc, struct bufr_descriptor *d, uint64_t ival, uint8_t nbits)
int bufr_find_tableC_csv_index(buf_t *index, struct bufr_tableC *tc, const char *key, uint32_t code)
char description[BUFR_EXPLAINED_LENGTH]
Store a table C readed from a file formated and named as ECMWF bufrdc package.
struct bufr_tableC_decoded_item item[BUFR_MAXLINES_TABLEC]
char path[BUFRDECO_PATH_LENGTH]
char old_path[BUFRDECO_PATH_LENGTH]
This struct contains all needed data to parse and decode a BUFR file.
struct bufr_tables * tables