home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1106 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.2 KB  |  87 lines

  1. Path: sn.no!not-for-mail
  2. From: christon (Christopher Naas)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: MsgPorts
  5. Date: 15 Jan 1996 21:04:46 +0100
  6. Organization: SN Internett
  7. Message-ID: <2005.6588T1264T489@Th0r.foo.bar>
  8. NNTP-Posting-Host: sinsen.sn.no
  9. X-Newsreader: THOR 2.21 (Amiga;SOUP)
  10.  
  11. Can someone please tell me what I'm doing wrong here? When I run this program,
  12. it causes a "Disable/Reboot" requester, and then hangs the machine (hard). If
  13. I run it with Enforcer enabled, it works fine. I guess I'm doing something not
  14. quite right, but I can't see what. Please help.
  15.  
  16. #include <exec/types.h>
  17. #include <exec/memory.h>
  18. #include <proto/exec.h>
  19. #include <proto/dos.h>
  20.  
  21.  
  22.  
  23. struct KMsg
  24. {
  25.     struct Message       Message;
  26.     ULONG                Type;
  27. };
  28. struct MsgPort       *mymsgport;
  29. struct KMsg          *kmsg;
  30. ULONG                    sig;
  31. UBYTE                 str[]="<< My test port >>";
  32.  
  33. void __main (void)
  34. {
  35.    if (kmsg = AllocVec (sizeof (struct KMsg), MEMF_ANY|MEMF_CLEAR))
  36.    {
  37.       kmsg->Type = 205;
  38.  
  39.       if (mymsgport = AllocVec (sizeof (struct MsgPort), MEMF_ANY|MEMF_CLEAR))
  40.       {
  41.          if (mymsgport = CreateMsgPort ())
  42.          {
  43.             mymsgport->mp_Node.ln_Name  = str;
  44.             mymsgport->mp_Node.ln_Pri   = 0;
  45.  
  46.             AddPort (mymsgport);
  47.  
  48.             for (;;)
  49.             {
  50.                sig = Wait (SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_C | 1L <<
  51. mymsgport->mp_SigBit);
  52.  
  53.                if (sig & SIGBREAKF_CTRL_C)
  54.                {
  55.                   break;
  56.                }
  57.                else
  58.                if (sig & SIGBREAKF_CTRL_E)
  59.                {
  60.                   PutMsg (mymsgport, (struct Message *)kmsg);
  61.                }
  62.                else
  63.                if (sig & 1L << mymsgport->mp_SigBit)
  64.                {
  65.                   kmsg = (struct KMsg *)GetMsg (mymsgport);
  66.                   Printf ("Got it!  %ld\n", kmsg->Type);
  67.                   ReplyMsg ((struct Message *)kmsg);
  68.                }
  69.             }
  70.  
  71.             RemPort (mymsgport);
  72.             DeleteMsgPort (mymsgport);
  73.          }
  74.  
  75.          FreeVec (mymsgport);
  76.       }
  77.  
  78.       FreeVec (kmsg);
  79.    }
  80. }
  81.  
  82.  
  83. --
  84. Christopher Landmark Naas    o  EMail: christon@sn.no
  85. LoungeBar Development        o  WWW:   http://www.sn.no/~christon/
  86. Former Reg. Amiga Developer  o  IRC:   KarmaComa
  87.