summaryrefslogtreecommitdiff
path: root/comm/BufStream.cc
diff options
context:
space:
mode:
authorsc2000-11-28 17:07:47 +0000
committersc2000-11-28 17:07:47 +0000
commitee937667fd0ecd82faab4c88d756b906fb625f1a (patch)
tree19e679318b5cb87e8be1a05a7bbc9ba5568d0814 /comm/BufStream.cc
parent1326b11d65f7020f5f6c691305d2c090b064bd04 (diff)
downloadivy-league-ee937667fd0ecd82faab4c88d756b906fb625f1a.zip
ivy-league-ee937667fd0ecd82faab4c88d756b906fb625f1a.tar.gz
ivy-league-ee937667fd0ecd82faab4c88d756b906fb625f1a.tar.bz2
ivy-league-ee937667fd0ecd82faab4c88d756b906fb625f1a.tar.xz
Integration into IvyLeague
Uvh -> Ivl Multiplexer.* is renamed into Scheduler.* A few name conflicts in the merger with ex-DNN have been solved Imakefile is replaced by Makefile Created InetAddress.* and UnixAddress.* from Address.* Created IrdaAddress.* OLD/TextStream has been updated
Diffstat (limited to 'comm/BufStream.cc')
-rw-r--r--comm/BufStream.cc82
1 files changed, 45 insertions, 37 deletions
diff --git a/comm/BufStream.cc b/comm/BufStream.cc
index d1ca25d..80bbdea 100644
--- a/comm/BufStream.cc
+++ b/comm/BufStream.cc
@@ -10,16 +10,17 @@
*
* $Id$
* $CurLog$
+ * Created from bits of MsgStream.cc
*/
#include "BufStream.h"
#include "error.h"
/*?
-These constructors are similar to those of class \typ{UchSocket}.
+These constructors are similar to those of class \typ{IvlSocket}.
?*/
-UchBufStream :: UchBufStream (UchAddress* bindTo, UchAddress* connectTo)
-: UchStream (bindTo, connectTo),
+IvlBufStream :: IvlBufStream (IvlAddress* bindTo, IvlAddress* connectTo)
+: IvlStream (bindTo, connectTo),
InBuffer (),
OutBuffer (),
OutSize (128),
@@ -29,8 +30,8 @@ UchBufStream :: UchBufStream (UchAddress* bindTo, UchAddress* connectTo)
// *** this copy constructor might be automatically generated
/*?nodoc?*/
-UchBufStream :: UchBufStream (const UchBufStream& ms)
-: UchStream (ms),
+IvlBufStream :: IvlBufStream (const IvlBufStream& ms)
+: IvlStream (ms),
InBuffer (),
OutBuffer (),
OutSize (ms.OutSize),
@@ -39,7 +40,7 @@ UchBufStream :: UchBufStream (const UchBufStream& ms)
}
/*?nodoc?*/
-UchBufStream :: ~UchBufStream ()
+IvlBufStream :: ~IvlBufStream ()
{
Flush ();
InBuffer.Clear ();
@@ -48,7 +49,7 @@ UchBufStream :: ~UchBufStream ()
/*?nextdoc?*/
void
-UchBufStream :: InputBuffer (int min, int grow, int max)
+IvlBufStream :: InputBuffer (int min, int grow, int max)
{
InBuffer.SetSizes (min, grow, max);
}
@@ -58,7 +59,7 @@ Set the input and output buffer sizes.
Default sizes are used if these functions are not called.
?*/
void
-UchBufStream :: OutputBuffer (int min, int grow, int max)
+IvlBufStream :: OutputBuffer (int min, int grow, int max)
{
OutBuffer.SetSizes (min, grow, max);
OutSize = max;
@@ -71,7 +72,7 @@ or after each message when this stream is in synchronous mode.
It is also called from \fun{Ask} to wait for the answer.
?*/
void
-UchBufStream :: Flush ()
+IvlBufStream :: Flush ()
{
if (OutBuffer.BufLength () == 0)
return;
@@ -81,34 +82,43 @@ UchBufStream :: Flush ()
/*?nodoc?*/
void
-UchBufStream :: HandleWrite ()
+IvlBufStream :: HandleWrite ()
{
Flush ();
}
-
// read stream into input buffer
// delete the stream when an eof is received
// return the number of bytes read
//
/*?hidden?*/
int
-UchBufStream :: ReadInput ()
+IvlBufStream :: ReadInput ()
{
+ /* read in buffer */
if (InBuffer.BufLength () == 0)
InBuffer.NeedSize (128);
int n = Read (InBuffer);
- if (n <= 0) {
- if (n == -2) {
- InBuffer.Grow ();
- n = Read (InBuffer);
- }
- if (n < 0)
- SysError (ErrWarn, "UchBufStream::ReadInput");
- if (n <= 0)
- Closing (n < 0 ? false : true);
+
+ /* handle errors */
+ if (n == -2) {
+ InBuffer.Grow ();
+ n = Read (InBuffer);
}
+
+#if 0
+ if (n < 0)
+ SysError (ErrWarn, "IvlBufStream::ReadInput");
+ if (n <= 0)
+ Closing (n < 0 ? false : true);
return n;
+#else
+ /* new code taken from BusAccess.cc (27/11/2000) */
+ if (n <= 0)
+ delete this;
+ return n;
+
+#endif
}
/*?
@@ -120,87 +130,85 @@ if it is non zero, \fun{Closing} was called because of an error. % wrong
By default this function does nothing.
?*/
void
-UchBufStream :: Closing (bool)
+IvlBufStream :: Closing (bool)
{
}
-
void
-UchBufStream :: WriteLong (lword l)
+IvlBufStream :: WriteLong (lword l)
{
OutBuffer << l;
}
void
-UchBufStream :: WriteShort (sword s)
+IvlBufStream :: WriteShort (sword s)
{
OutBuffer << s;
}
void
-UchBufStream :: WriteByte (byte b)
+IvlBufStream :: WriteByte (byte b)
{
OutBuffer << b;
}
void
-UchBufStream :: WriteChar (char c)
+IvlBufStream :: WriteChar (char c)
{
OutBuffer << c;
}
void
-UchBufStream :: WriteString (const char* s)
+IvlBufStream :: WriteString (const char* s)
{
OutBuffer << s;
}
void
-UchBufStream :: WriteBuf (const byte* b, int n)
+IvlBufStream :: WriteBuf (const byte* b, int n)
{
OutBuffer.WriteBuf (b, n);
}
bool
-UchBufStream :: ReadLong (lword& l)
+IvlBufStream :: ReadLong (lword& l)
{
return InBuffer.ReadLong (l);
}
bool
-UchBufStream :: ReadShort (sword& s)
+IvlBufStream :: ReadShort (sword& s)
{
return InBuffer.ReadShort (s);
}
bool
-UchBufStream :: ReadByte (byte& b)
+IvlBufStream :: ReadByte (byte& b)
{
return InBuffer.ReadByte (b);
}
bool
-UchBufStream :: ReadChar (char& c)
+IvlBufStream :: ReadChar (char& c)
{
return InBuffer.ReadChar (c);
}
int
-UchBufStream :: ReadString (char* s, int n)
+IvlBufStream :: ReadString (char* s, int n)
{
return InBuffer.ReadString (s, n);
}
int
-UchBufStream :: ReadString (CcuString& s)
+IvlBufStream :: ReadString (IvlString& s)
{
return InBuffer.ReadString (s);
}
bool
-UchBufStream :: ReadBuf (byte* b, int n)
+IvlBufStream :: ReadBuf (byte* b, int n)
{
return InBuffer.ReadBuf (b, n);
}
-