2004-03-29 03:37:46 +00:00
|
|
|
/** This tool converts a text property list to a serialised 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
|
|
|
|
|
|
|
|
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.
|
2005-02-22 11:22:44 +00:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public
|
1999-05-14 18:41:16 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
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
|
|
|
|
|
|
|
*/
|
|
|
|
|
2000-03-24 05:40:19 +00:00
|
|
|
#include "config.h"
|
2001-03-16 16:56:32 +00:00
|
|
|
#include <Foundation/Foundation.h>
|
1999-05-14 18:41:16 +00:00
|
|
|
#include <Foundation/NSArray.h>
|
|
|
|
#include <Foundation/NSData.h>
|
|
|
|
#include <Foundation/NSException.h>
|
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
#include <Foundation/NSProcessInfo.h>
|
|
|
|
#include <Foundation/NSUserDefaults.h>
|
|
|
|
#include <Foundation/NSDebug.h>
|
|
|
|
#include <Foundation/NSFileHandle.h>
|
|
|
|
#include <Foundation/NSAutoreleasePool.h>
|
|
|
|
|
|
|
|
|
2004-03-29 03:37:46 +00:00
|
|
|
/** <p> This tool converts a text property list to a binary serialised
|
|
|
|
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
|
|
|
|
[NSProcessInfo initializeWithArguments:argv count:argc environment:env];
|
|
|
|
#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(@"plser: 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 serialize.\n");
|
1999-05-14 18:41:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 1; i < [args count]; i++)
|
|
|
|
{
|
|
|
|
NSString *file = [args objectAtIndex: i];
|
|
|
|
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
NSData *myData;
|
|
|
|
NSString *myString;
|
|
|
|
id result;
|
|
|
|
|
|
|
|
myString = [NSString stringWithContentsOfFile: file];
|
|
|
|
result = [myString propertyList];
|
|
|
|
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;
|
|
|
|
|
|
|
|
myData = [NSSerializer serializePropertyList: result];
|
|
|
|
out = [NSFileHandle fileHandleWithStandardOutput];
|
|
|
|
[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;
|
|
|
|
}
|