As a result of changes I made to

url parameter handling, the parameter
lookup code was ignoring parameters
because I was giving it a url stripped
of parameters instead of the one with
parameters.

This code change fixes the parameter processing
so it again used the correct url.

reference:
docs/OPeNDAP.dox#section Defined Client Parameters
This commit is contained in:
Dennis Heimbigner 2017-11-01 19:48:51 -06:00
parent 2425d6610e
commit f827cf13f2
6 changed files with 23 additions and 126 deletions

View File

@ -1199,6 +1199,15 @@ constrainable(NCURI* durl)
return 0;
}
static const char*
paramlookup(NCDAPCOMMON* state, const char* key)
{
const char* value = NULL;
if(state == NULL || key == NULL || state->oc.url == NULL) return NULL;
value = ncurilookup(state->oc.url,key);
return value;
}
/* Note: this routine only applies some common
client parameters, other routines may apply
specific ones.
@ -1219,17 +1228,17 @@ applyclientparams(NCDAPCOMMON* nccomm)
ASSERT(nccomm->oc.url != NULL);
nccomm->cdf.cache->cachelimit = DFALTCACHELIMIT;
value = oc_clientparam_get(conn,"cachelimit");
value = paramlookup(nccomm,"cachelimit");
limit = getlimitnumber(value);
if(limit > 0) nccomm->cdf.cache->cachelimit = limit;
nccomm->cdf.fetchlimit = DFALTFETCHLIMIT;
value = oc_clientparam_get(conn,"fetchlimit");
value = paramlookup(nccomm,"fetchlimit");
limit = getlimitnumber(value);
if(limit > 0) nccomm->cdf.fetchlimit = limit;
nccomm->cdf.smallsizelimit = DFALTSMALLLIMIT;
value = oc_clientparam_get(conn,"smallsizelimit");
value = paramlookup(nccomm,"smallsizelimit");
limit = getlimitnumber(value);
if(limit > 0) nccomm->cdf.smallsizelimit = limit;
@ -1241,23 +1250,23 @@ applyclientparams(NCDAPCOMMON* nccomm)
}
}
#endif
value = oc_clientparam_get(conn,"cachecount");
value = paramlookup(nccomm,"cachecount");
limit = getlimitnumber(value);
if(limit > 0) nccomm->cdf.cache->cachecount = limit;
/* Ignore limit if not caching */
if(!FLAGSET(nccomm->controls,NCF_CACHE))
nccomm->cdf.cache->cachecount = 0;
if(oc_clientparam_get(conn,"nolimit") != NULL)
if(paramlookup(nccomm,"nolimit") != NULL)
dfaltseqlim = 0;
value = oc_clientparam_get(conn,"limit");
value = paramlookup(nccomm,"limit");
if(value != NULL && strlen(value) != 0) {
if(sscanf(value,"%d",&len) && len > 0) dfaltseqlim = len;
}
nccomm->cdf.defaultsequencelimit = dfaltseqlim;
/* allow embedded _ */
value = oc_clientparam_get(conn,"stringlength");
value = paramlookup(nccomm,"stringlength");
if(value != NULL && strlen(value) != 0) {
if(sscanf(value,"%d",&len) && len > 0) dfaltstrlen = len;
}
@ -1272,7 +1281,7 @@ applyclientparams(NCDAPCOMMON* nccomm)
pathstr = makeocpathstring(conn,var->ocnode,".");
strncat(tmpname,pathstr,NC_MAX_NAME);
nullfree(pathstr);
value = oc_clientparam_get(conn,tmpname);
value = paramlookup(nccomm,tmpname);
if(value != NULL && strlen(value) != 0) {
if(sscanf(value,"%d",&len) && len > 0) var->maxstringlength = len;
}
@ -1285,11 +1294,11 @@ applyclientparams(NCDAPCOMMON* nccomm)
strcpy(tmpname,"nolimit_");
pathstr = makeocpathstring(conn,var->ocnode,".");
strncat(tmpname,pathstr,NC_MAX_NAME);
if(oc_clientparam_get(conn,tmpname) != NULL)
if(paramlookup(nccomm,tmpname) != NULL)
var->sequencelimit = 0;
strcpy(tmpname,"limit_");
strncat(tmpname,pathstr,NC_MAX_NAME);
value = oc_clientparam_get(conn,tmpname);
value = paramlookup(nccomm,tmpname);
if(value != NULL && strlen(value) != 0) {
if(sscanf(value,"%d",&len) && len > 0)
var->sequencelimit = len;
@ -1298,7 +1307,7 @@ applyclientparams(NCDAPCOMMON* nccomm)
}
/* test for the appropriate fetch flags */
value = oc_clientparam_get(conn,"fetch");
value = paramlookup(nccomm,"fetch");
if(value != NULL && strlen(value) > 0) {
if(value[0] == 'd' || value[0] == 'D') {
SETFLAG(nccomm->controls,NCF_ONDISK);
@ -1306,7 +1315,7 @@ applyclientparams(NCDAPCOMMON* nccomm)
}
/* test for the force-whole-var flag */
value = oc_clientparam_get(conn,"wholevar");
value = paramlookup(nccomm,"wholevar");
if(value != NULL) {
SETFLAG(nccomm->controls,NCF_WHOLEVAR);
}

View File

@ -13,7 +13,7 @@ AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/include
# OC Sources; include the dapy.[ch] to avoid the need for bison by user
SRC=oc.c \
daplex.c dapparse.c dapy.c \
occlientparams.c occompile.c occurlfunctions.c \
occompile.c occurlfunctions.c \
ocdata.c ocdebug.c ocdump.c \
ocinternal.c ocnode.c \
ochttp.c \
@ -23,7 +23,7 @@ xxdr.c
HDRS=oc.h ocx.h \
dapparselex.h dapy.h \
occlientparams.h occompile.h occonstraints.h occurlfunctions.h \
occompile.h occonstraints.h occurlfunctions.h \
ocdata.h ocdatatypes.h ocdebug.h ocdump.h \
ocinternal.h ocnode.h \
ochttp.h ocread.h ocutil.h \

View File

@ -11,7 +11,6 @@
#include "ocdebug.h"
#include "ocdump.h"
#include "nclog.h"
#include "occlientparams.h"
#include "occurlfunctions.h"
#include "ochttp.h"
#include "ncwinpath.h"
@ -1713,76 +1712,6 @@ oc_errstring(OCerror err)
return ocerrstring(err);
}
/*!
Each OClink object maintains a table of
(name,value) pairs, called client parameters.
It is initialized from any such parameters
specified in the URL given as argument to
oc_open().
\param[in] link The link through which the server is accessed.
\param[in] param The name of the parameter whose value is desired.
\return The corresponding value, or NULL if parameter name is not in the table.
*/
const char*
oc_clientparam_get(OCobject link, const char* param)
{
OCstate* state;
OCVERIFYX(OC_State,link,NULL);
OCDEREF(OCstate*,state,link);
return ocparamlookup(state,param);
}
#ifdef OCIGNORE
/* Delete client parameter
return value:
OC_NOERR => defined; deletion performed
OC_EINVAL => not already defined
*/
OCerror
oc_clientparam_delete(OCobject link, const char* param)
{
OCstate* state;
OCVERIFY(OC_State,link);
OCDEREF(OCstate*,state,link);
return OCTHROW(ocparamdelete(state->clientparams,param));
}
/* Insert client parameter
return value:
OC_NOERR => not already define; insertion performed
OC_EINVAL => already defined
*/
OCerror
oc_clientparam_insert(OCobject link, const char* param, const char* value)
{
OCstate* state;
OCVERIFY(OC_State,link);
OCDEREF(OCstate*,state,link);
state->clientparams = dapparaminsert(state->clientparams,param,value);
return OCTHROW(OC_NOERR);
}
/* Replace client parameter
return value:
OC_NOERR => already define; replacement performed
OC_EINVAL => not already defined
*/
OCerror
oc_clientparam_replace(OCobject link, const char* param, const char* value)
{
OCstate* state;
OCVERIFY(OC_State,link);
OCDEREF(OCstate*,state,link);
return dapparamreplace(state->clientparams,param,value);
}
#endif
/**************************************************/

View File

@ -1,29 +0,0 @@
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
See the COPYRIGHT file for more information. */
#include "config.h"
#include "ocinternal.h"
#include "ocdebug.h"
#define LBRACKET '['
#define RBRACKET ']'
const char*
ocparamlookup(OCstate* state, const char* key)
{
const char* value = NULL;
if(state == NULL || key == NULL || state->uri == NULL) return NULL;
value = ncurilookup(state->uri,key);
return value;
}
#if 0
int
ocparamset(OCstate* state, const char* params)
{
int i;
i = ncurisetparams(state->uri,params);
return i?OC_NOERR:OC_EBADURL;
}
#endif

View File

@ -1,11 +0,0 @@
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
See the COPYRIGHT file for more information. */
#ifndef OCCLIENTPARAMS_H
#define OCCLIENTPARAMS_H
extern NClist* ocparamdecode(OCstate*);
extern const char* ocparamlookup(OCstate*, const char*);
extern void ocparamset(OCstate*,const char*);
#endif /*OCCLIENTPARAMS_H*/

View File

@ -24,7 +24,6 @@
#include "ocinternal.h"
#include "ocdebug.h"
#include "occlientparams.h"
#include "occurlfunctions.h"
#include "ochttp.h"
#include "ocread.h"