main.m (1756B)
1 // 2 // main.m 3 // uimac 4 // 5 // Created by Trevor Jim on Sun Aug 17 2003. 6 // Copyright (c) 2003, see file COPYING for details. 7 // 8 9 #import <Cocoa/Cocoa.h> 10 #import "Bridge.h" 11 12 int main(int argc, const char *argv[]) 13 { 14 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 15 int i; 16 17 /* When you click-start or use the open command, the program is invoked with 18 a command-line arg of the form -psn_XXXXXXXXX. The XXXXXXXX is a "process 19 serial number" and it seems to be important for Carbon programs. We need 20 to get rid of it if it's there so the ocaml code won't exit. Note, the 21 extra arg is not added if the binary is invoked directly from the command 22 line without using the open command. */ 23 if (argc == 2 && strncmp(argv[1],"-psn_",5) == 0) { 24 argc--; 25 argv[1] = NULL; 26 } 27 28 [Bridge startup:argv]; 29 30 /* Check for invocations that don't start up the gui */ 31 for (i=1; i<argc; i++) { 32 if (!strcmp(argv[i],"-doc") || 33 !strcmp(argv[i],"-help") || 34 !strcmp(argv[i],"-version") || 35 !strcmp(argv[i],"-server") || 36 !strcmp(argv[i],"-socket") || 37 !strcmp(argv[i],"-ui")) { 38 //NSLog(@"Calling nonGuiStartup"); 39 @try { 40 ocamlCall("x", "unisonNonGuiStartup"); 41 } @catch (NSException *ex) { 42 NSLog(@"Uncaught exception: %@", [ex reason]); 43 exit(1); 44 } 45 /* If we get here without exiting first, the non GUI startup detected a 46 -ui graphic or command-line profile, and we should in fact start the GUI. */ 47 } 48 } 49 50 /* go! */ 51 [pool release]; 52 return NSApplicationMain(argc, argv); 53 }