mirror of https://github.com/ecmwf/eccodes.git
Refactoring
This commit is contained in:
parent
3eaef920ba
commit
d34ac136e1
|
@ -355,11 +355,10 @@ int grib_get_block_length(grib_section* s, size_t* l)
|
|||
*l = s->length;
|
||||
return GRIB_SUCCESS;
|
||||
|
||||
// TODO: Because grib_pack_long takes a SIGNED value, we may have problems
|
||||
// TODO(masn): Because grib_pack_long takes a SIGNED value, we may have problems
|
||||
// if(s->aclength) {
|
||||
// size_t len = 1;
|
||||
// long plen = 0;
|
||||
|
||||
// int ret = grib_unpack_long(s->aclength, &plen, &len);
|
||||
// if(ret == GRIB_SUCCESS && plen != 0)
|
||||
// {
|
||||
|
@ -367,7 +366,6 @@ int grib_get_block_length(grib_section* s, size_t* l)
|
|||
// return GRIB_SUCCESS;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // empty block
|
||||
// if(s->block->first == NULL) {
|
||||
// *l = 0;
|
||||
|
@ -380,7 +378,6 @@ int grib_get_block_length(grib_section* s, size_t* l)
|
|||
// if(s->aclength) {
|
||||
// size_t len = 1;
|
||||
// long plen = *l;
|
||||
|
||||
// int ret = grib_pack_long(s->aclength, &plen, &len);
|
||||
// if(ret != GRIB_SUCCESS)
|
||||
// ;
|
||||
|
|
|
@ -204,31 +204,22 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type);
|
|||
|
||||
#include "grib_api.h"
|
||||
|
||||
#define GRIB_UNKNOWN_VALUE -9999.999
|
||||
#define GRIB_KEY_UNDEF "undef"
|
||||
|
||||
#define GRIB_HANDLE_BIG_ECMWF_GRIB1 1
|
||||
|
||||
#define MAX_ACCESSOR_ATTRIBUTES 20
|
||||
#define MAX_FILE_HANDLES_WITH_MULTI 10
|
||||
#define ACCESSORS_ARRAY_SIZE 5000
|
||||
#define MAX_NUM_CONCEPTS 2000
|
||||
#define MAX_NUM_HASH_ARRAY 2000
|
||||
|
||||
#define GRIB_NAMESPACE 10
|
||||
#define CODES_NAMESPACE 10
|
||||
#define MAX_NAMESPACE_LEN 64
|
||||
|
||||
#define GRIB_MY_BUFFER 0
|
||||
#define GRIB_USER_BUFFER 1
|
||||
#define CODES_MY_BUFFER 0
|
||||
#define CODES_USER_BUFFER 1
|
||||
|
||||
#define GRIB_REAL_MODE4 4
|
||||
#define GRIB_REAL_MODE8 8
|
||||
#define CODES_REAL_MODE8 8
|
||||
|
||||
#define MAX_NUM_SECTIONS 12
|
||||
|
||||
#define GRIB_DISPOSABLE_MEMORY 0
|
||||
#define GRIB_LONG_LASTING_MEMORY 1
|
||||
|
||||
#define GRIB_LOG_PERROR (1 << 10)
|
||||
|
||||
#define GRIB_HASH_ARRAY_TYPE_UNKNOWN 0
|
||||
|
@ -236,17 +227,17 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type);
|
|||
#define GRIB_HASH_ARRAY_TYPE_DOUBLE 2
|
||||
#define GRIB_HASH_ARRAY_TYPE_STRING 3
|
||||
|
||||
#define CODES_GRIB 1
|
||||
#define CODES_BUFR 2
|
||||
#define CODES_GRIB 1
|
||||
#define CODES_BUFR 2
|
||||
#define CODES_METAR 3
|
||||
#define CODES_GTS 4
|
||||
#define CODES_GTS 4
|
||||
|
||||
#define CODES_BUFR_UNPACK_STRUCTURE 0
|
||||
#define CODES_BUFR_UNPACK_FLAT 1
|
||||
#define CODES_BUFR_NEW_DATA 2
|
||||
#define CODES_BUFR_UNPACK_FLAT 1
|
||||
#define CODES_BUFR_NEW_DATA 2
|
||||
|
||||
#define MAX_SMART_TABLE_COLUMNS 20
|
||||
#define MAX_CODETABLE_ENTRIES 65536
|
||||
#define MAX_CODETABLE_ENTRIES 65536
|
||||
|
||||
/* ACCESSOR COMPARE FLAGS */
|
||||
#define GRIB_COMPARE_NAMES (1 << 0)
|
||||
|
@ -327,7 +318,6 @@ typedef void (*accessor_resize_proc)(grib_accessor*, size_t);
|
|||
typedef grib_accessor* (*accessor_next_proc)(grib_accessor*, int);
|
||||
typedef grib_section* (*accessor_sub_section_proc)(grib_accessor*);
|
||||
|
||||
|
||||
typedef int (*accessor_pack_missing_proc)(grib_accessor*);
|
||||
typedef int (*accessor_pack_is_missing_proc)(grib_accessor*);
|
||||
typedef int (*accessor_pack_long_proc)(grib_accessor*, const long*, size_t* len);
|
||||
|
@ -363,7 +353,6 @@ typedef int (*grib_binop_string_proc)(char*, char*);
|
|||
typedef struct second_order_packed second_order_packed;
|
||||
typedef void grib_expression_visit_proc(void* udata, grib_expression* e);
|
||||
|
||||
|
||||
struct grib_key_value_list
|
||||
{
|
||||
const char* name;
|
||||
|
@ -378,7 +367,6 @@ struct grib_key_value_list
|
|||
grib_key_value_list* next;
|
||||
};
|
||||
|
||||
|
||||
struct second_order_packed
|
||||
{
|
||||
unsigned long nbits_per_widths;
|
||||
|
@ -403,9 +391,7 @@ struct grib_packer
|
|||
grib_unpack_proc unpack; /** < unpacking procedure */
|
||||
};
|
||||
|
||||
|
||||
/* --------------- */
|
||||
|
||||
typedef struct grib_loader grib_loader;
|
||||
typedef int (*grib_loader_init_accessor_proc)(grib_loader*, grib_accessor*, grib_arguments*);
|
||||
typedef int (*grib_loader_lookup_long_proc)(grib_context*, grib_loader*, const char* name, long* value);
|
||||
|
@ -451,7 +437,6 @@ struct grib_accessors_list
|
|||
grib_accessors_list* last;
|
||||
};
|
||||
|
||||
|
||||
typedef int (*action_create_accessors_handle_proc)(grib_section* p, grib_action* a, grib_loader* h);
|
||||
typedef int (*action_notify_change_proc)(grib_action* a, grib_accessor* observer, grib_accessor* observed);
|
||||
|
||||
|
@ -490,7 +475,6 @@ struct grib_action_class
|
|||
action_execute_proc execute;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* a buffer
|
||||
* Structure containing the data of a message
|
||||
|
@ -590,7 +574,6 @@ struct grib_section
|
|||
size_t padding;
|
||||
};
|
||||
|
||||
|
||||
struct grib_iterator_class
|
||||
{
|
||||
grib_iterator_class** super;
|
||||
|
@ -625,10 +608,6 @@ struct grib_nearest_class
|
|||
};
|
||||
|
||||
/* --------------- */
|
||||
/* --------------- */
|
||||
typedef void (*search_all_callback_proc)(grib_accessor*, void* data);
|
||||
/* --------------- */
|
||||
|
||||
typedef int (*dumper_init_proc)(grib_dumper*);
|
||||
typedef void (*dumper_dump_proc)(grib_dumper*, grib_accessor*, const char* comment);
|
||||
typedef void (*dumper_dump_section_proc)(grib_dumper*, grib_accessor*, grib_block_of_accessors* block);
|
||||
|
@ -713,7 +692,6 @@ typedef struct grib_trie_with_rank_list grib_trie_with_rank_list;
|
|||
typedef struct grib_trie_with_rank grib_trie_with_rank;
|
||||
typedef struct grib_itrie grib_itrie;
|
||||
|
||||
|
||||
/* Dynamic array of strings */
|
||||
struct grib_sarray
|
||||
{
|
||||
|
@ -850,7 +828,6 @@ struct codes_condition
|
|||
double rightDouble;
|
||||
};
|
||||
|
||||
|
||||
void codes_assertion_failed(const char* message, const char* file, int line);
|
||||
|
||||
#define MAX_SET_VALUES 10
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
void grib_get_buffer_ownership(const grib_context* c, grib_buffer* b)
|
||||
{
|
||||
unsigned char* newdata;
|
||||
if (b->property == GRIB_MY_BUFFER)
|
||||
if (b->property == CODES_MY_BUFFER)
|
||||
return;
|
||||
|
||||
newdata = (unsigned char*)grib_context_malloc(c, b->length);
|
||||
memcpy(newdata, b->data, b->length);
|
||||
b->data = newdata;
|
||||
b->property = GRIB_MY_BUFFER;
|
||||
b->property = CODES_MY_BUFFER;
|
||||
}
|
||||
|
||||
grib_buffer* grib_create_growable_buffer(const grib_context* c)
|
||||
|
@ -34,7 +34,7 @@ grib_buffer* grib_create_growable_buffer(const grib_context* c)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
b->property = GRIB_MY_BUFFER;
|
||||
b->property = CODES_MY_BUFFER;
|
||||
b->length = 10240;
|
||||
b->ulength = 0;
|
||||
b->data = (unsigned char*)grib_context_malloc_clear(c, b->length);
|
||||
|
@ -58,7 +58,7 @@ grib_buffer* grib_new_buffer(const grib_context* c, const unsigned char* data, s
|
|||
return NULL;
|
||||
}
|
||||
|
||||
b->property = GRIB_USER_BUFFER;
|
||||
b->property = CODES_USER_BUFFER;
|
||||
b->length = buflen;
|
||||
b->ulength = buflen;
|
||||
b->ulength_bits = buflen * 8;
|
||||
|
@ -69,7 +69,7 @@ grib_buffer* grib_new_buffer(const grib_context* c, const unsigned char* data, s
|
|||
|
||||
void grib_buffer_delete(const grib_context* c, grib_buffer* b)
|
||||
{
|
||||
if (b->property == GRIB_MY_BUFFER)
|
||||
if (b->property == CODES_MY_BUFFER)
|
||||
grib_context_free(c, b->data);
|
||||
b->length = 0;
|
||||
b->ulength = 0;
|
||||
|
|
|
@ -292,7 +292,7 @@ static grib_context default_grib_context = {
|
|||
0, /* grib_concept_path */
|
||||
0, /* grib_reader */
|
||||
0, /* user data */
|
||||
GRIB_REAL_MODE8, /* real mode for fortran */
|
||||
CODES_REAL_MODE8, /* real mode for fortran */
|
||||
|
||||
#if MANAGE_MEM
|
||||
&grib_transient_free, /* free_mem */
|
||||
|
|
|
@ -196,7 +196,7 @@ static grib_handle* grib_handle_create(grib_handle* gl, grib_context* c, const v
|
|||
return NULL;
|
||||
}
|
||||
|
||||
gl->buffer->property = GRIB_USER_BUFFER;
|
||||
gl->buffer->property = CODES_USER_BUFFER;
|
||||
|
||||
next = gl->context->grib_reader->first->root;
|
||||
while (next) {
|
||||
|
@ -401,7 +401,7 @@ grib_handle* grib_handle_new_from_message_copy(grib_context* c, const void* data
|
|||
memcpy(copy, data, size);
|
||||
|
||||
g = grib_handle_new_from_message(c, copy, size);
|
||||
g->buffer->property = GRIB_MY_BUFFER;
|
||||
g->buffer->property = CODES_MY_BUFFER;
|
||||
|
||||
return g;
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ grib_handle* grib_handle_new_from_partial_message_copy(grib_context* c, const vo
|
|||
memcpy(copy, data, size);
|
||||
|
||||
g = grib_handle_new_from_partial_message(c, copy, size);
|
||||
g->buffer->property = GRIB_MY_BUFFER;
|
||||
g->buffer->property = CODES_MY_BUFFER;
|
||||
|
||||
return g;
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ static grib_handle* grib_handle_new_multi(grib_context* c, unsigned char** data,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
gl->buffer->property = GRIB_MY_BUFFER;
|
||||
gl->buffer->property = CODES_MY_BUFFER;
|
||||
grib_context_increment_handle_file_count(c);
|
||||
grib_context_increment_handle_total_count(c);
|
||||
|
||||
|
@ -764,7 +764,7 @@ static grib_handle* grib_handle_new_from_file_multi(grib_context* c, FILE* f, in
|
|||
}
|
||||
|
||||
gl->offset = gm->offset;
|
||||
gl->buffer->property = GRIB_MY_BUFFER;
|
||||
gl->buffer->property = CODES_MY_BUFFER;
|
||||
grib_context_increment_handle_file_count(c);
|
||||
grib_context_increment_handle_total_count(c);
|
||||
|
||||
|
@ -844,7 +844,7 @@ grib_handle* gts_new_from_file(grib_context* c, FILE* f, int* error)
|
|||
}
|
||||
|
||||
gl->offset = offset;
|
||||
gl->buffer->property = GRIB_MY_BUFFER;
|
||||
gl->buffer->property = CODES_MY_BUFFER;
|
||||
gl->product_kind = PRODUCT_GTS;
|
||||
grib_context_increment_handle_file_count(c);
|
||||
grib_context_increment_handle_total_count(c);
|
||||
|
@ -885,7 +885,7 @@ grib_handle* taf_new_from_file(grib_context* c, FILE* f, int* error)
|
|||
}
|
||||
|
||||
gl->offset = offset;
|
||||
gl->buffer->property = GRIB_MY_BUFFER;
|
||||
gl->buffer->property = CODES_MY_BUFFER;
|
||||
gl->product_kind = PRODUCT_TAF;
|
||||
grib_context_increment_handle_file_count(c);
|
||||
grib_context_increment_handle_total_count(c);
|
||||
|
@ -926,7 +926,7 @@ grib_handle* metar_new_from_file(grib_context* c, FILE* f, int* error)
|
|||
}
|
||||
|
||||
gl->offset = offset;
|
||||
gl->buffer->property = GRIB_MY_BUFFER;
|
||||
gl->buffer->property = CODES_MY_BUFFER;
|
||||
gl->product_kind = PRODUCT_METAR;
|
||||
grib_context_increment_handle_file_count(c);
|
||||
grib_context_increment_handle_total_count(c);
|
||||
|
@ -994,7 +994,7 @@ grib_handle* bufr_new_from_file(grib_context* c, FILE* f, int* error)
|
|||
}
|
||||
|
||||
gl->offset = offset;
|
||||
gl->buffer->property = GRIB_MY_BUFFER;
|
||||
gl->buffer->property = CODES_MY_BUFFER;
|
||||
gl->product_kind = PRODUCT_BUFR;
|
||||
grib_context_increment_handle_file_count(c);
|
||||
grib_context_increment_handle_total_count(c);
|
||||
|
@ -1046,7 +1046,7 @@ grib_handle* any_new_from_file(grib_context* c, FILE* f, int* error)
|
|||
}
|
||||
|
||||
gl->offset = offset;
|
||||
gl->buffer->property = GRIB_MY_BUFFER;
|
||||
gl->buffer->property = CODES_MY_BUFFER;
|
||||
gl->product_kind = PRODUCT_ANY;
|
||||
grib_context_increment_handle_file_count(c);
|
||||
grib_context_increment_handle_total_count(c);
|
||||
|
@ -1119,7 +1119,7 @@ static grib_handle* grib_handle_new_from_file_no_multi(grib_context* c, FILE* f,
|
|||
}
|
||||
|
||||
gl->offset = offset;
|
||||
gl->buffer->property = GRIB_MY_BUFFER;
|
||||
gl->buffer->property = CODES_MY_BUFFER;
|
||||
|
||||
grib_context_increment_handle_file_count(c);
|
||||
grib_context_increment_handle_total_count(c);
|
||||
|
@ -1415,7 +1415,7 @@ int grib_get_message_headers(grib_handle* h, const void** msg, size_t* size)
|
|||
// grib_handle_delete(h);
|
||||
// return NULL;
|
||||
// }
|
||||
// h->buffer->property = GRIB_USER_BUFFER;
|
||||
// h->buffer->property = CODES_USER_BUFFER;
|
||||
// h->header_mode = 1;
|
||||
// return h;
|
||||
// }
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#define NULL_MARKER 0
|
||||
#define NOT_NULL_MARKER 255
|
||||
|
||||
#define GRIB_KEY_UNDEF "undef"
|
||||
|
||||
/* #if GRIB_PTHREADS */
|
||||
// static pthread_once_t once = PTHREAD_ONCE_INIT;
|
||||
// static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
|
|
@ -180,7 +180,7 @@ static int read_GRIB(reader* r, int no_alloc)
|
|||
if (!tmp)
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
buf = grib_new_buffer(c, tmp, buflen);
|
||||
buf->property = GRIB_MY_BUFFER;
|
||||
buf->property = CODES_MY_BUFFER;
|
||||
|
||||
tmp[i++] = 'G';
|
||||
tmp[i++] = 'R';
|
||||
|
@ -721,7 +721,7 @@ static int read_BUFR(reader* r, int no_alloc)
|
|||
if (!tmp)
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
buf = grib_new_buffer(c, tmp, buflen);
|
||||
buf->property = GRIB_MY_BUFFER;
|
||||
buf->property = CODES_MY_BUFFER;
|
||||
r->offset = r->tell(r->read_data) - 4;
|
||||
|
||||
tmp[i++] = 'B';
|
||||
|
|
|
@ -114,7 +114,7 @@ static grib_handle* grib_sections_copy_internal(grib_handle* hfrom, grib_handle*
|
|||
h = grib_handle_new_from_message(hfrom->context, buffer, totalLength);
|
||||
|
||||
/*to allow free of buffer*/
|
||||
h->buffer->property = GRIB_MY_BUFFER;
|
||||
h->buffer->property = CODES_MY_BUFFER;
|
||||
|
||||
switch (edition) {
|
||||
case 1:
|
||||
|
@ -1810,7 +1810,7 @@ int parse_keyval_string(const char* grib_tool,
|
|||
if (*p == ':') {
|
||||
values[i].type = grib_type_to_int(*(p + 1));
|
||||
if (*(p + 1) == 'n')
|
||||
values[i].type = GRIB_NAMESPACE;
|
||||
values[i].type = CODES_NAMESPACE;
|
||||
*p = '\0';
|
||||
p++;
|
||||
}
|
||||
|
|
|
@ -1623,7 +1623,7 @@ static int grib_get_key_value(grib_handle* h, grib_key_value_list* kv)
|
|||
err = grib_get_bytes(h, kv->name, (unsigned char*)kv->string_value, &size);
|
||||
kv->error = err;
|
||||
break;
|
||||
case GRIB_NAMESPACE:
|
||||
case CODES_NAMESPACE:
|
||||
iter = grib_keys_iterator_new(h, 0, kv->name);
|
||||
list = (grib_key_value_list*)grib_context_malloc_clear(h->context, sizeof(grib_key_value_list));
|
||||
kv->namespace_value = list;
|
||||
|
@ -1672,7 +1672,7 @@ void grib_key_value_list_delete(grib_context* c, grib_key_value_list* kvl)
|
|||
grib_key_value_list* p = NULL;
|
||||
while (next) {
|
||||
p = next->next;
|
||||
if (next->type == GRIB_NAMESPACE)
|
||||
if (next->type == CODES_NAMESPACE)
|
||||
grib_key_value_list_delete(c, next->namespace_value);
|
||||
|
||||
grib_clean_key_value(c, next);
|
||||
|
|
|
@ -1344,7 +1344,7 @@ static int compare_handles(grib_handle* handle1, grib_handle* handle2, grib_runt
|
|||
for (i = 0; i < options->compare_count; i++) {
|
||||
if (blocklisted(options->compare[i].name))
|
||||
continue;
|
||||
if (options->compare[i].type == GRIB_NAMESPACE) {
|
||||
if (options->compare[i].type == CODES_NAMESPACE) {
|
||||
iter = grib_keys_iterator_new(handle1, 0, options->compare[i].name);
|
||||
if (!iter) {
|
||||
grib_context_log(handle1->context, GRIB_LOG_ERROR, "unable to get iterator");
|
||||
|
@ -1406,7 +1406,7 @@ static int compare_handles(grib_handle* handle1, grib_handle* handle2, grib_runt
|
|||
for (i = 0; i < options->compare_count; i++) {
|
||||
if (blocklisted(name))
|
||||
continue;
|
||||
if (options->compare[i].type == GRIB_NAMESPACE) {
|
||||
if (options->compare[i].type == CODES_NAMESPACE) {
|
||||
iter = grib_keys_iterator_new(handle1, 0, options->compare[i].name);
|
||||
if (!iter) {
|
||||
grib_context_log(handle1->context, GRIB_LOG_ERROR,
|
||||
|
|
|
@ -1207,7 +1207,7 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
|
|||
for (i = 0; i < options->compare_count; i++) {
|
||||
if (blocklisted(options->compare[i].name))
|
||||
continue;
|
||||
if (options->compare[i].type == GRIB_NAMESPACE) {
|
||||
if (options->compare[i].type == CODES_NAMESPACE) {
|
||||
int num_keys_in_namespace = 0;
|
||||
iter = grib_keys_iterator_new(h1, 0, options->compare[i].name);
|
||||
if (!iter) {
|
||||
|
@ -1265,7 +1265,7 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
|
|||
for (i = 0; i < options->compare_count; i++) {
|
||||
if (blocklisted(options->compare[i].name))
|
||||
continue;
|
||||
if (options->compare[i].type == GRIB_NAMESPACE) {
|
||||
if (options->compare[i].type == CODES_NAMESPACE) {
|
||||
iter = grib_keys_iterator_new(h1, 0, options->compare[i].name);
|
||||
if (!iter) {
|
||||
printf("ERROR: unable to get iterator for %s\n", options->compare[i].name);
|
||||
|
|
|
@ -386,7 +386,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g
|
|||
if (grib_options_on("e")) {
|
||||
for (i = 0; i < names_count; i++) {
|
||||
options->compare[i + options->compare_count].name = names[i];
|
||||
options->compare[i + options->compare_count].type = GRIB_NAMESPACE;
|
||||
options->compare[i + options->compare_count].type = CODES_NAMESPACE;
|
||||
}
|
||||
options->compare_count += names_count;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,6 @@ int lastPrint = 0;
|
|||
int force = 0;
|
||||
double maxAbsoluteError = 1e-19;
|
||||
int onlyListed = 1;
|
||||
int headerMode = 0;
|
||||
int morein1 = 0;
|
||||
int morein2 = 0;
|
||||
int listFromCommandLine = 0;
|
||||
|
@ -185,11 +184,6 @@ int grib_tool_init(grib_runtime_options* options)
|
|||
else
|
||||
onlyListed = 1;
|
||||
|
||||
if (grib_options_on("H"))
|
||||
headerMode = 1;
|
||||
else
|
||||
headerMode = 0;
|
||||
|
||||
if (grib_options_on("H") && grib_options_on("c:")) {
|
||||
printf("Error: -H and -c options are incompatible. Choose one of the two please.\n");
|
||||
exit(1);
|
||||
|
@ -730,8 +724,8 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
|
|||
grib_keys_iterator* iter = NULL;
|
||||
const char* name = NULL;
|
||||
|
||||
/* mask only if no -c option or headerMode (-H)*/
|
||||
if (blocklist && (!listFromCommandLine || headerMode)) {
|
||||
/* mask only if no -c option */
|
||||
if (blocklist && !listFromCommandLine) {
|
||||
grib_string_list* nextb = blocklist;
|
||||
while (nextb) {
|
||||
grib_clear(h1, nextb->value);
|
||||
|
@ -740,50 +734,11 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
|
|||
}
|
||||
}
|
||||
|
||||
if (headerMode) {
|
||||
const void *msg1 = NULL, *msg2 = NULL;
|
||||
size_t size1 = 0, size2 = 0;
|
||||
grib_handle *h11, *h22;
|
||||
GRIB_CHECK_NOLINE(grib_get_message_headers(h1, &msg1, &size1), 0);
|
||||
GRIB_CHECK_NOLINE(grib_get_message_headers(h2, &msg2, &size2), 0);
|
||||
if (size1 == size2 && !memcmp(msg1, msg2, size1))
|
||||
return 0;
|
||||
|
||||
err = 0;
|
||||
h11 = grib_handle_new_from_partial_message(h1->context, msg1, size1);
|
||||
h22 = grib_handle_new_from_partial_message(h1->context, msg2, size2);
|
||||
|
||||
iter = grib_keys_iterator_new(h11,
|
||||
GRIB_KEYS_ITERATOR_SKIP_COMPUTED, NULL);
|
||||
|
||||
if (!iter) {
|
||||
printf("ERROR: unable to get iterator\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (grib_keys_iterator_next(iter)) {
|
||||
name = grib_keys_iterator_get_name(iter);
|
||||
/*printf("----- comparing %s\n",name);*/
|
||||
|
||||
if (blocklisted(name))
|
||||
continue;
|
||||
if (compare_values(options, h11, h22, name, GRIB_TYPE_UNDEFINED)) {
|
||||
err++;
|
||||
write_messages(h11, h22);
|
||||
}
|
||||
}
|
||||
|
||||
grib_keys_iterator_delete(iter);
|
||||
grib_handle_delete(h11);
|
||||
grib_handle_delete(h22);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (listFromCommandLine && onlyListed) {
|
||||
for (i = 0; i < options->compare_count; i++) {
|
||||
if (blocklisted((char*)options->compare[i].name))
|
||||
continue;
|
||||
if (options->compare[i].type == GRIB_NAMESPACE) {
|
||||
if (options->compare[i].type == CODES_NAMESPACE) {
|
||||
iter = grib_keys_iterator_new(h1, 0, options->compare[i].name);
|
||||
if (!iter) {
|
||||
printf("ERROR: unable to get iterator\n");
|
||||
|
@ -844,7 +799,7 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
|
|||
for (i = 0; i < options->compare_count; i++) {
|
||||
if (blocklisted(name))
|
||||
continue;
|
||||
if (options->compare[i].type == GRIB_NAMESPACE) {
|
||||
if (options->compare[i].type == CODES_NAMESPACE) {
|
||||
iter = grib_keys_iterator_new(h1, 0, options->compare[i].name);
|
||||
if (!iter) {
|
||||
printf("ERROR: unable to get iterator for %s\n", options->compare[i].name);
|
||||
|
|
|
@ -919,7 +919,7 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
|
|||
for (i = 0; i < options->compare_count; i++) {
|
||||
if (blocklisted((char*)options->compare[i].name))
|
||||
continue;
|
||||
if (options->compare[i].type == GRIB_NAMESPACE) {
|
||||
if (options->compare[i].type == CODES_NAMESPACE) {
|
||||
iter = grib_keys_iterator_new(h1, 0, options->compare[i].name);
|
||||
if (!iter) {
|
||||
printf("ERROR: unable to get iterator\n");
|
||||
|
@ -960,7 +960,7 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
|
|||
for (i = 0; i < options->compare_count; i++) {
|
||||
if (blocklisted(name))
|
||||
continue;
|
||||
if (options->compare[i].type == GRIB_NAMESPACE) {
|
||||
if (options->compare[i].type == CODES_NAMESPACE) {
|
||||
iter = grib_keys_iterator_new(h1, 0, options->compare[i].name);
|
||||
if (!iter) {
|
||||
printf("ERROR: unable to get iterator for %s\n", options->compare[i].name);
|
||||
|
|
Loading…
Reference in New Issue