34 printf (
"\nUsage: \n" );
35 printf (
"%s -i input_file [-i input] [-I list_of_files] [-t bufrtable_dir] [-o output] [-s] [-v][-j][-x][-X][-c][-h][more optional args....]\n",
SELF );
36 printf (
" -c. The output is in csv format\n" );
37 printf (
" -D debug level. 0 = No debug, 1 = Debug, 2 = Verbose debug (default = 0)\n" );
38 printf (
" -E. Print expanded tree in json format\n" );
39 printf (
" -G. Print latitude, logitude and altitude \n" );
40 printf (
" -g. Print WIGOS ID\n" );
41 printf (
" -h Print this help\n" );
42 printf (
" -i Input file. Complete input path file for bufr file\n" );
43 printf (
" -I list_of_files. Pathname of a file with the list of files to parse, one filename per line\n" );
44 printf (
" -j. The output is in json format\n" );
45 printf (
" -J. Output expanded subset SEC 4 data in json format\n");
46 printf (
" -n. Do not try to decode to TAC, just parse BUFR report\n" );
47 printf (
" -o output. Pathname of output file. Default is standar output\n" );
48 printf (
" -R. Read bit_offsets file if exists. The path of these files is to add '.offs' to the name of input BUFR file\n");
49 printf (
" -s prints a long output with explained sequence of descriptors\n" );
50 printf (
" -S first..last . Print only results for subsets in range first..last (First subset available is 0). Default is all subsets\n" );
51 printf (
" -t bufrtable_dir. Pathname of bufr tables directory. Ended with '/'\n" );
52 printf (
" -T. Use cache of tables to optimize execution time\n");
53 printf (
" -W. Write bit_offsets file. The path of these files is to add '.offs' to the name of input BUFR file\n");
54 printf (
" -V. Verbose output\n" );
55 printf (
" -v. Print version\n" );
56 printf (
" -x. The output is in xml format\n" );
57 printf (
" -X. Try to extract an embebed bufr in a file seraching for a first '7777' after first 'BUFR'\n" );
58 printf (
" -0. Prints BUFR Sec 0 information in json format\n");
59 printf (
" -1. Prints BUFR Sec 1 information in json format\n");
60 printf (
" -2. Prints BUFR Sec 2 information in json format\n");
61 printf (
" -3. Prints BUFR Sec 3 information in json format\n");
79char *
bufrtotac_get_version(
char *version,
size_t dversion,
char *build,
size_t dbuild,
char *builder,
size_t dbuilder,
80 int *version_major,
int *version_minor,
int *version_patch)
82 int major = 0, minor = 0, patch = 0;
87 snprintf(version, dversion,
"%s",
VERSION);
89 sscanf(version,
"%d.%d.%d", &major, &minor, &patch);
94#if defined(__INTEL_COMPILER)
95 used += snprintf(build + used, dbuild - used,
"using INTEL C compiler icc %d.%d ", __INTEL_COMPILER, __INTEL_COMPILER_UPDATE);
96#elif defined(__clang_version__)
97 used += snprintf(build + used, dbuild - used,
"using clang C compiler ", __clang_version__);
98#elif defined(__GNUC__)
99 used += snprintf(build + used, dbuild - used,
"using GNU C compiler gcc %d.%d.%d ", __GNUC__ , __GNUC_MINOR__ , __GNUC_PATCHLEVEL__);
100#elif defined(_MSC_VER)
101 used += snprintf(build + used, dbuild - used,
"using MICROSOFT C compiler %d ", _MSC_VER);
103 used += snprintf(build + used, dbuild - used,
"using an unknown C compiler ");
105 snprintf(build + used, dbuild - used,
"at %s %s",__DATE__,__TIME__);
109#ifdef BUILD_USING_CMAKE
110 strncpy(builder,
"cmake", dbuilder);
112 strncpy(builder,
"autotools", dbuilder);
115 *version_major = major;
117 *version_minor = minor;
119 *version_patch = patch;
126 char version[16], build[128], builder[32];
128 bufrtotac_get_version ( version,
sizeof (version), build,
sizeof (build), builder,
sizeof (builder), NULL, NULL, NULL );
129 printf (
"%s: Version '%s' built %s and %s.\n",
SELF,
VERSION, build, builder );
130 bufr2tac_get_version ( version,
sizeof (version), build,
sizeof (build), builder,
sizeof (builder), NULL, NULL, NULL );
131 printf (
"Linked to bufr2tac library version '%s' built %s and %s.\n", version, build, builder );
132 bufrdeco_get_version ( version,
sizeof (version), build,
sizeof (build), builder,
sizeof (builder), NULL, NULL, NULL );
133 printf (
"Linked to bufrdeco library version '%s' built %s and %s.\n", version, build, builder );
181 while ( ( iopt = getopt ( _argc, _argv,
"cD:Ehi:jJHI:no:S:st:TvgGVWRxX0123" ) ) !=-1 )
185 if ( strlen ( optarg ) < 256 )
205 if ( strlen ( optarg ) < 256 )
214 if ( strlen ( optarg ) < 256 )
219 if ( strlen ( optarg ) < 256 )
230 if ( strlen ( optarg ) < 2 )
232 DEBUG = atoi ( optarg );
248 exit ( EXIT_SUCCESS );
257 if ( strlen ( optarg ) < 128 &&
258 strspn ( optarg,
"0123456789." ) == strlen ( optarg ) )
260 if ( strstr ( optarg,
".." ) != NULL )
262 strcpy ( aux, optarg );
263 c = strstr ( aux,
".." );
264 if ( strlen ( c ) > 2 )
329 exit ( EXIT_SUCCESS );
334 printf (
"read_args(): It is needed an input file. Use -i or -I option\n" );
344 printf (
"%s(): Cannot open file %s to write to\n", __func__ ,
OUTPUTFILE);
365 if ( ( kdtlst = (
int * ) calloc ( 1, nlst *
sizeof (
int ) ) ) == NULL )
367 sprintf ( err,
"decobufr_parse_subset_sequence(): cannot alloc memory for kdtlst\n" );
372 for ( i = 0; i < nlst ; i++ )
396 free ( (
void * ) kdtlst );
441 if ( fgets ( aux, 256,
FL ) )
443 c = strrchr ( aux,
'\n' );
446 strcpy ( filename, aux );
int PRINT_JSON_EXPANDED_TREE
char * bufr2tac_get_version(char *version, size_t dversion, char *build, size_t dbuild, char *builder, size_t dbuilder, int *version_major, int *version_minor, int *version_patch)
int bufr2tac_set_debug_level(int level)
#define PRINT_BITMASK_WIGOS
Bit mask to member print_mask in struct metreport to print WIGOS Identifier.
int parse_subset_sequence(struct metreport *m, struct bufr_subset_sequence_data *sq, struct bufr2tac_subset_state *st, int *kdtlst, size_t nlst, int *ksec1, char *err)
Parse a sequence of expanded descriptors for a subset.
void bufr2tac_clean_metreport(struct metreport *m)
#define PRINT_BITMASK_GEO
Bit mask to member print_mask in struct metreport to print geographic position.
int descriptor_to_integer(int *id, struct bufr_descriptor *d)
parse a descriptor and sets an integer in the decimal formas fxxyyy
char * bufrdeco_get_version(char *version, size_t dversion, char *build, size_t dbuild, char *builder, size_t dbuilder, int *version_major, int *version_minor, int *version_patch)
#define bufrdeco_assert(__my_expr__)
Check a expression and exit if it fails.
#define BUFRDECO_OUTPUT_JSON_EXPANDED_TREE
Bit mask to the member mask of struct bufrdeco to print bufr expanded tree of descriptors.
#define BUFRDECO_OUTPUT_JSON_SUBSET_DATA
Bit mask to the member mask of struct bufrdeco to print bufr subset data in json format.
#define BUFRDECO_OUTPUT_JSON_SEC2
Bit mask to the member mask of struct bufrdeco to print bufr info for SEC 2 in json format.
#define BUFRDECO_OUTPUT_JSON_SEC3
Bit mask to the member mask of struct bufrdeco to print bufr info for SEC 3 in json format.
#define BUFRDECO_OUTPUT_JSON_SEC0
Bit mask to the member mask of struct bufrdeco to print info for SEC 0 in json format.
#define BUFRDECO_OUTPUT_HTML
Bit mask to the member mask for struct bufrdeco to format output as html for SECs 0 to 3.
#define BUFRDECO_OUTPUT_JSON_SEC1
Bit mask to the member mask of struct bufrdeco to print info for SEC 1 in json format.
#define BUFRDECO_PATH_LENGTH
Length for files/directory path strings.
#define BUFRDECO_USE_TABLES_CACHE
Bit mask to the member mask of struct bufrdeco to mark the use of bufr_tables cache.
char OFFSETFILE[BUFRDECO_PATH_LENGTH+8]
Include header file for binary bufrtotac.
int bufrtotac_parse_subset_sequence(struct metreport *m, struct bufr2tac_subset_state *st, struct bufrdeco *b, char *err)
void bufrtotac_print_version()
void bufrtotac_print_usage(void)
char * get_bufrfile_path(char *filename, char *fileoffset, char *err)
char * bufrtotac_get_version(char *version, size_t dversion, char *build, size_t dbuild, char *builder, size_t dbuilder, int *version_major, int *version_minor, int *version_patch)
int bufrtotac_set_bufrdeco_bitmask(struct bufrdeco *b)
Set the bufrdeco struct bitmask according with readed args from shell.
int bufrtotac_read_args(int _argc, char *_argv[])
stores information needed to parse a sequential list of expanded descriptors for a subset
uint8_t subcategory_local
struct bufr_descriptor unexpanded[BUFR_LEN_UNEXPANDED_DESCRIPTOR]
This struct contains all needed data to parse and decode a BUFR file.
struct bufrdeco_subset_sequence_data seq
all the information for a meteorological report in WMO text format from a BUFR file