/* Wrapper for ceparse */ int dapceparse(char* input, DCEconstraint* constraint, char** errmsgp) { DCEparsestate* state; int errcode = 0; #ifdef PARSEDEBUG dcedebug = 1; #endif if(input != NULL) { #ifdef DEBUG fprintf(stderr,"dceeparse: input=%s\n",input); #endif state = ce_parse_init(input,constraint); if(dceparse(state) == 0) { #ifdef DEBUG if(nclistlength(constraint->projections) > 0) fprintf(stderr,"dceeparse: projections=%s\n", dcetostring((DCEnode*)constraint->projections)); #endif #ifdef DEBUG if(nclistlength(constraint->selections) > 0) fprintf(stderr,"dceeparse: selections=%s\n", dumpselections(constraint->selections)); #endif } else { if(errmsgp) *errmsgp = nulldup(state->errorbuf); } errcode = state->errorcode; dce_parse_cleanup(state); } return errcode; }
NCerror mapconstraints3(DCEconstraint* constraint, CDFnode* root) { int i; NCerror ncstat = NC_NOERR; NClist* nodes = root->tree->nodes; NClist* dceprojections; NClist* dceselections; dceprojections = constraint->projections; dceselections = constraint->selections; /* Convert the projection paths to leaves in the dds tree */ for(i=0;i<nclistlength(dceprojections);i++) { DCEprojection* proj = (DCEprojection*)nclistget(dceprojections,i); if(proj->discrim != CES_VAR) continue; // ignore functions ncstat = matchpartialname3(nodes,proj->var->segments, (CDFnode**)&proj->var->annotation); if(ncstat) goto done; } #ifdef IGNORE Only care about projections /* Convert the selection paths to leaves in the dds tree */ for(i=0;i<nclistlength(dceselections);i++) { DCEselection* sel = (DCEselection*)nclistget(dceselections,i); if(sel->lhs->discrim != CES_VAR) continue; ncstat = matchpartialname3(nodes,sel->lhs->var->segments, (CDFnode**)&sel->lhs->var->annotation); if(ncstat) goto done; } /* Convert the selection path values to leaves in the dds tree */ for(i=0;i<nclistlength(dceselections);i++) { int j; DCEselection* sel = (DCEselection*)nclistget(dceselections,i); for(j=0;j<nclistlength(sel->rhs);j++) { DCEvalue* value = (DCEvalue*)nclistget(sel->rhs,j); if(value->discrim != CES_VAR) continue; ncstat = matchpartialname3(nodes,value->var->segments, (CDFnode**)&value->var->annotation); if(ncstat) goto done; } } #endif #ifdef DEBUG fprintf(stderr,"mapconstraint.projections: %s\n", dumpprojections(dceprojections)); fprintf(stderr,"mapconstraint.selections: %s\n", dumpselections(dceselections)); #endif done: return THROW(ncstat); }
NCerror mapconstraints3(NCDAPCOMMON* dapcomm) { int i; NCerror ncstat = NC_NOERR; CDFnode* root = dapcomm->cdf.ddsroot; NClist* nodes = root->tree->nodes; NClist* dceprojections; NClist* dceselections; dceprojections = dapcomm->oc.dapconstraint->projections; dceselections = dapcomm->oc.dapconstraint->selections; /* Convert the projection paths to leaves in the dds tree */ for(i=0;i<nclistlength(dceprojections);i++) { DCEprojection* proj = (DCEprojection*)nclistget(dceprojections,i); if(proj->discrim != CES_VAR) continue; ncstat = matchpartialname3(nodes,proj->var->segments, &proj->var->cdfleaf); if(ncstat) goto done; } /* Convert the selection paths to leaves in the dds tree */ for(i=0;i<nclistlength(dceselections);i++) { DCEselection* sel = (DCEselection*)nclistget(dceselections,i); if(sel->lhs->discrim != CES_VAR) continue; ncstat = matchpartialname3(nodes,sel->lhs->var->segments,&sel->lhs->var->cdfleaf); if(ncstat) goto done; } /* Convert the selection path values to leaves in the dds tree */ for(i=0;i<nclistlength(dceselections);i++) { int j; DCEselection* sel = (DCEselection*)nclistget(dceselections,i); for(j=0;j<nclistlength(sel->rhs);j++) { DCEvalue* value = (DCEvalue*)nclistget(sel->rhs,j); if(value->discrim != CES_VAR) continue; ncstat = matchpartialname3(nodes,value->var->segments,&value->var->cdfnode); if(ncstat) goto done; } } /* Fill in segment information */ ncstat = qualifyconstraints3(dapcomm->oc.dapconstraint); if(ncstat != NC_NOERR) goto done; #ifdef DEBUG fprintf(stderr,"mapconstraint.projections: %s\n", dumpprojections(dceprojections)); fprintf(stderr,"mapconstraint.selections: %s\n", dumpselections(dceselections)); #endif done: return THROW(ncstat); }
char* dumpconstraint(NCconstraint* con) { NCbytes* buf = ncbytesnew(); char* result = NULL; if(nclistlength(con->projections)==0 && nclistlength(con->selections)==0) goto done; if(nclistlength(con->projections) > 0) { char* pstring = dumpprojections(con->projections); ncbytescat(buf,pstring); efree(pstring); } if(nclistlength(con->selections) > 0) { char* sstring = dumpselections(con->selections); ncbytescat(buf,sstring); efree(sstring); } done: result = ncbytesdup(buf); ncbytesfree(buf); return result; }