# HG changeset patch # User Jens Alfke # Date 1211660673 25200 # Node ID e5976864dfe936a7e78ab2a87302b48f3f68efa7 # Parent 82a37ccf6b8c4c56a53665762eb42bd7bae15f03 * Added BSD license to more .m files. * Updated some copyright notices. * Added some #imports to make the MYNetwork classes build without using the MYUtilities.pch prefix header. diff -r 82a37ccf6b8c -r e5976864dfe9 Base64.m --- a/Base64.m Tue May 20 17:40:28 2008 -0700 +++ b/Base64.m Sat May 24 13:24:33 2008 -0700 @@ -5,8 +5,9 @@ // Created by Jens Alfke on 1/27/08. // Copyright 2008 Jens Alfke. All rights reserved. // -// Adapted from SSCrypto.m by Ed Silva; +// Portions adapted from SSCrypto.m by Ed Silva; // Copyright (c) 2003-2006 Septicus Software. All rights reserved. +// Portions taken from uncopyrighted code posted by Dave Dribin. // #import "Base64.h" @@ -94,6 +95,8 @@ - (NSString *)my_hexString { + // Adapted from SSCrypto.m by Ed Silva: + // Copyright (c) 2003-2006 Septicus Software. All rights reserved. const UInt8 *bytes = self.bytes; NSUInteger length = self.length; char out[2*length+1]; @@ -106,6 +109,8 @@ - (NSString *)my_hexDump { + // Adapted from SSCrypto.m by Ed Silva: + // Copyright (c) 2003-2006 Septicus Software. All rights reserved. NSMutableString *ret=[NSMutableString stringWithCapacity:[self length]*2]; /* dumps size bytes of *data to string. Looks like: * [0000] 75 6E 6B 6E 6F 77 6E 20 @@ -165,3 +170,26 @@ } @end + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 CollectionUtils.h --- a/CollectionUtils.h Tue May 20 17:40:28 2008 -0700 +++ b/CollectionUtils.h Sat May 24 13:24:33 2008 -0700 @@ -6,7 +6,7 @@ // Copyright 2008 Jens Alfke. All rights reserved. // -#import +#import // Collection creation conveniences: diff -r 82a37ccf6b8c -r e5976864dfe9 CollectionUtils.m --- a/CollectionUtils.m Tue May 20 17:40:28 2008 -0700 +++ b/CollectionUtils.m Sat May 24 13:24:33 2008 -0700 @@ -267,3 +267,26 @@ nil]; CAssertEqual(d,dd); } + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 ConcurrentOperation.m --- a/ConcurrentOperation.m Tue May 20 17:40:28 2008 -0700 +++ b/ConcurrentOperation.m Sat May 24 13:24:33 2008 -0700 @@ -65,3 +65,26 @@ @end + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 DateUtils.h --- a/DateUtils.h Tue May 20 17:40:28 2008 -0700 +++ b/DateUtils.h Sat May 24 13:24:33 2008 -0700 @@ -1,9 +1,9 @@ // // DateUtils.h -// Cloudy +// MYUtilities // // Created by Jens Alfke on 3/25/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. +// Copyright 2008 Jens Alfke. All rights reserved. // #import diff -r 82a37ccf6b8c -r e5976864dfe9 DateUtils.m --- a/DateUtils.m Tue May 20 17:40:28 2008 -0700 +++ b/DateUtils.m Sat May 24 13:24:33 2008 -0700 @@ -1,9 +1,9 @@ // // DateUtils.m -// Cloudy +// MYUtilities // // Created by Jens Alfke on 3/25/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. +// Copyright 2008 Jens Alfke. All rights reserved. // #import "DateUtils.h" @@ -42,3 +42,26 @@ return *(uint64_t*)&elapsedNano / 1.0e9; } + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 ExceptionUtils.h --- a/ExceptionUtils.h Tue May 20 17:40:28 2008 -0700 +++ b/ExceptionUtils.h Sat May 24 13:24:33 2008 -0700 @@ -7,15 +7,17 @@ // See BSD license at bottom of ExceptionUtils.m. // -#import +#import +#ifdef NSAppKitVersionNumber10_4 // only enable this in a project that uses AppKit /** Edit your Info.plist to make this your app's principal class, and most exceptions will be reported via a modal alert. This includes exceptions caught by AppKit (i.e. uncaught ones from event handlers) and ones you report yourself via MYReportException and @catchAndReport. */ @interface MYExceptionReportingApplication : NSApplication @end +#endif /** A useful macro to use in code where you absolutely cannot allow an exception to @@ -39,3 +41,6 @@ /** Returns a textual, human-readable backtrace of the point where the exception was thrown. */ - (NSString*) my_callStack; @end + + +BOOL IsGDBAttached( void ); diff -r 82a37ccf6b8c -r e5976864dfe9 ExceptionUtils.m --- a/ExceptionUtils.m Tue May 20 17:40:28 2008 -0700 +++ b/ExceptionUtils.m Sat May 24 13:24:33 2008 -0700 @@ -8,7 +8,12 @@ // #import "ExceptionUtils.h" -#import + +#import "Logging.h" +#import "Test.h" + +#include +#include #ifndef Warn @@ -111,6 +116,8 @@ +#ifdef NSAppKitVersionNumber10_4 // only enable this in a project that uses AppKit + @implementation MYExceptionReportingApplication @@ -138,11 +145,11 @@ - (void) _showExceptionAlert: (NSException*)x { NSString *stack = [x my_callStack] ?:@""; - int r = NSRunCriticalAlertPanel( @"Cloudy Internal Error!", + int r = NSRunCriticalAlertPanel( @"Internal Error!", [NSString stringWithFormat: @"Uncaught exception: %@\n%@\n\n%@\n\n" - "Please report this bug to jens@mooseyard.com (you can copy & paste the text).", + "Please report this bug (you can copy & paste the text).", [x name], [x reason], stack], - @"Sorry",@"Quit",nil); + @"Continue",@"Quit",nil); if( r == NSAlertAlternateReturn ) exit(1); MYSetExceptionReporter(&report); @@ -150,9 +157,35 @@ @end +#endif + + + +BOOL IsGDBAttached( void ) +{ + // From: + int mib[4]; + size_t bufSize = 0; + int local_error = 0; + struct kinfo_proc kp; + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); + + bufSize = sizeof (kp); + if ((local_error = sysctl(mib, 4, &kp, &bufSize, NULL, 0)) < 0) { + Warn(@"Failure calling sysctl"); + return NO; + } + return (kp.kp_proc.p_flag & P_TRACED) != 0; +} + + /* - Copyright (c) 2008, Jens Alfke. All rights reserved. + Copyright (c) 2008, Jens Alfke . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -r 82a37ccf6b8c -r e5976864dfe9 FileAlias.m --- a/FileAlias.m Tue May 20 17:40:28 2008 -0700 +++ b/FileAlias.m Sat May 24 13:24:33 2008 -0700 @@ -229,3 +229,26 @@ @end + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 FileUtils.m --- a/FileUtils.m Tue May 20 17:40:28 2008 -0700 +++ b/FileUtils.m Sat May 24 13:24:33 2008 -0700 @@ -53,3 +53,26 @@ } return sPath; } + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 GraphicsUtils.m --- a/GraphicsUtils.m Tue May 20 17:40:28 2008 -0700 +++ b/GraphicsUtils.m Sat May 24 13:24:33 2008 -0700 @@ -272,3 +272,26 @@ return err; } + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 IChatUtils.h --- a/IChatUtils.h Tue May 20 17:40:28 2008 -0700 +++ b/IChatUtils.h Sat May 24 13:24:33 2008 -0700 @@ -7,7 +7,7 @@ // #import -@class SBApplication; +@class SBApplication, ABPerson; @interface IChatUtils : NSObject @@ -18,4 +18,8 @@ + (NSString*) activeChatPartner; + (BOOL) sendMessage: (NSString*)msg; ++ (NSDictionary*) iChatInfoForOnlinePerson: (ABPerson*)abPerson; ++ (BOOL) isPersonOnline: (ABPerson*)abPerson; ++ (BOOL) sendMessage: (NSString*)msg toPerson: (ABPerson*)abPerson; + @end diff -r 82a37ccf6b8c -r e5976864dfe9 IChatUtils.m --- a/IChatUtils.m Tue May 20 17:40:28 2008 -0700 +++ b/IChatUtils.m Sat May 24 13:24:33 2008 -0700 @@ -8,6 +8,7 @@ #import "IChatUtils.h" #import "iChatBridge.h" +#import @implementation IChatUtils @@ -63,5 +64,79 @@ return YES; } ++ (NSDictionary*) iChatInfoForOnlinePerson: (ABPerson*)abPerson +{ + if( ! abPerson ) + return nil; + IMPersonStatus bestStatus = IMPersonStatusOffline; + NSDictionary *bestInfo = nil; + for( IMService *service in [IMService allServices] ) { + for( NSString *name in [service screenNamesForPerson: abPerson] ) { + NSDictionary *info = [service infoForScreenName: name]; + if( [[info objectForKey: IMPersonCapabilitiesKey] containsObject: IMCapabilityText] ) { + IMPersonStatus status = [[info objectForKey: IMPersonStatusKey] intValue]; + if( IMComparePersonStatus(status,bestStatus) < 0 ) { // yes, it returns the wrong sign + bestInfo = info; + bestStatus = status; + } + } + } + } + return bestInfo; +} + ++ (BOOL) isPersonOnline: (ABPerson*)abPerson +{ + return [self iChatInfoForOnlinePerson: abPerson] != nil; +} + ++ (iChatBuddy*) buddyWithInfo: (NSDictionary*)info +{ + NSString *ident = [info objectForKey: IMPersonScreenNameKey]; + NSPredicate *pred = [NSPredicate predicateWithFormat: @"handle==%@", ident]; + @try{ + return [[[[sIChatApp buddies] filteredArrayUsingPredicate: pred] objectAtIndex: 0] get]; + } @catch( NSException *x ) { + Log(@"buddyWithInfo got exception: %@",x); + } + return nil; +} + ++ (BOOL) sendMessage: (NSString*)msg toPerson: (ABPerson*)abPerson +{ + NSDictionary *info = [self iChatInfoForOnlinePerson: abPerson]; + if( info ) { + iChatBuddy *buddy = [self buddyWithInfo: info]; + if( buddy ) { + [sIChatApp send: msg to: buddy]; + return YES; + } + } + return NO; +} + @end + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 KVUtils.m --- a/KVUtils.m Tue May 20 17:40:28 2008 -0700 +++ b/KVUtils.m Sat May 24 13:24:33 2008 -0700 @@ -168,3 +168,26 @@ } @end + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 Logging.h --- a/Logging.h Tue May 20 17:40:28 2008 -0700 +++ b/Logging.h Sat May 24 13:24:33 2008 -0700 @@ -6,25 +6,32 @@ // Copyright 2008 Jens Alfke. All rights reserved. // -#import +#import NSString* LOC( NSString *key ); // Localized string lookup -#ifdef __cplusplus - #define IN_SEGMENT(SEG) -#else +// To enable IN_SEGMENT (which breaks rarely-called logging code out of your main code segment, +// improving locality of reference) you must define MY_USE_NESTED_FNS in your prefix file or +// target settings, and add the GCC flag "-fnested-functions" to your target's C flags. +#if defined(MY_USE_NESTED_FNS) && ! defined(__cplusplus) #define IN_SEGMENT(SEG) auto __attribute__ ((section ("__TEXT, "#SEG))) __attribute__ ((noinline)) void _outofband_(void);\ _outofband_();\ void _outofband_(void) + #define IN_SEGMENT_NORETURN(SEG) auto __attribute__ ((section ("__TEXT, "#SEG))) __attribute__ ((noinline)) __attribute__((noreturn)) void _assertfailure_(void);\ + _assertfailure_();\ + void _assertfailure_(void) +#else + #define IN_SEGMENT(SEG) + #define IN_SEGMENT_NORETURN(SEG) #endif #define Log(FMT,ARGS...) do{if(__builtin_expect(_gShouldLog,0)) {\ IN_SEGMENT(Logging){_Log(FMT,##ARGS);}\ } }while(0) #define LogTo(DOMAIN,FMT,ARGS...) do{if(__builtin_expect(_gShouldLog,0)) {\ - IN_SEGMENT(Logging) {_LogTo(@""#DOMAIN,FMT,##ARGS);}\ + IN_SEGMENT(Logging) {if(_WillLogTo(@""#DOMAIN)) _LogTo(@""#DOMAIN,FMT,##ARGS);}\ } }while(0) #define Warn Warn diff -r 82a37ccf6b8c -r e5976864dfe9 Logging.m --- a/Logging.m Tue May 20 17:40:28 2008 -0700 +++ b/Logging.m Sat May 24 13:24:33 2008 -0700 @@ -7,9 +7,12 @@ // #import "Logging.h" -#import +#import "CollectionUtils.h" + +#include #include #include +#include NSString* LOC( NSString *key ) // Localized string lookup @@ -23,19 +26,35 @@ } +typedef enum { + kLoggingToOther, + kLoggingToFile, + kLoggingToTTY, + kLoggingToColorTTY +} MYLoggingTo; + + int _gShouldLog = -1; -static BOOL sConsole; +static MYLoggingTo sLoggingTo; static NSMutableSet *sEnabledDomains; -static BOOL isConsole( int fd ) +/** Does the file descriptor connect to console output, i.e. a terminal or Xcode? */ +static MYLoggingTo getLoggingMode( int fd ) { - if( isatty(fd) ) - return YES; - char path[MAXPATHLEN]; - if( fcntl(fd, F_GETPATH, path) == -1 ) - return NO; - return YES; + if( isatty(fd) ) { + const char *term = getenv("TERM"); + if( term && (strstr(term,"ANSI") || strstr(term,"ansi") || strstr(term,"color")) ) + return kLoggingToColorTTY; + else + return kLoggingToTTY; + } else { + char path[MAXPATHLEN]; + if( fcntl(fd, F_GETPATH, path) == 0 ) + return kLoggingToFile; + else + return kLoggingToOther; + } } @@ -57,9 +76,10 @@ [sEnabledDomains addObject: [key substringFromIndex: 3]]; } } - sConsole = isConsole(STDERR_FILENO); + sLoggingTo = getLoggingMode(STDERR_FILENO); - Log(@"Logging enabled in domains: {%@}", + Log(@"Logging mode %i enabled in domains: {%@}", + sLoggingTo, [[[sEnabledDomains allObjects] sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)] componentsJoinedByString: @", "]); [pool drain]; @@ -95,9 +115,14 @@ } +#define kWarningPrefix @"\007WARNING*** " + +#define COLOR(STR) (sLoggingTo==kLoggingToColorTTY ?@"\033["#STR"m" :@"") + + static void _Logv( NSString *prefix, NSString *msg, va_list args ) { - if( sConsole ) { + if( sLoggingTo > kLoggingToOther ) { NSAutoreleasePool *pool = [NSAutoreleasePool new]; static NSDateFormatter *sTimestampFormat; if( ! sTimestampFormat ) { @@ -109,14 +134,21 @@ [now release]; NSString *separator = prefix.length ?@": " :@""; msg = [[NSString alloc] initWithFormat: msg arguments: args]; - NSString *finalMsg = [[NSString alloc] initWithFormat: @"%@| %@%@%@\n", - timestamp,prefix,separator,msg]; + NSString *prefixColor = (prefix==kWarningPrefix) ?COLOR(91) :COLOR(93); + NSString *msgColor = (prefix==kWarningPrefix) ?@"" :COLOR(0); + NSString *finalMsg = [[NSString alloc] initWithFormat: @"%@%@| %@%@%@%@%@\n", + COLOR(30),timestamp, + prefixColor,prefix,separator, + msgColor,msg]; fputs([finalMsg UTF8String], stderr); [finalMsg release]; [msg release]; [pool drain]; - } else + } else { + if( prefix.length ) + msg = $sprintf(@"%@: %@", prefix,msg); NSLogv(msg,args); + } } @@ -159,8 +191,31 @@ { va_list args; va_start(args,msg); - _Logv(@"WARNING*** ",msg,args); + _Logv(kWarningPrefix,msg,args); va_end(args); } + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 MYUtilitiesTest_main.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MYUtilitiesTest_main.m Sat May 24 13:24:33 2008 -0700 @@ -0,0 +1,17 @@ +// +// MYUtilitiesTest_main.m +// MYNetwork +// +// Created by Jens Alfke on 5/21/08. +// Copyright 2008 Jens Alfke. All rights reserved. +// + + +#import "Test.h" + + +int main(int argc, const char *argv[]) +{ + RunTestCases(argc,argv); + return 0; +} diff -r 82a37ccf6b8c -r e5976864dfe9 MYUtilities_Prefix.pch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MYUtilities_Prefix.pch Sat May 24 13:24:33 2008 -0700 @@ -0,0 +1,10 @@ +// +// Prefix header for clients of MYUtilities. +// + +#ifdef __OBJC__ + #import + #import "Logging.h" + #import "Test.h" + #import "CollectionUtils.h" +#endif diff -r 82a37ccf6b8c -r e5976864dfe9 Target.h --- a/Target.h Tue May 20 17:40:28 2008 -0700 +++ b/Target.h Sat May 24 13:24:33 2008 -0700 @@ -6,7 +6,7 @@ // Copyright 2008 Jens Alfke. All rights reserved. // -#import +#import @interface MYTarget : NSObject diff -r 82a37ccf6b8c -r e5976864dfe9 Target.m --- a/Target.m Tue May 20 17:40:28 2008 -0700 +++ b/Target.m Sat May 24 13:24:33 2008 -0700 @@ -7,6 +7,8 @@ // #import "Target.h" +#import "Logging.h" +#import "Test.h" @implementation MYTarget @@ -147,3 +149,26 @@ @end + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 Test.h --- a/Test.h Tue May 20 17:40:28 2008 -0700 +++ b/Test.h Sat May 24 13:24:33 2008 -0700 @@ -48,22 +48,16 @@ /** Can call this in a test case to indicate a prerequisite. The prerequisite test will be run first, and if it fails, the current test case will be skipped. */ +#if DEBUG #define RequireTestCase(NAME) _RequireTestCase(#NAME) void _RequireTestCase( const char *name ); - +#else +#define RequireTestCase(NAME) +#endif /** General-purpose assertions, replacing NSAssert etc.. You can use these outside test cases. */ -#ifdef __cplusplus - #define IN_SEGMENT_NORETURN(SEG) -#else - #define IN_SEGMENT_NORETURN(SEG) auto __attribute__ ((section ("__TEXT, "#SEG))) __attribute__ ((noinline)) __attribute__((noreturn)) void _assertfailure_(void);\ - _assertfailure_();\ - void _assertfailure_(void) -#endif - - #define Assert(COND,MSG...) do{ if( __builtin_expect(!(COND),NO) ) { \ IN_SEGMENT_NORETURN(Logging) {_AssertFailed(self,(const char*)_cmd, __FILE__, __LINE__,\ #COND,##MSG,NULL);} } }while(0) @@ -80,6 +74,7 @@ }while(0) // AssertEq is for scalars (int, float...) +// Note: "typeof()" builtin function requires settingn C language dialect to GNU99. #define AssertEq(VAL,EXPECTED) do{ typeof(VAL) _val = VAL; typeof(EXPECTED) _expected = EXPECTED;\ Assert(_val==_expected, @"Unexpected value for %s: %@ (expected %@)", #VAL,$object(_val),$object(_expected)); \ }while(0) diff -r 82a37ccf6b8c -r e5976864dfe9 Test.m --- a/Test.m Tue May 20 17:40:28 2008 -0700 +++ b/Test.m Sat May 24 13:24:33 2008 -0700 @@ -7,6 +7,7 @@ // #import "Test.h" +#import "ExceptionUtils.h" #if DEBUG @@ -148,3 +149,26 @@ description: @"%@", message]; abort(); // unreachable, but appeases compiler } + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 TimeIntervalFormatter.m --- a/TimeIntervalFormatter.m Tue May 20 17:40:28 2008 -0700 +++ b/TimeIntervalFormatter.m Sat May 24 13:24:33 2008 -0700 @@ -108,3 +108,26 @@ @end + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 URLUtils.h --- a/URLUtils.h Tue May 20 17:40:28 2008 -0700 +++ b/URLUtils.h Sat May 24 13:24:33 2008 -0700 @@ -1,9 +1,9 @@ // // URLUtils.h -// Cloudy +// MYUtilities // // Created by Jens Alfke on 4/28/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. +// Copyright 2008 Jens Alfke. All rights reserved. // #import diff -r 82a37ccf6b8c -r e5976864dfe9 URLUtils.m --- a/URLUtils.m Tue May 20 17:40:28 2008 -0700 +++ b/URLUtils.m Sat May 24 13:24:33 2008 -0700 @@ -1,9 +1,9 @@ // // URLUtils.m -// Cloudy +// MYUtilities // // Created by Jens Alfke on 4/28/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. +// Copyright 2008 Jens Alfke. All rights reserved. // #import "URLUtils.h" @@ -30,3 +30,26 @@ @end + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 UniqueWindowController.h --- a/UniqueWindowController.h Tue May 20 17:40:28 2008 -0700 +++ b/UniqueWindowController.h Sat May 24 13:24:33 2008 -0700 @@ -1,9 +1,9 @@ // // UniqueWindowController.h -// Cloudy +// MYUtilities // // Created by Jens Alfke on 3/14/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. +// Copyright 2008 Jens Alfke. All rights reserved. // #import diff -r 82a37ccf6b8c -r e5976864dfe9 UniqueWindowController.m --- a/UniqueWindowController.m Tue May 20 17:40:28 2008 -0700 +++ b/UniqueWindowController.m Sat May 24 13:24:33 2008 -0700 @@ -1,9 +1,9 @@ // // UniqueWindowController.m -// Cloudy +// MYUtilities // // Created by Jens Alfke on 3/14/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. +// Copyright 2008 Jens Alfke. All rights reserved. // #import "UniqueWindowController.h" @@ -57,3 +57,26 @@ @end + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 ValueArray.m --- a/ValueArray.m Tue May 20 17:40:28 2008 -0700 +++ b/ValueArray.m Sat May 24 13:24:33 2008 -0700 @@ -91,3 +91,26 @@ ImplementValueArrayOf(Int,int) ImplementValueArrayOf(Double,double) + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff -r 82a37ccf6b8c -r e5976864dfe9 With.m --- a/With.m Tue May 20 17:40:28 2008 -0700 +++ b/With.m Sat May 24 13:24:33 2008 -0700 @@ -31,4 +31,27 @@ + (NSAutoreleasePool*) beginWith {return [self new];} - (void) endWith {[self drain];} - (BOOL) endWith: (NSException*)x {[self drain]; return YES;} -@end \ No newline at end of file +@end + + +/* + Copyright (c) 2008, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */