50 if ( td->
path[0] == 0 )
59 printf (
"# Reused table %s\n", td->
path);
64 strcpy ( caux, td->
path );
66 strcpy ( td->
path,caux );
67 if ( ( t = fopen ( td->
path,
"r" ) ) == NULL )
69 snprintf ( b->
error, sizeof (b->
error),
"Unable to open table D file '%s'\n", td->
path );
83 if (
parse_csv_line ( &nt, tk, laux ) < 0 || ( nt != 2 && nt != 4) )
85 snprintf ( b->
error, sizeof (b->
error),
"Error parsing csv line from table D file '%s' found %d tokens in line %u\n", td->
path, nt, i );
93 if (nt == 4 && tk[2][0])
98 if (nt == 4 && tk[3][0])
103 if ( strcmp ( oldkey, tk[0] ) )
108 sprintf ( aux,
"%s%3d", oldkey, nj );
109 td->
l[j0][1] = aux[0];
110 td->
l[j0][2] = aux[1];
111 td->
l[j0][3] = aux[2];
112 td->
l[j0][4] = aux[3];
113 td->
l[j0][5] = aux[4];
114 td->
l[j0][6] = aux[5];
115 td->
l[j0][7] = aux[6];
116 td->
l[j0][8] = aux[7];
117 td->
l[j0][9] = aux[8];
126 strcpy ( oldkey, tk[0] );
128 ix = strtoul ( tk[0], &c, 10 );
131 if ( td->
num[desc.
x] == 0 )
135 ( td->
num[desc.
x] ) ++;
138 sprintf ( td->
l[i],
" %s", tk[1] );
144 sprintf ( aux,
"%s%3d", oldkey, nj );
145 td->
l[j0][1] = aux[0];
146 td->
l[j0][2] = aux[1];
147 td->
l[j0][3] = aux[2];
148 td->
l[j0][4] = aux[3];
149 td->
l[j0][5] = aux[4];
150 td->
l[j0][6] = aux[5];
151 td->
l[j0][7] = aux[6];
152 td->
l[j0][8] = aux[7];
153 td->
l[j0][9] = aux[8];
180 ix = strtoul ( aux, &c, 10 );
182 for ( i = i0 ; i < i0 + td->
num[ix] ; i++ )
184 if ( td->
l[i][1] != key[0] ||
185 td->
l[i][2] != key[1] ||
186 td->
l[i][3] != key[2] ||
187 td->
l[i][4] != key[3] ||
188 td->
l[i][5] != key[4] ||
189 td->
l[i][6] != key[5] )
223 if ( s == NULL || b == NULL || key == NULL )
225 snprintf ( b->
error, sizeof (b->
error),
"%s(): Wrong entry arguments\n", __func__ );
233 snprintf ( b->
error, sizeof (b->
error),
"%s(): descriptor '%s' not found in table D\n", __func__, key );
244 nv = strtoul ( &td->
l[i][7], &c, 10 );
252 for ( j = 0; j < nv && ( i + j ) < td->
nlines ; j++ )
254 v = strtoul ( & ( td->
l[i+j][11] ), &c, 10 );
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.
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.
int parse_csv_line(int *nt, char *tk[], char *lin)
Parse a csv line.
#define BUFR_MAXLINES_TABLED
The maximum expected lines in a Table D file.
int bufr_find_tableD_index(buf_t *index, struct bufr_tableD *td, const char *key)
int bufr_read_tableD(struct bufrdeco *b)
Reads a file with table D content according with WMO csv format.
int bufrdeco_tableD_get_descriptors_array(struct bufr_sequence *s, struct bufrdeco *b, const char *key)
get the descriptors array for a descriptor sequence defined in table D with F = 3
Stores an unexpanded sequence of descriptors.
struct bufr_descriptor lseq[NMAXSEQ_DESCRIPTORS]
char name[BUFR_EXPLAINED_LENGTH]
char description2[BUFR_EXPLAINED_LENGTH]
char description[BUFR_EXPLAINED_LENGTH]
Store a table D readed from a file formated and named as ECMWF bufrdc package.
char l[BUFR_MAXLINES_TABLED][24]
char path[BUFRDECO_PATH_LENGTH]
char old_path[BUFRDECO_PATH_LENGTH]
struct bufr_tableD_decoded_item item[BUFR_MAXLINES_TABLED]
This struct contains all needed data to parse and decode a BUFR file.
struct bufr_tables * tables