added management of no handle in tools. Made the json valid when wrong messages and decoding errors.

This commit is contained in:
Enrico Fucile 2015-05-01 10:04:58 +01:00
parent 90c583542e
commit 9e798e2641
39 changed files with 231 additions and 6 deletions

View File

@ -1139,7 +1139,7 @@ static int decode_elements(grib_accessor* a) {
/* sval=grib_sarray_new(c,10,10); */
}
for (i=0;i<numberOfDescriptors;i++) {
grib_context_log(c, GRIB_LOG_DEBUG,"BUFR data decoding: elementNumber=%ld code=%ld", icount++,descriptors[i]->code);
grib_context_log(c, GRIB_LOG_DEBUG,"BUFR data decoding: elementNumber=%ld code=%6.6ld", icount++,descriptors[i]->code);
elementIndex=grib_iarray_used_size(elementsDescriptorsIndex);
switch(descriptors[i]->F) {
case 0:

View File

@ -1163,3 +1163,9 @@ static int compare_handles(grib_handle* h1,grib_handle* h2,grib_runtime_options*
}
return err;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -116,3 +116,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
fclose(options->outfile->file); */
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -44,6 +44,7 @@ char* grib_tool_name="bufr_dump";
char* grib_tool_usage="[options] file file ...";
static int json=0;
static char* json_option=0;
static int first_handle=1;
int grib_options_count=sizeof(grib_options)/sizeof(grib_option);
@ -118,7 +119,6 @@ int grib_tool_init(grib_runtime_options* options)
if (grib_options_on("d") && !grib_options_on("u"))
options->dump_flags |= GRIB_DUMP_FLAG_ALL_DATA;
if (json) fprintf(stdout,"{ \"messages\" : [ \n");
return 0;
}
@ -164,7 +164,10 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
if (json) {
if (options->handle_count>1) fprintf(stdout,",\n");
/* fprintf(stdout,"\"message%d\" : ",options->handle_count); */
if (json && first_handle) {
fprintf(stdout,"{ \"messages\" : [ \n");
first_handle=0;
}
switch (json_option[0]) {
case 'f':
err=grib_set_long(h,"unpack",2);
@ -229,3 +232,17 @@ int grib_tool_finalise_action(grib_runtime_options* options)
if (json) fprintf(stdout,"\n]}\n");
return 0;
}
int grib_no_handle_action(int err) {
if (json ){
if (first_handle) {
fprintf(dump_file,"{ \"messages\" : [ \n");
first_handle=0;
} else {
fprintf(dump_file,",\n");
}
}
fprintf(dump_file,"\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -112,3 +112,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
grib_file_pool_clean();
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -213,3 +213,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -147,3 +147,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
grib_index_delete(idx);
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -373,3 +373,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -167,3 +167,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -1079,3 +1079,9 @@ static int compare_handles(grib_handle* h1,grib_handle* h2,grib_runtime_options*
}
return err;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -202,3 +202,9 @@ void grib_tool_print_key_values(grib_runtime_options* options,grib_handle* h) {
int grib_tool_finalise_action(grib_runtime_options* options) {
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -128,3 +128,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
fclose(options->outfile->file); */
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -75,3 +75,9 @@ void grib_tool_print_key_values(grib_runtime_options* options,grib_handle* h) {
int grib_tool_finalise_action(grib_runtime_options* options) {
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -209,3 +209,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
{
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -113,3 +113,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
grib_file_pool_clean();
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -215,3 +215,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -278,3 +278,9 @@ static grib_values* get_key_values(grib_runtime_options* options,grib_handle* h)
return options->print_keys;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -149,3 +149,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
grib_index_delete(idx);
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -181,3 +181,9 @@ void grib_tool_print_key_values(grib_runtime_options* options,grib_handle* h) {
int grib_tool_finalise_action(grib_runtime_options* options) {
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -375,3 +375,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -326,3 +326,9 @@ int grib_tool_finalise_action(grib_runtime_options* options) {
}
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -191,3 +191,9 @@ int grib_tool_finalise_action(grib_runtime_options* options) {
}
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -168,3 +168,9 @@ int grib_tool_finalise_action(grib_runtime_options* options)
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -4180,3 +4180,5 @@ int main(int argc, char** argv)
exit(1);
}
#endif

View File

@ -228,8 +228,7 @@ static int grib_tool_with_orderby(grib_runtime_options* options)
options->error=err;
if (!h) {
fprintf(dump_file,"\t\t*** unable to read message ***\n");
if (options->fail || err==GRIB_WRONG_LENGTH) GRIB_CHECK_NOLINE(err,0);
grib_no_handle_action(err);
failed=(grib_failed*)grib_context_malloc_clear(c,sizeof(grib_failed));
failed->count=infile->handle_count;
@ -327,7 +326,8 @@ static int grib_tool_without_orderby(grib_runtime_options* options)
options->error=err;
if (!h) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
/* fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n"); */
grib_no_handle_action(err);
failed=(grib_failed*)grib_context_malloc_clear(c,sizeof(grib_failed));
failed->count=infile->handle_count;
@ -1038,3 +1038,4 @@ void grib_tools_write_message(grib_runtime_options* options, grib_handle* h)
#endif
}

View File

@ -194,6 +194,7 @@ int grib_get_runtime_options(int argc,char** argv,grib_runtime_options* options)
int grib_process_runtime_options(grib_context* c,int argc,char** argv,grib_runtime_options* options);
void grib_tools_write_message(grib_runtime_options* options, grib_handle* h);
int grib_tool_new_filename_action(grib_runtime_options* options,const char* file);
int grib_no_handle_action(int err);
#endif

View File

@ -120,3 +120,9 @@ int grib_tool_finalise_action(grib_runtime_options* options) {
*/
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -155,3 +155,9 @@ void grib_tool_print_key_values(grib_runtime_options* options,grib_handle* h) {
int grib_tool_finalise_action(grib_runtime_options* options) {
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -100,3 +100,9 @@ int grib_tool_finalise_action(grib_runtime_options* options) {
grib_file_pool_clean();
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -210,3 +210,9 @@ int grib_tool_finalise_action(grib_runtime_options* options) {
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -348,3 +348,9 @@ int grib_tool_finalise_action(grib_runtime_options* options) {
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -168,3 +168,9 @@ void grib_tool_print_key_values(grib_runtime_options* options,grib_handle* h) {
int grib_tool_finalise_action(grib_runtime_options* options) {
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -100,3 +100,9 @@ int grib_tool_finalise_action(grib_runtime_options* options) {
grib_file_pool_clean();
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -210,3 +210,9 @@ int grib_tool_finalise_action(grib_runtime_options* options) {
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -348,3 +348,9 @@ int grib_tool_finalise_action(grib_runtime_options* options) {
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -167,3 +167,9 @@ void grib_tool_print_key_values(grib_runtime_options* options,grib_handle* h) {
int grib_tool_finalise_action(grib_runtime_options* options) {
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -100,3 +100,9 @@ int grib_tool_finalise_action(grib_runtime_options* options) {
grib_file_pool_clean();
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -210,3 +210,9 @@ int grib_tool_finalise_action(grib_runtime_options* options) {
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}

View File

@ -348,3 +348,9 @@ int grib_tool_finalise_action(grib_runtime_options* options) {
return 0;
}
int grib_no_handle_action(int err) {
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}