Add basic plist syntax verification checks to the OXPVerifier
Doesn't check that the keys/values are sensible, just that it can be parsed at all. New file src/Core/OXPVerifier/OOCheckPListSyntaxVerifierStage.m will need adding to the Mac build.
This commit is contained in:
parent
2b89bec1eb
commit
bce6485b39
@ -262,6 +262,7 @@ OOLITE_OXP_VERIFIER_FILES = \
|
||||
OOAIStateMachineVerifierStage.m \
|
||||
OOCheckDemoShipsPListVerifierStage.m \
|
||||
OOCheckEquipmentPListVerifierStage.m \
|
||||
OOCheckPListSyntaxVerifierStage.m \
|
||||
OOCheckRequiresPListVerifierStage.m \
|
||||
OOCheckShipDataPListVerifierStage.m \
|
||||
OOFileScannerVerifierStage.m \
|
||||
|
@ -7,6 +7,7 @@
|
||||
stages =
|
||||
(
|
||||
OOCheckRequiresPListVerifierStage,
|
||||
OOCheckPListSyntaxVerifierStage,
|
||||
OOCheckDemoShipsPListVerifierStage,
|
||||
OOCheckEquipmentPListVerifierStage,
|
||||
OOTextureVerifierStage,
|
||||
@ -56,11 +57,15 @@
|
||||
"autoAImap.plist",
|
||||
"characters.plist",
|
||||
"commodities.plist",
|
||||
"crosshairs.plist",
|
||||
"customsounds.plist",
|
||||
"demoships.plist",
|
||||
"descriptions.plist",
|
||||
"effectdata.plist",
|
||||
"equipment.plist",
|
||||
"explosions.plist",
|
||||
"global-settings.plist",
|
||||
"gui-settings.plist",
|
||||
"hud.plist",
|
||||
"illegal_goods.plist",
|
||||
"keyconfig.plist",
|
||||
@ -68,15 +73,62 @@
|
||||
"missiontext.plist",
|
||||
"nebulatextures.plist",
|
||||
"planetinfo.plist",
|
||||
"requires.plist",
|
||||
"role-categories.plist",
|
||||
"scenarios.plist",
|
||||
"screenbackgrounds.plist",
|
||||
"script.plist",
|
||||
"script.js",
|
||||
"shipdata.plist",
|
||||
"shipyard.plist",
|
||||
"shiplibrary.plist",
|
||||
"speech_pronunciation_guide.plist",
|
||||
"startextures.plist",
|
||||
"trade-goods.plist",
|
||||
"world-scripts.plist"
|
||||
);
|
||||
|
||||
// the files in the "Config" list which are arrays
|
||||
"ConfigArrays" =
|
||||
(
|
||||
"demoships.plist",
|
||||
"equipment.plist",
|
||||
"nebulatextures.plist",
|
||||
"scenarios.plist",
|
||||
"shiplibrary.plist",
|
||||
"speech_pronunciation_guide.plist",
|
||||
"startextures.plist",
|
||||
"world-scripts.plist"
|
||||
);
|
||||
|
||||
// the files in the "Config" list which are dictionaries
|
||||
"ConfigDictionaries" =
|
||||
(
|
||||
"autoAImap.plist",
|
||||
"characters.plist",
|
||||
"commodities.plist",
|
||||
"crosshairs.plist",
|
||||
"customsounds.plist",
|
||||
"descriptions.plist",
|
||||
"effectdata.plist",
|
||||
"explosions.plist",
|
||||
"global-settings.plist",
|
||||
"gui-settings.plist",
|
||||
"hud.plist",
|
||||
"illegal_goods.plist",
|
||||
"keyconfig.plist",
|
||||
"material-defaults.plist",
|
||||
"missiontext.plist",
|
||||
"planetinfo.plist",
|
||||
"role-categories.plist",
|
||||
"screenbackgrounds.plist",
|
||||
"script.plist",
|
||||
"script.js",
|
||||
"shipdata.plist",
|
||||
"shipyard.plist",
|
||||
"startextures.plist",
|
||||
"trade-goods.plist"
|
||||
);
|
||||
|
||||
"Sounds" =
|
||||
(
|
||||
"afterburner1.ogg",
|
||||
|
35
src/Core/OXPVerifier/OOCheckPListSyntaxVerifierStage.h
Normal file
35
src/Core/OXPVerifier/OOCheckPListSyntaxVerifierStage.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
|
||||
OOCheckPListSyntaxVerifierStage.h
|
||||
|
||||
OOOXPVerifierStage which checks that plists have correct syntax
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright (C) 2004-2013 Giles C Williams and contributors
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import "OOFileScannerVerifierStage.h"
|
||||
|
||||
#if OO_OXP_VERIFIER_ENABLED
|
||||
|
||||
@interface OOCheckPListSyntaxVerifierStage: OOFileHandlingVerifierStage
|
||||
@end
|
||||
|
||||
#endif
|
104
src/Core/OXPVerifier/OOCheckPListSyntaxVerifierStage.m
Normal file
104
src/Core/OXPVerifier/OOCheckPListSyntaxVerifierStage.m
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
|
||||
OOCheckPListSyntaxVerifierStage.m
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright (C) 2004-2013 Giles C Williams and contributors
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import "OOCheckPListSyntaxVerifierStage.h"
|
||||
#import "OOCollectionExtractors.h"
|
||||
|
||||
#if OO_OXP_VERIFIER_ENABLED
|
||||
|
||||
#import "OOFileScannerVerifierStage.h"
|
||||
|
||||
static NSString * const kStageName = @"Checking plist well-formedness";
|
||||
|
||||
|
||||
@implementation OOCheckPListSyntaxVerifierStage
|
||||
|
||||
- (NSString *)name
|
||||
{
|
||||
return kStageName;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)shouldRun
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (void)run
|
||||
{
|
||||
OOFileScannerVerifierStage *fileScanner = nil;
|
||||
|
||||
|
||||
fileScanner = [[self verifier] fileScannerStage];
|
||||
|
||||
NSArray *plists = [[[self verifier] configurationDictionaryForKey:@"knownFiles"] oo_arrayForKey:@"Config"];
|
||||
NSArray *arrayPlists = [[[self verifier] configurationDictionaryForKey:@"knownFiles"] oo_arrayForKey:@"ConfigArrays"];
|
||||
NSArray *dictionaryPlists = [[[self verifier] configurationDictionaryForKey:@"knownFiles"] oo_arrayForKey:@"ConfigDictionaries"];
|
||||
|
||||
NSString *plistName = nil;
|
||||
foreach (plistName, plists)
|
||||
{
|
||||
if ([fileScanner fileExists:plistName
|
||||
inFolder:@"Config"
|
||||
referencedFrom:nil
|
||||
checkBuiltIn:NO])
|
||||
{
|
||||
OOLog(@"verifyOXP.syntaxCheck",@"Checking %@",plistName);
|
||||
id retrieve = [fileScanner plistNamed:plistName
|
||||
inFolder:@"Config"
|
||||
referencedFrom:nil
|
||||
checkBuiltIn:NO];
|
||||
if (retrieve != nil)
|
||||
{
|
||||
if ([retrieve isKindOfClass:[NSArray class]])
|
||||
{
|
||||
if (![arrayPlists containsObject:plistName])
|
||||
{
|
||||
OOLog(@"verifyOXP.syntaxCheck.error",@"%@ should be an array but isn't.",plistName);
|
||||
}
|
||||
}
|
||||
else if ([retrieve isKindOfClass:[NSDictionary class]])
|
||||
{
|
||||
if (![dictionaryPlists containsObject:plistName])
|
||||
{
|
||||
OOLog(@"verifyOXP.syntaxCheck.error",@"%@ should be an array but isn't.",plistName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OOLog(@"verifyOXP.syntaxCheck.error",@"%@ is neither an array nor a dictionary.",plistName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user