1 /* 2 * (C) Copyright 2005- ECMWF. 3 * 4 * This software is licensed under the terms of the Apache Licence Version 2.0 5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 6 * 7 * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by 8 * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. 9 */ 10 11 /** 12 include private headers used for all internal functions of 13 ecCodes, not seen by the user of the API 14 */ 15 16 #ifndef grib_api_internal_H 17 #define grib_api_internal_H 18 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /* cmake config header */ 25 #ifdef HAVE_ECCODES_CONFIG_H 26 #include "eccodes_config.h" 27 #endif 28 29 /* autoconf config header */ 30 #ifdef HAVE_CONFIG_H 31 #include "config.h" 32 #ifdef _LARGE_FILES 33 #undef _LARGE_FILE_API 34 #endif 35 #endif 36 37 #ifndef GRIB_INLINE 38 #define GRIB_INLINE 39 #endif 40 41 #if IS_BIG_ENDIAN 42 #if GRIB_MEM_ALIGN 43 #define FAST_BIG_ENDIAN 0 44 #else 45 #define FAST_BIG_ENDIAN 1 46 #endif 47 #endif 48 49 #if IEEE_BE 50 #define IEEE 51 #else 52 #if IEEE_LE 53 #define IEEE 54 #endif 55 #endif 56 57 #include <stdio.h> 58 #include <sys/types.h> 59 #include <sys/stat.h> 60 61 #include "eccodes_windef.h" 62 63 #ifndef ECCODES_ON_WINDOWS 64 #include <dirent.h> 65 #include <unistd.h> 66 #include <inttypes.h> 67 #define ecc_snprintf snprintf 68 #else 69 #include <direct.h> 70 #include <io.h> 71 72 /* Replace C99/Unix rint() for Windows Visual C++ (only before VC++ 2013 versions) */ 73 #if defined _MSC_VER && _MSC_VER < 1800 74 double rint(double x); 75 #endif 76 77 #ifndef S_ISREG 78 #define S_ISREG(mode) (mode & S_IFREG) 79 #endif 80 81 #ifndef S_ISDIR 82 #define S_ISDIR(mode) (mode & S_IFDIR) 83 #endif 84 85 #ifndef M_PI 86 #define M_PI 3.14159265358979323846 87 #endif 88 89 #define R_OK 04 /* Needed for Windows */ 90 91 #ifndef F_OK 92 #define F_OK 0 93 #endif 94 95 #define mkdir(dirname, mode) _mkdir(dirname) 96 97 #ifdef _MSC_VER 98 #define access(path, mode) _access(path, mode) 99 #define chmod(path, mode) _chmod(path, mode) 100 #define strdup(str) _strdup(str) 101 #endif 102 103 #define ecc_snprintf _snprintf 104 105 #endif 106 107 108 #include <limits.h> 109 #include <errno.h> 110 #include <stdlib.h> 111 #include <ctype.h> 112 113 114 #ifdef HAVE_STRING_H 115 #include <string.h> 116 #else 117 #include <strings.h> 118 #endif 119 120 #if GRIB_LINUX_PTHREADS 121 extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type); 122 #endif 123 124 #if GRIB_PTHREADS 125 #include <pthread.h> 126 #define GRIB_MUTEX_INIT_ONCE(a, b) pthread_once(a, b); 127 #define GRIB_MUTEX_LOCK(a) pthread_mutex_lock(a); 128 #define GRIB_MUTEX_UNLOCK(a) pthread_mutex_unlock(a); 129 /* 130 #define GRIB_MUTEX_LOCK(a) {pthread_mutex_lock(a); printf("MUTEX LOCK %p %s line %d\n",(void*)a,__FILE__,__LINE__);} 131 #define GRIB_MUTEX_UNLOCK(a) {pthread_mutex_unlock(a);printf("MUTEX UNLOCK %p %s line %d\n",(void*)a,__FILE__,__LINE__);} 132 */ 133 #elif GRIB_OMP_THREADS 134 #include <omp.h> 135 #ifdef _MSC_VER 136 #define GRIB_OMP_CRITICAL(a) __pragma(omp critical(a)) 137 #else 138 #define GRIB_OMP_STR(a) #a 139 #define GRIB_OMP_XSTR(a) GRIB_OMP_STR(a) 140 #define GRIB_OMP_CRITICAL(a) _Pragma(GRIB_OMP_XSTR(omp critical(a))) 141 #endif 142 #define GRIB_MUTEX_INIT_ONCE(a, b) (*(b))(); 143 #define GRIB_MUTEX_LOCK(a) omp_set_nest_lock(a); 144 #define GRIB_MUTEX_UNLOCK(a) omp_unset_nest_lock(a); 145 #else 146 #define GRIB_MUTEX_INIT_ONCE(a, b) 147 #define GRIB_MUTEX_LOCK(a) 148 #define GRIB_MUTEX_UNLOCK(a) 149 #endif 150 151 #if GRIB_LINUX_PTHREADS 152 /* Note: in newer pthreads PTHREAD_MUTEX_RECURSIVE and PTHREAD_MUTEX_RECURSIVE_NP are enums */ 153 #if !defined(PTHREAD_MUTEX_RECURSIVE) 154 #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP 155 #endif 156 #endif 157 158 159 #ifndef HAVE_FSEEKO 160 #define fseeko fseek 161 #define ftello ftell 162 #endif 163 164 #define Assert(a) \ 165 do { \ 166 if (!(a)) codes_assertion_failed(#a, __FILE__, __LINE__); \ 167 } while (0) 168 169 #ifdef __gnu_hurd__ 170 #define COMPILE_TIME_ASSERT(condition) \ 171 extern int compile_time_assert[!!(condition)-1] 172 #else 173 /* Compile time assertion - Thanks to Ralf Holly */ 174 #define COMPILE_TIME_ASSERT(condition) \ 175 do { \ 176 enum \ 177 { \ 178 assert_static__ = 1 / (condition) \ 179 }; \ 180 } while (0) 181 #endif 182 183 #ifdef DEBUG 184 #define DebugAssert(a) Assert(a) 185 #define DebugAssertAccess(array, index, size) \ 186 do { \ 187 if (!((index) >= 0 && (index) < (size))) { \ 188 printf("ARRAY ACCESS ERROR: array=%s idx=%ld size=%ld @ %s +%d \n", #array, index, size, __FILE__, __LINE__); \ 189 abort(); \ 190 } \ 191 } while (0) 192 #else 193 #define DebugAssert(a) 194 #define DebugAssertAccess(array, index, size) 195 #endif 196 197 /* Return true if two strings are equal */ 198 #define STR_EQ(a, b) (strcmp((a), (b)) == 0) 199 200 #include "grib_api.h" 201 202 #define GRIB_UNKNOWN_VALUE -9999.999 203 #define GRIB_KEY_UNDEF "undef" 204 205 #define GRIB_HANDLE_BIG_ECMWF_GRIB1 1 206 207 #define MAX_ACCESSOR_ATTRIBUTES 20 208 #define MAX_FILE_HANDLES_WITH_MULTI 10 209 #define ACCESSORS_ARRAY_SIZE 5000 210 #define MAX_NUM_CONCEPTS 2000 211 #define MAX_NUM_HASH_ARRAY 2000 212 213 #define GRIB_NAMESPACE 10 214 #define MAX_NAMESPACE_LEN 64 215 216 #define GRIB_MY_BUFFER 0 217 #define GRIB_USER_BUFFER 1 218 219 #define GRIB_REAL_MODE4 4 220 #define GRIB_REAL_MODE8 8 221 222 #define MAX_NUM_SECTIONS 12 223 224 #define GRIB_DISPOSABLE_MEMORY 0 225 #define GRIB_LONG_LASTING_MEMORY 1 226 227 #define GRIB_LOG_PERROR (1 << 10) 228 229 #define GRIB_HASH_ARRAY_TYPE_UNKNOWN 0 230 #define GRIB_HASH_ARRAY_TYPE_INTEGER 1 231 #define GRIB_HASH_ARRAY_TYPE_DOUBLE 2 232 #define GRIB_HASH_ARRAY_TYPE_STRING 3 233 234 #define CODES_GRIB 1 235 #define CODES_BUFR 2 236 #define CODES_METAR 3 237 #define CODES_GTS 4 238 239 #define CODES_BUFR_UNPACK_STRUCTURE 0 240 #define CODES_BUFR_UNPACK_FLAT 1 241 #define CODES_BUFR_NEW_DATA 2 242 243 #define MAX_SMART_TABLE_COLUMNS 20 244 #define MAX_CODETABLE_ENTRIES 65536 245 246 /* ACCESSOR COMPARE FLAGS */ 247 #define GRIB_COMPARE_NAMES (1 << 0) 248 #define GRIB_COMPARE_TYPES (1 << 1) 249 250 typedef struct grib_expression grib_expression; 251 typedef struct grib_arguments grib_arguments; 252 253 typedef struct grib_action_file grib_action_file; 254 typedef struct grib_action_file_list grib_action_file_list; 255 typedef struct grib_block_of_accessors grib_block_of_accessors; 256 typedef struct grib_buffer grib_buffer; 257 typedef struct grib_accessor_class grib_accessor_class; 258 typedef struct grib_action grib_action; 259 typedef struct grib_action_class grib_action_class; 260 typedef struct grib_section grib_section; 261 typedef struct grib_packer grib_packer; 262 typedef struct grib_codetable grib_codetable; 263 typedef struct grib_smart_table grib_smart_table; 264 265 typedef struct grib_accessor grib_accessor; 266 typedef struct grib_iterator_class grib_iterator_class; 267 typedef struct grib_nearest_class grib_nearest_class; 268 typedef struct grib_box_class grib_box_class; 269 typedef struct grib_dumper grib_dumper; 270 typedef struct grib_dumper_class grib_dumper_class; 271 typedef struct grib_dependency grib_dependency; 272 typedef struct string_feed string_feed; 273 274 typedef struct codes_condition codes_condition; 275 276 /* typedef void (*dynamic_key_proc) (const char*, void*) 277 */ 278 typedef void (*nearest_init_class_proc)(grib_nearest_class*); 279 typedef int (*nearest_init_proc)(grib_nearest* i, grib_handle*, grib_arguments*); 280 281 typedef int (*nearest_find_proc)(grib_nearest* nearest, grib_handle* h, 282 double inlat, double inlon, 283 unsigned long flags, double* outlats, 284 double* outlons, double* values, 285 double* distances, int* indexes, size_t* len); 286 typedef int (*nearest_destroy_proc)(grib_nearest* nearest); 287 288 typedef void (*box_init_class_proc)(grib_box_class*); 289 typedef int (*box_destroy_proc)(grib_box*); 290 typedef int (*box_init_proc)(grib_box*, grib_handle*, grib_arguments*); 291 typedef grib_points* (*box_get_points_proc)(grib_box*, double, double, double, double, int*); 292 293 typedef void (*iterator_init_class_proc)(grib_iterator_class*); 294 typedef int (*iterator_init_proc)(grib_iterator* i, grib_handle*, grib_arguments*); 295 296 typedef int (*iterator_next_proc)(grib_iterator* i, double* lat, double* lon, double* val); 297 typedef int (*iterator_previous_proc)(grib_iterator* i, double* lat, double* lon, double* val); 298 typedef int (*iterator_reset_proc)(grib_iterator* i); 299 typedef int (*iterator_destroy_proc)(grib_iterator* i); 300 typedef long (*iterator_has_next_proc)(grib_iterator* i); 301 302 typedef int (*grib_pack_proc)(grib_handle* h, const double* in, size_t inlen, void* out, size_t* outlen); 303 typedef int (*grib_unpack_proc)(grib_handle* h, const void* in, size_t inlen, double* out, size_t* outlen); 304 305 306 typedef void (*accessor_destroy_proc)(grib_context*, grib_accessor*); 307 308 typedef int (*accessor_unpack_long_proc)(grib_accessor*, long*, size_t* len); 309 typedef int (*accessor_unpack_double_proc)(grib_accessor*, double*, size_t* len); 310 typedef int (*accessor_unpack_double_element_proc)(grib_accessor*, size_t, double*); 311 typedef int (*accessor_unpack_double_subarray_proc)(grib_accessor*, double*, size_t, size_t); 312 typedef int (*accessor_unpack_string_proc)(grib_accessor*, char*, size_t* len); 313 typedef int (*accessor_unpack_string_array_proc)(grib_accessor*, char**, size_t* len); 314 typedef int (*accessor_unpack_bytes_proc)(grib_accessor*, unsigned char*, size_t* len); 315 typedef int (*accessor_get_native_type_proc)(grib_accessor*); 316 typedef int (*accessor_notify_change_proc)(grib_accessor*, grib_accessor*); 317 typedef void (*accessor_update_size_proc)(grib_accessor*, size_t); 318 typedef size_t (*accessor_preferred_size_proc)(grib_accessor*, int); 319 typedef void (*accessor_resize_proc)(grib_accessor*, size_t); 320 321 typedef grib_accessor* (*accessor_next_proc)(grib_accessor*, int); 322 typedef grib_section* (*accessor_sub_section_proc)(grib_accessor*); 323 324 325 typedef int (*accessor_pack_missing_proc)(grib_accessor*); 326 typedef int (*accessor_pack_is_missing_proc)(grib_accessor*); 327 typedef int (*accessor_pack_long_proc)(grib_accessor*, const long*, size_t* len); 328 typedef int (*accessor_pack_double_proc)(grib_accessor*, const double*, size_t* len); 329 typedef int (*accessor_pack_string_proc)(grib_accessor*, const char*, size_t* len); 330 typedef int (*accessor_pack_string_array_proc)(grib_accessor*, const char**, size_t* len); 331 typedef int (*accessor_pack_bytes_proc)(grib_accessor*, const unsigned char*, size_t* len); 332 typedef int (*accessor_pack_expression_proc)(grib_accessor*, grib_expression*); 333 typedef int (*accessor_clear_proc)(grib_accessor*); 334 typedef grib_accessor* (*accessor_clone_proc)(grib_accessor*, grib_section*, int*); 335 336 typedef void (*accessor_init_class_proc)(grib_accessor_class*); 337 338 typedef int (*accessor_compare_proc)(grib_accessor*, grib_accessor*); 339 typedef size_t (*accessor_string_proc)(grib_accessor*); 340 typedef int (*accessor_value_with_ret_proc)(grib_accessor*, long*); 341 typedef long (*accessor_value_proc)(grib_accessor*); 342 typedef void (*accessor_dump_proc)(grib_accessor*, grib_dumper*); 343 typedef void (*accessor_init_proc)(grib_accessor*, const long len, grib_arguments*); 344 typedef void (*accessor_post_init_proc)(grib_accessor*); 345 346 typedef int (*accessor_nearest_proc)(grib_accessor*, double, double*); 347 348 typedef long (*grib_binop_long_proc)(long, long); 349 typedef long (*grib_unop_long_proc)(long); 350 351 typedef double (*grib_binop_double_proc)(double, double); 352 typedef double (*grib_unop_double_proc)(double); 353 354 typedef int (*grib_binop_string_proc)(char*, char*); 355 356 typedef struct second_order_packed second_order_packed; 357 typedef void grib_expression_visit_proc(void* udata, grib_expression* e); 358 359 360 struct grib_key_value_list 361 { 362 const char* name; 363 int type; 364 int size; 365 long* long_value; 366 double* double_value; 367 grib_key_value_list* namespace_value; 368 char* string_value; 369 int has_value; 370 int error; 371 grib_key_value_list* next; 372 }; 373 374 375 struct second_order_packed 376 { 377 unsigned long nbits_per_widths; 378 unsigned long nbits_per_group_size; 379 size_t size_of_group_array; 380 size_t packed_byte_count; 381 unsigned long* array_of_group_size; 382 unsigned long* array_of_group_width; 383 long* array_of_group_refs; 384 }; 385 386 /** 387 * an grib_compression 388 * Structure supporting the packing and unpacking procedures 389 * 390 * @see grib_action_create_data 391 */ 392 struct grib_packer 393 { 394 const char* name; 395 grib_pack_proc pack; /** < packing procedure */ 396 grib_unpack_proc unpack; /** < unpacking procedure */ 397 }; 398 399 400 /* --------------- */ 401 402 typedef struct grib_loader grib_loader; 403 typedef int (*grib_loader_init_accessor_proc)(grib_loader*, grib_accessor*, grib_arguments*); 404 typedef int (*grib_loader_lookup_long_proc)(grib_context*, grib_loader*, const char* name, long* value); 405 406 struct grib_loader 407 { 408 void* data; 409 grib_loader_init_accessor_proc init_accessor; 410 grib_loader_lookup_long_proc lookup_long; 411 int list_is_resized; /** will be true if we resize a list */ 412 int changing_edition; 413 }; 414 415 /** 416 * an action 417 * Structure supporting the creation of accessor, resulting of a statement during a definition file parsing 418 * 419 * @see grib_action_class 420 */ 421 struct grib_action 422 { 423 char* name; /** name of the definition statement */ 424 char* op; /** operator of the definition statement */ 425 char* name_space; /** namespace of the definition statement */ 426 grib_action* next; /** next action in the list */ 427 grib_action_class* cclass; /** link to the structure containing a specific behaviour */ 428 grib_context* context; /** Context */ 429 unsigned long flags; 430 char* defaultkey; /** name of the key used as default if not found */ 431 grib_arguments* default_value; /** default expression as in .def file */ 432 char* set; 433 char* debug_info; /** purely for debugging and tracing */ 434 }; 435 436 typedef struct grib_accessors_list grib_accessors_list; 437 438 struct grib_accessors_list 439 { 440 grib_accessor* accessor; 441 int rank; 442 grib_accessors_list* next; 443 grib_accessors_list* prev; 444 grib_accessors_list* last; 445 }; 446 447 448 typedef int (*action_create_accessors_handle_proc)(grib_section* p, grib_action* a, grib_loader* h); 449 typedef int (*action_notify_change_proc)(grib_action* a, grib_accessor* observer, grib_accessor* observed); 450 451 typedef void (*grib_dump_proc)(grib_action*, FILE*, int); 452 typedef void (*grib_xref_proc)(grib_action*, FILE*, const char*); 453 typedef void (*action_init_class_proc)(grib_action_class* a); 454 typedef void (*action_init_proc)(grib_action* a); 455 typedef void (*action_destroy_proc)(grib_context* context, grib_action* a); 456 typedef grib_action* (*action_reparse_proc)(grib_action* a, grib_accessor*, int*); 457 typedef int (*action_execute_proc)(grib_action* a, grib_handle*); 458 459 /** 460 * an action_class 461 * Structure supporting the specific behaviour of an action 462 * 463 * @see grib_action 464 */ 465 struct grib_action_class 466 { 467 grib_action_class** super; /** < link to a more general behaviour */ 468 const char* name; /** < name of the behaviour class */ 469 size_t size; /** < size in bytes of the structure */ 470 471 int inited; 472 action_init_class_proc init_class; 473 474 action_init_proc init; 475 action_destroy_proc destroy; /** < destructor method to release the memory */ 476 477 grib_dump_proc dump; /** < dump method of the action */ 478 grib_xref_proc xref; /** < dump method of the action */ 479 action_create_accessors_handle_proc create_accessor; /** < method to create the corresponding accessor from a handle*/ 480 action_notify_change_proc notify_change; /** < method to create the corresponding accessor from a handle*/ 481 482 action_reparse_proc reparse; 483 action_execute_proc execute; 484 }; 485 486 487 /** 488 * a buffer 489 * Structure containing the data of a message 490 */ 491 struct grib_buffer 492 { 493 int property; /** < property parameter of buffer */ 494 int validity; /** < validity parameter of buffer */ 495 int growable; /** < buffer can be grown */ 496 size_t length; /** < Buffer length */ 497 size_t ulength; /** < length used of the buffer */ 498 size_t ulength_bits; /** < length used of the buffer in bits */ 499 unsigned char* data; /** < the data byte array */ 500 }; 501 502 /** 503 * an Accessor 504 * Structure supporting each single data unit and allowing its access 505 * @see grib_accessor_class 506 */ 507 508 #define MAX_ACCESSOR_NAMES 20 509 510 typedef struct grib_virtual_value grib_virtual_value; 511 512 struct grib_virtual_value 513 { 514 long lval; 515 double dval; 516 char* cval; 517 int missing; 518 int length; 519 int type; 520 }; 521 522 struct grib_accessor 523 { 524 const char* name; /** < name of the accessor */ 525 const char* name_space; /** < namespace to which the accessor belongs */ 526 grib_context* context; 527 grib_handle* h; 528 grib_action* creator; /** < action that created the accessor */ 529 long length; /** < byte length of the accessor */ 530 long offset; /** < offset of the data in the buffer */ 531 grib_section* parent; /** < section to which the accessor is attached */ 532 grib_accessor* next; /** < next accessor in list */ 533 grib_accessor* previous; /** < next accessor in list */ 534 grib_accessor_class* cclass; /** < behaviour of the accessor */ 535 unsigned long flags; /** < Various flags */ 536 grib_section* sub_section; 537 538 const char* all_names[MAX_ACCESSOR_NAMES]; /** < name of the accessor */ 539 const char* all_name_spaces[MAX_ACCESSOR_NAMES]; /** < namespace to which the accessor belongs */ 540 int dirty; 541 542 grib_accessor* same; /** < accessors with the same name */ 543 long loop; /** < used in lists */ 544 long bufr_subset_number; /** < bufr subset (bufr data accessors belong to different subsets)*/ 545 long bufr_group_number; /** < used in bufr */ 546 grib_virtual_value* vvalue; /** < virtual value used when transient flag on **/ 547 const char* set; 548 grib_accessor* attributes[MAX_ACCESSOR_ATTRIBUTES]; /** < attributes are accessors */ 549 grib_accessor* parent_as_attribute; 550 }; 551 552 #define GRIB_ACCESSOR_FLAG_READ_ONLY (1 << 1) 553 #define GRIB_ACCESSOR_FLAG_DUMP (1 << 2) 554 #define GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC (1 << 3) 555 #define GRIB_ACCESSOR_FLAG_CAN_BE_MISSING (1 << 4) 556 #define GRIB_ACCESSOR_FLAG_HIDDEN (1 << 5) 557 #define GRIB_ACCESSOR_FLAG_CONSTRAINT (1 << 6) 558 #define GRIB_ACCESSOR_FLAG_BUFR_DATA (1 << 7) 559 #define GRIB_ACCESSOR_FLAG_NO_COPY (1 << 8) 560 #define GRIB_ACCESSOR_FLAG_COPY_OK (1 << 9) 561 #define GRIB_ACCESSOR_FLAG_FUNCTION (1 << 10) 562 #define GRIB_ACCESSOR_FLAG_DATA (1 << 11) 563 #define GRIB_ACCESSOR_FLAG_NO_FAIL (1 << 12) 564 #define GRIB_ACCESSOR_FLAG_TRANSIENT (1 << 13) 565 #define GRIB_ACCESSOR_FLAG_STRING_TYPE (1 << 14) 566 #define GRIB_ACCESSOR_FLAG_LONG_TYPE (1 << 15) 567 #define GRIB_ACCESSOR_FLAG_DOUBLE_TYPE (1 << 16) 568 #define GRIB_ACCESSOR_FLAG_LOWERCASE (1 << 17) 569 570 /** 571 * a section accessor 572 * Structure supporting hierarchical naming of the accessors 573 * @see grib_accessor 574 */ 575 struct grib_section 576 { 577 grib_accessor* owner; 578 grib_handle* h; /** < Handles of all accessors and buffer */ 579 grib_accessor* aclength; /** < block of the length of the block */ 580 grib_block_of_accessors* block; /** < block */ 581 grib_action* branch; /** < branch that created the block */ 582 size_t length; 583 size_t padding; 584 }; 585 586 587 struct grib_iterator_class 588 { 589 grib_iterator_class** super; 590 char* name; 591 size_t size; 592 593 int inited; 594 iterator_init_class_proc init_class; 595 596 iterator_init_proc init; 597 iterator_destroy_proc destroy; 598 599 iterator_next_proc next; 600 iterator_previous_proc previous; 601 iterator_reset_proc reset; 602 iterator_has_next_proc has_next; 603 }; 604 605 struct grib_nearest_class 606 { 607 grib_nearest_class** super; 608 char* name; 609 size_t size; 610 611 int inited; 612 nearest_init_class_proc init_class; 613 614 nearest_init_proc init; 615 nearest_destroy_proc destroy; 616 617 nearest_find_proc find; 618 }; 619 620 struct grib_box_class 621 { 622 grib_box_class** super; 623 char* name; 624 size_t size; 625 int inited; 626 box_init_class_proc init_class; 627 box_init_proc init; 628 box_destroy_proc destroy; 629 box_get_points_proc get_points; 630 }; 631 632 /* --------------- */ 633 /* --------------- */ 634 typedef void (*search_all_callback_proc)(grib_accessor*, void* data); 635 /* --------------- */ 636 637 typedef int (*dumper_init_proc)(grib_dumper*); 638 typedef void (*dumper_dump_proc)(grib_dumper*, grib_accessor*, const char* comment); 639 typedef void (*dumper_dump_section_proc)(grib_dumper*, grib_accessor*, grib_block_of_accessors* block); 640 typedef void (*dumper_dump_values_proc)(grib_dumper*, grib_accessor*); 641 typedef int (*dumper_destroy_proc)(grib_dumper*); 642 typedef void (*dumper_header_proc)(grib_dumper*, grib_handle*); 643 typedef void (*dumper_footer_proc)(grib_dumper*, grib_handle*); 644 typedef void (*dumper_init_class_proc)(grib_dumper_class*); 645 646 struct grib_dumper 647 { 648 FILE* out; 649 unsigned long option_flags; 650 void* arg; 651 int depth; 652 long count; 653 grib_context* context; 654 grib_dumper_class* cclass; 655 }; 656 657 struct grib_dumper_class 658 { 659 grib_dumper_class** super; 660 char* name; 661 size_t size; 662 int inited; 663 dumper_init_class_proc init_class; 664 dumper_init_proc init; 665 dumper_destroy_proc destroy; 666 dumper_dump_proc dump_long; 667 dumper_dump_proc dump_double; 668 dumper_dump_proc dump_string; 669 dumper_dump_proc dump_string_array; 670 dumper_dump_proc dump_label; 671 dumper_dump_proc dump_bytes; 672 dumper_dump_proc dump_bits; 673 dumper_dump_section_proc dump_section; 674 dumper_dump_values_proc dump_values; 675 dumper_header_proc header; 676 dumper_footer_proc footer; 677 }; 678 679 struct grib_iterator 680 { 681 grib_arguments* args; /** args of iterator */ 682 grib_handle* h; 683 long e; /** current element */ 684 size_t nv; /** number of values */ 685 double* data; /** data values */ 686 grib_iterator_class* cclass; 687 unsigned long flags; 688 }; 689 690 struct grib_nearest 691 { 692 grib_arguments* args; /** args of iterator */ 693 grib_handle* h; 694 grib_context* context; 695 double* values; 696 size_t values_count; 697 grib_nearest_class* cclass; 698 unsigned long flags; 699 }; 700 701 struct grib_box 702 { 703 grib_box_class* cclass; 704 grib_context* context; 705 grib_arguments* args; 706 grib_handle* h; 707 unsigned long flags; 708 grib_points* points; 709 }; 710 711 struct grib_dependency 712 { 713 grib_dependency* next; 714 grib_accessor* observed; 715 grib_accessor* observer; 716 int run; 717 }; 718 719 struct grib_block_of_accessors 720 { 721 grib_accessor* first; 722 grib_accessor* last; 723 }; 724 725 726 typedef struct grib_trie grib_trie; 727 typedef struct grib_trie_with_rank_list grib_trie_with_rank_list; 728 typedef struct grib_trie_with_rank grib_trie_with_rank; 729 typedef struct grib_itrie grib_itrie; 730 731 732 /* Dynamic array of strings */ 733 struct grib_sarray 734 { 735 char** v; 736 size_t size; /* capacity */ 737 size_t n; /* used size */ 738 size_t incsize; 739 grib_context* context; 740 }; 741 742 /* Dynamic array of objects (void*) */ 743 struct grib_oarray 744 { 745 void** v; 746 size_t size; /* capacity */ 747 size_t n; /* used size */ 748 size_t incsize; 749 grib_context* context; 750 }; 751 752 /* Dynamic array of doubles */ 753 struct grib_darray 754 { 755 double* v; 756 size_t size; /* capacity */ 757 size_t n; /* used size */ 758 size_t incsize; 759 grib_context* context; 760 }; 761 762 /* Dynamic array of integers (long) */ 763 struct grib_iarray 764 { 765 long* v; 766 size_t size; /* capacity */ 767 size_t n; /* used size */ 768 size_t incsize; 769 size_t number_of_pop_front; 770 grib_context* context; 771 }; 772 773 /* Dynamic array of double arrays */ 774 struct grib_vdarray 775 { 776 grib_darray** v; 777 size_t size; /* capacity */ 778 size_t n; /* used size */ 779 size_t incsize; 780 grib_context* context; 781 }; 782 783 /* Dynamic array of string arrays */ 784 struct grib_vsarray 785 { 786 grib_sarray** v; 787 size_t size; /* capacity */ 788 size_t n; /* used size */ 789 size_t incsize; 790 grib_context* context; 791 }; 792 793 /* Dynamic array of integer arrays */ 794 struct grib_viarray 795 { 796 grib_iarray** v; 797 size_t size; /* capacity */ 798 size_t n; /* used size */ 799 size_t incsize; 800 grib_context* context; 801 }; 802 803 /* types of BUFR descriptors used in bufr_descriptor->type*/ 804 #define BUFR_DESCRIPTOR_TYPE_UNKNOWN 0 805 #define BUFR_DESCRIPTOR_TYPE_STRING 1 806 #define BUFR_DESCRIPTOR_TYPE_DOUBLE 2 807 #define BUFR_DESCRIPTOR_TYPE_LONG 3 808 #define BUFR_DESCRIPTOR_TYPE_TABLE 4 809 #define BUFR_DESCRIPTOR_TYPE_FLAG 5 810 #define BUFR_DESCRIPTOR_TYPE_REPLICATION 6 811 #define BUFR_DESCRIPTOR_TYPE_OPERATOR 7 812 #define BUFR_DESCRIPTOR_TYPE_SEQUENCE 8 813 814 struct bufr_descriptor 815 { 816 grib_context* context; 817 long code; 818 int F; 819 int X; 820 int Y; 821 int type; 822 /*char* name; Not needed: All usage commented out. See ECC-489 */ 823 char shortName[128]; 824 char units[128]; 825 long scale; 826 double factor; 827 long reference; 828 long width; 829 int nokey; /* set if descriptor does not have an associated key */ 830 grib_accessor* a; 831 }; 832 833 struct bufr_descriptors_array 834 { 835 bufr_descriptor** v; 836 size_t size; 837 size_t n; 838 size_t incsize; 839 size_t number_of_pop_front; 840 grib_context* context; 841 }; 842 843 struct bufr_descriptors_map_list 844 { 845 bufr_descriptors_array* unexpanded; 846 bufr_descriptors_array* expanded; 847 bufr_descriptors_map_list* next; 848 }; 849 850 /* BUFR: Operator 203YYY: Linked list storing Table B changed reference values */ 851 typedef struct bufr_tableb_override bufr_tableb_override; 852 struct bufr_tableb_override 853 { 854 bufr_tableb_override* next; 855 int code; 856 long new_ref_val; 857 }; 858 859 struct codes_condition 860 { 861 char* left; 862 int rightType; 863 char* rightString; 864 long rightLong; 865 double rightDouble; 866 }; 867 868 869 void codes_assertion_failed(const char* message, const char* file, int line); 870 871 #define MAX_SET_VALUES 10 872 #define MAX_ACCESSOR_CACHE 100 873 874 struct grib_handle 875 { 876 grib_context* context; /** < context attached to this handle */ 877 grib_buffer* buffer; /** < buffer attached to the handle */ 878 grib_section* root; /** the root section*/ 879 grib_section* asserts; /** the assertion section*/ 880 grib_section* rules; /** the rules section*/ 881 grib_dependency* dependencies; /** List of dependencies */ 882 grib_handle* main; /** Used during reparsing */ 883 grib_handle* kid; /** Used during reparsing */ 884 grib_loader* loader; /** Used during reparsing */ 885 int values_stack; 886 const grib_values* values[MAX_SET_VALUES]; /** Used when setting multiple values at once */ 887 size_t values_count[MAX_SET_VALUES]; /** Used when setting multiple values at once */ 888 int dont_trigger; /** Don't notify triggers */ 889 int partial; /** Not a complete message (just headers) */ 890 int header_mode; /** Header not jet complete */ 891 char* gts_header; 892 size_t gts_header_len; 893 int use_trie; 894 int trie_invalid; 895 grib_accessor* accessors[ACCESSORS_ARRAY_SIZE]; 896 char* section_offset[MAX_NUM_SECTIONS]; 897 char* section_length[MAX_NUM_SECTIONS]; 898 int sections_count; 899 off_t offset; 900 long bufr_subset_number; /* bufr subset number */ 901 long bufr_group_number; /* used in bufr */ 902 /* grib_accessor* groups[MAX_NUM_GROUPS]; */ 903 long missingValueLong; 904 double missingValueDouble; 905 ProductKind product_kind; 906 grib_trie* bufr_elements_table; 907 }; 908 909 struct grib_multi_handle 910 { 911 grib_context* context; /** < context attached to this handle */ 912 grib_buffer* buffer; /** < buffer attached to the handle */ 913 size_t offset; 914 size_t length; 915 }; 916 917 918 struct grib_accessor_class 919 { 920 grib_accessor_class** super; 921 const char* name; 922 size_t size; 923 924 int inited; 925 accessor_init_class_proc init_class; 926 927 accessor_init_proc init; 928 accessor_post_init_proc post_init; 929 accessor_destroy_proc destroy; 930 931 accessor_dump_proc dump; 932 accessor_value_proc next_offset; 933 934 accessor_string_proc string_length; 935 accessor_value_with_ret_proc value_count; 936 937 accessor_value_proc byte_count; 938 accessor_value_proc byte_offset; 939 940 accessor_get_native_type_proc get_native_type; 941 942 accessor_sub_section_proc sub_section; 943 944 accessor_pack_missing_proc pack_missing; 945 accessor_pack_is_missing_proc is_missing; 946 947 accessor_pack_long_proc pack_long; 948 accessor_unpack_long_proc unpack_long; 949 950 accessor_pack_double_proc pack_double; 951 accessor_unpack_double_proc unpack_double; 952 953 accessor_pack_string_proc pack_string; 954 accessor_unpack_string_proc unpack_string; 955 956 accessor_pack_string_array_proc pack_string_array; 957 accessor_unpack_string_array_proc unpack_string_array; 958 959 accessor_pack_bytes_proc pack_bytes; 960 accessor_unpack_bytes_proc unpack_bytes; 961 962 accessor_pack_expression_proc pack_expression; 963 964 accessor_notify_change_proc notify_change; 965 accessor_update_size_proc update_size; 966 967 accessor_preferred_size_proc preferred_size; 968 accessor_resize_proc resize; 969 970 accessor_nearest_proc nearest_smaller_value; 971 accessor_next_proc next; 972 accessor_compare_proc compare; 973 accessor_unpack_double_element_proc unpack_double_element; 974 accessor_unpack_double_subarray_proc unpack_double_subarray; 975 accessor_clear_proc clear; 976 accessor_clone_proc make_clone; 977 }; 978 979 typedef struct grib_multi_support grib_multi_support; 980 981 struct grib_multi_support 982 { 983 FILE* file; 984 size_t offset; 985 unsigned char* message; 986 size_t message_length; 987 unsigned char* sections[8]; 988 unsigned char* bitmap_section; 989 size_t bitmap_section_length; 990 size_t sections_length[9]; 991 int section_number; 992 grib_multi_support* next; 993 }; 994 995 /* Hash_array */ 996 typedef struct grib_hash_array_value grib_hash_array_value; 997 998 struct grib_hash_array_value 999 { 1000 grib_hash_array_value* next; 1001 char* name; 1002 int type; 1003 grib_iarray* iarray; 1004 grib_darray* darray; 1005 grib_trie* index; 1006 }; 1007 1008 /* Concepts */ 1009 typedef struct grib_concept_condition grib_concept_condition; 1010 1011 struct grib_concept_condition 1012 { 1013 grib_concept_condition* next; 1014 char* name; 1015 grib_expression* expression; 1016 grib_iarray* iarray; 1017 }; 1018 1019 typedef struct grib_concept_value_name grib_concept_value_name; 1020 struct grib_concept_value_name 1021 { 1022 grib_concept_value_name* next; 1023 char* name; 1024 }; 1025 1026 typedef struct grib_concept_value grib_concept_value; 1027 1028 struct grib_concept_value 1029 { 1030 grib_concept_value* next; 1031 char* name; 1032 grib_concept_condition* conditions; 1033 grib_trie* index; 1034 }; 1035 1036 /* ----------*/ 1037 struct grib_context 1038 { 1039 int inited; 1040 int debug; 1041 int write_on_fail; 1042 int no_abort; 1043 int io_buffer_size; 1044 int no_big_group_split; 1045 int no_spd; 1046 int keep_matrix; 1047 char* grib_definition_files_path; 1048 char* grib_samples_path; 1049 char* grib_concept_path; 1050 1051 grib_action_file_list* grib_reader; 1052 void* user_data; 1053 int real_mode; 1054 1055 grib_free_proc free_mem; 1056 grib_malloc_proc alloc_mem; 1057 grib_realloc_proc realloc_mem; 1058 1059 grib_free_proc free_persistent_mem; 1060 grib_malloc_proc alloc_persistent_mem; 1061 1062 grib_free_proc free_buffer_mem; 1063 grib_malloc_proc alloc_buffer_mem; 1064 grib_realloc_proc realloc_buffer_mem; 1065 1066 grib_data_read_proc read; 1067 grib_data_write_proc write; 1068 grib_data_tell_proc tell; 1069 grib_data_seek_proc seek; 1070 grib_data_eof_proc eof; 1071 1072 grib_log_proc output_log; 1073 grib_print_proc print; 1074 1075 grib_codetable* codetable; 1076 grib_smart_table* smart_table; 1077 char* outfilename; 1078 int multi_support_on; 1079 grib_multi_support* multi_support; 1080 grib_string_list* grib_definition_files_dir; 1081 int handle_file_count; 1082 int handle_total_count; 1083 off_t message_file_offset; 1084 int no_fail_on_wrong_length; 1085 int gts_header_on; 1086 int gribex_mode_on; 1087 int large_constant_fields; 1088 grib_itrie* keys; 1089 int keys_count; 1090 grib_itrie* concepts_index; 1091 int concepts_count; 1092 grib_concept_value* concepts[MAX_NUM_CONCEPTS]; 1093 grib_itrie* hash_array_index; 1094 int hash_array_count; 1095 grib_hash_array_value* hash_array[MAX_NUM_HASH_ARRAY]; 1096 grib_trie* def_files; 1097 grib_string_list* blocklist; 1098 int ieee_packing; 1099 int bufrdc_mode; 1100 int bufr_set_to_missing_if_out_of_range; 1101 int bufr_multi_element_constant_arrays; 1102 int grib_data_quality_checks; 1103 FILE* log_stream; 1104 grib_trie* classes; 1105 grib_trie* lists; 1106 grib_trie* expanded_descriptors; 1107 int file_pool_max_opened_files; 1108 #if GRIB_PTHREADS 1109 pthread_mutex_t mutex; 1110 #elif GRIB_OMP_THREADS 1111 omp_nest_lock_t mutex; 1112 #endif 1113 }; 1114 1115 /* expression*/ 1116 1117 typedef int (*expression_evaluate_long_proc)(grib_expression*, grib_handle*, long*); 1118 typedef int (*expression_evaluate_double_proc)(grib_expression*, grib_handle*, double*); 1119 typedef const char* (*expression_evaluate_string_proc)(grib_expression*, grib_handle*, char*, size_t*, int*); 1120 typedef const char* (*expression_get_name_proc)(grib_expression*); 1121 1122 typedef void (*expression_print_proc)(grib_context*, grib_expression*, grib_handle*); 1123 typedef void (*expression_add_dependency_proc)(grib_expression* e, grib_accessor* observer); 1124 1125 typedef struct grib_expression_class grib_expression_class; 1126 1127 typedef void (*expression_class_init_proc)(grib_expression_class* e); 1128 typedef void (*expression_init_proc)(grib_expression* e); 1129 typedef void (*expression_destroy_proc)(grib_context*, grib_expression* e); 1130 1131 typedef int (*expression_native_type_proc)(grib_expression*, grib_handle*); 1132 1133 struct grib_expression 1134 { 1135 grib_expression_class* cclass; 1136 }; 1137 1138 struct grib_expression_class 1139 { 1140 grib_expression_class** super; 1141 const char* name; 1142 size_t size; 1143 int inited; 1144 1145 expression_class_init_proc init_class; 1146 expression_init_proc init; 1147 expression_destroy_proc destroy; 1148 1149 1150 expression_print_proc print; 1151 expression_add_dependency_proc add_dependency; 1152 1153 expression_native_type_proc native_type; 1154 expression_get_name_proc get_name; 1155 1156 expression_evaluate_long_proc evaluate_long; 1157 expression_evaluate_double_proc evaluate_double; 1158 expression_evaluate_string_proc evaluate_string; 1159 }; 1160 1161 1162 struct grib_arguments 1163 { 1164 struct grib_arguments* next; 1165 grib_expression* expression; 1166 char value[80]; 1167 }; 1168 1169 1170 long grib_expression_evaluate(grib_handle*, grib_expression*); 1171 void grib_expression_free(grib_context*, grib_expression*); 1172 1173 grib_arguments* grib_arguments_new(grib_context*, grib_expression*, grib_arguments*); 1174 void grib_arguments_free(grib_context*, grib_arguments*); 1175 1176 const char* grib_argument_next(grib_arguments**); 1177 1178 /* file_pool */ 1179 extern grib_string_list grib_file_not_found; 1180 1181 typedef struct grib_file grib_file; 1182 typedef struct grib_file_pool grib_file_pool; 1183 1184 struct grib_file 1185 { 1186 grib_context* context; 1187 char* name; 1188 FILE* handle; 1189 char* mode; 1190 char* buffer; 1191 long refcount; 1192 grib_file* next; 1193 short id; 1194 }; 1195 1196 struct grib_file_pool 1197 { 1198 grib_context* context; 1199 grib_file* first; 1200 grib_file* current; 1201 size_t size; 1202 int number_of_opened_files; 1203 int max_opened_files; 1204 }; 1205 1206 /* fieldset */ 1207 typedef struct grib_field grib_field; 1208 typedef struct grib_column grib_column; 1209 typedef struct grib_fields grib_fields; 1210 typedef struct grib_int_array grib_int_array; 1211 1212 struct grib_where 1213 { 1214 grib_context* context; 1215 char* string; 1216 }; 1217 1218 struct grib_column 1219 { 1220 grib_context* context; 1221 int refcount; 1222 char* name; 1223 int type; 1224 size_t size; 1225 size_t values_array_size; 1226 long* long_values; 1227 double* double_values; 1228 char** string_values; 1229 int* errors; 1230 }; 1231 1232 struct grib_order_by 1233 { 1234 char* key; 1235 int idkey; 1236 int mode; 1237 grib_order_by* next; 1238 }; 1239 1240 #ifdef NEWDB 1241 struct grib_query 1242 { 1243 grib_context* context; 1244 char* where_string; 1245 grib_order_by* order_by; 1246 }; 1247 #endif 1248 1249 struct grib_field 1250 { 1251 grib_file* file; 1252 off_t offset; 1253 long length; 1254 grib_field* next; 1255 }; 1256 1257 struct grib_int_array 1258 { 1259 grib_context* context; 1260 size_t size; 1261 int* el; 1262 }; 1263 1264 #ifndef NEWDB 1265 struct grib_fieldset 1266 { 1267 grib_context* context; 1268 grib_int_array* filter; 1269 grib_int_array* order; 1270 size_t fields_array_size; 1271 size_t size; 1272 grib_column* columns; 1273 size_t columns_size; 1274 grib_where* where; 1275 grib_order_by* order_by; 1276 long current; 1277 grib_field** fields; 1278 }; 1279 #endif 1280 1281 #ifdef NEWDB 1282 /* grib db */ 1283 struct grib_db 1284 { 1285 grib_context* context; 1286 size_t size; 1287 size_t fields_array_size; 1288 grib_column* columns; 1289 size_t columns_size; 1290 grib_field** fields; 1291 }; 1292 1293 struct grib_fieldset 1294 { 1295 grib_context* context; 1296 grib_db* db; 1297 grib_int_array* filter; 1298 grib_int_array* order; 1299 size_t size; 1300 grib_query* query; 1301 long current; 1302 }; 1303 #endif 1304 1305 /* concept index structures */ 1306 1307 typedef struct grib_concept_index_key grib_concept_index_key; 1308 typedef struct grib_concept_index grib_concept_index; 1309 typedef struct grib_conditions_tree grib_conditions_tree; 1310 typedef struct grib_concept_entry grib_concept_entry; 1311 typedef struct grib_concept_key grib_concept_key; 1312 1313 struct grib_concept_index_entry 1314 { 1315 char* name; 1316 char* value; 1317 int type; 1318 grib_concept_entry* next; 1319 }; 1320 1321 struct grib_concept_index_key 1322 { 1323 char* name; 1324 int type; 1325 grib_concept_key* next; 1326 }; 1327 1328 struct grib_concept_index 1329 { 1330 grib_context* context; 1331 grib_concept_key* keys; 1332 grib_conditions_tree* conditions; 1333 }; 1334 1335 struct grib_conditions_tree 1336 { 1337 char* value; 1338 void* object; 1339 grib_conditions_tree* next; 1340 grib_conditions_tree* next_key; 1341 }; 1342 1343 /* support for in-memory definition and tables */ 1344 1345 extern int codes_memfs_exists(const char* path); 1346 extern FILE* codes_memfs_open(const char* path); 1347 1348 /* index structures */ 1349 1350 #define STRING_VALUE_LEN 100 1351 1352 typedef struct grib_field_tree grib_field_tree; 1353 1354 struct grib_field_tree 1355 { 1356 grib_field* field; 1357 char* value; 1358 grib_field_tree* next; 1359 grib_field_tree* next_level; 1360 }; 1361 1362 typedef struct grib_index_key grib_index_key; 1363 1364 struct grib_index_key 1365 { 1366 char* name; 1367 int type; 1368 char value[STRING_VALUE_LEN]; 1369 grib_string_list* values; 1370 grib_string_list* current; 1371 int values_count; 1372 int count; 1373 grib_index_key* next; 1374 }; 1375 1376 typedef struct grib_field_list grib_field_list; 1377 struct grib_field_list 1378 { 1379 grib_field* field; 1380 grib_field_list* next; 1381 }; 1382 1383 1384 struct grib_index 1385 { 1386 grib_context* context; 1387 grib_index_key* keys; 1388 int rewind; 1389 int orderby; 1390 grib_index_key* orederby_keys; 1391 grib_field_tree* fields; 1392 grib_field_list* fieldset; 1393 grib_field_list* current; 1394 grib_file* files; 1395 int count; 1396 ProductKind product_kind; 1397 int unpack_bufr; /* Only meaningful for product_kind of BUFR */ 1398 }; 1399 1400 /* header compute */ 1401 typedef struct grib_math grib_math; 1402 1403 struct grib_math 1404 { 1405 struct grib_math* left; 1406 struct grib_math* right; 1407 char* name; 1408 int arity; 1409 }; 1410 1411 typedef double (*mathproc)(void); 1412 typedef int (*funcproc)(grib_math*, mathproc); 1413 1414 typedef struct func 1415 { 1416 char* name; 1417 funcproc addr; 1418 mathproc proc; 1419 int arity; 1420 char* info; 1421 } func; 1422 1423 /* action file */ 1424 struct grib_action_file 1425 { 1426 char* filename; 1427 grib_action* root; 1428 grib_action_file* next; 1429 }; 1430 1431 struct grib_action_file_list 1432 { 1433 grib_action_file* first; 1434 grib_action_file* last; 1435 }; 1436 1437 /* Common keys iterator */ 1438 struct grib_keys_iterator 1439 { 1440 grib_handle* handle; 1441 unsigned long filter_flags; /** flags to filter out accessors */ 1442 unsigned long accessor_flags_skip; 1443 grib_accessor* current; 1444 char* name_space; 1445 int at_start; 1446 int match; 1447 int i_curr_attribute; 1448 grib_accessor** attributes; 1449 char* prefix; 1450 grib_trie* seen; 1451 }; 1452 1453 /* BUFR-specific keys iterator */ 1454 struct bufr_keys_iterator 1455 { 1456 grib_handle* handle; 1457 unsigned long filter_flags; /** flags to filter out accessors */ 1458 unsigned long accessor_flags_skip; 1459 unsigned long accessor_flags_only; 1460 grib_accessor* current; 1461 char* key_name; 1462 int at_start; 1463 int match; 1464 int i_curr_attribute; 1465 grib_accessor** attributes; 1466 char* prefix; 1467 grib_trie* seen; 1468 }; 1469 1470 /* ----------*/ 1471 /* md5 */ 1472 typedef unsigned long cvs_uint32; 1473 1474 struct cvs_MD5Context 1475 { 1476 cvs_uint32 buf[4]; 1477 cvs_uint32 bits[2]; 1478 unsigned char in[64]; 1479 }; 1480 /* --- */ 1481 1482 typedef struct grib_rule_entry grib_rule_entry; 1483 1484 struct grib_rule_entry 1485 { 1486 grib_rule_entry* next; 1487 char* name; 1488 grib_expression* value; 1489 }; 1490 1491 typedef struct grib_rule grib_rule; 1492 1493 struct grib_rule 1494 { 1495 grib_rule* next; 1496 grib_expression* condition; 1497 grib_rule_entry* entries; 1498 }; 1499 1500 typedef struct grib_case grib_case; 1501 1502 struct grib_case 1503 { 1504 grib_arguments* values; 1505 grib_action* action; 1506 grib_case* next; 1507 }; 1508 1509 /* ----------*/ 1510 1511 typedef struct code_table_entry 1512 { 1513 char* abbreviation; 1514 char* title; 1515 char* units; 1516 } code_table_entry; 1517 1518 struct grib_codetable 1519 { 1520 char* filename[2]; 1521 char* recomposed_name[2]; 1522 grib_codetable* next; 1523 size_t size; 1524 code_table_entry entries[1]; 1525 }; 1526 1527 typedef struct grib_smart_table_entry 1528 { 1529 /*int code;*/ 1530 char* abbreviation; 1531 char* column[MAX_SMART_TABLE_COLUMNS]; 1532 } grib_smart_table_entry; 1533 1534 struct grib_smart_table 1535 { 1536 char* filename[3]; 1537 char* recomposed_name[3]; 1538 grib_smart_table* next; 1539 size_t numberOfEntries; 1540 grib_smart_table_entry* entries; 1541 }; 1542 1543 1544 #if ECCODES_TIMER 1545 typedef struct grib_timer 1546 { 1547 struct timeval start_; 1548 double timer_; 1549 int active_; 1550 char* name_; 1551 int count_; 1552 long total_; 1553 1554 int elapsed_; 1555 double cpu_; 1556 double total_cpu_; 1557 1558 char* statname_; 1559 grib_context* context; 1560 1561 struct grib_timer* next_; 1562 } grib_timer; 1563 #else 1564 typedef struct grib_timer 1565 { 1566 char nothing; 1567 } grib_timer; 1568 #endif 1569 1570 typedef struct j2k_encode_helper 1571 { 1572 size_t buffer_size; 1573 1574 long width; 1575 long height; 1576 long bits_per_value; 1577 1578 float compression; 1579 1580 long no_values; 1581 const double* values; 1582 double reference_value; 1583 double divisor; 1584 double decimal; 1585 1586 long jpeg_length; 1587 unsigned char* jpeg_buffer; 1588 1589 } j2k_encode_helper; 1590 1591 #include "grib_api_prototypes.h" 1592 1593 1594 #ifdef __cplusplus 1595 } 1596 #endif 1597 #endif 1598 /* This part is automatically generated by ./errors.pl, do not edit */ 1599 #ifndef grib_errors_internal_H 1600 #define grib_errors_internal_H 1601 /** Value mismatch */ 1602 #define GRIB_VALUE_MISMATCH 1 1603 /** double values are different */ 1604 #define GRIB_DOUBLE_VALUE_MISMATCH 2 1605 /** long values are different */ 1606 #define GRIB_LONG_VALUE_MISMATCH 3 1607 /** byte values are different */ 1608 #define GRIB_BYTE_VALUE_MISMATCH 4 1609 /** string values are different */ 1610 #define GRIB_STRING_VALUE_MISMATCH 5 1611 /** Offset mismatch */ 1612 #define GRIB_OFFSET_MISMATCH 6 1613 /** Count mismatch */ 1614 #define GRIB_COUNT_MISMATCH 7 1615 /** Name mismatch */ 1616 #define GRIB_NAME_MISMATCH 8 1617 /** Type mismatch */ 1618 #define GRIB_TYPE_MISMATCH 9 1619 /** Type and value mismatch */ 1620 #define GRIB_TYPE_AND_VALUE_MISMATCH 10 1621 /** Unable to compare accessors */ 1622 #define GRIB_UNABLE_TO_COMPARE_ACCESSORS 11 1623 /** Unable to reset iterator */ 1624 #define GRIB_UNABLE_TO_RESET_ITERATOR 12 1625 /** Assertion failure */ 1626 #define GRIB_ASSERTION_FAILURE 13 1627 #endif 1628