int ScheduleAgentOperations(struct Bundle *bp) { struct SubType *sp; struct Promise *pp; enum typesequence type; int pass; if (PROCESSREFRESH == NULL || (PROCESSREFRESH && IsRegexItemIn(PROCESSREFRESH,bp->name))) { DeleteItemList(PROCESSTABLE); PROCESSTABLE = NULL; } for (pass = 1; pass < CF_DONEPASSES; pass++) { for (type = 0; TYPESEQUENCE[type] != NULL; type++) { ClassBanner(type); if ((sp = GetSubTypeForBundle(TYPESEQUENCE[type],bp)) == NULL) { continue; } BannerSubType(bp->name,sp->name,pass); SetScope(bp->name); if (!NewTypeContext(type)) { continue; } for (pp = sp->promiselist; pp != NULL; pp=pp->next) { SaveClassEnvironment(); ExpandPromise(cf_agent,bp->name,pp,KeepAgentPromise); if (Abort()) { NoteClassUsage(VADDCLASSES); DeleteTypeContext(type); return false; } } DeleteTypeContext(type); } } NoteClassUsage(VADDCLASSES); return true; }
static void KeepPromiseBundles() { Bundle *bp; SubType *sp; Promise *pp; Rlist *rp, *params; FnCall *fp; char *name; Rval retval; int ok = true; enum typesequence type; if (GetVariable("control_common", "bundlesequence", &retval) == cf_notype) { CfOut(cf_error, "", " !! No bundlesequence in the common control body"); exit(1); } for (rp = (Rlist *) retval.item; rp != NULL; rp = rp->next) { switch (rp->type) { case CF_SCALAR: name = (char *) rp->item; params = NULL; break; case CF_FNCALL: fp = (FnCall *) rp->item; name = (char *) fp->name; params = (Rlist *) fp->args; break; default: name = NULL; params = NULL; CfOut(cf_error, "", " !! Illegal item found in bundlesequence: "); ShowRval(stdout, (Rval) {rp->item, rp->type}); printf(" = %c\n", rp->type); ok = false; break; } if (!(GetBundle(name, "knowledge") || (GetBundle(name, "common")))) { CfOut(cf_error, "", " !! Bundle \"%s\" listed in the bundlesequence was not found\n", name); ok = false; } } if (!ok) { FatalError("Errors in knowledge bundles"); } /* If all is okay, go ahead and evaluate */ for (type = 0; TYPESEQUENCE[type] != NULL; type++) { for (rp = (Rlist *) retval.item; rp != NULL; rp = rp->next) { switch (rp->type) { case CF_FNCALL: fp = (FnCall *) rp->item; name = (char *) fp->name; params = (Rlist *) fp->args; break; default: name = (char *) rp->item; params = NULL; break; } if ((bp = GetBundle(name, "knowledge")) || (bp = GetBundle(name, "common"))) { BannerBundle(bp, params); AugmentScope(bp->name, bp->args, params); DeletePrivateClassContext(); // Each time we change bundle } if ((sp = GetSubTypeForBundle(TYPESEQUENCE[type], bp)) == NULL) { continue; } BannerSubType(bp->name, sp->name, 1); for (pp = sp->promiselist; pp != NULL; pp = pp->next) { ExpandPromise(cf_know, bp->name, pp, KeepKnowledgePromise); } } } }