home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / cdity / EasyTM_src.lha / EasyTM-src / EasyTM-Prefs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-27  |  4.0 KB  |  142 lines

  1. //************************************
  2. //
  3. // Name : main.c
  4. //
  5. //************************************
  6.  
  7. //**** Header files
  8.  
  9. //** OS Include files
  10. #include <workbench/startup.h>
  11. #include <workbench/workbench.h>
  12. #include <libraries/dos.h>
  13. #include <libraries/wbstart.h>
  14. #include <libraries/gadtools.h>
  15. #include <libraries/commodities.h>
  16.  
  17. //** OS function prototypes
  18. #include <clib/exec_protos.h>
  19. #include <clib/dos_protos.h>
  20. #include <clib/wb_protos.h>
  21. #include <clib/gadtools_protos.h>
  22. #include <clib/commodities_protos.h>
  23.  
  24. //** OS function inline calls
  25. #include <pragmas/exec_pragmas.h>
  26. #include <pragmas/dos_pragmas.h>
  27. #include <pragmas/wb_pragmas.h>
  28. #include <pragmas/gadtools_pragmas.h>
  29. #include <pragmas/commodities_pragmas.h>
  30.  
  31. //** ANSI C includes
  32. //#include <stdio.h>
  33.  
  34. //** application include
  35. #include "Read.h"
  36. #include "Node.h"
  37. #include "Prefs.h"
  38. #include "Librarian.h"
  39. #include "GuiExtras.h"
  40. #include "GadToolsBox.h"
  41.  
  42.  
  43. //**** Local storage
  44.  
  45. static char VersTag[]="\0$VER: EasyTM-Prefs v1.1 (28 May 1996)";
  46.  
  47.  
  48. //**** Main
  49.  
  50. void main(int argc, char **argv) {
  51.   int running=1;
  52.   ULONG sig_c, sret;
  53.   BOOL Active=TRUE;
  54.   struct NewBroker nb = {
  55.     NB_VERSION,
  56.     "EasyTM-Prefs",
  57.     &VersTag[7],
  58.     "EasyTM Prefs commidity",
  59.     NBU_UNIQUE | NBU_NOTIFY,
  60.     COF_SHOW_HIDE,
  61.     0,
  62.     NULL,
  63.     0
  64.   };
  65.   CxObj *broker=NULL;
  66.   CxMsg *msg;
  67.  
  68.   if (1==InitList()) {
  69.     if (1==OpenLibs() ) {
  70.       if (1==ReadIcon(argc,argv) ) {
  71.         if (nb.nb_Port =CreateMsgPort() ) {
  72.           nb.nb_Pri = my_cx_pri;
  73.           sig_c = 1 << nb.nb_Port->mp_SigBit;
  74.           if (broker = CxBroker(&nb, NULL)) {
  75.             ActivateCxObj(broker, 1L);
  76.  
  77.             ReadFile(ToolsFileName);
  78.             if (0==SetupScreen()) {
  79.               CX_Show();
  80.               for (running=1; running; ) {
  81.                 sret = Wait(SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D | sig_c | sig_g);
  82.                 if (sret & SIGBREAKF_CTRL_C) running=0;
  83.                 if (sret & SIGBREAKF_CTRL_D) CX_Hide();
  84.                 if (sret & sig_g) running=HandleETMPIDCMP();
  85.                 if (sret & sig_c) {
  86.                   while(msg = (CxMsg *)GetMsg(nb.nb_Port)) {
  87.                     switch(CxMsgType(msg)) {
  88.                       case CXM_COMMAND:
  89.                         switch(CxMsgID(msg)) {
  90.                           case CXCMD_DISABLE:
  91.                             if (TRUE==Active) {
  92.                               ActivateCxObj(broker, 0L);
  93.                               Active = FALSE;
  94.                             }; // if
  95.                             break;
  96.                           case CXCMD_ENABLE:
  97.                             if (FALSE==Active) {
  98.                               ActivateCxObj(broker, 1L);
  99.                               Active = TRUE;
  100.                             }; // if
  101.                             break;
  102.                           case CXCMD_APPEAR:
  103.                             CX_Show();
  104.                             break;
  105.                           case CXCMD_DISAPPEAR:
  106.                             CX_Hide();
  107.                             break;
  108.                           case CXCMD_KILL:
  109.                             running=FALSE;
  110.                             break;
  111.                           case CXCMD_UNIQUE:
  112.                             CX_Show();
  113.                             break;
  114.                         } // switch
  115.                         break;
  116.                     } // switch
  117.                     ReplyMsg((struct Message *)msg);
  118.                   } // while GetMsg
  119.                 } // if sig_n
  120.               } // for
  121.               CX_Hide();
  122.               CloseDownScreen();
  123.             } // if SetUpScreen
  124.  
  125.             ActivateCxObj(broker, 0L);
  126.             DeleteCxObj(broker);
  127.           } // if CreateBroker
  128.           while (msg=(CxMsg *)GetMsg(nb.nb_Port)) ReplyMsg((struct Message *)msg);
  129.           DeleteMsgPort(nb.nb_Port);
  130.         } // if CreateMsgPort (commodity)
  131.         FreeVec(ToolsFileName);
  132.         FreeVec(PrefsProgDir);
  133.       } // if ReadIcon
  134.     } // if OpenLibs
  135.     CloseLibs(); // yes, this is in the correct place
  136.     FreeList(1);
  137.   } // if InitList
  138.  
  139. } // main
  140.  
  141. //**** End of file
  142.