static void TestAgentPromises() { Promise pp = { 0 }; pp.conlist = NULL; pp.audit = NULL; printf("%d. Testing promise attribute completeness (with no desired intention)\n", ++NR); GetFilesAttributes(&pp); GetReportsAttributes(&pp); GetExecAttributes(&pp); GetProcessAttributes(&pp); GetStorageAttributes(&pp); GetClassContextAttributes(&pp); GetTopicsAttributes(&pp); GetOccurrenceAttributes(&pp); GetMethodAttributes(&pp); GetInterfacesAttributes(&pp); GetInsertionAttributes(&pp); GetDeletionAttributes(&pp); GetColumnAttributes(&pp); GetReplaceAttributes(&pp); printf(" -> All non-listed items are accounted for\n"); }
static void VerifyOccurrenceGroup(char *file, Promise *pp) { Attributes a = { {0} }; struct stat sb; char *sp, url[CF_BUFSIZE]; Rval retval; a = GetOccurrenceAttributes(pp); if (cfstat(file, &sb) == -1) { CfOut(cf_verbose, "", " !! File %s matched but could not be read", file); return; } if (a.path_root == NULL || a.web_root == NULL) { CfOut(cf_error, "", " !! No pathroot/webroot defined in representation"); PromiseRef(cf_error, pp); return; } Chop(a.path_root); DeleteSlash(a.path_root); sp = file + strlen(a.path_root) + 1; FullTextMatch(pp->promiser, sp); retval = ExpandPrivateRval("this", (Rval) {a.represents, CF_LIST}); DeleteScope("match"); if (strlen(a.web_root) > 0) { snprintf(url, CF_BUFSIZE - 1, "%s/%s", a.web_root, sp); } else { snprintf(url, CF_BUFSIZE - 1, "%s", sp); } AddOccurrence(&OCCURRENCES, url, retval.item, cfk_url, pp->classes); CfOut(cf_verbose, "", " -> File %s matched and being logged at %s", file, url); DeleteRlist((Rlist *) retval.item); }
static void VerifyOccurrencePromises(Promise *pp) { Attributes a = { {0} }; char name[CF_BUFSIZE]; enum representations rep_type; Rlist *contexts, *rp; a = GetOccurrenceAttributes(pp); if (a.rep_type) { rep_type = String2Representation(a.rep_type); } else { rep_type = cfk_url; } if (a.represents == NULL) { if (rep_type == cfk_literal) { CfOut(cf_error, "", " ! Occurrence of text information \"%s\" does not promise any topics to represent", pp->promiser); } else { CfOut(cf_error, "", " ! Occurrence or reference to information \"%s\" does not promise any topics to represent", pp->promiser); } return; } contexts = SplitContextExpression(pp->classes, pp); for (rp = contexts; rp != NULL; rp = rp->next) { CfOut(cf_verbose, "", " -> New occurrence promise for \"%s\" about context \"%s\"", pp->promiser, ScalarValue(rp)); switch (rep_type) { case cfk_file: if (a.web_root == NULL || a.path_root == NULL) { CfOut(cf_error, "", " !! File pattern but no complete url mapping path_root -> web_root"); return; } strncpy(name, a.path_root, CF_BUFSIZE - 1); if (!JoinPath(name, pp->promiser)) { CfOut(cf_error, "", " !! Unable to form pathname in search for local files"); return; } // FIXME - this should pass rp->item instead of pp->classes if we want to keep this LocateFilePromiserGroup(name, pp, VerifyOccurrenceGroup); break; default: AddOccurrence(&OCCURRENCES, pp->promiser, a.represents, rep_type, rp->item); break; } } DeleteRlist(contexts); }