home *** CD-ROM | disk | FTP | other *** search
- Path: sn.no!not-for-mail
- From: christon (Christopher Naas)
- Newsgroups: comp.sys.amiga.programmer
- Subject: MsgPorts
- Date: 15 Jan 1996 21:04:46 +0100
- Organization: SN Internett
- Message-ID: <2005.6588T1264T489@Th0r.foo.bar>
- NNTP-Posting-Host: sinsen.sn.no
- X-Newsreader: THOR 2.21 (Amiga;SOUP)
-
- Can someone please tell me what I'm doing wrong here? When I run this program,
- it causes a "Disable/Reboot" requester, and then hangs the machine (hard). If
- I run it with Enforcer enabled, it works fine. I guess I'm doing something not
- quite right, but I can't see what. Please help.
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
-
-
-
- struct KMsg
- {
- struct Message Message;
- ULONG Type;
- };
- struct MsgPort *mymsgport;
- struct KMsg *kmsg;
- ULONG sig;
- UBYTE str[]="<< My test port >>";
-
- void __main (void)
- {
- if (kmsg = AllocVec (sizeof (struct KMsg), MEMF_ANY|MEMF_CLEAR))
- {
- kmsg->Type = 205;
-
- if (mymsgport = AllocVec (sizeof (struct MsgPort), MEMF_ANY|MEMF_CLEAR))
- {
- if (mymsgport = CreateMsgPort ())
- {
- mymsgport->mp_Node.ln_Name = str;
- mymsgport->mp_Node.ln_Pri = 0;
-
- AddPort (mymsgport);
-
- for (;;)
- {
- sig = Wait (SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_C | 1L <<
- mymsgport->mp_SigBit);
-
- if (sig & SIGBREAKF_CTRL_C)
- {
- break;
- }
- else
- if (sig & SIGBREAKF_CTRL_E)
- {
- PutMsg (mymsgport, (struct Message *)kmsg);
- }
- else
- if (sig & 1L << mymsgport->mp_SigBit)
- {
- kmsg = (struct KMsg *)GetMsg (mymsgport);
- Printf ("Got it! %ld\n", kmsg->Type);
- ReplyMsg ((struct Message *)kmsg);
- }
- }
-
- RemPort (mymsgport);
- DeleteMsgPort (mymsgport);
- }
-
- FreeVec (mymsgport);
- }
-
- FreeVec (kmsg);
- }
- }
-
-
- --
- Christopher Landmark Naas o EMail: christon@sn.no
- LoungeBar Development o WWW: http://www.sn.no/~christon/
- Former Reg. Amiga Developer o IRC: KarmaComa
-