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 / tickle.c < prev    next >
C/C++ Source or Header  |  1993-11-18  |  4KB  |  206 lines

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