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

  1. //************************************
  2. //
  3. // Name : janitor.c
  4. //
  5. //************************************
  6.  
  7.  
  8. //**** Header files
  9.  
  10. //** OS Include files
  11.  
  12. //** OS function prototypes
  13. #include <clib/exec_protos.h>
  14. #include <clib/wb_protos.h>
  15.  
  16. //** OS function inline calls
  17. #include <pragmas/exec_pragmas.h>
  18. #include <pragmas/wb_pragmas.h>
  19.  
  20. //** ANSI C includes
  21.  
  22. //** application include
  23.  
  24. #include "Librarian.h"
  25. #include "Node.h"
  26. #include "Janitor.h"
  27.  
  28.  
  29. //**** Local data structures
  30.  
  31. struct MsgPort *StarPort[NUMPORTS]={NULL};
  32.  
  33.  
  34. //**** Aux functions
  35.  
  36. int BindMenus(void) {
  37.   struct ProgNode *pn;
  38.   if (IsListEmpty(List)) return 0;
  39.   for (pn = (struct ProgNode *)List->lh_Head ; pn->pn_Node.ln_Succ ; pn = (struct ProgNode *)pn->pn_Node.ln_Succ) {
  40.     pn->pn_appmenu=AddAppMenuItemA(0L,(ULONG)pn,pn->pn_Node.ln_Name,StarPort[1],NULL);
  41.     if (NULL==pn->pn_appmenu) {
  42.       FreeMenus();
  43.       return 0;
  44.     } // if
  45.   };
  46.   return 1;
  47. } // BindMenus
  48.  
  49. int FreeMenus(void) {
  50.   struct ProgNode *pn;
  51.   if (IsListEmpty(List)) return 1;
  52.   for (pn = (struct ProgNode *)List->lh_Head ; pn->pn_Node.ln_Succ ; pn = (struct ProgNode *)pn->pn_Node.ln_Succ) {
  53.     if (NULL!=pn->pn_appmenu) {
  54.       RemoveAppMenuItem(pn->pn_appmenu);
  55.       pn->pn_appmenu=NULL;
  56.     } // if
  57.   };
  58.   return 1;
  59. } // FreeMenus
  60.  
  61. int OpenPorts(void) {
  62.   int i;
  63.   for (i=0 ; i<NUMPORTS; i++) {
  64.     StarPort[i]=CreateMsgPort();
  65.     if (NULL==StarPort[i]) return 0;
  66.   }; // for
  67.   return 1;
  68. } // OpenPorts
  69.  
  70. void ClosePorts(void) {
  71.   int i;
  72.   struct Message *msg;
  73.  
  74.   for (i=0 ; i<NUMPORTS; i++) {
  75.     if (NULL!=StarPort[i]) {
  76.       while (msg=GetMsg(StarPort[i])) ReplyMsg((struct Message *)msg);
  77.       DeleteMsgPort(StarPort[i]);
  78.     }; // if
  79.   }; // for
  80. } // ClosePorts
  81.  
  82. //**** End of file
  83.