diff --git a/ChangeLog b/ChangeLog index 8ab8c97b5..681c0f557 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-12-19 Richard Frith-Macdonald + + * Source/GSXML.m: Check validation status at parse completion. + * Source/NSUserDefaults.m: Ensure flags are initialised. + * Source/GSCompatibility.m: Set GNUstep DTD for propertyLists. + * Tools/plist-0_9.dtd: GNUstep property list DTD. + Wed Dec 19 02:17:09 2001 Nicola Pero * Source/NSThread.m (GSRegisterCurrentThread): Use @defs to diff --git a/Headers/gnustep/base/GSMime.h b/Headers/gnustep/base/GSMime.h index a653c7386..9cbf58546 100644 --- a/Headers/gnustep/base/GSMime.h +++ b/Headers/gnustep/base/GSMime.h @@ -111,7 +111,6 @@ - (BOOL) scanPastSpace: (NSScanner*)scanner; - (NSString*) scanSpecial: (NSScanner*)scanner; - (NSString*) scanToken: (NSScanner*)scanner; - @end #endif diff --git a/Headers/gnustep/base/NSProcessInfo.h b/Headers/gnustep/base/NSProcessInfo.h index 2afa38ea2..490aeef08 100644 --- a/Headers/gnustep/base/NSProcessInfo.h +++ b/Headers/gnustep/base/NSProcessInfo.h @@ -57,14 +57,11 @@ #ifndef NO_GNUSTEP @interface NSProcessInfo (GNUstep) -/* This method returns a set of debug levels set using the - * --GNU-Debug=... command line option. */ - (NSMutableSet*) debugSet; -/* When non using the other argument initialization hacks... */ -+ (void)initializeWithArguments: (char**)argv - count: (int)argc - environment: (char**)env; ++ (void) initializeWithArguments: (char**)argv + count: (int)argc + environment: (char**)env; @end /* diff --git a/Source/GSCompatibility.m b/Source/GSCompatibility.m index 9af7a2cbd..2d6c31d90 100644 --- a/Source/GSCompatibility.m +++ b/Source/GSCompatibility.m @@ -424,7 +424,8 @@ GSXMLPlMake(id obj, NSDictionary *loc) dest = [NSMutableString stringWithCString: "\n\n" + "PUBLIC \"-//GNUstep//DTD plist 0.9//EN\" " + "\"http://www.gnustep.org/plist-0_9.xml\">\n" "\n"]; XMLPlObject(dest, obj, loc, 0); diff --git a/Source/GSHTTPURLHandle.m b/Source/GSHTTPURLHandle.m index 14d03194d..41a8c0445 100644 --- a/Source/GSHTTPURLHandle.m +++ b/Source/GSHTTPURLHandle.m @@ -100,9 +100,11 @@ static void debugRead(NSData *data) d = open(debugFile, O_WRONLY|O_CREAT|O_APPEND, 0644); if (d >= 0) { - s = [NSString stringWithFormat: @"\nRead %@ -\n", [NSDate date]]; + s = [NSString stringWithFormat: @"\nRead %@ %u bytes - '", + [NSDate date], [data length]]; write(d, [s cString], [s cStringLength]); write(d, [data bytes], [data length]); + write(d, "'", 1); close(d); } [debugLock unlock]; @@ -116,9 +118,11 @@ static void debugWrite(NSData *data) d = open(debugFile, O_WRONLY|O_CREAT|O_APPEND, 0644); if (d >= 0) { - s = [NSString stringWithFormat: @"\nWrite %@ -\n", [NSDate date]]; + s = [NSString stringWithFormat: @"\nWrite %@ %u bytes - '", + [NSDate date], [data length]]; write(d, [s cString], [s cStringLength]); write(d, [data bytes], [data length]); + write(d, "'", 1); close(d); } [debugLock unlock]; diff --git a/Source/GSMime.m b/Source/GSMime.m index 859c59b31..93cfa1d46 100644 --- a/Source/GSMime.m +++ b/Source/GSMime.m @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -223,17 +224,31 @@ parseCharacterSet(NSString *token) return NSASCIIStringEncoding; } +/** + * The most rudimentary context ... this is used for decoding plain + * text and binary dat (ie data which is not really decoded at all) + * and all other decoding work is done by a subclass. + */ @implementation GSMimeCodingContext +/** + * Returns the current value of the 'atEnd' flag. + */ - (BOOL) atEnd { return atEnd; } +/** + * Copying is implemented as a simple retain. + */ - (id) copyWithZone: (NSZone*)z { return RETAIN(self); } +/** + * Sets the current value of the 'atEnd' flag. + */ - (void) setAtEnd: (BOOL)flag { atEnd = flag; @@ -297,33 +312,6 @@ parseCharacterSet(NSString *token) -@interface GSMimeBinaryDecoderContext : GSMimeCodingContext -@end -@implementation GSMimeBinaryDecoderContext -- (id) autorelease -{ - return self; -} -- (id) copyWithZone: (NSZone*)z -{ - return self; -} -- (void) dealloc -{ - NSLog(@"Error - attempt to deallocate GSMimeBinaryDecoderContext"); -} -- (id) retain -{ - return self; -} -- (void) release -{ -} -@end - - - - @interface GSMimeParser (Private) - (BOOL) _decodeBody: (NSData*)data; - (NSString*) _decodeHeader; @@ -369,9 +357,9 @@ parseCharacterSet(NSString *token) * * base64 * quoted-printable - * binary - * 7bit - * 8bit + * binary (no coding actually performed) + * 7bit (no coding actually performed) + * 8bit (no coding actually performed) * chunked (for HTTP/1.1) * */ @@ -382,7 +370,7 @@ parseCharacterSet(NSString *token) if (info == nil) { - return AUTORELEASE([GSMimeBinaryDecoderContext new]); + return AUTORELEASE([GSMimeCodingContext new]); } name = [info objectForKey: @"Name"]; @@ -393,7 +381,7 @@ parseCharacterSet(NSString *token) if ([value length] == 0) { NSLog(@"Bad value for %@ header - assume binary encoding", name); - return AUTORELEASE([GSMimeBinaryDecoderContext new]); + return AUTORELEASE([GSMimeCodingContext new]); } if ([value isEqualToString: @"base64"] == YES) { @@ -405,15 +393,15 @@ parseCharacterSet(NSString *token) } else if ([value isEqualToString: @"binary"] == YES) { - return AUTORELEASE([GSMimeBinaryDecoderContext new]); + return AUTORELEASE([GSMimeCodingContext new]); } else if ([value characterAtIndex: 0] == '7') { - return AUTORELEASE([GSMimeBinaryDecoderContext new]); + return AUTORELEASE([GSMimeCodingContext new]); } else if ([value characterAtIndex: 0] == '8') { - return AUTORELEASE([GSMimeBinaryDecoderContext new]); + return AUTORELEASE([GSMimeCodingContext new]); } else if ([value isEqualToString: @"chunked"] == YES) { @@ -422,7 +410,7 @@ parseCharacterSet(NSString *token) } NSLog(@"contextFor: - unknown header (%@) ... assumed binary encoding", name); - return AUTORELEASE([GSMimeBinaryDecoderContext new]); + return AUTORELEASE([GSMimeCodingContext new]); } /** @@ -828,7 +816,7 @@ parseCharacterSet(NSString *token) } } /* - * Append any data. + * Correct size of output buffer. */ [dData setLength: size + dst - beg]; } @@ -840,7 +828,6 @@ parseCharacterSet(NSString *token) [dData setLength: size + (end - src)]; dst = (unsigned char*)[dData mutableBytes]; memcpy(&dst[size], src, (end - src)); - [dData setLength: size + end - src]; } /* @@ -923,19 +910,22 @@ parseCharacterSet(NSString *token) *

* Since it is not always possible to determine if the end of a * MIME document has been reached from its content, the method - * may need to be called with a nil argument after you have + * may need to be called with a nil or empty argument after you have * passed all the data to it ... this tells it that the data * is complete. *

*/ - (BOOL) parse: (NSData*)d { + unsigned l = [d length]; + if (complete == YES) { return NO; /* Already completely parsed! */ } - if ([d length] > 0) + if (l > 0) { + NSDebugMLLog(@"GSMime", @"Parse %u bytes - '%*.*s'", l, l, l, [d bytes]); if (inBody == NO) { [data appendBytes: [d bytes] length: [d length]]; @@ -961,6 +951,11 @@ parseCharacterSet(NSString *token) { return NO; /* Header not parsed properly. */ } + NSDebugMLLog(@"GSMime", @"Parsed header '%@'", header); + } + else + { + NSDebugMLLog(@"GSMime", @"Parsed end of headers"); } } /* @@ -996,6 +991,7 @@ parseCharacterSet(NSString *token) * This is an intermediary response ... so we have * to restart the parsing operation! */ + NSDebugMLLog(@"GSMime", @"Parsed http continuation"); inBody = NO; } } @@ -1007,13 +1003,18 @@ parseCharacterSet(NSString *token) { if (inBody == YES) { - [self _decodeBody: d]; + /* + * We can't just re-call -parse: ... + * that would lead to recursion. + */ + return [self _decodeBody: d]; } else { return [self parse: d]; } } + return YES; /* Want more data for body */ } else @@ -1277,69 +1278,66 @@ parseCharacterSet(NSString *token) * work generally - *

* -* -* content-disposition -* -* -* Parameters -* -* A dictionary containing parameters as key-value pairs -* in lowercase -* -* Value -* -* The content disposition (excluding parameters) as a -* lowercase string. -* -* -* -* content-type -* -* -* Parameters -* -* A dictionary containing parameters as key-value pairs -* in lowercase. -* -* SubType -* The MIME subtype lowercase -* Type -* The MIME type lowercase -* value -* The full MIME type (xxx/yyy) in lowercase -* -* -* -* content-transfer-encoding -* -* -* Value -* The transfer encoding type in lowercase -* -* -* -* http -* -* -* HttpVersion -* The HTTP protocol version number -* HttpMajorVersion -* The first component of the version number -* HttpMinorVersion -* The second component of the version number -* HttpStatus -* The response status value (numeric code) -* Value -* The text message (if any) -* -* -* transfer-encoding -* -* -* Value -* The transfer encoding type in lowercase -* -* + * content-disposition + * + * + * Parameters + * + * A dictionary containing parameters as key-value pairs + * in lowercase + * + * Value + * + * The content disposition (excluding parameters) as a + * lowercase string. + * + * + * + * content-type + * + * + * Parameters + * + * A dictionary containing parameters as key-value pairs + * in lowercase. + * + * SubType + * The MIME subtype lowercase + * Type + * The MIME type lowercase + * value + * The full MIME type (xxx/yyy) in lowercase + * + * + * content-transfer-encoding + * + * + * Value + * The transfer encoding type in lowercase + * + * + * http + * + * + * HttpVersion + * The HTTP protocol version number + * HttpMajorVersion + * The first component of the version number + * HttpMinorVersion + * The second component of the version number + * HttpStatus + * The response status value (numeric code) + * Value + * The text message (if any) + * + * + * transfer-encoding + * + * + * Value + * The transfer encoding type in lowercase + * + * * */ - (BOOL) scanHeader: (NSScanner*)scanner @@ -1833,9 +1831,10 @@ parseCharacterSet(NSString *token) - (BOOL) _decodeBody: (NSData*)d { - BOOL result = NO; + unsigned l = [d length]; + BOOL result = NO; - rawBodyLength += [d length]; + rawBodyLength += l; if (context == nil) { @@ -1868,8 +1867,11 @@ parseCharacterSet(NSString *token) } context = [self contextFor: hdr]; RETAIN(context); + NSDebugMLLog(@"GSMime", @"Parse body expects %u bytes", expect); } + NSDebugMLLog(@"GSMime", @"Parse %u bytes - '%*.*s'", l, l, l, [d bytes]); + if ([context atEnd] == YES) { inBody = NO; @@ -1908,6 +1910,7 @@ parseCharacterSet(NSString *token) inBody = NO; complete = YES; + NSDebugMLLog(@"GSMime", @"Parse body complete"); /* * If no content type is supplied, we assume text. */ @@ -2162,7 +2165,6 @@ parseCharacterSet(NSString *token) } return unwrappingComplete; } - @end diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index 5df22498a..de82f0997 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -3,7 +3,6 @@ Written by: Georg Tuparev Heidelberg, Germany - Tuparev@EMBL-Heidelberg.de Modified by: Richard Frith-Macdonald This file is part of the GNUstep Base Library. @@ -522,12 +521,14 @@ int main(int argc, char *argv[], char *env[]) #endif /* HAS_LOAD_METHOD && HAS_PROCFS */ -/* Fallback method. User must call this method if none of the other - above hacks is being used -*/ -+ (void)initializeWithArguments:(char**)argv - count:(int)argc - environment:(char**)env +/** + * Fallback method. The developer must call this method to initialize + * the |NSProcessInfo system if none of the system-specific hacks to + * auto initiailise it are working. + */ ++ (void) initializeWithArguments: (char**)argv + count: (int)argc + environment: (char**)env { if (!_gnu_processName && !_gnu_arguments && !_gnu_environment) { @@ -563,6 +564,13 @@ int main(int argc, char *argv[], char *env[]) return _gnu_arguments; } +/** + * This method returns a set of debug levels set using the + * --GNU-Debug=... command line option.
+ * You can modify this set to change the debug logging under + * your programs control ... but such modifications are not + * thread-safe. + */ - (NSMutableSet*) debugSet { return _debug_set; diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index fbc435c5d..ab7092f52 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -349,6 +349,7 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ [sharedDefaults registerDefaults: [self _unlocalizedDefaults]]; } RETAIN(sharedDefaults); + updateCache(sharedDefaults); [classLock unlock]; return AUTORELEASE(sharedDefaults); } diff --git a/Tools/GNUmakefile b/Tools/GNUmakefile index 952c2706e..9f7a52914 100644 --- a/Tools/GNUmakefile +++ b/Tools/GNUmakefile @@ -33,7 +33,7 @@ include ../config.mak # DTDs to install dtddir = $(GNUSTEP_RESOURCES)/DTDs -DTD_FILES = gsdoc-0_6_5.dtd gsdoc-0_6_6.dtd gsdoc-0_6_7.dtd +DTD_FILES = plist-0_9.dtd gsdoc-0_6_5.dtd gsdoc-0_6_6.dtd gsdoc-0_6_7.dtd # DocTemplates to install doctemplatesdir = $(GNUSTEP_RESOURCES)/DocTemplates diff --git a/Tools/plist-0_9.dtd b/Tools/plist-0_9.dtd new file mode 100644 index 000000000..0f8799dee --- /dev/null +++ b/Tools/plist-0_9.dtd @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +