diff --git a/libdap2/env b/libdap2/env index 01b0fb64d..66cdaed86 100644 --- a/libdap2/env +++ b/libdap2/env @@ -10,17 +10,7 @@ PROG="$TOP/ncdump/ncdump" P=`pwd` -#T="1990-S1700101.HDF.WVC_Lat" -T="synth10" - -F="file://$TOP/ncdap_test/testdata3/$T" -#F="http://motherlode.ucar.edu:8081/dts/$T?f64" -#F="http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20120801/gfs_hd_00z" -#F="http://hycom.coaps.fsu.edu/thredds/dodsC/atl_ops" -#F="http://testbedapps-dev.sura.org/thredds/dodsC/auto/in.usf.fvcom.ike.ultralite.vardrag.nowave.2d" -#F="http://motherlode.ucar.edu:8081/dts/test.06" -#F="http://motherlode.ucar.edu:8081/thredds/dodsC/testdods/nametest3.nc" -#F="http://ingrid.ldeo.columbia.edu/SOURCES/.USTOPO/dods" +F="http://motherlode.ucar.edu:9080/thredds/dodsC/grib/NCEP/NAM/CONUS_12km/best" #CON="OneD.amp,TwoD.amp,ThreeD.amp" @@ -104,6 +94,14 @@ F="http://motherlode.ucar.edu:8080/thredds/dodsC/station/metar/Surface_METAR_201 CON="weather[0:10]" F="http://nomad1.ncep.noaa.gov:9090/dods/reanalyses/reanalysis-1/6hr/pgb/pgb" VAR=hgtprs +F="file://$TOP/ncdap_test/testdata3/$T" +#F="http://motherlode.ucar.edu:8081/dts/$T?f64" +#F="http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20120801/gfs_hd_00z" +#F="http://hycom.coaps.fsu.edu/thredds/dodsC/atl_ops" +#F="http://testbedapps-dev.sura.org/thredds/dodsC/auto/in.usf.fvcom.ike.ultralite.vardrag.nowave.2d" +#F="http://motherlode.ucar.edu:8081/dts/test.06" +#F="http://motherlode.ucar.edu:8081/thredds/dodsC/testdods/nametest3.nc" +#F="http://ingrid.ldeo.columbia.edu/SOURCES/.USTOPO/dods" fi diff --git a/libdispatch/nclog.c b/libdispatch/nclog.c index babb217bf..6bb5f214a 100644 --- a/libdispatch/nclog.c +++ b/libdispatch/nclog.c @@ -43,13 +43,16 @@ static char* nctagname(int tag); void ncloginit(void) { - const char* file = getenv(NCENVFLAG); + const char* file; + if(nclogginginitialized) + return; nclogginginitialized = 1; ncsetlogging(0); nclogfile = NULL; nclogstream = NULL; /* Use environment variables to preset nclogging state*/ /* I hope this is portable*/ + file = getenv(NCENVFLAG); if(file != NULL && strlen(file) > 0) { if(nclogopen(file)) { ncsetlogging(1); diff --git a/oc2/oc.c b/oc2/oc.c index ab27a2d27..3b2437e7d 100644 --- a/oc2/oc.c +++ b/oc2/oc.c @@ -554,7 +554,6 @@ oc_dds_fieldbyname(OCobject link, OCobject ddsnode, const char* name, OCobject* size_t count,i; OCVERIFY(OC_Node,ddsnode); OCDEREF(OCnode*,node,ddsnode); - if(!iscontainer(node->octype)) return OC_EBADTYPE; diff --git a/oc2/ocinternal.c b/oc2/ocinternal.c index 28d4b8118..2891ea5ac 100644 --- a/oc2/ocinternal.c +++ b/oc2/ocinternal.c @@ -31,6 +31,10 @@ #define TMPPATH2 "./" #endif +#define CLBRACE '{' +#define CRBRACE '}' + + /* Define default rc files and aliases*/ static char* rcfilenames[4] = {".daprc",".dodsrc",".ocrc",NULL}; @@ -39,6 +43,7 @@ static int ocextractddsinfile(OCstate*,OCtree*,int); static char* constraintescape(const char* url); static OCerror createtempfile(OCstate*,OCtree*); static int createtempfile1(char*,char**); +static int dataError(XXDR* xdrs, OCstate*); static void ocsetcurlproperties(OCstate*); @@ -299,6 +304,17 @@ fprintf(stderr,"ocfetch.datadds.memory: datasize=%lu bod=%lu\n", = xxdr_memcreate(tree->data.memory,tree->data.datasize,tree->data.bod); } MEMCHECK(tree->data.xdrs,OC_ENOMEM); + /* Do a quick check to see if server returned an ERROR {} + at the beginning of the data + */ + if(dataError(tree->data.xdrs,state)) { + stat = OC_EDATADDS; + oclog(OCLOGERR,"oc_open: server error retrieving url: code=%s message=\"%s\"", + state->error.code, + (state->error.message?state->error.message:"")); + goto fail; + } + /* Compile the data into a more accessible format */ stat = occompile(state,tree->root); if(stat != OC_NOERR) @@ -589,3 +605,43 @@ ocsetuseragent(OCstate* state, const char* agent) return OC_ENOMEM; return OC_NOERR; } + +static char* ERROR_TAG = "Error "; + +static int +dataError(XXDR* xdrs, OCstate* state) +{ + int depth; + off_t ckp,avail,i; + char* errmsg; + char errortext[16]; /* bigger thant |ERROR_TAG|*/ + avail = xxdr_getavail(xdrs); + if(avail < strlen(ERROR_TAG)) + return 0; /* assume it is ok */ + ckp = xxdr_getpos(xdrs); + /* Read enough characters to test for 'ERROR ' */ + errortext[0] = '\0'; + xxdr_getbytes(xdrs,errortext,(off_t)strlen(ERROR_TAG)); + if(ocstrncmp(errortext,ERROR_TAG,strlen(ERROR_TAG)) != 0) + return 0; /* not an immediate error */ + /* Try to locate the whole error body */ + xxdr_setpos(xdrs,ckp); + for(depth=0,i=0;ierror.message = errmsg; + state->error.code = strdup("?"); + state->error.httpcode = 404; + xxdr_setpos(xdrs,ckp); + return 1; +} diff --git a/oc2/oclog.c b/oc2/oclog.c index cbb2f6ddc..5cd4e3f84 100644 --- a/oc2/oclog.c +++ b/oc2/oclog.c @@ -45,8 +45,11 @@ static char* octagname(int tag); void ocloginit(void) { - const char* file = getenv(OCENVFLAG); + const char* file; + if(oclogginginitialized) + return; oclogginginitialized = 1; + file = getenv(OCENVFLAG); ocsetlogging(0); oclogfile = NULL; oclogstream = NULL; diff --git a/oc2/ocutil.c b/oc2/ocutil.c index 1cbc203ac..42854e916 100644 --- a/oc2/ocutil.c +++ b/oc2/ocutil.c @@ -27,7 +27,8 @@ ocstrndup(const char* s, size_t len) return dup; } -/* Do not trust strncmp semantics */ +/* Do not trust strncmp semantics; this one + compares upto len chars or to null terminators */ int ocstrncmp(const char* s1, const char* s2, size_t len) {