2011-10-12 13:18:32 -04:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2012-10-21 12:53:33 -04:00
|
|
|
#import <Foundation/Foundation.h>
|
2011-10-12 13:18:32 -04:00
|
|
|
|
|
|
|
|
#include <u.h>
|
|
|
|
|
#include <libc.h>
|
|
|
|
|
|
2012-10-21 12:53:33 -04:00
|
|
|
AUTOFRAMEWORK(Foundation)
|
2011-10-12 13:18:32 -04:00
|
|
|
AUTOFRAMEWORK(Cocoa)
|
|
|
|
|
|
2017-01-06 16:32:31 -05:00
|
|
|
@interface appdelegate : NSObject<NSApplicationDelegate> @end
|
2011-10-12 13:18:32 -04:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
main(void)
|
|
|
|
|
{
|
|
|
|
|
[NSApplication sharedApplication];
|
2017-01-06 16:32:31 -05:00
|
|
|
NSObject<NSApplicationDelegate> *delegate = [appdelegate new];
|
2012-10-21 12:53:33 -04:00
|
|
|
[NSApp setDelegate:delegate];
|
|
|
|
|
|
|
|
|
|
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; /* Register a call-back for URL Events */
|
|
|
|
|
[appleEventManager setEventHandler:delegate andSelector:@selector(handleGetURLEvent:withReplyEvent:)
|
|
|
|
|
forEventClass:kInternetEventClass andEventID:kAEGetURL];
|
|
|
|
|
|
2011-10-12 13:18:32 -04:00
|
|
|
[NSApp run];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@implementation appdelegate
|
|
|
|
|
- (void)application:(id)arg openFiles:(NSArray*)file
|
|
|
|
|
{
|
|
|
|
|
int i,n;
|
|
|
|
|
NSString *s;
|
|
|
|
|
|
|
|
|
|
n = [file count];
|
|
|
|
|
for(i=0; i<n; i++){
|
|
|
|
|
s = [file objectAtIndex:i];
|
|
|
|
|
print("%s\n", [s UTF8String]);
|
|
|
|
|
}
|
|
|
|
|
[NSApp terminate:self];
|
|
|
|
|
}
|
2012-10-21 12:53:33 -04:00
|
|
|
|
|
|
|
|
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
|
|
|
|
|
{
|
|
|
|
|
NSString* url = [[event descriptorForKeyword:keyDirectObject] stringValue];
|
|
|
|
|
print("%s\n", [url UTF8String] + (sizeof("plumb:") - 1));
|
|
|
|
|
[NSApp terminate:self];
|
|
|
|
|
}
|
2011-10-12 13:18:32 -04:00
|
|
|
@end
|