* Added BSD license to more .m files.
authorJens Alfke <jens@mooseyard.com>
Sat May 24 13:24:33 2008 -0700 (2008-05-24)
changeset 11e5976864dfe9
parent 10 82a37ccf6b8c
child 12 66b870428f85
* 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.
Base64.m
CollectionUtils.h
CollectionUtils.m
ConcurrentOperation.m
DateUtils.h
DateUtils.m
ExceptionUtils.h
ExceptionUtils.m
FileAlias.m
FileUtils.m
GraphicsUtils.m
IChatUtils.h
IChatUtils.m
KVUtils.m
Logging.h
Logging.m
MYUtilitiesTest_main.m
MYUtilities_Prefix.pch
Target.h
Target.m
Test.h
Test.m
TimeIntervalFormatter.m
URLUtils.h
URLUtils.m
UniqueWindowController.h
UniqueWindowController.m
ValueArray.m
With.m
     1.1 --- a/Base64.m	Tue May 20 17:40:28 2008 -0700
     1.2 +++ b/Base64.m	Sat May 24 13:24:33 2008 -0700
     1.3 @@ -5,8 +5,9 @@
     1.4  //  Created by Jens Alfke on 1/27/08.
     1.5  //  Copyright 2008 Jens Alfke. All rights reserved.
     1.6  //
     1.7 -//  Adapted from SSCrypto.m by Ed Silva;
     1.8 +//  Portions adapted from SSCrypto.m by Ed Silva;
     1.9  //  Copyright (c) 2003-2006 Septicus Software. All rights reserved.
    1.10 +//  Portions taken from uncopyrighted code posted by Dave Dribin.
    1.11  //
    1.12  
    1.13  #import "Base64.h"
    1.14 @@ -94,6 +95,8 @@
    1.15  
    1.16  - (NSString *)my_hexString
    1.17  {
    1.18 +    //  Adapted from SSCrypto.m by Ed Silva:
    1.19 +    //  Copyright (c) 2003-2006 Septicus Software. All rights reserved.
    1.20      const UInt8 *bytes = self.bytes;
    1.21      NSUInteger length = self.length;
    1.22      char out[2*length+1];
    1.23 @@ -106,6 +109,8 @@
    1.24  
    1.25  - (NSString *)my_hexDump
    1.26  {
    1.27 +    //  Adapted from SSCrypto.m by Ed Silva:
    1.28 +    //  Copyright (c) 2003-2006 Septicus Software. All rights reserved.
    1.29      NSMutableString *ret=[NSMutableString stringWithCapacity:[self length]*2];
    1.30      /* dumps size bytes of *data to string. Looks like:
    1.31       * [0000] 75 6E 6B 6E 6F 77 6E 20
    1.32 @@ -165,3 +170,26 @@
    1.33  }
    1.34  
    1.35  @end
    1.36 +
    1.37 +
    1.38 +/*
    1.39 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
    1.40 + 
    1.41 + Redistribution and use in source and binary forms, with or without modification, are permitted
    1.42 + provided that the following conditions are met:
    1.43 + 
    1.44 + * Redistributions of source code must retain the above copyright notice, this list of conditions
    1.45 + and the following disclaimer.
    1.46 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
    1.47 + and the following disclaimer in the documentation and/or other materials provided with the
    1.48 + distribution.
    1.49 + 
    1.50 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
    1.51 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
    1.52 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
    1.53 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    1.54 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
    1.55 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
    1.56 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
    1.57 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.58 + */
     2.1 --- a/CollectionUtils.h	Tue May 20 17:40:28 2008 -0700
     2.2 +++ b/CollectionUtils.h	Sat May 24 13:24:33 2008 -0700
     2.3 @@ -6,7 +6,7 @@
     2.4  //  Copyright 2008 Jens Alfke. All rights reserved.
     2.5  //
     2.6  
     2.7 -#import <Cocoa/Cocoa.h>
     2.8 +#import <Foundation/Foundation.h>
     2.9  
    2.10  // Collection creation conveniences:
    2.11  
     3.1 --- a/CollectionUtils.m	Tue May 20 17:40:28 2008 -0700
     3.2 +++ b/CollectionUtils.m	Sat May 24 13:24:33 2008 -0700
     3.3 @@ -267,3 +267,26 @@
     3.4                          nil];
     3.5      CAssertEqual(d,dd);
     3.6  }
     3.7 +
     3.8 +
     3.9 +/*
    3.10 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
    3.11 + 
    3.12 + Redistribution and use in source and binary forms, with or without modification, are permitted
    3.13 + provided that the following conditions are met:
    3.14 + 
    3.15 + * Redistributions of source code must retain the above copyright notice, this list of conditions
    3.16 + and the following disclaimer.
    3.17 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
    3.18 + and the following disclaimer in the documentation and/or other materials provided with the
    3.19 + distribution.
    3.20 + 
    3.21 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
    3.22 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
    3.23 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
    3.24 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    3.25 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
    3.26 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
    3.27 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
    3.28 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    3.29 + */
     4.1 --- a/ConcurrentOperation.m	Tue May 20 17:40:28 2008 -0700
     4.2 +++ b/ConcurrentOperation.m	Sat May 24 13:24:33 2008 -0700
     4.3 @@ -65,3 +65,26 @@
     4.4  
     4.5  
     4.6  @end
     4.7 +
     4.8 +
     4.9 +/*
    4.10 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
    4.11 + 
    4.12 + Redistribution and use in source and binary forms, with or without modification, are permitted
    4.13 + provided that the following conditions are met:
    4.14 + 
    4.15 + * Redistributions of source code must retain the above copyright notice, this list of conditions
    4.16 + and the following disclaimer.
    4.17 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
    4.18 + and the following disclaimer in the documentation and/or other materials provided with the
    4.19 + distribution.
    4.20 + 
    4.21 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
    4.22 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
    4.23 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
    4.24 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    4.25 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
    4.26 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
    4.27 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
    4.28 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    4.29 + */
     5.1 --- a/DateUtils.h	Tue May 20 17:40:28 2008 -0700
     5.2 +++ b/DateUtils.h	Sat May 24 13:24:33 2008 -0700
     5.3 @@ -1,9 +1,9 @@
     5.4  //
     5.5  //  DateUtils.h
     5.6 -//  Cloudy
     5.7 +//  MYUtilities
     5.8  //
     5.9  //  Created by Jens Alfke on 3/25/08.
    5.10 -//  Copyright 2008 __MyCompanyName__. All rights reserved.
    5.11 +//  Copyright 2008 Jens Alfke. All rights reserved.
    5.12  //
    5.13  
    5.14  #import <Cocoa/Cocoa.h>
     6.1 --- a/DateUtils.m	Tue May 20 17:40:28 2008 -0700
     6.2 +++ b/DateUtils.m	Sat May 24 13:24:33 2008 -0700
     6.3 @@ -1,9 +1,9 @@
     6.4  //
     6.5  //  DateUtils.m
     6.6 -//  Cloudy
     6.7 +//  MYUtilities
     6.8  //
     6.9  //  Created by Jens Alfke on 3/25/08.
    6.10 -//  Copyright 2008 __MyCompanyName__. All rights reserved.
    6.11 +//  Copyright 2008 Jens Alfke. All rights reserved.
    6.12  //
    6.13  
    6.14  #import "DateUtils.h"
    6.15 @@ -42,3 +42,26 @@
    6.16      return *(uint64_t*)&elapsedNano / 1.0e9;
    6.17  }
    6.18  
    6.19 +
    6.20 +
    6.21 +/*
    6.22 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
    6.23 + 
    6.24 + Redistribution and use in source and binary forms, with or without modification, are permitted
    6.25 + provided that the following conditions are met:
    6.26 + 
    6.27 + * Redistributions of source code must retain the above copyright notice, this list of conditions
    6.28 + and the following disclaimer.
    6.29 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
    6.30 + and the following disclaimer in the documentation and/or other materials provided with the
    6.31 + distribution.
    6.32 + 
    6.33 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
    6.34 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
    6.35 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
    6.36 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    6.37 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
    6.38 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
    6.39 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
    6.40 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    6.41 + */
     7.1 --- a/ExceptionUtils.h	Tue May 20 17:40:28 2008 -0700
     7.2 +++ b/ExceptionUtils.h	Sat May 24 13:24:33 2008 -0700
     7.3 @@ -7,15 +7,17 @@
     7.4  //  See BSD license at bottom of ExceptionUtils.m.
     7.5  //
     7.6  
     7.7 -#import <Cocoa/Cocoa.h>
     7.8 +#import <Foundation/Foundation.h>
     7.9  
    7.10  
    7.11 +#ifdef NSAppKitVersionNumber10_4 // only enable this in a project that uses AppKit
    7.12  /** Edit your Info.plist to make this your app's principal class,
    7.13      and most exceptions will be reported via a modal alert. 
    7.14      This includes exceptions caught by AppKit (i.e. uncaught ones from event handlers)
    7.15      and ones you report yourself via MYReportException and @catchAndReport. */
    7.16  @interface MYExceptionReportingApplication : NSApplication
    7.17  @end
    7.18 +#endif
    7.19  
    7.20  
    7.21  /** A useful macro to use in code where you absolutely cannot allow an exception to 
    7.22 @@ -39,3 +41,6 @@
    7.23  /** Returns a textual, human-readable backtrace of the point where the exception was thrown. */
    7.24  - (NSString*) my_callStack;
    7.25  @end
    7.26 +
    7.27 +
    7.28 +BOOL IsGDBAttached( void );
     8.1 --- a/ExceptionUtils.m	Tue May 20 17:40:28 2008 -0700
     8.2 +++ b/ExceptionUtils.m	Sat May 24 13:24:33 2008 -0700
     8.3 @@ -8,7 +8,12 @@
     8.4  //
     8.5  
     8.6  #import "ExceptionUtils.h"
     8.7 -#import <unistd.h>
     8.8 +
     8.9 +#import "Logging.h"
    8.10 +#import "Test.h"
    8.11 +
    8.12 +#include <sys/sysctl.h>
    8.13 +#include <unistd.h>
    8.14  
    8.15  
    8.16  #ifndef Warn
    8.17 @@ -111,6 +116,8 @@
    8.18  
    8.19  
    8.20  
    8.21 +#ifdef NSAppKitVersionNumber10_4 // only enable this in a project that uses AppKit
    8.22 +
    8.23  @implementation MYExceptionReportingApplication
    8.24  
    8.25  
    8.26 @@ -138,11 +145,11 @@
    8.27  - (void) _showExceptionAlert: (NSException*)x
    8.28  {
    8.29      NSString *stack = [x my_callStack] ?:@"";
    8.30 -    int r = NSRunCriticalAlertPanel( @"Cloudy Internal Error!",
    8.31 +    int r = NSRunCriticalAlertPanel( @"Internal Error!",
    8.32                              [NSString stringWithFormat: @"Uncaught exception: %@\n%@\n\n%@\n\n"
    8.33 -                             "Please report this bug to jens@mooseyard.com (you can copy & paste the text).",
    8.34 +                             "Please report this bug (you can copy & paste the text).",
    8.35                               [x name], [x reason], stack],
    8.36 -                            @"Sorry",@"Quit",nil);
    8.37 +                            @"Continue",@"Quit",nil);
    8.38      if( r == NSAlertAlternateReturn )
    8.39          exit(1);
    8.40      MYSetExceptionReporter(&report);
    8.41 @@ -150,9 +157,35 @@
    8.42  
    8.43  @end
    8.44  
    8.45 +#endif
    8.46 +
    8.47 +
    8.48 +
    8.49 +BOOL IsGDBAttached( void )
    8.50 +{
    8.51 +    // From: <http://lists.apple.com/archives/Xcode-users/2004/Feb/msg00241.html>
    8.52 +    int mib[4];
    8.53 +    size_t bufSize = 0;
    8.54 +    int local_error = 0;
    8.55 +    struct kinfo_proc kp;
    8.56 +    
    8.57 +    mib[0] = CTL_KERN;
    8.58 +    mib[1] = KERN_PROC;
    8.59 +    mib[2] = KERN_PROC_PID;
    8.60 +    mib[3] = getpid();
    8.61 +    
    8.62 +    bufSize = sizeof (kp);
    8.63 +    if ((local_error = sysctl(mib, 4, &kp, &bufSize, NULL, 0)) < 0) {
    8.64 +        Warn(@"Failure calling sysctl");
    8.65 +        return NO;
    8.66 +    }
    8.67 +    return (kp.kp_proc.p_flag & P_TRACED) != 0;
    8.68 +}
    8.69 +
    8.70 +
    8.71  
    8.72  /*
    8.73 - Copyright (c) 2008, Jens Alfke. All rights reserved.
    8.74 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
    8.75   
    8.76   Redistribution and use in source and binary forms, with or without modification, are permitted
    8.77   provided that the following conditions are met:
     9.1 --- a/FileAlias.m	Tue May 20 17:40:28 2008 -0700
     9.2 +++ b/FileAlias.m	Sat May 24 13:24:33 2008 -0700
     9.3 @@ -229,3 +229,26 @@
     9.4  
     9.5  
     9.6  @end
     9.7 +
     9.8 +
     9.9 +/*
    9.10 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
    9.11 + 
    9.12 + Redistribution and use in source and binary forms, with or without modification, are permitted
    9.13 + provided that the following conditions are met:
    9.14 + 
    9.15 + * Redistributions of source code must retain the above copyright notice, this list of conditions
    9.16 + and the following disclaimer.
    9.17 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
    9.18 + and the following disclaimer in the documentation and/or other materials provided with the
    9.19 + distribution.
    9.20 + 
    9.21 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
    9.22 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
    9.23 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
    9.24 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    9.25 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
    9.26 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
    9.27 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
    9.28 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    9.29 + */
    10.1 --- a/FileUtils.m	Tue May 20 17:40:28 2008 -0700
    10.2 +++ b/FileUtils.m	Sat May 24 13:24:33 2008 -0700
    10.3 @@ -53,3 +53,26 @@
    10.4      }
    10.5      return sPath;
    10.6  }
    10.7 +
    10.8 +
    10.9 +/*
   10.10 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
   10.11 + 
   10.12 + Redistribution and use in source and binary forms, with or without modification, are permitted
   10.13 + provided that the following conditions are met:
   10.14 + 
   10.15 + * Redistributions of source code must retain the above copyright notice, this list of conditions
   10.16 + and the following disclaimer.
   10.17 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
   10.18 + and the following disclaimer in the documentation and/or other materials provided with the
   10.19 + distribution.
   10.20 + 
   10.21 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
   10.22 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
   10.23 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
   10.24 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   10.25 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
   10.26 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   10.27 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
   10.28 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   10.29 + */
    11.1 --- a/GraphicsUtils.m	Tue May 20 17:40:28 2008 -0700
    11.2 +++ b/GraphicsUtils.m	Sat May 24 13:24:33 2008 -0700
    11.3 @@ -272,3 +272,26 @@
    11.4      return err;
    11.5  }
    11.6  
    11.7 +
    11.8 +
    11.9 +/*
   11.10 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
   11.11 + 
   11.12 + Redistribution and use in source and binary forms, with or without modification, are permitted
   11.13 + provided that the following conditions are met:
   11.14 + 
   11.15 + * Redistributions of source code must retain the above copyright notice, this list of conditions
   11.16 + and the following disclaimer.
   11.17 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
   11.18 + and the following disclaimer in the documentation and/or other materials provided with the
   11.19 + distribution.
   11.20 + 
   11.21 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
   11.22 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
   11.23 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
   11.24 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   11.25 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
   11.26 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   11.27 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
   11.28 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   11.29 + */
    12.1 --- a/IChatUtils.h	Tue May 20 17:40:28 2008 -0700
    12.2 +++ b/IChatUtils.h	Sat May 24 13:24:33 2008 -0700
    12.3 @@ -7,7 +7,7 @@
    12.4  //
    12.5  
    12.6  #import <Cocoa/Cocoa.h>
    12.7 -@class SBApplication;
    12.8 +@class SBApplication, ABPerson;
    12.9  
   12.10  
   12.11  @interface IChatUtils : NSObject 
   12.12 @@ -18,4 +18,8 @@
   12.13  + (NSString*) activeChatPartner;
   12.14  + (BOOL) sendMessage: (NSString*)msg;
   12.15  
   12.16 ++ (NSDictionary*) iChatInfoForOnlinePerson: (ABPerson*)abPerson;
   12.17 ++ (BOOL) isPersonOnline: (ABPerson*)abPerson;
   12.18 ++ (BOOL) sendMessage: (NSString*)msg toPerson: (ABPerson*)abPerson;
   12.19 +
   12.20  @end
    13.1 --- a/IChatUtils.m	Tue May 20 17:40:28 2008 -0700
    13.2 +++ b/IChatUtils.m	Sat May 24 13:24:33 2008 -0700
    13.3 @@ -8,6 +8,7 @@
    13.4  
    13.5  #import "IChatUtils.h"
    13.6  #import "iChatBridge.h"
    13.7 +#import <InstantMessage/IMService.h>
    13.8  
    13.9  @implementation IChatUtils
   13.10  
   13.11 @@ -63,5 +64,79 @@
   13.12      return YES;
   13.13  }
   13.14  
   13.15 ++ (NSDictionary*) iChatInfoForOnlinePerson: (ABPerson*)abPerson
   13.16 +{
   13.17 +    if( ! abPerson )
   13.18 +        return nil;
   13.19 +    IMPersonStatus bestStatus = IMPersonStatusOffline;
   13.20 +    NSDictionary *bestInfo = nil;
   13.21 +    for( IMService *service in [IMService allServices] ) {
   13.22 +        for( NSString *name in [service screenNamesForPerson: abPerson] ) {
   13.23 +            NSDictionary *info = [service infoForScreenName: name];
   13.24 +            if( [[info objectForKey: IMPersonCapabilitiesKey] containsObject: IMCapabilityText] ) {
   13.25 +                IMPersonStatus status = [[info objectForKey: IMPersonStatusKey] intValue];
   13.26 +                if( IMComparePersonStatus(status,bestStatus) < 0 ) {    // yes, it returns the wrong sign
   13.27 +                    bestInfo = info;
   13.28 +                    bestStatus = status;
   13.29 +                }
   13.30 +            }
   13.31 +        }
   13.32 +    }
   13.33 +    return bestInfo;
   13.34 +}
   13.35 +
   13.36 ++ (BOOL) isPersonOnline: (ABPerson*)abPerson
   13.37 +{
   13.38 +    return [self iChatInfoForOnlinePerson: abPerson] != nil;
   13.39 +}
   13.40 +
   13.41 ++ (iChatBuddy*) buddyWithInfo: (NSDictionary*)info
   13.42 +{
   13.43 +    NSString *ident = [info objectForKey: IMPersonScreenNameKey];
   13.44 +    NSPredicate *pred = [NSPredicate predicateWithFormat: @"handle==%@", ident];
   13.45 +    @try{
   13.46 +        return [[[[sIChatApp buddies] filteredArrayUsingPredicate: pred] objectAtIndex: 0] get];
   13.47 +    } @catch( NSException *x ) {
   13.48 +        Log(@"buddyWithInfo got exception: %@",x);
   13.49 +    }
   13.50 +    return nil;
   13.51 +}
   13.52 +
   13.53 ++ (BOOL) sendMessage: (NSString*)msg toPerson: (ABPerson*)abPerson
   13.54 +{
   13.55 +    NSDictionary *info = [self iChatInfoForOnlinePerson: abPerson];
   13.56 +    if( info ) {
   13.57 +        iChatBuddy *buddy = [self buddyWithInfo: info];
   13.58 +        if( buddy ) {
   13.59 +            [sIChatApp send: msg to: buddy];
   13.60 +            return YES;
   13.61 +        }
   13.62 +    } 
   13.63 +    return NO;
   13.64 +}
   13.65 +
   13.66  
   13.67  @end
   13.68 +
   13.69 +
   13.70 +/*
   13.71 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
   13.72 + 
   13.73 + Redistribution and use in source and binary forms, with or without modification, are permitted
   13.74 + provided that the following conditions are met:
   13.75 + 
   13.76 + * Redistributions of source code must retain the above copyright notice, this list of conditions
   13.77 + and the following disclaimer.
   13.78 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
   13.79 + and the following disclaimer in the documentation and/or other materials provided with the
   13.80 + distribution.
   13.81 + 
   13.82 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
   13.83 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
   13.84 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
   13.85 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   13.86 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
   13.87 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   13.88 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
   13.89 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   13.90 + */
    14.1 --- a/KVUtils.m	Tue May 20 17:40:28 2008 -0700
    14.2 +++ b/KVUtils.m	Sat May 24 13:24:33 2008 -0700
    14.3 @@ -168,3 +168,26 @@
    14.4  }
    14.5  
    14.6  @end
    14.7 +
    14.8 +
    14.9 +/*
   14.10 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
   14.11 + 
   14.12 + Redistribution and use in source and binary forms, with or without modification, are permitted
   14.13 + provided that the following conditions are met:
   14.14 + 
   14.15 + * Redistributions of source code must retain the above copyright notice, this list of conditions
   14.16 + and the following disclaimer.
   14.17 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
   14.18 + and the following disclaimer in the documentation and/or other materials provided with the
   14.19 + distribution.
   14.20 + 
   14.21 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
   14.22 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
   14.23 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
   14.24 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   14.25 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
   14.26 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   14.27 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
   14.28 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   14.29 + */
    15.1 --- a/Logging.h	Tue May 20 17:40:28 2008 -0700
    15.2 +++ b/Logging.h	Sat May 24 13:24:33 2008 -0700
    15.3 @@ -6,25 +6,32 @@
    15.4  //  Copyright 2008 Jens Alfke. All rights reserved.
    15.5  //
    15.6  
    15.7 -#import <Cocoa/Cocoa.h>
    15.8 +#import <Foundation/Foundation.h>
    15.9  
   15.10  
   15.11  NSString* LOC( NSString *key );     // Localized string lookup
   15.12  
   15.13  
   15.14 -#ifdef __cplusplus
   15.15 -    #define IN_SEGMENT(SEG)
   15.16 -#else
   15.17 +// To enable IN_SEGMENT (which breaks rarely-called logging code out of your main code segment,
   15.18 +// improving locality of reference) you must define MY_USE_NESTED_FNS in your prefix file or
   15.19 +// target settings, and add the GCC flag "-fnested-functions" to your target's C flags.
   15.20 +#if defined(MY_USE_NESTED_FNS) && ! defined(__cplusplus)
   15.21      #define IN_SEGMENT(SEG) auto __attribute__ ((section ("__TEXT, "#SEG))) __attribute__ ((noinline)) void _outofband_(void);\
   15.22                              _outofband_();\
   15.23                              void _outofband_(void)
   15.24 +    #define IN_SEGMENT_NORETURN(SEG) auto __attribute__ ((section ("__TEXT, "#SEG))) __attribute__ ((noinline)) __attribute__((noreturn)) void _assertfailure_(void);\
   15.25 +                            _assertfailure_();\
   15.26 +                            void _assertfailure_(void)
   15.27 +#else
   15.28 +    #define IN_SEGMENT(SEG)
   15.29 +    #define IN_SEGMENT_NORETURN(SEG)
   15.30  #endif
   15.31  
   15.32  #define Log(FMT,ARGS...) do{if(__builtin_expect(_gShouldLog,0)) {\
   15.33                              IN_SEGMENT(Logging){_Log(FMT,##ARGS);}\
   15.34                           } }while(0)
   15.35  #define LogTo(DOMAIN,FMT,ARGS...) do{if(__builtin_expect(_gShouldLog,0)) {\
   15.36 -                                    IN_SEGMENT(Logging) {_LogTo(@""#DOMAIN,FMT,##ARGS);}\
   15.37 +                                    IN_SEGMENT(Logging) {if(_WillLogTo(@""#DOMAIN)) _LogTo(@""#DOMAIN,FMT,##ARGS);}\
   15.38                                    } }while(0)
   15.39  #define Warn Warn
   15.40  
    16.1 --- a/Logging.m	Tue May 20 17:40:28 2008 -0700
    16.2 +++ b/Logging.m	Sat May 24 13:24:33 2008 -0700
    16.3 @@ -7,9 +7,12 @@
    16.4  //
    16.5  
    16.6  #import "Logging.h"
    16.7 -#import <unistd.h>
    16.8 +#import "CollectionUtils.h"
    16.9 +
   16.10 +#include <unistd.h>
   16.11  #include <fcntl.h>
   16.12  #include <sys/param.h>
   16.13 +#include <termios.h>
   16.14  
   16.15  
   16.16  NSString* LOC( NSString *key )     // Localized string lookup
   16.17 @@ -23,19 +26,35 @@
   16.18  }
   16.19  
   16.20  
   16.21 +typedef enum {
   16.22 +    kLoggingToOther,
   16.23 +    kLoggingToFile,
   16.24 +    kLoggingToTTY,
   16.25 +    kLoggingToColorTTY
   16.26 +} MYLoggingTo;
   16.27 +
   16.28 +
   16.29  int _gShouldLog = -1;
   16.30 -static BOOL sConsole;
   16.31 +static MYLoggingTo sLoggingTo;
   16.32  static NSMutableSet *sEnabledDomains;
   16.33  
   16.34  
   16.35 -static BOOL isConsole( int fd )
   16.36 +/** Does the file descriptor connect to console output, i.e. a terminal or Xcode? */
   16.37 +static MYLoggingTo getLoggingMode( int fd )
   16.38  {
   16.39 -    if( isatty(fd) )
   16.40 -        return YES;
   16.41 -    char path[MAXPATHLEN];
   16.42 -    if( fcntl(fd, F_GETPATH, path) == -1 )
   16.43 -        return NO;
   16.44 -    return YES;
   16.45 +    if( isatty(fd) ) {
   16.46 +        const char *term = getenv("TERM");
   16.47 +        if( term && (strstr(term,"ANSI") || strstr(term,"ansi") || strstr(term,"color")) )
   16.48 +            return kLoggingToColorTTY;
   16.49 +        else
   16.50 +            return kLoggingToTTY;
   16.51 +    } else {
   16.52 +        char path[MAXPATHLEN];
   16.53 +        if( fcntl(fd, F_GETPATH, path) == 0 )
   16.54 +            return kLoggingToFile;
   16.55 +        else
   16.56 +            return kLoggingToOther;
   16.57 +    }
   16.58  }
   16.59  
   16.60  
   16.61 @@ -57,9 +76,10 @@
   16.62                  [sEnabledDomains addObject: [key substringFromIndex: 3]];
   16.63          }
   16.64      }
   16.65 -    sConsole = isConsole(STDERR_FILENO);
   16.66 +    sLoggingTo = getLoggingMode(STDERR_FILENO);
   16.67      
   16.68 -    Log(@"Logging enabled in domains: {%@}", 
   16.69 +    Log(@"Logging mode %i enabled in domains: {%@}", 
   16.70 +        sLoggingTo,
   16.71          [[[sEnabledDomains allObjects] sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)] 
   16.72                  componentsJoinedByString: @", "]);
   16.73      [pool drain];
   16.74 @@ -95,9 +115,14 @@
   16.75  }
   16.76  
   16.77  
   16.78 +#define kWarningPrefix @"\007WARNING*** "
   16.79 +            
   16.80 +#define COLOR(STR)     (sLoggingTo==kLoggingToColorTTY ?@"\033["#STR"m" :@"")
   16.81 +
   16.82 +
   16.83  static void _Logv( NSString *prefix, NSString *msg, va_list args )
   16.84  {
   16.85 -    if( sConsole ) {
   16.86 +    if( sLoggingTo > kLoggingToOther ) {
   16.87          NSAutoreleasePool *pool = [NSAutoreleasePool new];
   16.88          static NSDateFormatter *sTimestampFormat;
   16.89          if( ! sTimestampFormat ) {
   16.90 @@ -109,14 +134,21 @@
   16.91          [now release];
   16.92          NSString *separator = prefix.length ?@": " :@"";
   16.93          msg = [[NSString alloc] initWithFormat: msg arguments: args];
   16.94 -        NSString *finalMsg = [[NSString alloc] initWithFormat: @"%@| %@%@%@\n", 
   16.95 -                              timestamp,prefix,separator,msg];
   16.96 +        NSString *prefixColor = (prefix==kWarningPrefix) ?COLOR(91) :COLOR(93);
   16.97 +        NSString *msgColor = (prefix==kWarningPrefix) ?@"" :COLOR(0);
   16.98 +        NSString *finalMsg = [[NSString alloc] initWithFormat: @"%@%@| %@%@%@%@%@\n", 
   16.99 +                              COLOR(30),timestamp,
  16.100 +                              prefixColor,prefix,separator,
  16.101 +                              msgColor,msg];
  16.102          fputs([finalMsg UTF8String], stderr);
  16.103          [finalMsg release];
  16.104          [msg release];
  16.105          [pool drain];
  16.106 -    } else
  16.107 +    } else {
  16.108 +        if( prefix.length )
  16.109 +            msg = $sprintf(@"%@: %@", prefix,msg);
  16.110          NSLogv(msg,args);
  16.111 +    }
  16.112  }
  16.113  
  16.114  
  16.115 @@ -159,8 +191,31 @@
  16.116  {
  16.117      va_list args;
  16.118      va_start(args,msg);
  16.119 -    _Logv(@"WARNING*** ",msg,args);
  16.120 +    _Logv(kWarningPrefix,msg,args);
  16.121      va_end(args);
  16.122  }
  16.123  
  16.124  
  16.125 +
  16.126 +
  16.127 +/*
  16.128 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
  16.129 + 
  16.130 + Redistribution and use in source and binary forms, with or without modification, are permitted
  16.131 + provided that the following conditions are met:
  16.132 + 
  16.133 + * Redistributions of source code must retain the above copyright notice, this list of conditions
  16.134 + and the following disclaimer.
  16.135 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
  16.136 + and the following disclaimer in the documentation and/or other materials provided with the
  16.137 + distribution.
  16.138 + 
  16.139 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  16.140 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
  16.141 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
  16.142 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16.143 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
  16.144 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
  16.145 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
  16.146 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16.147 + */
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/MYUtilitiesTest_main.m	Sat May 24 13:24:33 2008 -0700
    17.3 @@ -0,0 +1,17 @@
    17.4 +//
    17.5 +//  MYUtilitiesTest_main.m
    17.6 +//  MYNetwork
    17.7 +//
    17.8 +//  Created by Jens Alfke on 5/21/08.
    17.9 +//  Copyright 2008 Jens Alfke. All rights reserved.
   17.10 +//
   17.11 +
   17.12 +
   17.13 +#import "Test.h"
   17.14 +
   17.15 +
   17.16 +int main(int argc, const char *argv[])
   17.17 +{
   17.18 +    RunTestCases(argc,argv);
   17.19 +    return 0;
   17.20 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/MYUtilities_Prefix.pch	Sat May 24 13:24:33 2008 -0700
    18.3 @@ -0,0 +1,10 @@
    18.4 +//
    18.5 +// Prefix header for clients of MYUtilities.
    18.6 +//
    18.7 +
    18.8 +#ifdef __OBJC__
    18.9 +    #import <Foundation/Foundation.h>
   18.10 +    #import "Logging.h"
   18.11 +    #import "Test.h"
   18.12 +    #import "CollectionUtils.h"
   18.13 +#endif
    19.1 --- a/Target.h	Tue May 20 17:40:28 2008 -0700
    19.2 +++ b/Target.h	Sat May 24 13:24:33 2008 -0700
    19.3 @@ -6,7 +6,7 @@
    19.4  //  Copyright 2008 Jens Alfke. All rights reserved.
    19.5  //
    19.6  
    19.7 -#import <Cocoa/Cocoa.h>
    19.8 +#import <Foundation/Foundation.h>
    19.9  
   19.10  
   19.11  @interface MYTarget : NSObject
    20.1 --- a/Target.m	Tue May 20 17:40:28 2008 -0700
    20.2 +++ b/Target.m	Sat May 24 13:24:33 2008 -0700
    20.3 @@ -7,6 +7,8 @@
    20.4  //
    20.5  
    20.6  #import "Target.h"
    20.7 +#import "Logging.h"
    20.8 +#import "Test.h"
    20.9  
   20.10  
   20.11  @implementation MYTarget
   20.12 @@ -147,3 +149,26 @@
   20.13  
   20.14  
   20.15  @end
   20.16 +
   20.17 +
   20.18 +/*
   20.19 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
   20.20 + 
   20.21 + Redistribution and use in source and binary forms, with or without modification, are permitted
   20.22 + provided that the following conditions are met:
   20.23 + 
   20.24 + * Redistributions of source code must retain the above copyright notice, this list of conditions
   20.25 + and the following disclaimer.
   20.26 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
   20.27 + and the following disclaimer in the documentation and/or other materials provided with the
   20.28 + distribution.
   20.29 + 
   20.30 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
   20.31 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
   20.32 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
   20.33 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   20.34 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
   20.35 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   20.36 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
   20.37 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   20.38 + */
    21.1 --- a/Test.h	Tue May 20 17:40:28 2008 -0700
    21.2 +++ b/Test.h	Sat May 24 13:24:33 2008 -0700
    21.3 @@ -48,22 +48,16 @@
    21.4  
    21.5  /** Can call this in a test case to indicate a prerequisite.
    21.6      The prerequisite test will be run first, and if it fails, the current test case will be skipped. */
    21.7 +#if DEBUG
    21.8  #define RequireTestCase(NAME)   _RequireTestCase(#NAME)
    21.9  void _RequireTestCase( const char *name );
   21.10 -
   21.11 +#else
   21.12 +#define RequireTestCase(NAME)
   21.13 +#endif
   21.14  
   21.15  
   21.16  /** General-purpose assertions, replacing NSAssert etc.. You can use these outside test cases. */
   21.17  
   21.18 -#ifdef __cplusplus
   21.19 -    #define IN_SEGMENT_NORETURN(SEG)
   21.20 -#else
   21.21 -    #define IN_SEGMENT_NORETURN(SEG) auto __attribute__ ((section ("__TEXT, "#SEG))) __attribute__ ((noinline)) __attribute__((noreturn)) void _assertfailure_(void);\
   21.22 -                            _assertfailure_();\
   21.23 -                            void _assertfailure_(void)
   21.24 -#endif
   21.25 -
   21.26 -
   21.27  #define Assert(COND,MSG...)    do{ if( __builtin_expect(!(COND),NO) ) { \
   21.28                                      IN_SEGMENT_NORETURN(Logging) {_AssertFailed(self,(const char*)_cmd, __FILE__, __LINE__,\
   21.29                                                          #COND,##MSG,NULL);} } }while(0)
   21.30 @@ -80,6 +74,7 @@
   21.31                                      }while(0)
   21.32  
   21.33  // AssertEq is for scalars (int, float...)
   21.34 +// Note: "typeof()" builtin function requires settingn C language dialect to GNU99.
   21.35  #define AssertEq(VAL,EXPECTED)  do{ typeof(VAL) _val = VAL; typeof(EXPECTED) _expected = EXPECTED;\
   21.36                                      Assert(_val==_expected, @"Unexpected value for %s: %@ (expected %@)", #VAL,$object(_val),$object(_expected)); \
   21.37                                  }while(0)
    22.1 --- a/Test.m	Tue May 20 17:40:28 2008 -0700
    22.2 +++ b/Test.m	Sat May 24 13:24:33 2008 -0700
    22.3 @@ -7,6 +7,7 @@
    22.4  //
    22.5  
    22.6  #import "Test.h"
    22.7 +#import "ExceptionUtils.h"
    22.8  
    22.9  
   22.10  #if DEBUG
   22.11 @@ -148,3 +149,26 @@
   22.12                                                           description: @"%@", message];
   22.13      abort(); // unreachable, but appeases compiler
   22.14  }
   22.15 +
   22.16 +
   22.17 +/*
   22.18 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
   22.19 + 
   22.20 + Redistribution and use in source and binary forms, with or without modification, are permitted
   22.21 + provided that the following conditions are met:
   22.22 + 
   22.23 + * Redistributions of source code must retain the above copyright notice, this list of conditions
   22.24 + and the following disclaimer.
   22.25 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
   22.26 + and the following disclaimer in the documentation and/or other materials provided with the
   22.27 + distribution.
   22.28 + 
   22.29 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
   22.30 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
   22.31 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
   22.32 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   22.33 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
   22.34 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   22.35 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
   22.36 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   22.37 + */
    23.1 --- a/TimeIntervalFormatter.m	Tue May 20 17:40:28 2008 -0700
    23.2 +++ b/TimeIntervalFormatter.m	Sat May 24 13:24:33 2008 -0700
    23.3 @@ -108,3 +108,26 @@
    23.4  
    23.5  
    23.6  @end
    23.7 +
    23.8 +
    23.9 +/*
   23.10 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
   23.11 + 
   23.12 + Redistribution and use in source and binary forms, with or without modification, are permitted
   23.13 + provided that the following conditions are met:
   23.14 + 
   23.15 + * Redistributions of source code must retain the above copyright notice, this list of conditions
   23.16 + and the following disclaimer.
   23.17 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
   23.18 + and the following disclaimer in the documentation and/or other materials provided with the
   23.19 + distribution.
   23.20 + 
   23.21 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
   23.22 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
   23.23 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
   23.24 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   23.25 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
   23.26 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   23.27 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
   23.28 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   23.29 + */
    24.1 --- a/URLUtils.h	Tue May 20 17:40:28 2008 -0700
    24.2 +++ b/URLUtils.h	Sat May 24 13:24:33 2008 -0700
    24.3 @@ -1,9 +1,9 @@
    24.4  //
    24.5  //  URLUtils.h
    24.6 -//  Cloudy
    24.7 +//  MYUtilities
    24.8  //
    24.9  //  Created by Jens Alfke on 4/28/08.
   24.10 -//  Copyright 2008 __MyCompanyName__. All rights reserved.
   24.11 +//  Copyright 2008 Jens Alfke. All rights reserved.
   24.12  //
   24.13  
   24.14  #import <Foundation/Foundation.h>
    25.1 --- a/URLUtils.m	Tue May 20 17:40:28 2008 -0700
    25.2 +++ b/URLUtils.m	Sat May 24 13:24:33 2008 -0700
    25.3 @@ -1,9 +1,9 @@
    25.4  //
    25.5  //  URLUtils.m
    25.6 -//  Cloudy
    25.7 +//  MYUtilities
    25.8  //
    25.9  //  Created by Jens Alfke on 4/28/08.
   25.10 -//  Copyright 2008 __MyCompanyName__. All rights reserved.
   25.11 +//  Copyright 2008 Jens Alfke. All rights reserved.
   25.12  //
   25.13  
   25.14  #import "URLUtils.h"
   25.15 @@ -30,3 +30,26 @@
   25.16  
   25.17  
   25.18  @end
   25.19 +
   25.20 +
   25.21 +/*
   25.22 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
   25.23 + 
   25.24 + Redistribution and use in source and binary forms, with or without modification, are permitted
   25.25 + provided that the following conditions are met:
   25.26 + 
   25.27 + * Redistributions of source code must retain the above copyright notice, this list of conditions
   25.28 + and the following disclaimer.
   25.29 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
   25.30 + and the following disclaimer in the documentation and/or other materials provided with the
   25.31 + distribution.
   25.32 + 
   25.33 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
   25.34 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
   25.35 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
   25.36 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   25.37 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
   25.38 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   25.39 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
   25.40 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   25.41 + */
    26.1 --- a/UniqueWindowController.h	Tue May 20 17:40:28 2008 -0700
    26.2 +++ b/UniqueWindowController.h	Sat May 24 13:24:33 2008 -0700
    26.3 @@ -1,9 +1,9 @@
    26.4  //
    26.5  //  UniqueWindowController.h
    26.6 -//  Cloudy
    26.7 +//  MYUtilities
    26.8  //
    26.9  //  Created by Jens Alfke on 3/14/08.
   26.10 -//  Copyright 2008 __MyCompanyName__. All rights reserved.
   26.11 +//  Copyright 2008 Jens Alfke. All rights reserved.
   26.12  //
   26.13  
   26.14  #import <Cocoa/Cocoa.h>
    27.1 --- a/UniqueWindowController.m	Tue May 20 17:40:28 2008 -0700
    27.2 +++ b/UniqueWindowController.m	Sat May 24 13:24:33 2008 -0700
    27.3 @@ -1,9 +1,9 @@
    27.4  //
    27.5  //  UniqueWindowController.m
    27.6 -//  Cloudy
    27.7 +//  MYUtilities
    27.8  //
    27.9  //  Created by Jens Alfke on 3/14/08.
   27.10 -//  Copyright 2008 __MyCompanyName__. All rights reserved.
   27.11 +//  Copyright 2008 Jens Alfke. All rights reserved.
   27.12  //
   27.13  
   27.14  #import "UniqueWindowController.h"
   27.15 @@ -57,3 +57,26 @@
   27.16  
   27.17  
   27.18  @end
   27.19 +
   27.20 +
   27.21 +/*
   27.22 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
   27.23 + 
   27.24 + Redistribution and use in source and binary forms, with or without modification, are permitted
   27.25 + provided that the following conditions are met:
   27.26 + 
   27.27 + * Redistributions of source code must retain the above copyright notice, this list of conditions
   27.28 + and the following disclaimer.
   27.29 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
   27.30 + and the following disclaimer in the documentation and/or other materials provided with the
   27.31 + distribution.
   27.32 + 
   27.33 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
   27.34 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
   27.35 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
   27.36 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   27.37 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
   27.38 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   27.39 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
   27.40 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   27.41 + */
    28.1 --- a/ValueArray.m	Tue May 20 17:40:28 2008 -0700
    28.2 +++ b/ValueArray.m	Sat May 24 13:24:33 2008 -0700
    28.3 @@ -91,3 +91,26 @@
    28.4  ImplementValueArrayOf(Int,int)
    28.5  
    28.6  ImplementValueArrayOf(Double,double)
    28.7 +
    28.8 +
    28.9 +/*
   28.10 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
   28.11 + 
   28.12 + Redistribution and use in source and binary forms, with or without modification, are permitted
   28.13 + provided that the following conditions are met:
   28.14 + 
   28.15 + * Redistributions of source code must retain the above copyright notice, this list of conditions
   28.16 + and the following disclaimer.
   28.17 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
   28.18 + and the following disclaimer in the documentation and/or other materials provided with the
   28.19 + distribution.
   28.20 + 
   28.21 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
   28.22 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
   28.23 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
   28.24 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   28.25 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
   28.26 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   28.27 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
   28.28 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   28.29 + */
    29.1 --- a/With.m	Tue May 20 17:40:28 2008 -0700
    29.2 +++ b/With.m	Sat May 24 13:24:33 2008 -0700
    29.3 @@ -31,4 +31,27 @@
    29.4  + (NSAutoreleasePool*) beginWith    {return [self new];}
    29.5  - (void) endWith                    {[self drain];}
    29.6  - (BOOL) endWith: (NSException*)x   {[self drain]; return YES;}
    29.7 -@end
    29.8 \ No newline at end of file
    29.9 +@end
   29.10 +
   29.11 +
   29.12 +/*
   29.13 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
   29.14 + 
   29.15 + Redistribution and use in source and binary forms, with or without modification, are permitted
   29.16 + provided that the following conditions are met:
   29.17 + 
   29.18 + * Redistributions of source code must retain the above copyright notice, this list of conditions
   29.19 + and the following disclaimer.
   29.20 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
   29.21 + and the following disclaimer in the documentation and/or other materials provided with the
   29.22 + distribution.
   29.23 + 
   29.24 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
   29.25 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
   29.26 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
   29.27 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   29.28 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
   29.29 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   29.30 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
   29.31 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   29.32 + */