home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / online / source / c / compilers / Tickle-4.0.sit.hqx / Tickle-4.0 / src / tclEngine.c < prev    next >
C/C++ Source or Header  |  1993-11-08  |  4KB  |  181 lines

  1.  
  2. /*
  3. ** Copyright © 1991 ICE Engineering, Inc.
  4. ** All rights reserved.
  5. ** 8840 Main St.
  6. ** Whitmore Lake, Mi.  48189
  7. **
  8. ** Written by Tim Endres.
  9. */
  10.  
  11. /*
  12. ** The following macro definition will cause the global varaible
  13. ** definitions to allocate storage, versus just "extern" definitions.
  14. ** One and only one compiled file should declare this macro.
  15. ** (refer to pages 28-30, "Scope; External Variables",
  16. ** in Kernigan and Richie, "The C Programming Language").
  17. */
  18. #define ALLOCATE_GLOBALS 1
  19. #undef USEDUMP
  20. #undef MAKEDUMP
  21.  
  22. #include "tickle.h"
  23. #include "TGE.h"
  24. #include "asd.h"
  25. #include "mb.h"
  26.  
  27. #include <GestaltEqu.h>
  28.  
  29. char    **environ = NULL;
  30.  
  31.  
  32. main(argc, argv, envp)
  33.     int        argc;
  34.     char    *argv[];
  35.     char    *envp[];
  36.     {
  37.     int        myerr, i;
  38.     long    gestaltLong;
  39.     char    **myenv;
  40.  
  41. #ifdef THINK_C
  42.     myenv = NULL;
  43. #else
  44.     myenv = envp;
  45. #endif
  46.  
  47.     if (myenv == NULL)
  48.         {
  49.         environ = (char **) malloc( 5 * sizeof(char *) );
  50.         if (environ == NULL)
  51.             {
  52.             exit(0);
  53.             }
  54.         
  55.         i = 0;
  56.         
  57. #ifdef TCL_LIBRARY
  58.         {
  59.         char    buffer[1024];
  60.         
  61.         sprintf(buffer, "TCL_LIBRARY=%s", TCL_LIBRARY);
  62.         environ[i] = ckalloc( strlen(buffer) + 1 );
  63.         strcpy(environ[i++], buffer);
  64.         }
  65. #else
  66.         environ[i++] = "TCL_LIBRARY=:library";
  67. #endif
  68.  
  69. #ifdef THINK_C
  70.         environ[i++] = "THINK_VERSION=1";
  71. #endif
  72. #ifdef MPW
  73.         environ[i++] = "MPW_VERSION=1";
  74. #endif
  75.  
  76.         environ[i] = NULL;
  77.         }
  78.     else
  79.         {
  80.         environ = myenv;
  81.         }
  82.  
  83.     /*
  84.     ** Initialize the Macintosh ROM managers that the Unifolder application
  85.     ** uses. This is required by all Macintosh applications.
  86.     */
  87.     
  88.     /* Increase stack space by 12,000 bytes */
  89.     
  90.     SetApplLimit(GetApplLimit() - (12 * 1024));
  91.     
  92.     /* Expand the application heap zone to the maximum. */
  93.     
  94.     MaxApplZone();
  95.     
  96.     /* Allocate a bunch of master pointers. */
  97.     
  98.     MoreMasters();
  99.     MoreMasters();
  100.     MoreMasters();
  101.     MoreMasters();
  102.     
  103.     /*
  104.     ** Initialize the Macintosh ROM managers that the Unifolder application
  105.     ** uses. This is required by all Macintosh applications.
  106.     */
  107.     InitGraf(&qd.thePort);
  108.     InitFonts();
  109.     InitWindows();
  110.     InitMenus();
  111.     TEInit();
  112.     InitDialogs((ResumeProcPtr)0);
  113.     InitCursor();
  114.     InitAllPacks();
  115.     
  116.     if (GestaltAvailable()) {
  117.         myerr = Gestalt(gestaltHelpMgrAttr, &gestaltLong);
  118.         if (myerr == noErr)
  119.             if ((gestaltLong & (1 << gestaltHelpMgrPresent)) != 0)
  120.                 gHasBalloons = true;
  121.     
  122.         myerr = Gestalt(gestaltFindFolderAttr, &gestaltLong);
  123.         if (myerr == noErr)
  124.             if ((gestaltLong & (1 << gestaltFindFolderPresent)) != 0)
  125.                 gHasDirectory = true;
  126.         
  127.         myerr = Gestalt(gestaltAppleEventsAttr, &gestaltLong);
  128.         if (myerr == noErr)
  129.             if ((gestaltLong & (1 << gestaltAppleEventsPresent)) != 0)
  130.                 gHasAppleEvents = true;
  131.         }
  132.     
  133.     memset(&theEnviron, 0, sizeof(SysEnvRec));
  134. #define CurrentVersion    1
  135.     if (SysEnvirons(CurrentVersion, &theEnviron) != noErr) {
  136.         theEnviron.environsVersion = -1;
  137.         theEnviron.hasColorQD = 0;
  138.         theEnviron.hasFPU = 0;
  139.         
  140.         switch (theEnviron.keyBoardType) {
  141.             case envMacKbd:        /* "Macintosh" */
  142.             case envMacAndPad:    /* "Macintosh with Pad" */
  143.             case envMacPlusKbd:    /* "MacPlus" */
  144.                 macplus_keybd = 1;
  145.                 break;
  146.             }
  147.  
  148.         message_alert("%s%s",
  149.             "This is a *very* old Mac isn't it?\015Things may not operate properly.");
  150.         }
  151.  
  152.     /*
  153.     ** Initialize things used by the application.
  154.     */
  155.     InitApplication();
  156.     
  157.     tar_initialize();
  158.     
  159.     InitFeedbackWindow();
  160.     
  161.     /*
  162.     ** app_done = true --> Quit the application.
  163.     */
  164.     app_done = false;
  165.  
  166.     /*
  167.     ** Loop forever on the application's event loop until
  168.     ** the app_done flag is set by a "quit" command.
  169.     */
  170.     
  171.     while (! app_done) {
  172.         while (! app_done) do_event();
  173.         ShutDownApplication();
  174.         }
  175.     
  176.     /*
  177.     ** All done, exit...
  178.     */
  179.     exit();
  180.     }
  181.