about summary refs log tree commit diff
path: root/src/osxlaunch
diff options
context:
space:
mode:
authorJoel de Vahl <joel@stalverk80.se>2008-03-22 15:09:49 +0000
committerJoel de Vahl <joel@stalverk80.se>2008-03-22 15:09:49 +0000
commitddca01abb612ee586a5274ce166f16a582db9544 (patch)
treebd3b74de68977db301b6c871d78009255dc572e1 /src/osxlaunch
parent1ee961d6d13125eb7e59c08a5dbe3ee7dd3bdf0e (diff)
downloadzcatch-ddca01abb612ee586a5274ce166f16a582db9544.tar.gz
zcatch-ddca01abb612ee586a5274ce166f16a582db9544.zip
OSX fixes
Diffstat (limited to 'src/osxlaunch')
-rw-r--r--src/osxlaunch/main.m101
1 files changed, 0 insertions, 101 deletions
diff --git a/src/osxlaunch/main.m b/src/osxlaunch/main.m
deleted file mode 100644
index 6b628a3b..00000000
--- a/src/osxlaunch/main.m
+++ /dev/null
@@ -1,101 +0,0 @@
-#import <Cocoa/Cocoa.h>
-#include <Carbon/Carbon.h>
-
-@interface ServerView : NSTextView
-{
-	NSTask *task;
-	NSFileHandle *file;
-}
-- (void)listenTo: (NSTask*)t;
-@end
-
-@implementation ServerView
-- (void)listenTo: (NSTask*)t;
-{
-	NSPipe *pipe;
-	task = t;
-    pipe = [NSPipe pipe];
-    [task setStandardOutput: pipe];
-    file = [pipe fileHandleForReading];
-
-	[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(outputNotification:) name: NSFileHandleReadCompletionNotification object: file];
-
-	[file readInBackgroundAndNotify];
-}
-
-- (void) outputNotification: (NSNotification *) notification
-{
-	NSData *data = [[[notification userInfo] objectForKey: NSFileHandleNotificationDataItem] retain];
-	NSString *string = [[NSString alloc] initWithData: data encoding: NSASCIIStringEncoding];
-
-	NSRange end = NSMakeRange([[self string] length], 0);
-
-	[self replaceCharactersInRange: end withString: string];
-	end.location += [string length];
-	[self scrollRangeToVisible: end];
-
-	[string release];
-	[file readInBackgroundAndNotify];
-}
-
--(void)windowWillClose:(NSNotification *)notification
-{
-	[task terminate];
-    [NSApp terminate:self];
-}
-@end
-
-int main(int argc, char **argv)
-{
-	UInt32 mod = GetCurrentKeyModifiers();
-
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSApp = [NSApplication sharedApplication];
-	NSBundle* mainBundle = [NSBundle mainBundle];
-	NSTask *task;
-    task = [[NSTask alloc] init];
-	[task setCurrentDirectoryPath: [mainBundle resourcePath]]; 
-
-	if(mod & optionKey)
-	{
-		// run server
-		NSWindow *window;
-		ServerView *view;
-		NSRect graphicsRect;
-
-		graphicsRect = NSMakeRect(100.0, 1000.0, 600.0, 400.0);
-
-		window = [[NSWindow alloc]
-			initWithContentRect: graphicsRect
-			styleMask: NSTitledWindowMask 
-			 | NSClosableWindowMask 
-			 | NSMiniaturizableWindowMask
-			backing: NSBackingStoreBuffered
-			defer: NO];
-
-		[window setTitle: @"Teewars Server"];
-
-		view = [[[ServerView alloc] initWithFrame: graphicsRect] autorelease];
-		[view setEditable: NO];
-
-		[window setContentView: view];
-		[window setDelegate: view];
-		[window makeKeyAndOrderFront: nil];
-
-		[view listenTo: task];
-		[task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"teewars_srv"]];
-		[task launch];
-		[NSApp run];
-		[task terminate];
-	}
-	else
-	{
-		// run client
-		[task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"teewars"]];
-		[task launch];
-	}
-
-    [NSApp release];
-    [pool release];
-    return(EXIT_SUCCESS);
-}