Commits

Jens Alfke committed e597686

* 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.

Comments (0)

Files changed (29)

 //  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"
 
 - (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];
 
 - (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
 }
 
 @end
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */

CollectionUtils.h

 //  Copyright 2008 Jens Alfke. All rights reserved.
 //
 
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
 
 // Collection creation conveniences:
 

CollectionUtils.m

                         nil];
     CAssertEqual(d,dd);
 }
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */

ConcurrentOperation.m

 
 
 @end
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */
 //
 //  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 <Cocoa/Cocoa.h>
 //
 //  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"
     return *(uint64_t*)&elapsedNano / 1.0e9;
 }
 
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */
 //  See BSD license at bottom of ExceptionUtils.m.
 //
 
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
 
 
+#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 
 /** Returns a textual, human-readable backtrace of the point where the exception was thrown. */
 - (NSString*) my_callStack;
 @end
+
+
+BOOL IsGDBAttached( void );
 //
 
 #import "ExceptionUtils.h"
-#import <unistd.h>
+
+#import "Logging.h"
+#import "Test.h"
+
+#include <sys/sysctl.h>
+#include <unistd.h>
 
 
 #ifndef Warn
 
 
 
+#ifdef NSAppKitVersionNumber10_4 // only enable this in a project that uses AppKit
+
 @implementation MYExceptionReportingApplication
 
 
 - (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);
 
 @end
 
+#endif
+
+
+
+BOOL IsGDBAttached( void )
+{
+    // From: <http://lists.apple.com/archives/Xcode-users/2004/Feb/msg00241.html>
+    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 <jens@mooseyard.com>. All rights reserved.
  
  Redistribution and use in source and binary forms, with or without modification, are permitted
  provided that the following conditions are met:
 
 
 @end
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */
     }
     return sPath;
 }
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */
     return err;
 }
 
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */
 //
 
 #import <Cocoa/Cocoa.h>
-@class SBApplication;
+@class SBApplication, ABPerson;
 
 
 @interface IChatUtils : NSObject 
 + (NSString*) activeChatPartner;
 + (BOOL) sendMessage: (NSString*)msg;
 
++ (NSDictionary*) iChatInfoForOnlinePerson: (ABPerson*)abPerson;
++ (BOOL) isPersonOnline: (ABPerson*)abPerson;
++ (BOOL) sendMessage: (NSString*)msg toPerson: (ABPerson*)abPerson;
+
 @end
 
 #import "IChatUtils.h"
 #import "iChatBridge.h"
+#import <InstantMessage/IMService.h>
 
 @implementation IChatUtils
 
     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 <jens@mooseyard.com>. 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.
+ */
 }
 
 @end
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */
 //  Copyright 2008 Jens Alfke. All rights reserved.
 //
 
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
 
 
 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
 
 //
 
 #import "Logging.h"
-#import <unistd.h>
+#import "CollectionUtils.h"
+
+#include <unistd.h>
 #include <fcntl.h>
 #include <sys/param.h>
+#include <termios.h>
 
 
 NSString* LOC( NSString *key )     // Localized string lookup
 }
 
 
+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;
+    }
 }
 
 
                 [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];
 }
 
 
+#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 ) {
         [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);
+    }
 }
 
 
 {
     va_list args;
     va_start(args,msg);
-    _Logv(@"WARNING*** ",msg,args);
+    _Logv(kWarningPrefix,msg,args);
     va_end(args);
 }
 
 
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */

MYUtilitiesTest_main.m

+//
+//  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;
+}

MYUtilities_Prefix.pch

+//
+// Prefix header for clients of MYUtilities.
+//
+
+#ifdef __OBJC__
+    #import <Foundation/Foundation.h>
+    #import "Logging.h"
+    #import "Test.h"
+    #import "CollectionUtils.h"
+#endif
 //  Copyright 2008 Jens Alfke. All rights reserved.
 //
 
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
 
 
 @interface MYTarget : NSObject
 //
 
 #import "Target.h"
+#import "Logging.h"
+#import "Test.h"
 
 
 @implementation MYTarget
 
 
 @end
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */
 
 /** 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)
                                     }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)
 //
 
 #import "Test.h"
+#import "ExceptionUtils.h"
 
 
 #if DEBUG
                                                          description: @"%@", message];
     abort(); // unreachable, but appeases compiler
 }
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */

TimeIntervalFormatter.m

 
 
 @end
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */
 //
 //  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 <Foundation/Foundation.h>
 //
 //  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"
 
 
 @end
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */

UniqueWindowController.h

 //
 //  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 <Cocoa/Cocoa.h>

UniqueWindowController.m

 //
 //  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"
 
 
 @end
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */
 ImplementValueArrayOf(Int,int)
 
 ImplementValueArrayOf(Double,double)
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */
 + (NSAutoreleasePool*) beginWith    {return [self new];}
 - (void) endWith                    {[self drain];}
 - (BOOL) endWith: (NSException*)x   {[self drain]; return YES;}
-@end
+@end
+
+
+/*
+ Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. 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.
+ */