home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 1 / FFMCD01.bin / bbs / libdisks / d700t799 / disk751.lha / PPMC / Source / PPMC_Setup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-05  |  4.1 KB  |  153 lines

  1. /*
  2.                             -----------------------
  3.                                   PPMC_Setup.c
  4.                                 © 1992 REELSOFT
  5.                             -----------------------
  6. */
  7.  
  8. #include    "PPMC_Setup.h"
  9.  
  10. VOID    Setup (VOID)
  11. {
  12. //    Opening reqtools.library...
  13.     ReqToolsBase = (struct ReqToolsBase *)OpenLibrary ( REQTOOLSNAME, REQTOOLSVERSION ) ;
  14.     if ( ReqToolsBase == NULL )
  15.         exit ( RETURN_FAIL ) ;
  16.  
  17. //    Opening powerpacker.library...
  18.     PPBase = (struct PPBase *)OpenLibrary ( PPNAME, PPVERSION ) ;
  19.     if ( PPBase == NULL ) {
  20.         DisplayWarning ( "You need powerpacker.library V35+ !" ) ;
  21.         Cleanup ( FROM_REQTOOLS, RETURN_FAIL ) ;
  22.     }
  23.  
  24. //    Opening intuition.library...
  25.     IntuitionBase = OpenLibrary ( "intuition.library", 37L ) ;
  26.     if ( IntuitionBase == NULL ) {
  27.         DisplayWarning ( "You need KickStart V37+ !" ) ;
  28.         Cleanup ( FROM_PPACKER, RETURN_FAIL ) ;
  29.     }
  30.  
  31. //    Opening graphics.library...
  32.     GfxBase = OpenLibrary ( "graphics.library", 37L ) ;
  33.     if ( GfxBase == NULL )
  34.         Cleanup ( FROM_INTUITION, RETURN_FAIL ) ;
  35.  
  36. //    Opening gadtools.library...
  37.     GadToolsBase = OpenLibrary ( "gadtools.library", 37L ) ;
  38.     if ( GadToolsBase == NULL )
  39.         Cleanup ( FROM_GFX, RETURN_FAIL ) ;
  40.  
  41. //    Opening utility.library...
  42.     UtilityBase = OpenLibrary ( "utility.library", 37L ) ;
  43.     if ( UtilityBase == NULL )
  44.         Cleanup ( FROM_GADTOOLS, RETURN_FAIL ) ;
  45.  
  46. //    Opening workbench.library...
  47.     WorkbenchBase = OpenLibrary ( "workbench.library", 37L ) ;
  48.     if ( WorkbenchBase == NULL )
  49.         Cleanup ( FROM_UTILITY, RETURN_FAIL ) ;
  50.  
  51. //    Opening commodities.library...
  52. #ifdef    PPMC_CX
  53.     CxBase = OpenLibrary ( "commodities.library", 37L ) ;
  54.     if ( CxBase == NULL )
  55.         Cleanup ( FROM_WORKBENCH, RETURN_FAIL ) ;
  56. #endif
  57.  
  58. //    Initializing the custom font...
  59.     FontInit_PPMC () ;
  60.     AddFont ( &PPMCFont ) ;
  61.  
  62. //    Locking the Workbench screen...
  63.     if ( SetupScreen () ) {
  64.         DisplayWarning ( "Unable to Lock\nWorkbench Screen !" ) ;
  65.         Cleanup ( FROM_SCREEN, RETURN_WARN ) ;
  66.     }
  67.  
  68. //    Opening PPMC Window...
  69.     if ( OpenPPMCWindow () ) {
  70.         DisplayWarning ( "Unable to open\nthe PPMC Window !" ) ;
  71.         Cleanup ( FROM_WINDOW, RETURN_WARN ) ;
  72.     }
  73.  
  74. //    Creating a Message Port...
  75.     msgport = CreateMsgPort () ;
  76.     if ( msgport == NULL ) {
  77.         DisplayWarning ( "Unable to Create Message Port !" ) ;
  78.         Cleanup ( FROM_WINDOW, RETURN_WARN ) ;
  79.     }
  80.  
  81. //    Adding an AppWindow...
  82.     appwin = AddAppWindow ( 1,0, PPMCWnd, msgport, NULL ) ;
  83.     if ( appwin == NULL ) {
  84.         DeleteMsgPort( msgport );
  85.         msgport = NULL;
  86.     }
  87.  
  88. //    Creating a Commodities Broker Port...
  89. #ifdef    PPMC_CX
  90.     BrokerMP = CreateMsgPort () ;
  91.     if ( BrokerMP == NULL ) {
  92.         DisplayWarning ( "Unable to Create\na Broker Port" ) ;
  93.         Cleanup ( FROM_APPWINDOW, RETURN_FAIL ) ;
  94.     }
  95.     newbroker.nb_Port = BrokerMP ;
  96.  
  97. //    Adding a Broker to the Commodities master list...
  98.     broker = CxBroker ( &newbroker, NULL ) ;
  99.     if ( broker == NULL ) {
  100.         DisplayWarning ( "Unable to Create a Broker" ) ;
  101.         Cleanup ( FROM_CXPORT, RETURN_FAIL ) ;
  102.     }
  103.     ActivateCxObj ( broker, 1L ) ;
  104. #endif
  105. }
  106.  
  107. //    »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  108. VOID    Cleanup ( WORD from, int return_code )
  109. {
  110. #ifdef    PPMC_CX
  111.     register    struct    Message    *msg ;
  112. #endif
  113.  
  114.     switch (from) {
  115.         case FROM_CLI        :
  116. #ifdef    PPMC_CBACK
  117.                                 if (_Backstdout) {
  118.                                     Write (_Backstdout, PPMC_CLI, strlen (PPMC_CLI)) ;
  119. #ifndef    _DCC
  120.                                     Close (_Backstdout) ;
  121. #endif
  122.                                 }
  123. #endif
  124.         case FROM_WB        :
  125. #ifdef    PPMC_CX
  126.         case FROM_BROKER    :    DeleteCxObjAll (broker) ;
  127.         case FROM_CXPORT    :    while (msg = GetMsg (BrokerMP))
  128.                                     ReplyMsg (msg) ;
  129.                                 DeletePort (BrokerMP) ;
  130. #endif
  131.         case FROM_APPWINDOW    :    if (appwin)
  132.                                     RemoveAppWindow (appwin) ;
  133.         case FROM_MSGPORT    :    if (msgport)
  134.                                     DeleteMsgPort (msgport) ;
  135.         case FROM_WINDOW    :    ClosePPMCWindow () ;
  136.         case FROM_SCREEN    :    CloseDownScreen () ;
  137.         case FROM_FONT        :    RemFont ( &PPMCFont ) ;
  138. #ifdef    PPMC_CX
  139.         case FROM_COMMODITY    :    CloseLibrary (CxBase) ;
  140. #endif
  141.         case FROM_WORKBENCH    :    CloseLibrary (WorkbenchBase) ;
  142.         case FROM_UTILITY    :    CloseLibrary (UtilityBase) ;
  143.         case FROM_GADTOOLS    :    CloseLibrary (GadToolsBase) ;
  144.         case FROM_GFX        :    CloseLibrary (GfxBase) ;
  145.         case FROM_INTUITION    :    CloseLibrary (IntuitionBase) ;
  146.         case FROM_PPACKER    :    CloseLibrary ((struct Library *)PPBase) ;
  147.         case FROM_REQTOOLS    :    CloseLibrary ((struct Library *)ReqToolsBase) ;
  148.                                 break ;
  149.     }
  150.     exit ( return_code ) ;
  151. }
  152.  
  153. //    ...