static int MacintoshInit() { #if GENERATING68K && !GENERATINGCFM SetApplLimit(GetApplLimit() - (TCL_MAC_68K_STACK_GROWTH)); #endif MaxApplZone(); #if defined(THINK_C) /* Set options for Think C console package */ /* The console package calls the Mac init calls */ console_options.pause_atexit = 0; console_options.title = "\pTcl Interpreter"; #elif defined(__MWERKS__) /* Set options for CodeWarrior SIOUX package */ SIOUXSettings.autocloseonquit = true; SIOUXSettings.showstatusline = true; SIOUXSettings.asktosaveonclose = false; SIOUXSettings.wasteusetempmemory = true; InstallConsole(0); SIOUXSetTitle("\pTcl Interpreter"); #elif defined(applec) /* Init packages used by MPW SIOW package */ InitGraf((Ptr)&qd.thePort); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(nil); InitCursor(); #endif Tcl_MacSetEventProc((Tcl_MacConvertEventPtr) SIOUXHandleOneEvent); /* No problems with initialization */ return TCL_OK; }
void main(void) { int code; int exit_code; int argc; char **argv; char dformat[64], ddevice[32]; SInt32 response; /* Initialize operating environment */ #if TARGET_API_MAC_CARBON MoreMasterPointers(224); #else MoreMasters(); #endif InitCursor(); FlushEvents(everyEvent,0); if (AEInstallEventHandler(kCoreEventClass,kAEQuitApplication, NewAEEventHandlerUPP((AEEventHandlerProcPtr) quitAppEventHandler), 0L,false) != noErr) ExitToShell(); gActionFunctionScrollUPP = NewControlActionUPP(&actionFunctionScroll); Gestalt(gestaltMenuMgrAttr,&response); if(response & gestaltMenuMgrAquaLayoutMask) gRunningOnX = true; /* Initialize SIOUX */ SIOUXSettings.initializeTB = false; SIOUXSettings.standalone = false; SIOUXSettings.asktosaveonclose = false; SIOUXSettings.sleep = GetCaretTime(); SIOUXSettings.userwindowtitle = "\pGhostscript"; /* Get arguments from user */ argc = ccommand(&argv); /* Show command line window */ if (InstallConsole(0)) ExitToShell(); /* Part of fudge to make SIOUX accept characters without becoming modal */ SelectWindow(SIOUXTextWindow->window); PostEvent(keyDown, 0x4c00); // Enter ReadCharsFromConsole(dformat, 0x7FFF); clrscr(); /* Add in the display format as the first command line argument */ if (argc >= MAX_ARGS - 1) { printf("Too many command line arguments\n"); return; } memmove(&argv[3], &argv[1], (argc-1) * sizeof(char**)); argc += 2; argv[1] = ddevice; argv[2] = dformat; gs_sprintf(ddevice, "-sDEVICE=display"); gs_sprintf(dformat, "-dDisplayFormat=%d", display_format); /* Run Ghostscript */ if (gsapi_new_instance(&instance, NULL) < 0) { printf("Can't create Ghostscript instance\n"); return; } #ifdef DEBUG visual_tracer_init(); set_visual_tracer(&visual_tracer); #endif gsapi_set_stdio(instance, gsdll_stdin, gsdll_stdout, gsdll_stderr); gsapi_set_poll(instance, gsdll_poll); gsapi_set_display_callback(instance, &display); code = gsapi_init_with_args(instance, argc, argv); if (code == 0) code = gsapi_run_string(instance, start_string, 0, &exit_code); else { printf("Failed to initialize. Error %d.\n", code); fflush(stdout); } code = gsapi_exit(instance); if (code != 0) { printf("Failed to terminate. Error %d.\n", code); fflush(stdout); } gsapi_delete_instance(instance); #ifdef DEBUG visual_tracer_close(); #endif /* Ghostscript has finished - let user see output before quitting */ WriteCharsToConsole("\r[Finished - hit any key to quit]", 33); fflush(stdout); /* Process events until a key is hit or user quits from menu */ while(!gDone) { EventRecord eventStructure; if(WaitNextEvent(everyEvent,&eventStructure,SIOUXSettings.sleep,NULL)) { if (eventStructure.what == keyDown) gDone = true; doEvents(&eventStructure); } else SIOUXHandleOneEvent(&eventStructure); } }