From 84207751120a9a606bbccc4bc759634b0a01377c Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Mon, 6 Nov 2023 14:35:28 -0500 Subject: [PATCH] Squashed 'externals/nitro/' changes from 80a517fcb..9618cb382 9618cb382 Merge branch 'main' into cpp17 253f57b2b latest from CODA-OSS (#590) c3ad6c72e Merge commit 'eba459da43c07c6a3d80b63248c9c7fb49605723' into cpp17 eba459da4 Squashed 'externals/coda-oss/' changes from e573adb323..8b21c3828b 0355e94ea latest from CODA-OSS 325fba327 Merge branch 'cpp17' of github.com:mdaus/nitro into cpp17 7558c7085 develop/sync_externals 2490f6fdc Merge branch 'main' into cpp17 4aa042353 turn off "Warnings as Errors" to fix github builds 45cd3febe turn off code-analysis to fix GitHub builds d6bc1d83a disable code-analysis to fix Github builds 981e75116 Update main.yml 907bf91cd Update frequent_check.yml git-subtree-dir: externals/nitro git-subtree-split: 9618cb382e07fc0edff06b39ed3987426c5011e2 --- .github/workflows/frequent_check.yml | 2 +- .github/workflows/main.yml | 2 +- UnitTest/UnitTest.vcxproj | 1 - .../.github/workflows/build_unittest.yml | 2 +- .../drivers/hdf5/include/H5HLprivate2.h | 25 + .../modules/drivers/hdf5/include/H5LTparse.h | 142 + .../drivers/hdf5/include/H5LTprivate.h | 30 + .../modules/drivers/hdf5/source/H5LT.c | 3343 +++++++++++++++++ .../modules/drivers/hdf5/source/H5LTanalyze.c | 2582 +++++++++++++ .../modules/drivers/hdf5/source/H5LTparse.c | 2121 +++++++++++ modules/c++/nitf-c++.vcxproj | 2 - .../nitf/apps/show_nitf++/show_nitf++.vcxproj | 1 - 12 files changed, 8246 insertions(+), 7 deletions(-) create mode 100644 externals/coda-oss/modules/drivers/hdf5/include/H5HLprivate2.h create mode 100644 externals/coda-oss/modules/drivers/hdf5/include/H5LTparse.h create mode 100644 externals/coda-oss/modules/drivers/hdf5/include/H5LTprivate.h create mode 100644 externals/coda-oss/modules/drivers/hdf5/source/H5LT.c create mode 100644 externals/coda-oss/modules/drivers/hdf5/source/H5LTanalyze.c create mode 100644 externals/coda-oss/modules/drivers/hdf5/source/H5LTparse.c diff --git a/.github/workflows/frequent_check.yml b/.github/workflows/frequent_check.yml index aa0c3d30d..9c1777f88 100644 --- a/.github/workflows/frequent_check.yml +++ b/.github/workflows/frequent_check.yml @@ -63,7 +63,7 @@ jobs: cmake --build . --config ${{ matrix.configuration }} -j cmake --build . --config ${{ matrix.configuration }} --target install - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1 # https://github.com/marketplace/actions/setup-msbuild + uses: microsoft/setup-msbuild@v1.0.2 # https://github.com/marketplace/actions/setup-msbuild with: msbuild-architecture: x64 - name: msbuild diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f08b70807..ef3dfa65e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,7 +37,7 @@ jobs: cd out ctest -C ${{ matrix.configuration }} --output-on-failure - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1 # https://github.com/marketplace/actions/setup-msbuild + uses: microsoft/setup-msbuild@v1.0.2 # https://github.com/marketplace/actions/setup-msbuild with: msbuild-architecture: x64 - name: msbuild diff --git a/UnitTest/UnitTest.vcxproj b/UnitTest/UnitTest.vcxproj index 5f556f3d1..3c1bc2284 100644 --- a/UnitTest/UnitTest.vcxproj +++ b/UnitTest/UnitTest.vcxproj @@ -64,7 +64,6 @@ AdvancedVectorExtensions2 MultiThreadedDebugDLL true - true true true true diff --git a/externals/coda-oss/.github/workflows/build_unittest.yml b/externals/coda-oss/.github/workflows/build_unittest.yml index 07f04cf85..8b3f29c1c 100644 --- a/externals/coda-oss/.github/workflows/build_unittest.yml +++ b/externals/coda-oss/.github/workflows/build_unittest.yml @@ -76,7 +76,7 @@ jobs: cmake --build . --config ${{ matrix.configuration }} -j cmake --build . --config ${{ matrix.configuration }} --target install - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1 # https://github.com/marketplace/actions/setup-msbuild + uses: microsoft/setup-msbuild@v1.0.2 # https://github.com/marketplace/actions/setup-msbuild with: msbuild-architecture: x64 - name: msbuild diff --git a/externals/coda-oss/modules/drivers/hdf5/include/H5HLprivate2.h b/externals/coda-oss/modules/drivers/hdf5/include/H5HLprivate2.h new file mode 100644 index 000000000..2bd8d0191 --- /dev/null +++ b/externals/coda-oss/modules/drivers/hdf5/include/H5HLprivate2.h @@ -0,0 +1,25 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef H5HLprivate2_H +#define H5HLprivate2_H + +/* Public HDF5 header */ +#include "hdf5.h" + +/* Public High-Level header */ +#include "hdf5_hl.h" + +/* HDF5 private functions */ +#include "H5private.h" + +#endif /* H5HLprivate2_H */ diff --git a/externals/coda-oss/modules/drivers/hdf5/include/H5LTparse.h b/externals/coda-oss/modules/drivers/hdf5/include/H5LTparse.h new file mode 100644 index 000000000..84c5fd093 --- /dev/null +++ b/externals/coda-oss/modules/drivers/hdf5/include/H5LTparse.h @@ -0,0 +1,142 @@ +/* A Bison parser, made by GNU Bison 3.8.2. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + +#ifndef YY_H5LTYY_HL_SRC_H5LTPARSE_H_INCLUDED +# define YY_H5LTYY_HL_SRC_H5LTPARSE_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int H5LTyydebug; +#endif + +/* Token kinds. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + YYEMPTY = -2, + YYEOF = 0, /* "end of file" */ + YYerror = 256, /* error */ + YYUNDEF = 257, /* "invalid token" */ + H5T_STD_I8BE_TOKEN = 258, /* H5T_STD_I8BE_TOKEN */ + H5T_STD_I8LE_TOKEN = 259, /* H5T_STD_I8LE_TOKEN */ + H5T_STD_I16BE_TOKEN = 260, /* H5T_STD_I16BE_TOKEN */ + H5T_STD_I16LE_TOKEN = 261, /* H5T_STD_I16LE_TOKEN */ + H5T_STD_I32BE_TOKEN = 262, /* H5T_STD_I32BE_TOKEN */ + H5T_STD_I32LE_TOKEN = 263, /* H5T_STD_I32LE_TOKEN */ + H5T_STD_I64BE_TOKEN = 264, /* H5T_STD_I64BE_TOKEN */ + H5T_STD_I64LE_TOKEN = 265, /* H5T_STD_I64LE_TOKEN */ + H5T_STD_U8BE_TOKEN = 266, /* H5T_STD_U8BE_TOKEN */ + H5T_STD_U8LE_TOKEN = 267, /* H5T_STD_U8LE_TOKEN */ + H5T_STD_U16BE_TOKEN = 268, /* H5T_STD_U16BE_TOKEN */ + H5T_STD_U16LE_TOKEN = 269, /* H5T_STD_U16LE_TOKEN */ + H5T_STD_U32BE_TOKEN = 270, /* H5T_STD_U32BE_TOKEN */ + H5T_STD_U32LE_TOKEN = 271, /* H5T_STD_U32LE_TOKEN */ + H5T_STD_U64BE_TOKEN = 272, /* H5T_STD_U64BE_TOKEN */ + H5T_STD_U64LE_TOKEN = 273, /* H5T_STD_U64LE_TOKEN */ + H5T_NATIVE_CHAR_TOKEN = 274, /* H5T_NATIVE_CHAR_TOKEN */ + H5T_NATIVE_SCHAR_TOKEN = 275, /* H5T_NATIVE_SCHAR_TOKEN */ + H5T_NATIVE_UCHAR_TOKEN = 276, /* H5T_NATIVE_UCHAR_TOKEN */ + H5T_NATIVE_SHORT_TOKEN = 277, /* H5T_NATIVE_SHORT_TOKEN */ + H5T_NATIVE_USHORT_TOKEN = 278, /* H5T_NATIVE_USHORT_TOKEN */ + H5T_NATIVE_INT_TOKEN = 279, /* H5T_NATIVE_INT_TOKEN */ + H5T_NATIVE_UINT_TOKEN = 280, /* H5T_NATIVE_UINT_TOKEN */ + H5T_NATIVE_LONG_TOKEN = 281, /* H5T_NATIVE_LONG_TOKEN */ + H5T_NATIVE_ULONG_TOKEN = 282, /* H5T_NATIVE_ULONG_TOKEN */ + H5T_NATIVE_LLONG_TOKEN = 283, /* H5T_NATIVE_LLONG_TOKEN */ + H5T_NATIVE_ULLONG_TOKEN = 284, /* H5T_NATIVE_ULLONG_TOKEN */ + H5T_IEEE_F32BE_TOKEN = 285, /* H5T_IEEE_F32BE_TOKEN */ + H5T_IEEE_F32LE_TOKEN = 286, /* H5T_IEEE_F32LE_TOKEN */ + H5T_IEEE_F64BE_TOKEN = 287, /* H5T_IEEE_F64BE_TOKEN */ + H5T_IEEE_F64LE_TOKEN = 288, /* H5T_IEEE_F64LE_TOKEN */ + H5T_NATIVE_FLOAT_TOKEN = 289, /* H5T_NATIVE_FLOAT_TOKEN */ + H5T_NATIVE_DOUBLE_TOKEN = 290, /* H5T_NATIVE_DOUBLE_TOKEN */ + H5T_NATIVE_LDOUBLE_TOKEN = 291, /* H5T_NATIVE_LDOUBLE_TOKEN */ + H5T_STRING_TOKEN = 292, /* H5T_STRING_TOKEN */ + STRSIZE_TOKEN = 293, /* STRSIZE_TOKEN */ + STRPAD_TOKEN = 294, /* STRPAD_TOKEN */ + CSET_TOKEN = 295, /* CSET_TOKEN */ + CTYPE_TOKEN = 296, /* CTYPE_TOKEN */ + H5T_VARIABLE_TOKEN = 297, /* H5T_VARIABLE_TOKEN */ + H5T_STR_NULLTERM_TOKEN = 298, /* H5T_STR_NULLTERM_TOKEN */ + H5T_STR_NULLPAD_TOKEN = 299, /* H5T_STR_NULLPAD_TOKEN */ + H5T_STR_SPACEPAD_TOKEN = 300, /* H5T_STR_SPACEPAD_TOKEN */ + H5T_CSET_ASCII_TOKEN = 301, /* H5T_CSET_ASCII_TOKEN */ + H5T_CSET_UTF8_TOKEN = 302, /* H5T_CSET_UTF8_TOKEN */ + H5T_C_S1_TOKEN = 303, /* H5T_C_S1_TOKEN */ + H5T_FORTRAN_S1_TOKEN = 304, /* H5T_FORTRAN_S1_TOKEN */ + H5T_OPAQUE_TOKEN = 305, /* H5T_OPAQUE_TOKEN */ + OPQ_SIZE_TOKEN = 306, /* OPQ_SIZE_TOKEN */ + OPQ_TAG_TOKEN = 307, /* OPQ_TAG_TOKEN */ + H5T_COMPOUND_TOKEN = 308, /* H5T_COMPOUND_TOKEN */ + H5T_ENUM_TOKEN = 309, /* H5T_ENUM_TOKEN */ + H5T_ARRAY_TOKEN = 310, /* H5T_ARRAY_TOKEN */ + H5T_VLEN_TOKEN = 311, /* H5T_VLEN_TOKEN */ + STRING = 312, /* STRING */ + NUMBER = 313 /* NUMBER */ + }; + typedef enum yytokentype yytoken_kind_t; +#endif + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +union YYSTYPE +{ +#line 68 "hl/src//H5LTparse.y" + + int ival; /*for integer token*/ + char *sval; /*for name string*/ + hid_t hid; /*for hid_t token*/ + +#line 128 "hl/src//H5LTparse.h" + +}; +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE H5LTyylval; + + +hid_t H5LTyyparse (void); + + +#endif /* !YY_H5LTYY_HL_SRC_H5LTPARSE_H_INCLUDED */ diff --git a/externals/coda-oss/modules/drivers/hdf5/include/H5LTprivate.h b/externals/coda-oss/modules/drivers/hdf5/include/H5LTprivate.h new file mode 100644 index 000000000..bea2e63c8 --- /dev/null +++ b/externals/coda-oss/modules/drivers/hdf5/include/H5LTprivate.h @@ -0,0 +1,30 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef H5LTprivate_H +#define H5LTprivate_H + +/* High-level library internal header file */ +#include "H5HLprivate2.h" + +/* public LT prototypes */ +#include "H5LTpublic.h" + +H5_HLDLL herr_t H5LT_get_attribute_disk(hid_t obj_id, const char *attr_name, void *data); +H5_HLDLL herr_t H5LT_set_attribute_numerical(hid_t loc_id, const char *obj_name, const char *attr_name, + size_t size, hid_t type_id, const void *data); +H5_HLDLL herr_t H5LT_set_attribute_string(hid_t dset_id, const char *name, const char *buf); +H5_HLDLL char *H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, + bool no_user_buf); +H5_HLDLL hid_t H5LTyyparse(void); + +#endif diff --git a/externals/coda-oss/modules/drivers/hdf5/source/H5LT.c b/externals/coda-oss/modules/drivers/hdf5/source/H5LT.c new file mode 100644 index 000000000..d48f24008 --- /dev/null +++ b/externals/coda-oss/modules/drivers/hdf5/source/H5LT.c @@ -0,0 +1,3343 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "H5LTprivate.h" + +/* For Lex and Yacc */ +#define COL 3 +#define LIMIT 512 +#define INCREMENT 1024 +#define TMP_LEN 256 +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +size_t input_len; +char *myinput; +size_t indent = 0; + +/* File Image operations + + A file image is a representation of an HDF5 file in a memory + buffer. In order to perform operations on an image in a similar way + to a file, the application buffer is copied to a FAPL buffer, which + in turn is copied to a VFD buffer. Buffer copying can decrease + performance, especially when using large file images. A solution to + this issue is to simulate the copying of the application buffer, + when actually the same buffer is used for the FAPL and the VFD. + This is implemented by using callbacks that simulate the standard + functions for memory management (additional callbacks are used for + the management of associated data structures). From the application + standpoint, a file handle can be obtained from a file image by using + the API routine H5LTopen_file_image(). This function takes a flag + argument that indicates the HDF5 library how to handle the given image; + several flag values can be combined by using the bitwise OR operator. + Valid flag values include: + + H5LT_FILE_IMAGE_OPEN_RW indicates the HDF5 library to open the file + image in read/write mode. Default is read-only mode. + + H5LT_FILE_IMAGE_DONT_COPY indicates the HDF5 library to not copy the + supplied user buffer; the same buffer will be handled by the FAPL and + the VFD driver. Default operation copies the user buffer to the FAPL and + VFD driver. + + H5LT_FILE_IMAGE_DONT_RELEASE indicates the HDF5 library to not release + the buffer handled by the FAPL and the VFD upon closing. This flag value + is only applicable when the flag value H5LT_FILE_IMAGE_DONT_COPY is set as + well. The application is responsible to release the image buffer. +*/ + +/* Data structure to pass application data to callbacks. */ +typedef struct { + void *app_image_ptr; /* Pointer to application buffer */ + size_t app_image_size; /* Size of application buffer */ + void *fapl_image_ptr; /* Pointer to FAPL buffer */ + size_t fapl_image_size; /* Size of FAPL buffer */ + int fapl_ref_count; /* Reference counter for FAPL buffer */ + void *vfd_image_ptr; /* Pointer to VFD buffer */ + size_t vfd_image_size; /* Size of VFD buffer */ + int vfd_ref_count; /* Reference counter for VFD buffer */ + unsigned flags; /* Flags indicate how the file image will */ + /* be open */ + int ref_count; /* Reference counter on udata struct */ +} H5LT_file_image_ud_t; + +/* callbacks prototypes for file image ops */ +static void *image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *udata); +static void *image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, + void *udata); +static void *image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata); +static herr_t image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *udata); +static void *udata_copy(void *udata); +static herr_t udata_free(void *udata); + +/* Definition of callbacks for file image operations. */ + +/*------------------------------------------------------------------------- + * Function: image_malloc + * + * Purpose: Simulates malloc() function to avoid copying file images. + * The application buffer is set to the buffer on only one FAPL. + * Then the FAPL buffer can be copied to other FAPL buffers or + * to only one VFD buffer. + * + * Return: Address of "allocated" buffer, if successful. Otherwise, it returns + * NULL. + * + *------------------------------------------------------------------------- + */ +static void * +image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) +{ + H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; + void *return_value = NULL; + + /* callback is only used if the application buffer is not actually copied */ + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + goto out; + + switch (file_image_op) { + /* the app buffer is "copied" to only one FAPL. Afterwards, FAPLs can be "copied" */ + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: + if (udata->app_image_ptr == NULL) + goto out; + if (udata->app_image_size != size) + goto out; + if (udata->fapl_image_ptr != NULL) + goto out; + if (udata->fapl_image_size != 0) + goto out; + if (udata->fapl_ref_count != 0) + goto out; + + udata->fapl_image_ptr = udata->app_image_ptr; + udata->fapl_image_size = udata->app_image_size; + return_value = udata->fapl_image_ptr; + udata->fapl_ref_count++; + break; + + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: + if (udata->fapl_image_ptr == NULL) + goto out; + if (udata->fapl_image_size != size) + goto out; + if (udata->fapl_ref_count == 0) + goto out; + + return_value = udata->fapl_image_ptr; + udata->fapl_ref_count++; + break; + + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET: + goto out; + + case H5FD_FILE_IMAGE_OP_FILE_OPEN: + /* FAPL buffer is "copied" to only one VFD buffer */ + if (udata->vfd_image_ptr != NULL) + goto out; + if (udata->vfd_image_size != 0) + goto out; + if (udata->vfd_ref_count != 0) + goto out; + if (udata->fapl_image_ptr == NULL) + goto out; + if (udata->fapl_image_size != size) + goto out; + if (udata->fapl_ref_count == 0) + goto out; + + udata->vfd_image_ptr = udata->fapl_image_ptr; + udata->vfd_image_size = size; + udata->vfd_ref_count++; + return_value = udata->vfd_image_ptr; + break; + + /* added unused labels to shut the compiler up */ + case H5FD_FILE_IMAGE_OP_NO_OP: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: + case H5FD_FILE_IMAGE_OP_FILE_RESIZE: + case H5FD_FILE_IMAGE_OP_FILE_CLOSE: + default: + goto out; + } /* end switch */ + + return (return_value); + +out: + return NULL; +} /* end image_malloc() */ + +/*------------------------------------------------------------------------- + * Function: image_memcpy + * + * Purpose: Simulates memcpy() function to avoid copying file images. + * The image buffer can be set to only one FAPL buffer, and + * "copied" to only one VFD buffer. The FAPL buffer can be + * "copied" to other FAPLs buffers. + * + * Return: The address of the destination buffer, if successful. Otherwise, it + * returns NULL. + * + *------------------------------------------------------------------------- + */ +static void * +image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, void *_udata) +{ + H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; + + /* callback is only used if the application buffer is not actually copied */ + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + goto out; + + switch (file_image_op) { + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: + if (dest != udata->fapl_image_ptr) + goto out; + if (src != udata->app_image_ptr) + goto out; + if (size != udata->fapl_image_size) + goto out; + if (size != udata->app_image_size) + goto out; + if (udata->fapl_ref_count == 0) + goto out; + break; + + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: + if (dest != udata->fapl_image_ptr) + goto out; + if (src != udata->fapl_image_ptr) + goto out; + if (size != udata->fapl_image_size) + goto out; + if (udata->fapl_ref_count < 2) + goto out; + break; + + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET: + goto out; + + case H5FD_FILE_IMAGE_OP_FILE_OPEN: + if (dest != udata->vfd_image_ptr) + goto out; + if (src != udata->fapl_image_ptr) + goto out; + if (size != udata->vfd_image_size) + goto out; + if (size != udata->fapl_image_size) + goto out; + if (udata->fapl_ref_count == 0) + goto out; + if (udata->vfd_ref_count != 1) + goto out; + break; + + /* added unused labels to shut the compiler up */ + case H5FD_FILE_IMAGE_OP_NO_OP: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: + case H5FD_FILE_IMAGE_OP_FILE_RESIZE: + case H5FD_FILE_IMAGE_OP_FILE_CLOSE: + default: + goto out; + } /* end switch */ + + return (dest); + +out: + return NULL; +} /* end image_memcpy() */ + +/*------------------------------------------------------------------------- + * Function: image_realloc + * + * Purpose: Reallocates the shared application image buffer and updates data + * structures that manage buffer "copying". + * + * Return: Address of reallocated buffer, if successful. Otherwise, it returns + * NULL. + * + *------------------------------------------------------------------------- + */ +static void * +image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *_udata) +{ + H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; + void *return_value = NULL; + + /* callback is only used if the application buffer is not actually copied */ + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + goto out; + + /* realloc() is not allowed when the HDF5 library won't release the image + buffer because reallocation may change the address of the buffer. The + new address cannot be communicated to the application to release it. */ + if (udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE) + goto out; + + /* realloc() is not allowed if the image is open in read-only mode */ + if (!(udata->flags & H5LT_FILE_IMAGE_OPEN_RW)) + goto out; + + if (file_image_op == H5FD_FILE_IMAGE_OP_FILE_RESIZE) { + if (udata->vfd_image_ptr != ptr) + goto out; + + if (udata->vfd_ref_count != 1) + goto out; + + if (NULL == (udata->vfd_image_ptr = realloc(ptr, size))) + goto out; + + udata->vfd_image_size = size; + return_value = udata->vfd_image_ptr; + } /* end if */ + else + goto out; + + return (return_value); + +out: + return NULL; +} /* end image_realloc() */ + +/*------------------------------------------------------------------------- + * Function: image_free + * + * Purpose: Simulates deallocation of FAPL and VFD buffers by decreasing + * reference counters. Shared application buffer is actually + * deallocated if there are no outstanding references. + * + * Return: SUCCEED or FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata) +{ + H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; + + /* callback is only used if the application buffer is not actually copied */ + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + goto out; + + switch (file_image_op) { + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: + if (udata->fapl_image_ptr != ptr) + goto out; + if (udata->fapl_ref_count == 0) + goto out; + + udata->fapl_ref_count--; + + /* release the shared buffer only if indicated by the respective flag and there are no outstanding + * references */ + if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 && + !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { + free(udata->fapl_image_ptr); + udata->app_image_ptr = NULL; + udata->fapl_image_ptr = NULL; + udata->vfd_image_ptr = NULL; + } /* end if */ + break; + + case H5FD_FILE_IMAGE_OP_FILE_CLOSE: + if (udata->vfd_image_ptr != ptr) + goto out; + if (udata->vfd_ref_count != 1) + goto out; + + udata->vfd_ref_count--; + + /* release the shared buffer only if indicated by the respective flag and there are no outstanding + * references */ + if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 && + !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { + free(udata->vfd_image_ptr); + udata->app_image_ptr = NULL; + udata->fapl_image_ptr = NULL; + udata->vfd_image_ptr = NULL; + } /* end if */ + break; + + /* added unused labels to keep the compiler quite */ + case H5FD_FILE_IMAGE_OP_NO_OP: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET: + case H5FD_FILE_IMAGE_OP_FILE_OPEN: + case H5FD_FILE_IMAGE_OP_FILE_RESIZE: + default: + goto out; + } /* end switch */ + + return (SUCCEED); + +out: + return (FAIL); +} /* end image_free() */ + +/*------------------------------------------------------------------------- + * Function: udata_copy + * + * Purpose: Simulates the copying of the user data structure utilized in the + * management of the "copying" of file images. + * + * Return: Address of "newly allocated" structure, if successful. Otherwise, it + * returns NULL. + * + *------------------------------------------------------------------------- + */ +static void * +udata_copy(void *_udata) +{ + H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; + + /* callback is only used if the application buffer is not actually copied */ + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + goto out; + if (udata->ref_count == 0) + goto out; + + udata->ref_count++; + + return (udata); + +out: + return NULL; +} /* end udata_copy */ + +/*------------------------------------------------------------------------- + * Function: udata_free + * + * Purpose: Simulates deallocation of the user data structure utilized in the + * management of the "copying" of file images. The data structure is + * actually deallocated when there are no outstanding references. + * + * Return: SUCCEED or FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +udata_free(void *_udata) +{ + H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; + + /* callback is only used if the application buffer is not actually copied */ + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + goto out; + if (udata->ref_count == 0) + goto out; + + udata->ref_count--; + + /* checks that there are no references outstanding before deallocating udata */ + if (udata->ref_count == 0 && udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0) + free(udata); + + return (SUCCEED); + +out: + return (FAIL); +} /* end udata_free */ + +/* End of callbacks definitions for file image operations */ + +/*------------------------------------------------------------------------- + * + * internal functions + * + *------------------------------------------------------------------------- + */ +static herr_t H5LT_get_attribute_mem(hid_t loc_id, const char *obj_name, const char *attr_name, + hid_t mem_type_id, void *data); + +/*------------------------------------------------------------------------- + * Function: H5LT_make_dataset + * + * Purpose: Creates and writes a dataset of a type tid + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +static herr_t +H5LT_make_dataset_numerical(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, hid_t tid, + const void *data) +{ + hid_t did = -1, sid = -1; + + /* check the arguments */ + if (dset_name == NULL) + return -1; + + /* Create the data space for the dataset. */ + if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) + return -1; + + /* Create the dataset. */ + if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + + /* Write the dataset only if there is data to write */ + if (data) + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + goto out; + + /* End access to the dataset and release resources used by it. */ + if (H5Dclose(did) < 0) + return -1; + + /* Terminate access to the data space. */ + if (H5Sclose(sid) < 0) + return -1; + + return 0; + +out: + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Sclose(sid); + } + H5E_END_TRY + return -1; +} + +/*------------------------------------------------------------------------- + * + * Public functions + * + *------------------------------------------------------------------------- + */ + +/*------------------------------------------------------------------------- + * Function: H5LTmake_dataset + * + * Purpose: Creates and writes a dataset of a type tid + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTmake_dataset(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, hid_t tid, + const void *data) +{ + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, tid, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTmake_dataset_char + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_CHAR type + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTmake_dataset_char(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const char *data) +{ + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_CHAR, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTmake_dataset_short + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_SHORT type + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTmake_dataset_short(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const short *data) +{ + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_SHORT, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTmake_dataset_int + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_INT type + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTmake_dataset_int(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const int *data) +{ + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_INT, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTmake_dataset_long + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_LONG type + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTmake_dataset_long(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const long *data) +{ + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_LONG, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTmake_dataset_float + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_FLOAT type + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTmake_dataset_float(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const float *data) +{ + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_FLOAT, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTmake_dataset_double + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_DOUBLE type + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTmake_dataset_double(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const double *data) +{ + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_DOUBLE, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTmake_dataset_string + * + * Purpose: Creates and writes a dataset of H5T_C_S1 type + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTmake_dataset_string(hid_t loc_id, const char *dset_name, const char *buf) +{ + hid_t did = -1; + hid_t sid = -1; + hid_t tid = -1; + size_t size; + + /* check the arguments */ + if (dset_name == NULL) + return -1; + + /* create a string data type */ + if ((tid = H5Tcopy(H5T_C_S1)) < 0) + goto out; + + size = strlen(buf) + 1; /* extra null term */ + + if (H5Tset_size(tid, size) < 0) + goto out; + + if (H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) + goto out; + + /* Create the data space for the dataset. */ + if ((sid = H5Screate(H5S_SCALAR)) < 0) + goto out; + + /* Create the dataset. */ + if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + + /* Write the dataset only if there is data to write */ + if (buf) + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto out; + + /* close*/ + if (H5Dclose(did) < 0) + return -1; + if (H5Sclose(sid) < 0) + return -1; + if (H5Tclose(tid) < 0) + goto out; + + return 0; + +out: + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Tclose(tid); + H5Sclose(sid); + } + H5E_END_TRY + return -1; +} + +/*------------------------------------------------------------------------- + * Function: H5LTopen_file_image + * + * Purpose: Open a user supplied file image using the core file driver. + * + * Return: File identifier, Failure: -1 + * + *------------------------------------------------------------------------- + */ +hid_t +H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) +{ + hid_t fapl = -1, file_id = -1; /* HDF5 identifiers */ + unsigned file_open_flags; /* Flags for image open */ + char file_name[64]; /* Filename buffer */ + size_t alloc_incr; /* Buffer allocation increment */ + size_t min_incr = 65536; /* Minimum buffer increment */ + double buf_prcnt = 0.1; /* Percentage of buffer size to set + as increment */ + static long file_name_counter; + H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy, &image_realloc, &image_free, + &udata_copy, &udata_free, (void *)NULL}; + + /* check arguments */ + if (buf_ptr == NULL) + goto out; + if (buf_size == 0) + goto out; + if (flags & (unsigned)~(H5LT_FILE_IMAGE_ALL)) + goto out; + + /* Create FAPL to transmit file image */ + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto out; + + /* set allocation increment to a percentage of the supplied buffer size, or + * a pre-defined minimum increment value, whichever is larger + */ + if ((size_t)(buf_prcnt * (double)buf_size) > min_incr) + alloc_incr = (size_t)(buf_prcnt * (double)buf_size); + else + alloc_incr = min_incr; + + /* Configure FAPL to use the core file driver */ + if (H5Pset_fapl_core(fapl, alloc_incr, false) < 0) + goto out; + + /* Set callbacks for file image ops ONLY if the file image is NOT copied */ + if (flags & H5LT_FILE_IMAGE_DONT_COPY) { + H5LT_file_image_ud_t *udata; /* Pointer to udata structure */ + + /* Allocate buffer to communicate user data to callbacks */ + if (NULL == (udata = (H5LT_file_image_ud_t *)malloc(sizeof(H5LT_file_image_ud_t)))) + goto out; + + /* Initialize udata with info about app buffer containing file image and flags */ + udata->app_image_ptr = buf_ptr; + udata->app_image_size = buf_size; + udata->fapl_image_ptr = NULL; + udata->fapl_image_size = 0; + udata->fapl_ref_count = 0; + udata->vfd_image_ptr = NULL; + udata->vfd_image_size = 0; + udata->vfd_ref_count = 0; + udata->flags = flags; + udata->ref_count = 1; /* corresponding to the first FAPL */ + + /* copy address of udata into callbacks */ + callbacks.udata = (void *)udata; + + /* Set file image callbacks */ + if (H5Pset_file_image_callbacks(fapl, &callbacks) < 0) { + free(udata); + goto out; + } /* end if */ + } /* end if */ + + /* Assign file image in user buffer to FAPL */ + if (H5Pset_file_image(fapl, buf_ptr, buf_size) < 0) + goto out; + + /* set file open flags */ + if (flags & H5LT_FILE_IMAGE_OPEN_RW) + file_open_flags = H5F_ACC_RDWR; + else + file_open_flags = H5F_ACC_RDONLY; + + /* define a unique file name */ + snprintf(file_name, (sizeof(file_name) - 1), "file_image_%ld", file_name_counter++); + + /* Assign file image in FAPL to the core file driver */ + if ((file_id = H5Fopen(file_name, file_open_flags, fapl)) < 0) + goto out; + + /* Close FAPL */ + if (H5Pclose(fapl) < 0) + goto out; + + /* Return file identifier */ + return file_id; + +out: + H5E_BEGIN_TRY + { + H5Pclose(fapl); + } + H5E_END_TRY + return -1; +} /* end H5LTopen_file_image() */ + +/*------------------------------------------------------------------------- + * Function: H5LT_read_dataset + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +static herr_t +H5LT_read_dataset_numerical(hid_t loc_id, const char *dset_name, hid_t tid, void *data) +{ + hid_t did; + + /* check the arguments */ + if (dset_name == NULL) + return -1; + + /* Open the dataset. */ + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + return -1; + + /* Read */ + if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + goto out; + + /* End access to the dataset and release resources used by it. */ + if (H5Dclose(did)) + return -1; + + return 0; + +out: + H5Dclose(did); + return -1; +} + +/*------------------------------------------------------------------------- + * Function: H5LTread_dataset + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTread_dataset(hid_t loc_id, const char *dset_name, hid_t tid, void *data) +{ + return (H5LT_read_dataset_numerical(loc_id, dset_name, tid, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTread_dataset_char + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTread_dataset_char(hid_t loc_id, const char *dset_name, char *data) +{ + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_CHAR, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTread_dataset_short + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTread_dataset_short(hid_t loc_id, const char *dset_name, short *data) +{ + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_SHORT, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTread_dataset_int + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTread_dataset_int(hid_t loc_id, const char *dset_name, int *data) +{ + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_INT, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTread_dataset_long + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTread_dataset_long(hid_t loc_id, const char *dset_name, long *data) +{ + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_LONG, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTread_dataset_float + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTread_dataset_float(hid_t loc_id, const char *dset_name, float *data) +{ + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_FLOAT, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTread_dataset_double + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTread_dataset_double(hid_t loc_id, const char *dset_name, double *data) +{ + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_DOUBLE, data)); +} + +/*------------------------------------------------------------------------- + * Function: H5LTread_dataset_string + * + * Purpose: Reads a dataset + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTread_dataset_string(hid_t loc_id, const char *dset_name, char *buf) +{ + hid_t did = -1; + hid_t tid = -1; + + /* check the arguments */ + if (dset_name == NULL) + return -1; + + /* Open the dataset. */ + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + return -1; + + if ((tid = H5Dget_type(did)) < 0) + goto out; + + /* Read */ + if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto out; + + /* close */ + if (H5Dclose(did)) + goto out; + if (H5Tclose(tid)) + return -1; + + return 0; + +out: + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Tclose(tid); + } + H5E_END_TRY + return -1; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_dataset_ndims + * + * Purpose: Gets the dimensionality of a dataset. + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTget_dataset_ndims(hid_t loc_id, const char *dset_name, int *rank) +{ + hid_t did = -1; + hid_t sid = -1; + + /* check the arguments */ + if (dset_name == NULL) + return -1; + + /* Open the dataset. */ + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + return -1; + + /* Get the dataspace handle */ + if ((sid = H5Dget_space(did)) < 0) + goto out; + + /* Get rank */ + if ((*rank = H5Sget_simple_extent_ndims(sid)) < 0) + goto out; + + /* Terminate access to the dataspace */ + if (H5Sclose(sid) < 0) + goto out; + + /* End access to the dataset */ + if (H5Dclose(did)) + return -1; + + return 0; + +out: + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Sclose(sid); + } + H5E_END_TRY + return -1; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_dataset_info + * + * Purpose: Gets information about a dataset. + * + * Return: Success: 0, Failure: -1 + *------------------------------------------------------------------------- + */ + +herr_t +H5LTget_dataset_info(hid_t loc_id, const char *dset_name, hsize_t *dims, H5T_class_t *type_class, + size_t *type_size) +{ + hid_t did = -1; + hid_t tid = -1; + hid_t sid = -1; + + /* check the arguments */ + if (dset_name == NULL) + return -1; + + /* open the dataset. */ + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + return -1; + + /* get an identifier for the datatype. */ + tid = H5Dget_type(did); + + /* get the class. */ + if (type_class != NULL) + *type_class = H5Tget_class(tid); + + /* get the size. */ + if (type_size != NULL) + *type_size = H5Tget_size(tid); + + if (dims != NULL) { + /* get the dataspace handle */ + if ((sid = H5Dget_space(did)) < 0) + goto out; + + /* get dimensions */ + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + goto out; + + /* terminate access to the dataspace */ + if (H5Sclose(sid) < 0) + goto out; + } /* end if */ + + /* release the datatype. */ + if (H5Tclose(tid)) + return -1; + + /* end access to the dataset */ + if (H5Dclose(did)) + return -1; + + return 0; + +out: + H5E_BEGIN_TRY + { + H5Tclose(tid); + H5Sclose(sid); + H5Dclose(did); + } + H5E_END_TRY + return -1; +} + +/*------------------------------------------------------------------------- + * Function: find_dataset + * + * Purpose: operator function used by H5LTfind_dataset + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +static herr_t +find_dataset(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const H5L_info2_t *linfo, + void *op_data) +{ + /* Define a default zero value for return. This will cause the iterator to continue if + * the dataset is not found yet. + */ + int ret = 0; + + /* check the arguments */ + if (name == NULL) + return ret; + + /* Shut the compiler up */ + (void)loc_id; + (void)linfo; + + /* Define a positive value for return value if the dataset was found. This will + * cause the iterator to immediately return that positive value, + * indicating short-circuit success + */ + if (strncmp(name, (char *)op_data, strlen((char *)op_data)) == 0) + ret = 1; + + return ret; +} + +/*------------------------------------------------------------------------- + * Function: H5LTfind_dataset + * + * Purpose: Inquires if a dataset named dset_name exists attached + * to the object loc_id. + * + * Return: + * Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + *------------------------------------------------------------------------- + */ +/* H5Literate wants a non-const pointer but we have a const pointer in the API + * call. It's safe to ignore this because we control the callback, don't + * modify the op_data buffer (i.e.: dset_name) during the traversal, and the + * library never modifies that buffer. + */ +H5_GCC_CLANG_DIAG_OFF("cast-qual") +herr_t +H5LTfind_dataset(hid_t loc_id, const char *dset_name) +{ + return H5Literate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, 0, find_dataset, (void *)dset_name); +} +H5_GCC_CLANG_DIAG_ON("cast-qual") + +/*------------------------------------------------------------------------- + * + * Set attribute functions + * + *------------------------------------------------------------------------- + */ + +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_string + * + * Purpose: Creates and writes a string attribute named attr_name and attaches + * it to the object specified by the name obj_name. + * + * Return: Success: 0, Failure: -1 + * + * Comments: If the attribute already exists, it is overwritten + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTset_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, const char *attr_data) +{ + hid_t attr_type; + hid_t attr_space_id; + hid_t attr_id; + hid_t obj_id; + htri_t has_attr; + size_t attr_size; + + /* check the arguments */ + if (obj_name == NULL) + return -1; + if (attr_name == NULL) + return -1; + if (attr_data == NULL) + return -1; + + /* Open the object */ + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + return -1; + + /* Create the attribute */ + if ((attr_type = H5Tcopy(H5T_C_S1)) < 0) + goto out; + + attr_size = strlen(attr_data) + 1; /* extra null term */ + + if (H5Tset_size(attr_type, (size_t)attr_size) < 0) + goto out; + + if (H5Tset_strpad(attr_type, H5T_STR_NULLTERM) < 0) + goto out; + + if ((attr_space_id = H5Screate(H5S_SCALAR)) < 0) + goto out; + + /* Delete the attribute if it already exists */ + if ((has_attr = H5Aexists(obj_id, attr_name)) < 0) + goto out; + if (has_attr > 0) + if (H5Adelete(obj_id, attr_name) < 0) + goto out; + + /* Create and write the attribute */ + + if ((attr_id = H5Acreate2(obj_id, attr_name, attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + + if (H5Awrite(attr_id, attr_type, attr_data) < 0) + goto out; + + if (H5Aclose(attr_id) < 0) + goto out; + + if (H5Sclose(attr_space_id) < 0) + goto out; + + if (H5Tclose(attr_type) < 0) + goto out; + + /* Close the object */ + if (H5Oclose(obj_id) < 0) + return -1; + + return 0; + +out: + + H5Oclose(obj_id); + return -1; +} + +/*------------------------------------------------------------------------- + * Function: H5LT_set_attribute_numerical + * + * Purpose: Private function used by H5LTset_attribute_int and H5LTset_attribute_float + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LT_set_attribute_numerical(hid_t loc_id, const char *obj_name, const char *attr_name, size_t size, + hid_t tid, const void *data) +{ + + hid_t obj_id, sid, attr_id; + hsize_t dim_size = size; + htri_t has_attr; + + /* check the arguments */ + if (obj_name == NULL) + return -1; + if (attr_name == NULL) + return -1; + + /* Open the object */ + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + return -1; + + /* Create the data space for the attribute. */ + if ((sid = H5Screate_simple(1, &dim_size, NULL)) < 0) + goto out; + + /* Delete the attribute if it already exists */ + if ((has_attr = H5Aexists(obj_id, attr_name)) < 0) + goto out; + if (has_attr > 0) + if (H5Adelete(obj_id, attr_name) < 0) + goto out; + + /* Create the attribute. */ + if ((attr_id = H5Acreate2(obj_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + + /* Write the attribute data. */ + if (H5Awrite(attr_id, tid, data) < 0) + goto out; + + /* Close the attribute. */ + if (H5Aclose(attr_id) < 0) + goto out; + + /* Close the dataspace. */ + if (H5Sclose(sid) < 0) + goto out; + + /* Close the object */ + if (H5Oclose(obj_id) < 0) + return -1; + + return 0; + +out: + H5Oclose(obj_id); + return -1; +} + +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_char + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTset_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, const char *data, + size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_CHAR, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_uchar + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTset_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned char *data, + size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_UCHAR, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_short + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTset_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, const short *data, + size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_SHORT, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_ushort + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTset_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned short *data, size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_USHORT, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_int + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTset_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, const int *data, size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_INT, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_uint + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTset_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned int *data, + size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_UINT, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_long + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTset_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, const long *data, + size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_LONG, data) < 0) + return -1; + + return 0; +} +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_long_long + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Comments: This function was added to support attributes of type long long + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTset_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, const long long *data, + size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_LLONG, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_ulong + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned long *data, + size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_ULONG, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_ullong + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTset_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned long long *data, size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_ULLONG, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_float + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, const float *data, + size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_FLOAT, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTset_attribute_double + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, const double *data, + size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_DOUBLE, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTfind_attribute + * + * Purpose: Checks if an attribute named attr_name exists attached to + * the object loc_id + * + * TODO: Overloading herr_t is not a great idea. This function either + * needs to be rewritten to take a Boolean out parameter in + * HDF5 2.0 or possibly even eliminated entirely as it simply + * wraps H5Aexists. + * + * Return: An htri_t value cast to herr_t + * Exists: Positive + * Does not exist: 0 + * Error: Negative + *------------------------------------------------------------------------- + */ +herr_t +H5LTfind_attribute(hid_t loc_id, const char *attr_name) +{ + return (herr_t)H5Aexists(loc_id, attr_name); +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_ndims + * + * Purpose: Gets the dimensionality of an attribute. + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTget_attribute_ndims(hid_t loc_id, const char *obj_name, const char *attr_name, int *rank) +{ + hid_t attr_id; + hid_t sid; + hid_t obj_id; + + /* check the arguments */ + if (obj_name == NULL) + return -1; + if (attr_name == NULL) + return -1; + + /* Open the object */ + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + return -1; + + /* Open the attribute. */ + if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) { + H5Oclose(obj_id); + return -1; + } + + /* Get the dataspace handle */ + if ((sid = H5Aget_space(attr_id)) < 0) + goto out; + + /* Get rank */ + if ((*rank = H5Sget_simple_extent_ndims(sid)) < 0) + goto out; + + /* Terminate access to the attribute */ + if (H5Sclose(sid) < 0) + goto out; + + /* End access to the attribute */ + if (H5Aclose(attr_id)) + goto out; + + /* Close the object */ + if (H5Oclose(obj_id) < 0) + return -1; + + return 0; + +out: + H5Aclose(attr_id); + H5Oclose(obj_id); + return -1; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_info + * + * Purpose: Gets information about an attribute. + * + * Return: Success: 0, Failure: -1 + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTget_attribute_info(hid_t loc_id, const char *obj_name, const char *attr_name, hsize_t *dims, + H5T_class_t *type_class, size_t *type_size) +{ + hid_t attr_id; + hid_t tid; + hid_t sid; + hid_t obj_id; + + /* check the arguments */ + if (obj_name == NULL) + return -1; + if (attr_name == NULL) + return -1; + + /* Open the object */ + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + return -1; + + /* Open the attribute. */ + if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) { + H5Oclose(obj_id); + return -1; + } + + /* Get an identifier for the datatype. */ + tid = H5Aget_type(attr_id); + + /* Get the class. */ + *type_class = H5Tget_class(tid); + + /* Get the size. */ + *type_size = H5Tget_size(tid); + + /* Get the dataspace handle */ + if ((sid = H5Aget_space(attr_id)) < 0) + goto out; + + /* Get dimensions */ + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + goto out; + + /* Terminate access to the dataspace */ + if (H5Sclose(sid) < 0) + goto out; + + /* Release the datatype. */ + if (H5Tclose(tid)) + goto out; + + /* End access to the attribute */ + if (H5Aclose(attr_id)) + goto out; + + /* Close the object */ + if (H5Oclose(obj_id) < 0) + return -1; + + return 0; + +out: + H5Tclose(tid); + H5Aclose(attr_id); + H5Oclose(obj_id); + return -1; +} + +/*------------------------------------------------------------------------- + * Function: H5LTtext_to_dtype + * + * Purpose: Convert DDL description to HDF5 data type. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +hid_t +H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) +{ + hid_t type_id; + + /* check the arguments */ + if (text == NULL) + return -1; + + if (lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) + goto out; + + if (lang_type != H5LT_DDL) { + fprintf(stderr, "only DDL is supported for now.\n"); + goto out; + } + + input_len = strlen(text); + myinput = HDstrdup(text); + + if ((type_id = H5LTyyparse()) < 0) { + free(myinput); + goto out; + } + + free(myinput); + input_len = 0; + + return type_id; + +out: + return -1; +} + +/*------------------------------------------------------------------------- + * Function: realloc_and_append + * + * Purpose: Expand the buffer and append a string to it. + * + * Return: void + * + *------------------------------------------------------------------------- + */ +static char * +realloc_and_append(bool _no_user_buf, size_t *len, char *buf, const char *str_to_add) +{ + size_t size_str_to_add, size_str; + + if (_no_user_buf) { + char *tmp_realloc; + + if (!buf) + goto out; + + /* If the buffer isn't big enough, reallocate it. Otherwise, go to do strcat. */ + if (str_to_add && ((ssize_t)(*len - (strlen(buf) + strlen(str_to_add) + 1)) < LIMIT)) { + *len += ((strlen(buf) + strlen(str_to_add) + 1) / INCREMENT + 1) * INCREMENT; + } + else if (!str_to_add && ((ssize_t)(*len - strlen(buf) - 1) < LIMIT)) { + *len += INCREMENT; + } + + tmp_realloc = (char *)realloc(buf, *len); + if (tmp_realloc == NULL) { + free(buf); + buf = NULL; + goto out; + } + else + buf = tmp_realloc; + } + + if (str_to_add) { + /* find the size of the buffer to add */ + size_str_to_add = strlen(str_to_add); + /* find the size of the current buffer */ + size_str = strlen(buf); + + /* Check to make sure the appended string does not + * extend past the allocated buffer; if it does then truncate the string + */ + if (size_str < *len - 1) { + if (size_str + size_str_to_add < *len - 1) { + strcat(buf, str_to_add); + } + else { + strncat(buf, str_to_add, (*len - 1) - size_str); + } + } + else { + buf[*len - 1] = '\0'; /* buffer is full, null terminate */ + } + } + + return buf; + +out: + return NULL; +} + +/*------------------------------------------------------------------------- + * Function: indentation + * + * Purpose: Print spaces for indentation + * + * Return: void + * + *------------------------------------------------------------------------- + */ +static char * +indentation(size_t x, char *str, bool no_u_buf, size_t *s_len) +{ + char tmp_str[TMP_LEN]; + + if (x < 80) { + memset(tmp_str, ' ', x); + tmp_str[x] = '\0'; + } + else + snprintf(tmp_str, TMP_LEN, "error: the indentation exceeds the number of cols."); + + if (!(str = realloc_and_append(no_u_buf, s_len, str, tmp_str))) + goto out; + + return str; + +out: + return NULL; +} + +/*------------------------------------------------------------------------- + * Function: print_enum + * + * Purpose: prints the enum data + * + * Return: Success: 0, Failure: -1 + * + *-----------------------------------------------------------------------*/ +static char * +print_enum(hid_t type, char *str, size_t *str_len, bool no_ubuf, size_t indt) +{ + char **name = NULL; /*member names */ + unsigned char *value = NULL; /*value array */ + int nmembs; /*number of members */ + char tmp_str[TMP_LEN]; + int nchars; /*number of output characters */ + hid_t super = -1; /*enum base integer type */ + hid_t native = -1; /*native integer data type */ + size_t super_size; /*enum base type size */ + size_t dst_size; /*destination value type size */ + int i; + + if ((nmembs = H5Tget_nmembers(type)) <= 0) + goto out; + + if ((super = H5Tget_super(type)) < 0) + goto out; + + /* Use buffer of INT or UNSIGNED INT to print enum values because + * we don't expect these values to be so big that INT or UNSIGNED + * INT can't hold. + */ + if (H5T_SGN_NONE == H5Tget_sign(super)) { + native = H5T_NATIVE_UINT; + } + else { + native = H5T_NATIVE_INT; + } + + super_size = H5Tget_size(super); + dst_size = H5Tget_size(native); + + /* Get the names and raw values of all members */ + name = (char **)calloc((size_t)nmembs, sizeof(char *)); + value = (unsigned char *)calloc((size_t)nmembs, MAX(dst_size, super_size)); + + for (i = 0; i < nmembs; i++) { + if ((name[i] = H5Tget_member_name(type, (unsigned)i)) == NULL) + goto out; + if (H5Tget_member_value(type, (unsigned)i, value + (size_t)i * super_size) < 0) + goto out; + } + + /* Convert values to native data type */ + if (native > 0) { + if (H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0) + goto out; + } + + /* + * Sort members by increasing value + * ***not implemented yet*** + */ + + /* Print members */ + for (i = 0; i < nmembs; i++) { + if (!(str = indentation(indt + COL, str, no_ubuf, str_len))) + goto out; + nchars = snprintf(tmp_str, TMP_LEN, "\"%s\"", name[i]); + if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) + goto out; + memset(tmp_str, ' ', (size_t)MAX(3, 19 - nchars) + 1); + tmp_str[MAX(3, 19 - nchars)] = '\0'; + if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) + goto out; + + if (H5T_SGN_NONE == H5Tget_sign(native)) + snprintf(tmp_str, TMP_LEN, "%u", *((unsigned int *)((void *)(value + (size_t)i * dst_size)))); + else + snprintf(tmp_str, TMP_LEN, "%d", *((int *)((void *)(value + (size_t)i * dst_size)))); + if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) + goto out; + + snprintf(tmp_str, TMP_LEN, ";\n"); + if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) + goto out; + } + + /* Release resources */ + for (i = 0; i < nmembs; i++) + H5free_memory(name[i]); + + free(name); + free(value); + H5Tclose(super); + + return str; + +out: + + if (0 == nmembs) { + str = realloc_and_append(no_ubuf, str_len, str, "\n"); + assert((indt + 4) < TMP_LEN); + memset(tmp_str, ' ', (indt + 4) + 1); + tmp_str[(indt + 4)] = '\0'; + str = realloc_and_append(no_ubuf, str_len, str, tmp_str); + str = realloc_and_append(no_ubuf, str_len, str, " "); + } /* end if */ + + /* Release resources */ + if (name) { + for (i = 0; i < nmembs; i++) + if (name[i]) + free(name[i]); + free(name); + } /* end if */ + + if (value) + free(value); + + if (super >= 0) + H5Tclose(super); + + return NULL; +} + +/*------------------------------------------------------------------------- + * Function: H5LTdtype_to_text + * + * Purpose: Convert HDF5 data type to DDL description. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len) +{ + size_t str_len = INCREMENT; + char *text_str = NULL; + herr_t ret = SUCCEED; + + if (lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) + goto out; + + if (len && !str) { + text_str = (char *)calloc(str_len, sizeof(char)); + text_str[0] = '\0'; + if (!(text_str = H5LT_dtype_to_text(dtype, text_str, lang_type, &str_len, 1))) + goto out; + *len = strlen(text_str) + 1; + if (text_str) + free(text_str); + text_str = NULL; + } + else if (len && str) { + if (!(H5LT_dtype_to_text(dtype, str, lang_type, len, 0))) + goto out; + str[*len - 1] = '\0'; + } + + return ret; + +out: + free(text_str); + + return FAIL; +} + +/*------------------------------------------------------------------------- + * Function: H5LT_dtype_to_text + * + * Purpose: Private function to convert HDF5 data type to DDL description. + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +char * +H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, bool no_user_buf) +{ + H5T_class_t tcls; + char tmp_str[TMP_LEN]; + int i; + + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, NULL))) + goto out; + + if (lang != H5LT_DDL) { + snprintf(dt_str, *slen, "only DDL is supported for now"); + goto out; + } + + if ((tcls = H5Tget_class(dtype)) < 0) + goto out; + + switch (tcls) { + case H5T_INTEGER: + case H5T_BITFIELD: + if (H5Tequal(dtype, H5T_STD_I8BE)) { + snprintf(dt_str, *slen, "H5T_STD_I8BE"); + } + else if (H5Tequal(dtype, H5T_STD_I8LE)) { + snprintf(dt_str, *slen, "H5T_STD_I8LE"); + } + else if (H5Tequal(dtype, H5T_STD_I16BE)) { + snprintf(dt_str, *slen, "H5T_STD_I16BE"); + } + else if (H5Tequal(dtype, H5T_STD_I16LE)) { + snprintf(dt_str, *slen, "H5T_STD_I16LE"); + } + else if (H5Tequal(dtype, H5T_STD_I32BE)) { + snprintf(dt_str, *slen, "H5T_STD_I32BE"); + } + else if (H5Tequal(dtype, H5T_STD_I32LE)) { + snprintf(dt_str, *slen, "H5T_STD_I32LE"); + } + else if (H5Tequal(dtype, H5T_STD_I64BE)) { + snprintf(dt_str, *slen, "H5T_STD_I64BE"); + } + else if (H5Tequal(dtype, H5T_STD_I64LE)) { + snprintf(dt_str, *slen, "H5T_STD_I64LE"); + } + else if (H5Tequal(dtype, H5T_STD_U8BE)) { + snprintf(dt_str, *slen, "H5T_STD_U8BE"); + } + else if (H5Tequal(dtype, H5T_STD_U8LE)) { + snprintf(dt_str, *slen, "H5T_STD_U8LE"); + } + else if (H5Tequal(dtype, H5T_STD_U16BE)) { + snprintf(dt_str, *slen, "H5T_STD_U16BE"); + } + else if (H5Tequal(dtype, H5T_STD_U16LE)) { + snprintf(dt_str, *slen, "H5T_STD_U16LE"); + } + else if (H5Tequal(dtype, H5T_STD_U32BE)) { + snprintf(dt_str, *slen, "H5T_STD_U32BE"); + } + else if (H5Tequal(dtype, H5T_STD_U32LE)) { + snprintf(dt_str, *slen, "H5T_STD_U32LE"); + } + else if (H5Tequal(dtype, H5T_STD_U64BE)) { + snprintf(dt_str, *slen, "H5T_STD_U64BE"); + } + else if (H5Tequal(dtype, H5T_STD_U64LE)) { + snprintf(dt_str, *slen, "H5T_STD_U64LE"); + } + else if (H5Tequal(dtype, H5T_NATIVE_SCHAR)) { + snprintf(dt_str, *slen, "H5T_NATIVE_SCHAR"); + } + else if (H5Tequal(dtype, H5T_NATIVE_UCHAR)) { + snprintf(dt_str, *slen, "H5T_NATIVE_UCHAR"); + } + else if (H5Tequal(dtype, H5T_NATIVE_SHORT)) { + snprintf(dt_str, *slen, "H5T_NATIVE_SHORT"); + } + else if (H5Tequal(dtype, H5T_NATIVE_USHORT)) { + snprintf(dt_str, *slen, "H5T_NATIVE_USHORT"); + } + else if (H5Tequal(dtype, H5T_NATIVE_INT)) { + snprintf(dt_str, *slen, "H5T_NATIVE_INT"); + } + else if (H5Tequal(dtype, H5T_NATIVE_UINT)) { + snprintf(dt_str, *slen, "H5T_NATIVE_UINT"); + } + else if (H5Tequal(dtype, H5T_NATIVE_LONG)) { + snprintf(dt_str, *slen, "H5T_NATIVE_LONG"); + } + else if (H5Tequal(dtype, H5T_NATIVE_ULONG)) { + snprintf(dt_str, *slen, "H5T_NATIVE_ULONG"); + } + else if (H5Tequal(dtype, H5T_NATIVE_LLONG)) { + snprintf(dt_str, *slen, "H5T_NATIVE_LLONG"); + } + else if (H5Tequal(dtype, H5T_NATIVE_ULLONG)) { + snprintf(dt_str, *slen, "H5T_NATIVE_ULLONG"); + } + else { + snprintf(dt_str, *slen, "undefined integer"); + } + + break; + case H5T_FLOAT: + if (H5Tequal(dtype, H5T_IEEE_F32BE)) { + snprintf(dt_str, *slen, "H5T_IEEE_F32BE"); + } + else if (H5Tequal(dtype, H5T_IEEE_F32LE)) { + snprintf(dt_str, *slen, "H5T_IEEE_F32LE"); + } + else if (H5Tequal(dtype, H5T_IEEE_F64BE)) { + snprintf(dt_str, *slen, "H5T_IEEE_F64BE"); + } + else if (H5Tequal(dtype, H5T_IEEE_F64LE)) { + snprintf(dt_str, *slen, "H5T_IEEE_F64LE"); + } + else if (H5Tequal(dtype, H5T_NATIVE_FLOAT)) { + snprintf(dt_str, *slen, "H5T_NATIVE_FLOAT"); + } + else if (H5Tequal(dtype, H5T_NATIVE_DOUBLE)) { + snprintf(dt_str, *slen, "H5T_NATIVE_DOUBLE"); + } + else if (H5Tequal(dtype, H5T_NATIVE_LDOUBLE)) { + snprintf(dt_str, *slen, "H5T_NATIVE_LDOUBLE"); + } + else { + snprintf(dt_str, *slen, "undefined float"); + } + + break; + case H5T_STRING: { + /* Make a copy of type in memory in case when DTYPE is on disk, the size + * will be bigger than in memory. This makes it easier to compare + * types in memory. */ + hid_t str_type; + H5T_order_t order; + hid_t tmp_type; + size_t size; + H5T_str_t str_pad; + H5T_cset_t cset; + htri_t is_vlstr; + + if ((tmp_type = H5Tcopy(dtype)) < 0) + goto out; + if ((size = H5Tget_size(tmp_type)) == 0) + goto out; + if ((str_pad = H5Tget_strpad(tmp_type)) < 0) + goto out; + if ((cset = H5Tget_cset(tmp_type)) < 0) + goto out; + if ((is_vlstr = H5Tis_variable_str(tmp_type)) < 0) + goto out; + + /* Print lead-in */ + snprintf(dt_str, *slen, "H5T_STRING {\n"); + indent += COL; + + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + + if (is_vlstr) + snprintf(tmp_str, TMP_LEN, "STRSIZE H5T_VARIABLE;\n"); + else + snprintf(tmp_str, TMP_LEN, "STRSIZE %d;\n", (int)size); + + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + + if (str_pad == H5T_STR_NULLTERM) + snprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLTERM;\n"); + else if (str_pad == H5T_STR_NULLPAD) + snprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLPAD;\n"); + else if (str_pad == H5T_STR_SPACEPAD) + snprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_SPACEPAD;\n"); + else + snprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_ERROR;\n"); + + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + + if (cset == H5T_CSET_ASCII) + snprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_ASCII;\n"); + else if (cset == H5T_CSET_UTF8) + snprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_UTF8;\n"); + else + snprintf(tmp_str, TMP_LEN, "CSET unknown;\n"); + + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + /* Reproduce a C type string */ + if ((str_type = H5Tcopy(H5T_C_S1)) < 0) + goto out; + if (is_vlstr) { + if (H5Tset_size(str_type, H5T_VARIABLE) < 0) + goto out; + } + else { + if (H5Tset_size(str_type, size) < 0) + goto out; + } + if (H5Tset_cset(str_type, cset) < 0) + goto out; + if (H5Tset_strpad(str_type, str_pad) < 0) + goto out; + + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + + /* Check C variable-length string first. Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + snprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + goto next; + } + + /* Change the endianness and see if they're equal. */ + if ((order = H5Tget_order(tmp_type)) < 0) + goto out; + if (order == H5T_ORDER_LE) { + if (H5Tset_order(str_type, H5T_ORDER_LE) < 0) + goto out; + } + else if (order == H5T_ORDER_BE) { + if (H5Tset_order(str_type, H5T_ORDER_BE) < 0) + goto out; + } + + if (H5Tequal(tmp_type, str_type)) { + snprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + goto next; + } + + /* If not equal to C variable-length string, check Fortran type. + * Actually H5Tequal can't tell difference between H5T_C_S1 and + * H5T_FORTRAN_S1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + if (H5Tclose(str_type) < 0) + goto out; + if ((str_type = H5Tcopy(H5T_FORTRAN_S1)) < 0) + goto out; + if (H5Tset_cset(str_type, cset) < 0) + goto out; + if (H5Tset_size(str_type, size) < 0) + goto out; + if (H5Tset_strpad(str_type, str_pad) < 0) + goto out; + + /* Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + snprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + goto next; + } + + /* Change the endianness and see if they're equal. */ + if ((order = H5Tget_order(tmp_type)) < 0) + goto out; + if (order == H5T_ORDER_LE) { + if (H5Tset_order(str_type, H5T_ORDER_LE) < 0) + goto out; + } + else if (order == H5T_ORDER_BE) { + if (H5Tset_order(str_type, H5T_ORDER_BE) < 0) + goto out; + } + + /* Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + snprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + goto next; + } + + /* Type doesn't match any of above. */ + snprintf(tmp_str, TMP_LEN, "CTYPE unknown_one_character_type;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + +next: + H5Tclose(str_type); + H5Tclose(tmp_type); + + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + snprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + break; + } + case H5T_OPAQUE: { + char *tag = NULL; + + /* Print lead-in */ + snprintf(dt_str, *slen, "H5T_OPAQUE {\n"); + indent += COL; + + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + snprintf(tmp_str, TMP_LEN, "OPQ_SIZE %lu;\n", (unsigned long)H5Tget_size(dtype)); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + tag = H5Tget_tag(dtype); + if (tag) { + snprintf(tmp_str, TMP_LEN, "OPQ_TAG \"%s\";\n", tag); + if (tag) + H5free_memory(tag); + tag = NULL; + } + else + snprintf(tmp_str, TMP_LEN, "OPQ_TAG \"\";\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + snprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + break; + } + case H5T_ENUM: { + hid_t super; + size_t super_len; + char *stmp = NULL; + + /* Print lead-in */ + snprintf(dt_str, *slen, "H5T_ENUM {\n"); + indent += COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + + if ((super = H5Tget_super(dtype)) < 0) + goto out; + if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) + goto out; + stmp = (char *)calloc(super_len, sizeof(char)); + if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) { + free(stmp); + goto out; + } + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) { + free(stmp); + goto out; + } + + if (stmp) + free(stmp); + stmp = NULL; + + snprintf(tmp_str, TMP_LEN, ";\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + H5Tclose(super); + + if (!(dt_str = print_enum(dtype, dt_str, slen, no_user_buf, indent))) + goto out; + + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + snprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + break; + } + case H5T_VLEN: { + hid_t super; + size_t super_len; + char *stmp = NULL; + + /* Print lead-in */ + snprintf(dt_str, *slen, "H5T_VLEN {\n"); + indent += COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + + if ((super = H5Tget_super(dtype)) < 0) + goto out; + if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) + goto out; + stmp = (char *)calloc(super_len, sizeof(char)); + if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) { + free(stmp); + goto out; + } + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) { + free(stmp); + goto out; + } + + if (stmp) + free(stmp); + stmp = NULL; + snprintf(tmp_str, TMP_LEN, "\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + H5Tclose(super); + + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + snprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + break; + } + case H5T_ARRAY: { + hid_t super; + size_t super_len; + char *stmp = NULL; + hsize_t dims[H5S_MAX_RANK]; + int ndims; + + /* Print lead-in */ + snprintf(dt_str, *slen, "H5T_ARRAY {\n"); + indent += COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + + /* Get array information */ + if ((ndims = H5Tget_array_ndims(dtype)) < 0) + goto out; + if (H5Tget_array_dims2(dtype, dims) < 0) + goto out; + + /* Print array dimensions */ + for (i = 0; i < ndims; i++) { + snprintf(tmp_str, TMP_LEN, "[%d]", (int)dims[i]); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + } + snprintf(tmp_str, TMP_LEN, " "); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + if ((super = H5Tget_super(dtype)) < 0) + goto out; + if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) + goto out; + stmp = (char *)calloc(super_len, sizeof(char)); + if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) { + free(stmp); + goto out; + } + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) { + free(stmp); + goto out; + } + if (stmp) + free(stmp); + stmp = NULL; + snprintf(tmp_str, TMP_LEN, "\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + H5Tclose(super); + + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + snprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + break; + } + case H5T_COMPOUND: { + char *mname = NULL; + hid_t mtype; + size_t moffset; + H5T_class_t mclass; + size_t mlen; + char *mtmp = NULL; + int nmembs; + + if ((nmembs = H5Tget_nmembers(dtype)) < 0) + goto out; + + snprintf(dt_str, *slen, "H5T_COMPOUND {\n"); + indent += COL; + + for (i = 0; i < nmembs; i++) { + if ((mname = H5Tget_member_name(dtype, (unsigned)i)) == NULL) + goto out; + if ((mtype = H5Tget_member_type(dtype, (unsigned)i)) < 0) + goto out; + moffset = H5Tget_member_offset(dtype, (unsigned)i); + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + + if ((mclass = H5Tget_class(mtype)) < 0) + goto out; + if (H5T_COMPOUND == mclass) + indent += COL; + + if (H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0) + goto out; + mtmp = (char *)calloc(mlen, sizeof(char)); + if (H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) { + free(mtmp); + goto out; + } + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp))) { + free(mtmp); + goto out; + } + if (mtmp) + free(mtmp); + mtmp = NULL; + + if (H5T_COMPOUND == mclass) + indent -= COL; + + snprintf(tmp_str, TMP_LEN, " \"%s\"", mname); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + if (mname) + H5free_memory(mname); + mname = NULL; + + snprintf(tmp_str, TMP_LEN, " : %lu;\n", (unsigned long)moffset); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + } + + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + snprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + break; + } + case H5T_TIME: + snprintf(dt_str, *slen, "H5T_TIME: not yet implemented"); + break; + case H5T_NO_CLASS: + snprintf(dt_str, *slen, "H5T_NO_CLASS"); + break; + case H5T_REFERENCE: + if (H5Tequal(dtype, H5T_STD_REF_DSETREG) == true) { + snprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_DSETREG }"); + } + else { + snprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_OBJECT }"); + } + break; + case H5T_NCLASSES: + break; + default: + snprintf(dt_str, *slen, "unknown data type"); + } + + return dt_str; + +out: + return NULL; +} + +/*------------------------------------------------------------------------- + * + * Get attribute functions + * + *------------------------------------------------------------------------- + */ + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_string + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTget_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, char *data) +{ + /* identifiers */ + hid_t obj_id; + + /* check the arguments */ + if (obj_name == NULL) + return -1; + if (attr_name == NULL) + return -1; + + /* Open the object */ + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + return -1; + + /* Get the attribute */ + if (H5LT_get_attribute_disk(obj_id, attr_name, data) < 0) { + H5Oclose(obj_id); + return -1; + } + + /* Close the object */ + if (H5Oclose(obj_id) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_char + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, char *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_CHAR, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_uchar + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned char *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UCHAR, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_short + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, short *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_SHORT, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_ushort + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned short *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_USHORT, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_int + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, int *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_INT, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_uint + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned int *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UINT, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_long + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, long *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LONG, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_long_long + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: This function was added to support INTEGER*8 Fortran types + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, long long *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LLONG, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_ulong + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULONG, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_ullong + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long long *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULLONG, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_float + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTget_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, float *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_FLOAT, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_double + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTget_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, double *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_DOUBLE, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute + * + * Purpose: Reads an attribute named attr_name with the memory type mem_type_id + * + * Return: Success: 0, Failure: -1 + * + * Comments: Private function + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LTget_attribute(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, void *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, mem_type_id, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- + * private functions + *------------------------------------------------------------------------- + */ + +/*------------------------------------------------------------------------- + * Function: H5LT_get_attribute_mem + * + * Purpose: Reads an attribute named attr_name with the memory type mem_type_id + * + * Return: Success: 0, Failure: -1 + * + * Comments: Private function + * + *------------------------------------------------------------------------- + */ + +static herr_t +H5LT_get_attribute_mem(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, + void *data) +{ + /* identifiers */ + hid_t obj_id = -1; + hid_t attr_id = -1; + + /* check the arguments */ + if (obj_name == NULL) + return -1; + if (attr_name == NULL) + return -1; + + /* Open the object */ + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + goto out; + + if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) + goto out; + + if (H5Aread(attr_id, mem_type_id, data) < 0) + goto out; + + if (H5Aclose(attr_id) < 0) + goto out; + attr_id = -1; + + /* Close the object */ + if (H5Oclose(obj_id) < 0) + goto out; + obj_id = -1; + + return 0; + +out: + if (obj_id > 0) + H5Oclose(obj_id); + if (attr_id > 0) + H5Aclose(attr_id); + return -1; +} + +/*------------------------------------------------------------------------- + * Function: H5LT_get_attribute_disk + * + * Purpose: Reads an attribute named attr_name with the datatype stored on disk + * + * Return: Success: 0, Failure: -1 + * + * Comments: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5LT_get_attribute_disk(hid_t loc_id, const char *attr_name, void *attr_out) +{ + /* identifiers */ + hid_t attr_id; + hid_t attr_type; + + if ((attr_id = H5Aopen(loc_id, attr_name, H5P_DEFAULT)) < 0) + return -1; + + if ((attr_type = H5Aget_type(attr_id)) < 0) + goto out; + + if (H5Aread(attr_id, attr_type, attr_out) < 0) + goto out; + + if (H5Tclose(attr_type) < 0) + goto out; + + if (H5Aclose(attr_id) < 0) + return -1; + + return 0; + +out: + H5Tclose(attr_type); + H5Aclose(attr_id); + return -1; +} + +/*------------------------------------------------------------------------- + * Function: H5LT_set_attribute_string + * + * Purpose: creates and writes an attribute named NAME to the dataset DSET_ID + * + * Return: FAIL on error, SUCCESS on success + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LT_set_attribute_string(hid_t dset_id, const char *name, const char *buf) +{ + hid_t tid; + hid_t sid = -1; + hid_t aid = -1; + htri_t has_attr; + size_t size; + + /* Delete the attribute if it already exists */ + if ((has_attr = H5Aexists(dset_id, name)) < 0) + return FAIL; + if (has_attr > 0) + if (H5Adelete(dset_id, name) < 0) + return FAIL; + + /*------------------------------------------------------------------------- + * create the attribute type + *------------------------------------------------------------------------- + */ + if ((tid = H5Tcopy(H5T_C_S1)) < 0) + return FAIL; + + size = strlen(buf) + 1; /* extra null term */ + + if (H5Tset_size(tid, (size_t)size) < 0) + goto out; + + if (H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) + goto out; + + if ((sid = H5Screate(H5S_SCALAR)) < 0) + goto out; + + /*------------------------------------------------------------------------- + * create and write the attribute + *------------------------------------------------------------------------- + */ + if ((aid = H5Acreate2(dset_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + + if (H5Awrite(aid, tid, buf) < 0) + goto out; + + if (H5Aclose(aid) < 0) + goto out; + + if (H5Sclose(sid) < 0) + goto out; + + if (H5Tclose(tid) < 0) + goto out; + + return SUCCEED; + + /* error zone */ +out: + H5E_BEGIN_TRY + { + H5Aclose(aid); + H5Tclose(tid); + H5Sclose(sid); + } + H5E_END_TRY + return FAIL; +} + +htri_t +H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid) +{ + char *tmp_path = NULL; /* Temporary copy of the path */ + char *curr_name; /* Pointer to current component of path name */ + char *delimit; /* Pointer to path delimiter during traversal */ + H5I_type_t obj_type; + htri_t link_exists, obj_exists; + size_t path_length; + htri_t ret_value; + + /* Initialize */ + ret_value = false; + + /* check the arguments */ + if (path == NULL) { + ret_value = FAIL; + goto done; + } + + /* Find the type of loc_id */ + if ((obj_type = H5Iget_type(loc_id)) == H5I_BADID) { + ret_value = FAIL; + goto done; + } + + /* Find the length of the path */ + path_length = strlen(path); + + /* Check if the identifier is the object itself, i.e. path is '.' */ + if (strncmp(path, ".", path_length) == 0) { + if (check_object_valid) { + obj_exists = H5Oexists_by_name(loc_id, path, H5P_DEFAULT); + ret_value = obj_exists; + goto done; + } + else { + ret_value = true; /* Since the object is the identifier itself, + * we can only check if loc_id is a valid type */ + goto done; + } + } + + /* Duplicate the path to use */ + if (NULL == (tmp_path = HDstrdup(path))) { + ret_value = FAIL; + goto done; + } + + curr_name = tmp_path; + + /* check if absolute pathname */ + if (strncmp(path, "/", 1) == 0) + curr_name++; + + /* check if relative path name starts with "./" */ + if (strncmp(path, "./", 2) == 0) + curr_name += 2; + + while ((delimit = strchr(curr_name, '/')) != NULL) { + /* Change the delimiter to terminate the string */ + *delimit = '\0'; + + obj_exists = false; + if ((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) { + ret_value = FAIL; + goto done; + } + + /* If target link does not exist then no reason to + * continue checking the path */ + if (link_exists != true) { + ret_value = false; + goto done; + } + + /* Determine if link resolves to an actual object */ + if ((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { + ret_value = FAIL; + goto done; + } + + if (obj_exists != true) + break; + + /* Change the delimiter back to '/' */ + *delimit = '/'; + + /* Advance the pointer in the path to the start of the next component */ + curr_name = delimit + 1; + + } /* end while */ + + /* Should be pointing to the last component in the path name now... */ + + /* Check if link does not exist */ + if ((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) { + ret_value = FAIL; + } + else { + ret_value = link_exists; + /* Determine if link resolves to an actual object for check_object_valid true */ + if (check_object_valid == true && link_exists == true) { + if ((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { + ret_value = FAIL; + } + else { + ret_value = obj_exists; + } + } + } + +done: + if (tmp_path != NULL) + free(tmp_path); + + return ret_value; +} diff --git a/externals/coda-oss/modules/drivers/hdf5/source/H5LTanalyze.c b/externals/coda-oss/modules/drivers/hdf5/source/H5LTanalyze.c new file mode 100644 index 000000000..8890b8e48 --- /dev/null +++ b/externals/coda-oss/modules/drivers/hdf5/source/H5LTanalyze.c @@ -0,0 +1,2582 @@ +#if defined (__GNUC__) +#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wimplicit-function-declaration" +#pragma GCC diagnostic ignored "-Wmissing-prototypes" +#pragma GCC diagnostic ignored "-Wnested-externs" +#pragma GCC diagnostic ignored "-Wold-style-definition" +#pragma GCC diagnostic ignored "-Wredundant-decls" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wstrict-overflow" +#pragma GCC diagnostic ignored "-Wstrict-prototypes" +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" +#if !defined (__clang__) +#pragma GCC diagnostic ignored "-Wlarger-than=" +#pragma GCC diagnostic ignored "-Wsuggest-attribute=const" +#pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" +#endif +#pragma GCC diagnostic ignored "-Wswitch-default" +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-macros" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif +#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 600 +#pragma GCC diagnostic ignored "-Wnull-dereference" +#endif +#elif defined __SUNPRO_CC +#pragma disable_warn +#elif defined _MSC_VER +#pragma warning(push, 1) +#endif +#line 2 "hl/src//H5LTanalyze.c" +/* Quiet warnings about integer type macro redefinitions on Visual Studio + * (MSVC doesn't define STDC_VERSION, but has inttypes.h). This is an + * issue that is apparently fixed in flex 2.6.5. + */ +#include + +#line 9 "hl/src//H5LTanalyze.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define yy_create_buffer H5LTyy_create_buffer +#define yy_delete_buffer H5LTyy_delete_buffer +#define yy_scan_buffer H5LTyy_scan_buffer +#define yy_scan_string H5LTyy_scan_string +#define yy_scan_bytes H5LTyy_scan_bytes +#define yy_init_buffer H5LTyy_init_buffer +#define yy_flush_buffer H5LTyy_flush_buffer +#define yy_load_buffer_state H5LTyy_load_buffer_state +#define yy_switch_to_buffer H5LTyy_switch_to_buffer +#define yypush_buffer_state H5LTyypush_buffer_state +#define yypop_buffer_state H5LTyypop_buffer_state +#define yyensure_buffer_stack H5LTyyensure_buffer_stack +#define yy_flex_debug H5LTyy_flex_debug +#define yyin H5LTyyin +#define yyleng H5LTyyleng +#define yylex H5LTyylex +#define yylineno H5LTyylineno +#define yyout H5LTyyout +#define yyrestart H5LTyyrestart +#define yytext H5LTyytext +#define yywrap H5LTyywrap +#define yyalloc H5LTyyalloc +#define yyrealloc H5LTyyrealloc +#define yyfree H5LTyyfree + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define H5LTyy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer H5LTyy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define H5LTyy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer H5LTyy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define H5LTyy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer H5LTyy_scan_buffer +#endif + +#ifdef yy_scan_string +#define H5LTyy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string H5LTyy_scan_string +#endif + +#ifdef yy_scan_bytes +#define H5LTyy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes H5LTyy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define H5LTyy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer H5LTyy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define H5LTyy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer H5LTyy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define H5LTyy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state H5LTyy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define H5LTyy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer H5LTyy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define H5LTyypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state H5LTyypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define H5LTyypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state H5LTyypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define H5LTyyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack H5LTyyensure_buffer_stack +#endif + +#ifdef yylex +#define H5LTyylex_ALREADY_DEFINED +#else +#define yylex H5LTyylex +#endif + +#ifdef yyrestart +#define H5LTyyrestart_ALREADY_DEFINED +#else +#define yyrestart H5LTyyrestart +#endif + +#ifdef yylex_init +#define H5LTyylex_init_ALREADY_DEFINED +#else +#define yylex_init H5LTyylex_init +#endif + +#ifdef yylex_init_extra +#define H5LTyylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra H5LTyylex_init_extra +#endif + +#ifdef yylex_destroy +#define H5LTyylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy H5LTyylex_destroy +#endif + +#ifdef yyget_debug +#define H5LTyyget_debug_ALREADY_DEFINED +#else +#define yyget_debug H5LTyyget_debug +#endif + +#ifdef yyset_debug +#define H5LTyyset_debug_ALREADY_DEFINED +#else +#define yyset_debug H5LTyyset_debug +#endif + +#ifdef yyget_extra +#define H5LTyyget_extra_ALREADY_DEFINED +#else +#define yyget_extra H5LTyyget_extra +#endif + +#ifdef yyset_extra +#define H5LTyyset_extra_ALREADY_DEFINED +#else +#define yyset_extra H5LTyyset_extra +#endif + +#ifdef yyget_in +#define H5LTyyget_in_ALREADY_DEFINED +#else +#define yyget_in H5LTyyget_in +#endif + +#ifdef yyset_in +#define H5LTyyset_in_ALREADY_DEFINED +#else +#define yyset_in H5LTyyset_in +#endif + +#ifdef yyget_out +#define H5LTyyget_out_ALREADY_DEFINED +#else +#define yyget_out H5LTyyget_out +#endif + +#ifdef yyset_out +#define H5LTyyset_out_ALREADY_DEFINED +#else +#define yyset_out H5LTyyset_out +#endif + +#ifdef yyget_leng +#define H5LTyyget_leng_ALREADY_DEFINED +#else +#define yyget_leng H5LTyyget_leng +#endif + +#ifdef yyget_text +#define H5LTyyget_text_ALREADY_DEFINED +#else +#define yyget_text H5LTyyget_text +#endif + +#ifdef yyget_lineno +#define H5LTyyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno H5LTyyget_lineno +#endif + +#ifdef yyset_lineno +#define H5LTyyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno H5LTyyset_lineno +#endif + +#ifdef yywrap +#define H5LTyywrap_ALREADY_DEFINED +#else +#define yywrap H5LTyywrap +#endif + +#ifdef yyalloc +#define H5LTyyalloc_ALREADY_DEFINED +#else +#define yyalloc H5LTyyalloc +#endif + +#ifdef yyrealloc +#define H5LTyyrealloc_ALREADY_DEFINED +#else +#define yyrealloc H5LTyyrealloc +#endif + +#ifdef yyfree +#define H5LTyyfree_ALREADY_DEFINED +#else +#define yyfree H5LTyyfree +#endif + +#ifdef yytext +#define H5LTyytext_ALREADY_DEFINED +#else +#define yytext H5LTyytext +#endif + +#ifdef yyleng +#define H5LTyyleng_ALREADY_DEFINED +#else +#define yyleng H5LTyyleng +#endif + +#ifdef yyin +#define H5LTyyin_ALREADY_DEFINED +#else +#define yyin H5LTyyin +#endif + +#ifdef yyout +#define H5LTyyout_ALREADY_DEFINED +#else +#define yyout H5LTyyout +#endif + +#ifdef yy_flex_debug +#define H5LTyy_flex_debug_ALREADY_DEFINED +#else +#define yy_flex_debug H5LTyy_flex_debug +#endif + +#ifdef yylineno +#define H5LTyylineno_ALREADY_DEFINED +#else +#define yylineno H5LTyylineno +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern int yyleng; + +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = NULL; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); + +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); + +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +typedef flex_uint8_t YY_CHAR; + +FILE *yyin = NULL, *yyout = NULL; + +typedef int yy_state_type; + +extern int yylineno; +int yylineno = 1; + +extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; +#define YY_NUM_RULES 64 +#define YY_END_OF_BUFFER 65 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[275] = + { 0, + 63, 63, 65, 64, 63, 64, 55, 61, 62, 64, + 64, 64, 64, 59, 60, 57, 58, 63, 0, 55, + 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, + 0, 38, 0, 0, 0, 0, 0, 39, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 54, 36, 0, 0, 0, 45, 49, 0, 0, + 0, 0, 0, 0, 0, 0, 51, 53, 50, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, + 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 2, 0, 0, 0, 0, 0, 0, 9, 10, 0, + 0, 47, 0, 44, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 3, 4, 5, 6, 7, 8, 11, 12, + 13, 14, 15, 16, 0, 0, 0, 43, 46, 28, + 29, 30, 31, 0, 0, 0, 22, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 0, 24, 0, 0, 0, 23, + 0, 0, 0, 41, 0, 0, 0, 32, 0, 26, + 18, 20, 19, 0, 25, 0, 40, 42, 33, 0, + 27, 21, 34, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, + 7, 8, 9, 10, 4, 11, 4, 12, 13, 1, + 1, 1, 1, 1, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 1, 1, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 1, 1, 34, 35, + 36, 1, 37, 1, 38, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 39, 1, 40, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static const YY_CHAR yy_meta[41] = + { 0, + 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, + 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[277] = + { 0, + 0, 0, 299, 300, 296, 0, 0, 300, 300, 11, + 288, 269, 264, 300, 300, 300, 300, 292, 290, 0, + 274, 257, 259, 261, 259, 300, 256, 259, 247, 246, + 16, 300, 265, 33, 14, 268, 259, 300, 251, 24, + 254, 252, 259, 262, 248, 243, 34, 251, 258, 254, + 235, 240, 244, 249, 236, 233, 235, 245, 231, 247, + 36, 231, 241, 223, 237, 300, 238, 241, 227, 222, + 247, 227, 219, 231, 226, 219, 208, 34, 223, 219, + 225, 300, 300, 208, 215, 202, 300, 300, 210, 200, + 204, 204, 38, 210, 39, 220, 300, 300, 300, 201, + + 47, 218, 212, 212, 211, 66, 73, 208, 195, 199, + 210, 199, 193, 191, 196, 75, 182, 300, 209, 212, + 209, 52, 206, 209, 206, 66, 300, 190, 198, 188, + 193, 193, 189, 169, 200, 197, 74, 71, 72, 77, + 186, 185, 84, 86, 87, 184, 183, 177, 183, 180, + 300, 175, 185, 165, 88, 90, 173, 167, 169, 166, + 91, 99, 96, 172, 171, 170, 169, 168, 167, 300, + 300, 166, 165, 164, 163, 162, 161, 300, 300, 94, + 160, 300, 155, 300, 171, 157, 156, 155, 154, 157, + 138, 143, 137, 141, 140, 140, 143, 137, 141, 136, + + 101, 139, 300, 300, 300, 300, 300, 300, 300, 300, + 300, 300, 300, 300, 145, 140, 130, 300, 300, 300, + 300, 300, 300, 127, 140, 140, 300, 121, 127, 131, + 136, 120, 134, 116, 120, 120, 118, 126, 113, 127, + 300, 117, 108, 123, 117, 300, 107, 104, 105, 300, + 108, 112, 102, 300, 105, 106, 104, 300, 93, 300, + 300, 300, 300, 78, 300, 57, 300, 300, 300, 56, + 300, 300, 300, 300, 127, 65 + } ; + +static const flex_int16_t yy_def[277] = + { 0, + 274, 1, 274, 274, 274, 275, 276, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 275, 276, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 0, 274, 274 + } ; + +static const flex_int16_t yy_nxt[341] = + { 0, + 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, + 7, 8, 9, 4, 4, 10, 4, 4, 4, 4, + 11, 4, 4, 4, 4, 12, 4, 4, 4, 13, + 4, 4, 4, 4, 4, 14, 15, 4, 16, 17, + 21, 22, 36, 48, 49, 37, 39, 62, 40, 53, + 41, 42, 77, 54, 43, 94, 63, 44, 45, 106, + 113, 55, 46, 109, 78, 47, 141, 20, 110, 107, + 119, 95, 120, 273, 142, 121, 122, 123, 114, 124, + 146, 135, 125, 126, 136, 164, 166, 272, 147, 157, + 158, 168, 159, 165, 167, 160, 161, 271, 172, 169, + + 174, 176, 186, 162, 188, 163, 173, 194, 175, 177, + 187, 199, 189, 195, 197, 270, 196, 200, 201, 198, + 215, 269, 268, 235, 216, 202, 236, 19, 267, 19, + 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, + 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, + 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, + 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, + 224, 223, 222, 221, 220, 219, 218, 217, 214, 213, + 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, + 193, 192, 191, 190, 185, 184, 183, 182, 181, 180, + + 179, 178, 171, 170, 156, 155, 154, 153, 152, 151, + 150, 149, 148, 145, 144, 143, 140, 139, 138, 137, + 134, 133, 132, 131, 130, 129, 128, 127, 118, 117, + 116, 115, 112, 111, 108, 105, 104, 103, 102, 101, + 100, 99, 98, 97, 96, 93, 92, 91, 90, 89, + 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, + 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, + 66, 65, 64, 61, 60, 59, 58, 57, 56, 52, + 51, 50, 38, 35, 34, 33, 32, 31, 30, 29, + 28, 27, 26, 18, 25, 24, 23, 18, 274, 3, + + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274 + } ; + +static const flex_int16_t yy_chk[341] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 10, 10, 31, 35, 35, 31, 34, 47, 34, 40, + 34, 34, 61, 40, 34, 78, 47, 34, 34, 93, + 101, 40, 34, 95, 61, 34, 122, 276, 95, 93, + 106, 78, 106, 270, 122, 106, 106, 107, 101, 107, + 126, 116, 107, 107, 116, 138, 139, 266, 126, 137, + 137, 140, 137, 138, 139, 137, 137, 264, 143, 140, + + 144, 145, 155, 137, 156, 137, 143, 161, 144, 145, + 155, 163, 156, 161, 162, 259, 161, 163, 163, 162, + 180, 257, 256, 201, 180, 163, 201, 275, 255, 275, + 253, 252, 251, 249, 248, 247, 245, 244, 243, 242, + 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, + 230, 229, 228, 226, 225, 224, 217, 216, 215, 202, + 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, + 190, 189, 188, 187, 186, 185, 183, 181, 177, 176, + 175, 174, 173, 172, 169, 168, 167, 166, 165, 164, + 160, 159, 158, 157, 154, 153, 152, 150, 149, 148, + + 147, 146, 142, 141, 136, 135, 134, 133, 132, 131, + 130, 129, 128, 125, 124, 123, 121, 120, 119, 117, + 115, 114, 113, 112, 111, 110, 109, 108, 105, 104, + 103, 102, 100, 96, 94, 92, 91, 90, 89, 86, + 85, 84, 81, 80, 79, 77, 76, 75, 74, 73, + 72, 71, 70, 69, 68, 67, 65, 64, 63, 62, + 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, + 50, 49, 48, 46, 45, 44, 43, 42, 41, 39, + 37, 36, 33, 30, 29, 28, 27, 25, 24, 23, + 22, 21, 19, 18, 13, 12, 11, 5, 3, 274, + + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int yy_flex_debug; +int yy_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "hl/src//H5LTanalyze.l" +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* NOTE! + * + * If you make any changes to H5LTanalyze.l, please run bin/genparser to + * recreate the output files. + */ + +#line 28 "hl/src//H5LTanalyze.l" +#include +#include +#include +#include + +#include "H5private.h" +#include "H5LTparse.h" + +static char *trim_quotes(const char *); +static int my_yyinput(char *, int); +#undef YY_INPUT +#define YY_INPUT(b, r, ms) (r=my_yyinput(b, ms)) +#define token(x) (int)x +#define hid(x) (hid_t)x + +#ifdef YY_BUF_SIZE +#undef YY_BUF_SIZE +#endif +#define YY_BUF_SIZE 262144 /*Define read buffer to be 256K*/ + +extern char *myinput; +extern size_t input_len; + +#line 909 "hl/src//H5LTanalyze.c" +#line 910 "hl/src//H5LTanalyze.c" + +#define INITIAL 0 + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals ( void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( void ); + +int yyget_debug ( void ); + +void yyset_debug ( int debug_flag ); + +YY_EXTRA_TYPE yyget_extra ( void ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined ); + +FILE *yyget_in ( void ); + +void yyset_in ( FILE * _in_str ); + +FILE *yyget_out ( void ); + +void yyset_out ( FILE * _out_str ); + + int yyget_leng ( void ); + +char *yyget_text ( void ); + +int yyget_lineno ( void ); + +void yyset_lineno ( int _line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( void ); +#else +extern int yywrap ( void ); +#endif +#endif + +#ifndef YY_NO_UNPUT + + static void yyunput ( int c, char *buf_ptr ); + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * ); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( void ); +#else +static int input ( void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + int n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex (void); + +#define YY_DECL int yylex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + { +#line 53 "hl/src//H5LTanalyze.l" + + +#line 1122 "hl/src//H5LTanalyze.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 275 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 300 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 55 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_I8BE_TOKEN);} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 56 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_I8LE_TOKEN);} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 57 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_I16BE_TOKEN);} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 58 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_I16LE_TOKEN);} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 59 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_I32BE_TOKEN);} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 60 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_I32LE_TOKEN);} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 61 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_I64BE_TOKEN);} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 62 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_I64LE_TOKEN);} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 64 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_U8BE_TOKEN);} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 65 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_U8LE_TOKEN);} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 66 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_U16BE_TOKEN);} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 67 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_U16LE_TOKEN);} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 68 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_U32BE_TOKEN);} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 69 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_U32LE_TOKEN);} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 70 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_U64BE_TOKEN);} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 71 "hl/src//H5LTanalyze.l" +{return hid(H5T_STD_U64LE_TOKEN);} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 73 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_CHAR_TOKEN);} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 74 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_SCHAR_TOKEN);} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 75 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_UCHAR_TOKEN);} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 76 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_SHORT_TOKEN);} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 77 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_USHORT_TOKEN);} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 78 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_INT_TOKEN);} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 79 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_UINT_TOKEN);} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 80 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_LONG_TOKEN);} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 81 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_ULONG_TOKEN);} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 82 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_LLONG_TOKEN);} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 83 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_ULLONG_TOKEN);} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 85 "hl/src//H5LTanalyze.l" +{return hid(H5T_IEEE_F32BE_TOKEN);} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 86 "hl/src//H5LTanalyze.l" +{return hid(H5T_IEEE_F32LE_TOKEN);} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 87 "hl/src//H5LTanalyze.l" +{return hid(H5T_IEEE_F64BE_TOKEN);} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 88 "hl/src//H5LTanalyze.l" +{return hid(H5T_IEEE_F64LE_TOKEN);} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 89 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_FLOAT_TOKEN);} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 90 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_DOUBLE_TOKEN);} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 91 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_LDOUBLE_TOKEN);} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 93 "hl/src//H5LTanalyze.l" +{return token(H5T_STRING_TOKEN);} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 94 "hl/src//H5LTanalyze.l" +{return token(STRSIZE_TOKEN);} + YY_BREAK +case 37: +YY_RULE_SETUP +#line 95 "hl/src//H5LTanalyze.l" +{return token(STRPAD_TOKEN);} + YY_BREAK +case 38: +YY_RULE_SETUP +#line 96 "hl/src//H5LTanalyze.l" +{return token(CSET_TOKEN);} + YY_BREAK +case 39: +YY_RULE_SETUP +#line 97 "hl/src//H5LTanalyze.l" +{return token(CTYPE_TOKEN);} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 98 "hl/src//H5LTanalyze.l" +{return token(H5T_STR_NULLTERM_TOKEN);} + YY_BREAK +case 41: +YY_RULE_SETUP +#line 99 "hl/src//H5LTanalyze.l" +{return token(H5T_STR_NULLPAD_TOKEN);} + YY_BREAK +case 42: +YY_RULE_SETUP +#line 100 "hl/src//H5LTanalyze.l" +{return token(H5T_STR_SPACEPAD_TOKEN);} + YY_BREAK +case 43: +YY_RULE_SETUP +#line 101 "hl/src//H5LTanalyze.l" +{return token(H5T_CSET_ASCII_TOKEN);} + YY_BREAK +case 44: +YY_RULE_SETUP +#line 102 "hl/src//H5LTanalyze.l" +{return token(H5T_CSET_UTF8_TOKEN);} + YY_BREAK +case 45: +YY_RULE_SETUP +#line 103 "hl/src//H5LTanalyze.l" +{return token(H5T_C_S1_TOKEN);} + YY_BREAK +case 46: +YY_RULE_SETUP +#line 104 "hl/src//H5LTanalyze.l" +{return token(H5T_FORTRAN_S1_TOKEN);} + YY_BREAK +case 47: +YY_RULE_SETUP +#line 105 "hl/src//H5LTanalyze.l" +{return token(H5T_VARIABLE_TOKEN);} + YY_BREAK +case 48: +YY_RULE_SETUP +#line 107 "hl/src//H5LTanalyze.l" +{return token(H5T_COMPOUND_TOKEN);} + YY_BREAK +case 49: +YY_RULE_SETUP +#line 108 "hl/src//H5LTanalyze.l" +{return token(H5T_ENUM_TOKEN);} + YY_BREAK +case 50: +YY_RULE_SETUP +#line 109 "hl/src//H5LTanalyze.l" +{return token(H5T_ARRAY_TOKEN);} + YY_BREAK +case 51: +YY_RULE_SETUP +#line 110 "hl/src//H5LTanalyze.l" +{return token(H5T_VLEN_TOKEN);} + YY_BREAK +case 52: +YY_RULE_SETUP +#line 112 "hl/src//H5LTanalyze.l" +{return token(H5T_OPAQUE_TOKEN);} + YY_BREAK +case 53: +YY_RULE_SETUP +#line 113 "hl/src//H5LTanalyze.l" +{return token(OPQ_SIZE_TOKEN);} + YY_BREAK +case 54: +YY_RULE_SETUP +#line 114 "hl/src//H5LTanalyze.l" +{return token(OPQ_TAG_TOKEN);} + YY_BREAK +case 55: +YY_RULE_SETUP +#line 116 "hl/src//H5LTanalyze.l" +{ + H5LTyylval.ival = atoi(yytext); + return NUMBER; + } + YY_BREAK +case 56: +/* rule 56 can match eol */ +YY_RULE_SETUP +#line 121 "hl/src//H5LTanalyze.l" +{ + H5LTyylval.sval = trim_quotes(yytext); + return STRING; + } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 126 "hl/src//H5LTanalyze.l" +{return token('{');} + YY_BREAK +case 58: +YY_RULE_SETUP +#line 127 "hl/src//H5LTanalyze.l" +{return token('}');} + YY_BREAK +case 59: +YY_RULE_SETUP +#line 128 "hl/src//H5LTanalyze.l" +{return token('[');} + YY_BREAK +case 60: +YY_RULE_SETUP +#line 129 "hl/src//H5LTanalyze.l" +{return token(']');} + YY_BREAK +case 61: +YY_RULE_SETUP +#line 130 "hl/src//H5LTanalyze.l" +{return token(':');} + YY_BREAK +case 62: +YY_RULE_SETUP +#line 131 "hl/src//H5LTanalyze.l" +{return token(';');} + YY_BREAK +case 63: +/* rule 63 can match eol */ +YY_RULE_SETUP +#line 132 "hl/src//H5LTanalyze.l" +; + YY_BREAK +case 64: +YY_RULE_SETUP +#line 134 "hl/src//H5LTanalyze.l" +ECHO; + YY_BREAK +#line 1507 "hl/src//H5LTanalyze.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + yy_state_type yy_current_state; + char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 275 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + int yy_is_jam; + char *yy_cp = (yy_c_buf_p); + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 275 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 274); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + + static void yyunput (int c, char * yy_bp ) +{ + char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + int number_to_move = (yy_n_chars) + 2; + char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yy_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf ); + + yyfree( (void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr ) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg ) +{ + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int yyget_lineno (void) +{ + + return yylineno; +} + +/** Get the input stream. + * + */ +FILE *yyget_in (void) +{ + return yyin; +} + +/** Get the output stream. + * + */ +FILE *yyget_out (void) +{ + return yyout; +} + +/** Get the length of the current token. + * + */ +int yyget_leng (void) +{ + return yyleng; +} + +/** Get the current token. + * + */ + +char *yyget_text (void) +{ + return yytext; +} + +/** Set the current line number. + * @param _line_number line number + * + */ +void yyset_lineno (int _line_number ) +{ + + yylineno = _line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str ) +{ + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str ) +{ + yyout = _out_str ; +} + +int yyget_debug (void) +{ + return yy_flex_debug; +} + +void yyset_debug (int _bdebug ) +{ + yy_flex_debug = _bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = NULL; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = NULL; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } + + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n ) +{ + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s ) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 134 "hl/src//H5LTanalyze.l" + + +/* Allocate a copy of `quoted` with the double quote character at + * the beginning and the one at the end both removed. The caller is + * responsible for free()ing the copy. + */ +static char * +trim_quotes(const char *quoted) +{ + size_t len = strlen(quoted); + char *trimmed; + + assert(quoted[0] == '"' && quoted[len - 1] == '"'); + + trimmed = strdup(quoted + 1); + trimmed[len - 2] = '\0'; + + return trimmed; +} + +static int my_yyinput(char *buf, int max_size) +{ + int ret; + + memcpy(buf, myinput, input_len); + ret = (int)input_len; + return ret; +} + +int H5LTyyerror(const char *msg) +{ + printf("ERROR: %s before \"%s\".\n", msg, yytext); + return 0; +} + +int yywrap() +{ + return 1; +} + diff --git a/externals/coda-oss/modules/drivers/hdf5/source/H5LTparse.c b/externals/coda-oss/modules/drivers/hdf5/source/H5LTparse.c new file mode 100644 index 000000000..592b86320 --- /dev/null +++ b/externals/coda-oss/modules/drivers/hdf5/source/H5LTparse.c @@ -0,0 +1,2121 @@ +#if defined (__GNUC__) +#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wimplicit-function-declaration" +#pragma GCC diagnostic ignored "-Wmissing-prototypes" +#pragma GCC diagnostic ignored "-Wnested-externs" +#pragma GCC diagnostic ignored "-Wold-style-definition" +#pragma GCC diagnostic ignored "-Wredundant-decls" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wstrict-overflow" +#pragma GCC diagnostic ignored "-Wstrict-prototypes" +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" +#if !defined (__clang__) +#pragma GCC diagnostic ignored "-Wlarger-than=" +#pragma GCC diagnostic ignored "-Wsuggest-attribute=const" +#pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" +#endif +#pragma GCC diagnostic ignored "-Wswitch-default" +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-macros" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif +#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 600 +#pragma GCC diagnostic ignored "-Wnull-dereference" +#endif +#elif defined __SUNPRO_CC +#pragma disable_warn +#elif defined _MSC_VER +#pragma warning(push, 1) +#endif +/* A Bison parser, made by GNU Bison 3.8.2. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output, and Bison version. */ +#define YYBISON 30802 + +/* Bison version string. */ +#define YYBISON_VERSION "3.8.2" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + +/* Substitute the variable and function names. */ +#define yyparse H5LTyyparse +#define yylex H5LTyylex +#define yyerror H5LTyyerror +#define yydebug H5LTyydebug +#define yynerrs H5LTyynerrs +#define yylval H5LTyylval +#define yychar H5LTyychar + +/* First part of user prologue. */ +#line 19 "hl/src//H5LTparse.y" + +#include +#include +#include + +#include "H5private.h" + +extern int yylex(void); +extern int yyerror(const char *); + +#define STACK_SIZE 16 + +/*structure for compound type information*/ +struct cmpd_info { + hid_t id; /*type ID*/ + bool is_field; /*flag to lexer for compound member*/ + bool first_memb; /*flag for first compound member*/ +}; + +/*stack for nested compound type*/ +static struct cmpd_info cmpd_stack[STACK_SIZE] = { + {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, + {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, + {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, + {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1} }; + +static int csindex = -1; /*pointer to the top of compound stack*/ + +/*structure for array type information*/ +struct arr_info { + hsize_t dims[H5S_MAX_RANK]; /*size of each dimension, limited to 32 dimensions*/ + unsigned ndims; /*number of dimensions*/ + bool is_dim; /*flag to lexer for dimension*/ +}; +/*stack for nested array type*/ +static struct arr_info arr_stack[STACK_SIZE]; +static int asindex = -1; /*pointer to the top of array stack*/ + +static H5T_str_t str_pad; /*variable for string padding*/ +static H5T_cset_t str_cset; /*variable for string character set*/ +static bool is_variable = 0; /*variable for variable-length string*/ +static size_t str_size; /*variable for string size*/ + +static hid_t enum_id; /*type ID*/ +static bool is_enum = 0; /*flag to lexer for enum type*/ +static bool is_enum_memb = 0; /*flag to lexer for enum member*/ +static char* enum_memb_symbol; /*enum member symbol string*/ + + +#line 128 "hl/src//H5LTparse.c" + +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) +# else +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif +# endif +# ifndef YY_NULLPTR +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# else +# define YY_NULLPTR ((void*)0) +# endif +# endif + +#include "H5LTparse.h" +/* Symbol kind. */ +enum yysymbol_kind_t +{ + YYSYMBOL_YYEMPTY = -2, + YYSYMBOL_YYEOF = 0, /* "end of file" */ + YYSYMBOL_YYerror = 1, /* error */ + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ + YYSYMBOL_H5T_STD_I8BE_TOKEN = 3, /* H5T_STD_I8BE_TOKEN */ + YYSYMBOL_H5T_STD_I8LE_TOKEN = 4, /* H5T_STD_I8LE_TOKEN */ + YYSYMBOL_H5T_STD_I16BE_TOKEN = 5, /* H5T_STD_I16BE_TOKEN */ + YYSYMBOL_H5T_STD_I16LE_TOKEN = 6, /* H5T_STD_I16LE_TOKEN */ + YYSYMBOL_H5T_STD_I32BE_TOKEN = 7, /* H5T_STD_I32BE_TOKEN */ + YYSYMBOL_H5T_STD_I32LE_TOKEN = 8, /* H5T_STD_I32LE_TOKEN */ + YYSYMBOL_H5T_STD_I64BE_TOKEN = 9, /* H5T_STD_I64BE_TOKEN */ + YYSYMBOL_H5T_STD_I64LE_TOKEN = 10, /* H5T_STD_I64LE_TOKEN */ + YYSYMBOL_H5T_STD_U8BE_TOKEN = 11, /* H5T_STD_U8BE_TOKEN */ + YYSYMBOL_H5T_STD_U8LE_TOKEN = 12, /* H5T_STD_U8LE_TOKEN */ + YYSYMBOL_H5T_STD_U16BE_TOKEN = 13, /* H5T_STD_U16BE_TOKEN */ + YYSYMBOL_H5T_STD_U16LE_TOKEN = 14, /* H5T_STD_U16LE_TOKEN */ + YYSYMBOL_H5T_STD_U32BE_TOKEN = 15, /* H5T_STD_U32BE_TOKEN */ + YYSYMBOL_H5T_STD_U32LE_TOKEN = 16, /* H5T_STD_U32LE_TOKEN */ + YYSYMBOL_H5T_STD_U64BE_TOKEN = 17, /* H5T_STD_U64BE_TOKEN */ + YYSYMBOL_H5T_STD_U64LE_TOKEN = 18, /* H5T_STD_U64LE_TOKEN */ + YYSYMBOL_H5T_NATIVE_CHAR_TOKEN = 19, /* H5T_NATIVE_CHAR_TOKEN */ + YYSYMBOL_H5T_NATIVE_SCHAR_TOKEN = 20, /* H5T_NATIVE_SCHAR_TOKEN */ + YYSYMBOL_H5T_NATIVE_UCHAR_TOKEN = 21, /* H5T_NATIVE_UCHAR_TOKEN */ + YYSYMBOL_H5T_NATIVE_SHORT_TOKEN = 22, /* H5T_NATIVE_SHORT_TOKEN */ + YYSYMBOL_H5T_NATIVE_USHORT_TOKEN = 23, /* H5T_NATIVE_USHORT_TOKEN */ + YYSYMBOL_H5T_NATIVE_INT_TOKEN = 24, /* H5T_NATIVE_INT_TOKEN */ + YYSYMBOL_H5T_NATIVE_UINT_TOKEN = 25, /* H5T_NATIVE_UINT_TOKEN */ + YYSYMBOL_H5T_NATIVE_LONG_TOKEN = 26, /* H5T_NATIVE_LONG_TOKEN */ + YYSYMBOL_H5T_NATIVE_ULONG_TOKEN = 27, /* H5T_NATIVE_ULONG_TOKEN */ + YYSYMBOL_H5T_NATIVE_LLONG_TOKEN = 28, /* H5T_NATIVE_LLONG_TOKEN */ + YYSYMBOL_H5T_NATIVE_ULLONG_TOKEN = 29, /* H5T_NATIVE_ULLONG_TOKEN */ + YYSYMBOL_H5T_IEEE_F32BE_TOKEN = 30, /* H5T_IEEE_F32BE_TOKEN */ + YYSYMBOL_H5T_IEEE_F32LE_TOKEN = 31, /* H5T_IEEE_F32LE_TOKEN */ + YYSYMBOL_H5T_IEEE_F64BE_TOKEN = 32, /* H5T_IEEE_F64BE_TOKEN */ + YYSYMBOL_H5T_IEEE_F64LE_TOKEN = 33, /* H5T_IEEE_F64LE_TOKEN */ + YYSYMBOL_H5T_NATIVE_FLOAT_TOKEN = 34, /* H5T_NATIVE_FLOAT_TOKEN */ + YYSYMBOL_H5T_NATIVE_DOUBLE_TOKEN = 35, /* H5T_NATIVE_DOUBLE_TOKEN */ + YYSYMBOL_H5T_NATIVE_LDOUBLE_TOKEN = 36, /* H5T_NATIVE_LDOUBLE_TOKEN */ + YYSYMBOL_H5T_STRING_TOKEN = 37, /* H5T_STRING_TOKEN */ + YYSYMBOL_STRSIZE_TOKEN = 38, /* STRSIZE_TOKEN */ + YYSYMBOL_STRPAD_TOKEN = 39, /* STRPAD_TOKEN */ + YYSYMBOL_CSET_TOKEN = 40, /* CSET_TOKEN */ + YYSYMBOL_CTYPE_TOKEN = 41, /* CTYPE_TOKEN */ + YYSYMBOL_H5T_VARIABLE_TOKEN = 42, /* H5T_VARIABLE_TOKEN */ + YYSYMBOL_H5T_STR_NULLTERM_TOKEN = 43, /* H5T_STR_NULLTERM_TOKEN */ + YYSYMBOL_H5T_STR_NULLPAD_TOKEN = 44, /* H5T_STR_NULLPAD_TOKEN */ + YYSYMBOL_H5T_STR_SPACEPAD_TOKEN = 45, /* H5T_STR_SPACEPAD_TOKEN */ + YYSYMBOL_H5T_CSET_ASCII_TOKEN = 46, /* H5T_CSET_ASCII_TOKEN */ + YYSYMBOL_H5T_CSET_UTF8_TOKEN = 47, /* H5T_CSET_UTF8_TOKEN */ + YYSYMBOL_H5T_C_S1_TOKEN = 48, /* H5T_C_S1_TOKEN */ + YYSYMBOL_H5T_FORTRAN_S1_TOKEN = 49, /* H5T_FORTRAN_S1_TOKEN */ + YYSYMBOL_H5T_OPAQUE_TOKEN = 50, /* H5T_OPAQUE_TOKEN */ + YYSYMBOL_OPQ_SIZE_TOKEN = 51, /* OPQ_SIZE_TOKEN */ + YYSYMBOL_OPQ_TAG_TOKEN = 52, /* OPQ_TAG_TOKEN */ + YYSYMBOL_H5T_COMPOUND_TOKEN = 53, /* H5T_COMPOUND_TOKEN */ + YYSYMBOL_H5T_ENUM_TOKEN = 54, /* H5T_ENUM_TOKEN */ + YYSYMBOL_H5T_ARRAY_TOKEN = 55, /* H5T_ARRAY_TOKEN */ + YYSYMBOL_H5T_VLEN_TOKEN = 56, /* H5T_VLEN_TOKEN */ + YYSYMBOL_STRING = 57, /* STRING */ + YYSYMBOL_NUMBER = 58, /* NUMBER */ + YYSYMBOL_59_ = 59, /* '{' */ + YYSYMBOL_60_ = 60, /* '}' */ + YYSYMBOL_61_ = 61, /* '[' */ + YYSYMBOL_62_ = 62, /* ']' */ + YYSYMBOL_63_ = 63, /* ':' */ + YYSYMBOL_64_ = 64, /* ';' */ + YYSYMBOL_YYACCEPT = 65, /* $accept */ + YYSYMBOL_start = 66, /* start */ + YYSYMBOL_ddl_type = 67, /* ddl_type */ + YYSYMBOL_atomic_type = 68, /* atomic_type */ + YYSYMBOL_integer_type = 69, /* integer_type */ + YYSYMBOL_fp_type = 70, /* fp_type */ + YYSYMBOL_compound_type = 71, /* compound_type */ + YYSYMBOL_72_1 = 72, /* $@1 */ + YYSYMBOL_memb_list = 73, /* memb_list */ + YYSYMBOL_memb_def = 74, /* memb_def */ + YYSYMBOL_75_2 = 75, /* $@2 */ + YYSYMBOL_field_name = 76, /* field_name */ + YYSYMBOL_field_offset = 77, /* field_offset */ + YYSYMBOL_offset = 78, /* offset */ + YYSYMBOL_array_type = 79, /* array_type */ + YYSYMBOL_80_3 = 80, /* $@3 */ + YYSYMBOL_dim_list = 81, /* dim_list */ + YYSYMBOL_dim = 82, /* dim */ + YYSYMBOL_83_4 = 83, /* $@4 */ + YYSYMBOL_84_5 = 84, /* $@5 */ + YYSYMBOL_dimsize = 85, /* dimsize */ + YYSYMBOL_vlen_type = 86, /* vlen_type */ + YYSYMBOL_opaque_type = 87, /* opaque_type */ + YYSYMBOL_88_6 = 88, /* @6 */ + YYSYMBOL_89_7 = 89, /* $@7 */ + YYSYMBOL_opaque_size = 90, /* opaque_size */ + YYSYMBOL_opaque_tag = 91, /* opaque_tag */ + YYSYMBOL_string_type = 92, /* string_type */ + YYSYMBOL_93_8 = 93, /* $@8 */ + YYSYMBOL_94_9 = 94, /* $@9 */ + YYSYMBOL_95_10 = 95, /* $@10 */ + YYSYMBOL_96_11 = 96, /* @11 */ + YYSYMBOL_strsize = 97, /* strsize */ + YYSYMBOL_strpad = 98, /* strpad */ + YYSYMBOL_cset = 99, /* cset */ + YYSYMBOL_ctype = 100, /* ctype */ + YYSYMBOL_enum_type = 101, /* enum_type */ + YYSYMBOL_102_12 = 102, /* $@12 */ + YYSYMBOL_enum_list = 103, /* enum_list */ + YYSYMBOL_enum_def = 104, /* enum_def */ + YYSYMBOL_105_13 = 105, /* $@13 */ + YYSYMBOL_enum_symbol = 106, /* enum_symbol */ + YYSYMBOL_enum_val = 107 /* enum_val */ +}; +typedef enum yysymbol_kind_t yysymbol_kind_t; + + + + +#ifdef short +# undef short +#endif + +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure + and (if available) are included + so that the code can choose integer types of a good width. */ + +#ifndef __PTRDIFF_MAX__ +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H +# endif +#endif + +/* Narrow types that promote to a signed type and that can represent a + signed or unsigned integer of at least N bits. In tables they can + save space and decrease cache pressure. Promoting to a signed type + helps avoid bugs in integer arithmetic. */ + +#ifdef __INT_LEAST8_MAX__ +typedef __INT_LEAST8_TYPE__ yytype_int8; +#elif defined YY_STDINT_H +typedef int_least8_t yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; +#else +typedef short yytype_int16; +#endif + +/* Work around bug in HP-UX 11.23, which defines these macros + incorrectly for preprocessor constants. This workaround can likely + be removed in 2023, as HPE has promised support for HP-UX 11.23 + (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of + . */ +#ifdef __hpux +# undef UINT_LEAST8_MAX +# undef UINT_LEAST16_MAX +# define UINT_LEAST8_MAX 255 +# define UINT_LEAST16_MAX 65535 +#endif + +#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST8_TYPE__ yytype_uint8; +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST8_MAX <= INT_MAX) +typedef uint_least8_t yytype_uint8; +#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX +typedef unsigned char yytype_uint8; +#else +typedef short yytype_uint8; +#endif + +#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST16_TYPE__ yytype_uint16; +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST16_MAX <= INT_MAX) +typedef uint_least16_t yytype_uint16; +#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX +typedef unsigned short yytype_uint16; +#else +typedef int yytype_uint16; +#endif + +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned +# endif +#endif + +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + + +/* Stored state numbers (used for stacks). */ +typedef yytype_uint8 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + + +#ifndef YY_ATTRIBUTE_PURE +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define YY_ATTRIBUTE_PURE +# endif +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +# else +# define YY_ATTRIBUTE_UNUSED +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YY_USE(E) ((void) (E)) +#else +# define YY_USE(E) /* empty */ +#endif + +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ +# if __GNUC__ * 100 + __GNUC_MINOR__ < 407 +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") +# else +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# endif +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif + + +#define YY_ASSERT(E) ((void) (0 && (E))) + +#if !defined yyoverflow + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* !defined yyoverflow */ + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yy_state_t yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYPTRDIFF_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYPTRDIFF_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 58 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 197 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 65 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 43 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 92 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 134 + +/* YYMAXUTOK -- Last valid token kind. */ +#define YYMAXUTOK 313 + + +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ +#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK \ + ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ + : YYSYMBOL_YYUNDEF) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex. */ +static const yytype_int8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 63, 64, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 61, 2, 62, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 59, 2, 60, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58 +}; + +#if YYDEBUG +/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_int16 yyrline[] = +{ + 0, 101, 101, 102, 104, 105, 106, 107, 109, 110, + 111, 112, 113, 116, 117, 118, 119, 120, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 145, 146, 147, 148, 149, 150, 151, 155, 154, 163, + 164, 166, 166, 203, 211, 212, 215, 217, 217, 226, + 227, 229, 230, 229, 237, 240, 247, 252, 244, 259, + 261, 266, 273, 282, 289, 263, 313, 314, 316, 317, + 318, 320, 321, 323, 324, 328, 327, 332, 333, 335, + 335, 385, 387 +}; +#endif + +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) + +#if YYDEBUG || 0 +/* The user-facing name of the symbol whose (internal) number is + YYSYMBOL. No bounds checking. */ +static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; + +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "\"end of file\"", "error", "\"invalid token\"", "H5T_STD_I8BE_TOKEN", + "H5T_STD_I8LE_TOKEN", "H5T_STD_I16BE_TOKEN", "H5T_STD_I16LE_TOKEN", + "H5T_STD_I32BE_TOKEN", "H5T_STD_I32LE_TOKEN", "H5T_STD_I64BE_TOKEN", + "H5T_STD_I64LE_TOKEN", "H5T_STD_U8BE_TOKEN", "H5T_STD_U8LE_TOKEN", + "H5T_STD_U16BE_TOKEN", "H5T_STD_U16LE_TOKEN", "H5T_STD_U32BE_TOKEN", + "H5T_STD_U32LE_TOKEN", "H5T_STD_U64BE_TOKEN", "H5T_STD_U64LE_TOKEN", + "H5T_NATIVE_CHAR_TOKEN", "H5T_NATIVE_SCHAR_TOKEN", + "H5T_NATIVE_UCHAR_TOKEN", "H5T_NATIVE_SHORT_TOKEN", + "H5T_NATIVE_USHORT_TOKEN", "H5T_NATIVE_INT_TOKEN", + "H5T_NATIVE_UINT_TOKEN", "H5T_NATIVE_LONG_TOKEN", + "H5T_NATIVE_ULONG_TOKEN", "H5T_NATIVE_LLONG_TOKEN", + "H5T_NATIVE_ULLONG_TOKEN", "H5T_IEEE_F32BE_TOKEN", + "H5T_IEEE_F32LE_TOKEN", "H5T_IEEE_F64BE_TOKEN", "H5T_IEEE_F64LE_TOKEN", + "H5T_NATIVE_FLOAT_TOKEN", "H5T_NATIVE_DOUBLE_TOKEN", + "H5T_NATIVE_LDOUBLE_TOKEN", "H5T_STRING_TOKEN", "STRSIZE_TOKEN", + "STRPAD_TOKEN", "CSET_TOKEN", "CTYPE_TOKEN", "H5T_VARIABLE_TOKEN", + "H5T_STR_NULLTERM_TOKEN", "H5T_STR_NULLPAD_TOKEN", + "H5T_STR_SPACEPAD_TOKEN", "H5T_CSET_ASCII_TOKEN", "H5T_CSET_UTF8_TOKEN", + "H5T_C_S1_TOKEN", "H5T_FORTRAN_S1_TOKEN", "H5T_OPAQUE_TOKEN", + "OPQ_SIZE_TOKEN", "OPQ_TAG_TOKEN", "H5T_COMPOUND_TOKEN", + "H5T_ENUM_TOKEN", "H5T_ARRAY_TOKEN", "H5T_VLEN_TOKEN", "STRING", + "NUMBER", "'{'", "'}'", "'['", "']'", "':'", "';'", "$accept", "start", + "ddl_type", "atomic_type", "integer_type", "fp_type", "compound_type", + "$@1", "memb_list", "memb_def", "$@2", "field_name", "field_offset", + "offset", "array_type", "$@3", "dim_list", "dim", "$@4", "$@5", + "dimsize", "vlen_type", "opaque_type", "@6", "$@7", "opaque_size", + "opaque_tag", "string_type", "$@8", "$@9", "$@10", "@11", "strsize", + "strpad", "cset", "ctype", "enum_type", "$@12", "enum_list", "enum_def", + "$@13", "enum_symbol", "enum_val", YY_NULLPTR +}; + +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) +{ + return yytname[yysymbol]; +} +#endif + +#define YYPACT_NINF (-25) + +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) + +#define YYTABLE_NINF (-1) + +#define yytable_value_is_error(Yyn) \ + 0 + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int16 yypact[] = +{ + 114, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -24, -22, -25, -13, -25, + -11, 49, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, 18, 45, 38, 168, 39, 114, -25, -4, + 41, -25, 36, -25, 42, -25, -25, 37, -25, 40, + 56, -25, -3, -25, -25, -25, -25, -25, -25, -25, + -25, 43, -25, 66, 55, 51, -21, 57, -25, 0, + 95, -25, 50, -25, -25, -25, -25, -25, -25, -25, + -25, -25, 89, -25, 90, 97, 92, 99, 52, -25, + -25, -25, -25, -25, -25, 94, -25, 119, 100, -25, + -6, -25, -25, -25, 98, -25, 120, 46, -25, -25, + 101, -25, 103, -25 +}; + +/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_int8 yydefact[] = +{ + 2, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 0, 0, 47, 0, 57, + 0, 0, 3, 4, 8, 9, 5, 6, 7, 12, + 10, 11, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 49, 0, 59, 0, 76, 77, 0, 69, 0, + 0, 85, 0, 65, 71, 66, 48, 51, 50, 87, + 61, 0, 60, 0, 0, 0, 0, 0, 58, 0, + 0, 53, 54, 91, 86, 88, 89, 64, 62, 78, + 79, 80, 0, 70, 0, 0, 0, 0, 0, 72, + 67, 56, 55, 52, 92, 0, 63, 0, 0, 90, + 0, 68, 81, 82, 0, 73, 0, 0, 83, 84, + 0, 74, 0, 75 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -25, -25, -15, -25, 111, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_uint8 yydefgoto[] = +{ + 0, 41, 42, 43, 44, 45, 46, 54, 70, 78, + 85, 92, 106, 112, 47, 56, 72, 82, 87, 108, + 98, 48, 49, 84, 118, 69, 104, 50, 83, 117, + 126, 132, 67, 102, 124, 130, 51, 79, 86, 95, + 107, 96, 115 +}; + +/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_uint8 yytable[] = +{ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 52, 93, 53, 65, 94, + 122, 123, 64, 99, 100, 101, 55, 36, 57, 58, + 37, 38, 39, 40, 66, 77, 59, 81, 80, 1, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 128, 129, 60, 61, 63, 68, + 71, 74, 73, 88, 75, 89, 36, 90, 91, 37, + 38, 39, 40, 105, 116, 97, 76, 1, 2, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 103, 109, 110, 111, 113, 114, 119, 120, + 121, 127, 125, 133, 36, 131, 62, 37, 38, 39, + 40, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27 +}; + +static const yytype_int8 yycheck[] = +{ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 59, 57, 59, 42, 60, + 46, 47, 57, 43, 44, 45, 59, 50, 59, 0, + 53, 54, 55, 56, 58, 70, 38, 72, 61, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 48, 49, 51, 59, 59, 58, + 64, 64, 60, 60, 64, 39, 50, 52, 57, 53, + 54, 55, 56, 63, 62, 58, 60, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 57, 64, 64, 58, 64, 58, 64, 40, + 60, 41, 64, 60, 50, 64, 55, 53, 54, 55, + 56, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29 +}; + +/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of + state STATE-NUM. */ +static const yytype_int8 yystos[] = +{ + 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 50, 53, 54, 55, + 56, 66, 67, 68, 69, 70, 71, 79, 86, 87, + 92, 101, 59, 59, 72, 59, 80, 59, 0, 38, + 51, 59, 69, 59, 67, 42, 58, 97, 58, 90, + 73, 64, 81, 60, 64, 64, 60, 67, 74, 102, + 61, 67, 82, 93, 88, 75, 103, 83, 60, 39, + 52, 57, 76, 57, 60, 104, 106, 58, 85, 43, + 44, 45, 98, 57, 91, 63, 77, 105, 84, 64, + 64, 58, 78, 64, 58, 107, 62, 94, 89, 64, + 40, 60, 46, 47, 99, 64, 95, 41, 48, 49, + 100, 64, 96, 60 +}; + +/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ +static const yytype_int8 yyr1[] = +{ + 0, 65, 66, 66, 67, 67, 67, 67, 68, 68, + 68, 68, 68, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 70, 70, 70, 70, 70, 70, 70, 72, 71, 73, + 73, 75, 74, 76, 77, 77, 78, 80, 79, 81, + 81, 83, 84, 82, 85, 86, 88, 89, 87, 90, + 91, 93, 94, 95, 96, 92, 97, 97, 98, 98, + 98, 99, 99, 100, 100, 102, 101, 103, 103, 105, + 104, 106, 107 +}; + +/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ +static const yytype_int8 yyr2[] = +{ + 0, 2, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 5, 0, + 2, 0, 5, 1, 0, 2, 1, 0, 6, 0, + 2, 0, 0, 5, 1, 4, 0, 0, 11, 1, + 1, 0, 0, 0, 0, 19, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 7, 0, 2, 0, + 4, 1, 1 +}; + + +enum { YYENOMEM = -2 }; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab +#define YYNOMEM goto yyexhaustedlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) + +/* Backward compatibility with an undocumented macro. + Use YYerror or YYUNDEF. */ +#define YYERRCODE YYUNDEF + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + + + + +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Kind, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) +{ + FILE *yyoutput = yyo; + YY_USE (yyoutput); + if (!yyvaluep) + return; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YY_USE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ + +static void +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyo, "%s %s (", + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); + + yy_symbol_value_print (yyo, yykind, yyvaluep); + YYFPRINTF (yyo, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, + int yyrule) +{ + int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &yyvsp[(yyi + 1) - (yynrhs)]); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) ((void) 0) +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + + + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep) +{ + YY_USE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YY_USE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + +/* Lookahead token kind. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + + + +/*----------. +| yyparse. | +`----------*/ + +hid_t +yyparse (void) +{ + yy_state_fast_t yystate = 0; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus = 0; + + /* Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* Their size. */ + YYPTRDIFF_T yystacksize = YYINITDEPTH; + + /* The state stack: array, bottom, top. */ + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss = yyssa; + yy_state_t *yyssp = yyss; + + /* The semantic value stack: array, bottom, top. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp = yyvs; + + int yyn; + /* The return value of yyparse. */ + int yyresult; + /* Lookahead symbol kind. */ + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yychar = YYEMPTY; /* Cause a token to be read. */ + + goto yysetstate; + + +/*------------------------------------------------------------. +| yynewstate -- push a new state, which is found in yystate. | +`------------------------------------------------------------*/ +yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + +/*--------------------------------------------------------------------. +| yysetstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + YY_IGNORE_USELESS_CAST_BEGIN + *yyssp = YY_CAST (yy_state_t, yystate); + YY_IGNORE_USELESS_CAST_END + YY_STACK_PRINT (yyss, yyssp); + + if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + YYNOMEM; +#else + { + /* Get the current used size of the three stacks, in elements. */ + YYPTRDIFF_T yysize = yyssp - yyss + 1; + +# if defined yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + yy_state_t *yyss1 = yyss; + YYSTYPE *yyvs1 = yyvs; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), + &yystacksize); + yyss = yyss1; + yyvs = yyvs1; + } +# else /* defined YYSTACK_RELOCATE */ + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + YYNOMEM; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yy_state_t *yyss1 = yyss; + union yyalloc *yyptr = + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); + if (! yyptr) + YYNOMEM; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YY_IGNORE_USELESS_CAST_BEGIN + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + YY_CAST (long, yystacksize))); + YY_IGNORE_USELESS_CAST_END + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ + + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token\n")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = YYEOF; + yytoken = YYSYMBOL_YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else if (yychar == YYerror) + { + /* The scanner already issued an error message, process directly + to error recovery. But do not keep the error token as + lookahead, it is too special and may lead us to an endless + loop in error recovery. */ + yychar = YYUNDEF; + yytoken = YYSYMBOL_YYerror; + goto yyerrlab1; + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + /* Discard the shifted token. */ + yychar = YYEMPTY; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: /* start: %empty */ +#line 101 "hl/src//H5LTparse.y" + { memset(arr_stack, 0, STACK_SIZE*sizeof(struct arr_info)); /*initialize here?*/ } +#line 1353 "hl/src//H5LTparse.c" + break; + + case 3: /* start: ddl_type */ +#line 102 "hl/src//H5LTparse.y" + { return (yyval.hid);} +#line 1359 "hl/src//H5LTparse.c" + break; + + case 13: /* integer_type: H5T_STD_I8BE_TOKEN */ +#line 116 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_I8BE); } +#line 1365 "hl/src//H5LTparse.c" + break; + + case 14: /* integer_type: H5T_STD_I8LE_TOKEN */ +#line 117 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_I8LE); } +#line 1371 "hl/src//H5LTparse.c" + break; + + case 15: /* integer_type: H5T_STD_I16BE_TOKEN */ +#line 118 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_I16BE); } +#line 1377 "hl/src//H5LTparse.c" + break; + + case 16: /* integer_type: H5T_STD_I16LE_TOKEN */ +#line 119 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_I16LE); } +#line 1383 "hl/src//H5LTparse.c" + break; + + case 17: /* integer_type: H5T_STD_I32BE_TOKEN */ +#line 120 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_I32BE); } +#line 1389 "hl/src//H5LTparse.c" + break; + + case 18: /* integer_type: H5T_STD_I32LE_TOKEN */ +#line 121 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_I32LE); } +#line 1395 "hl/src//H5LTparse.c" + break; + + case 19: /* integer_type: H5T_STD_I64BE_TOKEN */ +#line 122 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_I64BE); } +#line 1401 "hl/src//H5LTparse.c" + break; + + case 20: /* integer_type: H5T_STD_I64LE_TOKEN */ +#line 123 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_I64LE); } +#line 1407 "hl/src//H5LTparse.c" + break; + + case 21: /* integer_type: H5T_STD_U8BE_TOKEN */ +#line 124 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_U8BE); } +#line 1413 "hl/src//H5LTparse.c" + break; + + case 22: /* integer_type: H5T_STD_U8LE_TOKEN */ +#line 125 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_U8LE); } +#line 1419 "hl/src//H5LTparse.c" + break; + + case 23: /* integer_type: H5T_STD_U16BE_TOKEN */ +#line 126 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_U16BE); } +#line 1425 "hl/src//H5LTparse.c" + break; + + case 24: /* integer_type: H5T_STD_U16LE_TOKEN */ +#line 127 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_U16LE); } +#line 1431 "hl/src//H5LTparse.c" + break; + + case 25: /* integer_type: H5T_STD_U32BE_TOKEN */ +#line 128 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_U32BE); } +#line 1437 "hl/src//H5LTparse.c" + break; + + case 26: /* integer_type: H5T_STD_U32LE_TOKEN */ +#line 129 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_U32LE); } +#line 1443 "hl/src//H5LTparse.c" + break; + + case 27: /* integer_type: H5T_STD_U64BE_TOKEN */ +#line 130 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_U64BE); } +#line 1449 "hl/src//H5LTparse.c" + break; + + case 28: /* integer_type: H5T_STD_U64LE_TOKEN */ +#line 131 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_STD_U64LE); } +#line 1455 "hl/src//H5LTparse.c" + break; + + case 29: /* integer_type: H5T_NATIVE_CHAR_TOKEN */ +#line 132 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_CHAR); } +#line 1461 "hl/src//H5LTparse.c" + break; + + case 30: /* integer_type: H5T_NATIVE_SCHAR_TOKEN */ +#line 133 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_SCHAR); } +#line 1467 "hl/src//H5LTparse.c" + break; + + case 31: /* integer_type: H5T_NATIVE_UCHAR_TOKEN */ +#line 134 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_UCHAR); } +#line 1473 "hl/src//H5LTparse.c" + break; + + case 32: /* integer_type: H5T_NATIVE_SHORT_TOKEN */ +#line 135 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_SHORT); } +#line 1479 "hl/src//H5LTparse.c" + break; + + case 33: /* integer_type: H5T_NATIVE_USHORT_TOKEN */ +#line 136 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_USHORT); } +#line 1485 "hl/src//H5LTparse.c" + break; + + case 34: /* integer_type: H5T_NATIVE_INT_TOKEN */ +#line 137 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_INT); } +#line 1491 "hl/src//H5LTparse.c" + break; + + case 35: /* integer_type: H5T_NATIVE_UINT_TOKEN */ +#line 138 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_UINT); } +#line 1497 "hl/src//H5LTparse.c" + break; + + case 36: /* integer_type: H5T_NATIVE_LONG_TOKEN */ +#line 139 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_LONG); } +#line 1503 "hl/src//H5LTparse.c" + break; + + case 37: /* integer_type: H5T_NATIVE_ULONG_TOKEN */ +#line 140 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_ULONG); } +#line 1509 "hl/src//H5LTparse.c" + break; + + case 38: /* integer_type: H5T_NATIVE_LLONG_TOKEN */ +#line 141 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_LLONG); } +#line 1515 "hl/src//H5LTparse.c" + break; + + case 39: /* integer_type: H5T_NATIVE_ULLONG_TOKEN */ +#line 142 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_ULLONG); } +#line 1521 "hl/src//H5LTparse.c" + break; + + case 40: /* fp_type: H5T_IEEE_F32BE_TOKEN */ +#line 145 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_IEEE_F32BE); } +#line 1527 "hl/src//H5LTparse.c" + break; + + case 41: /* fp_type: H5T_IEEE_F32LE_TOKEN */ +#line 146 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_IEEE_F32LE); } +#line 1533 "hl/src//H5LTparse.c" + break; + + case 42: /* fp_type: H5T_IEEE_F64BE_TOKEN */ +#line 147 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_IEEE_F64BE); } +#line 1539 "hl/src//H5LTparse.c" + break; + + case 43: /* fp_type: H5T_IEEE_F64LE_TOKEN */ +#line 148 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_IEEE_F64LE); } +#line 1545 "hl/src//H5LTparse.c" + break; + + case 44: /* fp_type: H5T_NATIVE_FLOAT_TOKEN */ +#line 149 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_FLOAT); } +#line 1551 "hl/src//H5LTparse.c" + break; + + case 45: /* fp_type: H5T_NATIVE_DOUBLE_TOKEN */ +#line 150 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_DOUBLE); } +#line 1557 "hl/src//H5LTparse.c" + break; + + case 46: /* fp_type: H5T_NATIVE_LDOUBLE_TOKEN */ +#line 151 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_LDOUBLE); } +#line 1563 "hl/src//H5LTparse.c" + break; + + case 47: /* $@1: %empty */ +#line 155 "hl/src//H5LTparse.y" + { csindex++; cmpd_stack[csindex].id = H5Tcreate(H5T_COMPOUND, 1); /*temporarily set size to 1*/ } +#line 1569 "hl/src//H5LTparse.c" + break; + + case 48: /* compound_type: H5T_COMPOUND_TOKEN $@1 '{' memb_list '}' */ +#line 157 "hl/src//H5LTparse.y" + { (yyval.hid) = cmpd_stack[csindex].id; + cmpd_stack[csindex].id = 0; + cmpd_stack[csindex].first_memb = 1; + csindex--; + } +#line 1579 "hl/src//H5LTparse.c" + break; + + case 51: /* $@2: %empty */ +#line 166 "hl/src//H5LTparse.y" + { cmpd_stack[csindex].is_field = 1; /*notify lexer a compound member is parsed*/ } +#line 1585 "hl/src//H5LTparse.c" + break; + + case 52: /* memb_def: ddl_type $@2 field_name field_offset ';' */ +#line 168 "hl/src//H5LTparse.y" + { + size_t origin_size, new_size; + hid_t dtype_id = cmpd_stack[csindex].id; + + /*Adjust size and insert member, consider both member size and offset.*/ + if(cmpd_stack[csindex].first_memb) { /*reclaim the size 1 temporarily set*/ + new_size = H5Tget_size((yyvsp[-4].hid)) + (yyvsp[-1].ival); + H5Tset_size(dtype_id, new_size); + /*member name is saved in yylval.sval by lexer*/ + H5Tinsert(dtype_id, (yyvsp[-2].sval), (yyvsp[-1].ival), (yyvsp[-4].hid)); + + cmpd_stack[csindex].first_memb = 0; + } else { + origin_size = H5Tget_size(dtype_id); + + if((yyvsp[-1].ival) == 0) { + new_size = origin_size + H5Tget_size((yyvsp[-4].hid)); + H5Tset_size(dtype_id, new_size); + H5Tinsert(dtype_id, (yyvsp[-2].sval), origin_size, (yyvsp[-4].hid)); + } else { + new_size = (yyvsp[-1].ival) + H5Tget_size((yyvsp[-4].hid)); + H5Tset_size(dtype_id, new_size); + H5Tinsert(dtype_id, (yyvsp[-2].sval), (yyvsp[-1].ival), (yyvsp[-4].hid)); + } + } + if((yyvsp[-2].sval)) { + free((yyvsp[-2].sval)); + (yyvsp[-2].sval) = NULL; + } + cmpd_stack[csindex].is_field = 0; + H5Tclose((yyvsp[-4].hid)); + + new_size = H5Tget_size(dtype_id); + } +#line 1624 "hl/src//H5LTparse.c" + break; + + case 53: /* field_name: STRING */ +#line 204 "hl/src//H5LTparse.y" + { + (yyval.sval) = strdup(yylval.sval); + free(yylval.sval); + yylval.sval = NULL; + } +#line 1634 "hl/src//H5LTparse.c" + break; + + case 54: /* field_offset: %empty */ +#line 211 "hl/src//H5LTparse.y" + { (yyval.ival) = 0; } +#line 1640 "hl/src//H5LTparse.c" + break; + + case 55: /* field_offset: ':' offset */ +#line 213 "hl/src//H5LTparse.y" + { (yyval.ival) = yylval.ival; } +#line 1646 "hl/src//H5LTparse.c" + break; + + case 57: /* $@3: %empty */ +#line 217 "hl/src//H5LTparse.y" + { asindex++; /*pushd onto the stack*/ } +#line 1652 "hl/src//H5LTparse.c" + break; + + case 58: /* array_type: H5T_ARRAY_TOKEN $@3 '{' dim_list ddl_type '}' */ +#line 219 "hl/src//H5LTparse.y" + { + (yyval.hid) = H5Tarray_create2((yyvsp[-1].hid), arr_stack[asindex].ndims, arr_stack[asindex].dims); + arr_stack[asindex].ndims = 0; + asindex--; + H5Tclose((yyvsp[-1].hid)); + } +#line 1663 "hl/src//H5LTparse.c" + break; + + case 61: /* $@4: %empty */ +#line 229 "hl/src//H5LTparse.y" + { arr_stack[asindex].is_dim = 1; /*notice lexer of dimension size*/ } +#line 1669 "hl/src//H5LTparse.c" + break; + + case 62: /* $@5: %empty */ +#line 230 "hl/src//H5LTparse.y" + { unsigned ndims = arr_stack[asindex].ndims; + arr_stack[asindex].dims[ndims] = (hsize_t)yylval.ival; + arr_stack[asindex].ndims++; + arr_stack[asindex].is_dim = 0; + } +#line 1679 "hl/src//H5LTparse.c" + break; + + case 65: /* vlen_type: H5T_VLEN_TOKEN '{' ddl_type '}' */ +#line 241 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tvlen_create((yyvsp[-1].hid)); H5Tclose((yyvsp[-1].hid)); } +#line 1685 "hl/src//H5LTparse.c" + break; + + case 66: /* @6: %empty */ +#line 247 "hl/src//H5LTparse.y" + { + size_t size = (size_t)yylval.ival; + (yyval.hid) = H5Tcreate(H5T_OPAQUE, size); + } +#line 1694 "hl/src//H5LTparse.c" + break; + + case 67: /* $@7: %empty */ +#line 252 "hl/src//H5LTparse.y" + { + H5Tset_tag((yyvsp[-3].hid), yylval.sval); + free(yylval.sval); + yylval.sval = NULL; + } +#line 1704 "hl/src//H5LTparse.c" + break; + + case 68: /* opaque_type: H5T_OPAQUE_TOKEN '{' OPQ_SIZE_TOKEN opaque_size ';' @6 OPQ_TAG_TOKEN opaque_tag ';' $@7 '}' */ +#line 257 "hl/src//H5LTparse.y" + { (yyval.hid) = (yyvsp[-5].hid); } +#line 1710 "hl/src//H5LTparse.c" + break; + + case 71: /* $@8: %empty */ +#line 266 "hl/src//H5LTparse.y" + { + if((yyvsp[-1].ival) == H5T_VARIABLE_TOKEN) + is_variable = 1; + else + str_size = yylval.ival; + } +#line 1721 "hl/src//H5LTparse.c" + break; + + case 72: /* $@9: %empty */ +#line 273 "hl/src//H5LTparse.y" + { + if((yyvsp[-1].ival) == H5T_STR_NULLTERM_TOKEN) + str_pad = H5T_STR_NULLTERM; + else if((yyvsp[-1].ival) == H5T_STR_NULLPAD_TOKEN) + str_pad = H5T_STR_NULLPAD; + else if((yyvsp[-1].ival) == H5T_STR_SPACEPAD_TOKEN) + str_pad = H5T_STR_SPACEPAD; + } +#line 1734 "hl/src//H5LTparse.c" + break; + + case 73: /* $@10: %empty */ +#line 282 "hl/src//H5LTparse.y" + { + if((yyvsp[-1].ival) == H5T_CSET_ASCII_TOKEN) + str_cset = H5T_CSET_ASCII; + else if((yyvsp[-1].ival) == H5T_CSET_UTF8_TOKEN) + str_cset = H5T_CSET_UTF8; + } +#line 1745 "hl/src//H5LTparse.c" + break; + + case 74: /* @11: %empty */ +#line 289 "hl/src//H5LTparse.y" + { + if((yyvsp[-1].hid) == H5T_C_S1_TOKEN) + (yyval.hid) = H5Tcopy(H5T_C_S1); + else if((yyvsp[-1].hid) == H5T_FORTRAN_S1_TOKEN) + (yyval.hid) = H5Tcopy(H5T_FORTRAN_S1); + } +#line 1756 "hl/src//H5LTparse.c" + break; + + case 75: /* string_type: H5T_STRING_TOKEN '{' STRSIZE_TOKEN strsize ';' $@8 STRPAD_TOKEN strpad ';' $@9 CSET_TOKEN cset ';' $@10 CTYPE_TOKEN ctype ';' @11 '}' */ +#line 296 "hl/src//H5LTparse.y" + { + hid_t str_id = (yyvsp[-1].hid); + + /*set string size*/ + if(is_variable) { + H5Tset_size(str_id, H5T_VARIABLE); + is_variable = 0; + } else + H5Tset_size(str_id, str_size); + + /*set string padding and character set*/ + H5Tset_strpad(str_id, str_pad); + H5Tset_cset(str_id, str_cset); + + (yyval.hid) = str_id; + } +#line 1777 "hl/src//H5LTparse.c" + break; + + case 76: /* strsize: H5T_VARIABLE_TOKEN */ +#line 313 "hl/src//H5LTparse.y" + {(yyval.ival) = H5T_VARIABLE_TOKEN;} +#line 1783 "hl/src//H5LTparse.c" + break; + + case 78: /* strpad: H5T_STR_NULLTERM_TOKEN */ +#line 316 "hl/src//H5LTparse.y" + {(yyval.ival) = H5T_STR_NULLTERM_TOKEN;} +#line 1789 "hl/src//H5LTparse.c" + break; + + case 79: /* strpad: H5T_STR_NULLPAD_TOKEN */ +#line 317 "hl/src//H5LTparse.y" + {(yyval.ival) = H5T_STR_NULLPAD_TOKEN;} +#line 1795 "hl/src//H5LTparse.c" + break; + + case 80: /* strpad: H5T_STR_SPACEPAD_TOKEN */ +#line 318 "hl/src//H5LTparse.y" + {(yyval.ival) = H5T_STR_SPACEPAD_TOKEN;} +#line 1801 "hl/src//H5LTparse.c" + break; + + case 81: /* cset: H5T_CSET_ASCII_TOKEN */ +#line 320 "hl/src//H5LTparse.y" + {(yyval.ival) = H5T_CSET_ASCII_TOKEN;} +#line 1807 "hl/src//H5LTparse.c" + break; + + case 82: /* cset: H5T_CSET_UTF8_TOKEN */ +#line 321 "hl/src//H5LTparse.y" + {(yyval.ival) = H5T_CSET_UTF8_TOKEN;} +#line 1813 "hl/src//H5LTparse.c" + break; + + case 83: /* ctype: H5T_C_S1_TOKEN */ +#line 323 "hl/src//H5LTparse.y" + {(yyval.hid) = H5T_C_S1_TOKEN;} +#line 1819 "hl/src//H5LTparse.c" + break; + + case 84: /* ctype: H5T_FORTRAN_S1_TOKEN */ +#line 324 "hl/src//H5LTparse.y" + {(yyval.hid) = H5T_FORTRAN_S1_TOKEN;} +#line 1825 "hl/src//H5LTparse.c" + break; + + case 85: /* $@12: %empty */ +#line 328 "hl/src//H5LTparse.y" + { is_enum = 1; enum_id = H5Tenum_create((yyvsp[-1].hid)); H5Tclose((yyvsp[-1].hid)); } +#line 1831 "hl/src//H5LTparse.c" + break; + + case 86: /* enum_type: H5T_ENUM_TOKEN '{' integer_type ';' $@12 enum_list '}' */ +#line 330 "hl/src//H5LTparse.y" + { is_enum = 0; /*reset*/ (yyval.hid) = enum_id; } +#line 1837 "hl/src//H5LTparse.c" + break; + + case 89: /* $@13: %empty */ +#line 335 "hl/src//H5LTparse.y" + { + is_enum_memb = 1; /*indicate member of enum*/ + enum_memb_symbol = strdup(yylval.sval); + free(yylval.sval); + yylval.sval = NULL; + } +#line 1848 "hl/src//H5LTparse.c" + break; + + case 90: /* enum_def: enum_symbol $@13 enum_val ';' */ +#line 342 "hl/src//H5LTparse.y" + { + char char_val=(char)yylval.ival; + short short_val=(short)yylval.ival; + int int_val=(int)yylval.ival; + long long_val=(long)yylval.ival; + long long llong_val=(long long)yylval.ival; + hid_t super = H5Tget_super(enum_id); + hid_t native = H5Tget_native_type(super, H5T_DIR_ASCEND); + H5T_order_t super_order = H5Tget_order(super); + H5T_order_t native_order = H5Tget_order(native); + + if(is_enum && is_enum_memb) { /*if it's an enum member*/ + /*To handle machines of different endianness*/ + if(H5Tequal(native, H5T_NATIVE_SCHAR) || H5Tequal(native, H5T_NATIVE_UCHAR)) { + if(super_order != native_order) + H5Tconvert(native, super, 1, &char_val, NULL, H5P_DEFAULT); + H5Tenum_insert(enum_id, enum_memb_symbol, &char_val); + } else if(H5Tequal(native, H5T_NATIVE_SHORT) || H5Tequal(native, H5T_NATIVE_USHORT)) { + if(super_order != native_order) + H5Tconvert(native, super, 1, &short_val, NULL, H5P_DEFAULT); + H5Tenum_insert(enum_id, enum_memb_symbol, &short_val); + } else if(H5Tequal(native, H5T_NATIVE_INT) || H5Tequal(native, H5T_NATIVE_UINT)) { + if(super_order != native_order) + H5Tconvert(native, super, 1, &int_val, NULL, H5P_DEFAULT); + H5Tenum_insert(enum_id, enum_memb_symbol, &int_val); + } else if(H5Tequal(native, H5T_NATIVE_LONG) || H5Tequal(native, H5T_NATIVE_ULONG)) { + if(super_order != native_order) + H5Tconvert(native, super, 1, &long_val, NULL, H5P_DEFAULT); + H5Tenum_insert(enum_id, enum_memb_symbol, &long_val); + } else if(H5Tequal(native, H5T_NATIVE_LLONG) || H5Tequal(native, H5T_NATIVE_ULLONG)) { + if(super_order != native_order) + H5Tconvert(native, super, 1, &llong_val, NULL, H5P_DEFAULT); + H5Tenum_insert(enum_id, enum_memb_symbol, &llong_val); + } + + is_enum_memb = 0; + if(enum_memb_symbol) free(enum_memb_symbol); + } + + H5Tclose(super); + H5Tclose(native); + } +#line 1895 "hl/src//H5LTparse.c" + break; + + +#line 1899 "hl/src//H5LTparse.c" + + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; + yyerror (YY_("syntax error")); + } + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; + ++yynerrs; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + /* Pop stack until we find a state that shifts the error token. */ + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYSYMBOL_YYerror; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + YY_ACCESSING_SYMBOL (yystate), yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturnlab; + + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturnlab; + + +/*-----------------------------------------------------------. +| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. | +`-----------------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + goto yyreturnlab; + + +/*----------------------------------------------------------. +| yyreturnlab -- parsing is finished, clean up and return. | +`----------------------------------------------------------*/ +yyreturnlab: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + + return yyresult; +} + diff --git a/modules/c++/nitf-c++.vcxproj b/modules/c++/nitf-c++.vcxproj index 7e669fcc8..f6cef97cf 100644 --- a/modules/c++/nitf-c++.vcxproj +++ b/modules/c++/nitf-c++.vcxproj @@ -206,7 +206,6 @@ true - true nitf.ruleset @@ -231,7 +230,6 @@ Disabled true AdvancedVectorExtensions2 - true MultiThreadedDebugDLL true stdcpp17 diff --git a/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj b/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj index c4ebcd831..5ed17fc33 100644 --- a/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj +++ b/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj @@ -64,7 +64,6 @@ MultiThreadedDebugDLL true AdvancedVectorExtensions2 - true true stdcpp17 stdc11