35 buf_t i = 0, used = 0;
41 used += fprintf ( out,
"%c%c",
'\\', source[i++] );
44 used += fprintf ( out,
"%c", source[i++] );
65 used += fprintf ( out,
"{\"BUFR File\":\"%s\",\"Subset\":%u,\"Decoded data\":",b->
header.
filename, b->
seq.
ss );
82 used += fprintf ( out,
"}\n" );
98 used += fprintf ( out,
"{\"Descriptor\":\"%c %c%c %c%c%c\",", seq->
key[0], seq->
key[1], seq->
key[2], seq->
key[3], seq->
key[4], seq->
key[5] );
99 used += fprintf ( out,
"\"Sequence description\":\"%s\",\"Expanded sequence\":[", seq->
name );
114 used += fprintf ( out,
"]}" );
142 if ( add != NULL && add[0] )
143 used += fprintf ( out,
"%s,", add );
149 used += fprintf ( out,
"\"Unit\":\"CCITT5\",\"Value\":\"MISSING\"}" ) ;
152 used += fprintf ( out,
"\"Unit\":\"CCITT5\",\"Value\":\"" ) ;
154 used += fprintf ( out,
"\"}" );
161 used += fprintf ( out,
"\"Unit\":\"Code table\",\"Value\":\"MISSING\"}" ) ;
164 used += fprintf ( out,
"\"Unit\":\"Code table\",\"Value\":%u,", ( uint32_t ) ( a->
val + 0.5 ) ) ;
172 used += fprintf ( out,
"\"Unit\":\"Flag table\",\"Value\":\"MISSING\"}" ) ;
175 used += fprintf ( out,
"\"Unit\":\"Flag table\",\"Value\":\"0x%08X\",", ( uint32_t ) ( a->
val ) ) ;
183 used += fprintf ( out,
"\"Unit\":\"%s\",\"Value\":\"MISSING\"}", a->
unit ) ;
186 used += fprintf ( out,
"\"Unit\":\"%s\",\"Value\":%s}", a->
unit,
206 char explanation[256];
211 used += fprintf ( out,
"{\"Descriptor\":\"%u %02u %03u\",", d->
f, d->
x, d->
y );
213 if ( add != NULL && add[0] )
214 used += fprintf ( out,
"%s,", add );
236 used += fprintf ( out,
"{\"Descriptor\":\"%u %02u %03u\",", d->
f, d->
x, d->
y );
238 if ( add != NULL && add[0] )
239 used += fprintf ( out,
"%s,", add );
244 used += fprintf ( out,
"\"Replicator\":\"Replicator for %d descriptor after next delayed descriptor which set the number of replications.\"}", d->
x );
246 used += fprintf ( out,
"\"Replicator\":\"Replicator for %d descriptors after next delayed descriptor which set the number of replications.\"}", d->
x );
251 used += fprintf ( out,
"\"Replicator\":\"Replicator for next descriptor %d times.\"}", d->
y );
253 used += fprintf ( out,
"\"Replicator\":\"Replicator for next %d descriptors %d times\"}", d->
x, d->
y );
269 return fprintf ( out,
"," );
285 used += fprintf ( out,
"{\"Sec 0\":{" );
287 used += fprintf ( out,
"\"Bufr edition\":%u}}", b->
sec0.
edition );
305 used += fprintf ( out,
"{\"Sec 1\":{" );
306 used += fprintf ( out,
"\"Length\":%u", b->
sec1.
length );
307 used += fprintf ( out,
",\"Bufr master table\":%u", b->
sec1.
master );
308 used += fprintf ( out,
",\"Centre\":%u", b->
sec1.
centre );
309 used += fprintf ( out,
",\"Sub-Centre\":%u", b->
sec1.
subcentre );
310 used += fprintf ( out,
",\"Update sequence\":%u", b->
sec1.
update );
311 used += fprintf ( out,
",\"Options\":\"0x%x\"", b->
sec1.
options );
312 used += fprintf ( out,
",\"Category\":%u", b->
sec1.
category );
316 used += fprintf ( out,
",\"Master table local\":%u", b->
sec1.
master_local );
317 used += fprintf ( out,
",\"Year\":%u", b->
sec1.
year );
318 used += fprintf ( out,
",\"Month\":%u", b->
sec1.
month );
319 used += fprintf ( out,
",\"Day\":%u", b->
sec1.
day );
320 used += fprintf ( out,
",\"Hour\":%u", b->
sec1.
hour );
321 used += fprintf ( out,
",\"Minute\":%u", b->
sec1.
minute );
322 used += fprintf ( out,
",\"Second\":%u", b->
sec1.
second );
324 used += fprintf ( out,
",\"Aditional space\":%u", b->
sec1.
length - 17 );
326 used += fprintf ( out,
",\"Aditional space\":%u", b->
sec1.
length - 22 );
327 used += fprintf ( out,
"}" );
331 used += fprintf ( out,
",{\"Used tables\":{" );
332 used += fprintf ( out,
",\"TableB file\":\"%s\"", b->
tables->
b.
path );
333 used += fprintf ( out,
",\"tableC file\":\"%s\"", b->
tables->
c.
path );
334 used += fprintf ( out,
",\"tableD file\":\"%s\"", b->
tables->
d.
path );
335 used += fprintf ( out,
"}" );
337 used += fprintf ( out,
"}" );
355 used += fprintf ( out,
"{\"Sec 2\":{" );
357 used += fprintf ( out,
"\"Length\":%u}}", b->
sec2.
length );
359 used += fprintf ( out,
"\"Length\":0}}" );
377 used += fprintf ( out,
"{\"Sec 3\":{" );
378 used += fprintf ( out,
"\"Sec3 length\":%u", b->
sec3.
length );
379 used += fprintf ( out,
",\"Subsets\":%u", b->
sec3.
subsets );
380 used += fprintf ( out,
",\"Observed\":%u", b->
sec3.
observed );
381 used += fprintf ( out,
",\"Compressed\":%u", b->
sec3.
compressed );
382 used += fprintf ( out,
",\"Unexpanded descriptors\":%u", b->
sec3.
ndesc );
383 used += fprintf ( out,
",\"Unexpanded array\":" );
385 used += fprintf ( out,
"[" );
389 used += fprintf ( out,
"," );
392 used += fprintf ( out,
"]}}" );
407 buf_t i, k, used = 0;
409 char explanation[256];
423 for ( i = 0; i < l->
ndesc; i++ )
426 used += fprintf ( out,
"," );
427 fprintf ( out,
"{\"%u %02u %03u\"", l->
lseq[i].
f, l->
lseq[i].
x,l->
lseq[i].
y );
429 if ( l->
lseq[i].
f != 3 )
431 if ( l->
lseq[i].
f == 0 )
434 used += fprintf ( out,
"\"Not found in tables\"}" );
437 used += fprintf ( out,
":\"" );
443 used += fprintf ( out,
"Replicated | " );
445 used += fprintf ( out,
"Replicated depth %u | ", l->
replicated[i] );
455 else if ( l->
lseq[i].
f == 2 )
459 else if ( l->
lseq[i].
f == 1 )
461 if ( l->
lseq[i].
y == 0 )
463 if ( l->
lseq[i].
x == 1 )
464 used += fprintf ( out,
":\"* Replicator for %d descriptor after next delayed descriptor which set the number of replications.\"}", l->
lseq[i].
x );
466 used += fprintf ( out,
":\"* Replicator for %d descriptors after next delayed descriptor which set the number of replications.\"}", l->
lseq[i].
x );
470 if ( l->
lseq[i].
x == 1 )
471 used += fprintf ( out,
":\"* Replicator for next descriptor %d times\"}", l->
lseq[i].
y );
473 used += fprintf ( out,
":\"* Replicator for next %d descriptors %d times\"}", l->
lseq[i].
x, l->
lseq[i].
y );
477 used += fprintf ( out,
"\n" );
483 used += fprintf ( out,
":\"" );
487 used += fprintf ( out,
"Replicated | " );
489 used += fprintf ( out,
"Replicated depth %u | ", l->
replicated[i] );
492 used += fprintf ( out,
",\"Expanded\":[" );
495 used += fprintf ( out,
"]}" );
buf_t bufrdeco_print_json_subset_data_prologue(FILE *out, struct bufrdeco *b)
buf_t bufrdeco_print_json_sec1(FILE *out, struct bufrdeco *b)
Print info form sec 1 in json format.
buf_t bufrdeco_print_json_sec2(FILE *out, struct bufrdeco *b)
Print info form optional sec 2 in json format.
buf_t bufrdeco_print_json_separator(FILE *out)
Print the comma ',' separator in an output.
buf_t bufrdeco_print_json_tree_recursive(FILE *out, struct bufrdeco *b, struct bufr_sequence *seq)
Print a tree of descriptors to a file in a recursive way in json format.
buf_t bufrdeco_print_json_sequence_descriptor_final(FILE *out)
buf_t bufrdeco_print_json_object_operator_descriptor(FILE *out, struct bufr_descriptor *d, char *add)
print an operator desciptor as a json object
buf_t bufrdeco_print_json_sec0(FILE *out, struct bufrdeco *b)
buf_t bufrdeco_print_json_sequence_descriptor_header(FILE *out, struct bufr_sequence *seq)
Print the header of a sequence descriptor (f == 3)
buf_t bufrdeco_print_json_sec3(FILE *out, struct bufrdeco *b)
Print info form sec 3 in json format.
buf_t bufrdeco_print_json_object_replicator_descriptor(FILE *out, struct bufr_descriptor *d, char *add)
print an operator desciptor as a json object
buf_t bufrdeco_print_json_object_atom_data(FILE *out, struct bufr_atom_data *a, char *add)
Print an json object with a descriptor data.
buf_t bufrdeco_print_json_subset_data_epilogue(FILE *out)
buf_t bufrdeco_print_json_scape_string_cvals(FILE *out, char *source)
prints a descriptor string value scaping the '"' for a json format
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 bufr_find_tableB_index(buf_t *index, struct bufr_tableB *tb, const char *key)
found a descriptor index in a struct bufr_tableB
#define BUFRDECO_OUTPUT_JSON_EXPANDED_TREE
Bit mask to the member mask of struct bufrdeco to print bufr expanded tree of descriptors.
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
buf_t bufrdeco_print_json_tree(struct bufrdeco *b)
#define DESCRIPTOR_HAVE_STRING_VALUE
Bit mask for a string in a struct bufr_atom_data.
#define DESCRIPTOR_IS_FLAG_TABLE
Bit mask for a flag table in a struct bufr_atom_data.
#define DESCRIPTOR_IS_CODE_TABLE
Bit mask for a code table in a struct bufr_atom_data.
int is_a_delayed_descriptor(struct bufr_descriptor *d)
check if a descriptor is a delayed descriptor
#define DESCRIPTOR_VALUE_MISSING
Bit mask for a missing value in a struct bufr_atom_data.
char * bufr_adjust_string(char *s)
Supress trailing blanks of a string.
int is_a_short_delayed_descriptor(struct bufr_descriptor *d)
check if a descriptor is a short delayed descriptor
char * bufrdeco_get_f2_descriptor_explanation(char *e, size_t dim, struct bufr_descriptor *d)
Contains all the information for a single data related with a descriptor in a expanded squence.
char name[BUFR_TABLEB_NAME_LENGTH]
char ctable[BUFR_EXPLAINED_LENGTH]
struct bufr_descriptor desc
char unit[BUFR_TABLEB_UNIT_LENGTH]
char cval[BUFR_CVAL_LENGTH]
uint8_t subcategory_local
struct bufr_descriptor unexpanded[BUFR_LEN_UNEXPANDED_DESCRIPTOR]
Stores an unexpanded sequence of descriptors.
struct bufr_descriptor lseq[NMAXSEQ_DESCRIPTORS]
uint8_t replicated[NMAXSEQ_DESCRIPTORS]
struct bufr_sequence * sons[NMAXSEQ_DESCRIPTORS]
char name[BUFR_EXPLAINED_LENGTH]
char name[BUFR_TABLEB_NAME_LENGTH]
struct bufr_tableB_decoded_item item[BUFR_MAXLINES_TABLEB]
char path[BUFRDECO_PATH_LENGTH]
char path[BUFRDECO_PATH_LENGTH]
char path[BUFRDECO_PATH_LENGTH]
struct bufr_sequence seq[BUFR_MAX_EXPANDED_SEQUENCES]
This struct contains all needed data to parse and decode a BUFR file.
struct bufrdeco_subset_sequence_data seq
struct bufr_tables * tables
struct bufrdeco_expanded_tree * tree