Cosmetics

This commit is contained in:
shahramn 2024-05-10 16:15:08 +01:00
parent 80d3a68ad1
commit ac80478fa4
10 changed files with 199 additions and 140 deletions

View File

@ -11,11 +11,12 @@
#include "grib_accessor_class_position.h"
grib_accessor_class_position_t _grib_accessor_class_position{"position"};
grib_accessor_class_position_t _grib_accessor_class_position{ "position" };
grib_accessor_class* grib_accessor_class_position = &_grib_accessor_class_position;
void grib_accessor_class_position_t::init(grib_accessor* a, const long len, grib_arguments* arg){
void grib_accessor_class_position_t::init(grib_accessor* a, const long len, grib_arguments* arg)
{
grib_accessor_class_gen_t::init(a, len, arg);
a->length = 0;
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
@ -23,17 +24,20 @@ void grib_accessor_class_position_t::init(grib_accessor* a, const long len, grib
a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC;
}
int grib_accessor_class_position_t::get_native_type(grib_accessor* a){
int grib_accessor_class_position_t::get_native_type(grib_accessor* a)
{
return GRIB_TYPE_LONG;
}
void grib_accessor_class_position_t::dump(grib_accessor* a, grib_dumper* dumper){
void grib_accessor_class_position_t::dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
int grib_accessor_class_position_t::unpack_long(grib_accessor* a, long* val, size_t* len){
int grib_accessor_class_position_t::unpack_long(grib_accessor* a, long* val, size_t* len)
{
if (*len < 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values ", a->name, 1);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -11,11 +11,12 @@
#include "grib_accessor_class_proj_string.h"
grib_accessor_class_proj_string_t _grib_accessor_class_proj_string{"proj_string"};
grib_accessor_class_proj_string_t _grib_accessor_class_proj_string{ "proj_string" };
grib_accessor_class* grib_accessor_class_proj_string = &_grib_accessor_class_proj_string;
void grib_accessor_class_proj_string_t::init(grib_accessor* a, const long len, grib_arguments* arg){
void grib_accessor_class_proj_string_t::init(grib_accessor* a, const long len, grib_arguments* arg)
{
grib_accessor_class_gen_t::init(a, len, arg);
grib_accessor_proj_string_t* self = (grib_accessor_proj_string_t*)a;
grib_handle* h = grib_handle_of_accessor(a);
@ -27,7 +28,8 @@ void grib_accessor_class_proj_string_t::init(grib_accessor* a, const long len, g
a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC;
}
int grib_accessor_class_proj_string_t::get_native_type(grib_accessor* a){
int grib_accessor_class_proj_string_t::get_native_type(grib_accessor* a)
{
return GRIB_TYPE_STRING;
}
@ -41,7 +43,8 @@ struct proj_mapping
typedef struct proj_mapping proj_mapping;
// This should only be called for GRID POINT data (not spherical harmonics etc)
static int get_major_minor_axes(grib_handle* h, double* pMajor, double* pMinor){
static int get_major_minor_axes(grib_handle* h, double* pMajor, double* pMinor)
{
int err = 0;
if (grib_is_earth_oblate(h)) {
if ((err = grib_get_double_internal(h, "earthMinorAxisInMetres", pMinor)) != GRIB_SUCCESS) return err;
@ -56,7 +59,8 @@ static int get_major_minor_axes(grib_handle* h, double* pMajor, double* pMinor){
}
// Caller must have allocated enough space in the 'result' argument
static int get_earth_shape(grib_handle* h, char* result){
static int get_earth_shape(grib_handle* h, char* result)
{
int err = 0;
double major = 0, minor = 0;
if ((err = get_major_minor_axes(h, &major, &minor)) != GRIB_SUCCESS)
@ -68,7 +72,8 @@ static int get_earth_shape(grib_handle* h, char* result){
return err;
}
static int proj_space_view(grib_handle* h, char* result){
static int proj_space_view(grib_handle* h, char* result)
{
return GRIB_NOT_IMPLEMENTED;
// int err = 0;
// char shape[128] = {0,};
@ -84,17 +89,21 @@ static int proj_space_view(grib_handle* h, char* result){
// return err;
}
static int proj_albers(grib_handle* h, char* result){
static int proj_albers(grib_handle* h, char* result)
{
return GRIB_NOT_IMPLEMENTED;
}
static int proj_transverse_mercator(grib_handle* h, char* result){
static int proj_transverse_mercator(grib_handle* h, char* result)
{
return GRIB_NOT_IMPLEMENTED;
}
static int proj_equatorial_azimuthal_equidistant(grib_handle* h, char* result){
static int proj_equatorial_azimuthal_equidistant(grib_handle* h, char* result)
{
return GRIB_NOT_IMPLEMENTED;
}
static int proj_lambert_conformal(grib_handle* h, char* result){
static int proj_lambert_conformal(grib_handle* h, char* result)
{
int err = 0;
char shape[128] = {0,};
double LoVInDegrees = 0, LaDInDegrees = 0, Latin1InDegrees = 0, Latin2InDegrees = 0;
@ -114,7 +123,8 @@ static int proj_lambert_conformal(grib_handle* h, char* result){
return err;
}
static int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result){
static int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result)
{
int err = 0;
char shape[128] = {0,};
double standardParallel = 0, centralLongitude = 0;
@ -130,7 +140,8 @@ static int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result){
return err;
}
static int proj_polar_stereographic(grib_handle* h, char* result){
static int proj_polar_stereographic(grib_handle* h, char* result)
{
int err = 0;
double centralLongitude = 0, centralLatitude = 0;
int has_northPole = 0;
@ -153,17 +164,19 @@ static int proj_polar_stereographic(grib_handle* h, char* result){
// ECC-1552: This is for regular_ll, regular_gg, reduced_ll, reduced_gg
// These are not 'projected' grids!
static int proj_unprojected(grib_handle* h, char* result){
static int proj_unprojected(grib_handle* h, char* result)
{
int err = 0;
//char shape[128] = {0,};
//if ((err = get_earth_shape(h, shape)) != GRIB_SUCCESS) return err;
//snprintf(result, 1024, "+proj=longlat %s", shape);
// char shape[128] = {0,};
// if ((err = get_earth_shape(h, shape)) != GRIB_SUCCESS) return err;
// snprintf(result, 1024, "+proj=longlat %s", shape);
snprintf(result, 1024, "+proj=longlat +datum=WGS84 +no_defs +type=crs");
return err;
}
static int proj_mercator(grib_handle* h, char* result){
static int proj_mercator(grib_handle* h, char* result)
{
int err = 0;
double LaDInDegrees = 0;
char shape[128] = {0,};
@ -195,7 +208,8 @@ static proj_mapping proj_mappings[] = {
#define ENDPOINT_SOURCE 0
#define ENDPOINT_TARGET 1
int grib_accessor_class_proj_string_t::unpack_string(grib_accessor* a, char* v, size_t* len){
int grib_accessor_class_proj_string_t::unpack_string(grib_accessor* a, char* v, size_t* len)
{
grib_accessor_proj_string_t* self = (grib_accessor_proj_string_t*)a;
int err = 0, found = 0;
size_t i = 0;

View File

@ -11,11 +11,12 @@
#include "grib_accessor_class_raw.h"
grib_accessor_class_raw_t _grib_accessor_class_raw{"raw"};
grib_accessor_class_raw_t _grib_accessor_class_raw{ "raw" };
grib_accessor_class* grib_accessor_class_raw = &_grib_accessor_class_raw;
void grib_accessor_class_raw_t::init(grib_accessor* a, const long len, grib_arguments* arg){
void grib_accessor_class_raw_t::init(grib_accessor* a, const long len, grib_arguments* arg)
{
grib_accessor_class_gen_t::init(a, len, arg);
int n = 0;
int err = 0;
@ -42,31 +43,37 @@ void grib_accessor_class_raw_t::init(grib_accessor* a, const long len, grib_argu
/* Assert(a->length>=0); */
}
int grib_accessor_class_raw_t::get_native_type(grib_accessor* a){
int grib_accessor_class_raw_t::get_native_type(grib_accessor* a)
{
return GRIB_TYPE_BYTES;
}
int grib_accessor_class_raw_t::compare(grib_accessor* a, grib_accessor* b){
int grib_accessor_class_raw_t::compare(grib_accessor* a, grib_accessor* b)
{
int retval = GRIB_SUCCESS;
size_t alen = (size_t)a->byte_count(); size_t blen = (size_t)b->byte_count();
size_t alen = (size_t)a->byte_count();
size_t blen = (size_t)b->byte_count();
if (alen != blen)
return GRIB_COUNT_MISMATCH;
return retval;
}
long grib_accessor_class_raw_t::byte_count(grib_accessor* a){
long grib_accessor_class_raw_t::byte_count(grib_accessor* a)
{
return a->length;
}
int grib_accessor_class_raw_t::value_count(grib_accessor* a, long* len){
int grib_accessor_class_raw_t::value_count(grib_accessor* a, long* len)
{
*len = a->length;
return 0;
}
int grib_accessor_class_raw_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len){
int grib_accessor_class_raw_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len)
{
if (*len < a->length) {
*len = a->length;
return GRIB_ARRAY_TOO_SMALL;
@ -78,7 +85,8 @@ int grib_accessor_class_raw_t::unpack_bytes(grib_accessor* a, unsigned char* buf
return GRIB_SUCCESS;
}
void grib_accessor_class_raw_t::update_size(grib_accessor* a, size_t s){
void grib_accessor_class_raw_t::update_size(grib_accessor* a, size_t s)
{
grib_context_log(a->context, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", a->name, a->length, s);
a->length = s;
Assert(a->length >= 0);
@ -94,7 +102,8 @@ long accessor_raw_get_offset(grib_accessor* a)
return a->offset;
}
int grib_accessor_class_raw_t::pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len){
int grib_accessor_class_raw_t::pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len)
{
size_t length = *len;
long totalLength;
long sectionLength;

View File

@ -15,7 +15,8 @@ grib_accessor_class_rdbtime_guess_date_t _grib_accessor_class_rdbtime_guess_date
grib_accessor_class* grib_accessor_class_rdbtime_guess_date = &_grib_accessor_class_rdbtime_guess_date;
void grib_accessor_class_rdbtime_guess_date_t::init(grib_accessor* a, const long l, grib_arguments* c){
void grib_accessor_class_rdbtime_guess_date_t::init(grib_accessor* a, const long l, grib_arguments* c)
{
grib_accessor_class_long_t::init(a, l, c);
grib_accessor_rdbtime_guess_date_t* self = (grib_accessor_rdbtime_guess_date_t*)a;
int n = 0;
@ -29,14 +30,14 @@ void grib_accessor_class_rdbtime_guess_date_t::init(grib_accessor* a, const long
/* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */
}
int grib_accessor_class_rdbtime_guess_date_t::unpack_long(grib_accessor* a, long* val, size_t* len){
int grib_accessor_class_rdbtime_guess_date_t::unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_rdbtime_guess_date_t* self = (grib_accessor_rdbtime_guess_date_t*)a;
grib_handle* h = grib_handle_of_accessor(a);
int ret = 0;
long typicalYear, typicalMonth, typicalDay, rdbDay;
long rdbYear, rdbMonth;
ret = grib_get_long(h, self->typicalYear, &typicalYear);
int ret = grib_get_long(h, self->typicalYear, &typicalYear);
if (ret)
return ret;
ret = grib_get_long(h, self->typicalMonth, &typicalMonth);
@ -70,7 +71,8 @@ int grib_accessor_class_rdbtime_guess_date_t::unpack_long(grib_accessor* a, long
return GRIB_SUCCESS;
}
int grib_accessor_class_rdbtime_guess_date_t::pack_long(grib_accessor* a, const long* v, size_t* len){
int grib_accessor_class_rdbtime_guess_date_t::pack_long(grib_accessor* a, const long* v, size_t* len)
{
/* do nothing*/
return GRIB_SUCCESS;
}

View File

@ -11,11 +11,12 @@
#include "grib_accessor_class_reference_value_error.h"
grib_accessor_class_reference_value_error_t _grib_accessor_class_reference_value_error{"reference_value_error"};
grib_accessor_class_reference_value_error_t _grib_accessor_class_reference_value_error{ "reference_value_error" };
grib_accessor_class* grib_accessor_class_reference_value_error = &_grib_accessor_class_reference_value_error;
void grib_accessor_class_reference_value_error_t::init(grib_accessor* a, const long l, grib_arguments* c){
void grib_accessor_class_reference_value_error_t::init(grib_accessor* a, const long l, grib_arguments* c)
{
grib_accessor_class_double_t::init(a, l, c);
grib_accessor_reference_value_error_t* self = (grib_accessor_reference_value_error_t*)a;
int n = 0;
@ -27,9 +28,10 @@ void grib_accessor_class_reference_value_error_t::init(grib_accessor* a, const l
a->length = 0;
}
int grib_accessor_class_reference_value_error_t::unpack_double(grib_accessor* a, double* val, size_t* len){
int grib_accessor_class_reference_value_error_t::unpack_double(grib_accessor* a, double* val, size_t* len)
{
grib_accessor_reference_value_error_t* self = (grib_accessor_reference_value_error_t*)a;
int ret = 0;
int ret = GRIB_SUCCESS;
double referenceValue = 0;
if ((ret = grib_get_double_internal(grib_handle_of_accessor(a),

View File

@ -11,11 +11,12 @@
#include "grib_accessor_class_round.h"
grib_accessor_class_round_t _grib_accessor_class_round{"round"};
grib_accessor_class_round_t _grib_accessor_class_round{ "round" };
grib_accessor_class* grib_accessor_class_round = &_grib_accessor_class_round;
int grib_accessor_class_round_t::unpack_double(grib_accessor* a, double* val, size_t* len){
int grib_accessor_class_round_t::unpack_double(grib_accessor* a, double* val, size_t* len)
{
grib_accessor_round_t* self = (grib_accessor_round_t*)a;
int ret = GRIB_SUCCESS;
@ -42,7 +43,8 @@ int grib_accessor_class_round_t::unpack_double(grib_accessor* a, double* val, si
return ret;
}
int grib_accessor_class_round_t::unpack_string(grib_accessor* a, char* val, size_t* len){
int grib_accessor_class_round_t::unpack_string(grib_accessor* a, char* val, size_t* len)
{
char result[1024];
int ret = GRIB_SUCCESS;
size_t replen = 1;

View File

@ -11,11 +11,12 @@
#include "grib_accessor_class_scale.h"
grib_accessor_class_scale_t _grib_accessor_class_scale{"scale"};
grib_accessor_class_scale_t _grib_accessor_class_scale{ "scale" };
grib_accessor_class* grib_accessor_class_scale = &_grib_accessor_class_scale;
void grib_accessor_class_scale_t::init(grib_accessor* a, const long l, grib_arguments* c){
void grib_accessor_class_scale_t::init(grib_accessor* a, const long l, grib_arguments* c)
{
grib_accessor_class_double_t::init(a, l, c);
grib_accessor_scale_t* self = (grib_accessor_scale_t*)a;
int n = 0;
@ -26,7 +27,8 @@ void grib_accessor_class_scale_t::init(grib_accessor* a, const long l, grib_argu
self->truncating = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
}
int grib_accessor_class_scale_t::unpack_double(grib_accessor* a, double* val, size_t* len){
int grib_accessor_class_scale_t::unpack_double(grib_accessor* a, double* val, size_t* len)
{
grib_accessor_scale_t* self = (grib_accessor_scale_t*)a;
int ret = 0;
long value = 0;
@ -61,12 +63,14 @@ int grib_accessor_class_scale_t::unpack_double(grib_accessor* a, double* val, si
return ret;
}
int grib_accessor_class_scale_t::pack_long(grib_accessor* a, const long* val, size_t* len){
int grib_accessor_class_scale_t::pack_long(grib_accessor* a, const long* val, size_t* len)
{
const double dval = (double)*val;
return pack_double(a, &dval, len);
}
int grib_accessor_class_scale_t::pack_double(grib_accessor* a, const double* val, size_t* len){
int grib_accessor_class_scale_t::pack_double(grib_accessor* a, const double* val, size_t* len)
{
grib_accessor_scale_t* self = (grib_accessor_scale_t*)a;
int ret = 0;
@ -115,7 +119,8 @@ int grib_accessor_class_scale_t::pack_double(grib_accessor* a, const double* val
return ret;
}
int grib_accessor_class_scale_t::is_missing(grib_accessor* a){
int grib_accessor_class_scale_t::is_missing(grib_accessor* a)
{
grib_accessor_scale_t* self = (grib_accessor_scale_t*)a;
grib_accessor* av = grib_find_accessor(grib_handle_of_accessor(a), self->value);

View File

@ -11,11 +11,12 @@
#include "grib_accessor_class_scale_values.h"
grib_accessor_class_scale_values_t _grib_accessor_class_scale_values{"scale_values"};
grib_accessor_class_scale_values_t _grib_accessor_class_scale_values{ "scale_values" };
grib_accessor_class* grib_accessor_class_scale_values = &_grib_accessor_class_scale_values;
void grib_accessor_class_scale_values_t::init(grib_accessor* a, const long l, grib_arguments* args){
void grib_accessor_class_scale_values_t::init(grib_accessor* a, const long l, grib_arguments* args)
{
grib_accessor_class_double_t::init(a, l, args);
int n = 0;
grib_accessor_scale_values_t* self = (grib_accessor_scale_values_t*)a;
@ -25,14 +26,16 @@ void grib_accessor_class_scale_values_t::init(grib_accessor* a, const long l, gr
a->length = 0;
}
int grib_accessor_class_scale_values_t::unpack_double(grib_accessor* a, double* val, size_t* len){
int ret = 0;
int grib_accessor_class_scale_values_t::unpack_double(grib_accessor* a, double* val, size_t* len)
{
int ret = GRIB_SUCCESS;
*val = 1;
*len = 1;
return ret;
}
int grib_accessor_class_scale_values_t::pack_double(grib_accessor* a, const double* val, size_t* len){
int grib_accessor_class_scale_values_t::pack_double(grib_accessor* a, const double* val, size_t* len)
{
double* values = NULL;
double missingValue = 0;
long missingValuesPresent = 0;

View File

@ -11,24 +11,28 @@
#include "grib_accessor_class_signed.h"
grib_accessor_class_signed_t _grib_accessor_class_signed{"signed"};
grib_accessor_class_signed_t _grib_accessor_class_signed{ "signed" };
grib_accessor_class* grib_accessor_class_signed = &_grib_accessor_class_signed;
void grib_accessor_class_signed_t::init(grib_accessor* a, const long len, grib_arguments* arg){
void grib_accessor_class_signed_t::init(grib_accessor* a, const long len, grib_arguments* arg)
{
grib_accessor_class_long_t::init(a, len, arg);
grib_accessor_signed_t* self = (grib_accessor_signed_t*)a;
long count = 0;
self->arg = arg;
a->value_count(&count); a->length = len * count;
a->value_count(&count);
a->length = len * count;
self->nbytes = len;
Assert(a->length >= 0);
}
void grib_accessor_class_signed_t::dump(grib_accessor* a, grib_dumper* dumper){
void grib_accessor_class_signed_t::dump(grib_accessor* a, grib_dumper* dumper)
{
long rlen = 0;
a->value_count(&rlen); if (rlen == 1)
a->value_count(&rlen);
if (rlen == 1)
grib_dump_long(dumper, a, NULL);
else
grib_dump_values(dumper, a);
@ -42,7 +46,8 @@ static const long ones[] = {
-0x7fffffff,
};
int grib_accessor_class_signed_t::unpack_long(grib_accessor* a, long* val, size_t* len){
int grib_accessor_class_signed_t::unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_signed_t* self = (grib_accessor_signed_t*)a;
unsigned long rlen = 0;
int err = 0;
@ -52,7 +57,8 @@ int grib_accessor_class_signed_t::unpack_long(grib_accessor* a, long* val, size_
long pos = a->offset;
long missing = 0;
err = a->value_count(&count); if (err)
err = a->value_count(&count);
if (err)
return err;
rlen = count;
@ -79,19 +85,21 @@ int grib_accessor_class_signed_t::unpack_long(grib_accessor* a, long* val, size_
return GRIB_SUCCESS;
}
int grib_accessor_class_signed_t::pack_long(grib_accessor* a, const long* val, size_t* len){
int grib_accessor_class_signed_t::pack_long(grib_accessor* a, const long* val, size_t* len)
{
grib_accessor_signed_t* self = (grib_accessor_signed_t*)a;
int ret = 0;
long off = 0;
unsigned long rlen = 0;
int err = 0;
long count = 0;
size_t buflen = 0;
unsigned char* buf = NULL;
unsigned long i = 0;
long missing = 0;
err = a->value_count(&count); if (err)
int err = a->value_count(&count);
if (err)
return err;
rlen = count;
@ -111,12 +119,13 @@ int grib_accessor_class_signed_t::pack_long(grib_accessor* a, const long* val, s
if (missing) {
if (v == GRIB_MISSING_LONG)
v = missing;
} else {
}
else {
// ECC-1605: Check overflow/underflow
const int nbits = self->nbytes * 8;
const long minval = -(1L << (nbits-1)) + 1;
const long maxval = (1L << (nbits-1)) - 1;
//printf(" key=%s: v=%ld (minval=%ld maxval=%ld)\n", a->name, v, minval, maxval);
const long minval = -(1L << (nbits - 1)) + 1;
const long maxval = (1L << (nbits - 1)) - 1;
// printf(" key=%s: v=%ld (minval=%ld maxval=%ld)\n", a->name, v, minval, maxval);
if (v > maxval || v < minval) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"Key \"%s\": Trying to encode value of %ld but the allowable range is %ld to %ld (number of bits=%d)",
@ -156,11 +165,13 @@ int grib_accessor_class_signed_t::pack_long(grib_accessor* a, const long* val, s
return ret;
}
long grib_accessor_class_signed_t::byte_count(grib_accessor* a){
long grib_accessor_class_signed_t::byte_count(grib_accessor* a)
{
return a->length;
}
int grib_accessor_class_signed_t::value_count(grib_accessor* a, long* len){
int grib_accessor_class_signed_t::value_count(grib_accessor* a, long* len)
{
grib_accessor_signed_t* self = (grib_accessor_signed_t*)a;
*len = 0;
if (!self->arg) {
@ -170,19 +181,24 @@ int grib_accessor_class_signed_t::value_count(grib_accessor* a, long* len){
return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len);
}
long grib_accessor_class_signed_t::byte_offset(grib_accessor* a){
long grib_accessor_class_signed_t::byte_offset(grib_accessor* a)
{
return a->offset;
}
void grib_accessor_class_signed_t::update_size(grib_accessor* a, size_t s){
void grib_accessor_class_signed_t::update_size(grib_accessor* a, size_t s)
{
a->length = s;
Assert(a->length >= 0);
}
long grib_accessor_class_signed_t::next_offset(grib_accessor* a){
return a->byte_offset() + a->byte_count();}
long grib_accessor_class_signed_t::next_offset(grib_accessor* a)
{
return a->byte_offset() + a->byte_count();
}
int grib_accessor_class_signed_t::is_missing(grib_accessor* a){
int grib_accessor_class_signed_t::is_missing(grib_accessor* a)
{
int i = 0;
unsigned char ff = 0xff;
unsigned long offset = a->offset;

View File

@ -11,11 +11,12 @@
#include "grib_accessor_class_size.h"
grib_accessor_class_size_t _grib_accessor_class_size{"size"};
grib_accessor_class_size_t _grib_accessor_class_size{ "size" };
grib_accessor_class* grib_accessor_class_size = &_grib_accessor_class_size;
void grib_accessor_class_size_t::init(grib_accessor* a, const long l, grib_arguments* c){
void grib_accessor_class_size_t::init(grib_accessor* a, const long l, grib_arguments* c)
{
grib_accessor_class_long_t::init(a, l, c);
grib_accessor_size_t* self = (grib_accessor_size_t*)a;
self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0);
@ -24,11 +25,12 @@ void grib_accessor_class_size_t::init(grib_accessor* a, const long l, grib_argum
a->length = 0;
}
int grib_accessor_class_size_t::unpack_long(grib_accessor* a, long* val, size_t* len){
int ret = 0;
size_t size = 0;
int grib_accessor_class_size_t::unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_size_t* self = (grib_accessor_size_t*)a;
ret = grib_get_size(grib_handle_of_accessor(a), self->accessor, &size);
size_t size = 0;
int ret = grib_get_size(grib_handle_of_accessor(a), self->accessor, &size);
*val = (long)size;
*len = 1;
return ret;