From ee14b4764960b33f05c4ed735116a6fb614bbf57 Mon Sep 17 00:00:00 2001 From: richard Date: Fri, 14 May 1999 18:41:16 +0000 Subject: [PATCH] New tools git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4253 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++ Tools/GNUmakefile | 4 ++- Tools/pldes.m | 92 +++++++++++++++++++++++++++++++++++++++++++++++ Tools/plser.m | 90 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 Tools/pldes.m create mode 100644 Tools/plser.m diff --git a/ChangeLog b/ChangeLog index 585b77d72..369dd0fd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri May 14 20:00:00 1999 Richard Frith-Macdonald + + * Tools/pldes.m: new tool to deserialise serialised property lists. + * Tools/plser.m: new tool to serialise text property lists. + * Tools/GNUmakefile: add pldes and plser + Mon May 11 15:00:00 1999 Manuel Guesdon * Source/NSArray.m: getObjects: (id*)aBuffer range: (NSRange)aRange diff --git a/Tools/GNUmakefile b/Tools/GNUmakefile index f10063724..780bf69b1 100644 --- a/Tools/GNUmakefile +++ b/Tools/GNUmakefile @@ -31,7 +31,7 @@ include ../Version include ../config.mak # The application to be compiled -TOOL_NAME = gdnc defaults dread dwrite dremove plparse sfparse +TOOL_NAME = gdnc defaults dread dwrite dremove plparse sfparse pldes plser OBJC_PROGRAM_NAME = gdomap # The source files to be compiled @@ -41,6 +41,8 @@ defaults_OBJC_FILES = defaults.m dread_OBJC_FILES = dread.m dremove_OBJC_FILES = dremove.m dwrite_OBJC_FILES = dwrite.m +pldes_OBJC_FILES = pldes.m +plser_OBJC_FILES = plser.m plparse_OBJC_FILES = plparse.m sfparse_OBJC_FILES = sfparse.m diff --git a/Tools/pldes.m b/Tools/pldes.m new file mode 100644 index 000000000..4c494d723 --- /dev/null +++ b/Tools/pldes.m @@ -0,0 +1,92 @@ +/* This tool converts a serialised proerty list to a text representation. + Copyright (C) 1999 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald + 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. + + 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. + + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +int +main(int argc, char** argv) +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + NSUserDefaults *defs; + NSProcessInfo *proc; + NSArray *args; + unsigned i; + + proc = [NSProcessInfo processInfo]; + if (proc == nil) + { + NSLog(@"defaults: unable to get process information!\n"); + [pool release]; + exit(0); + } + + args = [proc arguments]; + + if ([args count] <= 1) + { + NSLog(@"No file names given to deserialize."); + } + else + { + 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) + NSLog(@"Loading '%@' - nil property list", file); + else + { + NSFileHandle *out; + + myString = [result description]; + out = [NSFileHandle fileHandleWithStandardOutput]; + myData = [myString dataUsingEncoding: NSASCIIStringEncoding]; + [out writeData: myData]; + [out synchronizeFile]; + } + } + NS_HANDLER + { + NSLog(@"Loading '%@' - %@", file, [localException reason]); + } + NS_ENDHANDLER + } + } + [pool release]; + return 0; +} diff --git a/Tools/plser.m b/Tools/plser.m new file mode 100644 index 000000000..a008681ef --- /dev/null +++ b/Tools/plser.m @@ -0,0 +1,90 @@ +/* This tool converts a text property list to a serialised representation. + Copyright (C) 1999 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald + 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. + + 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. + + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +int +main(int argc, char** argv) +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + NSUserDefaults *defs; + NSProcessInfo *proc; + NSArray *args; + unsigned i; + + proc = [NSProcessInfo processInfo]; + if (proc == nil) + { + NSLog(@"defaults: unable to get process information!\n"); + [pool release]; + exit(0); + } + + args = [proc arguments]; + + if ([args count] <= 1) + { + NSLog(@"No file names given to deserialize."); + } + 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) + NSLog(@"Loading '%@' - nil property list", file); + else + { + NSFileHandle *out; + + myData = [NSSerializer serializePropertyList: result]; + out = [NSFileHandle fileHandleWithStandardOutput]; + [out writeData: myData]; + [out synchronizeFile]; + } + } + NS_HANDLER + { + NSLog(@"Loading '%@' - %@", file, [localException reason]); + } + NS_ENDHANDLER + } + } + [pool release]; + return 0; +}