From c0cb7354d1dee328a45fcf838b2a4d9d1367b0f8 Mon Sep 17 00:00:00 2001 From: chatty Date: Wed, 8 Feb 1995 14:44:24 +0000 Subject: new return types for Read* --- comm/Channel.cc | 36 ++++++++++++++++++++---------------- comm/Channel.h | 16 ++++++++-------- 2 files changed, 28 insertions(+), 24 deletions(-) (limited to 'comm') diff --git a/comm/Channel.cc b/comm/Channel.cc index 4515b95..9b559fc 100644 --- a/comm/Channel.cc +++ b/comm/Channel.cc @@ -3,7 +3,7 @@ * * by Michel Beaudouin-Lafon * - * Copyright 1990-1993 + * Copyright 1990-1995 * Laboratoire de Recherche en Informatique (LRI) * * File descriptors, channels @@ -423,50 +423,54 @@ UchChannel :: WriteBuf (const byte* b, int n) -void +bool UchChannel :: ReadLong (lword& l) { - Read ((byte*)&l, lwsize); + return bool (Read ((byte*)&l, lwsize) == lwsize); } -void +bool UchChannel :: ReadShort (sword& s) { - Read ((byte*)&s, swsize); + return bool (Read ((byte*)&s, swsize) == swsize); } -void +bool UchChannel :: ReadByte (byte& b) { - Read (&b, 1); + return bool (Read (&b, 1) == 1); } -void +bool UchChannel :: ReadChar (char& c) { - Read ((byte*)&c, 1); + return bool (Read ((byte*)&c, 1) == 1); } -void -UchChannel :: ReadString (char* s) +int +UchChannel :: ReadString (char* s, int n) { + int i = 0; // this is extremely non optimal do { Read ((byte*)s, 1); - } while (*s++); + i++; + } while (*s++ && n--); + return i; } -void +int UchChannel :: ReadString (CcuString& s) { // this enforces an undue limitation char c [1024]; - ReadString (c); + int i = ReadString (c, -1); s = c; + return i; } -void +bool UchChannel :: ReadBuf (byte* b, int n) { - Read (b, n); + return bool (Read (b, n) == n); } diff --git a/comm/Channel.h b/comm/Channel.h index 9d30321..4a6d5f9 100644 --- a/comm/Channel.h +++ b/comm/Channel.h @@ -3,7 +3,7 @@ * * by Michel Beaudouin-Lafon * - * Copyright 1990-1993 + * Copyright 1990-1995 * Laboratoire de Recherche en Informatique (LRI) * * File descriptors, channels @@ -117,13 +117,13 @@ virtual void WriteChar (char); virtual void WriteString (const char*); virtual void WriteBuf (const byte*, int); -virtual void ReadLong (lword&); -virtual void ReadShort (sword&); -virtual void ReadByte (byte&); -virtual void ReadChar (char&); -virtual void ReadString (char*); -virtual void ReadString (CcuString&); -virtual void ReadBuf (byte*, int); +virtual bool ReadLong (lword&); +virtual bool ReadShort (sword&); +virtual bool ReadByte (byte&); +virtual bool ReadChar (char&); +virtual int ReadString (char*, int); +virtual int ReadString (CcuString&); +virtual bool ReadBuf (byte*, int); static CH_HANDLER ReadHandler; static CH_HANDLER WriteHandler; -- cgit v1.1