This commit is contained in:
Dennis Heimbigner 2011-04-17 18:50:10 +00:00
parent 66e9bd3f4f
commit c04d65e1d3
29 changed files with 3455 additions and 6573 deletions

View File

@ -85,10 +85,11 @@ endif
if BUILD_DAP
OCLIB=oc
NCDAP3=libncdap3
NCDAP4=libncdap4
DAP2=libdap2
if BUILD_UTILITIES
NCDAPTESTDIR=ncdap_test
endif # BUILD_UTILITIES
NCDAP4=libncdap4
endif
# Build UDUNITS?
@ -115,13 +116,13 @@ endif
# If using dispatch, then the order is different
if BUILD_SEPARATE_FORTRAN
SUBDIRS = include $(UDUNITS) $(H5_TEST_DIR) $(DISPATCHDIR) $(OCLIB) \
$(LIBSRC_DIR) $(LIBSRC4_DIR) $(NCDAP3) $(NCDAP4) $(LIBCDMR) \
$(LIBSRC_DIR) $(LIBSRC4_DIR) $(DAP2) $(LIBCDMR) \
${ASSEMBLEDIR} $(V2_TEST) $(NC_TEST_DIR) $(F90_DIR) $(F77_DIR) \
$(NCGEN3) $(NCGEN) $(NCDUMP) $(F77_TEST) ${CXX_DIR} $(CXX4) \
$(NC_TEST4) $(NCDAPTESTDIR) man4 $(EXAMPLES) $(LIBCF)
else
SUBDIRS = include $(UDUNITS) $(H5_TEST_DIR) $(DISPATCHDIR) $(OCLIB) \
$(F90_DIR) $(F77_DIR) $(LIBSRC_DIR) $(LIBSRC4_DIR) $(NCDAP3) $(NCDAP4) \
$(F90_DIR) $(F77_DIR) $(LIBSRC_DIR) $(LIBSRC4_DIR) $(DAP2) \
$(LIBCDMR) ${ASSEMBLEDIR} $(V2_TEST) $(NCGEN3) $(NCGEN) $(NCDUMP) \
$(F77_TEST) ${CXX_DIR} $(CXX4) $(NC_TEST4) $(NC_TEST_DIR) \
$(NCDAPTESTDIR) man4 $(EXAMPLES) $(LIBCF)

View File

@ -3,6 +3,12 @@ Entries are in reverse chronological order (most recent first).
VERSION COMMENTS
------- --------
4.X 2011-04-17
Merged libncdap3 and libncdap4 into new libdap2 library.
The suffix dap2 now refers to the dap protocol. This is
in prep for adding dap4 protocol support.
4.1.2-rc1 2011-03-17
Changes in build system to support building dlls on

View File

@ -1515,8 +1515,7 @@ AC_CONFIG_FILES([Makefile
examples/F90/Makefile
examples/F77/Makefile
oc/Makefile
libncdap3/Makefile
libncdap4/Makefile
libdap2/Makefile
libcdmr/Makefile
libdispatch/Makefile
liblib/Makefile

View File

@ -12,5 +12,4 @@ endif
noinst_HEADERS = nc_logging.h nc_tests.h fbits.h nc3dispatch.h nc.h \
ncio.h nclist.h nc_url.h utf8proc.h ncdispatch.h ncdimscale.h \
netcdf_f.h err_macros.h ncbytes.h nchashmap.h
netcdf_f.h err_macros.h ncbytes.h nchashmap.h ceconstraints.h

View File

@ -4,8 +4,8 @@
*********************************************************************/
/* $Header$ */
#ifndef NCCONSTRAINTS_H
#define NCCONSTRAINTS_H 1
#ifndef CECONSTRAINTS_H
#define CECONSTRAINTS_H
#ifndef NC_MAX_VAR_DIMS
#define NC_MAX_VAR_DIMS 1024
@ -27,4 +27,5 @@ CES_SEGMENT=16, CES_CONSTRAINT=17,
CES_VALUE=18, CES_SLICE=19
} CEsort;
#endif /*NCCONSTRAINTS_H*/
#endif /*CECONSTRAINTS_H*/

View File

@ -7,6 +7,7 @@
DISTCLEANFILES =
CLEANFILES =
EXTRA_DIST =
LDADD=
AM_CPPFLAGS = -I$(top_srcdir)/include
AM_LDFLAGS =
@ -18,7 +19,10 @@ nccrdump.c \
ncStreamx.c curlwrap.c ncaux.c \
ast_byteio.c ast_curl.c ast_internal.c \
ast_runtime.c ast_util.c ast_debug.c \
crce.c
crce.c \
cceparse.c cceconstraints.c
EXTRA_DIST += ccetab.c ccelex.c
HDRS=nccrdispatch.h nccr.h nccrmeta.h nccrproto.h \
crdebug.h crutil.h \
@ -26,7 +30,8 @@ nccrdump.h \
ncStreamx.h curlwrap.h ncaux.h \
ast.h ast_byteio.h ast_curl.h ast_internal.h \
ast_runtime.h ast_util.h ast_debug.h \
crce.h nccrnode.h
crce.h nccrnode.h \
ccetab.h cceconstraints.h cceparselex.h
if BUILD_CDMREMOTE
@ -62,7 +67,7 @@ CLEANFILES += t_cdmr
##################################################
# Generate the augmented ncstream structures
EXTRA_DIST=ncStream.proto ncStream.h ncStreamc
EXTRA_DIST+=ncStream.proto ncStream.h ncStreamc
ASTDIR=./ast/src/compiler
@ -74,10 +79,23 @@ ncStreamx.c ncStreamx.h: ncStreamx.proto ${ASTJAR}
ncStreamx.proto: ncStream.proto extends.sed
sed -f extends.sed <ncStream.proto |tr -d '\r' >ncStreamx.proto
.PHONEY: jar
.PHONEY: jar bison
${ASTJAR}:
cd ${ASTDIR}; make -f Make0 jar
# These rule are used if someone wants to rebuild the grammar files.
# Otherwise never invoked, but records how to do it.
# BTW: note that renaming is essential because otherwise
# autoconf will forcibly delete files of the name *.tab.*
EXTRA_DIST += cce.y
bison ccetab.c ccetab.h: cce.y
bison -v -d -t -p cce cce.y
rm -f ccetab.c ccetab.h
mv cce.tab.c ccetab.c
mv cce.tab.h ccetab.h
endif # BUILD_CDMREMOTE

View File

@ -44,7 +44,7 @@ CLASSES=${SRC:%.java=${BUILDDIR}/${ASTPATH}/%.class}\
.PHONEY: compiler gen jar
all: jar gen c
all: jar
gen:
for t in ${TESTS} ; do java ${D} -jar ${JAR} ${W} $${t} ; done

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,408 +0,0 @@
#ifndef foo_H
#define foo_H
typedef enum TestEnumSmall {
VALUE=0,
OTHER_VALUE=1
} TestEnumSmall;
typedef enum TestEnum {
VALUE0=0,
VALUE1=1,
VALUE127=127,
VALUE128=128,
VALUE16383=16383,
VALUE16384=16384,
VALUE2097151=2097151,
VALUE2097152=2097152,
VALUE268435455=268435455,
VALUE268435456=268435456
} TestEnum;
typedef enum TestEnumDupValues {
VALUE_A=42,
VALUE_B=42,
VALUE_C=42,
VALUE_D=666,
VALUE_E=666,
VALUE_F=1000,
VALUE_AA=1000,
VALUE_BB=1001
} TestEnumDupValues;
typedef struct SubMess {
int test_f;
} SubMess;
extern int SubMess_write(ast_runtime*,SubMess*);
extern int SubMess_read(ast_runtime*,SubMess**);
extern int SubMess_reclaim(ast_runtime*,SubMess*);
extern long SubMess_size(ast_runtime*,SubMess*);
typedef struct TestFieldNo15 {
char* test_f;
} TestFieldNo15;
extern int TestFieldNo15_write(ast_runtime*,TestFieldNo15*);
extern int TestFieldNo15_read(ast_runtime*,TestFieldNo15**);
extern int TestFieldNo15_reclaim(ast_runtime*,TestFieldNo15*);
extern long TestFieldNo15_size(ast_runtime*,TestFieldNo15*);
typedef struct TestFieldNo16 {
char* test_f;
} TestFieldNo16;
extern int TestFieldNo16_write(ast_runtime*,TestFieldNo16*);
extern int TestFieldNo16_read(ast_runtime*,TestFieldNo16**);
extern int TestFieldNo16_reclaim(ast_runtime*,TestFieldNo16*);
extern long TestFieldNo16_size(ast_runtime*,TestFieldNo16*);
typedef struct TestFieldNo2047 {
char* test_f;
} TestFieldNo2047;
extern int TestFieldNo2047_write(ast_runtime*,TestFieldNo2047*);
extern int TestFieldNo2047_read(ast_runtime*,TestFieldNo2047**);
extern int TestFieldNo2047_reclaim(ast_runtime*,TestFieldNo2047*);
extern long TestFieldNo2047_size(ast_runtime*,TestFieldNo2047*);
typedef struct TestFieldNo2048 {
char* test_f;
} TestFieldNo2048;
extern int TestFieldNo2048_write(ast_runtime*,TestFieldNo2048*);
extern int TestFieldNo2048_read(ast_runtime*,TestFieldNo2048**);
extern int TestFieldNo2048_reclaim(ast_runtime*,TestFieldNo2048*);
extern long TestFieldNo2048_size(ast_runtime*,TestFieldNo2048*);
typedef struct TestFieldNo262143 {
char* test_f;
} TestFieldNo262143;
extern int TestFieldNo262143_write(ast_runtime*,TestFieldNo262143*);
extern int TestFieldNo262143_read(ast_runtime*,TestFieldNo262143**);
extern int TestFieldNo262143_reclaim(ast_runtime*,TestFieldNo262143*);
extern long TestFieldNo262143_size(ast_runtime*,TestFieldNo262143*);
typedef struct TestFieldNo262144 {
char* test_f;
} TestFieldNo262144;
extern int TestFieldNo262144_write(ast_runtime*,TestFieldNo262144*);
extern int TestFieldNo262144_read(ast_runtime*,TestFieldNo262144**);
extern int TestFieldNo262144_reclaim(ast_runtime*,TestFieldNo262144*);
extern long TestFieldNo262144_size(ast_runtime*,TestFieldNo262144*);
typedef struct TestFieldNo33554431 {
char* test_f;
} TestFieldNo33554431;
extern int TestFieldNo33554431_write(ast_runtime*,TestFieldNo33554431*);
extern int TestFieldNo33554431_read(ast_runtime*,TestFieldNo33554431**);
extern int TestFieldNo33554431_reclaim(ast_runtime*,TestFieldNo33554431*);
extern long TestFieldNo33554431_size(ast_runtime*,TestFieldNo33554431*);
typedef struct TestFieldNo33554432 {
char* test_f;
} TestFieldNo33554432;
extern int TestFieldNo33554432_write(ast_runtime*,TestFieldNo33554432*);
extern int TestFieldNo33554432_read(ast_runtime*,TestFieldNo33554432**);
extern int TestFieldNo33554432_reclaim(ast_runtime*,TestFieldNo33554432*);
extern long TestFieldNo33554432_size(ast_runtime*,TestFieldNo33554432*);
typedef struct TestMess {
struct {int count; int* values;} test_int32_f;
struct {int count; int* values;} test_sint32_f;
struct {int count; int* values;} test_sfixed32_f;
struct {int count; longlong* values;} test_int64_f;
struct {int count; longlong* values;} test_sint64_f;
struct {int count; longlong* values;} test_sfixed64_f;
struct {int count; int* values;} test_uint32_f;
struct {int count; int* values;} test_fixed32_f;
struct {int count; longlong* values;} test_uint64_f;
struct {int count; longlong* values;} test_fixed64_f;
struct {int count; float* values;} test_float_f;
struct {int count; double* values;} test_double_f;
struct {int count; int* values;} test_boolean_f;
struct {int count; TestEnumSmall** values;} test_enum_small_f;
struct {int count; TestEnum** values;} test_enum_f;
struct {int count; char** values;} test_string_f;
struct {int count; Bytestring* values;} test_bytes_f;
struct {int count; SubMess** values;} test_message_f;
} TestMess;
extern int TestMess_write(ast_runtime*,TestMess*);
extern int TestMess_read(ast_runtime*,TestMess**);
extern int TestMess_reclaim(ast_runtime*,TestMess*);
extern long TestMess_size(ast_runtime*,TestMess*);
typedef struct TestMessPacked {
struct {int count; int* values;} test_int32_f;
struct {int count; int* values;} test_sint32_f;
struct {int count; int* values;} test_sfixed32_f;
struct {int count; longlong* values;} test_int64_f;
struct {int count; longlong* values;} test_sint64_f;
struct {int count; longlong* values;} test_sfixed64_f;
struct {int count; int* values;} test_uint32_f;
struct {int count; int* values;} test_fixed32_f;
struct {int count; longlong* values;} test_uint64_f;
struct {int count; longlong* values;} test_fixed64_f;
struct {int count; float* values;} test_float_f;
struct {int count; double* values;} test_double_f;
struct {int count; int* values;} test_boolean_f;
struct {int count; TestEnumSmall** values;} test_enum_small_f;
struct {int count; TestEnum** values;} test_enum_f;
} TestMessPacked;
extern int TestMessPacked_write(ast_runtime*,TestMessPacked*);
extern int TestMessPacked_read(ast_runtime*,TestMessPacked**);
extern int TestMessPacked_reclaim(ast_runtime*,TestMessPacked*);
extern long TestMessPacked_size(ast_runtime*,TestMessPacked*);
typedef struct TestMessOptional {
struct {int exists; int value;} test_int32_f;
struct {int exists; int value;} test_sint32_f;
struct {int exists; int value;} test_sfixed32_f;
struct {int exists; longlong value;} test_int64_f;
struct {int exists; longlong value;} test_sint64_f;
struct {int exists; longlong value;} test_sfixed64_f;
struct {int exists; int value;} test_uint32_f;
struct {int exists; int value;} test_fixed32_f;
struct {int exists; longlong value;} test_uint64_f;
struct {int exists; longlong value;} test_fixed64_f;
struct {int exists; float value;} test_float_f;
struct {int exists; double value;} test_double_f;
struct {int exists; int value;} test_boolean_f;
struct {int exists; TestEnumSmall* value;} test_enum_small_f;
struct {int exists; TestEnum* value;} test_enum_f;
struct {int exists; char* value;} test_string_f;
struct {int exists; Bytestring value;} test_bytes_f;
struct {int exists; SubMess* value;} test_message_f;
} TestMessOptional;
extern int TestMessOptional_write(ast_runtime*,TestMessOptional*);
extern int TestMessOptional_read(ast_runtime*,TestMessOptional**);
extern int TestMessOptional_reclaim(ast_runtime*,TestMessOptional*);
extern long TestMessOptional_size(ast_runtime*,TestMessOptional*);
typedef struct TestMessRequiredInt32 {
int test_f;
} TestMessRequiredInt32;
extern int TestMessRequiredInt32_write(ast_runtime*,TestMessRequiredInt32*);
extern int TestMessRequiredInt32_read(ast_runtime*,TestMessRequiredInt32**);
extern int TestMessRequiredInt32_reclaim(ast_runtime*,TestMessRequiredInt32*);
extern long TestMessRequiredInt32_size(ast_runtime*,TestMessRequiredInt32*);
typedef struct TestMessRequiredSInt32 {
int test_f;
} TestMessRequiredSInt32;
extern int TestMessRequiredSInt32_write(ast_runtime*,TestMessRequiredSInt32*);
extern int TestMessRequiredSInt32_read(ast_runtime*,TestMessRequiredSInt32**);
extern int TestMessRequiredSInt32_reclaim(ast_runtime*,TestMessRequiredSInt32*);
extern long TestMessRequiredSInt32_size(ast_runtime*,TestMessRequiredSInt32*);
typedef struct TestMessRequiredSFixed32 {
int test_f;
} TestMessRequiredSFixed32;
extern int TestMessRequiredSFixed32_write(ast_runtime*,TestMessRequiredSFixed32*);
extern int TestMessRequiredSFixed32_read(ast_runtime*,TestMessRequiredSFixed32**);
extern int TestMessRequiredSFixed32_reclaim(ast_runtime*,TestMessRequiredSFixed32*);
extern long TestMessRequiredSFixed32_size(ast_runtime*,TestMessRequiredSFixed32*);
typedef struct TestMessRequiredInt64 {
longlong test_f;
} TestMessRequiredInt64;
extern int TestMessRequiredInt64_write(ast_runtime*,TestMessRequiredInt64*);
extern int TestMessRequiredInt64_read(ast_runtime*,TestMessRequiredInt64**);
extern int TestMessRequiredInt64_reclaim(ast_runtime*,TestMessRequiredInt64*);
extern long TestMessRequiredInt64_size(ast_runtime*,TestMessRequiredInt64*);
typedef struct TestMessRequiredSInt64 {
longlong test_f;
} TestMessRequiredSInt64;
extern int TestMessRequiredSInt64_write(ast_runtime*,TestMessRequiredSInt64*);
extern int TestMessRequiredSInt64_read(ast_runtime*,TestMessRequiredSInt64**);
extern int TestMessRequiredSInt64_reclaim(ast_runtime*,TestMessRequiredSInt64*);
extern long TestMessRequiredSInt64_size(ast_runtime*,TestMessRequiredSInt64*);
typedef struct TestMessRequiredSFixed64 {
longlong test_f;
} TestMessRequiredSFixed64;
extern int TestMessRequiredSFixed64_write(ast_runtime*,TestMessRequiredSFixed64*);
extern int TestMessRequiredSFixed64_read(ast_runtime*,TestMessRequiredSFixed64**);
extern int TestMessRequiredSFixed64_reclaim(ast_runtime*,TestMessRequiredSFixed64*);
extern long TestMessRequiredSFixed64_size(ast_runtime*,TestMessRequiredSFixed64*);
typedef struct TestMessRequiredUInt32 {
int test_f;
} TestMessRequiredUInt32;
extern int TestMessRequiredUInt32_write(ast_runtime*,TestMessRequiredUInt32*);
extern int TestMessRequiredUInt32_read(ast_runtime*,TestMessRequiredUInt32**);
extern int TestMessRequiredUInt32_reclaim(ast_runtime*,TestMessRequiredUInt32*);
extern long TestMessRequiredUInt32_size(ast_runtime*,TestMessRequiredUInt32*);
typedef struct TestMessRequiredFixed32 {
int test_f;
} TestMessRequiredFixed32;
extern int TestMessRequiredFixed32_write(ast_runtime*,TestMessRequiredFixed32*);
extern int TestMessRequiredFixed32_read(ast_runtime*,TestMessRequiredFixed32**);
extern int TestMessRequiredFixed32_reclaim(ast_runtime*,TestMessRequiredFixed32*);
extern long TestMessRequiredFixed32_size(ast_runtime*,TestMessRequiredFixed32*);
typedef struct TestMessRequiredUInt64 {
longlong test_f;
} TestMessRequiredUInt64;
extern int TestMessRequiredUInt64_write(ast_runtime*,TestMessRequiredUInt64*);
extern int TestMessRequiredUInt64_read(ast_runtime*,TestMessRequiredUInt64**);
extern int TestMessRequiredUInt64_reclaim(ast_runtime*,TestMessRequiredUInt64*);
extern long TestMessRequiredUInt64_size(ast_runtime*,TestMessRequiredUInt64*);
typedef struct TestMessRequiredFixed64 {
longlong test_f;
} TestMessRequiredFixed64;
extern int TestMessRequiredFixed64_write(ast_runtime*,TestMessRequiredFixed64*);
extern int TestMessRequiredFixed64_read(ast_runtime*,TestMessRequiredFixed64**);
extern int TestMessRequiredFixed64_reclaim(ast_runtime*,TestMessRequiredFixed64*);
extern long TestMessRequiredFixed64_size(ast_runtime*,TestMessRequiredFixed64*);
typedef struct TestMessRequiredFloat {
float test_f;
} TestMessRequiredFloat;
extern int TestMessRequiredFloat_write(ast_runtime*,TestMessRequiredFloat*);
extern int TestMessRequiredFloat_read(ast_runtime*,TestMessRequiredFloat**);
extern int TestMessRequiredFloat_reclaim(ast_runtime*,TestMessRequiredFloat*);
extern long TestMessRequiredFloat_size(ast_runtime*,TestMessRequiredFloat*);
typedef struct TestMessRequiredDouble {
double test_f;
} TestMessRequiredDouble;
extern int TestMessRequiredDouble_write(ast_runtime*,TestMessRequiredDouble*);
extern int TestMessRequiredDouble_read(ast_runtime*,TestMessRequiredDouble**);
extern int TestMessRequiredDouble_reclaim(ast_runtime*,TestMessRequiredDouble*);
extern long TestMessRequiredDouble_size(ast_runtime*,TestMessRequiredDouble*);
typedef struct TestMessRequiredBool {
int test_f;
} TestMessRequiredBool;
extern int TestMessRequiredBool_write(ast_runtime*,TestMessRequiredBool*);
extern int TestMessRequiredBool_read(ast_runtime*,TestMessRequiredBool**);
extern int TestMessRequiredBool_reclaim(ast_runtime*,TestMessRequiredBool*);
extern long TestMessRequiredBool_size(ast_runtime*,TestMessRequiredBool*);
typedef struct TestMessRequiredEnum {
TestEnum* test_f;
} TestMessRequiredEnum;
extern int TestMessRequiredEnum_write(ast_runtime*,TestMessRequiredEnum*);
extern int TestMessRequiredEnum_read(ast_runtime*,TestMessRequiredEnum**);
extern int TestMessRequiredEnum_reclaim(ast_runtime*,TestMessRequiredEnum*);
extern long TestMessRequiredEnum_size(ast_runtime*,TestMessRequiredEnum*);
typedef struct TestMessRequiredEnumSmall {
TestEnumSmall* test_f;
} TestMessRequiredEnumSmall;
extern int TestMessRequiredEnumSmall_write(ast_runtime*,TestMessRequiredEnumSmall*);
extern int TestMessRequiredEnumSmall_read(ast_runtime*,TestMessRequiredEnumSmall**);
extern int TestMessRequiredEnumSmall_reclaim(ast_runtime*,TestMessRequiredEnumSmall*);
extern long TestMessRequiredEnumSmall_size(ast_runtime*,TestMessRequiredEnumSmall*);
typedef struct TestMessRequiredString {
char* test_f;
} TestMessRequiredString;
extern int TestMessRequiredString_write(ast_runtime*,TestMessRequiredString*);
extern int TestMessRequiredString_read(ast_runtime*,TestMessRequiredString**);
extern int TestMessRequiredString_reclaim(ast_runtime*,TestMessRequiredString*);
extern long TestMessRequiredString_size(ast_runtime*,TestMessRequiredString*);
typedef struct TestMessRequiredBytes {
Bytestring test_f;
} TestMessRequiredBytes;
extern int TestMessRequiredBytes_write(ast_runtime*,TestMessRequiredBytes*);
extern int TestMessRequiredBytes_read(ast_runtime*,TestMessRequiredBytes**);
extern int TestMessRequiredBytes_reclaim(ast_runtime*,TestMessRequiredBytes*);
extern long TestMessRequiredBytes_size(ast_runtime*,TestMessRequiredBytes*);
typedef struct TestMessRequiredMessage {
SubMess* test_f;
} TestMessRequiredMessage;
extern int TestMessRequiredMessage_write(ast_runtime*,TestMessRequiredMessage*);
extern int TestMessRequiredMessage_read(ast_runtime*,TestMessRequiredMessage**);
extern int TestMessRequiredMessage_reclaim(ast_runtime*,TestMessRequiredMessage*);
extern long TestMessRequiredMessage_size(ast_runtime*,TestMessRequiredMessage*);
typedef struct EmptyMess {
} EmptyMess;
extern int EmptyMess_write(ast_runtime*,EmptyMess*);
extern int EmptyMess_read(ast_runtime*,EmptyMess**);
extern int EmptyMess_reclaim(ast_runtime*,EmptyMess*);
extern long EmptyMess_size(ast_runtime*,EmptyMess*);
typedef struct DefaultRequiredValues {
int v_int32_f;
int v_uint32_f;
int v_int64_f;
int v_uint64_f;
float v_float_f;
double v_double_f;
char* v_string_f;
Bytestring v_bytes_f;
} DefaultRequiredValues;
extern int DefaultRequiredValues_write(ast_runtime*,DefaultRequiredValues*);
extern int DefaultRequiredValues_read(ast_runtime*,DefaultRequiredValues**);
extern int DefaultRequiredValues_reclaim(ast_runtime*,DefaultRequiredValues*);
extern long DefaultRequiredValues_size(ast_runtime*,DefaultRequiredValues*);
typedef struct DefaultOptionalValues {
struct {int exists; int value;} v_int32_f;
struct {int exists; int value;} v_uint32_f;
struct {int exists; int value;} v_int64_f;
struct {int exists; int value;} v_uint64_f;
struct {int exists; float value;} v_float_f;
struct {int exists; double value;} v_double_f;
struct {int exists; char* value;} v_string_f;
struct {int exists; Bytestring value;} v_bytes_f;
} DefaultOptionalValues;
extern int DefaultOptionalValues_write(ast_runtime*,DefaultOptionalValues*);
extern int DefaultOptionalValues_read(ast_runtime*,DefaultOptionalValues**);
extern int DefaultOptionalValues_reclaim(ast_runtime*,DefaultOptionalValues*);
extern long DefaultOptionalValues_size(ast_runtime*,DefaultOptionalValues*);
typedef struct AllocValues {
struct {int exists; Bytestring value;} o_bytes_f;
struct {int count; char** values;} r_string_f;
char* a_string_f;
Bytestring a_bytes_f;
DefaultRequiredValues* a_mess_f;
} AllocValues;
extern int AllocValues_write(ast_runtime*,AllocValues*);
extern int AllocValues_read(ast_runtime*,AllocValues**);
extern int AllocValues_reclaim(ast_runtime*,AllocValues*);
extern long AllocValues_size(ast_runtime*,AllocValues*);
#endif /*foo_H*/

View File

@ -1,24 +0,0 @@
#ifndef t_H
#define t_H
typedef enum PhoneType {
MOBILE=0,
HOME=1,
WORK=2
} PhoneType;
typedef struct t {
int f1_f;
struct {int exists; float value;} f2_f;
struct {int count; int* values;} f3_f;
m2* f4_f;
} t;
extern int t_write(ast_runtime*,t*);
extern int t_read(ast_runtime*,t**);
extern int t_reclaim(ast_runtime*,t*);
extern long t_size(ast_runtime*,t*);
#endif /*t_H*/

94
libcdmr/cce.y Normal file
View File

@ -0,0 +1,94 @@
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
See the COPYRIGHT file for more information. */
/*The lines down to DO NOT DELETE ... comment are specific to the C Parser.
They will be commennted out when building a java parser.
*/
%pure-parser
%lex-param {CCEparsestate* parsestate}
%parse-param {CCEparsestate* parsestate}
%{
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include "netcdf.h"
#include "ncbytes.h"
#include "nclist.h"
#include "cceconstraints.h"
#include "cceparselex.h"
%}
/*DO NOT DELETE THIS LINE*/
%token SCAN_WORD
%token SCAN_STRINGCONST
%token SCAN_NUMBERCONST
%start constraints
%%
constraints:
optquestionmark projections
| /*empty*/
;
optquestionmark: '?' | /*empty*/ ;
projections:
projectionlist {projections(parsestate,$1);}
;
projectionlist:
projection
{$$=projectionlist(parsestate,(Object)null,$1);}
| projectionlist ',' projection
{$$=projectionlist(parsestate,$1,$3);}
;
projection:
segmentlist
{$$=projection(parsestate,$1);}
;
segmentlist:
segment
{$$=segmentlist(parsestate,null,$1);}
| segmentlist '.' segment
{$$=segmentlist(parsestate,$1,$3);}
;
segment:
word
{$$=segment(parsestate,$1,null);}
| word rangelist
{$$=segment(parsestate,$1,$2);}
;
rangelist:
range
{$$=rangelist(parsestate,null,$1);}
| rangelist range
{$$=rangelist(parsestate,$1,$2);}
;
range:
'[' number ']'
{$$=range(parsestate,$2,null,null);}
| '[' number ':' number ']'
{$$=range(parsestate,$2,null,$4);}
| '[' number ':' number ':' number ']'
{$$=range(parsestate,$2,$4,$6);}
;
word: SCAN_WORD
{$$ = checkobject($1);}
;
number: SCAN_NUMBERCONST
{$$ = checkobject($1);}
;
%%

844
libcdmr/cceconstraints.c Normal file
View File

@ -0,0 +1,844 @@
/*********************************************************************
* Copyright 1993, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
* $Header: /upc/share/CVS/netcdf-3/libncdap3/constraints3.c,v 1.40 2010/05/27 21:34:07 dmh Exp $
*********************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "nclist.h"
#include "ncbytes.h"
#include "nclog.h"
#include "netcdf.h"
#include "cceconstraints.h"
#include "crdebug.h"
#define DEBUG
#ifndef nulldup
#define nulldup(s) ((s)==NULL?NULL:strdup(s))
#endif
#ifndef nullfree
#define nullfree(s) if((s)!=NULL) {free(s);} else {}
#endif
static char* opstrings[] = OPSTRINGS ;
static int mergeprojection(CCEprojection* dst, CCEprojection* src);
static void ceallnodesr(CCEnode* node, NClist* allnodes, CEsort which);
/* Parse incoming url constraints, if any,
to check for syntactic correctness
*/
int
cdmparseconstraints(char* constraints, CCEconstraint* dapconstraint)
{
int ncstat = NC_NOERR;
char* errmsg;
assert(dapconstraint != NULL);
nclistclear(dapconstraint->projections);
nclistclear(dapconstraint->selections);
ncstat = dapceparse(constraints,dapconstraint,&errmsg);
if(ncstat) {
nclog(NCLOGWARN,"DAP constraint parse failure: %s",errmsg);
if(errmsg) free(errmsg);
nclistclear(dapconstraint->projections);
nclistclear(dapconstraint->selections);
}
#ifdef DEBUG
fprintf(stderr,"constraint: %s",ccetostring((CCEnode*)dapconstraint));
#endif
return ncstat;
}
/* Worksheet
mg.st = md.st * ms.st
mg.f = md.f+(ms.f*md.st)
mg.l = ((ms.l-1) / ms.st) * mg.st + 1
mg.p = mg.f + mg.l
mg.c = mg.l / mg.st
0000000000111111111122222222223
0123456789012345678901234567890
xxxxxx
xxxxxx
0 1 2 3 4 5 6 7 8 md=(st=3 f=1 l=25 p=26)
0 1 2 ms=(st=2 f=3 l=5 p=8 )
----------------------------
mg=(st=6 f=10 p=23 l=13)
c = 4 / 2 = 2
l = 2 * 6 + 1 = 13
0000000000111111
0123456789012345
0 1 2 3 4 md=(st=2 f=1 l=9 p=10)
0 1 2 ms=(st=1 f=2 l=3 p=5)
----------------------------
mg=(st=2 f=5 p=10 l=5 )
c = 2/1 = 2
l = 2 * 2 + 1 = 13
0000000000111111111
0123456789012345678
0 1 2 3 4 5 6 7 8 md=(st=2 f=1 l=17 p=18)
0 1 2 ms=(st=2 f=3 l=5 p=8)
----------------------------
mg=(st=4 f=7 p=16 l=9 )
c = 4/2 = 2
l = 2 * 4 + 1 = 9
0000000000111111111
0123456789012345678
0 1 2 3 4 md=(st=2 f=1 l=9 p=10)
0 1 2 3 4 ms=(st=1 f=0 l=5 p=5)
----------------------------
mg=(st=2 f=1 p=10 l=9 )
c = 4/1 = 4
l = 4 * 2 + 1 = 9
00000
01234
01 md=(st=1 f=0 l=2 p=2)
0 ms=(st=1 f=0 l=1 p=1)
----------------------------
mg=(st=1 f=0 p=1 l=1 )
c = 0/1 = 0
l = 0 * 1 + 1 = 1
000000000011
012345678901
012 md=(st=1 f=0 l=3 p=3)
012 ms=(st=1 f=0 l=3 p=2)
----------------------------
mg=(st=1 f=0 p=3 l=3 )
c = 2/1 = 2
l = 2 * 1 + 1 = 3
*/
/* Merge slice src into slice dst; dst != src */
int
cceslicemerge(CCEslice* dst, CCEslice* src)
{
int err = NC_NOERR;
CCEslice tmp;
tmp.stride = (dst->stride * src->stride);
tmp.first = (dst->first+((src->first)*(dst->stride)));
tmp.length = (((src->length - 1) / src->stride) * tmp.stride) + 1;
tmp.stop = tmp.first + tmp.length;
tmp.count = tmp.length / tmp.stride;
tmp.declsize = dst->declsize;
if(tmp.length % tmp.stride != 0) tmp.count++;
if(tmp.first >= dst->stop || tmp.stop > dst->stop)
err = NC_EINVALCOORDS;
else
*dst = tmp;
return err;
}
/*
Given two projection lists, merge
src into dst taking
overlapping projections into acct.
*/
int
cdmmergeprojections(NClist* dst, NClist* src)
{
int i;
NClist* cat = nclistnew();
int ncstat = NC_NOERR;
#ifdef DEBUG
fprintf(stderr,"dapmergeprojection: dst = %s\n",ccetostring((CCEnode*)dst));
fprintf(stderr,"dapmergeprojection: src = %s\n",ccetostring((CCEnode*)src));
#endif
/* get dst concat clone(src) */
nclistsetalloc(cat,nclistlength(dst)+nclistlength(src));
for(i=0;i<nclistlength(dst);i++) {
CCEprojection* p = (CCEprojection*)nclistget(dst,i);
nclistpush(cat,(ncelem)p);
}
for(i=0;i<nclistlength(src);i++) {
CCEprojection* p = (CCEprojection*)nclistget(src,i);
nclistpush(cat,(ncelem)cceclone((CCEnode*)p));
}
nclistclear(dst);
/* Repeatedly pull elements from the concat,
merge with all duplicates, and stick into
the dst
*/
while(nclistlength(cat) > 0) {
CCEprojection* target = (CCEprojection*)nclistremove(cat,0);
if(target == NULL) continue;
if(target->discrim != CES_VAR) continue;
for(i=0;i<nclistlength(cat);i++) {
CCEprojection* p2 = (CCEprojection*)nclistget(cat,i);
if(p2 == NULL) continue;
if(p2->discrim != CES_VAR) continue;
if(ccesamepath(target->var->segments,
p2->var->segments)!=0) continue;
/* This entry matches our current target; merge */
ncstat = mergeprojection(target,p2);
/* null out this merged entry and release it */
nclistset(cat,i,(ncelem)NULL);
ccefree((CCEnode*)p2);
}
/* Capture the clone */
nclistpush(dst,(ncelem)target);
}
nclistfree(cat);
return ncstat;
}
static int
mergeprojection(CCEprojection* dst, CCEprojection* src)
{
int ncstat = NC_NOERR;
int i,j;
/* merge segment by segment;
|dst->segments| == |src->segments|
by construction
*/
assert((dst->discrim == CES_VAR && src->discrim == CES_VAR));
assert((nclistlength(dst->var->segments) == nclistlength(src->var->segments)));
for(i=0;i<nclistlength(dst->var->segments);i++) {
CCEsegment* dstseg = (CCEsegment*)nclistget(dst->var->segments,i);
CCEsegment* srcseg = (CCEsegment*)nclistget(src->var->segments,i);
for(j=0;j<dstseg->rank;j++) {
cceslicemerge(dstseg->slices+j,
srcseg->slices+j);
}
}
return ncstat;
}
/* Convert an CCEprojection instance into a string
that can be used with the url
*/
char*
cdmbuildprojectionstring(NClist* projections)
{
char* pstring;
NCbytes* buf = ncbytesnew();
ccelisttobuffer(projections,buf,",");
pstring = ncbytesdup(buf);
ncbytesfree(buf);
return pstring;
}
char*
cdmbuildselectionstring(NClist* selections)
{
NCbytes* buf = ncbytesnew();
char* sstring;
ccelisttobuffer(selections,buf,",");
sstring = ncbytesdup(buf);
ncbytesfree(buf);
return sstring;
}
char*
cdmbuildconstraintstring(CCEconstraint* constraints)
{
NCbytes* buf = ncbytesnew();
char* result = NULL;
ccetobuffer((CCEnode*)constraints,buf);
result = ncbytesdup(buf);
ncbytesfree(buf);
return result;
}
CCEnode*
cceclone(CCEnode* node)
{
int i;
CCEnode* result = NULL;
result = (CCEnode*)ccecreate(node->sort);
if(result == NULL) goto done;
switch (node->sort) {
case CES_SLICE: {
CCEslice* clone = (CCEslice*)result;
CCEslice* orig = (CCEslice*)node;
*clone = *orig;
} break;
case CES_SEGMENT: {
CCEsegment* clone = (CCEsegment*)result;
CCEsegment* orig = (CCEsegment*)node;
*clone = *orig;
clone->name = nulldup(orig->name);
if(orig->rank > 0)
memcpy(clone->slices,orig->slices,orig->rank*sizeof(CCEslice));
} break;
case CES_VAR: {
CCEvar* clone = (CCEvar*)result;
CCEvar* orig = (CCEvar*)node;
*clone = *orig;
clone->segments = cceclonelist(clone->segments);
} break;
case CES_FCN: {
CCEfcn* clone = (CCEfcn*)result;
CCEfcn* orig = (CCEfcn*)node;
*clone = *orig;
clone->name = nulldup(orig->name);
clone->args = cceclonelist(orig->args);
} break;
case CES_CONST: {
CCEconstant* clone = (CCEconstant*)result;
CCEconstant* orig = (CCEconstant*)node;
*clone = *orig;
if(clone->discrim == CES_STR)
clone->text = nulldup(clone->text);
} break;
case CES_VALUE: {
CCEvalue* clone = (CCEvalue*)result;
CCEvalue* orig = (CCEvalue*)node;
*clone = *orig;
switch (clone->discrim) {
case CES_CONST:
clone->constant = (CCEconstant*)cceclone((CCEnode*)orig->constant); break;
case CES_VAR:
clone->var = (CCEvar*)cceclone((CCEnode*)orig->var); break;
case CES_FCN:
clone->fcn = (CCEfcn*)cceclone((CCEnode*)orig->fcn); break;
default: assert(0);
}
} break;
case CES_PROJECT: {
CCEprojection* clone = (CCEprojection*)result;
CCEprojection* orig = (CCEprojection*)node;
*clone = *orig;
switch (orig->discrim) {
case CES_VAR:
clone->var = (CCEvar*)cceclone((CCEnode*)orig->var); break;
case CES_FCN:
clone->fcn = (CCEfcn*)cceclone((CCEnode*)orig->fcn); break;
default: assert(0);
}
} break;
case CES_SELECT: {
CCEselection* clone = (CCEselection*)result;
CCEselection* orig = (CCEselection*)node;
*clone = *orig;
clone->lhs = (CCEvalue*)cceclone((CCEnode*)orig->lhs);
clone->rhs = cceclonelist(orig->rhs);
} break;
case CES_CONSTRAINT: {
CCEconstraint* clone = (CCEconstraint*)result;
CCEconstraint* orig = (CCEconstraint*)node;
*clone = *orig;
clone->projections = cceclonelist(orig->projections);
clone->selections = cceclonelist(orig->selections);
} break;
default:
assert(0);
}
done:
return result;
}
NClist*
cceclonelist(NClist* list)
{
int i;
NClist* clone;
if(list == NULL) return NULL;
clone = nclistnew();
for(i=0;i<nclistlength(list);i++) {
CCEnode* node = (CCEnode*)nclistget(list,i);
CCEnode* newnode = cceclone((CCEnode*)node);
nclistpush(clone,(ncelem)newnode);
}
return clone;
}
void
ccefree(CCEnode* node)
{
int i;
if(node == NULL) return;
switch (node->sort) {
case CES_VAR: {
CCEvar* target = (CCEvar*)node;
ccefreelist(target->segments);
} break;
case CES_FCN: {
CCEfcn* target = (CCEfcn*)node;
ccefreelist(target->args);
nullfree(target->name);
} break;
case CES_CONST: {
CCEconstant* target = (CCEconstant*)node;
if(target->discrim == CES_STR)
nullfree(target->text);
} break;
case CES_VALUE: {
CCEvalue* target = (CCEvalue*)node;
switch(target->discrim) {
case CES_CONST: ccefree((CCEnode*)target->constant); break;
case CES_VAR: ccefree((CCEnode*)target->var); break;
case CES_FCN: ccefree((CCEnode*)target->fcn); break;
default: assert(0);
}
} break;
case CES_PROJECT: {
CCEprojection* target = (CCEprojection*)node;
switch (target->discrim) {
case CES_VAR: ccefree((CCEnode*)target->var); break;
case CES_FCN: ccefree((CCEnode*)target->fcn); break;
default: assert(0);
}
} break;
case CES_SELECT: {
CCEselection* target = (CCEselection*)node;
ccefreelist(target->rhs);
ccefree((CCEnode*)target->lhs);
} break;
case CES_CONSTRAINT: {
CCEconstraint* target = (CCEconstraint*)node;
ccefreelist(target->projections);
ccefreelist(target->selections);
} break;
case CES_SEGMENT: {
CCEsegment* target = (CCEsegment*)node;
target->rank = 0;
nullfree(target->name);
} break;
case CES_SLICE: {
} break;
default:
assert(0);
}
/* final action */
free(node);
}
void
ccefreelist(NClist* list)
{
int i;
if(list == NULL) return;
for(i=0;i<nclistlength(list);i++) {
CCEnode* node = (CCEnode*)nclistget(list,i);
ccefree((CCEnode*)node);
}
nclistfree(list);
}
char*
ccetostring(CCEnode* node)
{
char* s;
NCbytes* buf = ncbytesnew();
ccetobuffer(node,buf);
s = ncbytesextract(buf);
ncbytesfree(buf);
return s;
}
void
ccetobuffer(CCEnode* node, NCbytes* buf)
{
int i;
char tmp[1024];
if(buf == NULL) return;
if(node == NULL) {ncbytesappend(buf,'?'); return;}
switch (node->sort) {
case CES_SLICE: {
CCEslice* slice = (CCEslice*)node;
size_t last = (slice->first+slice->length)-1;
if(last > slice->declsize && slice->declsize > 0)
last = slice->declsize - 1;
if(slice->count == 1) {
snprintf(tmp,sizeof(tmp),"[%lu]",
(unsigned long)slice->first);
} else if(slice->stride == 1) {
snprintf(tmp,sizeof(tmp),"[%lu:%lu]",
(unsigned long)slice->first,
(unsigned long)last);
} else {
snprintf(tmp,sizeof(tmp),"[%lu:%lu:%lu]",
(unsigned long)slice->first,
(unsigned long)slice->stride,
(unsigned long)last);
}
ncbytescat(buf,tmp);
} break;
case CES_SEGMENT: {
CCEsegment* segment = (CCEsegment*)node;
int rank = segment->rank;
char* name = (segment->name?segment->name:"<unknown>");
ncbytescat(buf,nulldup(name));
if(!cceiswholesegment(segment)) {
for(i=0;i<rank;i++) {
CCEslice* slice = segment->slices+i;
ccetobuffer((CCEnode*)slice,buf);
}
}
} break;
case CES_VAR: {
CCEvar* var = (CCEvar*)node;
ccelisttobuffer(var->segments,buf,".");
} break;
case CES_FCN: {
CCEfcn* fcn = (CCEfcn*)node;
ncbytescat(buf,fcn->name);
ncbytescat(buf,"(");
ccelisttobuffer(fcn->args,buf,",");
ncbytescat(buf,")");
} break;
case CES_CONST: {
CCEconstant* value = (CCEconstant*)node;
switch (value->discrim) {
case CES_STR:
ncbytescat(buf,value->text);
break;
case CES_INT:
snprintf(tmp,sizeof(tmp),"%lld",value->intvalue);
ncbytescat(buf,tmp);
break;
case CES_FLOAT:
snprintf(tmp,sizeof(tmp),"%g",value->floatvalue);
ncbytescat(buf,tmp);
break;
default: assert(0);
}
} break;
case CES_VALUE: {
CCEvalue* value = (CCEvalue*)node;
switch (value->discrim) {
case CES_CONST:
ccetobuffer((CCEnode*)value->constant,buf);
break;
case CES_VAR:
ccetobuffer((CCEnode*)value->var,buf);
break;
case CES_FCN:
ccetobuffer((CCEnode*)value->fcn,buf);
break;
default: assert(0);
}
} break;
case CES_PROJECT: {
CCEprojection* target = (CCEprojection*)node;
switch (target->discrim) {
case CES_VAR:
ccetobuffer((CCEnode*)target->var,buf);
break;
case CES_FCN: ccetobuffer((CCEnode*)target->fcn,buf); break;
default: assert(0);
}
} break;
case CES_SELECT: {
CCEselection* sel = (CCEselection*)node;
ccetobuffer((CCEnode*)sel->lhs,buf);
if(sel->operator == CES_NIL) break;
ncbytescat(buf,opstrings[(int)sel->operator]);
if(nclistlength(sel->rhs) > 1)
ncbytescat(buf,"{");
ccelisttobuffer(sel->rhs,buf,",");
if(nclistlength(sel->rhs) > 1)
ncbytescat(buf,"}");
} break;
case CES_CONSTRAINT: {
CCEconstraint* con = (CCEconstraint*)node;
if(con->projections != NULL && nclistlength(con->projections) > 0) {
ccelisttobuffer(con->projections,buf,",");
}
if(con->selections != NULL && nclistlength(con->selections) > 0) {
ncbytescat(buf,"&"); /* because & is really a prefix */
ccelisttobuffer(con->selections,buf,"&");
}
} break;
case CES_NIL: {
ncbytescat(buf,"<nil>");
} break;
default:
assert(0);
}
}
char*
ccelisttostring(NClist* list, char* sep)
{
char* s;
NCbytes* buf = ncbytesnew();
ccelisttobuffer(list,buf,sep);
s = ncbytesextract(buf);
ncbytesfree(buf);
return s;
}
void
ccelisttobuffer(NClist* list, NCbytes* buf, char* sep)
{
int i;
if(list == NULL || buf == NULL) return;
if(sep == NULL) sep = ",";
for(i=0;i<nclistlength(list);i++) {
CCEnode* node = (CCEnode*)nclistget(list,i);
if(i>0) ncbytescat(buf,sep);
ccetobuffer((CCEnode*)node,buf);
}
}
/* Collect all nodes within a specified constraint tree */
/* Caller frees result */
NClist*
cceallnodes(CCEnode* node, CEsort which)
{
NClist* allnodes = nclistnew();
ceallnodesr(node,allnodes,which);
return allnodes;
}
static void
ceallnodesr(CCEnode* node, NClist* allnodes, CEsort which)
{
int i;
if(node == NULL) return;
if(nclistcontains(allnodes,(ncelem)node)) return;
if(which == CES_NIL || node->sort == which)
nclistpush(allnodes,(ncelem)node);
switch(node->sort) {
case CES_FCN: {
CCEfcn* fcn = (CCEfcn*)node;
for(i=0;i<nclistlength(fcn->args);i++) {
ceallnodesr((CCEnode*)nclistget(fcn->args,i),allnodes,which);
}
} break;
case CES_VAR: {
CCEvar* var = (CCEvar*)node;
for(i=0;i<nclistlength(var->segments);i++) {
ceallnodesr((CCEnode*)nclistget(var->segments,i),allnodes,which);
}
} break;
case CES_VALUE: {
CCEvalue* value = (CCEvalue*)node;
if(value->discrim == CES_VAR)
ceallnodesr((CCEnode*)value->var,allnodes,which);
else if(value->discrim == CES_FCN)
ceallnodesr((CCEnode*)value->fcn,allnodes,which);
else
ceallnodesr((CCEnode*)value->constant,allnodes,which);
} break;
case CES_SELECT: {
CCEselection* selection = (CCEselection*)node;
ceallnodesr((CCEnode*)selection->lhs,allnodes,which);
for(i=0;i<nclistlength(selection->rhs);i++)
ceallnodesr((CCEnode*)nclistget(selection->rhs,i),allnodes,which);
} break;
case CES_PROJECT: {
CCEprojection* projection = (CCEprojection*)node;
if(projection->discrim == CES_VAR)
ceallnodesr((CCEnode*)projection->var,allnodes,which);
else
ceallnodesr((CCEnode*)projection->fcn,allnodes,which);
} break;
case CES_CONSTRAINT: {
CCEconstraint* constraint = (CCEconstraint*)node;
for(i=0;i<nclistlength(constraint->projections);i++)
ceallnodesr((CCEnode*)nclistget(constraint->projections,i),allnodes,which);
for(i=0;i<nclistlength(constraint->selections);i++)
ceallnodesr((CCEnode*)nclistget(constraint->selections,i),allnodes,which);
} break;
/* All others have no subnodes */
default:
break;
}
}
CCEnode*
ccecreate(CEsort sort)
{
CCEnode* node = NULL;
switch (sort) {
case CES_SLICE: {
CCEslice* target = (CCEslice*)calloc(1,sizeof(CCEslice));
if(target == NULL) return NULL;
node = (CCEnode*)target;
} break;
case CES_SEGMENT: {
int i;
CCEsegment* target = (CCEsegment*)calloc(1,sizeof(CCEsegment));
if(target == NULL) return NULL;
/* Initialize the sort of the slices */
for(i=0;i<NC_MAX_VAR_DIMS;i++)
target->slices[i].node.sort = CES_SLICE;
node = (CCEnode*)target;
} break;
case CES_CONST: {
CCEconstant* target = (CCEconstant*)calloc(1,sizeof(CCEconstant));
if(target == NULL) return NULL;
node = (CCEnode*)target;
target->discrim == CES_NIL;
} break;
case CES_VALUE: {
CCEvalue* target = (CCEvalue*)calloc(1,sizeof(CCEvalue));
if(target == NULL) return NULL;
node = (CCEnode*)target;
target->discrim == CES_NIL;
} break;
case CES_VAR: {
CCEvar* target = (CCEvar*)calloc(1,sizeof(CCEvar));
if(target == NULL) return NULL;
node = (CCEnode*)target;
} break;
case CES_FCN: {
CCEfcn* target = (CCEfcn*)calloc(1,sizeof(CCEfcn));
if(target == NULL) return NULL;
node = (CCEnode*)target;
} break;
case CES_PROJECT: {
CCEprojection* target = (CCEprojection*)calloc(1,sizeof(CCEprojection));
if(target == NULL) return NULL;
node = (CCEnode*)target;
} break;
case CES_SELECT: {
CCEselection* target = (CCEselection*)calloc(1,sizeof(CCEselection));
if(target == NULL) return NULL;
node = (CCEnode*)target;
target->operator = CEO_NIL;
} break;
case CES_CONSTRAINT: {
CCEconstraint* target = (CCEconstraint*)calloc(1,sizeof(CCEconstraint));
if(target == NULL) return NULL;
node = (CCEnode*)target;
} break;
default:
assert(0);
}
/* final action */
node->sort = sort;
return node;
}
void
ccemakewholeslice(CCEslice* slice, size_t declsize)
{
slice->first = 0;
slice->stride = 1;
slice->length = declsize;
slice->stop = declsize;
slice->declsize = declsize;
slice->count = declsize;
}
int
cceiswholeslice(CCEslice* slice)
{
if(slice->first != 0 || slice->stride != 1) return 0;
return 1;
}
int
cceiswholesegment(CCEsegment* seg)
{
int i,whole;
NClist* dimset = NULL;
unsigned int rank;
if(!seg->slicesdefined) return 0; /* actually, we don't know */
whole = 1; /* assume so */
for(i=0;i<seg->rank;i++) {
if(!cceiswholeslice(&seg->slices[i])) {whole = 0; break;}
}
return whole;
}
int
cceiswholevar(CCEvar* var)
{
int i,whole;
whole = 1; /* assume so */
for(i=0;i<nclistlength(var->segments);i++) {
CCEsegment* segment = (CCEsegment*)nclistget(var->segments,i);
if(!cceiswholesegment(segment)) {whole = 0; break;}
}
return whole;
}
int
ccesamepath(NClist* list1, NClist* list2)
{
int i;
int len = nclistlength(list1);
if(len != nclistlength(list2)) return 0;
for(i=0;i<len;i++) {
CCEsegment* s1 = (CCEsegment*)nclistget(list1,i);
CCEsegment* s2 = (CCEsegment*)nclistget(list2,i);
if(strcmp(s1->name,s2->name) != 0) return 0;
}
return 1;
}

126
libcdmr/cceconstraints.h Normal file
View File

@ -0,0 +1,126 @@
/*********************************************************************
* Copyright 1993, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*********************************************************************/
/* $Header$ */
#ifndef CCECONSTRAINTS_H
#define CCECONSTRAINTS_H 1
#include "ceconstraints.h"
#ifndef NC_MAX_VAR_DIMS
#define NC_MAX_VAR_DIMS 1024
#endif
/* Provide a universal cast type containing common fields */
struct CDFnode; /* Forward */
typedef struct CCEnode {
CEsort sort;
} CCEnode;
typedef struct CCEslice {
CCEnode node;
size_t first;
size_t count;
size_t length; /* count*stride */
size_t stride;
size_t stop; /* == first + count*/
size_t declsize; /* from defining dimension, if any.*/
} CCEslice;
typedef struct CCEsegment {
CCEnode node;
char* name;
int slicesdefined; /*1=>slice counts defined, except declsize*/
int slicesdeclized; /*1=>slice declsize defined */
size_t rank;
CCEslice slices[NC_MAX_VAR_DIMS];
struct CDFnode* cdfnode;
} CCEsegment;
typedef struct CCEfcn {
CCEnode node;
char* name;
NClist* args;
} CCEfcn;
typedef struct CCEvar {
CCEnode node;
NClist* segments;
struct CDFnode* cdfnode;
struct CDFnode* cdfleaf;
} CCEvar;
typedef struct CCEconstant {
CCEnode node;
CEsort discrim;
char* text;
long long intvalue;
double floatvalue;
} CCEconstant;
typedef struct CCEvalue {
CCEnode node;
CEsort discrim;
/* Do not bother with a union */
CCEconstant* constant;
CCEvar* var;
CCEfcn* fcn;
} CCEvalue;
typedef struct CCEselection {
CCEnode node;
CEsort operator;
CCEvalue* lhs;
NClist* rhs;
} CCEselection;
typedef struct CCEprojection {
CCEnode node;
CEsort discrim;
/* Do not bother with a union */
CCEvar* var;
CCEfcn* fcn;
} CCEprojection;
typedef struct CCEconstraint {
CCEnode node;
NClist* projections;
NClist* selections;
} CCEconstraint;
extern int cceparseconstraints(char* constraints, CCEconstraint* CCEonstraint);
extern int cceslicemerge(CCEslice* dst, CCEslice* src);
extern int ccemergeprojections(NClist* dst, NClist* src);
extern char* ccebuildprojectionstring(NClist* projections);
extern char* ccebuildselectionstring(NClist* selections);
extern char* ccebuildconstraintstring(CCEconstraint* constraints);
extern CCEnode* cceclone(CCEnode* node);
extern NClist* cceclonelist(NClist* list);
extern void ccefree(CCEnode* node);
extern void ccefreelist(NClist* list);
extern char* ccetostring(CCEnode* node);
extern char* ccelisttostring(NClist* list,char*);
extern void ccetobuffer(CCEnode* node, NCbytes* buf);
extern void ccelisttobuffer(NClist* list, NCbytes* buf,char*);
extern NClist* cceallnodes(CCEnode* node, CEsort which);
extern CCEnode* ccecreate(CEsort sort);
extern void ccemakewholeslice(CCEslice* slice, size_t declsize);
extern int cceiswholesegment(CCEsegment*);
extern int cceiswholeslice(CCEslice*);
extern int cceiswholeseglist(NClist*);
extern int ccesamepath(NClist* list1, NClist* list2);
#endif /*CCECONSTRAINTS_H*/

223
libcdmr/ccelex.c Normal file
View File

@ -0,0 +1,223 @@
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
See the COPYRIGHT file for more information. */
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "netcdf.h"
#include "nclist.h"
#include "ncbytes.h"
#include "cceconstraints.h"
#include "cceparselex.h"
/* Forward */
static void dumptoken(CCElexstate* lexstate);
static int tohex(int c);
static void ceaddyytext(CCElexstate* lex, int c);
/****************************************************/
#ifdef UNUSED
static char* worddelims =
"{}[]:;=,";
#endif
/* Define 1 and > 1st legal characters */
static char* wordchars1 =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_/%\\";
static char* wordcharsn =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_/%\\";
/* Number characters */
static char* numchars1="+-0123456789";
static char* numcharsn="Ee.+-0123456789";
/**************************************************/
static int
ccelex(YYSTYPE* lvalp, CCEparsestate* state)
{
CCElexstate* lexstate = state->lexstate;
int token;
int c;
int len;
char* p=lexstate->next;
token = 0;
ncbytesclear(lexstate->yytext);
ncbytesnull(lexstate->yytext);
p=lexstate->next;
while(token == 0 && (c=*p)) {
if(c <= ' ' || c >= '\177') {p++; continue;}
if(c == '"') {
int more = 1;
/* We have a SCAN_STRINGCONST */
while(more && (c=*(++p))) {
switch (c) {
case '"': p++; more=0; break;
case '\\':
c=*(++p);
switch (c) {
case 'r': c = '\r'; break;
case 'n': c = '\n'; break;
case 'f': c = '\f'; break;
case 't': c = '\t'; break;
case 'x': {
int d1,d2;
c = '?';
++p;
d1 = tohex(*p++);
if(d1 < 0) {
cceerror(state,"Illegal \\xDD in SCAN_STRING");
} else {
d2 = tohex(*p++);
if(d2 < 0) {
cceerror(state,"Illegal \\xDD in SCAN_STRING");
} else {
c=(((unsigned int)d1)<<4) | (unsigned int)d2;
}
}
} break;
default: break;
}
break;
default: break;
}
ceaddyytext(lexstate,c);
}
token=SCAN_STRINGCONST;
} else if(strchr(numchars1,c) != NULL) {
/* we might have a SCAN_NUMBERCONST */
int isnumber = 0;
char* yytext;
char* endpoint;
ceaddyytext(lexstate,c);
for(p++;(c=*p);p++) {
if(strchr(numcharsn,c) == NULL) break;
ceaddyytext(lexstate,c);
}
/* See if this is a number */
ncbytesnull(lexstate->yytext);
yytext = ncbytescontents(lexstate->yytext);
(void)strtoll(yytext,&endpoint,10);
if(*yytext != '\0' && *endpoint == '\0')
isnumber = 1;
else {
(void)strtod(yytext,&endpoint);
if(*yytext != '\0' && *endpoint == '\0')
isnumber = 1; /* maybe */
}
/* A number followed by an id char is assumed to just be
a funny id */
if(isnumber && (*p == '\0' || strchr(wordcharsn,*p) == NULL)) {
token = SCAN_NUMBERCONST;
} else {
/* Now, if the funny word has a "." in it,
we have to back up to that dot */
char* dotpoint = strchr(yytext,'.');
if(dotpoint != NULL) {
p = dotpoint;
*dotpoint = '\0';
}
token = SCAN_WORD;
}
} else if(strchr(wordchars1,c) != NULL) {
/* we have a SCAN_WORD */
ceaddyytext(lexstate,c);
for(p++;(c=*p);p++) {
if(strchr(wordcharsn,c) == NULL) break;
ceaddyytext(lexstate,c);
}
token=SCAN_WORD;
} else {
/* we have a single char token */
token = c;
ceaddyytext(lexstate,c);
p++;
}
}
lexstate->next = p;
len = ncbyteslength(lexstate->yytext);
if(len > MAX_TOKEN_LENGTH) len = MAX_TOKEN_LENGTH;
strncpy(lexstate->lasttokentext,ncbytescontents(lexstate->yytext),len);
lexstate->lasttokentext[len] = '\0';
lexstate->lasttoken = token;
#ifdef PARSEDEBUG
if(ccedebug) dumptoken(lexstate);
#endif
/*Put return value onto Bison stack*/
if(ncbyteslength(lexstate->yytext) == 0)
*lvalp = NULL;
else {
*lvalp = ncbytesdup(lexstate->yytext);
nclistpush(lexstate->reclaim,(ncelem)*lvalp);
}
return token;
}
static void
ceaddyytext(CCElexstate* lex, int c)
{
ncbytesappend(lex->yytext,(char)c);
}
static int
tohex(int c)
{
if(c >= 'a' && c <= 'f') return (c - 'a') + 0xa;
if(c >= 'A' && c <= 'F') return (c - 'A') + 0xa;
if(c >= '0' && c <= '9') return (c - '0');
return -1;
}
static void
dumptoken(CCElexstate* lexstate)
{
switch (lexstate->lasttoken) {
case SCAN_STRINGCONST:
fprintf(stderr,"TOKEN = |\"%s\"|\n",lexstate->lasttokentext);
break;
case SCAN_WORD:
case SCAN_NUMBERCONST:
default:
fprintf(stderr,"TOKEN = |%s|\n",lexstate->lasttokentext);
break;
}
}
static void
ccelexinit(char* input, CCElexstate** lexstatep)
{
CCElexstate* lexstate = (CCElexstate*)malloc(sizeof(CCElexstate));
if(lexstatep) *lexstatep = lexstate;
if(lexstate == NULL) return;
memset((void*)lexstate,0,sizeof(CCElexstate));
lexstate->input = strdup(input);
lexstate->next = lexstate->input;
lexstate->yytext = ncbytesnew();
lexstate->reclaim = nclistnew();
}
static void
ccelexcleanup(CCElexstate** lexstatep)
{
CCElexstate* lexstate = *lexstatep;
if(lexstate == NULL) return;
if(lexstate->input != NULL) free(lexstate->input);
if(lexstate->reclaim != NULL) {
while(nclistlength(lexstate->reclaim) > 0) {
char* word = (char*)nclistpop(lexstate->reclaim);
if(word) free(word);
}
nclistfree(lexstate->reclaim);
}
ncbytesfree(lexstate->yytext);
free(lexstate);
*lexstatep = NULL;
}

244
libcdmr/cceparse.c Normal file
View File

@ -0,0 +1,244 @@
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
See the COPYRIGHT file for more information. */
/* Parser actions for constraint expressions */
/* Since oc does not use the constraint parser,
they functions all just abort if called.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "netcdf.h"
#include "nclist.h"
#include "ncbytes.h"
#include "cceconstraints.h"
#include "cceparselex.h"
#ifndef nulldup
#define nulldup(s) ((s)==NULL?NULL:strdup(s))
#endif
#ifndef nullfree
#define nullfree(s) if((s)!=NULL) {free(s);} else {}
#endif
#ifdef PARSEDEBUG
extern int ccedebug;
#endif
static int ccelex(YYSTYPE* lvalp, CCEparsestate* state);
static void ccelexinit(char* input, CCElexstate** lexstatep);
static void ccelexcleanup(CCElexstate** lexstatep);
static Object collectlist(Object list0, Object decl);
static void
projections(CCEparsestate* state, Object list0)
{
NClist* list = (NClist*)list0;
if(list != NULL) {
nclistfree(state->constraint->projections);
state->constraint->projections = list;
}
#ifdef DEBUG
fprintf(stderr," ce.projections: %s\n",
ccetostring((CCEnode*)state->constraint->projections));
#endif
}
static Object
projectionlist(CCEparsestate* state, Object list0, Object decl)
{
return collectlist(list0,decl);
}
static Object
projection(CCEparsestate* state, Object varorfcn)
{
CCEprojection* p = (CCEprojection*)ccecreate(CES_PROJECT);
CEsort tag = *(CEsort*)varorfcn;
if(tag == CES_FCN)
p->fcn = varorfcn;
else
p->var = varorfcn;
p->discrim = tag;
#ifdef DEBUG
fprintf(stderr," ce.projection: %s\n",
ccetostring((CCEnode*)p));
#endif
return p;
}
static Object
segmentlist(CCEparsestate* state, Object var0, Object decl)
{
/* watch out: this is non-standard */
NClist* list;
CCEvar* v = (CCEvar*)var0;
if(v==NULL) v = (CCEvar*)ccecreate(CES_VAR);
list = v->segments;
if(list == NULL) list = nclistnew();
nclistpush(list,(ncelem)decl);
v->segments = list;
return v;
}
static Object
segment(CCEparsestate* state, Object name, Object slices0)
{
int i;
CCEsegment* segment = (CCEsegment*)ccecreate(CES_SEGMENT);
NClist* slices = (NClist*)slices0;
segment->name = strdup((char*)name);
if(slices != NULL && nclistlength(slices) > 0) {
segment->slicesdefined = 1; /* but not declsizes */
for(i=0;i<nclistlength(slices);i++) {
CCEslice* slice = (CCEslice*)nclistget(slices,i);
segment->slices[i] = *slice;
free(slice);
}
nclistfree(slices);
} else
segment->slicesdefined = 0;
#ifdef DEBUG
fprintf(stderr," ce.segment: %s\n",
dumpsegment(segment));
#endif
return segment;
}
static Object
rangelist(CCEparsestate* state, Object list0, Object decl)
{
return collectlist(list0,decl);
}
static Object
range(CCEparsestate* state, Object sfirst, Object sstride, Object slast)
{
CCEslice* slice = (CCEslice*)ccecreate(CES_SLICE);
unsigned long first,stride,last;
/* Note: that incoming arguments are strings; we must convert to size_t;
but we do know they are legal integers or NULL */
sscanf((char*)sfirst,"%lu",&first); /* always defined */
if(slast != NULL)
sscanf((char*)slast,"%lu",&last);
else
last = first;
if(sstride != NULL)
sscanf((char*)sstride,"%lu",&stride);
else
stride = 1; /* default */
if(stride == 0)
cceerror(state,"Illegal index for range stride");
if(last < first)
cceerror(state,"Illegal index for range last index");
slice->first = first;
slice->stride = stride;
slice->stop = last + 1;
slice->length = slice->stop - slice->first;
slice->count = slice->length / slice->stride;
#ifdef DEBUG
fprintf(stderr," ce.slice: %s\n",
dumpslice(slice));
#endif
return slice;
}
static Object
collectlist(Object list0, Object decl)
{
NClist* list = (NClist*)list0;
if(list == NULL) list = nclistnew();
nclistpush(list,(ncelem)decl);
return list;
}
int
cceerror(CCEparsestate* state, char* msg)
{
strcpy(state->errorbuf,msg);
state->errorcode=1;
return 0;
}
static void
cce_parse_cleanup(CCEparsestate* state)
{
ccelexcleanup(&state->lexstate); /* will free */
}
static CCEparsestate*
ce_parse_init(char* input, CCEconstraint* constraint)
{
CCEparsestate* state = NULL;
if(input==NULL) {
cceerror(state,"ce_parse_init: no input buffer");
} else {
state = (CCEparsestate*)calloc(1,sizeof(CCEparsestate));
if(state==NULL) return (CCEparsestate*)NULL;
state->errorbuf[0] = '\0';
state->errorcode = 0;
ccelexinit(input,&state->lexstate);
state->constraint = constraint;
}
return state;
}
/* Wrapper for ceparse */
int
cdmceparse(char* input, CCEconstraint* constraint, char** errmsgp)
{
CCEparsestate* state;
int errcode = 0;
#ifdef PARSEDEBUG
ccedebug = 1;
#endif
if(input != NULL) {
#ifdef DEBUG
fprintf(stderr,"cceeparse: input=%s\n",input);
#endif
state = ce_parse_init(input,constraint);
if(cceparse(state) == 0) {
#ifdef DEBUG
if(nclistlength(constraint->projections) > 0)
fprintf(stderr,"cceeparse: projections=%s\n",
ccetostring((CCEnode*)constraint->projections));
#endif
#ifdef DEBUG
if(nclistlength(constraint->selections) > 0)
fprintf(stderr,"cceeparse: selections=%s\n",
dumpselections(constraint->selections));
#endif
} else {
if(errmsgp) *errmsgp = nulldup(state->errorbuf);
}
errcode = state->errorcode;
cce_parse_cleanup(state);
}
return errcode;
}
#ifdef PARSEDEBUG
Object
debugobject(Object o)
{
return o;
}
#endif
#include "ccelex.c"
#include "ccetab.c"

89
libcdmr/cceparselex.h Normal file
View File

@ -0,0 +1,89 @@
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
See the COPYRIGHT file for more information. */
#ifndef CCEPARSELEX_H
#define CCEPARSELEX_H
#include "config.h"
#include "ccetab.h"
#ifdef WIN32
#define strcasecmp stricmp
#define snprintf _snprintf
#endif
/* For consistency with Java parser */
#ifndef null
#define null NULL
#endif
typedef void* Object;
#define YYSTYPE Object
#define MAX_TOKEN_LENGTH 1024
/*! Specifies CCElexstate. */
typedef struct CCElexstate {
char* input;
char* next; /* next char in uri.query */
NCbytes* yytext;
/*! Specifies the Lasttoken. */
int lasttoken;
char lasttokentext[MAX_TOKEN_LENGTH+1]; /* leave room for trailing null */
NClist* reclaim; /* reclaim SCAN_WORD instances */
} CCElexstate;
/*! Specifies CCEparsestate. */
typedef struct CCEparsestate {
CCEconstraint* constraint;
char errorbuf[1024];
int errorcode;
CCElexstate* lexstate;
} CCEparsestate;
/* Define a generic object carrier; this serves
essentially the same role as the typical bison %union
declaration
*/
#ifdef IGNORE
extern int ceerror(CCEparsestate*,char*);
extern void ce_parse_error(CCEparsestate*,const char *fmt, ...);
/* bison parse entry point */
extern int cceparse(CCEparsestate*);
extern int yyerror(CCEparsestate* state, char* msg);
extern void projections(CCEparsestate* state, Object list0);
extern Object projectionlist(CCEparsestate* state, Object list0, Object decl);
extern Object projection(CCEparsestate* state, Object segmentlist);
extern Object segmentlist(CCEparsestate* state, Object list0, Object decl);
extern Object segment(CCEparsestate* state, Object name, Object slices0);
extern Object range(CCEparsestate* state, Object, Object, Object);
extern Object indexer(CCEparsestate* state, Object name, Object indices);
extern Object indexpath(CCEparsestate* state, Object list0, Object index);
extern Object var(CCEparsestate* state, Object indexpath);
extern Object range1(CCEparsestate* state, Object rangenumber);
extern Object rangelist(CCEparsestate* state, Object list0, Object decl);
/* lexer interface */
extern int ccelex(YYSTYPE*, CCEparsestate*);
extern void ccelexinit(char* input, CCElexstate** lexstatep);
extern void ccelexcleanup(CCElexstate** lexstatep);
#endif
extern int cdmceparse(char* input, CCEconstraint*, char**);
#ifdef PARSEDEBUG
extern int ccedebug;
extern Object debugobject(Object);
#define checkobject(x) debugobject(x)
#else
#define checkobject(x) (x)
#endif
#endif /*CCEPARSELEX_H*/

1679
libcdmr/ccetab.c Normal file

File diff suppressed because it is too large Load Diff

58
libcdmr/ccetab.h Normal file
View File

@ -0,0 +1,58 @@
/* A Bison parser, made by GNU Bison 2.4.3. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
SCAN_WORD = 258,
SCAN_STRINGCONST = 259,
SCAN_NUMBERCONST = 260
};
#endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif

View File

@ -165,8 +165,8 @@ nccr_fetchurl(CURL* curl, char* url, bytes_t* buf, long* filetime)
endex = crstrindex(buf->bytes,"</html>");
if(endex >= 0) endex += 7; else endex = buf->nbytes-1;
nclog(NCLOGWARN,"Probable Server error");
nclogtext(NCLOGWARN,buf->bytes+first,endex-first);
nclogtext(NCLOGWARN,"\n",1);
nclogtextn(NCLOGWARN,buf->bytes+first,endex-first);
nclogtext(NCLOGWARN,"\n");
}
return stat;

View File

@ -40,8 +40,8 @@
extern NC_FILE_INFO_T* nc_file;
static NCerror skiptoheader(bytes_t* packet, size_t* offsetp);
static void freeNCCDMR(NCCDMR* cdmr);
static int nccr_elide_vars(NCCDMR* cdmr);
/**************************************************/
int
@ -226,37 +226,11 @@ NCCR_close(int ncid)
/* Auxilliary routines */
/**************************************************/
static NCerror
skiptoheader(bytes_t* packet, size_t* offsetp)
static int
nccr_elide_vars(NCCDMR* cdmr)
{
NCerror status = NC_NOERR;
unsigned long long vlen;
size_t size,offset;
/* Check the structure of the resulting data */
if(packet->nbytes < (strlen(MAGIC_HEADER) + strlen(MAGIC_HEADER))) {
nclog(NCLOGERR,"Curl data too short: %d\n",packet->nbytes);
status = NC_ECURL;
goto done;
}
if(memcmp(packet->bytes,MAGIC_HEADER,strlen(MAGIC_HEADER)) != 0) {
nclog(NCLOGERR,"MAGIC_HEADER missing\n");
status = NC_ECURL;
goto done;
}
offset = strlen(MAGIC_HEADER);
/* Extract the proposed count as a varint */
vlen = varint_decode(10,packet->bytes+offset,&size);
offset += size;
if(vlen != (packet->nbytes-offset)) {
nclog(NCLOGERR,"Curl data size mismatch\n");
status = NC_ECURL;
goto done;
}
if(offsetp) *offsetp = offset;
done:
return status;
int ncstat = NC_NOERR;
return ncstat;
}
static void

View File

@ -76,16 +76,6 @@ extern char* nulldup(const char*);
#define nulllen(s) (s==NULL?0:strlen(s))
#define nullstring(s) (s==NULL?"(null)":s)
/**************************************************/
/* Define cdmremote magic numbers */
#define MAGIC_START "\x43\x44\x46\x53"
#define MAGIC_END "\xed\xed\xde\xde"
#define MAGIC_HEADER "\xad\xec\xce\xda"
#define MAGIC_DATA "\xab\xec\xce\xba"
#define MAGIC_ERR "\xab\xad\xba\xda"
/**********************************************************/
/* Forwards */
struct Header;

View File

@ -1,173 +0,0 @@
/*********************************************************************
* Copyright 1993, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
* $Header: /upc/share/CVS/netcdf-3/libncdap4/constraints4.c,v 1.9 2010/04/13 03:36:31 dmh Exp $
*********************************************************************/
#include "ncdap4.h"
#include "dapodom.h"
#ifdef DEBUG
#include "dapdump.h"
#endif
/* In order to construct the projection,
we need to make sure to match the relevant dimensions
against the relevant nodes in which the ultimate target
is contained.
*/
int
crbuildvaraprojection(Getvara* getvar,
const size_t* startp, const size_t* countp, const ptrdiff_t* stridep,
CRCprojection** projectionp)
{
int i;
int ncstat = NC_NOERR;
NClist* dimset;
CDFnode* var = getvar->target;
CRCprojection* projection = NULL;
NClist* segments = NULL;
NCsegment* segment;
segment = createncsegment();
segment->node = var;
ASSERT((segment->node != NULL));
segment->name = nulldup(segment->node->name);
segment->slicesdefined = 0; /* temporary */
segments = nclistnew();
nclistpush(segments,(ncelem)segment);
projection = createCRCprojection();
projection->discrim = NS_VAR;
projection->var = createncvar();
projection->var->leaf = var;
projection->var->segments = segments;
/* All slices are assigned to the first (and only segment) */
dimset = var->array.dimensions;
segment->slicerank = nclistlength(var->array.dimensions);
for(i=0;i<segment->slicerank;i++) {
NCslice* slice = &segment->slices[i];
CDFnode* dim = (CDFnode*)nclistget(dimset,i);
slice->first = startp[i];
slice->stride = stridep[i];
slice->count = countp[i];
slice->length = slice->count * slice->stride;
slice->stop = (slice->first + slice->length);
ASSERT(dim->dim.declsize > 0);
slice->declsize = dim->dim.declsize;
}
segment->slicesdefined = 1;
if(projectionp) *projectionp = projection;
if(ncstat) freeCRCprojection(projection);
return ncstat;
}
/* Compute the set of prefetched data */
int
crprefetchdata(NCCR* drno)
{
int i,j;
int ncstat = NC_NOERR;
NClist* allvars = drno->dap.cdf.varnodes;
NCconstraint* constraint = drno->dap.oc.dapconstraint;
NClist* vars = nclistnew();
NCcachenode* cache = NULL;
NCconstraint* newconstraint;
/* If caching is off, and we can do constraints, then
don't even do prefetch
*/
if(!FLAGSET(drno->dap.controls,NCF_CACHE) && !FLAGSET(drno->dap.controls,NCF_UNCONSTRAINABLE)) {
drno->dap.cdf.cache->prefetch = NULL;
goto done;
}
for(i=0;i<nclistlength(allvars);i++) {
CDFnode* var = (CDFnode*)nclistget(allvars,i);
size_t nelems = 1;
/* Compute the # of elements in the variable */
for(j=0;j<nclistlength(var->array.dimensions);j++) {
CDFnode* dim = (CDFnode*)nclistget(var->array.dimensions,j);
nelems *= dim->dim.declsize;
}
/* If we cannot constrain, then pull in everything */
if(FLAGSET(drno->dap.controls,NCF_UNCONSTRAINABLE)
|| nelems <= drno->dap.cdf.smallsizelimit)
nclistpush(vars,(ncelem)var);
}
/* If we cannot constrain, then pull in everything */
newconstraint = createncconstraint();
if(FLAGSET(drno->dap.controls,NCF_UNCONSTRAINABLE)) {
newconstraint->projections = NULL;
newconstraint->selections= NULL;
} else { /* Construct the projections for this set of vars */
/* Construct the projections for this set of vars */
/* Initially, the constraints are same as the merged constraints */
newconstraint->projections = cloneCRCprojections(constraint->projections);
crrestrictprojection3(vars,newconstraint->projections);
/* similar for selections */
newconstraint->selections = clonencselections(constraint->selections);
}
ncstat = crbuildcachenode3(&drno->dap,newconstraint,vars,&cache,0);
if(ncstat) goto done;
if(FLAGSET(drno->dap.controls,NCF_SHOWFETCH)) {
/* Log the set of prefetch variables */
NCbytes* buf = ncbytesnew();
ncbytescat(buf,"prefetch.vars: ");
for(i=0;i<nclistlength(vars);i++) {
CDFnode* var = (CDFnode*)nclistget(vars,i);
ncbytescat(buf," ");
ncbytescat(buf,makesimplepathstring3(var));
}
ncbytescat(buf,"\n");
oc_log(OCLOGNOTE,ncbytescontents(buf));
ncbytesfree(buf);
}
done:
if(ncstat) {
freenccachenode(&drno->dap,cache);
}
return THROW(ncstat);
}
#ifdef IGNORE
/* Based on the tactic, determine the set of variables to add */
static void
crcomputevarset(NCCR* drno, Getvara* getvar, NClist* varlist)
{
int i;
nclistclear(varlist);
for(i=0;i<nclistlength(drno->dap.cdf.varnodes);i++) {
CDFnode* var = (CDFnode*)nclistget(drno->dap.cdf.varnodes,i);
#ifdef IGNORE
int ok = 1;
for(j=0;j<nclistlength(var->array.ncdimensions);j++) {
CDFnode* dim = (CDFnode*)nclistget(var->array.ncdimensions,j);
if(dim->dim.declsize == NC_UNLIMITED) {ok = 0; break;}
}
if(!ok) continue;
#endif
switch (getvar->tactic->tactic) {
case tactic_all: /* add all visible variables */
nclistpush(varlist,(ncelem)var);
break;
case tactic_partial: /* add only small variables + target */
if(var->estimatedsize < drno->dap.cdf.smallsizelimit
|| getvar->target == var) {
nclistpush(varlist,(ncelem)var);
}
break;
case tactic_var: /* add only target var */
if(getvar->target == var) nclistpush(varlist,(ncelem)var);
break;
default: break;
}
}
}
#endif

View File

@ -1,108 +0,0 @@
/*********************************************************************
* Copyright 1993, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
* $Header: /upc/share/CVS/netcdf-3/libncconstraints/ncconstraints.h,v 1.40 2010/05/30 19:45:52 dmh Exp $
*********************************************************************/
#ifndef NCCONSTRAINTS_H
#define NCCONSTRAINTS_H 1
typedef enum NCsort {
NS_NIL=0,
NS_EQ=1,NS_NEQ=2,NS_GE=3,NS_GT=4,NS_LT=5,NS_LE=6,NS_RE=7,
NS_STR=8,NS_INT=9,NS_FLOAT=10,
NS_VAR=11,NS_FCN=12,NS_CONST=13,
NS_SELECT=14, NS_PROJECT=15,
NS_SEGMENT=16, NS_SLICE=17,
NS_CONSTRAINT=18,
NS_VALUE=19
} NCsort;
/* Must match NCsort */
#define OPSTRINGS \
{"?","=","!=",">=",">","<=","<","=~","?","?","?","?","?","?","?","?","?","?","?"}
/* Provide a universal cast type */
typedef struct NCany {
NCsort sort;
} NCany;
/*
Store the relevant parameters for accessing
data for a particular variable
Break up the startp, countp, stridep into slices
to facilitate the odometer walk
*/
typedef struct NCslice {
NCsort sort;
size_t first;
size_t count;
size_t length; /* count*stride */
size_t stride;
size_t stop; /* == first + count*/
size_t declsize; /* from defining dimension, if any.*/
} NCslice;
typedef struct NCsegment {
NCsort sort;
char* name;
struct CDFnode* node;
int slicesdefined; /* do we know yet if this has defined slices */
unsigned int slicerank; /* Note: this is the rank as shown in the
projection; may be less than node->array.rank */
NCslice slices[NC_MAX_VAR_DIMS];
} NCsegment;
typedef struct NCfcn {
NCsort sort;
char* name;
NClist* args;
} NCfcn;
typedef struct NCvar {
NCsort sort;
NClist* segments;
struct CDFnode* node;
/* Following duplicate info inferrable from the segments */
struct CDFnode* leaf;
} NCvar;
typedef struct NCconstant {
NCsort sort;
NCsort discrim;
char* text;
long long intvalue;
double floatvalue;
} NCconstant;
typedef struct NCvalue {
NCsort sort;
NCsort discrim;
NCconstant* constant;
NCvar* var;
NCfcn* fcn;
} NCvalue;
typedef struct NCselection {
NCsort sort;
NCsort operator;
NCvalue* lhs;
NClist* rhs;
} NCselection;
typedef struct NCprojection {
NCsort sort;
NCsort discrim;
NCvar* var;
NCfcn* fcn;
} NCprojection;
typedef struct NCconstraint {
NCsort sort;
NClist* projections;
NClist* selections;
} NCconstraint;
#endif /*NCCONSTRAINTS_H*/

View File

@ -13,6 +13,7 @@
#include "nclist.h"
#include "ncbytes.h"
#include "nclog.h"
#include "netcdf.h"
#include "ast.h"
@ -33,6 +34,17 @@ static void annotate(Group*, CRnode*, Sort, NClist*);
static void computepathname(CRnode* leaf);
static char* getname(CRnode* node);
static int skiptoheader(bytes_t* packet, size_t* offsetp);
/**************************************************/
/* Define cdmremote magic numbers */
#define MAGIC_START "\x43\x44\x46\x53"
#define MAGIC_END "\xed\xed\xde\xde"
#define MAGIC_HEADER "\xad\xec\xce\xda"
#define MAGIC_DATA "\xab\xec\xce\xba"
#define MAGIC_ERR "\xab\xad\xba\xda"
int
nccr_cvtasterr(ast_err err)
{
@ -408,3 +420,36 @@ nccr_deref_dimensions(NClist* nodes)
}
nclistfree(replaced);
}
static int
skiptoheader(bytes_t* packet, size_t* offsetp)
{
int status = NC_NOERR;
unsigned long long vlen;
size_t size,offset;
/* Check the structure of the resulting data */
if(packet->nbytes < (strlen(MAGIC_HEADER) + strlen(MAGIC_HEADER))) {
nclog(NCLOGERR,"Curl data too short: %d\n",packet->nbytes);
status = NC_ECURL;
goto done;
}
if(memcmp(packet->bytes,MAGIC_HEADER,strlen(MAGIC_HEADER)) != 0) {
nclog(NCLOGERR,"MAGIC_HEADER missing\n");
status = NC_ECURL;
goto done;
}
offset = strlen(MAGIC_HEADER);
/* Extract the proposed count as a varint */
vlen = varint_decode(10,packet->bytes+offset,&size);
offset += size;
if(vlen != (packet->nbytes-offset)) {
nclog(NCLOGERR,"Curl data size mismatch\n");
status = NC_ECURL;
goto done;
}
if(offsetp) *offsetp = offset;
done:
return status;
}

View File

@ -34,8 +34,8 @@ ${top_builddir}/libsrc/libnetcdf3.la
# netcdf3 + dap
if USE_DAP
AM_CPPFLAGS += -I${top_srcdir}/libncdap3 -I${top_srcdir}/oc
libnetcdf_la_LIBADD += ${top_builddir}/libncdap3/libncdap3.la
AM_CPPFLAGS += -I${top_srcdir}/libdap2 -I${top_srcdir}/oc
libnetcdf_la_LIBADD += ${top_builddir}/libdap2/libdap2.la
libnetcdf_la_LIBADD += ${top_builddir}/oc/liboc.la
endif # USE_DAP
@ -45,11 +45,6 @@ if USE_NETCDF4
AM_CPPFLAGS += -I${top_srcdir}/libsrc4
libnetcdf_la_LIBADD += ${top_builddir}/libsrc4/libnetcdf4.la
# netcdf4+dap
if USE_DAP
libnetcdf_la_LIBADD += ${top_builddir}/libncdap4/libncdap4.la
endif # USE_DAP
# netcdf4+cdmremote
if BUILD_CDMREMOTE
libnetcdf_la_LIBADD += ${top_builddir}/libcdmr/libnccr.la

View File

@ -47,8 +47,7 @@ daputil.h \
dapdebug.h \
dapdump.h \
dceconstraints.h \
dcetab.h dceparselex.h \
ceconstraints.h
dcetab.h dceparselex.h
if BUILD_DAP

View File

@ -1,17 +1,15 @@
/*********************************************************************
* Copyright 1993, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
* $Header: /upc/share/CVS/netcdf-3/libncdap3/dapodom.h,v 1.10 2010/05/27 21:34:08 dmh Exp $
* $Header$
*********************************************************************/
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
See the COPYRIGHT file for more information. */
#ifndef DAPODOM_H
#define DAPODOM_H 1
typedef struct Dapodometer {
int rank;
DCEslice slices[NC_MAX_VAR_DIMS];
DCEslice slices[NC_MAX_VAR_DIMS];
size_t index[NC_MAX_VAR_DIMS];
} Dapodometer;

View File

@ -9,18 +9,16 @@
#include "ceconstraints.h"
#ifndef NC_MAX_VAR_DIMS
#define NC_MAX_VAR_DIMS 1024
#endif
/* Provide a universal cast type containing common fields */
struct CDFnode; /* Forward */
/* Define the common "supertype */
typedef struct DCEnode {
CEsort sort;
} DCEnode;
/* The slice structure is assumed common to all uses */
typedef struct DCEslice {
DCEnode node;
size_t first;