From b4da0b7e0aa8614f668308733599639c7f56ca98 Mon Sep 17 00:00:00 2001 From: chatty Date: Mon, 29 Nov 1993 12:29:07 +0000 Subject: New syntax for CcuIdTables Changed syntax of UchMsgBuffer::Get --- comm/OLD/dgram.cc | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'comm/OLD') diff --git a/comm/OLD/dgram.cc b/comm/OLD/dgram.cc index d6e5c50..28e50d1 100644 --- a/comm/OLD/dgram.cc +++ b/comm/OLD/dgram.cc @@ -49,12 +49,6 @@ struct PENDING { ~PENDING () { delete outBuf; toAddr = 0; } }; -static void -DelPending (void* p) -{ - delete ((PENDING*) p); -} - /*?hidden?*/ void UchDGRAM_TIMER :: Handle (Millisecond) @@ -114,15 +108,17 @@ UchDGRAM :: ~UchDGRAM () timer.Stop (); if (! npending) return; - for (CcuIdIter iter (pending); iter (); ++iter) { + CcuIdIterOf iter = pending; + while (++iter) { RemovePending (iter.CurId ()); if (! npending) break; } if (ninput) { - CcuListIter li (input); + CcuListIterOf li (input); while (++li) - DelPending (*li); + delete *li; + input.Clear (); } } @@ -155,9 +151,9 @@ DEBUG SysError (ErrWarn, "UchDGRAM::GetInput") DEBUG if (DGTrace) printf ("UchDGRAM :: GetInput : received %d bytes\n", buf->BufLength ()); lword id; - buf->Get (&id); + buf->Get (id); byte s; - buf->Get (&s); + buf->Get (s); DEBUG if (DGTrace) printf ("UchDGRAM :: GetInput : id %x byte %d\n", id, s); if (s == DGRAM_ACK) { @@ -226,7 +222,7 @@ DEBUG if (DGTrace) printf ("UchDGRAM::Wait %x\n", id); break; // did we receive the ack ? - pend = (PENDING*) pending.Get (id); + pend = pending.Get (id); if (! pend) { ret = TRUE; break; @@ -323,7 +319,7 @@ DEBUG SysError (ErrWarn, "UchDGRAM::SendBuffer") void UchDGRAM :: RemovePending (lword id) { - PENDING* pend = (PENDING*) pending.Get (id); + PENDING* pend = pending.Get (id); if (! pend) { Error (ErrWarn, "Receive", "unrecognized ACK"); return; @@ -359,7 +355,7 @@ UchDGRAM :: Receive (byte* buf, int len) DEBUG if (DGTrace) printf ("UchDGRAM :: Receive\n"); if (! WaitInput ()) return -1; - PENDING* p = (PENDING*) input.RemoveFirst (); + PENDING* p = input.RemoveFirst (); ninput--; int n = p->outBuf->BufLength (); if (len < n) @@ -404,7 +400,7 @@ UchDGRAM :: Receive (UchMsgBuffer& buf) DEBUG if (DGTrace) printf ("UchDGRAM :: Receive\n"); if (! WaitInput ()) return -1; - PENDING* p = (PENDING*) input.RemoveFirst (); + PENDING* p = input.RemoveFirst (); ninput--; int n = p->outBuf->BufLength (); buf.Append (p->outBuf->Buffer (), n); @@ -464,13 +460,13 @@ UchDGRAM :: Receive (UchMessage* msg) DEBUG if (DGTrace) printf ("UchDGRAM :: Receive message\n"); if (! WaitInput ()) return FALSE; - PENDING* p = (PENDING*) input.RemoveFirst (); + PENDING* p = input.RemoveFirst (); ninput--; // int n; // printf ("inBuffer is %d bytes long\n", n = p->outBuf->BufLength ()); // for (int i = 0; i < n; i++) printf ("%02x ", p->outBuf->Buffer () [i]); // printf ("\n"); - if (! p->outBuf->Get (msg)) + if (! p->outBuf->Get (*msg)) return FALSE; SendAck (p->id, *p->toAddr); delete p; @@ -515,7 +511,7 @@ DEBUG if (DGTrace) printf ("UchDGRAM :: Ask\n"); for (;;) { if (! WaitInput ()) continue; - PENDING* pend = (PENDING*) input.Last (); + PENDING* pend = input.Last (); if (pend->toAddr == to............. } } @@ -546,15 +542,16 @@ if (DGTrace) printf ("UchDGRAM::Resend\n"); UchAddress* addr = 0; - PENDING* pend; - for (CcuIdIter iter (pending); pend = (PENDING*) iter (); ++iter) { + CcuIdIterOf iter = pending; + while ( ++iter) { + PENDING* pend = *iter; if (pend->retries <= 0) { // the output buffer contains the leading id and type UchMsgBuffer fake (*pend->outBuf); lword id; byte typ; - fake.Get (&id); - fake.Get (&typ); + fake.Get (id); + fake.Get (typ); if (! DiscardNotify (fake, *pend->toAddr)) { pend->retries = retry; // *** should be controllable ? continue; @@ -652,7 +649,7 @@ UchDGRAM :: HandleRead () return; DEBUG if (DGTrace) printf (">>UchDGRAM :: HandleRead\n"); - PENDING* p = (PENDING*) input.RemoveFirst (); + PENDING* p = input.RemoveFirst (); ninput--; if (NewMessage (* p->outBuf)) SendAck (p->id, *p->toAddr); @@ -671,7 +668,7 @@ UchDGRAM :: HandleSelect () if (! ninput) return FALSE; DEBUG if (DGTrace) printf (">>UchDGRAM :: HandleSelect\n"); - PENDING* p = (PENDING*) input.RemoveFirst (); + PENDING* p = input.RemoveFirst (); ninput--; if (NewMessage (* p->outBuf)) SendAck (p->id, *p->toAddr); -- cgit v1.1