123- (void) validateAI:(NSString *)aiName
125 NSString *path =
nil;
126 NSDictionary *aiStateMachine =
nil;
127 NSEnumerator *stateEnum =
nil;
128 NSString *stateKey =
nil;
129 NSDictionary *stateHandlers =
nil;
130 NSEnumerator *handlerEnum =
nil;
131 NSString *handlerKey =
nil;
132 NSArray *handlerActions =
nil;
133 NSEnumerator *actionEnum =
nil;
134 NSString *action =
nil;
136 NSString *selector =
nil;
137 NSMutableSet *badSelectors =
nil;
138 NSString *badSelectorDesc =
nil;
139 NSUInteger index = 0;
141 OOLog(
@"verifyOXP.verbose.validateAI",
@"- Validating AI \"%@\
".", aiName);
146 if (path ==
nil)
return;
151 if (aiStateMachine ==
nil)
153 OOLog(
@"verifyOXP.validateAI.failed.notDictPlist",
@"***** ERROR: could not interpret \"%@\
" as a dictionary.", path);
158 for (stateEnum = [aiStateMachine keyEnumerator]; (stateKey = [
stateEnum nextObject]); )
161 if (![stateHandlers isKindOfClass:[NSDictionary
class]])
163 OOLog(
@"verifyOXP.validateAI.failed.invalidFormat.state",
@"***** ERROR: state \"%@\
" in AI \"%@\" is not a dictionary.", stateKey, aiName);
168 for (handlerEnum = [stateHandlers keyEnumerator]; (handlerKey = [
handlerEnum nextObject]); )
171 if (![handlerActions isKindOfClass:[NSArray
class]])
173 OOLog(
@"verifyOXP.validateAI.failed.invalidFormat.handler",
@"***** ERROR: handler \"%@\
" for state \"%@\" in AI \"%@\" is not an array, ignoring.", handlerKey, stateKey, aiName);
179 for (actionEnum = [handlerActions objectEnumerator]; (action = [
actionEnum nextObject]); )
182 if (![action isKindOfClass:[NSString
class]])
184 OOLog(
@"verifyOXP.validateAI.failed.invalidFormat.action",
@"***** ERROR: action %lu in handler \"%@\
" for state \"%@\" in AI \"%@\" is not a string, ignoring.", index - 1, handlerKey, stateKey, aiName);
192 spaceRange = [
action rangeOfString:@" "];
193 if (spaceRange.location == NSNotFound) selector = action;
194 else selector = [
action substringToIndex:spaceRange.location];
197 if (![_whitelist containsObject:selector])
205 if ([badSelectors
count] != 0)
207 badSelectorDesc = [[[
badSelectors allObjects] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)] componentsJoinedByString:@", "];
208 OOLog(
@"verifyOXP.validateAI.failed.badSelector",
@"***** ERROR: the AI \"%@\
" uses %lu unpermitted method%s: %@", aiName, [badSelectors
count], ([badSelectors
count] == 1) ?
"" :
"s", badSelectorDesc);