Merge grib api and eccodes - part 4 - src compiles

This commit is contained in:
Shahram Najm 2014-06-20 18:18:57 +01:00
parent 1644d6da4c
commit 9cce21e421
101 changed files with 3781 additions and 2899 deletions

View File

@ -1,40 +0,0 @@
DIR=.
MARS=../../../mars/client/main/src
MARS=.
PGI=/usr/local/apps/pgi/current
FORTRAN=-L$(PGI)/linux86/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lpghpf -lpgc -lpgf90 -lstd -Wl,-rpath $(PGI)/linux86/lib
CFLAGS=-I../src -I$(MARS) -g -Wall -Werror -m32
#JASPER=/usr/lib/libjasper.a
# JASPER=/tmp/mab/degrib/src/jpeg2000/src/libjasper/.libs/libjasper.a
JASPER=-ljasper -lpng
EMOSLIB=-lemos.new.R64.D64.I32
EMOSLIB=/home/ma/maf/public/libemosR64.a
#FORTRAN=-lxlf90 -lxlf -lc -lm
EMOSLIB=/home/ma/emos/lib/$(ARCH)/000300/libemos.R64.D64.I32.a
PROGS= gaussian
LIBS=../src/libgrib_api.a $(EMOSLIB) $(FORTRAN) -lm $(JASPER)
# Netcdf
NCINCDIR=/home/ma/mac/netcdf/netcdf-3.6.1/include
NCLIBDIR=/home/ma/mac/netcdf/netcdf-3.6.1/lib
start : all
all::
cd ../src; make
all:: $(PROGS)
gaussian: $(OBJ) gaussian.c gaussian.h ../src/libgrib_api.a
$(CC) -o gaussian $(OBJ) gaussian.c $(CFLAGS) $(LIBS)
.PRECIOUS: fail
clean:
rm -f *.o core $(PROGS)

View File

@ -1,29 +0,0 @@
LIB = /usr/local/lib/metaps/lib/000381/libemos.R64.D64.I32.a
INSTALL_DIR=/usr/local/lib/metaps/bin
VERSION=1.9.9
GRIB_API=-L/usr/local/lib/metaps/lib/grib_api/${VERSION}/lib -lgrib_api_f90 -lgrib_api -L/usr/local/apps/jasper/1.900.0/LP64/lib -ljasper -lm -I/usr/local/lib/metaps/lib/grib_api/${VERSION}/include -I/usr/local/apps/jasper/1.900.0/LP64/include
FFLAGS=-O
EXECS = gribex_count grib_api_count
all: $(EXECS)
grib_api_count: grib_api_count.c
xlc_r -o $@ grib_api_count.c $(GRIB_API)
gribex_count: gribex_count.o gribex_count.F
$(FC) $(FFLAGS) -o $@ gribex_count.o $(LIB)
install: grib_api_count gribex_count gribex_check.ksh gribex_check_no_fail.ksh
cp $(INSTALL_DIR)/grib_api_count $(INSTALL_DIR)/grib_api_count.old
cp grib_api_count $(INSTALL_DIR)/grib_api_count
cp $(INSTALL_DIR)/gribex_count $(INSTALL_DIR)/gribex_count.old
cp gribex_count $(INSTALL_DIR)/gribex_count
cp $(INSTALL_DIR)/gribex_check.ksh $(INSTALL_DIR)/gribex_check.ksh.old
cp gribex_check.ksh $(INSTALL_DIR)/gribex_check.ksh
cp $(INSTALL_DIR)/gribex_check_no_fail.ksh $(INSTALL_DIR)/gribex_check_no_fail.ksh.old
cp gribex_check_no_fail.ksh $(INSTALL_DIR)/gribex_check_no_fail.ksh
clean:
@for name in $(EXECS) ; do\
(rm -f $$name $$name.o ); \
done

View File

@ -1,77 +0,0 @@
# SYNOPSIS
#
# AX_LINUX_DISTRIBUTION
#
# DESCRIPTION
#
# Try to detect the name and version of the Linux distribution where the software is being run
#
# In configure.in:
#
# dnl For my rpm.m4 macros
# AC_SUBST(LINUX_DISTRIBUTION_NAME)
# AC_SUBST(LINUX_DISTRIBUTION_VERSION)
#
# Daniel Varela <dvarela@ecmwf.int> 2011
# Version 1.1 (2011-11-11)
dnl AX_LINUX_DISTRIBUTION
dnl Figure out the Linux distribution where the software is being built
dnl automake target
AC_DEFUN([AX_LINUX_DISTRIBUTION],
[dnl
AC_REQUIRE([AC_CANONICAL_HOST])
HOST_CPU=${host_cpu}
HOST_VENDOR=${host_vendor}
HOST_OS=${host_os}
if test x$HOST_OS = "xlinux-gnu"
then
AC_MSG_CHECKING(for Linux distribution )
# This works for Fedora, RedHat and Slackware
for f in /etc/fedora-release /etc/redhat-release /etc/slackware-release
do
if test -f $f; then
distro=`cat $f`
break
fi
done
# This works in Ubuntu (11 at least)
if test -f /etc/lsb-release; then
distro=`cat /etc/lsb-release | grep DISTRIB_ID | awk -F= '{print $2}' `
distro_version=`cat /etc/lsb-release | grep DISTRIB_RELEASE | awk -F= '{print $2}' `
fi
# For SuSE
if test -f /etc/SuSE-release; then
distro=`cat /etc/SuSE-release | head -1`
#distro_version=`cat /etc/SuSE-release | tail -1 | awk -F= '{print $2}' `
fi
# At least Debian has this
if test -f /etc/issue.net -a "x$distro" = x; then
distro=`cat /etc/issue.net | head -1`
fi
# Everything else
if test "x$distro" = x; then
distro="Unknown Linux"
fi
LINUX_DISTRIBUTION_NAME=$distro
LINUX_DISTRIBUTION_VERSION=$distro_version
AC_MSG_RESULT($LINUX_DISTRIBUTION_NAME $LINUX_DISTRIBUTION_VERSION)
else
LINUX_DISTRIBUTION_NAME=$HOST_OS
LINUX_DISTRIBUTION_VERSION=""
AC_MSG_NOTICE(OS is non-Linux UNIX $HOST_OS.)
fi
AC_SUBST(LINUX_DISTRIBUTION_NAME)
AC_SUBST(LINUX_DISTRIBUTION_VERSION)
])

View File

@ -1,258 +0,0 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_rpm_init.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_RPM_INIT
#
# DESCRIPTION
#
# Setup variables for creation of rpms. It will define several variables
# useful for creating rpms on a system where rpms are supported.
# Currently, I requires changes to Makefile.am to function properly (see
# the example below).
#
# Also note that I do not use any non-UNIX OSs (and for the most part, I
# only use RedHat), so this is probably generally not useful for other
# systems.
#
# Required setup:
#
# In configure.in:
#
# dnl For my rpm.m4 macros
# RPM_RELEASE=1
# AC_SUBST(RPM_RELEASE)
#
# AX_RPM_INIT
# dnl Enable or disable the rpm making rules in Makefile.am
# AM_CONDITIONAL(MAKE_RPMS, test x$make_rpms = xtrue)
#
# Furthermore, the %GNUconfigure rpm macro has a problem in that it does
# not define CXXFLAGS for the target system correctly, so for compiling
# C++ code, add the following line _before_ calling AC_PROG_CXX:
#
# dnl This is a little hack to make this work with rpm better (see mysql++.spec.in)
# test -z "$CXXFLAGS" && CXXFLAGS="${CFLAGS}"
#
# Changes to Makefile.am (I am trying to get rid of this step; suggestions
# invited):
#
# if MAKE_RPMS
# rpm: @RPM_TARGET@
#
# .PHONY: rpm
#
# $(RPM_TARGET): $(DISTFILES)
# ${MAKE} dist
# -mkdir -p $(RPM_DIR)/SRPMS
# -mkdir -p `dirname $(RPM_TARGET)`
# $(RPM_PROG) $(RPM_ARGS) $(RPM_TARBALL)
# @echo Congratulations, $(RPM_TARGET) "(and friends)" should now exist.
# else
# endif
#
# Also, it works best with a XXXX.spec.in file like the following (this is
# way down on the wishlist, but a program to generate the skeleton spec.in
# much like autoscan would just kick butt!):
#
# ---------- 8< ----------
# # -*- Mode:rpm-spec -*-
# # mysql++.spec.in
# Summary: Your package description goes here
# %define rel @RPM_RELEASE@
#
# %define version @VERSION@
# %define pkgname @PACKAGE@
# %define prefix /usr
#
# %define lt_release @LT_RELEASE@
# %define lt_version @LT_CURRENT@.@LT_REVISION@.@LT_AGE@
#
# # This is a hack until I can figure out how to better handle replacing
# # autoconf macros... (gotta love autoconf...)
# %define __aclocal aclocal || aclocal -I ./macros
# %define configure_args @RPM_CONFIGURE_ARGS@
#
# Name: %{pkgname}
# Version: %{version}
# Release: %{rel}
#
# Copyright: LGPL
# Group: # your group name goes here
# Source: %{pkgname}-%{version}.tar.gz
# Requires: # additional requirements
# Buildroot: /tmp/%{pkgname}-root
# URL: http://yoururl.go.here
# Prefix: %{prefix}
# BuildArchitectures: # Target platforms, i.e., i586
# Packager: Your Name <youremail@your.address>
#
# %description
# Your package description
#
# %changelog
#
# %prep
# %setup
# #%patch
#
# %build
# %GNUconfigure %{configure_args}
# # This is why we copy the CFLAGS to the CXXFLAGS in configure.in
# # CFLAGS="%{optflags}" CXXFLAGS="%{optflags}" ./configure %{_target_platform} --prefix=%{prefix}
# make
#
# %install
# # To make things work with BUILDROOT
# if [ "$RPM_BUILD_ROOT" != "/tmp/%{pkgname}-root" ]
# then
# echo
# echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# echo @ @
# echo @ RPM_BUILD_ROOT is not what I expected. Please clean it yourself. @
# echo @ @
# echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# echo
# else
# echo Cleaning RPM_BUILD_ROOT: "$RPM_BUILD_ROOT"
# rm -rf "$RPM_BUILD_ROOT"
# fi
# make DESTDIR="$RPM_BUILD_ROOT" install
#
# %clean
# # Call me paranoid, but I do not want to be responsible for nuking
# # someone's harddrive!
# if [ "$RPM_BUILD_ROOT" != "/tmp/%{pkgname}-root" ]
# then
# echo
# echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# echo @ @
# echo @ RPM_BUILD_ROOT is not what I expected. Please clean it yourself. @
# echo @ @
# echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# echo
# else
# echo Cleaning RPM_BUILD_ROOT: "$RPM_BUILD_ROOT"
# rm -rf "$RPM_BUILD_ROOT"
# fi
#
# %files
# %defattr(-, root, root)
# # Your application file list goes here
# # %{prefix}/lib/lib*.so*
# %doc COPYRIGHT ChangeLog README AUTHORS NEWS
# %doc doc/*
#
# # If you install a library
# %post -p /sbin/ldconfig
#
# # If you install a library
# %postun -p /sbin/ldconfig
#
# %package devel
# Summary: Development files for %{pkgname}
# Group: Applications/Databases
# %description devel
# Development files for %{pkgname}.
#
# %files devel
# %defattr(-, root, root)
# # Your development files go here
# # Programmers documentation goes here
# %doc doc
#
# # end of file
# ---------- >8 ----------
#
# LICENSE
#
# Copyright (c) 2008 Dale K. Hawkins <dhawkins@cdrgts.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
# Modified by Daniel Varela <dvarela@ecmwf.int> 2011
#serial 5
dnl AX_RPM_INIT
dnl Figure out how to create rpms for this system and setup for an
dnl automake target
AU_ALIAS([AM_RPM_INIT], [AX_RPM_INIT])
AC_DEFUN([AX_RPM_INIT],
[dnl
AC_REQUIRE([AC_CANONICAL_HOST])
RPM_HOST_CPU=${host_cpu}
RPM_HOST_VENDOR=${host_vendor}
RPM_HOST_OS=${host_os}
dnl Find the RPM program
AC_ARG_WITH(rpmbuild-prog,[ --with-rpmbuild-prog=PROG Which rpmbuild to use (optional)],
rpmbuild_prog="$withval", rpmbuild_prog="")
AC_ARG_WITH(rpmbuild-extra-args, [ --with-rpmbuild-extra-args=ARGS Run rpmbuild with extra arguments (defaults to none)],
rpmbuild_extra_args="$withval", rpmbuild_extra_args="")
AC_ARG_WITH(rpm-release, [ --with-rpm-release=NUMBER The rpms will use this release number (defaults to 1)],
rpm_release="$withval", rpm_release=1)
RPM_TARGET=""
RPM_RELEASE=$rpm_release
AC_PATH_PROG(RPMBUILD_PROG, rpmbuild, no)
no_rpm=no
if test "$RPMBUILD_PROG" = "no"
then
echo rpm package building is disabled. Set the path to the rpmbuild program using --with-rpmbuild-prog=PROG
no_rpm=yes
RPM_MAKE_RULES=""
else
# AC_MSG_CHECKING(how rpmbuild sets %{_rpmdir})
rpmdir=`$RPMBUILD_PROG --eval %{_rpmdir} 2> /dev/null`
if test x$rpmdir = x"%{_rpmdir}" ; then
AC_MSG_RESULT([not set (cannot build rpms?)])
echo *** Could not determine the value of %{_rpmdir}
echo *** This could be because it is not set, or your version of rpm does not set it
echo *** It must be set in order to generate the correct rpm generation commands
echo ***
echo *** You might still be able to create rpms, but I could not automate it for you
echo *** BTW, if you know this is wrong, please help to improve the rpm.m4 module
echo *** Send corrections, updates and fixes to dhawkins@cdrgts.com. Thanks.
# else
# AC_MSG_RESULT([$rpmdir])
fi
AC_MSG_CHECKING(how rpm sets %{_rpmfilename})
rpmfilename=`$RPMBUILD_PROG --eval %{_rpmfilename} 2> /dev/null | sed "s/%{ARCH}/${RPM_HOST_CPU}/g" | sed "s/%{NAME}/$PACKAGE/g" | sed "s/%{VERSION}/${VERSION}/g" | sed "s/%{RELEASE}/${RPM_RELEASE}/g"`
AC_MSG_RESULT([$rpmfilename])
RPM_DIR=${rpmdir}
RPM_TARGET=$rpmfilename
RPM_ARGS="-ta $rpmbuild_extra_args"
RPM_TARBALL=${PACKAGE}-${VERSION}.tar.gz
fi
case "${no_rpm}" in
yes) make_rpms=false;;
no) make_rpms=true;;
*) AC_MSG_WARN([bad value ${no_rpm} for no_rpm (not making rpms)])
make_rpms=false;;
esac
AC_SUBST(RPM_DIR)
AC_SUBST(RPM_TARGET)
AC_SUBST(RPM_ARGS)
AC_SUBST(RPM_TARBALL)
AC_SUBST(RPM_HOST_CPU)
AC_SUBST(RPM_HOST_VENDOR)
AC_SUBST(RPM_HOST_OS)
RPM_CONFIGURE_ARGS=${ac_configure_args}
AC_SUBST(RPM_CONFIGURE_ARGS)
])

View File

@ -1,23 +0,0 @@
all : ../definitions/grib2/tigge_name.def ../tigge/tigge_check.h db
# ./tigge_def.pl produces 3 files. The rule is only for tigge_name.def
# ../definitions/grib2/tigge_parameter.def
# ../definitions/grib2/tigge_short_name.def
../definitions/grib2/tigge_name.def: master.info tigge_def.pl
-p4 edit ../definitions/grib2/tigge_name.def
-p4 edit ../definitions/grib2/tigge_parameter.def
-p4 edit ../definitions/grib2/tigge_short_name.def
./tigge_def.pl master.info
cp tigge_name.def ../definitions/grib2/tigge_name.def
cp tigge_parameter.def ../definitions/grib2/tigge_parameter.def
cp tigge_short_name.def ../definitions/grib2/tigge_short_name.def
../tigge/tigge_check.h: master.info tigge_check.info tigge_check.pl
-p4 edit ../tigge/tigge_check.h
./tigge_check.pl master.info tigge_check.info > ../tigge/tigge_check.h
db : master.info feed_metdb.pl
./feed_metdb.pl
./feed_tigge.pl prod
touch db

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -240,17 +240,17 @@ grib_hash_array_value* get_hash_array(grib_handle* h,grib_action* a)
id=grib_itrie_get_id(h->context->hash_array_index,key);
if ((c=h->context->hash_array[id])!=NULL) return c;
if (*local && (full=grib_context_full_path(context,local))!=NULL) {
if (*local && (full=grib_context_full_defs_path(context,local))!=NULL) {
c=grib_parse_hash_array_file(context,full);
grib_context_log(h->context,GRIB_LOG_DEBUG,
"Loading hash_array %s from %s",((grib_action*)self)->name,full);
} else if (*ecmf && (full=grib_context_full_path(context,ecmf))!=NULL) {
} else if (*ecmf && (full=grib_context_full_defs_path(context,ecmf))!=NULL) {
c=grib_parse_hash_array_file(context,full);
grib_context_log(h->context,GRIB_LOG_DEBUG,
"Loading hash_array %s from %s",((grib_action*)self)->name,full);
}
full=grib_context_full_path(context,master);
full=grib_context_full_defs_path(context,master);
if(c) {
grib_hash_array_value* last=c;

View File

@ -127,7 +127,7 @@ static void destroy(grib_context* context,grib_action* act)
grib_action_set_iarray* a = (grib_action_set_iarray*) act;
grib_context_free_persistent(context, a->name);
grib_iarray_delete(context,a->iarray);
grib_iarray_delete(a->iarray);
grib_context_free_persistent(context, act->name);
grib_context_free_persistent(context, act->op);

View File

@ -9,7 +9,7 @@
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -86,6 +86,8 @@ static grib_accessor_class _grib_accessor_class_ascii = {
&unpack_double, /* grib_unpack procedures double */
&pack_string, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -113,6 +115,8 @@ static void init_class(grib_accessor_class* c)
c->sub_section = (*(c->super))->sub_section;
c->pack_missing = (*(c->super))->pack_missing;
c->is_missing = (*(c->super))->is_missing;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl
@ -233,7 +233,7 @@ typedef struct grib_accessor_bufr_data_element {
static int number_of_qualifiers=NUMBER_OF_QUALIFIERS_PER_CATEGORY*NUMBER_OF_QUALIFIERS_CATEGORIES;
static inline int significanceQualifierIndex(X,Y) {
static inline int significanceQualifierIndex(int X,int Y) {
int a[]={-1,0,1,-1,-1,-1,-1,-1,2};
return Y+a[X]*NUMBER_OF_QUALIFIERS_PER_CATEGORY;
}

View File

@ -11,7 +11,7 @@
* Enrico Fucile
****************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
#include <ctype.h>
/*

View File

@ -11,7 +11,7 @@
* Enrico Fucile
****************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
#include <ctype.h>
/*

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -12,7 +12,7 @@
* Enrico Fucile
**********************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -9,7 +9,7 @@
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -12,7 +12,7 @@
* Enrico Fucile
**********************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -70,6 +70,8 @@ static grib_accessor_class _grib_accessor_class_bytes = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -105,6 +107,8 @@ static void init_class(grib_accessor_class* c)
c->pack_double = (*(c->super))->pack_double;
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -108,6 +108,8 @@ static grib_accessor_class _grib_accessor_class_codetable = {
0, /* grib_unpack procedures double */
&pack_string, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
&pack_expression, /* pack_expression */
@ -139,6 +141,8 @@ static void init_class(grib_accessor_class* c)
c->pack_long = (*(c->super))->pack_long;
c->pack_double = (*(c->super))->pack_double;
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->notify_change = (*(c->super))->notify_change;

View File

@ -88,6 +88,8 @@ static grib_accessor_class _grib_accessor_class_concept = {
&unpack_double, /* grib_unpack procedures double */
&pack_string, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -115,6 +117,8 @@ static void init_class(grib_accessor_class* c)
c->sub_section = (*(c->super))->sub_section;
c->pack_missing = (*(c->super))->pack_missing;
c->is_missing = (*(c->super))->is_missing;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -79,6 +79,8 @@ static grib_accessor_class _grib_accessor_class_constant = {
0, /* grib_unpack procedures double */
&pack_string, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
&pack_bytes, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -113,6 +115,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_long = (*(c->super))->unpack_long;
c->unpack_double = (*(c->super))->unpack_double;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;
c->notify_change = (*(c->super))->notify_change;

View File

@ -88,6 +88,8 @@ static grib_accessor_class _grib_accessor_class_data_apply_bitmap = {
&unpack_double, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -120,6 +122,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_long = (*(c->super))->unpack_long;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -86,6 +86,8 @@ static grib_accessor_class _grib_accessor_class_data_apply_boustrophedonic = {
&unpack_double, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -118,6 +120,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_long = (*(c->super))->unpack_long;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -91,6 +91,8 @@ static grib_accessor_class _grib_accessor_class_data_apply_boustrophedonic_bitma
&unpack_double, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -123,6 +125,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_long = (*(c->super))->unpack_long;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -143,6 +143,8 @@ static grib_accessor_class _grib_accessor_class_data_g1second_order_general_exte
&unpack_double, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -177,6 +179,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_long = (*(c->super))->unpack_long;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -89,6 +89,8 @@ static grib_accessor_class _grib_accessor_class_data_g2simple_packing = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
&pack_bytes, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -124,6 +126,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;
c->notify_change = (*(c->super))->notify_change;

View File

@ -109,6 +109,8 @@ static grib_accessor_class _grib_accessor_class_data_jpeg2000_packing = {
&unpack_double, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -143,6 +145,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_long = (*(c->super))->unpack_long;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -90,6 +90,8 @@ static grib_accessor_class _grib_accessor_class_data_raw_packing = {
&unpack_double, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -124,6 +126,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_long = (*(c->super))->unpack_long;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -105,6 +105,8 @@ static grib_accessor_class _grib_accessor_class_data_simple_packing = {
&unpack_double, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -139,6 +141,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_long = (*(c->super))->unpack_long;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -12,7 +12,7 @@
* Enrico Fucile
****************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
#include <ctype.h>
/*
@ -164,7 +164,7 @@ static grib_trie* load_dictionary(grib_context* c,grib_accessor* a, int* err) {
*err=GRIB_SUCCESS;
filename=grib_context_full_path(c,self->dictionary);
filename=grib_context_full_defs_path(c,self->dictionary);
if (!filename) {
grib_context_log(c,GRIB_LOG_ERROR,"unable to find def file %s",self->dictionary);
*err=GRIB_FILE_NOT_FOUND;

View File

@ -77,6 +77,8 @@ static grib_accessor_class _grib_accessor_class_double = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -110,6 +112,8 @@ static void init_class(grib_accessor_class* c)
c->pack_double = (*(c->super))->pack_double;
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -15,7 +15,7 @@ expanded descriptors cannot contain sequences and only delayed replication
can appear
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -75,6 +75,8 @@ static grib_accessor_class _grib_accessor_class_g1_half_byte_codeflag = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -108,6 +110,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -79,6 +79,8 @@ static grib_accessor_class _grib_accessor_class_g1bitmap = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
&unpack_bytes, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -114,6 +116,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->pack_expression = (*(c->super))->pack_expression;
c->notify_change = (*(c->super))->notify_change;

View File

@ -78,6 +78,8 @@ static grib_accessor_class _grib_accessor_class_g1end_of_interval_monthly = {
&unpack_double, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -113,6 +115,8 @@ static void init_class(grib_accessor_class* c)
c->pack_double = (*(c->super))->pack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -22,6 +22,7 @@
IMPLEMENTS = unpack_long;pack_long; clear
IMPLEMENTS = unpack_double;pack_double;unpack_double_element
IMPLEMENTS = unpack_string;pack_string
IMPLEMENTS = unpack_string_array;pack_string_array
IMPLEMENTS = unpack_bytes;pack_bytes
IMPLEMENTS = unpack_double_subarray
IMPLEMENTS = init;dump;destroy;string_length
@ -51,11 +52,13 @@ static int pack_bytes(grib_accessor*,const unsigned char*, size_t *len);
static int pack_double(grib_accessor*, const double* val,size_t *len);
static int pack_long(grib_accessor*, const long* val,size_t *len);
static int pack_string(grib_accessor*, const char*, size_t *len);
static int pack_string_array(grib_accessor*, const char**, size_t *len);
static int pack_expression(grib_accessor*, grib_expression*);
static int unpack_bytes (grib_accessor*,unsigned char*, size_t *len);
static int unpack_double(grib_accessor*, double* val,size_t *len);
static int unpack_long(grib_accessor*, long* val,size_t *len);
static int unpack_string (grib_accessor*, char*, size_t *len);
static int unpack_string_array (grib_accessor*, char**, size_t *len);
static size_t string_length(grib_accessor*);
static long byte_count(grib_accessor*);
static long byte_offset(grib_accessor*);
@ -105,6 +108,8 @@ static grib_accessor_class _grib_accessor_class_gen = {
&unpack_double, /* grib_unpack procedures double */
&pack_string, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
&pack_string_array, /* grib_pack array procedures string */
&unpack_string_array, /* grib_unpack array procedures string */
&pack_bytes, /* grib_pack procedures bytes */
&unpack_bytes, /* grib_unpack procedures bytes */
&pack_expression, /* pack_expression */
@ -178,14 +183,21 @@ static void init(grib_accessor* a,const long len, grib_arguments* param)
static void dump(grib_accessor* a, grib_dumper* dumper)
{
if(a->cclass->unpack_string)
int type=grib_accessor_get_native_type(a);
switch (type) {
case GRIB_TYPE_STRING:
grib_dump_string(dumper,a,NULL);
else if(a->cclass->unpack_double)
break;
case GRIB_TYPE_DOUBLE:
grib_dump_double(dumper,a,NULL);
else if(a->cclass->unpack_long)
break;
case GRIB_TYPE_LONG:
grib_dump_long(dumper,a,NULL);
else
break;
default:
grib_dump_bytes(dumper,a,NULL);
}
}
static long next_offset(grib_accessor* a)
@ -341,6 +353,10 @@ static int unpack_string(grib_accessor*a , char* v, size_t *len){
return GRIB_NOT_IMPLEMENTED;
}
static int unpack_string_array(grib_accessor*a , char** v, size_t *len){
return GRIB_NOT_IMPLEMENTED;
}
static int pack_expression(grib_accessor* a, grib_expression *e){
size_t len = 1;
long lval;
@ -423,6 +439,10 @@ static int pack_double(grib_accessor* a, const double *v, size_t *len){
return GRIB_NOT_IMPLEMENTED;
}
static int pack_string_array(grib_accessor*a , const char** v, size_t *len){
return GRIB_NOT_IMPLEMENTED;
}
static int pack_string(grib_accessor*a , const char* v, size_t *len){
if(a->cclass->pack_double && a->cclass->pack_double != &pack_double)
{

View File

@ -11,7 +11,7 @@
* Enrico Fucile
***********************************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -13,7 +13,7 @@
* Enrico Fucile
******************************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -89,6 +89,8 @@ static grib_accessor_class _grib_accessor_class_ibmfloat = {
&unpack_double, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -120,6 +122,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_long = (*(c->super))->unpack_long;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -78,6 +78,8 @@ static grib_accessor_class _grib_accessor_class_ieeefloat = {
&unpack_double, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -112,6 +114,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_long = (*(c->super))->unpack_long;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -71,6 +71,8 @@ static grib_accessor_class _grib_accessor_class_label = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -105,6 +107,8 @@ static void init_class(grib_accessor_class* c)
c->pack_double = (*(c->super))->pack_double;
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -76,6 +76,8 @@ static grib_accessor_class _grib_accessor_class_long = {
&unpack_double, /* grib_unpack procedures double */
&pack_string, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -107,6 +109,8 @@ static void init_class(grib_accessor_class* c)
c->pack_long = (*(c->super))->pack_long;
c->unpack_long = (*(c->super))->unpack_long;
c->pack_double = (*(c->super))->pack_double;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -86,6 +86,8 @@ static grib_accessor_class _grib_accessor_class_lookup = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -117,6 +119,8 @@ static void init_class(grib_accessor_class* c)
c->pack_double = (*(c->super))->pack_double;
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -19,7 +19,8 @@
IMPLEMENTS = get_native_type;init
IMPLEMENTS = compare;unpack_string;value_count
MEMBERS = const char* offset
MEMBERS = const char* length
MEMBERS = grib_expression* length
MEMBERS = grib_string_list* blacklist
END_CLASS_DEF
*/
@ -46,7 +47,8 @@ typedef struct grib_accessor_md5 {
/* Members defined in gen */
/* Members defined in md5 */
const char* offset;
const char* length;
grib_expression* length;
grib_string_list* blacklist;
} grib_accessor_md5;
extern grib_accessor_class* grib_accessor_class_gen;
@ -76,6 +78,8 @@ static grib_accessor_class _grib_accessor_class_md5 = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -110,6 +114,8 @@ static void init_class(grib_accessor_class* c)
c->pack_double = (*(c->super))->pack_double;
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;
@ -129,10 +135,25 @@ static void init_class(grib_accessor_class* c)
static void init(grib_accessor* a, const long len , grib_arguments* arg )
{
grib_accessor_md5* self = (grib_accessor_md5*)a;
char* b=0;
int n=0;
grib_string_list* current=0;
grib_context* context=a->parent->h->context;
self->offset = grib_arguments_get_name(a->parent->h,arg,n++);
self->length = grib_arguments_get_name(a->parent->h,arg,n++);
self->length = grib_arguments_get_expression(a->parent->h,arg,n++);
self->blacklist=0;
while ( (b=(char*)grib_arguments_get_name(a->parent->h,arg,n++)) !=NULL) {
if (! self->blacklist) {
self->blacklist=grib_context_malloc_clear(context,sizeof(grib_string_list));
self->blacklist->value=grib_context_strdup(context,b);
current=self->blacklist;
} else {
current->next=grib_context_malloc_clear(context,sizeof(grib_string_list));
current->next->value=grib_context_strdup(context,b);
current=current->next;
}
}
a->length = 0;
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC;
@ -185,18 +206,20 @@ static int unpack_string(grib_accessor*a , char* v, size_t *len){
if((ret = grib_get_long_internal(a->parent->h,self->offset,&offset))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(a->parent->h,self->length,&length))
if((ret = grib_expression_evaluate_long(a->parent->h,self->length,&length))
!= GRIB_SUCCESS)
return ret;
mess=grib_context_malloc(a->parent->h->context,length);
memcpy(mess,a->parent->h->buffer->data+offset,length);
mess_len=length;
blacklist=a->parent->h->context->blacklist;
/* passed blacklist overrides context blacklist.
Consider to modify following line to extend context blacklist.
*/
if (self->blacklist) blacklist=self->blacklist;
while (blacklist && blacklist->value) {
b=grib_find_accessor(a->parent->h,blacklist->value);
if (!b) {
grib_context_free(a->parent->h->context,mess);

View File

@ -79,6 +79,8 @@ static grib_accessor_class _grib_accessor_class_message = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -113,6 +115,8 @@ static void init_class(grib_accessor_class* c)
c->pack_double = (*(c->super))->pack_double;
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -95,6 +95,8 @@ static grib_accessor_class _grib_accessor_class_missing = {
&unpack_double, /* grib_unpack procedures double */
&pack_string, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
&pack_bytes, /* grib_pack procedures bytes */
&unpack_bytes, /* grib_unpack procedures bytes */
&pack_expression, /* pack_expression */

View File

@ -11,7 +11,7 @@
* Enrico Fucile
***********************************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -76,6 +76,8 @@ static grib_accessor_class _grib_accessor_class_pad = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -113,6 +115,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -78,6 +78,8 @@ static grib_accessor_class _grib_accessor_class_padding = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -112,6 +114,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -76,6 +76,8 @@ static grib_accessor_class _grib_accessor_class_padto = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -112,6 +114,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -78,6 +78,8 @@ static grib_accessor_class _grib_accessor_class_padtoeven = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -115,6 +117,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -78,6 +78,8 @@ static grib_accessor_class _grib_accessor_class_padtomultiple = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -115,6 +117,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -78,6 +78,8 @@ static grib_accessor_class _grib_accessor_class_position = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -112,6 +114,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -79,6 +79,8 @@ static grib_accessor_class _grib_accessor_class_section = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -111,6 +113,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -71,6 +71,8 @@ static grib_accessor_class _grib_accessor_class_section_padding = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -108,6 +110,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -11,7 +11,7 @@
* Enrico Fucile
***********************************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -87,6 +87,8 @@ static grib_accessor_class _grib_accessor_class_signed = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -116,6 +118,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -86,6 +86,8 @@ static grib_accessor_class _grib_accessor_class_signed_bits = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -116,6 +118,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -12,7 +12,7 @@
* Enrico Fucile
****************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
#include <ctype.h>
/*
@ -217,16 +217,16 @@ static grib_smart_table* load_table(grib_accessor_smart_table* self)
if (*masterDir!=0) {
sprintf(name,"%s/%s",masterDir,self->tablename);
grib_recompose_name(h, NULL,name, recomposed,0);
filename=grib_context_full_path(c,recomposed);
filename=grib_context_full_defs_path(c,recomposed);
} else {
grib_recompose_name(h, NULL,self->tablename, recomposed,0);
filename=grib_context_full_path(c,recomposed);
filename=grib_context_full_defs_path(c,recomposed);
}
if (*localDir!=0) {
sprintf(localName,"%s/%s",localDir,self->tablename);
grib_recompose_name(h, NULL,localName, localRecomposed,0);
localFilename=grib_context_full_path(c,localRecomposed);
localFilename=grib_context_full_defs_path(c,localRecomposed);
}
next=c->smart_table;

View File

@ -12,7 +12,7 @@
* Enrico Fucile
****************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
#include <ctype.h>
/*

View File

@ -86,6 +86,8 @@ static grib_accessor_class _grib_accessor_class_spd = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -116,6 +118,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -87,6 +87,8 @@ static grib_accessor_class _grib_accessor_class_statistics = {
&unpack_double, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -121,6 +123,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_long = (*(c->super))->unpack_long;
c->pack_double = (*(c->super))->pack_double;
c->pack_string = (*(c->super))->pack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -91,6 +91,8 @@ static grib_accessor_class _grib_accessor_class_statistics_spectral = {
&unpack_double, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -126,6 +128,8 @@ static void init_class(grib_accessor_class* c)
c->pack_double = (*(c->super))->pack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -11,7 +11,7 @@
* Enrico Fucile
***********************************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -11,7 +11,7 @@
* Enrico Fucile
***********************************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -11,7 +11,7 @@
* Enrico Fucile
***********************************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -11,7 +11,7 @@
* Enrico Fucile
****************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
#include <ctype.h>
/*

View File

@ -87,6 +87,8 @@ static grib_accessor_class _grib_accessor_class_unsigned = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -116,6 +118,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -86,6 +86,8 @@ static grib_accessor_class _grib_accessor_class_unsigned_bits = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -116,6 +118,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -93,6 +93,8 @@ static grib_accessor_class _grib_accessor_class_values = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -124,6 +126,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -90,6 +90,8 @@ static grib_accessor_class _grib_accessor_class_variable = {
&unpack_double, /* grib_unpack procedures double */
&pack_string, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -116,6 +118,8 @@ static void init_class(grib_accessor_class* c)
c->sub_section = (*(c->super))->sub_section;
c->pack_missing = (*(c->super))->pack_missing;
c->is_missing = (*(c->super))->is_missing;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -74,6 +74,8 @@ static grib_accessor_class _grib_accessor_class_when = {
0, /* grib_unpack procedures double */
0, /* grib_pack procedures string */
0, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
@ -110,6 +112,8 @@ static void init_class(grib_accessor_class* c)
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;

View File

@ -194,7 +194,7 @@ long grib_iarray_pop(grib_iarray *a);
long grib_iarray_pop_front(grib_iarray *a);
grib_iarray *grib_iarray_resize_to(grib_iarray *v, size_t newsize);
grib_iarray *grib_iarray_resize(grib_iarray *v);
grib_iarray *grib_iarray_push(grib_context *c, grib_iarray *v, long val);
grib_iarray *grib_iarray_push(grib_iarray *v, long val);
grib_iarray *grib_iarray_push_front(grib_iarray *v, long val);
grib_iarray *grib_iarray_push_array(grib_iarray *v, long *val, size_t size);
long grib_iarray_get(grib_iarray *a, size_t i);

View File

@ -286,6 +286,7 @@ static grib_context default_grib_context = {
&default_log, /* logging_procedure */
&default_print, /* print procedure */
0, /* code tables */
0, /* smart tables */
0, /* files */
0, /* multigrib support on */
0, /* multigrib support */
@ -302,11 +303,16 @@ static grib_context default_grib_context = {
0, /* concepts_index */
0, /* concepts_count */
{0,}, /* concepts */
0, /* hash_array_index */
0, /* hash_array_count */
{0,}, /* hash_array */
0, /* def_files */
0, /* ieee_packing */
0, /* unpack */
0, /* blacklist */
0, /* log_stream */
0 /* classes */
0, /* classes */
0 /* lists */
#if GRIB_PTHREADS
,PTHREAD_MUTEX_INITIALIZER /* mutex */
#endif
@ -329,6 +335,7 @@ grib_context* grib_context_get_default()
const char *no_big_group_split=NULL;
const char *no_spd=NULL;
const char *keep_matrix=NULL;
const char *nounpack=NULL;
GRIB_MUTEX_LOCK(&mutex_c);
@ -343,6 +350,7 @@ grib_context* grib_context_get_default()
no_big_group_split=getenv("GRIB_API_NO_BIG_GROUP_SPLIT");
no_spd=getenv("GRIB_API_NO_SPD");
keep_matrix=getenv("GRIB_API_KEEP_MATRIX");
nounpack=getenv("GRIB_API_NO_UNPACK");
/* On UNIX, when we read from a file we get exactly what is in the file on disk.
* But on Windows a file can be opened in binary or text mode. In binary mode the system behaves exactly as in UNIX.
@ -356,6 +364,7 @@ grib_context* grib_context_get_default()
default_grib_context.no_big_group_split = no_big_group_split ? atoi(no_big_group_split) : 0;
default_grib_context.no_spd = no_spd ? atoi(no_spd) : 0;
default_grib_context.keep_matrix = keep_matrix ? atoi(keep_matrix) : 1;
default_grib_context.unpack = nounpack ? 0 : 1;
default_grib_context.write_on_fail = write_on_fail ? atoi(write_on_fail) : 0;
default_grib_context.no_abort = no_abort ? atoi(no_abort) : 0;
default_grib_context.debug = debug ? atoi(debug) : 0;
@ -396,7 +405,10 @@ grib_context* grib_context_get_default()
default_grib_context.concepts_index=grib_itrie_new(&(default_grib_context),
&(default_grib_context.concepts_count));
default_grib_context.hash_array_index=grib_itrie_new(&(default_grib_context),
&(default_grib_context.hash_array_count));
default_grib_context.def_files=grib_trie_new(&(default_grib_context));
default_grib_context.lists=grib_trie_new(&(default_grib_context));
default_grib_context.classes=grib_trie_new(&(default_grib_context));
GRIB_MUTEX_UNLOCK(&mutex_c);
@ -440,6 +452,7 @@ grib_context* grib_context_new(grib_context* parent)
c->print = default_grib_context.print ;
c->user_data = default_grib_context.user_data;
c->def_files = default_grib_context.def_files;
c->lists = default_grib_context.lists;
#if GRIB_PTHREADS
pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE);
@ -635,6 +648,9 @@ void grib_context_reset(grib_context* c)
if(c->codetable) grib_codetable_delete(c);
c->codetable = NULL;
if(c->smart_table) grib_smart_table_delete(c);
c->smart_table = NULL;
if(c->grib_definition_files_dir)
grib_context_free(c,c->grib_definition_files_dir);

View File

@ -69,6 +69,7 @@ static grib_dumper_class _grib_dumper_class_c_code = {
&dump_long, /* dump long */
&dump_double, /* dump double */
&dump_string, /* dump string */
0, /* dump string array */
&dump_label, /* dump labels */
&dump_bytes, /* dump bytes */
&dump_bits, /* dump bits */

View File

@ -70,6 +70,7 @@ static grib_dumper_class _grib_dumper_class_debug = {
&dump_long, /* dump long */
&dump_double, /* dump double */
&dump_string, /* dump string */
0, /* dump string array */
&dump_label, /* dump labels */
&dump_bytes, /* dump bytes */
&dump_bits, /* dump bits */

View File

@ -21,7 +21,7 @@
START_CLASS_DEF
CLASS = dumper
IMPLEMENTS = dump_long;dump_bits
IMPLEMENTS = dump_double;dump_string
IMPLEMENTS = dump_double;dump_string;dump_string_array
IMPLEMENTS = dump_bytes;dump_values
IMPLEMENTS = dump_label;dump_section
IMPLEMENTS = init;destroy
@ -50,6 +50,7 @@ static void dump_long (grib_dumper* d, grib_accessor* a,const char* commen
static void dump_bits (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_double (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_string (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_string_array (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_bytes (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_values (grib_dumper* d, grib_accessor* a);
static void dump_label (grib_dumper* d, grib_accessor* a,const char* comment);
@ -75,6 +76,7 @@ static grib_dumper_class _grib_dumper_class_default = {
&dump_long, /* dump long */
&dump_double, /* dump double */
&dump_string, /* dump string */
&dump_string_array, /* dump string array */
&dump_label, /* dump labels */
&dump_bytes, /* dump bytes */
&dump_bits, /* dump bits */
@ -300,6 +302,73 @@ static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
fprintf(self->dumper.out,"\n");
}
static void dump_string_array(grib_dumper* d,grib_accessor* a,const char* comment)
{
grib_dumper_default *self = (grib_dumper_default*)d;
char **values;
size_t size = 0,i=0;
grib_context* c=NULL;
int err = 0;
int tab=0;
long count=0;
c=a->parent->h->context;
grib_value_count(a,&count);
size=count;
if (size==1) {
dump_string(d,a,comment);
return;
}
values=(char**)grib_context_malloc_clear(c,size*sizeof(char*));
if (!values) {
grib_context_log(c,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size);
return;
}
err = grib_unpack_string_array(a,values,&size);
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
print_offset(self->dumper.out,d,a);
if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) {
fprintf(self->dumper.out," ");
fprintf(self->dumper.out,"# type %s \n",a->creator->op);
}
aliases(d,a);
if(comment) {
fprintf(self->dumper.out," ");
fprintf(self->dumper.out,"# %s \n",comment);
}
if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) {
fprintf(self->dumper.out," ");
fprintf(self->dumper.out,"#-READ ONLY- ");
tab=13;
} else
fprintf(self->dumper.out," ");
tab++;
fprintf(self->dumper.out,"%s = {\n",a->name);
for (i=0;i<size;i++) {
fprintf(self->dumper.out,"%-*s\"%s\",\n",(int)(tab+strlen(a->name)+4)," ",values[i]);
}
fprintf(self->dumper.out," }");
if(err) {
fprintf(self->dumper.out," ");
fprintf(self->dumper.out,"# *** ERR=%d (%s)",err,grib_get_error_message(err));
}
fprintf(self->dumper.out,"\n");
grib_context_free(c,values);
}
static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
{
grib_dumper_default *self = (grib_dumper_default*)d;

View File

@ -16,7 +16,7 @@
START_CLASS_DEF
CLASS = dumper
IMPLEMENTS = dump_long;dump_bits
IMPLEMENTS = dump_double;dump_string
IMPLEMENTS = dump_double;dump_string;dump_string_array
IMPLEMENTS = dump_bytes;dump_values
IMPLEMENTS = dump_label;dump_section
IMPLEMENTS = init;destroy
@ -45,6 +45,7 @@ static void dump_long (grib_dumper* d, grib_accessor* a,const char* commen
static void dump_bits (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_double (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_string (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_string_array (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_bytes (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_values (grib_dumper* d, grib_accessor* a);
static void dump_label (grib_dumper* d, grib_accessor* a,const char* comment);
@ -70,6 +71,7 @@ static grib_dumper_class _grib_dumper_class_json = {
&dump_long, /* dump long */
&dump_double, /* dump double */
&dump_string, /* dump string */
&dump_string_array, /* dump string array */
&dump_label, /* dump labels */
&dump_bytes, /* dump bytes */
&dump_bits, /* dump bits */
@ -265,6 +267,53 @@ static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
}
static void dump_string_array(grib_dumper* d,grib_accessor* a,const char* comment)
{
grib_dumper_json *self = (grib_dumper_json*)d;
char **values;
size_t size = 0,i=0;
grib_context* c=NULL;
int err = 0;
int tab=0;
long count=0;
int mydepth=depth+2;
c=a->parent->h->context;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
grib_value_count(a,&count);
size=count;
if (size==1) {
dump_string(d,a,comment);
return;
}
if (!self->begin) fprintf(self->dumper.out,",\n");
else self->begin=0;
values=(char**)grib_context_malloc_clear(c,size*sizeof(char*));
if (!values) {
grib_context_log(c,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size);
return;
}
err = grib_unpack_string_array(a,values,&size);
fprintf(self->dumper.out,"%-*s",mydepth," ");
fprintf(self->dumper.out,"\"%s\" : [\n",a->name);
tab=mydepth+1;
for (i=0;i<size-1;i++) {
fprintf(self->dumper.out,"%-*s\"%s\",\n",(int)(tab+strlen(a->name)+4)," ",values[i]);
}
fprintf(self->dumper.out,"%-*s\"%s\"\n",(int)(tab+strlen(a->name)+4)," ",values[i]);
fprintf(self->dumper.out,"%-*s",mydepth," ");
fprintf(self->dumper.out," ],");
grib_context_free(c,values);
}
static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
{
grib_dumper_json *self = (grib_dumper_json*)d;
@ -306,6 +355,7 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
static void dump_bytes(grib_dumper* d,grib_accessor* a,const char* comment)
{
}
static void dump_label(grib_dumper* d,grib_accessor* a,const char* comment)
@ -315,14 +365,29 @@ static void dump_label(grib_dumper* d,grib_accessor* a,const char* comment)
static void dump_section(grib_dumper* d,grib_accessor* a,grib_block_of_accessors* block)
{
grib_dumper_json *self = (grib_dumper_json*)d;
if ( !grib_inline_strcmp(a->name,"GRIB") ) {
if (!grib_inline_strcmp(a->name,"BUFR") ||
!grib_inline_strcmp(a->name,"GRIB") ||
!grib_inline_strcmp(a->name,"META")
) {
fprintf(self->dumper.out,"{\n");
self->begin=1;
grib_dump_accessors_block(d,block);
fprintf(self->dumper.out,"\n}\n");
}
else {
} else if (!grib_inline_strcmp(a->name,"groupNumber")) {
depth+=2;
fprintf(self->dumper.out,",\n");
fprintf(self->dumper.out,"%-*s",depth," ");
fprintf(self->dumper.out,"\"group%d\" : {",(int)a->bufr_group_number);
fprintf(self->dumper.out,"\n");
/* fprintf(self->dumper.out,"%-*s",depth," "); */
self->begin=1;
grib_dump_accessors_block(d,block);
fprintf(self->dumper.out,"\n");
fprintf(self->dumper.out,"%-*s",depth," ");
fprintf(self->dumper.out,"}");
depth-=2;
} else {
grib_dump_accessors_block(d,block);
}
}

View File

@ -75,6 +75,7 @@ static grib_dumper_class _grib_dumper_class_keys = {
&dump_long, /* dump long */
&dump_double, /* dump double */
&dump_string, /* dump string */
0, /* dump string array */
&dump_label, /* dump labels */
&dump_bytes, /* dump bytes */
&dump_bits, /* dump bits */

View File

@ -70,6 +70,7 @@ static grib_dumper_class _grib_dumper_class_serialize = {
&dump_long, /* dump long */
&dump_double, /* dump double */
&dump_string, /* dump string */
0, /* dump string array */
&dump_label, /* dump labels */
&dump_bytes, /* dump bytes */
&dump_bits, /* dump bits */

View File

@ -75,6 +75,7 @@ static grib_dumper_class _grib_dumper_class_wmo = {
&dump_long, /* dump long */
&dump_double, /* dump double */
&dump_string, /* dump string */
0, /* dump string array */
&dump_label, /* dump labels */
&dump_bytes, /* dump bytes */
&dump_bits, /* dump bits */

View File

@ -13,7 +13,7 @@
**************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
#include <ctype.h>
/*
This is used by make_class.pl

View File

@ -40,25 +40,28 @@ static const char *errors[] = {
"Missing a key from the fieldset", /* -34 GRIB_MISSING_KEY */
"The point is out of the grid area", /* -35 GRIB_OUT_OF_AREA */
"Concept no match", /* -36 GRIB_CONCEPT_NO_MATCH */
"Definitions files not found", /* -37 GRIB_NO_DEFINITIONS */
"Wrong type while packing", /* -38 GRIB_WRONG_TYPE */
"End of resource", /* -39 GRIB_END */
"Unable to code a field without values", /* -40 GRIB_NO_VALUES */
"Grid description is wrong or inconsistent", /* -41 GRIB_WRONG_GRID */
"End of index reached", /* -42 GRIB_END_OF_INDEX */
"Null index", /* -43 GRIB_NULL_INDEX */
"End of resource reached when reading message", /* -44 GRIB_PREMATURE_END_OF_FILE */
"An internal array is too small", /* -45 GRIB_INTERNAL_ARRAY_TOO_SMALL */
"Message is too large for the current architecture", /* -46 GRIB_MESSAGE_TOO_LARGE */
"Constant field", /* -47 GRIB_CONSTANT_FIELD */
"Switch unable to find a matching case", /* -48 GRIB_SWITCH_NO_MATCH */
"Underflow", /* -49 GRIB_UNDERFLOW */
"Message malformed", /* -50 GRIB_MESSAGE_MALFORMED */
"Index is corrupted", /* -51 GRIB_CORRUPTED_INDEX */
"Invalid number of bits per value", /* -52 GRIB_INVALID_BPV */
"Edition of two messages is different", /* -53 GRIB_DIFFERENT_EDITION */
"Value is different", /* -54 GRIB_VALUE_DIFFERENT */
"Invalid key value", /* -55 GRIB_INVALID_KEY_VALUE */
"Hash array no match", /* -37 GRIB_HASH_ARRAY_NO_MATCH */
"Definitions files not found", /* -38 GRIB_NO_DEFINITIONS */
"Wrong type while packing", /* -39 GRIB_WRONG_TYPE */
"End of resource", /* -40 GRIB_END */
"Unable to code a field without values", /* -41 GRIB_NO_VALUES */
"Grid description is wrong or inconsistent", /* -42 GRIB_WRONG_GRID */
"End of index reached", /* -43 GRIB_END_OF_INDEX */
"Null index", /* -44 GRIB_NULL_INDEX */
"End of resource reached when reading message", /* -45 GRIB_PREMATURE_END_OF_FILE */
"An internal array is too small", /* -46 GRIB_INTERNAL_ARRAY_TOO_SMALL */
"Message is too large for the current architecture", /* -47 GRIB_MESSAGE_TOO_LARGE */
"Constant field", /* -48 GRIB_CONSTANT_FIELD */
"Switch unable to find a matching case", /* -49 GRIB_SWITCH_NO_MATCH */
"Underflow", /* -50 GRIB_UNDERFLOW */
"Message malformed", /* -51 GRIB_MESSAGE_MALFORMED */
"Index is corrupted", /* -52 GRIB_CORRUPTED_INDEX */
"Invalid number of bits per value", /* -53 GRIB_INVALID_BPV */
"Edition of two messages is different", /* -54 GRIB_DIFFERENT_EDITION */
"Value is different", /* -55 GRIB_VALUE_DIFFERENT */
"Invalid key value", /* -56 GRIB_INVALID_KEY_VALUE */
"String is smaller than requested", /* -57 GRIB_STRING_TOO_SMALL */
"Wrong type conversion", /* -58 GRIB_WRONG_CONVERSION */
"Value mismatch", /* 1 GRIB_VALUE_MISMATCH */
"double values are different", /* 2 GRIB_DOUBLE_VALUE_MISMATCH */
"long values are different", /* 3 GRIB_LONG_VALUE_MISMATCH */
@ -103,7 +106,9 @@ void grib_check(const char* call,const char* file,int line,int e,const char* ms
}
}
void grib_fail(const char* expr,const char* file,int line) {
void grib_fail(const char* expr,const char* file,int line,int silent) {
if (!silent)
fprintf(stderr,"%s at line %d: assertion failure Assert(%s)\n",file,line,expr);
abort();
}

View File

@ -26,6 +26,8 @@
IMPLEMENTS = compile
IMPLEMENTS = add_dependency
MEMBERS = char *name
MEMBERS = long start
MEMBERS = size_t length
END_CLASS_DEF
*/
@ -61,6 +63,8 @@ typedef struct grib_expression_accessor{
grib_expression base;
/* Members defined in accessor */
char *name;
long start;
size_t length;
} grib_expression_accessor;
@ -113,10 +117,22 @@ static int evaluate_double(grib_expression *g,grib_handle *h,double* result)
static string evaluate_string(grib_expression* g,grib_handle* h,char* buf,size_t* size,int* err)
{
grib_expression_accessor* e = (grib_expression_accessor*)g;
char mybuf[1024]={0,};
long start=e->start;
Assert(buf);
if((*err=grib_get_string_internal(h,e->name,buf,size)) != GRIB_SUCCESS)
if((*err=grib_get_string_internal(h,e->name,mybuf,size)) != GRIB_SUCCESS)
return NULL;
if (e->start<0) start+=*size;
if (e->length != 0) {
memcpy(buf,mybuf+start,e->length);
buf[e->length]=0;
} else {
memcpy(buf,mybuf,*size);
buf[*size]=0;
}
return buf;
}
@ -155,11 +171,13 @@ static void add_dependency(grib_expression* g, grib_accessor* observer){
grib_dependency_add(observer,observed);
}
grib_expression* new_accessor_expression(grib_context* c,const char *name)
grib_expression* new_accessor_expression(grib_context* c,const char *name,long start, size_t length)
{
grib_expression_accessor* e = grib_context_malloc_clear_persistent(c,sizeof(grib_expression_accessor));
e->base.cclass = grib_expression_class_accessor;
e->name = grib_context_strdup_persistent(c,name);
e->start = start;
e->length = length;
return (grib_expression*)e;
}

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl
@ -107,7 +107,7 @@ static grib_trie* load_dictionary(grib_context* c,grib_expression* e, int* err)
*err=GRIB_SUCCESS;
filename=grib_context_full_path(c,self->dictionary);
filename=grib_context_full_defs_path(c,self->dictionary);
if (!filename) {
grib_context_log(c,GRIB_LOG_ERROR,"unable to find def file %s",self->dictionary);
*err=GRIB_FILE_NOT_FOUND;

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl
@ -106,7 +106,7 @@ static grib_trie* load_list(grib_context* c,grib_expression* e, int* err) {
*err=GRIB_SUCCESS;
filename=grib_context_full_path(c,self->list);
filename=grib_context_full_defs_path(c,self->list);
if (!filename) {
grib_context_log(c,GRIB_LOG_ERROR,"unable to find def file %s",self->list);
*err=GRIB_FILE_NOT_FOUND;

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
/*
This is used by make_class.pl
@ -116,7 +116,7 @@ grib_expression* new_sub_string_expression(grib_context* c,const char* value,siz
char v[1024]={0,};
grib_expression_sub_string* e = grib_context_malloc_clear_persistent(c,sizeof(grib_expression_sub_string));
if (start<0) start+=strlen(value);
/* if (start<0) start+=strlen(value); */
memcpy(v,value+start,length);
e->base.cclass = grib_expression_class_sub_string;

View File

@ -205,11 +205,14 @@ grib_file* grib_file_open(const char* filename, const char* mode,int* err)
}
if (!file->handle) {
/*printf("-- opening file %s %s\n",file->name,mode);*/
if (!is_new && *mode == 'w')
file->handle = fopen(file->name,"a");
else
file->handle = fopen(file->name,mode);
/*printf("-- opening file %s %s\n",file->name,mode);*/
if (!is_new && *mode == 'w') {
/* fprintf(stderr,"++++ opening %s as append\n",file->name); */
file->handle = fopen(file->name,"a");
} else {
file->handle = fopen(file->name,mode);
/* fprintf(stderr,"++++ opening %s as mode\n",file->name); */
}
file->mode=strdup(mode);
if (!file->handle) {
@ -239,6 +242,51 @@ grib_file* grib_file_open(const char* filename, const char* mode,int* err)
return file;
}
void grib_file_pool_delete_file(grib_file* file) {
grib_file* prev=NULL;
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex1);
if (file==file_pool.first) {
file_pool.first=file->next;
file_pool.current=file->next;
} else {
prev=file_pool.first;
file_pool.current=file_pool.first;
while (prev) {
if (prev->next==file) break;
prev=prev->next;
}
prev->next=file->next;
}
if (file->handle) {
file_pool.number_of_opened_files--;
}
grib_file_delete(file);
GRIB_MUTEX_UNLOCK(&mutex1);
}
void grib_file_close_force(const char* filename,int* err)
{
grib_file* file=NULL;
/* fprintf(stderr,"++++ closing file %s\n",filename); */
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex1);
file=grib_get_file(filename,err);
fclose(file->handle);
if (file->buffer) {
free(file->buffer);
file->buffer=0;
}
file->handle=NULL;
file_pool.number_of_opened_files--;
GRIB_MUTEX_UNLOCK(&mutex1);
}
void grib_file_close(const char* filename,int* err)
{
grib_file* file=NULL;

View File

@ -8,7 +8,7 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
grib_hash_array_value* grib_integer_hash_array_value_new(grib_context* c, const char* name,grib_iarray* array)

View File

@ -16,10 +16,27 @@
#include "grib_api_internal.h"
grib_iarray* grib_iarray_new_from_array(grib_context* c,long* a,size_t size) {
size_t i;
grib_iarray* v;
if (!c) c=grib_context_get_default();
v=grib_iarray_new(c,size,100);
for (i=0;i<size;i++) v->v[i]=a[i];
v->n=size;
v->number_of_pop_front=0;
v->context=c;
return v;
}
grib_iarray* grib_iarray_new(grib_context* c,size_t size,size_t incsize) {
grib_iarray* v=NULL;
if (!c) c=grib_context_get_default();
v=(grib_iarray*)grib_context_malloc(c,sizeof(grib_iarray));
v->context=c;
if (!v) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_iarray_new unable to allocate %d bytes\n",sizeof(grib_iarray));
@ -29,6 +46,7 @@ grib_iarray* grib_iarray_new(grib_context* c,size_t size,size_t incsize) {
v->n=0;
v->incsize=incsize;
v->v=(long*)grib_context_malloc(c,sizeof(long)*size);
v->number_of_pop_front=0;
if (!v->v) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_iarray_new unable to allocate %d bytes\n",sizeof(long)*size);
@ -37,36 +55,149 @@ grib_iarray* grib_iarray_new(grib_context* c,size_t size,size_t incsize) {
return v;
}
grib_iarray* grib_iarray_resize(grib_context* c,grib_iarray* v) {
int newsize=v->incsize+v->size;
long grib_iarray_pop(grib_iarray* a) {
a->n-=1;
return a->v[a->n];
}
long grib_iarray_pop_front(grib_iarray* a) {
long v=a->v[0];
/* size_t i=0; */
if (a->n==0) Assert(0);
a->n--;
a->v++;
a->number_of_pop_front++;
/* for (i=0;i<a->n;i++) a->v[i]=a->v[i+1]; */
return v;
}
grib_iarray* grib_iarray_resize_to(grib_iarray* v,size_t newsize) {
long* newv;
size_t i;
grib_context* c=v->context;
if (newsize<v->size) return v;
if (!c) c=grib_context_get_default();
v->v=grib_context_realloc(c,v->v,newsize*sizeof(long));
v->size=newsize;
if (!v->v) {
newv=grib_context_malloc_clear(c,newsize*sizeof(long));
if (!newv) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_iarray_resize unable to allocate %d bytes\n",sizeof(long)*newsize);
return NULL;
}
for (i=0;i<v->n;i++) newv[i]=v->v[i];
v->v-=v->number_of_pop_front;
grib_context_free(c,v->v);
v->v=newv;
v->size=newsize;
v->number_of_pop_front=0;
return v;
}
grib_iarray* grib_iarray_push(grib_context* c,grib_iarray* v,long val) {
grib_iarray* grib_iarray_resize(grib_iarray* v) {
int newsize=v->incsize+v->size;
return grib_iarray_resize_to(v,newsize);
}
grib_iarray* grib_iarray_push(grib_iarray* v,long val) {
size_t start_size=100;
size_t start_incsize=100;
if (!v) v=grib_iarray_new(c,start_size,start_incsize);
if (v->n >= v->size) v=grib_iarray_resize(c,v);
if (!v) v=grib_iarray_new(0,start_size,start_incsize);
if (v->n >= v->size-v->number_of_pop_front)
v=grib_iarray_resize(v);
v->v[v->n]=val;
v->n++;
return v;
}
void grib_iarray_delete(grib_context* c,grib_iarray* v) {
grib_iarray* grib_iarray_push_front(grib_iarray* v,long val) {
size_t start_size=100;
size_t start_incsize=100;
int i;
if (!v) v=grib_iarray_new(0,start_size,start_incsize);
if (v->number_of_pop_front) {
v->v--;
v->number_of_pop_front--;
} else {
if (v->n >= v->size) v=grib_iarray_resize(v);
for (i=v->n;i>0;i--) v[i]=v[i-1];
}
v->v[0]=val;
v->n++;
return v;
}
grib_iarray* grib_iarray_push_array(grib_iarray* v,long *val,size_t size) {
size_t start_size=size;
size_t start_incsize=100;
long* vp=0;
long* valp=val;
if (!v) v=grib_iarray_new(0,start_size,start_incsize);
v=grib_iarray_resize_to(v,size+v->n);
vp=v->v+v->n+v->number_of_pop_front;
v->n+=size;
while (size) {
*(vp++)=*(valp++);
size--;
}
return v;
}
long grib_iarray_get(grib_iarray* a,size_t i) {
return a->v[i];
}
void grib_iarray_set(grib_iarray* a,size_t i,long v) {
a->v[i]=v;
}
void grib_iarray_delete(grib_iarray* v) {
grib_context* c;
if (!v) return;
if (!c) grib_context_get_default();
if (v->v) grib_context_free(c,v->v);
c=v->context;
grib_iarray_delete_array(v);
grib_context_free(c,v);
}
void grib_iarray_delete_array(grib_iarray* v) {
grib_context* c;
if (!v) return;
c=v->context;
if (v->v) {
long* vv = v->v - v->number_of_pop_front;
grib_context_free(c,vv);
}
}
long* grib_iarray_get_array(grib_iarray* v) {
long* vv;
size_t i;
grib_context* c=grib_context_get_default();
vv=grib_context_malloc_clear(c,sizeof(long)*v->n);
for (i=0;i<v->n;i++) vv[i]=v->v[i];
return vv;
}
size_t grib_iarray_get_used_size(grib_iarray* v) {return v->n;}

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@
grib_action* grib_parser_all_actions = 0;
grib_context* grib_parser_context = 0;
grib_concept_value* grib_parser_concept = 0;
grib_hash_array_value* grib_parser_hash_array = 0;
grib_rule* grib_parser_rules = 0;
extern FILE* grib_yyin;
@ -30,6 +31,7 @@ static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex_file = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex_rules = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex_concept = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex_hash_array = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex_stream = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex_parse = PTHREAD_MUTEX_INITIALIZER;
@ -41,6 +43,7 @@ static void init()
pthread_mutex_init(&mutex_file,&attr);
pthread_mutex_init(&mutex_rules,&attr);
pthread_mutex_init(&mutex_concept,&attr);
pthread_mutex_init(&mutex_hash_array,&attr);
pthread_mutex_init(&mutex_stream,&attr);
pthread_mutex_init(&mutex_parse,&attr);
pthread_mutexattr_destroy(&attr);
@ -157,7 +160,7 @@ int grib_recompose_print(grib_handle* h, grib_accessor *observer, const char* un
char double_format[]="%g"; /* default format for printing double keys */
char long_format[]="%ld"; /* default format for printing integer keys */
char buff[10]={0,};
char sbuf[200]={0,};
char sbuf[1024]={0,};
char buff1[1024]={0,};
char* format=NULL;
int type=-1;
@ -217,7 +220,7 @@ int grib_recompose_print(grib_handle* h, grib_accessor *observer, const char* un
if (type==-1) type=grib_accessor_get_native_type(a);
switch (type) {
case GRIB_TYPE_STRING:
replen=200;
replen=sizeof(sbuf)/sizeof(*sbuf);;
ret = grib_get_string_internal(a->parent->h,a->name,sbuf,&replen);
fprintf(out,"%s",sbuf);
break;
@ -435,6 +438,7 @@ void grib_parser_include(const char* fname)
parse_file = path;
}
grib_context_log(grib_parser_context,GRIB_LOG_DEBUG,"parsing include file %s",parse_file);
f = fopen(parse_file,"r");
/* for(i = 0; i < top ; i++) printf(" "); */
/* printf("PARSING %s\n",parse_file); */
@ -545,6 +549,23 @@ grib_concept_value* grib_parse_concept_file( grib_context* gc,const char* filena
}
}
grib_hash_array_value* grib_parse_hash_array_file( grib_context* gc,const char* filename)
{
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex_hash_array);
gc = gc ? gc : grib_context_get_default();
grib_parser_context = gc;
if(parse(gc,filename) == 0) {
GRIB_MUTEX_UNLOCK(&mutex_hash_array);
return grib_parser_hash_array;
} else {
GRIB_MUTEX_UNLOCK(&mutex_hash_array);
return NULL;
}
}
grib_rule* grib_parse_rules_file( grib_context* gc,const char* filename)
{
if (!gc) gc=grib_context_get_default();

View File

@ -14,7 +14,7 @@
*
***************************************************************************/
#include "ecCodes_internal.h"
#include "grib_api_internal.h"
grib_sarray* grib_sarray_new(grib_context* c,size_t size,size_t incsize) {
grib_sarray* v=NULL;

File diff suppressed because it is too large Load Diff

View File

@ -44,92 +44,110 @@
IF_TRANSIENT = 260,
ELSE = 261,
END = 262,
UNSIGNED = 263,
TEMPLATE = 264,
TEMPLATE_NOFAIL = 265,
TRIGGER = 266,
ASCII = 267,
KSEC1EXPVER = 268,
LABEL = 269,
LIST = 270,
WHILE = 271,
IBMFLOAT = 272,
SIGNED = 273,
BYTE = 274,
CODETABLE = 275,
COMPLEX_CODETABLE = 276,
LOOKUP = 277,
ALIAS = 278,
UNALIAS = 279,
META = 280,
POS = 281,
INTCONST = 282,
TRANS = 283,
FLAGBIT = 284,
CONCEPT = 285,
GETENV = 286,
CONCEPT_NOFAIL = 287,
NIL = 288,
DUMMY = 289,
MODIFY = 290,
READ_ONLY = 291,
STRING_TYPE = 292,
LONG_TYPE = 293,
DOUBLE_TYPE = 294,
NO_COPY = 295,
DUMP = 296,
NO_FAIL = 297,
EDITION_SPECIFIC = 298,
OVERRIDE = 299,
HIDDEN = 300,
CAN_BE_MISSING = 301,
MISSING = 302,
CONSTRAINT = 303,
COPY_OK = 304,
WHEN = 305,
SET = 306,
SET_NOFAIL = 307,
WRITE = 308,
APPEND = 309,
PRINT = 310,
EXPORT = 311,
REMOVE = 312,
SKIP = 313,
PAD = 314,
SECTION_PADDING = 315,
MESSAGE = 316,
PADTO = 317,
PADTOEVEN = 318,
PADTOMULTIPLE = 319,
G1_HALF_BYTE = 320,
G1_MESSAGE_LENGTH = 321,
G1_SECTION4_LENGTH = 322,
SECTION_LENGTH = 323,
FLAG = 324,
ITERATOR = 325,
NEAREST = 326,
BOX = 327,
KSEC = 328,
ASSERT = 329,
CASE = 330,
SWITCH = 331,
DEFAULT = 332,
EQ = 333,
NE = 334,
GE = 335,
LE = 336,
LT = 337,
GT = 338,
BIT = 339,
BITOFF = 340,
AND = 341,
OR = 342,
NOT = 343,
IS = 344,
IDENT = 345,
STRING = 346,
INTEGER = 347,
FLOAT = 348
CLOSE = 263,
UNSIGNED = 264,
TEMPLATE = 265,
TEMPLATE_NOFAIL = 266,
TRIGGER = 267,
ASCII = 268,
GROUP = 269,
NON_ALPHA = 270,
KSEC1EXPVER = 271,
LABEL = 272,
LIST = 273,
IS_IN_LIST = 274,
IS_IN_DICT = 275,
IS_INTEGER = 276,
TO_INTEGER = 277,
TO_STRING = 278,
SEX2DEC = 279,
WHILE = 280,
IBMFLOAT = 281,
SIGNED = 282,
BYTE = 283,
CODETABLE = 284,
SMART_TABLE = 285,
DICTIONARY = 286,
COMPLEX_CODETABLE = 287,
LOOKUP = 288,
ALIAS = 289,
UNALIAS = 290,
META = 291,
POS = 292,
INTCONST = 293,
TRANS = 294,
FLAGBIT = 295,
CONCEPT = 296,
GETENV = 297,
HASH_ARRAY = 298,
CONCEPT_NOFAIL = 299,
NIL = 300,
DUMMY = 301,
MODIFY = 302,
READ_ONLY = 303,
STRING_TYPE = 304,
LONG_TYPE = 305,
DOUBLE_TYPE = 306,
NO_COPY = 307,
DUMP = 308,
JSON = 309,
XML = 310,
NO_FAIL = 311,
EDITION_SPECIFIC = 312,
OVERRIDE = 313,
HIDDEN = 314,
CAN_BE_MISSING = 315,
MISSING = 316,
CONSTRAINT = 317,
COPY_OK = 318,
WHEN = 319,
SET = 320,
SET_NOFAIL = 321,
WRITE = 322,
APPEND = 323,
PRINT = 324,
EXPORT = 325,
REMOVE = 326,
RENAME = 327,
SKIP = 328,
PAD = 329,
SECTION_PADDING = 330,
MESSAGE = 331,
MESSAGE_COPY = 332,
PADTO = 333,
PADTOEVEN = 334,
PADTOMULTIPLE = 335,
G1_HALF_BYTE = 336,
G1_MESSAGE_LENGTH = 337,
G1_SECTION4_LENGTH = 338,
SECTION_LENGTH = 339,
LENGTH = 340,
FLAG = 341,
ITERATOR = 342,
NEAREST = 343,
BOX = 344,
KSEC = 345,
ASSERT = 346,
SUBSTR = 347,
CASE = 348,
SWITCH = 349,
DEFAULT = 350,
EQ = 351,
NE = 352,
GE = 353,
LE = 354,
LT = 355,
GT = 356,
BIT = 357,
BITOFF = 358,
AND = 359,
OR = 360,
NOT = 361,
IS = 362,
IDENT = 363,
STRING = 364,
INTEGER = 365,
FLOAT = 366
};
#endif
/* Tokens. */
@ -138,92 +156,110 @@
#define IF_TRANSIENT 260
#define ELSE 261
#define END 262
#define UNSIGNED 263
#define TEMPLATE 264
#define TEMPLATE_NOFAIL 265
#define TRIGGER 266
#define ASCII 267
#define KSEC1EXPVER 268
#define LABEL 269
#define LIST 270
#define WHILE 271
#define IBMFLOAT 272
#define SIGNED 273
#define BYTE 274
#define CODETABLE 275
#define COMPLEX_CODETABLE 276
#define LOOKUP 277
#define ALIAS 278
#define UNALIAS 279
#define META 280
#define POS 281
#define INTCONST 282
#define TRANS 283
#define FLAGBIT 284
#define CONCEPT 285
#define GETENV 286
#define CONCEPT_NOFAIL 287
#define NIL 288
#define DUMMY 289
#define MODIFY 290
#define READ_ONLY 291
#define STRING_TYPE 292
#define LONG_TYPE 293
#define DOUBLE_TYPE 294
#define NO_COPY 295
#define DUMP 296
#define NO_FAIL 297
#define EDITION_SPECIFIC 298
#define OVERRIDE 299
#define HIDDEN 300
#define CAN_BE_MISSING 301
#define MISSING 302
#define CONSTRAINT 303
#define COPY_OK 304
#define WHEN 305
#define SET 306
#define SET_NOFAIL 307
#define WRITE 308
#define APPEND 309
#define PRINT 310
#define EXPORT 311
#define REMOVE 312
#define SKIP 313
#define PAD 314
#define SECTION_PADDING 315
#define MESSAGE 316
#define PADTO 317
#define PADTOEVEN 318
#define PADTOMULTIPLE 319
#define G1_HALF_BYTE 320
#define G1_MESSAGE_LENGTH 321
#define G1_SECTION4_LENGTH 322
#define SECTION_LENGTH 323
#define FLAG 324
#define ITERATOR 325
#define NEAREST 326
#define BOX 327
#define KSEC 328
#define ASSERT 329
#define CASE 330
#define SWITCH 331
#define DEFAULT 332
#define EQ 333
#define NE 334
#define GE 335
#define LE 336
#define LT 337
#define GT 338
#define BIT 339
#define BITOFF 340
#define AND 341
#define OR 342
#define NOT 343
#define IS 344
#define IDENT 345
#define STRING 346
#define INTEGER 347
#define FLOAT 348
#define CLOSE 263
#define UNSIGNED 264
#define TEMPLATE 265
#define TEMPLATE_NOFAIL 266
#define TRIGGER 267
#define ASCII 268
#define GROUP 269
#define NON_ALPHA 270
#define KSEC1EXPVER 271
#define LABEL 272
#define LIST 273
#define IS_IN_LIST 274
#define IS_IN_DICT 275
#define IS_INTEGER 276
#define TO_INTEGER 277
#define TO_STRING 278
#define SEX2DEC 279
#define WHILE 280
#define IBMFLOAT 281
#define SIGNED 282
#define BYTE 283
#define CODETABLE 284
#define SMART_TABLE 285
#define DICTIONARY 286
#define COMPLEX_CODETABLE 287
#define LOOKUP 288
#define ALIAS 289
#define UNALIAS 290
#define META 291
#define POS 292
#define INTCONST 293
#define TRANS 294
#define FLAGBIT 295
#define CONCEPT 296
#define GETENV 297
#define HASH_ARRAY 298
#define CONCEPT_NOFAIL 299
#define NIL 300
#define DUMMY 301
#define MODIFY 302
#define READ_ONLY 303
#define STRING_TYPE 304
#define LONG_TYPE 305
#define DOUBLE_TYPE 306
#define NO_COPY 307
#define DUMP 308
#define JSON 309
#define XML 310
#define NO_FAIL 311
#define EDITION_SPECIFIC 312
#define OVERRIDE 313
#define HIDDEN 314
#define CAN_BE_MISSING 315
#define MISSING 316
#define CONSTRAINT 317
#define COPY_OK 318
#define WHEN 319
#define SET 320
#define SET_NOFAIL 321
#define WRITE 322
#define APPEND 323
#define PRINT 324
#define EXPORT 325
#define REMOVE 326
#define RENAME 327
#define SKIP 328
#define PAD 329
#define SECTION_PADDING 330
#define MESSAGE 331
#define MESSAGE_COPY 332
#define PADTO 333
#define PADTOEVEN 334
#define PADTOMULTIPLE 335
#define G1_HALF_BYTE 336
#define G1_MESSAGE_LENGTH 337
#define G1_SECTION4_LENGTH 338
#define SECTION_LENGTH 339
#define LENGTH 340
#define FLAG 341
#define ITERATOR 342
#define NEAREST 343
#define BOX 344
#define KSEC 345
#define ASSERT 346
#define SUBSTR 347
#define CASE 348
#define SWITCH 349
#define DEFAULT 350
#define EQ 351
#define NE 352
#define GE 353
#define LE 354
#define LT 355
#define GT 356
#define BIT 357
#define BITOFF 358
#define AND 359
#define OR 360
#define NOT 361
#define IS 362
#define IDENT 363
#define STRING 364
#define INTEGER 365
#define FLOAT 366
@ -233,7 +269,7 @@ typedef union YYSTYPE
{
/* Line 1676 of yacc.c */
#line 34 "griby.y"
#line 37 "griby.y"
char *str;
long lval;
@ -245,6 +281,7 @@ typedef union YYSTYPE
grib_expression *exp;
grib_concept_condition *concept_condition;
grib_concept_value *concept_value;
grib_hash_array_value *hash_array_value;
grib_case *case_value;
grib_rule *rules;
grib_rule_entry *rule_entry;
@ -252,7 +289,7 @@ typedef union YYSTYPE
/* Line 1676 of yacc.c */
#line 256 "y.tab.h"
#line 293 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define grib_yystype YYSTYPE /* obsolescent; will be withdrawn */

Some files were not shown because too many files have changed in this diff Show More