2004-03-29 03:37:46 +00:00
|
|
|
/** This tool converts a serialised property list to a text representation.
|
1999-05-14 18:41:16 +00:00
|
|
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
Created: may 1999
|
|
|
|
|
|
|
|
This file is part of the GNUstep Project
|
|
|
|
|
2008-06-08 10:38:33 +00:00
|
|
|
This program is free software; you can redistribute it and/or
|
1999-05-14 18:41:16 +00:00
|
|
|
modify it under the terms of the GNU General Public License
|
2008-06-08 10:38:33 +00:00
|
|
|
as published by the Free Software Foundation; either
|
|
|
|
version 3 of the License, or (at your option) any later version.
|
2005-02-22 11:22:44 +00:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public
|
2008-06-08 10:38:33 +00:00
|
|
|
License along with this program; see the file COPYINGv3.
|
1999-05-14 18:41:16 +00:00
|
|
|
If not, write to the Free Software Foundation,
|
2005-05-22 03:32:16 +00:00
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1999-05-14 18:41:16 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2010-02-19 14:21:02 +00:00
|
|
|
#import "common.h"
|
|
|
|
|
2010-02-14 14:30:02 +00:00
|
|
|
#import "Foundation/NSArray.h"
|
|
|
|
#import "Foundation/NSData.h"
|
|
|
|
#import "Foundation/NSException.h"
|
|
|
|
#import "Foundation/NSProcessInfo.h"
|
|
|
|
#import "Foundation/NSUserDefaults.h"
|
|
|
|
#import "Foundation/NSFileHandle.h"
|
|
|
|
#import "Foundation/NSAutoreleasePool.h"
|
1999-05-14 18:41:16 +00:00
|
|
|
|
|
|
|
|
2004-03-29 03:37:46 +00:00
|
|
|
/** <p>This tool converts a binary serialised property list to a text
|
|
|
|
representation.
|
|
|
|
</p> */
|
1999-05-14 18:41:16 +00:00
|
|
|
int
|
2000-06-29 03:51:06 +00:00
|
|
|
main(int argc, char** argv, char **env)
|
1999-05-14 18:41:16 +00:00
|
|
|
{
|
2000-06-29 03:51:06 +00:00
|
|
|
NSAutoreleasePool *pool;
|
1999-05-14 18:41:16 +00:00
|
|
|
NSProcessInfo *proc;
|
|
|
|
NSArray *args;
|
|
|
|
unsigned i;
|
|
|
|
|
2000-06-29 03:51:06 +00:00
|
|
|
#ifdef GS_PASS_ARGUMENTS
|
2009-10-12 14:38:49 +00:00
|
|
|
GSInitializeProcess(argc, argv, env);
|
2000-06-29 03:51:06 +00:00
|
|
|
#endif
|
|
|
|
pool = [NSAutoreleasePool new];
|
1999-05-14 18:41:16 +00:00
|
|
|
proc = [NSProcessInfo processInfo];
|
|
|
|
if (proc == nil)
|
|
|
|
{
|
2002-04-05 16:26:47 +00:00
|
|
|
NSLog(@"pldes: unable to get process information!\n");
|
1999-05-14 18:41:16 +00:00
|
|
|
[pool release];
|
2003-05-12 20:42:47 +00:00
|
|
|
exit(EXIT_SUCCESS);
|
1999-05-14 18:41:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
args = [proc arguments];
|
|
|
|
|
|
|
|
if ([args count] <= 1)
|
|
|
|
{
|
2002-10-11 09:14:14 +00:00
|
|
|
GSPrintf(stderr, @"No file names given to deserialize.\n");
|
1999-05-14 18:41:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-03-17 13:13:08 +00:00
|
|
|
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
|
|
|
NSDictionary *locale = [defs dictionaryRepresentation];
|
|
|
|
|
1999-05-14 18:41:16 +00:00
|
|
|
for (i = 1; i < [args count]; i++)
|
|
|
|
{
|
|
|
|
NSString *file = [args objectAtIndex: i];
|
|
|
|
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
NSData *myData;
|
|
|
|
NSString *myString;
|
|
|
|
id result;
|
|
|
|
|
|
|
|
myData = [NSData dataWithContentsOfFile: file];
|
|
|
|
result = [NSDeserializer deserializePropertyListFromData: myData
|
|
|
|
mutableContainers: NO];
|
|
|
|
if (result == nil)
|
2002-10-11 09:14:14 +00:00
|
|
|
GSPrintf(stderr, @"Loading '%@' - nil property list\n", file);
|
1999-05-14 18:41:16 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
NSFileHandle *out;
|
|
|
|
|
2000-03-17 13:13:08 +00:00
|
|
|
myString = [result descriptionWithLocale: locale indent: 0];
|
1999-05-14 18:41:16 +00:00
|
|
|
out = [NSFileHandle fileHandleWithStandardOutput];
|
|
|
|
myData = [myString dataUsingEncoding: NSASCIIStringEncoding];
|
|
|
|
[out writeData: myData];
|
|
|
|
[out synchronizeFile];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
2002-10-11 09:14:14 +00:00
|
|
|
GSPrintf(stderr, @"Loading '%@' - %@\n", file,
|
|
|
|
[localException reason]);
|
1999-05-14 18:41:16 +00:00
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[pool release];
|
|
|
|
return 0;
|
|
|
|
}
|