mirror of https://github.com/ecmwf/eccodes.git
GRIB-663: Support for HDF5 headers. Part 1
This commit is contained in:
parent
68b2b343dc
commit
c10e4742dd
|
@ -273,3 +273,6 @@ python/gribapi_swig_wrap.c
|
|||
data/bufr/*diff
|
||||
data/bufr/*decode
|
||||
data/bufr/*test
|
||||
|
||||
*.sublime-workspace
|
||||
*.old
|
||||
|
|
|
@ -20,7 +20,7 @@ install( DIRECTORY budg bufr cdf common grib1 grib2 gts mars metar taf tide
|
|||
file( COPY ${definition_files} ${table_files}
|
||||
DESTINATION ${CMAKE_BINARY_DIR}/share/${PROJECT_NAME}/definitions )
|
||||
|
||||
file( COPY budg cdf common grib1 grib2 gts mars metar taf tide
|
||||
file( COPY budg cdf common grib1 grib2 gts mars metar taf tide hdf5 wrap
|
||||
DESTINATION ${CMAKE_BINARY_DIR}/share/${PROJECT_NAME}/definitions
|
||||
FILES_MATCHING
|
||||
PATTERN "*.def"
|
||||
|
|
|
@ -106,3 +106,15 @@ if(kindOfProduct == `TAF ` ){
|
|||
constant TAFstr="TAF";
|
||||
alias ls.identifier=TAFstr;
|
||||
}
|
||||
|
||||
if(kindOfProduct == 2303214662){
|
||||
template HDF5 "hdf5/boot.def" ;
|
||||
constant HDF5str="HDF5";
|
||||
alias ls.identifier=HDF5str;
|
||||
}
|
||||
|
||||
if(kindOfProduct == `WRAP`){
|
||||
template WRAP "wrap/boot.def" ;
|
||||
constant WRAPstr="WRAP";
|
||||
alias ls.identifier=WRAPstr;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
# http://www.hdfgroup.org/HDF5/doc/H5.format.html#Superblock
|
||||
constant identifier="HDF5";
|
||||
|
||||
|
||||
ascii[8] signature : dump;
|
||||
uint8 versionNumberOfSuperblock : dump;
|
||||
|
||||
if(versionNumberOfSuperblock == 2) {
|
||||
uint8 sizeOfOffsets : dump;
|
||||
uint8 sizeOfLength : dump;
|
||||
uint8 fileConsistencyFlags : dump;
|
||||
|
||||
if(sizeOfOffsets == 8) {
|
||||
uint64_little_endian baseAddress : dump;
|
||||
uint64_little_endian superblockExtensionAddress : dump;
|
||||
uint64_little_endian endOfFileAddress : dump;
|
||||
uint64_little_endian rootGroupObjectHeaderAddress : dump;
|
||||
}
|
||||
|
||||
if(sizeOfOffsets == 4) {
|
||||
uint32_little_endian baseAddress : dump;
|
||||
uint32_little_endian superblockExtensionAddress : dump;
|
||||
uint32_little_endian endOfFileAddress : dump;
|
||||
uint32_little_endian rootGroupObjectHeaderAddress : dump;
|
||||
}
|
||||
|
||||
#ascii[4] superblockChecksum;
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
# Copyright 2005-2014 ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
#
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
#
|
||||
|
||||
position startOfHeaders;
|
||||
ascii[4] identifier = `WRAP`: dump;
|
||||
alias ls.identifier=identifier;
|
||||
|
||||
uint64 totalLength : dump;
|
||||
uint8 version = 1 : dump;
|
||||
uint8 spare;
|
||||
|
||||
template metadata "wrap/metadata.[version].def";
|
||||
|
||||
position endOfHeadersMaker;
|
||||
|
||||
constant dataLength = (totalLength - endOfHeadersMaker - 4);
|
||||
blob data[dataLength] : dump;
|
||||
|
||||
ascii[4] endMark = `7777` : dump;
|
||||
|
||||
position totalLength;
|
|
@ -0,0 +1,2 @@
|
|||
# empty
|
||||
label 'empty';
|
|
@ -345,6 +345,21 @@ list( APPEND grib_api_srcs
|
|||
grib_yacc.h
|
||||
md5.h
|
||||
md5.c
|
||||
grib_accessor_class_int16.c
|
||||
grib_accessor_class_int16_little_endian.c
|
||||
grib_accessor_class_int32.c
|
||||
grib_accessor_class_int32_little_endian.c
|
||||
grib_accessor_class_int64.c
|
||||
grib_accessor_class_int64_little_endian.c
|
||||
grib_accessor_class_int8.c
|
||||
grib_accessor_class_uint16.c
|
||||
grib_accessor_class_uint16_little_endian.c
|
||||
grib_accessor_class_uint32.c
|
||||
grib_accessor_class_uint32_little_endian.c
|
||||
grib_accessor_class_uint64.c
|
||||
grib_accessor_class_uint64_little_endian.c
|
||||
grib_accessor_class_uint8.c
|
||||
grib_accessor_class_blob.c
|
||||
grib_windef.h
|
||||
)
|
||||
|
||||
|
|
|
@ -128,6 +128,21 @@ libgrib_api_la_prototypes= \
|
|||
grib_accessor_class_gen.c \
|
||||
grib_accessor_class_gts_header.c \
|
||||
grib_accessor_class_ifs_param.c \
|
||||
grib_accessor_class_int16.c \
|
||||
grib_accessor_class_int16_little_endian.c \
|
||||
grib_accessor_class_int32.c \
|
||||
grib_accessor_class_int32_little_endian.c \
|
||||
grib_accessor_class_int64.c \
|
||||
grib_accessor_class_int64_little_endian.c \
|
||||
grib_accessor_class_int8.c \
|
||||
grib_accessor_class_uint16.c \
|
||||
grib_accessor_class_uint16_little_endian.c \
|
||||
grib_accessor_class_uint32.c \
|
||||
grib_accessor_class_uint32_little_endian.c \
|
||||
grib_accessor_class_uint64.c \
|
||||
grib_accessor_class_uint64_little_endian.c \
|
||||
grib_accessor_class_uint8.c \
|
||||
grib_accessor_class_blob.c \
|
||||
grib_accessor_class_julian_day.c \
|
||||
grib_accessor_class_latlonvalues.c \
|
||||
grib_accessor_class_latitudes.c \
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# To rebuild the grammar:
|
||||
|
||||
make LEX_OUTPUT_ROOT=lex.yy -f extrules.am grib_yacc.c grib_yacc.h grib_lex.c
|
|
@ -9,6 +9,7 @@ extern grib_accessor_class* grib_accessor_class_bit;
|
|||
extern grib_accessor_class* grib_accessor_class_bitmap;
|
||||
extern grib_accessor_class* grib_accessor_class_bits;
|
||||
extern grib_accessor_class* grib_accessor_class_bits_per_value;
|
||||
extern grib_accessor_class* grib_accessor_class_blob;
|
||||
extern grib_accessor_class* grib_accessor_class_box;
|
||||
extern grib_accessor_class* grib_accessor_class_budgdate;
|
||||
extern grib_accessor_class* grib_accessor_class_bufr_data;
|
||||
|
@ -119,6 +120,13 @@ extern grib_accessor_class* grib_accessor_class_headers_only;
|
|||
extern grib_accessor_class* grib_accessor_class_ibmfloat;
|
||||
extern grib_accessor_class* grib_accessor_class_ieeefloat;
|
||||
extern grib_accessor_class* grib_accessor_class_ifs_param;
|
||||
extern grib_accessor_class* grib_accessor_class_int16;
|
||||
extern grib_accessor_class* grib_accessor_class_int16_little_endian;
|
||||
extern grib_accessor_class* grib_accessor_class_int32;
|
||||
extern grib_accessor_class* grib_accessor_class_int32_little_endian;
|
||||
extern grib_accessor_class* grib_accessor_class_int64;
|
||||
extern grib_accessor_class* grib_accessor_class_int64_little_endian;
|
||||
extern grib_accessor_class* grib_accessor_class_int8;
|
||||
extern grib_accessor_class* grib_accessor_class_iterator;
|
||||
extern grib_accessor_class* grib_accessor_class_julian_day;
|
||||
extern grib_accessor_class* grib_accessor_class_ksec1expver;
|
||||
|
@ -186,6 +194,13 @@ extern grib_accessor_class* grib_accessor_class_to_double;
|
|||
extern grib_accessor_class* grib_accessor_class_to_integer;
|
||||
extern grib_accessor_class* grib_accessor_class_to_string;
|
||||
extern grib_accessor_class* grib_accessor_class_transient;
|
||||
extern grib_accessor_class* grib_accessor_class_uint16;
|
||||
extern grib_accessor_class* grib_accessor_class_uint16_little_endian;
|
||||
extern grib_accessor_class* grib_accessor_class_uint32;
|
||||
extern grib_accessor_class* grib_accessor_class_uint32_little_endian;
|
||||
extern grib_accessor_class* grib_accessor_class_uint64;
|
||||
extern grib_accessor_class* grib_accessor_class_uint64_little_endian;
|
||||
extern grib_accessor_class* grib_accessor_class_uint8;
|
||||
extern grib_accessor_class* grib_accessor_class_unexpanded_descriptors;
|
||||
extern grib_accessor_class* grib_accessor_class_unpack_bufr_values;
|
||||
extern grib_accessor_class* grib_accessor_class_unsigned;
|
||||
|
|
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = get_native_type;init
|
||||
IMPLEMENTS = unpack_bytes;dump
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int get_native_type(grib_accessor*);
|
||||
static int unpack_bytes (grib_accessor*,unsigned char*, size_t *len);
|
||||
static void dump(grib_accessor*, grib_dumper*);
|
||||
static void init(grib_accessor*,const long, grib_arguments* );
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_blob {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in blob */
|
||||
} grib_accessor_blob;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_blob = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"blob", /* name */
|
||||
sizeof(grib_accessor_blob), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
&init, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
&dump, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
&get_native_type, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
&unpack_bytes, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_blob = &_grib_accessor_class_blob;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_long = (*(c->super))->pack_long;
|
||||
c->unpack_long = (*(c->super))->unpack_long;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static void init(grib_accessor* a, const long len , grib_arguments* arg )
|
||||
{
|
||||
grib_get_long_internal(a->parent->h, grib_arguments_get_name(a->parent->h, arg, 0), &a->length);
|
||||
Assert(a->length>=0);
|
||||
|
||||
}
|
||||
|
||||
static int get_native_type(grib_accessor* a){
|
||||
return GRIB_TYPE_BYTES;
|
||||
}
|
||||
|
||||
static int unpack_bytes (grib_accessor* a,unsigned char* buffer, size_t *len) {
|
||||
if (*len < a->length) {
|
||||
*len = a->length;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
*len = a->length;
|
||||
|
||||
memcpy(buffer, a->parent->h->buffer->data + a->offset, *len);
|
||||
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
static void dump(grib_accessor* a, grib_dumper* dumper)
|
||||
{
|
||||
grib_dump_bytes(dumper,a,NULL);
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_int16 {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in int16 */
|
||||
} grib_accessor_int16;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_int16 = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"int16", /* name */
|
||||
sizeof(grib_accessor_int16), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_int16 = &_grib_accessor_class_int16;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_int16_little_endian {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in int16_little_endian */
|
||||
} grib_accessor_int16_little_endian;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_int16_little_endian = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"int16_little_endian", /* name */
|
||||
sizeof(grib_accessor_int16_little_endian), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_int16_little_endian = &_grib_accessor_class_int16_little_endian;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_int32 {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in int32 */
|
||||
} grib_accessor_int32;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_int32 = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"int32", /* name */
|
||||
sizeof(grib_accessor_int32), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_int32 = &_grib_accessor_class_int32;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_int32_little_endian {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in int32_little_endian */
|
||||
} grib_accessor_int32_little_endian;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_int32_little_endian = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"int32_little_endian", /* name */
|
||||
sizeof(grib_accessor_int32_little_endian), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_int32_little_endian = &_grib_accessor_class_int32_little_endian;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_int64 {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in int64 */
|
||||
} grib_accessor_int64;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_int64 = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"int64", /* name */
|
||||
sizeof(grib_accessor_int64), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_int64 = &_grib_accessor_class_int64;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
unsigned long long result = 0, tmp;
|
||||
int i;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
for(i = 0 ; i < 8; i ++) {
|
||||
result <<= 8;
|
||||
result |= data[pos + i];
|
||||
}
|
||||
|
||||
value = result;
|
||||
tmp = value;
|
||||
|
||||
/* Result does not fit in long */
|
||||
if(tmp != result) {
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name , result );
|
||||
return GRIB_DECODING_ERROR;
|
||||
}
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_int64_little_endian {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in int64_little_endian */
|
||||
} grib_accessor_int64_little_endian;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_int64_little_endian = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"int64_little_endian", /* name */
|
||||
sizeof(grib_accessor_int64_little_endian), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_int64_little_endian = &_grib_accessor_class_int64_little_endian;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
unsigned long long result = 0, tmp;
|
||||
int i;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
for(i = 7 ; i >= 0; i --) {
|
||||
result <<= 8;
|
||||
result |= data[pos + i];
|
||||
}
|
||||
|
||||
value = result;
|
||||
tmp = value;
|
||||
|
||||
/* Result does not fit in long */
|
||||
if(tmp != result) {
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name , result );
|
||||
return GRIB_DECODING_ERROR;
|
||||
}
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_int8 {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in int8 */
|
||||
} grib_accessor_int8;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_int8 = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"int8", /* name */
|
||||
sizeof(grib_accessor_int8), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_int8 = &_grib_accessor_class_int8;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
char* data = (char*)a->parent->h->buffer->data;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
value = data[pos];
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_uint16 {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in uint16 */
|
||||
} grib_accessor_uint16;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_uint16 = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"uint16", /* name */
|
||||
sizeof(grib_accessor_uint16), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_uint16 = &_grib_accessor_class_uint16;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_uint16_little_endian {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in uint16_little_endian */
|
||||
} grib_accessor_uint16_little_endian;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_uint16_little_endian = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"uint16_little_endian", /* name */
|
||||
sizeof(grib_accessor_uint16_little_endian), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_uint16_little_endian = &_grib_accessor_class_uint16_little_endian;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_uint32 {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in uint32 */
|
||||
} grib_accessor_uint32;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_uint32 = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"uint32", /* name */
|
||||
sizeof(grib_accessor_uint32), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_uint32 = &_grib_accessor_class_uint32;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_uint32_little_endian {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in uint32_little_endian */
|
||||
} grib_accessor_uint32_little_endian;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_uint32_little_endian = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"uint32_little_endian", /* name */
|
||||
sizeof(grib_accessor_uint32_little_endian), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_uint32_little_endian = &_grib_accessor_class_uint32_little_endian;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
IMPLEMENTS = get_native_type
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int get_native_type(grib_accessor*);
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_uint64 {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in uint64 */
|
||||
} grib_accessor_uint64;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_uint64 = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"uint64", /* name */
|
||||
sizeof(grib_accessor_uint64), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
&get_native_type, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_uint64 = &_grib_accessor_class_uint64;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
unsigned long long result = 0, tmp;
|
||||
int i;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
for(i = 0 ; i < 8; i ++) {
|
||||
result <<= 8;
|
||||
result |= data[pos + i];
|
||||
}
|
||||
|
||||
value = result;
|
||||
tmp = value;
|
||||
|
||||
/* Result does not fit in long */
|
||||
if(tmp != result) {
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name , result );
|
||||
return GRIB_DECODING_ERROR;
|
||||
}
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int get_native_type(grib_accessor* a) {
|
||||
return GRIB_TYPE_LONG;
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_uint64_little_endian {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in uint64_little_endian */
|
||||
} grib_accessor_uint64_little_endian;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_uint64_little_endian = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"uint64_little_endian", /* name */
|
||||
sizeof(grib_accessor_uint64_little_endian), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_uint64_little_endian = &_grib_accessor_class_uint64_little_endian;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
unsigned long long result = 0, tmp;
|
||||
int i;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
for(i = 7 ; i >= 0; i --) {
|
||||
result <<= 8;
|
||||
result |= data[pos + i];
|
||||
}
|
||||
|
||||
value = result;
|
||||
tmp = value;
|
||||
|
||||
/* Result does not fit in long */
|
||||
if(tmp != result) {
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name , result );
|
||||
return GRIB_DECODING_ERROR;
|
||||
}
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* Copyright 2005-2014 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = accessor
|
||||
SUPER = grib_accessor_class_gen
|
||||
IMPLEMENTS = unpack_long
|
||||
IMPLEMENTS = pack_long
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "accessor.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static int pack_long(grib_accessor*, const long* val,size_t *len);
|
||||
static int unpack_long(grib_accessor*, long* val,size_t *len);
|
||||
static void init_class(grib_accessor_class*);
|
||||
|
||||
typedef struct grib_accessor_uint8 {
|
||||
grib_accessor att;
|
||||
/* Members defined in gen */
|
||||
/* Members defined in uint8 */
|
||||
} grib_accessor_uint8;
|
||||
|
||||
extern grib_accessor_class* grib_accessor_class_gen;
|
||||
|
||||
static grib_accessor_class _grib_accessor_class_uint8 = {
|
||||
&grib_accessor_class_gen, /* super */
|
||||
"uint8", /* name */
|
||||
sizeof(grib_accessor_uint8), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
0, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
0, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
0, /* get number of values */
|
||||
0, /* get number of bytes */
|
||||
0, /* get offset to bytes */
|
||||
0, /* get native type */
|
||||
0, /* get sub_section */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
&pack_long, /* grib_pack procedures long */
|
||||
&unpack_long, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_unpack procedures double */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack procedures bytes */
|
||||
0, /* grib_unpack procedures bytes */
|
||||
0, /* pack_expression */
|
||||
0, /* notify_change */
|
||||
0, /* update_size */
|
||||
0, /* preferred_size */
|
||||
0, /* resize */
|
||||
0, /* nearest_smaller_value */
|
||||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
};
|
||||
|
||||
|
||||
grib_accessor_class* grib_accessor_class_uint8 = &_grib_accessor_class_uint8;
|
||||
|
||||
|
||||
static void init_class(grib_accessor_class* c)
|
||||
{
|
||||
c->dump = (*(c->super))->dump;
|
||||
c->next_offset = (*(c->super))->next_offset;
|
||||
c->string_length = (*(c->super))->string_length;
|
||||
c->value_count = (*(c->super))->value_count;
|
||||
c->byte_count = (*(c->super))->byte_count;
|
||||
c->byte_offset = (*(c->super))->byte_offset;
|
||||
c->get_native_type = (*(c->super))->get_native_type;
|
||||
c->sub_section = (*(c->super))->sub_section;
|
||||
c->pack_missing = (*(c->super))->pack_missing;
|
||||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->unpack_double = (*(c->super))->unpack_double;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_bytes = (*(c->super))->pack_bytes;
|
||||
c->unpack_bytes = (*(c->super))->unpack_bytes;
|
||||
c->pack_expression = (*(c->super))->pack_expression;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->update_size = (*(c->super))->update_size;
|
||||
c->preferred_size = (*(c->super))->preferred_size;
|
||||
c->resize = (*(c->super))->resize;
|
||||
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
|
||||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
}
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
{
|
||||
long value = 0;
|
||||
long pos = a->offset;
|
||||
unsigned char* data = a->parent->h->buffer->data;
|
||||
|
||||
if(*len < 1)
|
||||
{
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
|
||||
*len = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
value = data[pos];
|
||||
|
||||
*val = value;
|
||||
*len = 1;
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len) {
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
{ "bitmap", &grib_accessor_class_bitmap, },
|
||||
{ "bits", &grib_accessor_class_bits, },
|
||||
{ "bits_per_value", &grib_accessor_class_bits_per_value, },
|
||||
{ "blob", &grib_accessor_class_blob, },
|
||||
{ "box", &grib_accessor_class_box, },
|
||||
{ "budgdate", &grib_accessor_class_budgdate, },
|
||||
{ "bufr_data", &grib_accessor_class_bufr_data, },
|
||||
|
@ -118,6 +119,13 @@
|
|||
{ "ibmfloat", &grib_accessor_class_ibmfloat, },
|
||||
{ "ieeefloat", &grib_accessor_class_ieeefloat, },
|
||||
{ "ifs_param", &grib_accessor_class_ifs_param, },
|
||||
{ "int16", &grib_accessor_class_int16, },
|
||||
{ "int16_little_endian", &grib_accessor_class_int16_little_endian, },
|
||||
{ "int32", &grib_accessor_class_int32, },
|
||||
{ "int32_little_endian", &grib_accessor_class_int32_little_endian, },
|
||||
{ "int64", &grib_accessor_class_int64, },
|
||||
{ "int64_little_endian", &grib_accessor_class_int64_little_endian, },
|
||||
{ "int8", &grib_accessor_class_int8, },
|
||||
{ "iterator", &grib_accessor_class_iterator, },
|
||||
{ "julian_day", &grib_accessor_class_julian_day, },
|
||||
{ "ksec1expver", &grib_accessor_class_ksec1expver, },
|
||||
|
@ -185,6 +193,13 @@
|
|||
{ "to_integer", &grib_accessor_class_to_integer, },
|
||||
{ "to_string", &grib_accessor_class_to_string, },
|
||||
{ "transient", &grib_accessor_class_transient, },
|
||||
{ "uint16", &grib_accessor_class_uint16, },
|
||||
{ "uint16_little_endian", &grib_accessor_class_uint16_little_endian, },
|
||||
{ "uint32", &grib_accessor_class_uint32, },
|
||||
{ "uint32_little_endian", &grib_accessor_class_uint32_little_endian, },
|
||||
{ "uint64", &grib_accessor_class_uint64, },
|
||||
{ "uint64_little_endian", &grib_accessor_class_uint64_little_endian, },
|
||||
{ "uint8", &grib_accessor_class_uint8, },
|
||||
{ "unexpanded_descriptors", &grib_accessor_class_unexpanded_descriptors, },
|
||||
{ "unpack_bufr_values", &grib_accessor_class_unpack_bufr_values, },
|
||||
{ "unsigned", &grib_accessor_class_unsigned, },
|
||||
|
|
|
@ -9,6 +9,7 @@ bit, &grib_accessor_class_bit
|
|||
bitmap, &grib_accessor_class_bitmap
|
||||
bits, &grib_accessor_class_bits
|
||||
bits_per_value, &grib_accessor_class_bits_per_value
|
||||
blob, &grib_accessor_class_blob
|
||||
box, &grib_accessor_class_box
|
||||
budgdate, &grib_accessor_class_budgdate
|
||||
bufr_data, &grib_accessor_class_bufr_data
|
||||
|
@ -123,6 +124,13 @@ headers_only, &grib_accessor_class_headers_only
|
|||
ibmfloat, &grib_accessor_class_ibmfloat
|
||||
ieeefloat, &grib_accessor_class_ieeefloat
|
||||
ifs_param, &grib_accessor_class_ifs_param
|
||||
int16, &grib_accessor_class_int16
|
||||
int16_little_endian, &grib_accessor_class_int16_little_endian
|
||||
int32, &grib_accessor_class_int32
|
||||
int32_little_endian, &grib_accessor_class_int32_little_endian
|
||||
int64, &grib_accessor_class_int64
|
||||
int64_little_endian, &grib_accessor_class_int64_little_endian
|
||||
int8, &grib_accessor_class_int8
|
||||
iterator, &grib_accessor_class_iterator
|
||||
julian_day, &grib_accessor_class_julian_day
|
||||
ksec1expver, &grib_accessor_class_ksec1expver
|
||||
|
@ -191,6 +199,13 @@ to_double, &grib_accessor_class_to_double
|
|||
to_integer, &grib_accessor_class_to_integer
|
||||
to_string, &grib_accessor_class_to_string
|
||||
transient, &grib_accessor_class_transient
|
||||
uint16, &grib_accessor_class_uint16
|
||||
uint16_little_endian, &grib_accessor_class_uint16_little_endian
|
||||
uint32, &grib_accessor_class_uint32
|
||||
uint32_little_endian, &grib_accessor_class_uint32_little_endian
|
||||
uint64, &grib_accessor_class_uint64
|
||||
uint64_little_endian, &grib_accessor_class_uint64_little_endian
|
||||
uint8, &grib_accessor_class_uint8
|
||||
unexpanded_descriptors, &grib_accessor_class_unexpanded_descriptors
|
||||
unpack_bufr_values, &grib_accessor_class_unpack_bufr_values
|
||||
unsigned, &grib_accessor_class_unsigned
|
||||
|
|
|
@ -933,6 +933,7 @@ grib_handle *taf_new_from_file(grib_context *c, FILE *f, int headers_only, int *
|
|||
grib_handle *metar_new_from_file(grib_context *c, FILE *f, int headers_only, int *error);
|
||||
grib_handle *codes_new_from_file(grib_context *c, FILE *f, int headers_only, int *error);
|
||||
grib_handle *bufr_new_from_file(grib_context *c, FILE *f, int headers_only, int *error);
|
||||
grib_handle *any_new_from_file(grib_context *c, FILE *f, int headers_only, int *error);
|
||||
grib_multi_handle *grib_multi_handle_new(grib_context *c);
|
||||
int grib_multi_handle_delete(grib_multi_handle *h);
|
||||
int grib_multi_handle_append(grib_handle *h, int start_section, grib_multi_handle *mh);
|
||||
|
|
|
@ -265,7 +265,7 @@ static void dump_bytes(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
err = grib_unpack_bytes(a,buf,&size);
|
||||
if(err){
|
||||
grib_context_free(d->handle->context,buf);
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) \n}",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_c_code::dump_bytes]\n}",err,grib_get_error_message(err));
|
||||
return ;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ static void dump_long(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
fprintf(self->dumper.out,"%ld-%ld %s %s = %ld",self->begin,self->theEnd,a->creator->op, a->name,value);
|
||||
if(comment) fprintf(self->dumper.out," [%s]",comment);
|
||||
if(err)
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_debug::dump_long]",err,grib_get_error_message(err));
|
||||
|
||||
aliases(d,a);
|
||||
|
||||
|
@ -189,7 +189,7 @@ static void dump_bits(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
fprintf(self->dumper.out,"]");
|
||||
|
||||
if(err)
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_debug::dump_bits]",err,grib_get_error_message(err));
|
||||
|
||||
aliases(d,a);
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
@ -216,7 +216,7 @@ static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
fprintf(self->dumper.out,"%ld-%ld %s %s = %g",self->begin,self->theEnd,a->creator->op, a->name,value);
|
||||
if(comment) fprintf(self->dumper.out," [%s]",comment);
|
||||
if(err)
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_debug::dump_double]",err,grib_get_error_message(err));
|
||||
aliases(d,a);
|
||||
fprintf(self->dumper.out,"\n");
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
|
||||
if(comment) fprintf(self->dumper.out," [%s]",comment);
|
||||
if(err)
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_debug::dump_string]",err,grib_get_error_message(err));
|
||||
aliases(d,a);
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
||||
|
@ -296,7 +296,7 @@ static void dump_bytes(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
err = grib_unpack_bytes(a,buf,&size);
|
||||
if(err){
|
||||
grib_context_free(d->handle->context,buf);
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) \n}",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_debug::dump_bytes]\n}",err,grib_get_error_message(err));
|
||||
return ;
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
|
|||
|
||||
if(err){
|
||||
grib_context_free(d->handle->context,buf);
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) \n}",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_debug::dump_values]\n}",err,grib_get_error_message(err));
|
||||
return ;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ static void dump_long(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
|
||||
if(err) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s) [grib_dumper_default::dump_long]",err,grib_get_error_message(err));
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
@ -271,7 +271,7 @@ static void dump_bits(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
|
||||
if(err) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s) [grib_dumper_default::dump_bits]",err,grib_get_error_message(err));
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
@ -315,7 +315,7 @@ static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
|
||||
if(err) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s) [grib_dumper_default::dump_double]",err,grib_get_error_message(err));
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
@ -441,7 +441,7 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
|
||||
if(err) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s) [grib_dumper_default::dump_string]",err,grib_get_error_message(err));
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
@ -488,7 +488,7 @@ static void dump_bytes(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
err = grib_unpack_bytes(a,buf,&size);
|
||||
if(err){
|
||||
grib_context_free(d->handle->context,buf);
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) \n}",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_default::dump_bytes]\n}",err,grib_get_error_message(err));
|
||||
return ;
|
||||
}
|
||||
|
||||
|
@ -578,7 +578,7 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
|
|||
|
||||
if(err){
|
||||
grib_context_free(d->handle->context,buf);
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) \n}",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_default::dump_values]\n}",err,grib_get_error_message(err));
|
||||
return ;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ static void dump_long(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
if(comment) fprintf(self->dumper.out," [%s]",comment);
|
||||
#endif
|
||||
if(err)
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_serialize::dump_long]",err,grib_get_error_message(err));
|
||||
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
||||
|
@ -195,7 +195,7 @@ static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
if(comment) fprintf(self->dumper.out," [%s]",comment);
|
||||
#endif
|
||||
if(err)
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_serialize::dump_double]",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
if(comment) fprintf(self->dumper.out," [%s]",comment);
|
||||
#endif
|
||||
if(err)
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_serialize::dump_string]",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ static void dump_bytes(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
err = grib_unpack_bytes(a,buf,&size);
|
||||
if(err){
|
||||
grib_context_free(d->handle->context,buf);
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) \n}",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_serialize::dump_bytes]\n}",err,grib_get_error_message(err));
|
||||
return ;
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
|
|||
|
||||
if(err){
|
||||
grib_context_free(d->handle->context,buf);
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) \n}",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_serialize::dump_values]\n}",err,grib_get_error_message(err));
|
||||
return ;
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ static void dump_long(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
if(comment) fprintf(self->dumper.out," [%s]",comment);
|
||||
}
|
||||
if(err)
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_wmo::dump_long]",err,grib_get_error_message(err));
|
||||
|
||||
aliases(d,a);
|
||||
|
||||
|
@ -240,7 +240,7 @@ static void dump_bits(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
if (err==0) print_hexadecimal(self->dumper.out,d->option_flags,a);
|
||||
|
||||
if(err)
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_wmo::dump_bits]",err,grib_get_error_message(err));
|
||||
|
||||
aliases(d,a);
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
@ -274,7 +274,7 @@ static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
if (err==0) print_hexadecimal(self->dumper.out,d->option_flags,a);
|
||||
|
||||
if(err)
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_wmo::dump_double]",err,grib_get_error_message(err));
|
||||
aliases(d,a);
|
||||
fprintf(self->dumper.out,"\n");
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
|
||||
/*if(comment) fprintf(self->dumper.out," [%s]",comment);*/
|
||||
if(err)
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_wmo::dump_string]",err,grib_get_error_message(err));
|
||||
aliases(d,a);
|
||||
fprintf(self->dumper.out,"\n");
|
||||
if (value) grib_context_free(a->parent->h->context,value);
|
||||
|
@ -361,7 +361,7 @@ static void dump_bytes(grib_dumper* d,grib_accessor* a,const char* comment)
|
|||
err = grib_unpack_bytes(a,buf,&size);
|
||||
if(err){
|
||||
grib_context_free(d->handle->context,buf);
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) \n}",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_wmo::dump_bytes]\n}",err,grib_get_error_message(err));
|
||||
return ;
|
||||
}
|
||||
|
||||
|
@ -444,7 +444,7 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
|
|||
|
||||
if(err){
|
||||
grib_context_free(d->handle->context,buf);
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) \n}",err,grib_get_error_message(err));
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_wmo::dump_values]\n}",err,grib_get_error_message(err));
|
||||
return ;
|
||||
}
|
||||
|
||||
|
|
|
@ -928,6 +928,48 @@ grib_handle* bufr_new_from_file ( grib_context* c, FILE* f,int headers_only,int
|
|||
return gl;
|
||||
}
|
||||
|
||||
grib_handle* any_new_from_file ( grib_context* c, FILE* f,int headers_only,int *error )
|
||||
{
|
||||
void *data = NULL;
|
||||
size_t olen = 0;
|
||||
grib_handle *gl = NULL;
|
||||
off_t offset=0;
|
||||
|
||||
if ( c == NULL ) c = grib_context_get_default();
|
||||
|
||||
data = wmo_read_any_from_file_malloc ( f, headers_only,&olen,&offset,error );
|
||||
|
||||
if ( *error != GRIB_SUCCESS )
|
||||
{
|
||||
if ( data ) grib_context_free ( c,data );
|
||||
|
||||
if ( *error == GRIB_END_OF_FILE ) *error = GRIB_SUCCESS;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (headers_only) {
|
||||
gl = grib_handle_new_from_partial_message ( c, data, olen );
|
||||
} else {
|
||||
gl = grib_handle_new_from_message ( c, data, olen );
|
||||
}
|
||||
|
||||
if ( !gl )
|
||||
{
|
||||
*error = GRIB_DECODING_ERROR;
|
||||
grib_context_log ( c, GRIB_LOG_ERROR, "grib_handle_new_from_file : cannot create handle \n" );
|
||||
grib_context_free ( c,data );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gl->offset=offset;
|
||||
gl->buffer->property = GRIB_MY_BUFFER;
|
||||
c->handle_file_count++;
|
||||
c->handle_total_count++;
|
||||
|
||||
return gl;
|
||||
}
|
||||
|
||||
|
||||
static grib_handle* grib_handle_new_from_file_no_multi ( grib_context* c,FILE* f,int headers_only,int *error )
|
||||
{
|
||||
void *data = NULL;
|
||||
|
|
207
src/grib_io.c
207
src/grib_io.c
|
@ -16,8 +16,13 @@
|
|||
#define DIAG 0x44494147
|
||||
#define TIDE 0x54494445
|
||||
#define BUFR 0x42554652
|
||||
#define HDF5 0x89484446
|
||||
#define WRAP 0x57524150
|
||||
|
||||
#define GRIB_API_READS_BUFR 1
|
||||
#define GRIB_API_READS_HDF5 1
|
||||
#define GRIB_API_READS_WRAP 1
|
||||
|
||||
|
||||
typedef struct alloc_buffer {
|
||||
size_t size;
|
||||
|
@ -46,7 +51,7 @@ typedef struct reader {
|
|||
|
||||
} reader;
|
||||
|
||||
static int read_the_rest(reader* r,size_t message_length,unsigned char* tmp, int already_read)
|
||||
static int read_the_rest(reader* r,size_t message_length,unsigned char* tmp, int already_read, int check7777)
|
||||
{
|
||||
int err = 0;
|
||||
size_t buffer_size;
|
||||
|
@ -65,7 +70,7 @@ static int read_the_rest(reader* r,size_t message_length,unsigned char* tmp, int
|
|||
if((r->read(r->read_data,buffer+already_read,rest,&err) != rest) || err)
|
||||
return err;
|
||||
|
||||
if(!r->headers_only && (buffer[message_length-4] != '7' ||
|
||||
if(check7777 && !r->headers_only && (buffer[message_length-4] != '7' ||
|
||||
buffer[message_length-3] != '7' ||
|
||||
buffer[message_length-2] != '7' ||
|
||||
buffer[message_length-1] != '7')) {
|
||||
|
@ -361,7 +366,7 @@ static int read_GRIB(reader* r)
|
|||
}
|
||||
|
||||
/* Assert(i <= buf->length); */
|
||||
err=read_the_rest(r,length,tmp,i);
|
||||
err=read_the_rest(r, length, tmp, i, 1);
|
||||
|
||||
grib_buffer_delete(c,buf);
|
||||
|
||||
|
@ -415,7 +420,150 @@ static int read_PSEUDO(reader *r,const char* type)
|
|||
/* fprintf(stderr,"%s sec4len=%d i=%d l=%d\n",type,sec4len,i,4+sec1len+sec4len+4); */
|
||||
|
||||
Assert(i <= sizeof(tmp));
|
||||
return read_the_rest(r,4+sec1len+sec4len+4,tmp,i);
|
||||
return read_the_rest(r,4+sec1len+sec4len+4,tmp,i, 1);
|
||||
}
|
||||
|
||||
|
||||
static int read_HDF5_offset(reader *r, int length, unsigned long* v, unsigned char *tmp, int* i) {
|
||||
unsigned char buf[8];
|
||||
int j, k;
|
||||
int err = 0;
|
||||
|
||||
|
||||
if( (r->read(r->read_data, buf, length, &err) != length) || err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
k = *i;
|
||||
for(j = 0; j < length; j++) {
|
||||
tmp[k++] = buf[j];
|
||||
}
|
||||
*i = k;
|
||||
|
||||
*v = 0;
|
||||
for(j = length-1; j >= 0; j--) {
|
||||
*v <<= 8;
|
||||
*v |= buf[j];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_HDF5(reader *r)
|
||||
{
|
||||
/* See: http://www.hdfgroup.org/HDF5/doc/H5.format.html#Superblock */
|
||||
unsigned char tmp[36]; /* Should be enough */
|
||||
unsigned char buf[4];
|
||||
|
||||
unsigned char version_of_superblock, size_of_offsets, size_of_lengths, consistency_flags;
|
||||
unsigned long base_address, superblock_extension_address, end_of_file_address;
|
||||
|
||||
int i = 0, j;
|
||||
int err = 0;
|
||||
grib_context* c = grib_context_get_default();
|
||||
|
||||
tmp[i++] = 137;
|
||||
tmp[i++] = 'H';
|
||||
tmp[i++] = 'D';
|
||||
tmp[i++] = 'F';
|
||||
|
||||
if( (r->read(r->read_data, buf, 4, &err) != 4) || err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if( !(buf[0] == '\r' && buf[1] == '\n' && buf[2] == 26 && buf[3] == '\n')) {
|
||||
/* Invalid magic, we should not use grib_context_log without a context */
|
||||
grib_context_log(c, GRIB_LOG_ERROR,"read_HDF5: invalid signature");
|
||||
return GRIB_INVALID_MESSAGE;
|
||||
}
|
||||
|
||||
for(j = 0; j < 4; j++) {
|
||||
tmp[i++] = buf[j];
|
||||
}
|
||||
|
||||
if( (r->read(r->read_data, &version_of_superblock, 1, &err) != 1) || err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
tmp[i++] = version_of_superblock;
|
||||
|
||||
if(version_of_superblock != 2) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR,"read_HDF5: invalid version_of_superblock: %ld, only version 2 is supported", (long)version_of_superblock);
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if( (r->read(r->read_data, &size_of_offsets, 1, &err) != 1) || err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
tmp[i++] = size_of_offsets;
|
||||
|
||||
|
||||
if(size_of_offsets > 8) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR,"read_HDF5: invalid size_of_offsets: %ld, only <= 8 is supported", (long)size_of_offsets);
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if( (r->read(r->read_data, &size_of_lengths, 1, &err) != 1) || err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
tmp[i++] = size_of_lengths;
|
||||
|
||||
if( (r->read(r->read_data, &consistency_flags, 1, &err) != 1) || err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
tmp[i++] = consistency_flags;
|
||||
|
||||
err = read_HDF5_offset(r, size_of_offsets, &base_address, tmp, &i);
|
||||
if(err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = read_HDF5_offset(r, size_of_offsets, &superblock_extension_address, tmp, &i);
|
||||
if(err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = read_HDF5_offset(r, size_of_offsets, &end_of_file_address, tmp, &i);
|
||||
if(err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Assert(i <= sizeof(tmp));
|
||||
return read_the_rest(r, end_of_file_address, tmp, i, 0);
|
||||
}
|
||||
|
||||
static int read_WRAP(reader *r)
|
||||
{
|
||||
/* See: http://www.hdfgroup.org/HDF5/doc/H5.format.html#Superblock */
|
||||
unsigned char tmp[36]; /* Should be enough */
|
||||
unsigned char buf[8];
|
||||
|
||||
unsigned long long length = 0;
|
||||
|
||||
int i = 0, j;
|
||||
int err = 0;
|
||||
|
||||
tmp[i++] = 'W';
|
||||
tmp[i++] = 'R';
|
||||
tmp[i++] = 'A';
|
||||
tmp[i++] = 'P';
|
||||
|
||||
if( (r->read(r->read_data, buf, 8, &err) != 8) || err) {
|
||||
printf("error\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
for(j = 0; j < 8; j++) {
|
||||
length <<= 8;
|
||||
length |= buf[j];
|
||||
tmp[i++] = buf[j];
|
||||
}
|
||||
|
||||
Assert(i <= sizeof(tmp));
|
||||
return read_the_rest(r, length, tmp, i, 1);
|
||||
}
|
||||
|
||||
static int read_BUFR(reader *r)
|
||||
|
@ -585,14 +733,14 @@ static int read_BUFR(reader *r)
|
|||
}
|
||||
|
||||
/* Assert(i <= sizeof(tmp)); */
|
||||
err=read_the_rest(r,length,tmp,i);
|
||||
err=read_the_rest(r, length, tmp, i, 1);
|
||||
|
||||
grib_buffer_delete(c,buf);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int read_any(reader *r,int grib_ok,int bufr_ok)
|
||||
static int read_any(reader *r,int grib_ok,int bufr_ok, int hdf5_ok, int wrap_ok)
|
||||
{
|
||||
unsigned char c;
|
||||
int err = 0;
|
||||
|
@ -621,6 +769,22 @@ static int read_any(reader *r,int grib_ok,int bufr_ok)
|
|||
}
|
||||
break;
|
||||
|
||||
case HDF5:
|
||||
if(hdf5_ok)
|
||||
{
|
||||
err = read_HDF5(r);
|
||||
return err == GRIB_END_OF_FILE ? GRIB_PREMATURE_END_OF_FILE : err; /* Premature EOF */
|
||||
}
|
||||
break;
|
||||
|
||||
case WRAP:
|
||||
if(wrap_ok)
|
||||
{
|
||||
err = read_WRAP(r);
|
||||
return err == GRIB_END_OF_FILE ? GRIB_PREMATURE_END_OF_FILE : err; /* Premature EOF */
|
||||
}
|
||||
break;
|
||||
|
||||
case BUDG:
|
||||
if(grib_ok)
|
||||
{
|
||||
|
@ -854,7 +1018,7 @@ static void* user_provider_buffer(void *data,size_t* length,int *err)
|
|||
}
|
||||
|
||||
static
|
||||
int _wmo_read_any_from_file(FILE* f,void* buffer,size_t* len,int grib_ok,int bufr_ok)
|
||||
int _wmo_read_any_from_file(FILE* f,void* buffer,size_t* len,int grib_ok,int bufr_ok, int hdf5_ok, int wrap_ok)
|
||||
{
|
||||
int err;
|
||||
user_buffer u;
|
||||
|
@ -872,7 +1036,7 @@ int _wmo_read_any_from_file(FILE* f,void* buffer,size_t* len,int grib_ok,int buf
|
|||
r.alloc = &user_provider_buffer;
|
||||
r.headers_only = 0;
|
||||
|
||||
err = read_any(&r,grib_ok,bufr_ok);
|
||||
err = read_any(&r, grib_ok, bufr_ok, hdf5_ok, wrap_ok);
|
||||
*len = r.message_size;
|
||||
|
||||
return err;
|
||||
|
@ -880,17 +1044,17 @@ int _wmo_read_any_from_file(FILE* f,void* buffer,size_t* len,int grib_ok,int buf
|
|||
|
||||
int wmo_read_any_from_file(FILE* f,void* buffer,size_t* len)
|
||||
{
|
||||
return _wmo_read_any_from_file(f,buffer,len,1,1);
|
||||
return _wmo_read_any_from_file(f, buffer, len, 1, 1, 1 ,1);
|
||||
}
|
||||
|
||||
int wmo_read_grib_from_file(FILE* f,void* buffer,size_t* len)
|
||||
{
|
||||
return _wmo_read_any_from_file(f,buffer,len,1,0);
|
||||
return _wmo_read_any_from_file(f, buffer, len, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
int wmo_read_bufr_from_file(FILE* f,void* buffer,size_t* len)
|
||||
{
|
||||
return _wmo_read_any_from_file(f,buffer,len,0,1);
|
||||
return _wmo_read_any_from_file(f, buffer, len, 0, 1, 0, 0);
|
||||
}
|
||||
|
||||
int wmo_read_gts_from_file(FILE* f,void* buffer,size_t* len)
|
||||
|
@ -1022,7 +1186,7 @@ int wmo_read_any_from_stream(void* stream_data,long (*stream_proc)(void*,void* b
|
|||
r.alloc = &user_provider_buffer;
|
||||
r.headers_only = 0;
|
||||
|
||||
err = read_any(&r,1,1);
|
||||
err = read_any(&r, 1, 1, 1, 1);
|
||||
*len = r.message_size;
|
||||
|
||||
return err;
|
||||
|
@ -1046,6 +1210,7 @@ void *wmo_read_gts_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t
|
|||
reader r;
|
||||
|
||||
u.buffer = NULL;
|
||||
r.offset = 0;
|
||||
|
||||
r.message_size = 0;
|
||||
r.read_data = f;
|
||||
|
@ -1108,7 +1273,7 @@ void *wmo_read_metar_from_file_malloc(FILE* f,int headers_only,size_t *size,off_
|
|||
}
|
||||
|
||||
static void *_wmo_read_any_from_file_malloc(FILE* f,int* err,size_t *size,off_t *offset,
|
||||
int grib_ok,int bufr_ok,int headers_only)
|
||||
int grib_ok,int bufr_ok, int hdf5_ok, int wrap_ok, int headers_only)
|
||||
{
|
||||
alloc_buffer u;
|
||||
reader r;
|
||||
|
@ -1126,7 +1291,7 @@ static void *_wmo_read_any_from_file_malloc(FILE* f,int* err,size_t *size,off_t
|
|||
r.headers_only = headers_only;
|
||||
r.offset = 0;
|
||||
|
||||
*err = read_any(&r,grib_ok,bufr_ok);
|
||||
*err = read_any(&r, grib_ok, bufr_ok, hdf5_ok, wrap_ok);
|
||||
*size = r.message_size;
|
||||
*offset = r.offset;
|
||||
|
||||
|
@ -1134,17 +1299,17 @@ static void *_wmo_read_any_from_file_malloc(FILE* f,int* err,size_t *size,off_t
|
|||
}
|
||||
void *wmo_read_any_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err)
|
||||
{
|
||||
return _wmo_read_any_from_file_malloc(f,err,size,offset,1,1,headers_only);
|
||||
return _wmo_read_any_from_file_malloc(f,err,size,offset, 1, 1, 1, 1, headers_only);
|
||||
}
|
||||
|
||||
void *wmo_read_grib_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err)
|
||||
{
|
||||
return _wmo_read_any_from_file_malloc(f,err,size,offset,1,0,headers_only);
|
||||
return _wmo_read_any_from_file_malloc(f,err,size,offset, 1, 0, 0, 0, headers_only);
|
||||
}
|
||||
|
||||
void *wmo_read_bufr_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err)
|
||||
{
|
||||
return _wmo_read_any_from_file_malloc(f,err,size,offset,0,1,headers_only);
|
||||
return _wmo_read_any_from_file_malloc(f,err,size,offset, 0, 1, 0, 0, headers_only);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1239,7 +1404,7 @@ int grib_read_any_headers_only_from_file(grib_context* ctx,FILE* f,void* buffer,
|
|||
r.alloc = &user_provider_buffer;
|
||||
r.headers_only = 1;
|
||||
|
||||
err = read_any(&r,1,GRIB_API_READS_BUFR);
|
||||
err = read_any(&r, 1, GRIB_API_READS_BUFR, GRIB_API_READS_HDF5, GRIB_API_READS_WRAP);
|
||||
|
||||
*len = r.message_size;
|
||||
|
||||
|
@ -1267,7 +1432,7 @@ int grib_read_any_from_file(grib_context* ctx,FILE* f,void* buffer,size_t* len)
|
|||
|
||||
offset=ftello(f);
|
||||
|
||||
err = read_any(&r,1,GRIB_API_READS_BUFR);
|
||||
err = read_any(&r, 1, GRIB_API_READS_BUFR, GRIB_API_READS_HDF5, GRIB_API_READS_WRAP);
|
||||
|
||||
if (err==GRIB_BUFFER_TOO_SMALL) {
|
||||
if (fseeko(f,offset,SEEK_SET))
|
||||
|
@ -1337,7 +1502,7 @@ int grib_read_any_from_memory_alloc(grib_context* ctx,unsigned char** data,size_
|
|||
r.alloc = &context_allocate_buffer;
|
||||
r.headers_only = 0;
|
||||
|
||||
err = read_any(&r,1,GRIB_API_READS_BUFR);
|
||||
err = read_any(&r, 1, GRIB_API_READS_BUFR, GRIB_API_READS_HDF5, GRIB_API_READS_WRAP);
|
||||
*buffer = u.buffer;
|
||||
*length = u.length;
|
||||
|
||||
|
@ -1369,7 +1534,7 @@ int grib_read_any_from_memory(grib_context* ctx,unsigned char** data,size_t* dat
|
|||
r.alloc = &user_provider_buffer;
|
||||
r.headers_only = 0;
|
||||
|
||||
err = read_any(&r,1,GRIB_API_READS_BUFR);
|
||||
err = read_any(&r, 1, GRIB_API_READS_BUFR, GRIB_API_READS_HDF5, GRIB_API_READS_WRAP);
|
||||
*len = r.message_size;
|
||||
|
||||
*data_length = m.data_len;
|
||||
|
|
1664
src/grib_lex.c
1664
src/grib_lex.c
File diff suppressed because it is too large
Load Diff
3172
src/grib_yacc.c
3172
src/grib_yacc.c
File diff suppressed because it is too large
Load Diff
368
src/grib_yacc.h
368
src/grib_yacc.h
|
@ -64,90 +64,105 @@
|
|||
WHILE = 280,
|
||||
IBMFLOAT = 281,
|
||||
SIGNED = 282,
|
||||
BYTE = 283,
|
||||
CODETABLE = 284,
|
||||
SMART_TABLE = 285,
|
||||
DICTIONARY = 286,
|
||||
COMPLEX_CODETABLE = 287,
|
||||
LOOKUP = 288,
|
||||
ALIAS = 289,
|
||||
UNALIAS = 290,
|
||||
META = 291,
|
||||
POS = 292,
|
||||
INTCONST = 293,
|
||||
TRANS = 294,
|
||||
FLAGBIT = 295,
|
||||
CONCEPT = 296,
|
||||
GETENV = 297,
|
||||
HASH_ARRAY = 298,
|
||||
CONCEPT_NOFAIL = 299,
|
||||
NIL = 300,
|
||||
DUMMY = 301,
|
||||
MODIFY = 302,
|
||||
READ_ONLY = 303,
|
||||
STRING_TYPE = 304,
|
||||
LONG_TYPE = 305,
|
||||
DOUBLE_TYPE = 306,
|
||||
NO_COPY = 307,
|
||||
DUMP = 308,
|
||||
JSON = 309,
|
||||
XML = 310,
|
||||
NO_FAIL = 311,
|
||||
EDITION_SPECIFIC = 312,
|
||||
OVERRIDE = 313,
|
||||
HIDDEN = 314,
|
||||
CAN_BE_MISSING = 315,
|
||||
MISSING = 316,
|
||||
CONSTRAINT = 317,
|
||||
COPY_OK = 318,
|
||||
WHEN = 319,
|
||||
SET = 320,
|
||||
SET_NOFAIL = 321,
|
||||
WRITE = 322,
|
||||
APPEND = 323,
|
||||
PRINT = 324,
|
||||
EXPORT = 325,
|
||||
REMOVE = 326,
|
||||
RENAME = 327,
|
||||
SKIP = 328,
|
||||
PAD = 329,
|
||||
SECTION_PADDING = 330,
|
||||
MESSAGE = 331,
|
||||
MESSAGE_COPY = 332,
|
||||
PADTO = 333,
|
||||
PADTOEVEN = 334,
|
||||
PADTOMULTIPLE = 335,
|
||||
G1_HALF_BYTE = 336,
|
||||
G1_MESSAGE_LENGTH = 337,
|
||||
G1_SECTION4_LENGTH = 338,
|
||||
SECTION_LENGTH = 339,
|
||||
LENGTH = 340,
|
||||
FLAG = 341,
|
||||
ITERATOR = 342,
|
||||
NEAREST = 343,
|
||||
BOX = 344,
|
||||
KSEC = 345,
|
||||
ASSERT = 346,
|
||||
SUBSTR = 347,
|
||||
CASE = 348,
|
||||
SWITCH = 349,
|
||||
DEFAULT = 350,
|
||||
EQ = 351,
|
||||
NE = 352,
|
||||
GE = 353,
|
||||
LE = 354,
|
||||
LT = 355,
|
||||
GT = 356,
|
||||
BIT = 357,
|
||||
BITOFF = 358,
|
||||
AND = 359,
|
||||
OR = 360,
|
||||
NOT = 361,
|
||||
IS = 362,
|
||||
IDENT = 363,
|
||||
STRING = 364,
|
||||
INTEGER = 365,
|
||||
FLOAT = 366
|
||||
UINT8 = 283,
|
||||
INT8 = 284,
|
||||
UINT16 = 285,
|
||||
INT16 = 286,
|
||||
UINT16_LITTLE_ENDIAN = 287,
|
||||
INT16_LITTLE_ENDIAN = 288,
|
||||
UINT32 = 289,
|
||||
INT32 = 290,
|
||||
UINT32_LITTLE_ENDIAN = 291,
|
||||
INT32_LITTLE_ENDIAN = 292,
|
||||
UINT64 = 293,
|
||||
INT64 = 294,
|
||||
UINT64_LITTLE_ENDIAN = 295,
|
||||
INT64_LITTLE_ENDIAN = 296,
|
||||
BLOB = 297,
|
||||
BYTE = 298,
|
||||
CODETABLE = 299,
|
||||
SMART_TABLE = 300,
|
||||
DICTIONARY = 301,
|
||||
COMPLEX_CODETABLE = 302,
|
||||
LOOKUP = 303,
|
||||
ALIAS = 304,
|
||||
UNALIAS = 305,
|
||||
META = 306,
|
||||
POS = 307,
|
||||
INTCONST = 308,
|
||||
TRANS = 309,
|
||||
FLAGBIT = 310,
|
||||
CONCEPT = 311,
|
||||
GETENV = 312,
|
||||
HASH_ARRAY = 313,
|
||||
CONCEPT_NOFAIL = 314,
|
||||
NIL = 315,
|
||||
DUMMY = 316,
|
||||
MODIFY = 317,
|
||||
READ_ONLY = 318,
|
||||
STRING_TYPE = 319,
|
||||
LONG_TYPE = 320,
|
||||
DOUBLE_TYPE = 321,
|
||||
NO_COPY = 322,
|
||||
DUMP = 323,
|
||||
JSON = 324,
|
||||
XML = 325,
|
||||
NO_FAIL = 326,
|
||||
EDITION_SPECIFIC = 327,
|
||||
OVERRIDE = 328,
|
||||
HIDDEN = 329,
|
||||
CAN_BE_MISSING = 330,
|
||||
MISSING = 331,
|
||||
CONSTRAINT = 332,
|
||||
COPY_OK = 333,
|
||||
WHEN = 334,
|
||||
SET = 335,
|
||||
SET_NOFAIL = 336,
|
||||
WRITE = 337,
|
||||
APPEND = 338,
|
||||
PRINT = 339,
|
||||
EXPORT = 340,
|
||||
REMOVE = 341,
|
||||
RENAME = 342,
|
||||
SKIP = 343,
|
||||
PAD = 344,
|
||||
SECTION_PADDING = 345,
|
||||
MESSAGE = 346,
|
||||
MESSAGE_COPY = 347,
|
||||
PADTO = 348,
|
||||
PADTOEVEN = 349,
|
||||
PADTOMULTIPLE = 350,
|
||||
G1_HALF_BYTE = 351,
|
||||
G1_MESSAGE_LENGTH = 352,
|
||||
G1_SECTION4_LENGTH = 353,
|
||||
SECTION_LENGTH = 354,
|
||||
LENGTH = 355,
|
||||
FLAG = 356,
|
||||
ITERATOR = 357,
|
||||
NEAREST = 358,
|
||||
BOX = 359,
|
||||
KSEC = 360,
|
||||
ASSERT = 361,
|
||||
SUBSTR = 362,
|
||||
CASE = 363,
|
||||
SWITCH = 364,
|
||||
DEFAULT = 365,
|
||||
EQ = 366,
|
||||
NE = 367,
|
||||
GE = 368,
|
||||
LE = 369,
|
||||
LT = 370,
|
||||
GT = 371,
|
||||
BIT = 372,
|
||||
BITOFF = 373,
|
||||
AND = 374,
|
||||
OR = 375,
|
||||
NOT = 376,
|
||||
IS = 377,
|
||||
IDENT = 378,
|
||||
STRING = 379,
|
||||
INTEGER = 380,
|
||||
FLOAT = 381
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
|
@ -176,90 +191,105 @@
|
|||
#define WHILE 280
|
||||
#define IBMFLOAT 281
|
||||
#define SIGNED 282
|
||||
#define BYTE 283
|
||||
#define CODETABLE 284
|
||||
#define SMART_TABLE 285
|
||||
#define DICTIONARY 286
|
||||
#define COMPLEX_CODETABLE 287
|
||||
#define LOOKUP 288
|
||||
#define ALIAS 289
|
||||
#define UNALIAS 290
|
||||
#define META 291
|
||||
#define POS 292
|
||||
#define INTCONST 293
|
||||
#define TRANS 294
|
||||
#define FLAGBIT 295
|
||||
#define CONCEPT 296
|
||||
#define GETENV 297
|
||||
#define HASH_ARRAY 298
|
||||
#define CONCEPT_NOFAIL 299
|
||||
#define NIL 300
|
||||
#define DUMMY 301
|
||||
#define MODIFY 302
|
||||
#define READ_ONLY 303
|
||||
#define STRING_TYPE 304
|
||||
#define LONG_TYPE 305
|
||||
#define DOUBLE_TYPE 306
|
||||
#define NO_COPY 307
|
||||
#define DUMP 308
|
||||
#define JSON 309
|
||||
#define XML 310
|
||||
#define NO_FAIL 311
|
||||
#define EDITION_SPECIFIC 312
|
||||
#define OVERRIDE 313
|
||||
#define HIDDEN 314
|
||||
#define CAN_BE_MISSING 315
|
||||
#define MISSING 316
|
||||
#define CONSTRAINT 317
|
||||
#define COPY_OK 318
|
||||
#define WHEN 319
|
||||
#define SET 320
|
||||
#define SET_NOFAIL 321
|
||||
#define WRITE 322
|
||||
#define APPEND 323
|
||||
#define PRINT 324
|
||||
#define EXPORT 325
|
||||
#define REMOVE 326
|
||||
#define RENAME 327
|
||||
#define SKIP 328
|
||||
#define PAD 329
|
||||
#define SECTION_PADDING 330
|
||||
#define MESSAGE 331
|
||||
#define MESSAGE_COPY 332
|
||||
#define PADTO 333
|
||||
#define PADTOEVEN 334
|
||||
#define PADTOMULTIPLE 335
|
||||
#define G1_HALF_BYTE 336
|
||||
#define G1_MESSAGE_LENGTH 337
|
||||
#define G1_SECTION4_LENGTH 338
|
||||
#define SECTION_LENGTH 339
|
||||
#define LENGTH 340
|
||||
#define FLAG 341
|
||||
#define ITERATOR 342
|
||||
#define NEAREST 343
|
||||
#define BOX 344
|
||||
#define KSEC 345
|
||||
#define ASSERT 346
|
||||
#define SUBSTR 347
|
||||
#define CASE 348
|
||||
#define SWITCH 349
|
||||
#define DEFAULT 350
|
||||
#define EQ 351
|
||||
#define NE 352
|
||||
#define GE 353
|
||||
#define LE 354
|
||||
#define LT 355
|
||||
#define GT 356
|
||||
#define BIT 357
|
||||
#define BITOFF 358
|
||||
#define AND 359
|
||||
#define OR 360
|
||||
#define NOT 361
|
||||
#define IS 362
|
||||
#define IDENT 363
|
||||
#define STRING 364
|
||||
#define INTEGER 365
|
||||
#define FLOAT 366
|
||||
#define UINT8 283
|
||||
#define INT8 284
|
||||
#define UINT16 285
|
||||
#define INT16 286
|
||||
#define UINT16_LITTLE_ENDIAN 287
|
||||
#define INT16_LITTLE_ENDIAN 288
|
||||
#define UINT32 289
|
||||
#define INT32 290
|
||||
#define UINT32_LITTLE_ENDIAN 291
|
||||
#define INT32_LITTLE_ENDIAN 292
|
||||
#define UINT64 293
|
||||
#define INT64 294
|
||||
#define UINT64_LITTLE_ENDIAN 295
|
||||
#define INT64_LITTLE_ENDIAN 296
|
||||
#define BLOB 297
|
||||
#define BYTE 298
|
||||
#define CODETABLE 299
|
||||
#define SMART_TABLE 300
|
||||
#define DICTIONARY 301
|
||||
#define COMPLEX_CODETABLE 302
|
||||
#define LOOKUP 303
|
||||
#define ALIAS 304
|
||||
#define UNALIAS 305
|
||||
#define META 306
|
||||
#define POS 307
|
||||
#define INTCONST 308
|
||||
#define TRANS 309
|
||||
#define FLAGBIT 310
|
||||
#define CONCEPT 311
|
||||
#define GETENV 312
|
||||
#define HASH_ARRAY 313
|
||||
#define CONCEPT_NOFAIL 314
|
||||
#define NIL 315
|
||||
#define DUMMY 316
|
||||
#define MODIFY 317
|
||||
#define READ_ONLY 318
|
||||
#define STRING_TYPE 319
|
||||
#define LONG_TYPE 320
|
||||
#define DOUBLE_TYPE 321
|
||||
#define NO_COPY 322
|
||||
#define DUMP 323
|
||||
#define JSON 324
|
||||
#define XML 325
|
||||
#define NO_FAIL 326
|
||||
#define EDITION_SPECIFIC 327
|
||||
#define OVERRIDE 328
|
||||
#define HIDDEN 329
|
||||
#define CAN_BE_MISSING 330
|
||||
#define MISSING 331
|
||||
#define CONSTRAINT 332
|
||||
#define COPY_OK 333
|
||||
#define WHEN 334
|
||||
#define SET 335
|
||||
#define SET_NOFAIL 336
|
||||
#define WRITE 337
|
||||
#define APPEND 338
|
||||
#define PRINT 339
|
||||
#define EXPORT 340
|
||||
#define REMOVE 341
|
||||
#define RENAME 342
|
||||
#define SKIP 343
|
||||
#define PAD 344
|
||||
#define SECTION_PADDING 345
|
||||
#define MESSAGE 346
|
||||
#define MESSAGE_COPY 347
|
||||
#define PADTO 348
|
||||
#define PADTOEVEN 349
|
||||
#define PADTOMULTIPLE 350
|
||||
#define G1_HALF_BYTE 351
|
||||
#define G1_MESSAGE_LENGTH 352
|
||||
#define G1_SECTION4_LENGTH 353
|
||||
#define SECTION_LENGTH 354
|
||||
#define LENGTH 355
|
||||
#define FLAG 356
|
||||
#define ITERATOR 357
|
||||
#define NEAREST 358
|
||||
#define BOX 359
|
||||
#define KSEC 360
|
||||
#define ASSERT 361
|
||||
#define SUBSTR 362
|
||||
#define CASE 363
|
||||
#define SWITCH 364
|
||||
#define DEFAULT 365
|
||||
#define EQ 366
|
||||
#define NE 367
|
||||
#define GE 368
|
||||
#define LE 369
|
||||
#define LT 370
|
||||
#define GT 371
|
||||
#define BIT 372
|
||||
#define BITOFF 373
|
||||
#define AND 374
|
||||
#define OR 375
|
||||
#define NOT 376
|
||||
#define IS 377
|
||||
#define IDENT 378
|
||||
#define STRING 379
|
||||
#define INTEGER 380
|
||||
#define FLOAT 381
|
||||
|
||||
|
||||
|
||||
|
@ -289,7 +319,7 @@ typedef union YYSTYPE
|
|||
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
#line 293 "y.tab.h"
|
||||
#line 323 "y.tab.h"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define grib_yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
|
|
20
src/gribl.l
20
src/gribl.l
|
@ -172,6 +172,26 @@ FLOAT3 {NSIGNED}+{EXP}?
|
|||
"override" return OVERRIDE;
|
||||
"copy_ok" return COPY_OK;
|
||||
|
||||
"uint8" return UINT8;
|
||||
"int" return INT8;
|
||||
|
||||
"uint16" return UINT16;
|
||||
"int16" return INT16;
|
||||
"uint16_little_endian" return UINT16_LITTLE_ENDIAN;
|
||||
"int16_little_endian" return INT16_LITTLE_ENDIAN;
|
||||
|
||||
"uint32" return UINT32;
|
||||
"int32" return INT32;
|
||||
"uint32_little_endian" return UINT32_LITTLE_ENDIAN;
|
||||
"int32_little_endian" return INT32_LITTLE_ENDIAN;
|
||||
|
||||
"uint64" return UINT64;
|
||||
"int64" return INT64;
|
||||
"uint64_little_endian" return UINT64_LITTLE_ENDIAN;
|
||||
"int64_little_endian" return INT64_LITTLE_ENDIAN;
|
||||
|
||||
"blob" return BLOB;
|
||||
|
||||
"set" return SET;
|
||||
"set_nofail" return SET_NOFAIL;
|
||||
"when" return WHEN;
|
||||
|
|
68
src/griby.y
68
src/griby.y
|
@ -78,6 +78,27 @@ static grib_hash_array_value *_reverse_hash_array(grib_hash_array_value *r,grib_
|
|||
%token WHILE
|
||||
%token IBMFLOAT
|
||||
%token SIGNED
|
||||
|
||||
%token UINT8
|
||||
%token INT8
|
||||
|
||||
%token UINT16
|
||||
%token INT16
|
||||
%token UINT16_LITTLE_ENDIAN
|
||||
%token INT16_LITTLE_ENDIAN
|
||||
|
||||
%token UINT32
|
||||
%token INT32
|
||||
%token UINT32_LITTLE_ENDIAN
|
||||
%token INT32_LITTLE_ENDIAN
|
||||
|
||||
%token UINT64
|
||||
%token INT64
|
||||
%token UINT64_LITTLE_ENDIAN
|
||||
%token INT64_LITTLE_ENDIAN
|
||||
|
||||
%token BLOB
|
||||
|
||||
%token BYTE
|
||||
%token CODETABLE
|
||||
%token SMART_TABLE
|
||||
|
@ -393,6 +414,53 @@ simple : UNSIGNED '[' INTEGER ']' IDENT default flags
|
|||
| IBMFLOAT IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"ibmfloat",4,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
/*---------*/
|
||||
| INT8 IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"int8",1,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| UINT8 IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"uint8",1,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| INT16 IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"int16",2,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| UINT16 IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"uint16",2,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| INT16_LITTLE_ENDIAN IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"int16_little_endian",2,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| UINT16_LITTLE_ENDIAN IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"uint16_little_endian",2,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| INT32 IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"int32",4,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| UINT32 IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"uint32",4,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| INT32_LITTLE_ENDIAN IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"int32_little_endian",4,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| UINT32_LITTLE_ENDIAN IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"uint32_little_endian",4,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| INT64 IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"int64",8,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| UINT64 IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"uint64",8,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| INT64_LITTLE_ENDIAN IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"int64_little_endian",8,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| UINT64_LITTLE_ENDIAN IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"uint64_little_endian",8,NULL,$3,$4,NULL,NULL);free($2); }
|
||||
|
||||
| BLOB IDENT '[' argument_list ']' default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$2,"blob",0,$4,$6,$7,NULL,NULL); free($2); }
|
||||
/*---------*/
|
||||
|
||||
| IBMFLOAT IDENT '.' IDENT default flags
|
||||
{ $$ = grib_action_create_gen(grib_parser_context,$4,"ibmfloat",4,NULL,$5,$6,$2,NULL);free($4); free($2); }
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
use Switch;
|
||||
|
||||
|
||||
my $name;
|
||||
|
@ -266,17 +265,15 @@ EOF
|
|||
if ($mtype=~ /\*/) { $is_pointer=1; $mtype =~ s/\*//; }
|
||||
|
||||
if ($is_pointer) {
|
||||
switch ($mtype) {
|
||||
case "char" {
|
||||
if ($mtype =~ "\bchar\b") {
|
||||
print OUT "\tif (self->$mname) \n\t\tc->$mname=grib_context_strdup(a->parent->h,self->$mname);\n\n";
|
||||
}
|
||||
case /double|long|int|float/ {
|
||||
}
|
||||
if ($mtype =~ "\b(double|long|int|float)\b") {
|
||||
print OUT "\tif (self->".$mname."_size) {\n";
|
||||
print OUT "\tint i=0;\n";
|
||||
print OUT "\tc->$mname=grib_context_alloc_clear(a->parent->h,self->".$mname."_size*sizeof($mtype));";
|
||||
print OUT "\tfor (i=0;i<self->${mname}_size;i++) c->".$mname."[i]=self->".$mname."[i];";
|
||||
print OUT "}\n";
|
||||
}
|
||||
}
|
||||
} else { print OUT "\tc->$mname=self->$mname;\n\n"; }
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ grib_options_help grib_options_help_list[] ={
|
|||
"\n\t\tall=relative_error will compare all the floating point keys using relative_error. Default all=0.\n"},
|
||||
{"S",0,"Strict. Only grib messages matching all the constraints are copied to"
|
||||
"\n\t\tthe output file\n"},
|
||||
{"T:","T | B","Message type. T->GTS, B->BUFR. The input file is interpreted according to the message type.\n"},
|
||||
{"T:","T | B | A","Message type. T->GTS, B->BUFR, A->Any (Experimental). The input file is interpreted according to the message type.\n"},
|
||||
{"V",0,"Version.\n"},
|
||||
{"W:","width","\n\t\tMinimum width of each column in output. Default is 10.\n"},
|
||||
{"X:","offset","\n\t\tInput file offset in bytes. Processing of the input file will start from \"offset\".\n"},
|
||||
|
@ -201,6 +201,7 @@ int grib_process_runtime_options(grib_context* context,int argc,char** argv,grib
|
|||
char* x=grib_options_get_option("T:");
|
||||
if ( *x == 'T' ) options->mode=MODE_GTS;
|
||||
else if ( *x == 'B' ) options->mode=MODE_BUFR;
|
||||
else if ( *x == 'A' ) options->mode=MODE_ANY;
|
||||
else options->mode=MODE_GRIB;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,6 +111,9 @@ grib_runtime_options options={
|
|||
|
||||
static grib_handle* grib_handle_new_from_file_x(grib_context* c,FILE* f,int mode,int headers_only,int *err)
|
||||
{
|
||||
if (mode==MODE_ANY)
|
||||
return any_new_from_file(c,f,headers_only,err);
|
||||
|
||||
if (mode==MODE_GTS)
|
||||
return gts_new_from_file(c,f,headers_only,err);
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#define MODE_BUFR 2
|
||||
#define MODE_METAR 3
|
||||
#define MODE_TAF 5
|
||||
#define MODE_ANY 6
|
||||
|
||||
typedef union grib_typed_value {
|
||||
long* long_value;
|
||||
|
|
Loading…
Reference in New Issue