1. synch with oc

2. replace all occurrences of
   'template' with 'pattern'
   since template is reserved in windows.
This commit is contained in:
dmh 2015-01-15 14:19:51 -07:00
parent 2e89b50641
commit 65f78d6a8b
15 changed files with 183 additions and 183 deletions

2
cf
View File

@ -25,7 +25,7 @@ fi
CFLAGS=""
#CFLAGS="-Wall -Wno-unused-variable -Wno-unused-parameter -Wconversion ${CFLAGS}"
CFLAGS="-Wall -Wno-unused-variable ${CFLAGS}"
CFLAGS="-Wall ${CFLAGS}"
#CFLAGS="-Wconversion"
stddir="/usr/local"

View File

@ -384,15 +384,15 @@ Input is
*/
NCerror
restruct(NCDAPCOMMON* ncc, CDFnode* ddsroot, CDFnode* templateroot, NClist* projections)
restruct(NCDAPCOMMON* ncc, CDFnode* ddsroot, CDFnode* patternroot, NClist* projections)
{
NCerror ncstat = NC_NOERR;
NClist* repairs = nclistnew();
/* The current restruct assumes that the ddsroot tree
has missing grids compared to the template.
has missing grids compared to the pattern.
It is also assumed that order of the nodes
in the ddsroot is the same as in the template.
in the ddsroot is the same as in the pattern.
*/
if(ddsroot->tree->restructed) {
nclistfree(repairs);
@ -401,13 +401,13 @@ restruct(NCDAPCOMMON* ncc, CDFnode* ddsroot, CDFnode* templateroot, NClist* proj
#ifdef DEBUG
fprintf(stderr,"restruct: ddsroot=%s\n",dumptree(ddsroot));
fprintf(stderr,"restruct: templateroot=%s\n",dumptree(templateroot));
fprintf(stderr,"restruct: patternroot=%s\n",dumptree(patternroot));
#endif
/* Match roots */
if(!simplenodematch(ddsroot,templateroot))
if(!simplenodematch(ddsroot,patternroot))
ncstat = NC_EDATADDS;
else if(!restructr(ncc,ddsroot,templateroot,repairs))
else if(!restructr(ncc,ddsroot,patternroot,repairs))
ncstat = NC_EDATADDS;
else if(nclistlength(repairs) > 0) {
/* Do the repairs */
@ -422,8 +422,8 @@ fprintf(stderr,"restruct: templateroot=%s\n",dumptree(templateroot));
/*
Locate nodes in the tree rooted at node
that correspond to a single grid field in the template
when the template is a grid.
that correspond to a single grid field in the pattern
when the pattern is a grid.
Wrap that grid field in a synthesized structure.
The key thing to look for is the case where
@ -433,17 +433,17 @@ we expected a grid.
*/
static int
restructr(NCDAPCOMMON* ncc, CDFnode* dxdparent, CDFnode* templateparent, NClist* repairlist)
restructr(NCDAPCOMMON* ncc, CDFnode* dxdparent, CDFnode* patternparent, NClist* repairlist)
{
int index, i, j, match;
#ifdef DEBUG
fprintf(stderr,"restruct: matched: %s -> %s\n",
ocfqn(dxdparent->ocnode),ocfqn(templateparent->ocnode));
ocfqn(dxdparent->ocnode),ocfqn(patternparent->ocnode));
#endif
/* walk each node child and locate its match
in the template's children; recurse on matches,
in the pattern's children; recurse on matches,
non-matches may be nodes needing wrapping.
*/
@ -451,11 +451,11 @@ ocfqn(dxdparent->ocnode),ocfqn(templateparent->ocnode));
CDFnode* dxdsubnode = (CDFnode*)nclistget(dxdparent->subnodes,index);
CDFnode* matchnode = NULL;
/* Look for a matching template node with same ocname */
for(i=0;i<nclistlength(templateparent->subnodes);i++) {
CDFnode* templatesubnode = (CDFnode*)nclistget(templateparent->subnodes,i);
if(strcmp(dxdsubnode->ocname,templatesubnode->ocname) == 0) {
matchnode = templatesubnode;
/* Look for a matching pattern node with same ocname */
for(i=0;i<nclistlength(patternparent->subnodes);i++) {
CDFnode* patternsubnode = (CDFnode*)nclistget(patternparent->subnodes,i);
if(strcmp(dxdsubnode->ocname,patternsubnode->ocname) == 0) {
matchnode = patternsubnode;
break;
}
}
@ -465,7 +465,7 @@ ocfqn(dxdsubnode->ocnode),ocfqn(matchnode->ocnode));
#endif
if(simplenodematch(dxdsubnode,matchnode)) {
/* this subnode of the node matches the corresponding
node of the template, so it is ok =>
node of the pattern, so it is ok =>
recurse looking for nested mis-matches
*/
if(!restructr(ncc,dxdsubnode,matchnode,repairlist))
@ -475,11 +475,11 @@ ocfqn(dxdsubnode->ocnode),ocfqn(matchnode->ocnode));
at all the grids to see if this node matches a field
in one of the grids
*/
for(match=0,i=0;!match && i<nclistlength(templateparent->subnodes);i++) {
CDFnode* subtemp = (CDFnode*)nclistget(templateparent->subnodes,i);
for(match=0,i=0;!match && i<nclistlength(patternparent->subnodes);i++) {
CDFnode* subtemp = (CDFnode*)nclistget(patternparent->subnodes,i);
if(subtemp->nctype == NC_Grid) {
/* look inside */
for(j=0;j<nclistlength(templateparent->subnodes);j++) {
for(j=0;j<nclistlength(patternparent->subnodes);j++) {
CDFnode* gridfield = (CDFnode*)nclistget(subtemp->subnodes,j);
if(simplenodematch(dxdsubnode,gridfield)) {
/* We need to do this repair */
@ -497,7 +497,7 @@ ocfqn(dxdsubnode->ocnode),ocfqn(matchnode->ocnode));
return 1; /* we matched everything at this level */
}
/* Wrap the node wrt the template grid or template struct */
/* Wrap the node wrt the pattern grid or pattern struct */
static NCerror
repairgrids(NCDAPCOMMON* ncc, NClist* repairlist)
@ -507,14 +507,14 @@ repairgrids(NCDAPCOMMON* ncc, NClist* repairlist)
assert(nclistlength(repairlist) % 2 == 0);
for(i=0;i<nclistlength(repairlist);i+=2) {
CDFnode* node = (CDFnode*)nclistget(repairlist,i);
CDFnode* template = (CDFnode*)nclistget(repairlist,i+1);
CDFnode* pattern = (CDFnode*)nclistget(repairlist,i+1);
int index = findin(node->container,node);
int tindex = findin(template->container,template);
int tindex = findin(pattern->container,pattern);
ncstat = structwrap(ncc, node,node->container,index,
template->container,tindex);
pattern->container,tindex);
#ifdef DEBUG
fprintf(stderr,"repairgrids: %s -> %s\n",
ocfqn(node->ocnode),ocfqn(template->ocnode));
ocfqn(node->ocnode),ocfqn(pattern->ocnode));
#endif
}
@ -523,12 +523,12 @@ ocfqn(node->ocnode),ocfqn(template->ocnode));
static NCerror
structwrap(NCDAPCOMMON* ncc, CDFnode* node, CDFnode* parent, int parentindex,
CDFnode* templategrid, int gridindex)
CDFnode* patterngrid, int gridindex)
{
CDFnode* newstruct;
ASSERT((templategrid->nctype == NC_Grid));
newstruct = makenewstruct(ncc, node,templategrid);
ASSERT((patterngrid->nctype == NC_Grid));
newstruct = makenewstruct(ncc, node,patterngrid);
if(newstruct == NULL) {return THROW(NC_ENOMEM);}
/* replace the node with the new structure
@ -558,15 +558,15 @@ findin(CDFnode* parent, CDFnode* child)
*/
static CDFnode*
makenewstruct(NCDAPCOMMON* ncc, CDFnode* node, CDFnode* templatenode)
makenewstruct(NCDAPCOMMON* ncc, CDFnode* node, CDFnode* patternnode)
{
CDFnode* newstruct = makecdfnode(ncc,templatenode->ocname,OC_Structure,
templatenode->ocnode, node->container);
CDFnode* newstruct = makecdfnode(ncc,patternnode->ocname,OC_Structure,
patternnode->ocnode, node->container);
if(newstruct == NULL) return NULL;
newstruct->nc_virtual = 1;
newstruct->ncbasename = nulldup(templatenode->ncbasename);
newstruct->ncbasename = nulldup(patternnode->ncbasename);
newstruct->subnodes = nclistnew();
newstruct->template = templatenode;
newstruct->pattern = patternnode;
node->container = newstruct;
nclistpush(newstruct->subnodes,(void*)node);
return newstruct;

View File

@ -39,7 +39,7 @@ static int extract(NCDAPCOMMON*, Getvara*, CDFnode*, DCEsegment*, size_t diminde
static int extractstring(NCDAPCOMMON*, Getvara*, CDFnode*, DCEsegment*, size_t dimindex, OClink, OCdatanode, struct NCMEMORY*);
static void freegetvara(Getvara* vara);
static NCerror makegetvar(NCDAPCOMMON*, CDFnode*, void*, nc_type, Getvara**);
static NCerror attachsubset(CDFnode* target, CDFnode* template);
static NCerror attachsubset(CDFnode* target, CDFnode* pattern);
/**************************************************/
/**
@ -1029,27 +1029,27 @@ unattach(CDFnode* root)
}
static void
setattach(CDFnode* target, CDFnode* template)
setattach(CDFnode* target, CDFnode* pattern)
{
target->attachment = template;
template->attachment = target;
target->attachment = pattern;
pattern->attachment = target;
/* Transfer important information */
target->externaltype = template->externaltype;
target->maxstringlength = template->maxstringlength;
target->sequencelimit = template->sequencelimit;
target->ncid = template->ncid;
target->externaltype = pattern->externaltype;
target->maxstringlength = pattern->maxstringlength;
target->sequencelimit = pattern->sequencelimit;
target->ncid = pattern->ncid;
/* also transfer libncdap4 info */
target->typeid = template->typeid;
target->typesize = template->typesize;
target->typeid = pattern->typeid;
target->typesize = pattern->typesize;
}
static NCerror
attachdims(CDFnode* xnode, CDFnode* template)
attachdims(CDFnode* xnode, CDFnode* pattern)
{
unsigned int i;
for(i=0;i<nclistlength(xnode->array.dimsetall);i++) {
CDFnode* xdim = (CDFnode*)nclistget(xnode->array.dimsetall,i);
CDFnode* tdim = (CDFnode*)nclistget(template->array.dimsetall,i);
CDFnode* tdim = (CDFnode*)nclistget(pattern->array.dimsetall,i);
setattach(xdim,tdim);
#ifdef DEBUG2
fprintf(stderr,"attachdim: %s->%s\n",xdim->ocname,tdim->ocname);
@ -1064,48 +1064,48 @@ It is assumed that both trees have been re-struct'ed if necessary.
*/
static NCerror
attachr(CDFnode* xnode, NClist* templatepath, int depth)
attachr(CDFnode* xnode, NClist* patternpath, int depth)
{
unsigned int i,plen,lastnode,gridable;
NCerror ncstat = NC_NOERR;
CDFnode* templatepathnode;
CDFnode* templatepathnext;
CDFnode* patternpathnode;
CDFnode* patternpathnext;
plen = nclistlength(templatepath);
plen = nclistlength(patternpath);
if(depth >= plen) {THROWCHK(ncstat=NC_EINVAL); goto done;}
lastnode = (depth == (plen-1));
templatepathnode = (CDFnode*)nclistget(templatepath,depth);
ASSERT((simplenodematch(xnode,templatepathnode)));
setattach(xnode,templatepathnode);
patternpathnode = (CDFnode*)nclistget(patternpath,depth);
ASSERT((simplenodematch(xnode,patternpathnode)));
setattach(xnode,patternpathnode);
#ifdef DEBUG2
fprintf(stderr,"attachnode: %s->%s\n",xnode->ocname,templatepathnode->ocname);
fprintf(stderr,"attachnode: %s->%s\n",xnode->ocname,patternpathnode->ocname);
#endif
if(lastnode) goto done; /* We have the match and are done */
if(nclistlength(xnode->array.dimsetall) > 0) {
attachdims(xnode,templatepathnode);
attachdims(xnode,patternpathnode);
}
ASSERT((!lastnode));
templatepathnext = (CDFnode*)nclistget(templatepath,depth+1);
patternpathnext = (CDFnode*)nclistget(patternpath,depth+1);
gridable = (templatepathnext->nctype == NC_Grid && depth+2 < plen);
gridable = (patternpathnext->nctype == NC_Grid && depth+2 < plen);
/* Try to find an xnode subnode that matches templatepathnext */
/* Try to find an xnode subnode that matches patternpathnext */
for(i=0;i<nclistlength(xnode->subnodes);i++) {
CDFnode* xsubnode = (CDFnode*)nclistget(xnode->subnodes,i);
if(simplenodematch(xsubnode,templatepathnext)) {
ncstat = attachr(xsubnode,templatepath,depth+1);
if(simplenodematch(xsubnode,patternpathnext)) {
ncstat = attachr(xsubnode,patternpath,depth+1);
if(ncstat) goto done;
} else if(gridable && xsubnode->nctype == NC_Atomic) {
/* grids may or may not appear in the datadds;
try to match the xnode subnodes against the parts of the grid
*/
CDFnode* templatepathnext2 = (CDFnode*)nclistget(templatepath,depth+2);
if(simplenodematch(xsubnode,templatepathnext2)) {
ncstat = attachr(xsubnode,templatepath,depth+2);
CDFnode* patternpathnext2 = (CDFnode*)nclistget(patternpath,depth+2);
if(simplenodematch(xsubnode,patternpathnext2)) {
ncstat = attachr(xsubnode,patternpath,depth+2);
if(ncstat) goto done;
}
}
@ -1115,49 +1115,49 @@ done:
}
NCerror
attach(CDFnode* xroot, CDFnode* template)
attach(CDFnode* xroot, CDFnode* pattern)
{
NCerror ncstat = NC_NOERR;
NClist* templatepath = nclistnew();
CDFnode* ddsroot = template->root;
NClist* patternpath = nclistnew();
CDFnode* ddsroot = pattern->root;
if(xroot->attachment) unattach(xroot);
if(ddsroot != NULL && ddsroot->attachment) unattach(ddsroot);
if(!simplenodematch(xroot,ddsroot))
{THROWCHK(ncstat=NC_EINVAL); goto done;}
collectnodepath(template,templatepath,WITHDATASET);
ncstat = attachr(xroot,templatepath,0);
collectnodepath(pattern,patternpath,WITHDATASET);
ncstat = attachr(xroot,patternpath,0);
done:
nclistfree(templatepath);
nclistfree(patternpath);
return ncstat;
}
static NCerror
attachsubsetr(CDFnode* target, CDFnode* template)
attachsubsetr(CDFnode* target, CDFnode* pattern)
{
unsigned int i;
NCerror ncstat = NC_NOERR;
int fieldindex;
#ifdef DEBUG2
fprintf(stderr,"attachsubsetr: attach: target=%s template=%s\n",
target->ocname,template->ocname);
fprintf(stderr,"attachsubsetr: attach: target=%s pattern=%s\n",
target->ocname,pattern->ocname);
#endif
ASSERT((nodematch(target,template)));
setattach(target,template);
ASSERT((nodematch(target,pattern)));
setattach(target,pattern);
/* Try to match target subnodes against template subnodes */
/* Try to match target subnodes against pattern subnodes */
fieldindex = 0;
for(fieldindex=0,i=0;i<nclistlength(template->subnodes) && fieldindex<nclistlength(target->subnodes);i++) {
CDFnode* templatesubnode = (CDFnode*)nclistget(template->subnodes,i);
for(fieldindex=0,i=0;i<nclistlength(pattern->subnodes) && fieldindex<nclistlength(target->subnodes);i++) {
CDFnode* patternsubnode = (CDFnode*)nclistget(pattern->subnodes,i);
CDFnode* targetsubnode = (CDFnode*)nclistget(target->subnodes,fieldindex);
if(nodematch(targetsubnode,templatesubnode)) {
if(nodematch(targetsubnode,patternsubnode)) {
#ifdef DEBUG2
fprintf(stderr,"attachsubsetr: match: %s :: %s\n",targetsubnode->ocname,templatesubnode->ocname);
fprintf(stderr,"attachsubsetr: match: %s :: %s\n",targetsubnode->ocname,patternsubnode->ocname);
#endif
ncstat = attachsubsetr(targetsubnode,templatesubnode);
ncstat = attachsubsetr(targetsubnode,patternsubnode);
if(ncstat) goto done;
fieldindex++;
}
@ -1168,23 +1168,23 @@ done:
/*
Match nodes in template tree to nodes in target tree;
template tree is typically a structural superset of target tree.
Match nodes in pattern tree to nodes in target tree;
pattern tree is typically a structural superset of target tree.
WARNING: Dimensions are not attached
*/
static NCerror
attachsubset(CDFnode* target, CDFnode* template)
attachsubset(CDFnode* target, CDFnode* pattern)
{
NCerror ncstat = NC_NOERR;
if(template == NULL) {THROWCHK(ncstat=NC_NOERR); goto done;}
if(!nodematch(target,template)) {THROWCHK(ncstat=NC_EINVAL); goto done;}
if(pattern == NULL) {THROWCHK(ncstat=NC_NOERR); goto done;}
if(!nodematch(target,pattern)) {THROWCHK(ncstat=NC_EINVAL); goto done;}
#ifdef DEBUG2
fprintf(stderr,"attachsubset: target=%s\n",dumptree(target));
fprintf(stderr,"attachsubset: template=%s\n",dumptree(template));
fprintf(stderr,"attachsubset: pattern=%s\n",dumptree(pattern));
#endif
ncstat = attachsubsetr(target,template);
ncstat = attachsubsetr(target,pattern);
done:
return ncstat;
}

View File

@ -266,13 +266,13 @@ typedef struct CDFnode {
unsigned long sequencelimit; /* 0=>unlimited */
BOOL usesequence; /* If this sequence is usable */
BOOL elided; /* 1 => node does not partipate in naming*/
struct CDFnode* basenode; /* derived tree map to template tree */
struct CDFnode* basenode; /* derived tree map to pattern tree */
BOOL invisible; /* 1 => do not show to user */
BOOL zerodim; /* 1 => node has a zero dimension */
/* These two flags track the effects on grids of constraints */
BOOL nc_virtual; /* node added by regrid */
struct CDFnode* attachment; /* DDS<->DATADDS cross link*/
struct CDFnode* template; /* temporary field for regridding */
struct CDFnode* pattern; /* temporary field for regridding */
/* Fields for use by libncdap4 */
NCtypesize typesize;
int typeid; /* when treating field as type */

View File

@ -44,7 +44,7 @@ static NCerror getseqdimsize(NCDAPCOMMON*, CDFnode* seq, size_t* sizep);
static NCerror makeseqdim(NCDAPCOMMON*, CDFnode* seq, size_t count, CDFnode** sqdimp);
static NCerror countsequence(NCDAPCOMMON*, CDFnode* xseq, size_t* sizep);
static NCerror freeNCDAPCOMMON(NCDAPCOMMON*);
static NCerror fetchtemplatemetadata(NCDAPCOMMON*);
static NCerror fetchpatternmetadata(NCDAPCOMMON*);
static size_t fieldindex(CDFnode* parent, CDFnode* child);
static NCerror computeseqcountconstraints(NCDAPCOMMON*, CDFnode*, NCbytes*);
static void computeseqcountconstraintsr(NCDAPCOMMON*, CDFnode*, CDFnode**);
@ -406,11 +406,11 @@ NCD2_open(const char * path, int mode,
}
/* fetch and build the unconstrained DDS for use as
template */
ncstat = fetchtemplatemetadata(dapcomm);
pattern */
ncstat = fetchpatternmetadata(dapcomm);
if(ncstat != NC_NOERR) goto done;
/* Operations on the template tree */
/* Operations on the pattern tree */
/* Accumulate useful nodes sets */
ncstat = computecdfnodesets(dapcomm,dapcomm->cdf.fullddsroot->tree);
@ -420,7 +420,7 @@ NCD2_open(const char * path, int mode,
ncstat = definedimsettrans(dapcomm,dapcomm->cdf.fullddsroot->tree);
if(ncstat) {THROWCHK(ncstat); goto done;}
/* Mark the nodes of the template that are eligible for prefetch */
/* Mark the nodes of the pattern that are eligible for prefetch */
ncstat = markprefetch(dapcomm);
/* fetch and build the constrained DDS */
@ -1942,7 +1942,7 @@ fprintf(stderr,"total estimatedsize = %lu\n",totalsize);
}
static NCerror
fetchtemplatemetadata(NCDAPCOMMON* dapcomm)
fetchpatternmetadata(NCDAPCOMMON* dapcomm)
{
NCerror ncstat = NC_NOERR;
OCerror ocstat = OC_NOERR;
@ -2002,7 +2002,7 @@ fetchtemplatemetadata(NCDAPCOMMON* dapcomm)
}
#ifdef DEBUG
fprintf(stderr,"full template:\n%s",dumptree(dapcomm->cdf.fullddsroot));
fprintf(stderr,"full pattern:\n%s",dumptree(dapcomm->cdf.fullddsroot));
#endif
done:

View File

@ -129,13 +129,13 @@ extern size_t dap_zero[NC_MAX_VAR_DIMS];
extern NCerror nc3d_open(const char* path, int mode, int* ncidp);
extern int nc3d_close(int ncid);
extern NCerror restruct(NCDAPCOMMON*, CDFnode* ddsroot, CDFnode* template, NClist*);
extern NCerror restruct(NCDAPCOMMON*, CDFnode* ddsroot, CDFnode* pattern, NClist*);
extern void setvisible(CDFnode* root, int visible);
extern NCerror mapnodes(CDFnode* dstroot, CDFnode* srcroot);
extern void unmap(CDFnode* root);
#if 0
extern NCerror fetchtemplatemetadata(NCDAPCOMMON* nccomm);
extern NCerror fetchpatternmetadata(NCDAPCOMMON* nccomm);
extern NCerror fetchconstrainedmetadata(NCDAPCOMMON* nccomm);
extern void applyclientparamcontrols(NCDAPCOMMON*);
extern NCerror suppressunusablevars(NCDAPCOMMON*);

View File

@ -1228,7 +1228,7 @@ oc_data_recordcount(OCobject link, OCobject datanode, size_t* countp)
}
/*!
Return the dds node that is the "template"
Return the dds node that is the "pattern"
for this data instance.
\param[in] link The link through which the server is accessed.
@ -1247,14 +1247,14 @@ oc_data_ddsnode(OCobject link, OCobject datanode, OCobject* nodep)
OCVERIFY(OC_Data,datanode);
OCDEREF(OCdata*,data,datanode);
OCASSERT(data->template != NULL);
OCASSERT(data->pattern != NULL);
if(nodep == NULL) ocerr = OC_EINVAL;
else *nodep = (OCobject)data->template;
else *nodep = (OCobject)data->pattern;
return OCTHROW(ocerr);
}
/*!
Return the OCtype of the ddsnode that is the "template"
Return the OCtype of the ddsnode that is the "pattern"
for this data instance. This is a convenience function
since it can be obtained using a combination of other
API procedures.
@ -1275,9 +1275,9 @@ oc_data_octype(OCobject link, OCobject datanode, OCtype* typep)
OCVERIFY(OC_Data,datanode);
OCDEREF(OCdata*,data,datanode);
OCASSERT(data->template != NULL);
OCASSERT(data->pattern != NULL);
if(typep == NULL) ocerr = OC_EINVAL;
else *typep = data->template->octype;
else *typep = data->pattern->octype;
return OCTHROW(ocerr);
}
@ -1368,7 +1368,7 @@ oc_data_read(OCobject link, OCobject datanode,
size_t memsize, void* memory)
{
OCdata* data;
OCnode* template;
OCnode* pattern;
size_t count, rank;
OCVERIFY(OC_Data,datanode);
@ -1381,8 +1381,8 @@ oc_data_read(OCobject link, OCobject datanode,
return OCTHROW(OCTHROW(OC_EINVALCOORDS));
/* Convert edges to a count */
template = data->template;
rank = template->array.rank;
pattern = data->pattern;
rank = pattern->array.rank;
count = octotaldimsize(rank,edges);
return OCTHROW(oc_data_readn(link,datanode,start,count,memsize,memory));
@ -1454,7 +1454,7 @@ oc_data_readn(OCobject link, OCobject datanode,
OCerror ocerr = OC_NOERR;
OCstate* state;
OCdata* data;
OCnode* template;
OCnode* pattern;
size_t rank,startpoint;
OCVERIFY(OC_State,link);
@ -1467,8 +1467,8 @@ oc_data_readn(OCobject link, OCobject datanode,
if(memory == NULL || memsize == 0)
return OCTHROW(OC_EINVAL);
template = data->template;
rank = template->array.rank;
pattern = data->pattern;
rank = pattern->array.rank;
if(rank == 0) {
startpoint = 0;
@ -1476,12 +1476,12 @@ oc_data_readn(OCobject link, OCobject datanode,
} else if(start == NULL) {
return OCTHROW(OCTHROW(OC_EINVALCOORDS));
} else {/* not scalar */
startpoint = ocarrayoffset(rank,template->array.sizes,start);
startpoint = ocarrayoffset(rank,pattern->array.sizes,start);
}
if(N > 0)
ocerr = ocdata_read(state,data,startpoint,N,memory,memsize);
if(ocerr == OC_EDATADDS)
ocdataddsmsg(state,template->tree);
ocdataddsmsg(state,pattern->tree);
return OCTHROW(OCTHROW(ocerr));
}

View File

@ -432,7 +432,7 @@ extern OCerror oc_data_readn(OClink, OCdatanode, size_t*, size_t, size_t, void*)
*/
extern OCerror oc_data_position(OClink, OCdatanode data, size_t* indices);
/* Return the template dds node for an data */
/* Return the pattern dds node for an data */
extern OCerror oc_data_ddsnode(OClink, OCdatanode data, OCddsnode*);
/* Return the octype of the data (convenience) */

View File

@ -16,7 +16,7 @@
#define TOPLEVEL 1
/* Forward */
static OCdata* newocdata(OCnode* oc_template);
static OCdata* newocdata(OCnode* pattern);
static size_t ocxdrsize(OCtype etype,int isscalar);
static OCerror occompile1(OCstate*, OCnode*, XXDR*, OCdata**);
static OCerror occompilerecord(OCstate*, OCnode*, XXDR*, OCdata**);
@ -218,7 +218,7 @@ occompilerecord(OCstate* state, OCnode* xnode, XXDR* xxdrs, OCdata** recordp)
OCdata* record = newocdata(xnode);/* create record record */
MEMFAIL(record);
fset(record->datamode,OCDT_RECORD);
record->template = xnode;
record->pattern = xnode;
/* capture the current record position */
record->xdroffset = xxdr_getpos(xxdrs);
/* Compile the fields of this record */
@ -240,7 +240,7 @@ occompilefields(OCstate* state, OCdata* data, XXDR* xxdrs, int istoplevel)
size_t i;
OCerror ocstat = OC_NOERR;
size_t nelements;
OCnode* xnode = data->template;
OCnode* xnode = data->pattern;
assert(data != NULL);
nelements = oclistlength(xnode->subnodes);
@ -291,7 +291,7 @@ occompileatomic(OCstate* state, OCdata* data, XXDR* xxdrs)
int i;
off_t nelements,xdrsize;
unsigned int xxdrcount;
OCnode* xnode = data->template;
OCnode* xnode = data->pattern;
int scalar = (xnode->array.rank == 0);
OCASSERT((xnode->octype == OC_Atomic));
@ -391,13 +391,13 @@ ocdata_free(OCstate* state, OCdata* data)
}
static OCdata*
newocdata(OCnode* template)
newocdata(OCnode* pattern)
{
OCdata* data = (OCdata*)calloc(1,sizeof(OCdata));
MEMCHECK(data,NULL);
data->header.magic = OCMAGIC;
data->header.occlass = OC_Data;
data->template = template;
data->pattern = pattern;
return data;
}

View File

@ -47,13 +47,13 @@ OCerror
ocdata_container(OCstate* state, OCdata* data, OCdata** containerp)
{
OCdata* container;
OCnode* template;
OCnode* pattern;
OCASSERT(state != NULL);
template = data->template;
pattern = data->pattern;
if(template->container == NULL)
if(pattern->container == NULL)
return OCTHROW(OC_EBADTYPE);
container = data->container;
@ -71,12 +71,12 @@ OCerror
ocdata_root(OCstate* state, OCdata* data, OCdata** rootp)
{
OCdata* root;
OCnode* template;
OCnode* pattern;
OCASSERT(state != NULL);
template = data->template;
root = template->tree->data.data;
pattern = data->pattern;
root = pattern->tree->data.data;
if(rootp) *rootp = root;
octrace("root", state, root);
@ -88,14 +88,14 @@ OCerror
ocdata_ithfield(OCstate* state, OCdata* container, size_t index, OCdata** fieldp)
{
OCdata* field;
OCnode* template;
OCnode* pattern;
OCASSERT(state != NULL);
OCASSERT(container != NULL);
template = container->template;
pattern = container->pattern;
if(!ociscontainer(template->octype))
if(!ociscontainer(pattern->octype))
return OCTHROW(OC_EBADTYPE);
/* Validate index */
@ -115,25 +115,25 @@ ocdata_ithelement(OCstate* state, OCdata* data, size_t* indices, OCdata** elemen
{
int stat = OC_NOERR;
OCdata* element;
OCnode* template;
OCnode* pattern;
size_t index,rank;
OCASSERT(state != NULL);
OCASSERT(data != NULL);
template = data->template;
rank = template->array.rank;
pattern = data->pattern;
rank = pattern->array.rank;
/* Must be a dimensioned Structure */
if(template->octype != OC_Structure || rank == 0)
if(pattern->octype != OC_Structure || rank == 0)
return OCTHROW(OC_EBADTYPE);
/* Validate indices */
if(!ocvalidateindices(rank,template->array.sizes,indices))
if(!ocvalidateindices(rank,pattern->array.sizes,indices))
return OCTHROW(OC_EINVALCOORDS);
/* compute linearized index */
index = ocarrayoffset(rank,template->array.sizes,indices);
index = ocarrayoffset(rank,pattern->array.sizes,indices);
if(index >= data->ninstances)
return OCTHROW(OC_EINDEX);
@ -156,15 +156,15 @@ ocdata_ithrecord(OCstate* state, OCdata* data,
{
int stat = OC_NOERR;
OCdata* record;
OCnode* template;
OCnode* pattern;
OCASSERT(state != NULL);
OCASSERT(data != NULL);
template = data->template;
pattern = data->pattern;
/* Must be a Sequence */
if(template->octype != OC_Sequence
if(pattern->octype != OC_Sequence
|| !fisset(data->datamode,OCDT_SEQUENCE))
return OCTHROW(OC_EBADTYPE);
@ -184,20 +184,20 @@ ocdata_ithrecord(OCstate* state, OCdata* data,
OCerror
ocdata_position(OCstate* state, OCdata* data, size_t* indices)
{
OCnode* template;
OCnode* pattern;
OCASSERT(state != NULL);
OCASSERT(data != NULL);
OCASSERT(indices != NULL);
template = data->template;
pattern = data->pattern;
if(fisset(data->datamode,OCDT_RECORD))
indices[0] = data->index;
else if(fisset(data->datamode,OCDT_ELEMENT)) {
/* Transform the linearized array index into a set of indices */
ocarrayindices(data->index,
template->array.rank,
template->array.sizes,
pattern->array.rank,
pattern->array.sizes,
indices);
} else
return OCTHROW(OC_EBADTYPE);
@ -211,7 +211,7 @@ ocdata_recordcount(OCstate* state, OCdata* data, size_t* countp)
OCASSERT(data != NULL);
OCASSERT(countp != NULL);
if(data->template->octype != OC_Sequence
if(data->pattern->octype != OC_Sequence
|| !fisset(data->datamode,OCDT_SEQUENCE))
return OCTHROW(OC_EBADTYPE);
@ -241,7 +241,7 @@ ocdata_read(OCstate* state, OCdata* data, size_t start, size_t count,
OCtype etype, octype;
int isscalar;
size_t elemsize, totalsize, countsize;
OCnode* template;
OCnode* pattern;
octrace("read", state, data);
@ -250,12 +250,12 @@ ocdata_read(OCstate* state, OCdata* data, size_t start, size_t count,
assert(memory != NULL);
assert(memsize > 0);
template = data->template;
octype = template->octype;
pattern = data->pattern;
octype = pattern->octype;
assert(octype == OC_Atomic);
etype = template->etype;
etype = pattern->etype;
isscalar = (template->array.rank == 0 ? 1 : 0);
isscalar = (pattern->array.rank == 0 ? 1 : 0);
/* validate memory space*/
elemsize = octypesize(etype);
@ -265,7 +265,7 @@ ocdata_read(OCstate* state, OCdata* data, size_t start, size_t count,
return OCTHROW(OC_EINVAL);
/* Get XXDR* */
xdrs = template->root->tree->data.xdrs;
xdrs = pattern->root->tree->data.xdrs;
if(isscalar) {
/* Extract the data */
@ -291,7 +291,7 @@ static OCerror
ocread(OCdata* data, XXDR* xdrs, char* memory, size_t memsize, size_t start, size_t count)
{
int i;
OCnode* template;
OCnode* pattern;
OCtype etype;
off_t elemsize, totalsize, xdrtotal, xdrstart;
int scalar;
@ -302,9 +302,9 @@ ocread(OCdata* data, XXDR* xdrs, char* memory, size_t memsize, size_t start, siz
OCASSERT(count > 0);
OCASSERT((start+count) <= data->ninstances);
template = data->template;
etype = template->etype;
scalar = (template->array.rank == 0);
pattern = data->pattern;
etype = pattern->etype;
scalar = (pattern->array.rank == 0);
/* Note that for strings, xdrsize == 0 */
xdrtotal = count*data->xdrsize; /* amount (in xdr sizes) to read */

View File

@ -14,7 +14,7 @@ This has some similarities to OCNODE.
struct OCdata {
OCheader header;
OCDT datamode;
OCnode* template;
OCnode* pattern;
OCdata* container; /* link back to container instance */
size_t index; /* WRT to the container */
off_t xdroffset; /* Of this instance wrt xxdr_getpos() */

View File

@ -496,23 +496,23 @@ void
ocdumpdata(OCstate* state, OCdata* data, OCbytes* buffer, int frominstance)
{
char tmp[1024];
OCnode* template = data->template;
OCnode* pattern = data->pattern;
snprintf(tmp,sizeof(tmp),"%lx:",(unsigned long)data);
ocbytescat(buffer,tmp);
if(!frominstance) {
ocbytescat(buffer," node=");
ocbytescat(buffer,template->name);
ocbytescat(buffer,pattern->name);
}
snprintf(tmp,sizeof(tmp)," xdroffset=%ld",(unsigned long)data->xdroffset);
ocbytescat(buffer,tmp);
if(data->template->octype == OC_Atomic) {
if(data->pattern->octype == OC_Atomic) {
snprintf(tmp,sizeof(tmp)," xdrsize=%ld",(unsigned long)data->xdrsize);
ocbytescat(buffer,tmp);
}
if(ociscontainer(template->octype)) {
if(ociscontainer(pattern->octype)) {
snprintf(tmp,sizeof(tmp)," ninstances=%d",(int)data->ninstances);
ocbytescat(buffer,tmp);
} else if(template->etype == OC_String || template->etype == OC_URL) {
} else if(pattern->etype == OC_String || pattern->etype == OC_URL) {
snprintf(tmp,sizeof(tmp)," nstrings=%d",(int)data->nstrings);
ocbytescat(buffer,tmp);
}
@ -537,7 +537,7 @@ void
ocdumpdatatree(OCstate* state, OCdata* data, OCbytes* buffer, int depth)
{
size_t i,rank;
OCnode* template;
OCnode* pattern;
char tmp[1024];
size_t crossproduct;
int tabstop = 0;
@ -548,13 +548,13 @@ ocdumpdatatree(OCstate* state, OCdata* data, OCbytes* buffer, int depth)
ocbytescat(buffer,header);
}
/* get info about the template */
template = data->template;
rank = template->array.rank;
/* get info about the pattern */
pattern = data->pattern;
rank = pattern->array.rank;
/* get total dimension size */
if(rank > 0)
crossproduct = octotaldimsize(template->array.rank,template->array.sizes);
crossproduct = octotaldimsize(pattern->array.rank,pattern->array.sizes);
/* Dump the depth first */
snprintf(tmp,sizeof(tmp),"[%03d]",depth);
@ -593,16 +593,16 @@ ocdumpdatatree(OCstate* state, OCdata* data, OCbytes* buffer, int depth)
tabto(tabstops[++tabstop],buffer);
if(template->octype == OC_Atomic) {
typename = octypetoddsstring(template->etype);
if(pattern->octype == OC_Atomic) {
typename = octypetoddsstring(pattern->etype);
} else { /*must be container*/
typename = octypetoddsstring(template->octype);
typename = octypetoddsstring(pattern->octype);
}
ocbytescat(buffer,typename);
tabto(tabstops[++tabstop],buffer);
if(!occopycat(tmp,sizeof(tmp),1,template->name))
if(!occopycat(tmp,sizeof(tmp),1,pattern->name))
return;
ocbytescat(buffer,tmp);
@ -626,7 +626,7 @@ ocdumpdatapath(OCstate* state, OCdata* data, OCbytes* buffer)
OCdata* path[1024];
char tmp[1024];
OCdata* pathdata;
OCnode* template;
OCnode* pattern;
int isrecord;
path[0] = data;
@ -638,9 +638,9 @@ ocdumpdatapath(OCstate* state, OCdata* data, OCbytes* buffer)
/* Path is in reverse order */
for(i=i-1;i>=0;i--) {
pathdata = path[i];
template = pathdata->template;
pattern = pathdata->pattern;
ocbytescat(buffer,"/");
ocbytescat(buffer,template->name);
ocbytescat(buffer,pattern->name);
/* Check the mode of the next step in path */
if(i > 0) {
OCdata* next = path[i-1];
@ -651,31 +651,31 @@ ocdumpdatapath(OCstate* state, OCdata* data, OCbytes* buffer)
ocbytescat(buffer,tmp);
}
}
if(template->octype == OC_Atomic) {
if(template->array.rank > 0) {
off_t xproduct = octotaldimsize(template->array.rank,template->array.sizes);
if(pattern->octype == OC_Atomic) {
if(pattern->array.rank > 0) {
off_t xproduct = octotaldimsize(pattern->array.rank,pattern->array.sizes);
snprintf(tmp,sizeof(tmp),"[0..%lu]",(unsigned long)xproduct-1);
ocbytescat(buffer,tmp);
}
}
isrecord = 0;
if(template->octype == OC_Sequence) {
if(pattern->octype == OC_Sequence) {
/* Is this a record or a sequence ? */
isrecord = (fisset(pathdata->datamode,OCDT_RECORD) ? 1 : 0);
}
}
/* Add suffix to path */
if(ociscontainer(template->octype)) {
if(ociscontainer(pattern->octype)) {
/* add the container type, except distinguish record and sequence */
ocbytescat(buffer,":");
if(isrecord)
ocbytescat(buffer,"Record");
else
ocbytescat(buffer,octypetoddsstring(template->octype));
} else if(ocisatomic(template->octype)) {
ocbytescat(buffer,octypetoddsstring(pattern->octype));
} else if(ocisatomic(pattern->octype)) {
/* add the atomic etype */
ocbytescat(buffer,":");
ocbytescat(buffer,octypetoddsstring(template->etype));
ocbytescat(buffer,octypetoddsstring(pattern->etype));
}
snprintf(tmp,sizeof(tmp),"->0x%0lx",(unsigned long)pathdata);
ocbytescat(buffer,tmp);

View File

@ -69,9 +69,9 @@ ocinternalinitialize(void)
{
int stat = OC_NOERR;
if(sizeof(long) != sizeof(void*)) {
fprintf(stderr,"OC depends on the assumption that sizeof(long) == sizeof(void*)\n");
//OCASSERT(sizeof(long) == sizeof(void*));
if(sizeof(off_t) != sizeof(void*)) {
fprintf(stderr,"OC xxdr depends on the assumption that sizeof(off_t) == sizeof(void*)\n");
OCASSERT(sizeof(off_t) == sizeof(void*));
}
if(!ocglobalstate.initialized) {

View File

@ -141,7 +141,7 @@ xxdr_uint(XXDR* xdr, unsigned int* ip)
/* get a long long from underlying stream*/
int
xxdr_ulonglong(XXDR* xdr, unsigned long* llp)
xxdr_ulonglong(XXDR* xdr, unsigned long long* llp)
{
/* Pull two units */
if(!llp) return 0;

View File

@ -150,7 +150,7 @@ extern int xxdr_ushort(XXDR* , unsigned short*);
extern int xxdr_uint(XXDR* , unsigned int*);
/* get an int from underlying stream*/
extern int xxdr_ulonglong(XXDR* , unsigned long*);
extern int xxdr_ulonglong(XXDR* , unsigned long long*);
/* get a float from underlying stream*/
extern int xxdr_float(XXDR* , float*);