1999-02-04 13:49:27 +00:00
|
|
|
/* This tool checks that a file contains a valid text property-list
|
|
|
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
Created: February 1999
|
|
|
|
|
|
|
|
This file is part of the GNUstep Project
|
|
|
|
|
|
|
|
This library 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.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2000-03-24 05:40:19 +00:00
|
|
|
#include "config.h"
|
2001-03-16 16:56:32 +00:00
|
|
|
#include <Foundation/Foundation.h>
|
1999-02-04 13:49:27 +00:00
|
|
|
#include <Foundation/NSArray.h>
|
|
|
|
#include <Foundation/NSException.h>
|
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
#include <Foundation/NSProcessInfo.h>
|
|
|
|
#include <Foundation/NSUserDefaults.h>
|
|
|
|
#include <Foundation/NSDebug.h>
|
|
|
|
#include <Foundation/NSAutoreleasePool.h>
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2000-06-29 03:51:06 +00:00
|
|
|
main(int argc, char** argv, char **env)
|
1999-02-04 13:49:27 +00:00
|
|
|
{
|
2000-06-29 03:51:06 +00:00
|
|
|
NSAutoreleasePool *pool;
|
1999-02-04 13:49:27 +00:00
|
|
|
NSProcessInfo *proc;
|
|
|
|
NSArray *args;
|
|
|
|
unsigned i;
|
|
|
|
|
2000-06-29 03:51:06 +00:00
|
|
|
#ifdef GS_PASS_ARGUMENTS
|
|
|
|
[NSProcessInfo initializeWithArguments:argv count:argc environment:env];
|
|
|
|
#endif
|
|
|
|
pool = [NSAutoreleasePool new];
|
1999-02-04 13:49:27 +00:00
|
|
|
proc = [NSProcessInfo processInfo];
|
|
|
|
if (proc == nil)
|
|
|
|
{
|
2002-04-05 16:26:47 +00:00
|
|
|
NSLog(@"plparse: unable to get process information!\n");
|
1999-02-04 13:49:27 +00:00
|
|
|
[pool release];
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
args = [proc arguments];
|
|
|
|
|
1999-02-17 09:26:56 +00:00
|
|
|
if ([args count] <= 1)
|
1999-02-04 13:49:27 +00:00
|
|
|
{
|
2002-10-11 09:14:14 +00:00
|
|
|
GSPrintf(stderr, @"No file names given to parse.\n");
|
1999-02-04 13:49:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-02-17 09:26:56 +00:00
|
|
|
for (i = 1; i < [args count]; i++)
|
1999-02-04 13:49:27 +00:00
|
|
|
{
|
|
|
|
NSString *file = [args objectAtIndex: i];
|
|
|
|
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
NSString *myString;
|
|
|
|
id result;
|
|
|
|
|
|
|
|
myString = [NSString stringWithContentsOfFile: file];
|
|
|
|
result = [myString propertyList];
|
|
|
|
if (result == nil)
|
2002-10-11 09:14:14 +00:00
|
|
|
GSPrintf(stderr, @"Parsing '%@' - nil property list\n", file);
|
1999-02-04 13:49:27 +00:00
|
|
|
else if ([result isKindOfClass: [NSDictionary class]] == YES)
|
2002-10-11 09:14:14 +00:00
|
|
|
GSPrintf(stderr, @"Parsing '%@' - a dictionary\n", file);
|
1999-02-04 13:49:27 +00:00
|
|
|
else if ([result isKindOfClass: [NSArray class]] == YES)
|
2002-10-11 09:14:14 +00:00
|
|
|
GSPrintf(stderr, @"Parsing '%@' - an array\n", file);
|
1999-02-04 13:49:27 +00:00
|
|
|
else if ([result isKindOfClass: [NSData class]] == YES)
|
2002-10-11 09:14:14 +00:00
|
|
|
GSPrintf(stderr, @"Parsing '%@' - a data object\n", file);
|
1999-02-04 13:49:27 +00:00
|
|
|
else if ([result isKindOfClass: [NSString class]] == YES)
|
2002-10-11 09:14:14 +00:00
|
|
|
GSPrintf(stderr, @"Parsing '%@' - a string\n", file);
|
1999-02-04 13:49:27 +00:00
|
|
|
else
|
2002-10-11 09:14:14 +00:00
|
|
|
GSPrintf(stderr, @"Parsing '%@' - unexpected class - %@\n",
|
|
|
|
file, [[result class] description]);
|
1999-02-04 13:49:27 +00:00
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
2002-10-11 09:14:14 +00:00
|
|
|
GSPrintf(stderr, @"Parsing '%@' - %@\n", file,
|
|
|
|
[localException reason]);
|
1999-02-04 13:49:27 +00:00
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[pool release];
|
|
|
|
return 0;
|
|
|
|
}
|