summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsc2000-11-28 17:07:47 +0000
committersc2000-11-28 17:07:47 +0000
commitee937667fd0ecd82faab4c88d756b906fb625f1a (patch)
tree19e679318b5cb87e8be1a05a7bbc9ba5568d0814
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
-rw-r--r--comm/Address.cc343
-rw-r--r--comm/Address.h89
-rw-r--r--comm/BufStream.cc82
-rw-r--r--comm/BufStream.h15
-rw-r--r--comm/BusAccess.cc207
-rw-r--r--comm/BusAccess.h108
-rw-r--r--comm/Channel.cc139
-rw-r--r--comm/Channel.h55
-rw-r--r--comm/Datagram.cc44
-rw-r--r--comm/Datagram.h26
-rw-r--r--comm/IOS.cc39
-rw-r--r--comm/IOS.h43
-rw-r--r--comm/Imakefile137
-rw-r--r--comm/InetAddress.cc251
-rw-r--r--comm/InetAddress.h58
-rw-r--r--comm/IrdaAddress.cc69
-rw-r--r--comm/IrdaAddress.h38
-rw-r--r--comm/Makefile164
-rw-r--r--comm/Message.cc22
-rw-r--r--comm/Message.h21
-rw-r--r--comm/MsgBuffer.cc139
-rw-r--r--comm/MsgBuffer.h38
-rw-r--r--comm/MsgStream.cc97
-rw-r--r--comm/MsgStream.h30
-rw-r--r--comm/Scheduler.cc (renamed from comm/Multiplexer.cc)181
-rw-r--r--comm/Scheduler.h (renamed from comm/Multiplexer.h)78
-rw-r--r--comm/SignalHandler.cc42
-rw-r--r--comm/SignalHandler.h27
-rw-r--r--comm/Socket.cc70
-rw-r--r--comm/Socket.h26
-rw-r--r--comm/Stream.cc30
-rw-r--r--comm/Stream.h10
-rw-r--r--comm/TimeOut.cc51
-rw-r--r--comm/TimeOut.h37
-rw-r--r--comm/TkMultiplexer.cc34
-rw-r--r--comm/TkMultiplexer.h8
-rw-r--r--comm/UnixAddress.cc86
-rw-r--r--comm/UnixAddress.h43
-rw-r--r--comm/XtMultiplexer.cc36
-rw-r--r--comm/XtMultiplexer.h6
-rw-r--r--comm/error.cc21
-rw-r--r--comm/error.h11
-rw-r--r--comm/test.cc56
-rw-r--r--comm/testbus.cc55
-rw-r--r--comm/version.h8
45 files changed, 1691 insertions, 1479 deletions
diff --git a/comm/Address.cc b/comm/Address.cc
index d0853d1..01bc037 100644
--- a/comm/Address.cc
+++ b/comm/Address.cc
@@ -10,6 +10,8 @@
*
* $Id$
* $CurLog$
+ * Smart(ies) removed by Stephane Sire
+ * Added buffered hostname to IvlInetAddress
*/
#include "Address.h"
@@ -20,30 +22,20 @@
#include <unistd.h>
#include <stdio.h>
#include <memory.h>
-#include <sys/utsname.h>
+
+/* all this is necessary for function Decode only. This should be investigated */
+#include "UnixAddress.h"
+#include "InetAddress.h"
+#include "IrdaAddress.h"
-#ifdef __osf__
-extern "C" {
-#endif
-#include <netdb.h>
-#ifdef __osf__
-}
-#endif
-#ifdef __osf__
-extern "C" {
- unsigned short htons (unsigned short);
- unsigned short ntohs (unsigned short);
- int gethostname (char*, int);
-}
-#endif
-/*?class UchAddress
+/*?class IvlAddress
This class is a virtual base class: no objects of this class are ever created.
It implements the Unix type \typ{^{struct sockaddr}}, used for creating sockets.
Addresses are used mainly as arguments of constructors for the class
-\typ{UchSocket} and its derived classes.
+\typ{IvlSocket} and its derived classes.
All its member functions are virtual.
These functions exist for all the derived classes but are only described here.
An address can be valid or invalid, depending on the constructor being able to create the address or not.
@@ -57,13 +49,13 @@ static member function \fun{Decode} for example when a socket is bound.
/*?
Construct an invalid address.
?*/
-UchAddress :: UchAddress ()
+IvlAddress :: IvlAddress ()
: Valid (false)
{
}
/*?nodoc?*/
-UchAddress :: ~UchAddress ()
+IvlAddress :: ~IvlAddress ()
{
}
@@ -74,7 +66,7 @@ UchAddress :: ~UchAddress ()
Return true if the address is valid.
?*/
bool
-UchAddress :: IsValid ()
+IvlAddress :: IsValid ()
{
}
@@ -83,13 +75,13 @@ Return one of \var{AF\_UNSPEC}, \var{AF\_UNIX} or \var{AF\_INET}.
Other values may be defined if supported by the system.
?*/
int
-UchAddress :: Family ()
+IvlAddress :: Family ()
{
}
/*?nextdoc?*/
int
-UchAddress :: Length ()
+IvlAddress :: Length ()
{
}
@@ -98,175 +90,22 @@ Return the address structure and its length.
\typ{^{SockAddr}} is a typedef for \typ{^{struct sockaddr}}.
?*/
SockAddr*
-UchAddress :: GetSockAddr ()
+IvlAddress :: GetSockAddr ()
{
}
/*?nodoc?*/
char*
-UchAddress :: StrRepr (char* buf)
+IvlAddress :: StrRepr (char* buf)
{
}
#endif /* DOC */
-#ifdef UNIX_SOCK
-
-// constructors for Unix addresses
-// a Unix domain address is just a filename
-// -> some problems: check for access, when to unlink it ?
-// to do : generate name from a template (for uniqueness)
-//
-
-/*?nodoc?*/
-UchUnixAddress :: UchUnixAddress ()
-: UchAddress ()
-{
-}
-
-/*?
-Create a Unix domain address associated to file \var{filename}.
-The file is not unlinked when the address is destroyed;
-it should be unlinked by the application whenever the last socket using this address is closed.
-?*/
-UchUnixAddress :: UchUnixAddress (const char* filename)
-: UchAddress ()
-{
- Addr.sun_family = AF_UNIX;
- strcpy (Addr.sun_path, filename);
- Valid = true;
- // should check access to file ???
- // unlink if already there ?
-}
-
-/*?nodoc?*/
-UchUnixAddress :: ~UchUnixAddress ()
-{
- // how to unlink the file ??
-}
-
-/*?nodoc?*/
-int
-UchUnixAddress :: Family ()
-{
- return AF_UNIX;
-}
-
-/*?nodoc?*/
-int
-UchUnixAddress :: Length ()
-{
- if (Valid)
- return (Addr.sun_path + strlen (Addr.sun_path)) - (char*) &Addr;
- return 0;
-}
-
-/*?nodoc?*/
-SockAddr*
-UchUnixAddress :: GetSockAddr ()
-{
- return (SockAddr*) &Addr;
-}
-
-/*?nodoc?*/
-char*
-UchUnixAddress :: StrRepr (char* buf)
-{
- sprintf (buf, "%s", Addr.sun_path);
- return buf;
-}
-
-#endif /* UNIX_SOCK */
-
-// constructors for inet addresses
-// inet address specified by:
-// hostname / port# (ANY if hostname is NIL, LOOPBACK if hostname is "")
-// hostid / port# (predefined hostids ANYADDR, ...)
-// todo:
-// hostname / service name ??
-//
-/*?
-UchInetAddresses should only be allocated with new because they
-can be deleted and reallocated by \type{UchSocket} class.
-?*/
-UchInetAddress :: UchInetAddress ()
-: UchAddress (),
- HostName (),
- HasHostName (false)
-{
-}
-
-/*?
-Construct an inet address, from a hostname and a port number.
-The address is valid only if the host is valid.
-If \var{host} is the empty string, the loopback host is used;
-if it is the nil pointer, the wildcard (INADDR_ANY) is used.
-If the port number is 0, it will be allocated by the system.
-?*/
-UchInetAddress :: UchInetAddress (const char* name, sword port)
-: UchAddress (),
- HostName (),
- HasHostName (false)
-{
- if (name && *name) {
- struct hostent *host = gethostbyname (name);
- if (! host)
- return;
- memcpy (&Addr.sin_addr, host->h_addr, host->h_length);
- } else
- Addr.sin_addr.s_addr = name ? INADDR_LOOPBACK : INADDR_ANY;
- Addr.sin_family = AF_INET;
- Addr.sin_port = htons (port);
- Valid = true;
-}
-
-/*?
-Construct an inet address, from a host id (internet address) and a port number.
-If the port number is 0, it is assigned by the system.
-The host ids \var{^{ANYADDR}}, \var{^{LOOPBACK}} and \var{^{BROADCAST}} are predefined.
-\var{ANYADDR} is used to receive messages from anywhere.
-\var{LOOPBACK} is the local host address.
-\var{BROADCAST} makes it possible to send data to all the hosts of a local area network.
-?*/
-UchInetAddress :: UchInetAddress (lword host, sword port)
-: UchAddress (),
- HostName (),
- HasHostName (false)
-{
- Addr.sin_family = AF_INET;
- Addr.sin_port = htons (port);
- Addr.sin_addr.s_addr = host;
- Valid = true;
-}
-
-/*?nodoc?*/
-UchInetAddress :: ~UchInetAddress ()
-{
-}
-
-/*?nodoc?*/
-int
-UchInetAddress :: Family ()
-{
- return AF_INET;
-}
-
-/*?nodoc?*/
-int
-UchInetAddress :: Length ()
-{
- return sizeof (Addr);
-}
-/*?nodoc?*/
-SockAddr*
-UchInetAddress :: GetSockAddr ()
-{
- return (SockAddr*) &Addr;
-}
/*?
-This is a global function (static member of class \typ{UchAddress}).
-It creates an object of a derived class of \typ{UchAddress} from a generic address
+This is a global function (static member of class \typ{IvlAddress}).
+It creates an object of a derived class of \typ{IvlAddress} from a generic address
(thus is cannot be replaced by a constructor).
A generic address is the following union of address structures
(it is typically returned by system calls like \fun{recvfrom}):
@@ -274,157 +113,29 @@ A generic address is the following union of address structures
typedef union {
struct sockaddr sa; // default
struct sockaddr_un su; // Unix
+ struct sockaddr_irda sir; // irda
struct sockaddr_in si; // inet
} GEN_ADDR;
\end{ccode}
?*/
-UchAddress*
-UchAddress :: Decode (GEN_ADDR* addr, int alen)
+IvlAddress*
+IvlAddress :: Decode (GEN_ADDR* addr, int alen)
{
switch (addr->sa.sa_family) {
#ifdef UNIX_SOCK
case AF_UNIX :
addr->su.sun_path [alen] = 0;
- return new UchUnixAddress (addr->su.sun_path);
+ return new IvlUnixAddress (addr->su.sun_path);
+#endif
+#ifdef IRDA_SOCK
+ case AF_IRDA :
+ return new IvlIrdaAddress (addr->sir.sir_name);
#endif
case AF_INET :
- return new UchInetAddress (addr->si.sin_addr.s_addr, addr->si.sin_port);
+ return new IvlInetAddress (addr->si.sin_addr.s_addr, addr->si.sin_port);
default :
return 0;
}
}
-/*?
-This is a global function (static member of class \typ{UchInetAddress}.
-It returns the internet address of the local host.
-This is different from the predefined address \var{LOOPBACK}:
-\var{LOOPBACK} is the same constant on each machine, so that it cannot
-be communicated across the network.
-The value returned by \fun{LoopBack} is the unique internet address of the local host.
-Thus it can be communicated to another host across the network.
-?*/
-lword
-UchInetAddress :: LoopBack ()
-{
- static lword loopback = 0;
-
- if (loopback)
- return loopback;
-
- struct hostent *host;
-
-#if 0
- char name [128];
- gethostname (name, sizeof (name));
- host = gethostbyname (name);
-#else
- struct utsname un;
- if (uname (&un) < 0) {
- Error (ErrFatal, "address", "cannot get name of local host");
- return 0;
- }
- host = gethostbyname (un.nodename);
-#endif
-
- if (! host) {
- Error (ErrFatal, "address", "cannot get address of local host");
- return 0;
- }
- return loopback = * ((lword *) host->h_addr);
-}
-
-#ifdef DOC
-// Ca c'est les super fake declarations pour avoir la DOC
-// merci au LRI...
-/*?
-Return the host number of the address.
-?*/
-lword
-UchInetAddress :: Host ()
-{}
-
-/*?
-Return the port number of the address.
-?*/
-sword
-UchInetAddress :: Port ()
-{}
-#endif /* DOC */
-
-
-/*?
-Return a const string representing the hostname part of the address if any
-or NULL if it does not exist (INADDR_ANY, INADDR_LOOPBACK or INADDR_BROADCAST).
-This is an interface to unix \fun{gethostbyaddr} system call.
-?*/
-const char*
-UchInetAddress :: GetHostName ()
-{
- struct hostent *host;
- unsigned long saddr;
-
- if (HasHostName)
- return HostName;
-
- saddr = Addr.sin_addr.s_addr;
- host = gethostbyaddr ((char*) &saddr, sizeof (long), AF_INET);
- if (host)
- HostName = host->h_name;
-#if 0
- } else
- HostName = GetNoHostName();
-#endif
- else {
- struct utsname un;
- if (uname (&un) < 0) {
- Error (ErrFatal, "GetHostName", "cannot get name of local host");
- HostName = 0;
- }
- HostName = un.nodename;
- }
- HasHostName = true;
- return HostName;
-}
-
-/*?nodoc?*/
-const char*
-UchInetAddress :: GetNoHostName ()
-{
- const char* hname;
- unsigned long saddr = Addr.sin_addr.s_addr;
- if (saddr == INADDR_ANY)
- hname = "ANY";
- else if (saddr == INADDR_LOOPBACK)
- hname = "LOOPBACK";
- else if (saddr == INADDR_BROADCAST)
- hname = "BROADCAST";
- else
- hname = "???";
- return hname;
-}
-
-/*?
-Return a newly allocated \typ{char*} pointing to a string representing
-the internet address as "hostname:port". If no host name can be found
-then it can be "ANY" (INADDR_ANY), "LOOPBACK" (INADDR_LOOPBACK), "BROADCAST"
-(INADDR_BROADCAST) or "???".
-If argument \var{buf} is not null, return it's value in buf and do not
-allocate any memory.
-?*/
-char*
-UchInetAddress :: StrRepr (char* buf)
-{
- const char* hname;
- if (HasHostName) {
- hname = HostName;
- if (!hname)
- hname = GetNoHostName ();
- } else
- hname = GetHostName ();
- if (! buf)
- buf = new char [ strlen(hname) + 2 + 7 ];
- sprintf (buf, "%s::%d",hname, ntohs (Addr.sin_port));
- return buf;
-}
-
diff --git a/comm/Address.h b/comm/Address.h
index d0e083d..7ca302a 100644
--- a/comm/Address.h
+++ b/comm/Address.h
@@ -10,47 +10,56 @@
*
* $Id$
* $CurLog$
+ * Removed smart pointers (S.Sire)
+ * Changed IvlInetAddress::StrRepr and added GetHostname and GetNoHostname
*/
#ifndef Address_H_
#define Address_H_
#include "cplus_bugs.h"
-#include "ccu/bool.h"
-#include "ccu/word.h"
-#include "ccu/String.h"
+#include "ivl/bool.h"
+#include "ivl/word.h"
+#include "ivl/String.h"
#include <sys/types.h>
#include <sys/socket.h>
-#include <netinet/in.h>
+typedef struct sockaddr SockAddr;
+
+/***** all this is necessary for function Decode only. This should be investigated */
+#include <netinet/in.h>
#ifdef UNIX_SOCK
#include <sys/un.h>
-#endif
-
#ifndef AF_UNIX
#define AF_UNIX AF_UNSPEC
#endif
+#endif
+#ifdef IRDA_SOCK
+#include <linux/irda.h>
+#endif
union gen_addr {
struct sockaddr sa; // default
#ifdef UNIX_SOCK
struct sockaddr_un su; // unix
#endif
+#ifdef IRDA_SOCK
+ struct sockaddr_irda sir; // irda
+#endif
struct sockaddr_in si; // inet
};
+/***** end of part that is necessary for Decode only */
-typedef struct sockaddr SockAddr;
-/* this union is useful for adresses returned by system calls */
-typedef union gen_addr GEN_ADDR;
+typedef union gen_addr GEN_ADDR; /* useful for adresses returned by system calls */
-class UchAddress {
+class IvlAddress {
protected:
bool Valid;
public:
- UchAddress ();
-virtual ~UchAddress ();
+ IvlAddress ();
+virtual ~IvlAddress ();
bool IsValid () const { return Valid; }
virtual int Family () = 0; // AF_UNSPEC, AF_UNIX, AF_INET
@@ -58,61 +67,7 @@ virtual int Length () = 0;
virtual SockAddr* GetSockAddr () = 0;
virtual char* StrRepr (char* buf) = 0;
-static UchAddress* Decode (GEN_ADDR*, int);
-};
-
-class UchInetAddress : public UchAddress {
-protected:
- CcuString HostName;
- bool HasHostName;
- struct sockaddr_in Addr;
-
- const char* GetNoHostName ();
-
-public:
- UchInetAddress ();
- UchInetAddress (lword, sword); // hostid, port#
- UchInetAddress (const char*, sword = 0); // hostname, port#
- ~UchInetAddress ();
-
- int Family ();
- int Length ();
- SockAddr* GetSockAddr ();
-inline sword Port () { return Addr.sin_port; }
-inline lword Host () { return Addr.sin_addr.s_addr; }
- char* StrRepr (char* buf = 0);
- const char* GetHostName ();
-
-static lword LoopBack ();
-};
-
-#ifndef INADDR_LOOPBACK
-#define INADDR_LOOPBACK (INET_ADDR::LoopBack ())
-#endif
-
-#define ANYADDR ((lword) INADDR_ANY)
-#define LOOPBACK ((lword) INADDR_LOOPBACK)
-#define BROADCAST ((lword) INADDR_BROADCAST)
-
-
-#ifdef UNIX_SOCK
-
-class UchUnixAddress : public UchAddress {
-protected:
- struct sockaddr_un Addr;
-
-public:
- UchUnixAddress ();
- UchUnixAddress (const char*);
- ~UchUnixAddress ();
-
- int Family ();
- int Length ();
- SockAddr* GetSockAddr ();
- char* StrRepr (char* buf);
+static IvlAddress* Decode (GEN_ADDR*, int);
};
-#endif /* UNIX_ADDR */
-
-
#endif /* Address_H_ */
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);
}
-
diff --git a/comm/BufStream.h b/comm/BufStream.h
index a221bfa..dc2511e 100644
--- a/comm/BufStream.h
+++ b/comm/BufStream.h
@@ -10,6 +10,7 @@
*
* $Id$
* $CurLog$
+ * Created from bits of MsgStream.h
*/
#ifndef BufStream_H_
@@ -18,14 +19,14 @@
#include "Stream.h"
#include "MsgBuffer.h"
-class UchBufStream : public UchStream {
+class IvlBufStream : public IvlStream {
protected:
- UchMsgBuffer InBuffer;
- UchMsgBuffer OutBuffer;
+ IvlMsgBuffer InBuffer;
+ IvlMsgBuffer OutBuffer;
int OutSize;
bool Sync;
- UchBufStream (const UchBufStream&);
+ IvlBufStream (const IvlBufStream&);
int ReadInput ();
void HandleWrite ();
@@ -42,12 +43,12 @@ protected:
bool ReadByte (byte&);
bool ReadChar (char&);
int ReadString (char*, int);
- int ReadString (CcuString&);
+ int ReadString (IvlString&);
bool ReadBuf (byte*, int);
public:
- UchBufStream (UchAddress* = 0, UchAddress* = 0);
- ~UchBufStream ();
+ IvlBufStream (IvlAddress* = 0, IvlAddress* = 0);
+ ~IvlBufStream ();
void InputBuffer (int min, int grow, int max);
void OutputBuffer (int min, int grow, int max);
diff --git a/comm/BusAccess.cc b/comm/BusAccess.cc
index 5383e91..3f9605a 100644
--- a/comm/BusAccess.cc
+++ b/comm/BusAccess.cc
@@ -10,15 +10,17 @@
*
* $Id$
* $CurLog$
+ * Now handle Die
*/
#include "BusAccess.h"
-#include "Multiplexer.h"
+#include "Scheduler.h"
#include "BufStream.h"
-#include "ccu/String.h"
-#include "dnn/Trigger.h"
-#include "dnn/Reaction.h"
-#include "ccu/Signal.h"
+#include "InetAddress.h"
+#include "ivl/String.h"
+#include "ivl/Trigger.h"
+#include "ivl/Reaction.h"
+#include "ivl/Signal.h"
#include <stdlib.h>
#include <stdio.h>
#include <ostream.h>
@@ -26,10 +28,10 @@
#include <stdarg.h>
#include <ctype.h>
-int UchBusAccess::Version = 3;
-const char* const UchBusAccess::DefaultBus = "127:2010";
-const sword UchBusAccess::DefaultBusPort = 2010;
-const char* const UchBusAccess::DefaultBusNet = "127";
+int IvlBusAccess::Version = 3;
+const char* const IvlBusAccess::DefaultBus = "127:2010";
+const sword IvlBusAccess::DefaultBusPort = 2010;
+const char* const IvlBusAccess::DefaultBusNet = "127";
static int _BusDebug = 0;
@@ -48,49 +50,46 @@ typedef enum {
BusDie
} BusMsgType;
-
-
-
-class UchBusSubscription {
+class IvlBusSubscription {
protected:
int Id;
- CcuString Regexp;
+ IvlString Regexp;
regex_t Compiled;
public:
- UchBusSubscription (int, const char*);
+ IvlBusSubscription (int, const char*);
inline int GetId () const { return Id; }
inline const char* GetRegexp () const { return Regexp; }
inline const regex_t* GetCompiled () const { return &Compiled; }
};
-class UchBusTrigger : public DnnTrigger {
+class IvlBusTrigger : public IvlTrigger {
protected:
int Id;
- CcuString Regexp;
+ IvlString Regexp;
public:
- UchBusTrigger (const char*);
+ IvlBusTrigger (const char*);
inline int GetId () const { return Id; }
inline void SetId (int id) { Id = id; }
inline const char* GetRegexp () const { return Regexp; }
};
-class UchBusServer : public UchStream {
+class IvlBusServer : public IvlStream {
public:
- UchBusAccess* MyBus;
+ IvlBusAccess* MyBus;
- UchBusServer (UchBusAccess*);
+ IvlBusServer (IvlBusAccess*);
void HandleRead ();
};
/* this is used for local subscriptions */
-UchBusTrigger :: UchBusTrigger (const char* r)
+IvlBusTrigger :: IvlBusTrigger (const char* r)
: Id (-1),
Regexp (r)
{
}
/* this is used for remote subscriptions */
-UchBusSubscription :: UchBusSubscription (int id, const char* r)
+IvlBusSubscription :: IvlBusSubscription (int id, const char* r)
: Id (id),
Regexp (r)
{
@@ -99,8 +98,8 @@ UchBusSubscription :: UchBusSubscription (int id, const char* r)
cerr << "bad regexp " << r << "\n";
}
-UchBusServer :: UchBusServer (UchBusAccess* bus)
-: UchStream (new UchInetAddress (ANYADDR)),
+IvlBusServer :: IvlBusServer (IvlBusAccess* bus)
+: IvlStream (new IvlInetAddress (ANYADDR)),
MyBus (bus)
{
if (Listen () < 0) {
@@ -108,12 +107,12 @@ UchBusServer :: UchBusServer (UchBusAccess* bus)
return;
}
SetMode (IORead);
- Add (UchMpx);
+ Add (IvlScd);
}
/* this happens when another agent opens a connection with us */
void
-UchBusServer :: HandleRead ()
+IvlBusServer :: HandleRead ()
{
/* Accept connection */
int fd = Accept ();
@@ -125,28 +124,27 @@ UchBusServer :: HandleRead ()
/* create agent handle */
if (_BusDebug)
cout << "Someone was there. Hello!\n";
- UchBusAgent* a = new UchBusAgent (fd, MyBus);
+ IvlBusAgent* a = new IvlBusAgent (fd, MyBus);
/* send name and subscriptions */
a->SayHello ();
}
-UchBusAgent :: UchBusAgent (int fd, UchBusAccess* bus)
-: UchBufStream (),
+IvlBusAgent :: IvlBusAgent (int fd, IvlBusAccess* bus)
+: IvlBufStream (),
RemoteSubscriptions (),
MyBus (bus),
DirectMsg (16)
{
// SetMode (IOReadWrite);
SetMode (IORead);
- UchChannel::Open (fd);
- Add (UchMpx);
+ IvlChannel::Open (fd);
+ Add (IvlScd);
MyBus->Agents.Append (this);
}
-
-UchBusAgent :: UchBusAgent (const char* host, sword port, UchBusAccess *bus)
-: UchBufStream (0, new UchInetAddress (host, port)),
+IvlBusAgent :: IvlBusAgent (const char* host, sword port, IvlBusAccess *bus)
+: IvlBufStream (0, new IvlInetAddress (host, port)),
RemoteSubscriptions (),
MyBus (bus),
DirectMsg (16)
@@ -156,32 +154,30 @@ UchBusAgent :: UchBusAgent (const char* host, sword port, UchBusAccess *bus)
return;
}
SetMode (IORead);
- Add (UchMpx);
+ Add (IvlScd);
MyBus->Agents.Append (this);
}
-
-UchBusAgent :: ~UchBusAgent ()
+IvlBusAgent :: ~IvlBusAgent ()
{
MyBus->Agents.Remove (this);
Remove ();
Close ();
}
-
-/* this had to be redefined because UchChannel adds null character
+/* this had to be redefined because IvlChannel adds null character
and we don't want it */
void
-UchBusAgent :: WriteString (const char* s)
+IvlBusAgent :: WriteString (const char* s)
{
/* now that this is a BufStream, perhaps we should use Buffer? */
Write ((byte*) s, strlen (s));
}
void
-UchBusAgent :: SayHello ()
+IvlBusAgent :: SayHello ()
{
- CcuSignalBlocker b (SigPipe);
+ IvlSignalBlocker b (SigPipe);
char buf[32];
/* Say hello */
@@ -192,7 +188,7 @@ UchBusAgent :: SayHello ()
if (_BusDebug)
cout << "sending subscriptions\n";
- CcuListIterOf<UchBusTrigger> s = MyBus->LocalSubscriptions;
+ IvlListIterOf<IvlBusTrigger> s = MyBus->LocalSubscriptions;
while (++s)
SendLocalSubscription (*s);
@@ -202,7 +198,7 @@ UchBusAgent :: SayHello ()
}
void
-UchBusAgent :: SendLocalSubscription (const UchBusTrigger* s)
+IvlBusAgent :: SendLocalSubscription (const IvlBusTrigger* s)
{
char buf[32];
sprintf (buf, "%d %d%c", BusRegexp, s->GetId (), STX);
@@ -214,9 +210,9 @@ UchBusAgent :: SendLocalSubscription (const UchBusTrigger* s)
}
void
-UchBusAgent :: SayBye ()
+IvlBusAgent :: SayBye ()
{
- CcuSignalBlocker b (SigPipe);
+ IvlSignalBlocker b (SigPipe);
char buf[32];
/* Say bye */
@@ -224,10 +220,9 @@ UchBusAgent :: SayBye ()
WriteString (buf);
}
-
-/* this happens when another agent talks */
+/* this happens when another agent talks to us */
void
-UchBusAgent :: HandleRead ()
+IvlBusAgent :: HandleRead ()
{
/* read in buffer */
if (InBuffer.BufLength () == 0)
@@ -260,13 +255,13 @@ UchBusAgent :: HandleRead ()
static int id = 0;
static int
-has_id (UchBusSubscription* s)
+has_id (IvlBusSubscription* s)
{
return (s->GetId () == id);
}
void
-UchBusAgent :: ProcessLine (const char* line)
+IvlBusAgent :: ProcessLine (const char* line)
{
/* message structure is:
Bye: "0 0\002"
@@ -288,19 +283,19 @@ UchBusAgent :: ProcessLine (const char* line)
}
const char* p = (const char*) (line+nb_chars);
- DnnEvent* ev;
+ IvlEvent* ev;
switch (msg_type) {
case BusBye:
if (_BusDebug)
cout << "[bye " << Name << "]\n";
- ev = new UchAgentEvent (this, UchAgentEvent::BusAgentBye);
+ ev = new IvlAgentEvent (this, IvlAgentEvent::BusAgentBye);
Bye.Dispatch (*ev);
delete this;
break;
case BusRegexp:
if (_BusDebug)
cout << "[regexp " << Name << " " << p+1 << "]\n";
- RemoteSubscriptions.Append (new UchBusSubscription (id, p+1));
+ RemoteSubscriptions.Append (new IvlBusSubscription (id, p+1));
break;
case BusMsg:
if (_BusDebug)
@@ -316,15 +311,15 @@ UchBusAgent :: ProcessLine (const char* line)
case BusReady:
if (_BusDebug)
cout << "[ready " << Name << "]\n";
- ev = new UchAgentEvent (this, UchAgentEvent::BusNewAgent);
+ ev = new IvlAgentEvent (this, IvlAgentEvent::BusNewAgent);
MyBus->NewAgents.Dispatch (*ev);
break;
case BusDirectMsg:
{
if (_BusDebug)
cout << "[direct " << Name << id << " " << p+1 << "]\n";
- ev = new UchDirectEvent (this, p+1);
- DnnTrigger* t = DirectMsg[id];
+ ev = new IvlDirectEvent (this, p+1);
+ IvlTrigger* t = DirectMsg[id];
t->Dispatch (*ev);
break;
}
@@ -348,16 +343,16 @@ UchBusAgent :: ProcessLine (const char* line)
}
void
-UchBusAgent :: EmitEvent (const char* msg)
+IvlBusAgent :: EmitEvent (const char* msg)
{
- CcuSignalBlocker b (SigPipe);
+ IvlSignalBlocker b (SigPipe);
const int MAX_MATCHING_ARGS = 20;
regmatch_t pmatch[MAX_MATCHING_ARGS+1];
/* scan all subscriptions from this agent */
- CcuListIterOf<UchBusSubscription> r = RemoteSubscriptions;
+ IvlListIterOf<IvlBusSubscription> r = RemoteSubscriptions;
while (++r) {
- UchBusSubscription* s = *r;
+ IvlBusSubscription* s = *r;
/* does the message match the regexp? */
if (regexec (s->GetCompiled (), msg, MAX_MATCHING_ARGS, pmatch, 0) != 0)
continue;
@@ -392,7 +387,7 @@ UchBusAgent :: EmitEvent (const char* msg)
/* emit direct message */
void
-UchBusAgent :: Emit (int id, const char* fmt, ...)
+IvlBusAgent :: Emit (int id, const char* fmt, ...)
{
/* build message */
char message[4096];
@@ -403,7 +398,7 @@ UchBusAgent :: Emit (int id, const char* fmt, ...)
va_end (ap );
/* send it */
- CcuSignalBlocker b (SigPipe);
+ IvlSignalBlocker b (SigPipe);
char buf[32];
sprintf (buf, "%d %d%c", BusDirectMsg, id, STX);
WriteString (buf);
@@ -411,9 +406,9 @@ UchBusAgent :: Emit (int id, const char* fmt, ...)
WriteString ("\n");
}
-UchBusAccess :: UchBusAccess (const char* name, const char* bus)
-: UchDatagram (),
- UchBaseSignalHandler (*UchMpx, SigInt),
+IvlBusAccess :: IvlBusAccess (const char* name, const char* bus)
+: IvlDatagram (),
+ IvlBaseScheduledHandler (*IvlScd, SigInt),
Name (name),
ListenPort (0),
BroadcastPort (0),
@@ -423,7 +418,6 @@ UchBusAccess :: UchBusAccess (const char* name, const char* bus)
LocalSubscriptions ()
{
-
/** determine network list as well as broadcast port **/
/* (we accept addresses such as 123.231,123.123:2000 or 123.231 or :2000) */
@@ -441,9 +435,8 @@ UchBusAccess :: UchBusAccess (const char* name, const char* bus)
else
BroadcastPort = DefaultBusPort;
-
/** set up UDP broadcast socket **/
- UchInetAddress* a = new UchInetAddress (ANYADDR, BroadcastPort);
+ IvlInetAddress* a = new IvlInetAddress (ANYADDR, BroadcastPort);
BindTo (a);
if (!Open ()) {
perror ("Cannot open socket: ");
@@ -466,8 +459,8 @@ UchBusAccess :: UchBusAccess (const char* name, const char* bus)
SetMode (IORead);
/** set up stream **/
- Server = new UchBusServer (this);
- a = dynamic_cast<UchInetAddress*>(Server->BoundTo ());
+ Server = new IvlBusServer (this);
+ a = dynamic_cast<IvlInetAddress*>(Server->BoundTo ());
if (!a) {
cerr << "bad address type?!\n";
return;
@@ -511,7 +504,7 @@ UchBusAccess :: UchBusAccess (const char* name, const char* bus)
/* addresses are terminated by a comma or end of string */
} else {
printf ("Broadcasting on network %lx, port %d\n", mask, BroadcastPort);
- UchInetAddress ba (mask, BroadcastPort);
+ IvlInetAddress ba (mask, BroadcastPort);
Send ((byte*)handshake, strlen (handshake), ba);
numelem = 0;
mask = 0xffffffff;
@@ -543,29 +536,29 @@ UchBusAccess :: UchBusAccess (const char* name, const char* bus)
}
/* add to main loop */
- Add (UchMpx);
+ Add (IvlScd);
}
void
-UchBusAccess :: Clear ()
+IvlBusAccess :: Clear ()
{
/* say bye to all remote agents, remove and delete them */
- UchBusAgent* a;
+ IvlBusAgent* a;
while (a = Agents.RemoveFirst ()) {
a->SayBye ();
delete a;
}
}
-UchBusAccess :: ~UchBusAccess ()
+IvlBusAccess :: ~IvlBusAccess ()
{
}
/* this happens when someone sends a broadcast on the bus: a newcomer */
void
-UchBusAccess :: HandleRead ()
+IvlBusAccess :: HandleRead ()
{
/* read data */
byte buf [256];
@@ -585,7 +578,7 @@ UchBusAccess :: HandleRead ()
}
/* where did this come from? */
- UchInetAddress* a = dynamic_cast<UchInetAddress*> (From ());
+ IvlInetAddress* a = dynamic_cast<IvlInetAddress*> (From ());
if (!a) {
cerr << "bad address!?\n";
return;
@@ -605,17 +598,16 @@ UchBusAccess :: HandleRead ()
printf ("Arrivee de %s:%hu port %hu\n", remote_host, remote_port, remote_listen_port );
/* Create agent handle */
- UchBusAgent* ag = new UchBusAgent (remote_host, remote_listen_port, this);
+ IvlBusAgent* ag = new IvlBusAgent (remote_host, remote_listen_port, this);
/* send name and subscriptions */
ag->SayHello ();
}
-
void
-UchBusAccess :: HandleEvent (int id, const char* msg)
+IvlBusAccess :: HandleEvent (int id, const char* msg)
{
- UchBusTrigger* s = IdToSubscription.Get (id);
+ IvlBusTrigger* s = IdToSubscription.Get (id);
if (!s) {
cerr << "bad regexp id " << id << "\n";
return;
@@ -623,23 +615,23 @@ UchBusAccess :: HandleEvent (int id, const char* msg)
if (_BusDebug)
cout << "REGEXP " << s->GetId () << " MATCHED: " << msg << "\n";
- UchBusEvent* ev = new UchBusEvent (s->GetRegexp (), msg);
+ IvlBusEvent* ev = new IvlBusEvent (s->GetRegexp (), msg);
s->Dispatch (*ev);
}
/* this is the handler for SIGINT */
void
-UchBusAccess :: DeferredHandle (int)
+IvlBusAccess :: DeferredHandle (int)
{
cerr << "quitting\n";
Clear ();
- UchStop ();
+ IvlStop ();
}
bool
-UchBusAccess :: CheckUnicity (UchBusAgent* a, sword id)
+IvlBusAccess :: CheckUnicity (IvlBusAgent* a, sword id)
{
- CcuListIterOf<UchBusAgent> li = Agents;
+ IvlListIterOf<IvlBusAgent> li = Agents;
while (++li) {
if ((*li)->RemoteId == id && a != (*li))
return false;
@@ -648,7 +640,7 @@ UchBusAccess :: CheckUnicity (UchBusAgent* a, sword id)
}
void
-UchBusAccess :: Subscribe (DnnBaseReaction& r, const char* fmt, ...)
+IvlBusAccess :: Subscribe (IvlBaseReaction& r, const char* fmt, ...)
{
/* build regexp */
char regexp[4096];
@@ -659,13 +651,13 @@ UchBusAccess :: Subscribe (DnnBaseReaction& r, const char* fmt, ...)
va_end (ap );
/* store new subscription */
- UchBusTrigger* s = new UchBusTrigger (regexp);
+ IvlBusTrigger* s = new IvlBusTrigger (regexp);
LocalSubscriptions.Append (s);
int id = IdToSubscription.Store (s);
s->SetId (id);
/* emit to current remote agents */
- CcuListIterOf<UchBusAgent> a = Agents;
+ IvlListIterOf<IvlBusAgent> a = Agents;
while (++a)
(*a)->SendLocalSubscription (s);
@@ -673,9 +665,8 @@ UchBusAccess :: Subscribe (DnnBaseReaction& r, const char* fmt, ...)
r.SubscribeTo (*s);
}
-
void
-UchBusAccess :: Emit (const char* fmt, ...)
+IvlBusAccess :: Emit (const char* fmt, ...)
{
/* build message */
char message[4096];
@@ -685,17 +676,17 @@ UchBusAccess :: Emit (const char* fmt, ...)
vsprintf (message, fmt, ap);
va_end (ap );
- CcuListIterOf <UchBusAgent> a = Agents;
+ IvlListIterOf <IvlBusAgent> a = Agents;
while (++a)
(*a)->EmitEvent (message);
}
-DnnEventType* UchAgentEvent::BusNewAgent = new DnnEventType ("new agent", 0, 0);
-DnnEventType* UchAgentEvent::BusAgentBye = new DnnEventType ("agent bye", 0, 0);
+IvlEventType* IvlAgentEvent::BusNewAgent = new IvlEventType ("new agent", 0, 0);
+IvlEventType* IvlAgentEvent::BusAgentBye = new IvlEventType ("agent bye", 0, 0);
-UchBusEvent :: UchBusEvent (const char* r, const char* m)
-: DnnEvent (),
+IvlBusEvent :: IvlBusEvent (const char* r, const char* m)
+: IvlEvent (),
Regexp (r),
NbMatches (0),
Matches (m),
@@ -714,7 +705,7 @@ UchBusEvent :: UchBusEvent (const char* r, const char* m)
case ETX:
NbMatches++;
*q = '\0';
- MatchList.Append (new CcuString (p));
+ MatchList.Append (new IvlString (p));
p = q + 1;
/* fall through */
default:
@@ -723,34 +714,32 @@ UchBusEvent :: UchBusEvent (const char* r, const char* m)
}
}
-
-UchBusEvent :: ~UchBusEvent ()
+IvlBusEvent :: ~IvlBusEvent ()
{
- CcuListIterOf<CcuString> li = MatchList;
+ IvlListIterOf<IvlString> li = MatchList;
while (++li)
delete (*li);
}
-UchAgentEvent :: UchAgentEvent (UchBusAgent* a, DnnEventType* t)
-: DnnEvent (t),
+IvlAgentEvent :: IvlAgentEvent (IvlBusAgent* a, IvlEventType* t)
+: IvlEvent (t),
Agent (a)
{
}
-
-UchAgentEvent :: ~UchAgentEvent ()
+IvlAgentEvent :: ~IvlAgentEvent ()
{
}
-UchDirectEvent :: UchDirectEvent (UchBusAgent* a, const char* m)
-: DnnEvent (),
+IvlDirectEvent :: IvlDirectEvent (IvlBusAgent* a, const char* m)
+: IvlEvent (),
Agent (a),
Msg (m)
{
}
-UchDirectEvent::~UchDirectEvent ()
+IvlDirectEvent::~IvlDirectEvent ()
{
}
diff --git a/comm/BusAccess.h b/comm/BusAccess.h
index 4c18d5c..3d45db8 100644
--- a/comm/BusAccess.h
+++ b/comm/BusAccess.h
@@ -12,7 +12,6 @@
* $CurLog$
*/
-
#ifndef BusAccess_H_
#define BusAccess_H_
@@ -20,119 +19,112 @@
#include "Stream.h"
#include "BufStream.h"
#include "SignalHandler.h"
-#include "ccu/List.h"
-#include "ccu/IdTable.h"
-#include "ccu/String.h"
-#include "ccu/HashTable.h"
-#include "dnn/Event.h"
-#include "dnn/Trigger.h"
-
+#include "ivl/List.h"
+#include "ivl/IdTable.h"
+#include "ivl/String.h"
+#include "ivl/HashTable.h"
+#include "ivl/Event.h"
+#include "ivl/Trigger.h"
-class UchBusSubscription;
-class UchBusTrigger;
-class DnnBaseReaction;
+class IvlBusSubscription;
+class IvlBusTrigger;
+class IvlBaseReaction;
-class UchBusAccess : public UchDatagram, public UchBaseSignalHandler {
-friend class UchBusAgent;
+class IvlBusAccess : public IvlDatagram, public IvlBaseScheduledHandler {
+friend class IvlBusAgent;
protected:
static int Version;
static const char* const DefaultBus;
static const char* const DefaultBusNet;
static sword const DefaultBusPort;
- CcuString Name;
+ IvlString Name;
sword ListenPort;
sword BroadcastPort;
- UchStream* Server;
- CcuListOf<UchBusAgent> Agents;
- CcuListOf<UchBusTrigger> LocalSubscriptions;
- CcuIdTableOf<UchBusTrigger> IdToSubscription;
+ IvlStream* Server;
+ IvlListOf<IvlBusAgent> Agents;
+ IvlListOf<IvlBusTrigger> LocalSubscriptions;
+ IvlIdTableOf<IvlBusTrigger> IdToSubscription;
void HandleRead ();
void Clear ();
void DeferredHandle (int);
void HandleEvent (int, const char*);
- bool CheckUnicity (UchBusAgent*, sword);
+ bool CheckUnicity (IvlBusAgent*, sword);
public:
- DnnTrigger NewAgents;
+ IvlTrigger NewAgents;
- UchBusAccess (const char*, const char* = 0);
- ~UchBusAccess ();
- void Subscribe (DnnBaseReaction&, const char*, ...);
+ IvlBusAccess (const char*, const char* = 0);
+ ~IvlBusAccess ();
+ void Subscribe (IvlBaseReaction&, const char*, ...);
void Emit (const char*, ...);
};
-
-class UchBusAgent : public UchBufStream {
-friend class UchBusAccess;
-friend class UchBusServer;
+class IvlBusAgent : public IvlBufStream {
+friend class IvlBusAccess;
+friend class IvlBusServer;
protected:
- CcuListOf<UchBusSubscription> RemoteSubscriptions;
+ IvlListOf<IvlBusSubscription> RemoteSubscriptions;
sword RemoteId;
- UchBusAccess* MyBus;
- CcuString Name;
+ IvlBusAccess* MyBus;
+ IvlString Name;
void WriteString (const char*);
void ProcessLine (const char*);
- UchBusAgent (int, UchBusAccess*);
- UchBusAgent (const char*, sword, UchBusAccess*);
- ~UchBusAgent ();
+ IvlBusAgent (int, IvlBusAccess*);
+ IvlBusAgent (const char*, sword, IvlBusAccess*);
+ ~IvlBusAgent ();
void HandleRead ();
- void SendLocalSubscription (const UchBusTrigger*);
+ void SendLocalSubscription (const IvlBusTrigger*);
void SayHello ();
void SayBye ();
void EmitEvent (const char*);
public:
- DnnTrigger Bye;
- CcuHashedArrayOf<DnnTrigger> DirectMsg;
+ IvlTrigger Bye;
+ IvlHashedArrayOf<IvlTrigger> DirectMsg;
void Emit (int, const char*, ...);
inline const char* GetName () const { return Name; }
};
-class UchAgentEvent : public DnnEvent {
+class IvlAgentEvent : public IvlEvent {
public:
-static DnnEventType* BusNewAgent, *BusAgentBye;
+static IvlEventType* BusNewAgent, *BusAgentBye;
protected:
- UchBusAgent* Agent;
+ IvlBusAgent* Agent;
public:
- UchAgentEvent (UchBusAgent*, DnnEventType*);
- ~UchAgentEvent ();
-
+ IvlAgentEvent (IvlBusAgent*, IvlEventType*);
+ ~IvlAgentEvent ();
-inline UchBusAgent* GetAgent () const { return Agent;}
+inline IvlBusAgent* GetAgent () const { return Agent;}
};
-
-class UchDirectEvent : public DnnEvent {
+class IvlDirectEvent : public IvlEvent {
public:
- UchBusAgent* Agent;
- CcuString Msg;
+ IvlBusAgent* Agent;
+ IvlString Msg;
public:
- UchDirectEvent (UchBusAgent*, const char*);
- ~UchDirectEvent ();
+ IvlDirectEvent (IvlBusAgent*, const char*);
+ ~IvlDirectEvent ();
};
-
-
-class UchBusEvent : public DnnEvent {
+class IvlBusEvent : public IvlEvent {
public:
- CcuString Regexp;
+ IvlString Regexp;
int NbMatches;
- CcuListOf<CcuString> MatchList;
- CcuString Matches;
+ IvlListOf<IvlString> MatchList;
+ IvlString Matches;
- UchBusEvent (const char*, const char*);
- ~UchBusEvent ();
+ IvlBusEvent (const char*, const char*);
+ ~IvlBusEvent ();
};
-
#endif /* BusAccess_H_ */
diff --git a/comm/Channel.cc b/comm/Channel.cc
index 75a6a33..f396a40 100644
--- a/comm/Channel.cc
+++ b/comm/Channel.cc
@@ -10,16 +10,18 @@
*
* $Id$
* $CurLog$
+ * Smart(ies) removed by Stephane Sire
+ * Removed ReadHandler and WriteHandler
*/
#ifdef __GNUG__
#pragma implementation "Channel.h"
#endif
#include "Channel.h"
-#include "Multiplexer.h"
+#include "Scheduler.h"
#include "MsgBuffer.h"
#include "error.h"
-#include "ccu/String.h"
+#include "ivl/String.h"
#include <stdlib.h>
#include <stdio.h>
@@ -35,7 +37,7 @@ static int Inited = 0;
/*?nodoc?*/
void
-UchFilDes :: Use (int fd)
+IvlFilDes :: Use (int fd)
{
if (fd < 0)
return;
@@ -50,7 +52,7 @@ UchFilDes :: Use (int fd)
/*?nodoc?*/
void
-UchFilDes :: Unuse (int fd)
+IvlFilDes :: Unuse (int fd)
{
if (fd < 0)
return;
@@ -60,20 +62,20 @@ UchFilDes :: Unuse (int fd)
/*?nodoc?*/
char*
-UchFilDes :: StrRepr (char* buf)
+IvlFilDes :: StrRepr (char* buf)
{
sprintf (buf, "%d", Fd);
return buf;
}
-/*?class UchFilDes
+/*?class IvlFilDes
This class implements objects representing Unix file descriptors.
-When the associated file descriptor is -1, the \typ{UchFilDes} is said to be closed,
+When the associated file descriptor is -1, the \typ{IvlFilDes} is said to be closed,
else it is said to be opened.
Because several objects of this class can refer to the same file descriptor,
the destructor closes the file descriptor only if it is the last object referring to this file descriptor.
This is implemented with the help of a reference count, the overloading of \fun{operator =}
-and the definition of the constructor \fun{UchFilDes(const UchFilDes\&)}.
+and the definition of the constructor \fun{IvlFilDes(const IvlFilDes\&)}.
All member functions described here are inline for maximum efficiency.
?*/
@@ -82,30 +84,30 @@ All member functions described here are inline for maximum efficiency.
/*?
Construct a closed file descriptor.
?*/
-UchFilDes :: UchFilDes ()
+IvlFilDes :: IvlFilDes ()
{ }
/*?
Construct an open file descriptor for the Unix file descriptor \var{fd}.
-In particular, this makes it possible to pass an integer where a \typ{UchFilDes} is normally expected.
+In particular, this makes it possible to pass an integer where a \typ{IvlFilDes} is normally expected.
This is most useful when using Unix file descriptors.
?*/
-UchFilDes :: UchFilDes (int fd)
+IvlFilDes :: IvlFilDes (int fd)
{ }
/*?
-This conversion operator makes it possible to pass a \typ{UchFilDes} argument where
+This conversion operator makes it possible to pass a \typ{IvlFilDes} argument where
an integer is expected. This is most useful for system calls.
?*/
int
-UchFilDes :: operator int ()
+IvlFilDes :: operator int ()
{ }
/*?
Return the Unix file descriptor, or -1 if it is closed.
?*/
int
-UchFilDes :: FilDes ()
+IvlFilDes :: FilDes ()
{ }
/*?
@@ -113,7 +115,7 @@ Open the object on file descriptor \var{fd}.
If it was already opened, it is closed first.
?*/
void
-UchFilDes :: Open (int fd)
+IvlFilDes :: Open (int fd)
{ }
/*?
@@ -122,14 +124,14 @@ only if it was the last reference to it.
\fun{Close} is automatically called by the destructor.
?*/
void
-UchFilDes :: Close ()
+IvlFilDes :: Close ()
{ }
/*?
Return true if the object is opened, false else.
?*/
bool
-UchFilDes :: Opened ()
+IvlFilDes :: Opened ()
{ }
/*?
@@ -138,7 +140,7 @@ This is the Unix \fun{read} system call.
For efficiency, this function does not test whether the file descriptor is opened.
?*/
int
-UchFilDes :: Read (byte* b, int n)
+IvlFilDes :: Read (byte* b, int n)
{ }
/*?
@@ -147,29 +149,29 @@ This is the Unix \fun{write} system call.
For efficiency, this function does not test whether the file descriptor is opened.
?*/
int
-UchFilDes :: Write (byte* b, int n)
+IvlFilDes :: Write (byte* b, int n)
{ }
#endif /* DOC */
-/*?class UchChannel
-A \typ{UchChannel} is basically a file descriptor, with more strict semantics than a \typ{UchFilDes}.
+/*?class IvlChannel
+A \typ{IvlChannel} is basically a file descriptor, with more strict semantics than a \typ{IvlFilDes}.
A channel is immutable: once initialized, it cannot change its file descriptor.
It has a mode, of type \typ{^{IOMODE}}, with possible values
\var{IONone}, \var{IORead}, \var{IOWrite}, \var{IOReadWrite},
\var{IOSelect}, \var{IOReadSelect}, \var{IOWriteSelect}, \var{IOAll}.
\index{IOMODE :: IONone}\index{IOMODE :: IORead}\index{IOMODE :: IOWrite}\index{IOMODE :: IOReadWrite}\index{IOMODE :: IOSelect}\index{IOMODE :: IOReadSelect}\index{IOMODE :: IOWriteSelect}\index{IOMODE :: IOAll}
-Before being initialized, a UchChannel.has mode \var{IONone} and is said to be closed.
+Before being initialized, a IvlChannel.has mode \var{IONone} and is said to be closed.
-A UchChannel.has a number of virtual functions.
+A IvlChannel.has a number of virtual functions.
The destructor is virtual; this is useful for classes that store pointers to objects
-of a class derived from \typ{UchChannel} (like in the class \typ{UchSocket}).
+of a class derived from \typ{IvlChannel} (like in the class \typ{IvlSocket}).
The functions \fun{HandleSelect}, \fun{HandleRead} and \fun{HandleWrite}
are intended to give a channel the ability to automatically handle input/output,
for instance for use with the \fun{select} system call.
-Such capabilities are used and thus illustrated in class \typ{UchMultiplexer}.
+Such capabilities are used and thus illustrated in class \typ{IvlScheduler}.
-A \typ{UchChannel} can be associated with only one \typ{UchBaseMultiplexer}
+A \typ{IvlChannel} can be associated with only one \typ{IvlBaseScheduler}
at a time by using the functions \fun{Add} and \fun{Remove} of the Channel.
When it is added/removed from its Multiplexor,
virtual function \fun{Added/Removed} is called.
@@ -178,8 +180,8 @@ virtual function \fun{Added/Removed} is called.
/*?
Construct a closed channel.
?*/
-UchChannel :: UchChannel ()
-: UchIOS (),
+IvlChannel :: IvlChannel ()
+: IvlIOS (),
Fd (),
Mode (IONone),
Mpx (0)
@@ -189,8 +191,8 @@ UchChannel :: UchChannel ()
/*?
Construct an open channel on file descriptor \var{fd} with mode \var{io}.
?*/
-UchChannel :: UchChannel (int fd, IOMODE io)
-: UchIOS (),
+IvlChannel :: IvlChannel (int fd, IOMODE io)
+: IvlIOS (),
Fd (fd),
Mode (io),
Mpx (0)
@@ -198,8 +200,8 @@ UchChannel :: UchChannel (int fd, IOMODE io)
}
/*?nodoc?*/
-UchChannel :: UchChannel (const UchChannel& ch)
-: UchIOS (ch),
+IvlChannel :: IvlChannel (const IvlChannel& ch)
+: IvlIOS (ch),
Fd (ch.Fd),
Mode (ch.Mode),
Mpx (ch.Mpx)
@@ -215,12 +217,12 @@ in order to associate a file descriptor to it.
Because a channel is immutable, this can be done only once.
?*/
void
-UchChannel :: Open (int fd)
+IvlChannel :: Open (int fd)
{ }
/*?nextdoc?*/
IOMODE
-UchChannel :: IOMode ()
+IvlChannel :: IOMode ()
{
}
@@ -228,23 +230,22 @@ UchChannel :: IOMode ()
Return/set the mode of the channel.
?*/
void
-UchChannel :: SetMode (IOMODE io)
+IvlChannel :: SetMode (IOMODE io)
{ }
#endif /* DOC */
-
/*?
Destroy the channel. It is removed from its multiplexor if necessary.
?*/
-UchChannel :: ~UchChannel ()
+IvlChannel :: ~IvlChannel ()
{
Remove ();
}
/*?nextdoc?*/
void
-UchChannel :: Added ()
+IvlChannel :: Added ()
{
}
@@ -254,13 +255,13 @@ These virtual functions are called whenever a channel is added to
nothing.
?*/
void
-UchChannel :: Removed ()
+IvlChannel :: Removed ()
{
}
/*?nextdoc?*/
void
-UchChannel :: Add (UchBaseMultiplexer* m)
+IvlChannel :: Add (IvlBaseScheduler* m)
{
if (Mpx != m) {
if (Mpx != 0)
@@ -279,7 +280,7 @@ If a channel with the same file descriptor as the one being added
is already in the multiplexor, the old channel is first removed.
?*/
void
-UchChannel :: Remove ()
+IvlChannel :: Remove ()
{
if (Mpx && Mpx->Remove (*this)) {
Removed ();
@@ -289,30 +290,30 @@ UchChannel :: Remove ()
/*?nextdoc?*/
void
-UchChannel :: HandleWrite ()
+IvlChannel :: HandleWrite ()
{
}
/*?
-These virtual functions are called by a \typ{UchMultiplexer} when data can be written
+These virtual functions are called by a \typ{IvlScheduler} when data can be written
to the channel or read from the channel.
The default implementation does nothing.
?*/
void
-UchChannel :: HandleRead ()
+IvlChannel :: HandleRead ()
{
}
#if 0
/*?
-This virtual function is called by a \typ{UchMultiplexer} before making a \fun{select} call.
+This virtual function is called by a \typ{IvlScheduler} before making a \fun{select} call.
It is intended to handle any background task or buffered input/output associated to the channel.
If it returns true, the channel set scan functions will return before performing the select call.
-See the class \typ{UchMultiplexer} for more details.
+See the class \typ{IvlScheduler} for more details.
The default implementation does nothing but returning false.
?*/
bool
-UchChannel :: HandleSelect ()
+IvlChannel :: HandleSelect ()
{
return false;
}
@@ -322,21 +323,21 @@ UchChannel :: HandleSelect ()
/*?nextdoc?*/
int
-UchChannel :: Read (byte* b, int n)
+IvlChannel :: Read (byte* b, int n)
{ }
/*?
-The Unix \fun{read} and \fun{write} system calls, as in class \typ{UchFilDes}.
+The Unix \fun{read} and \fun{write} system calls, as in class \typ{IvlFilDes}.
?*/
int
-UchChannel :: Write (byte* b, int n)
+IvlChannel :: Write (byte* b, int n)
{ }
#endif /* DOC */
/*?nextdoc?*/
int
-UchChannel :: Read (UchMsgBuffer& b)
+IvlChannel :: Read (IvlMsgBuffer& b)
{
int l = b.FreeLength ();
if (! l)
@@ -348,12 +349,12 @@ UchChannel :: Read (UchMsgBuffer& b)
}
/*?
-The Unix \fun{read} and \fun{write} system calls applied to a \typ{UchMsgBuffer}.
+The Unix \fun{read} and \fun{write} system calls applied to a \typ{IvlMsgBuffer}.
They return the number of bytes transferred, -1 if a system error occurred,
-2 if the buffer is empty when writing or full when reading.
?*/
int
-UchChannel :: Write (UchMsgBuffer& b)
+IvlChannel :: Write (IvlMsgBuffer& b)
{
int l = b.BufLength ();
if (! l)
@@ -366,7 +367,7 @@ UchChannel :: Write (UchMsgBuffer& b)
/*?nextdoc?*/
bool
-UchChannel :: ReadBuffer (UchMsgBuffer& b)
+IvlChannel :: ReadBuffer (IvlMsgBuffer& b)
{
int n;
errno = 0;
@@ -380,7 +381,7 @@ These functions repeatedly call \fun{Read} or \fun{Write} until the whole buffer
transferred or a system error occurred. In case of an error, they return false, else true.
?*/
bool
-UchChannel :: WriteBuffer (UchMsgBuffer& b)
+IvlChannel :: WriteBuffer (IvlMsgBuffer& b)
{
int n;
errno = 0;
@@ -390,69 +391,67 @@ UchChannel :: WriteBuffer (UchMsgBuffer& b)
}
void
-UchChannel :: WriteLong (lword l)
+IvlChannel :: WriteLong (lword l)
{
Write ((byte*)&l, lwsize);
}
void
-UchChannel :: WriteShort (sword s)
+IvlChannel :: WriteShort (sword s)
{
Write ((byte*)&s, swsize);
}
void
-UchChannel :: WriteByte (byte b)
+IvlChannel :: WriteByte (byte b)
{
Write (&b, 1);
}
void
-UchChannel :: WriteChar (char c)
+IvlChannel :: WriteChar (char c)
{
Write ((byte*)&c, 1);
}
void
-UchChannel :: WriteString (const char* s)
+IvlChannel :: WriteString (const char* s)
{
Write ((byte*) s, strlen (s) + 1);
}
void
-UchChannel :: WriteBuf (const byte* b, int n)
+IvlChannel :: WriteBuf (const byte* b, int n)
{
Write (b, n);
}
-
-
bool
-UchChannel :: ReadLong (lword& l)
+IvlChannel :: ReadLong (lword& l)
{
return bool (Read ((byte*)&l, lwsize) == lwsize);
}
bool
-UchChannel :: ReadShort (sword& s)
+IvlChannel :: ReadShort (sword& s)
{
return bool (Read ((byte*)&s, swsize) == swsize);
}
bool
-UchChannel :: ReadByte (byte& b)
+IvlChannel :: ReadByte (byte& b)
{
return bool (Read (&b, 1) == 1);
}
bool
-UchChannel :: ReadChar (char& c)
+IvlChannel :: ReadChar (char& c)
{
return bool (Read ((byte*)&c, 1) == 1);
}
int
-UchChannel :: ReadString (char* s, int n)
+IvlChannel :: ReadString (char* s, int n)
{
int i = 0;
// this is extremely non optimal
@@ -464,7 +463,7 @@ UchChannel :: ReadString (char* s, int n)
}
int
-UchChannel :: ReadString (CcuString& s)
+IvlChannel :: ReadString (IvlString& s)
{
// this enforces an undue limitation
char c [1024];
@@ -474,7 +473,7 @@ UchChannel :: ReadString (CcuString& s)
}
bool
-UchChannel :: ReadBuf (byte* b, int n)
+IvlChannel :: ReadBuf (byte* b, int n)
{
return bool (Read (b, n) == n);
}
diff --git a/comm/Channel.h b/comm/Channel.h
index 32271cf..1a9bd64 100644
--- a/comm/Channel.h
+++ b/comm/Channel.h
@@ -10,6 +10,11 @@
*
* $Id$
* $CurLog$
+ * Removed virtual IvlChannel::Copy ()
+ * Removed virutal IvlChannel::HandleSelect ()
+ * Smart(ies) removed by Stephane Sire
+ * Removed ReadHandler and WriteHandler
+ * NFILE -> 64, en attendant mieux
*/
#ifndef Channel_H_
@@ -20,11 +25,11 @@
#endif
#include "cplus_bugs.h"
-#include "ccu/bool.h"
+#include "ivl/bool.h"
#include "IOS.h"
-class UchMsgBuffer;
-class CcuString;
+class IvlMsgBuffer;
+class IvlString;
// we need read and write system calls
#include <unistd.h>
@@ -39,7 +44,7 @@ enum IOMODE { IONone = 0, IORead = 1, IOWrite = 2,
extern char* StrReprBuf;
-class UchFilDes {
+class IvlFilDes {
private:
static void Use (int);
static void Unuse (int);
@@ -47,13 +52,13 @@ static void Unuse (int);
protected:
int Fd;
public:
-inline UchFilDes () : Fd (-1) { }
-inline UchFilDes (const UchFilDes& fd) { Use (Fd = fd.Fd); }
-inline UchFilDes (int fd) { Use (Fd = fd); }
-inline ~UchFilDes () { Unuse (Fd); }
+inline IvlFilDes () : Fd (-1) { }
+inline IvlFilDes (const IvlFilDes& fd) { Use (Fd = fd.Fd); }
+inline IvlFilDes (int fd) { Use (Fd = fd); }
+inline ~IvlFilDes () { Unuse (Fd); }
inline operator int () const { return Fd; }
-inline UchFilDes& operator = (const UchFilDes& fd) { Unuse (Fd); Fd = fd.Fd; Use (Fd); return *this; }
+inline IvlFilDes& operator = (const IvlFilDes& fd) { Unuse (Fd); Fd = fd.Fd; Use (Fd); return *this; }
inline int FilDes () { return Fd; }
inline void Open (int fd) { Unuse (Fd); Use (Fd = fd); }
inline void Close () { Unuse (Fd); Fd = -1; }
@@ -70,32 +75,31 @@ inline int Write (byte* b, int n) { return write (Fd, (const char*) b, n); }
// potentially bypass immutability.
//
-class UchChannel : public UchIOS {
-friend class UchBaseMultiplexer;
+class IvlChannel : public IvlIOS {
+friend class IvlBaseScheduler;
protected:
- UchFilDes Fd;
+ IvlFilDes Fd;
IOMODE Mode;
- UchBaseMultiplexer* Mpx;
+ IvlBaseScheduler* Mpx;
virtual void Added ();
virtual void Removed ();
public:
- UchChannel ();
- UchChannel (int, IOMODE = IOReadWrite);
- UchChannel (const UchChannel& ch);
- ~UchChannel ();
-
+ IvlChannel ();
+ IvlChannel (int, IOMODE = IOReadWrite);
+ IvlChannel (const IvlChannel& ch);
+ ~IvlChannel ();
inline void Open (int fd) { if (Fd < 0) Fd.Open (fd); }
inline void Close () { if (Fd.Opened ()) Fd.Close (); }
inline IOMODE IOMode () const { return Mode; }
inline void SetMode (IOMODE io) { Mode = io; }
- int Read (UchMsgBuffer&);
- int Write (UchMsgBuffer&);
- bool ReadBuffer (UchMsgBuffer&);
- bool WriteBuffer (UchMsgBuffer&);
- void Add (UchBaseMultiplexer*);
+ int Read (IvlMsgBuffer&);
+ int Write (IvlMsgBuffer&);
+ bool ReadBuffer (IvlMsgBuffer&);
+ bool WriteBuffer (IvlMsgBuffer&);
+ void Add (IvlBaseScheduler*);
void Remove ();
virtual void HandleWrite ();
virtual void HandleRead ();
@@ -104,10 +108,9 @@ inline int FilDes () const { return Fd; }
inline int Read (byte* b, int n) { return read (Fd, (char*) b, n); }
inline int Write (const byte* b, int n) { return write (Fd, (const char*) b, n); }
inline operator int () { return Fd; }
-inline UchBaseMultiplexer* GetMultiplexer () const { return Mpx; }
+inline IvlBaseScheduler* GetScheduler () const { return Mpx; }
inline char* StrRepr (char* s = StrReprBuf) { return Fd.StrRepr (s); }
-
virtual void WriteLong (lword);
virtual void WriteShort (sword);
virtual void WriteByte (byte);
@@ -120,7 +123,7 @@ virtual bool ReadShort (sword&);
virtual bool ReadByte (byte&);
virtual bool ReadChar (char&);
virtual int ReadString (char*, int);
-virtual int ReadString (CcuString&);
+virtual int ReadString (IvlString&);
virtual bool ReadBuf (byte*, int);
};
diff --git a/comm/Datagram.cc b/comm/Datagram.cc
index e7eb577..66c40df 100644
--- a/comm/Datagram.cc
+++ b/comm/Datagram.cc
@@ -17,7 +17,7 @@
#include <stdlib.h>
#include <sys/socket.h>
-/*?class UchDatagram
+/*?class IvlDatagram
A datagram socket can send to and receive from any other datagram
socket, unless it is connected. Thus, establishing a datagram
connection is simple.
@@ -40,23 +40,23 @@ or \fun{Open} followed by \fun{Bind} and \fun{Connect} if necessary.
?*/
/*?
-These constructors are similar to those of the class \typ{UchSocket}.
+These constructors are similar to those of the class \typ{IvlSocket}.
?*/
-UchDatagram :: UchDatagram (UchAddress* bound, UchAddress* connected)
-: UchSocket (bound, connected),
+IvlDatagram :: IvlDatagram (IvlAddress* bound, IvlAddress* connected)
+: IvlSocket (bound, connected),
FAddr (0)
{
}
/*?nodoc?*/
-UchDatagram :: UchDatagram (const UchDatagram& d)
-: UchSocket (d),
+IvlDatagram :: IvlDatagram (const IvlDatagram& d)
+: IvlSocket (d),
FAddr (d.FAddr)
{
}
/*?nodoc?*/
-UchDatagram :: ~UchDatagram ()
+IvlDatagram :: ~IvlDatagram ()
{
}
@@ -64,22 +64,22 @@ UchDatagram :: ~UchDatagram ()
/*?
Return the address of the sender of the last received message.
?*/
-UchAddress*
-UchDatagram :: From ()
+IvlAddress*
+IvlDatagram :: From ()
{ }
#endif /* DOC */
/*?nodoc?*/
-UchChannel*
-UchDatagram :: Copy () const
+IvlChannel*
+IvlDatagram :: Copy () const
{
- return new UchDatagram (*this);
+ return new IvlDatagram (*this);
}
/*?nodoc?*/
int
-UchDatagram :: SockType ()
+IvlDatagram :: SockType ()
{
return SOCK_DGRAM;
}
@@ -90,7 +90,7 @@ Return the number of bytes actually transferred, or -1 if a system error occurre
If the datagram is connected, you must use \fun{Write} instead.
?*/
int
-UchDatagram :: Send (byte* buf, int len, UchAddress& to)
+IvlDatagram :: Send (byte* buf, int len, IvlAddress& to)
{
return sendto (FilDes (), (char*) buf, len, 0, to.GetSockAddr (), to.Length ());
}
@@ -102,17 +102,17 @@ The address of the sender can be retrieved with \fun{From}.
If the socket is connected, you must use \fun{Read} instead.
?*/
int
-UchDatagram :: Receive (byte* buf, int len)
+IvlDatagram :: Receive (byte* buf, int len)
{
GEN_ADDR addr;
- int alen = sizeof (addr);
+ socklen_t alen = sizeof (addr);
int ret;
ret = recvfrom (Fd, (char*) buf, len, 0, &addr.sa, &alen);
if (ret < 0)
return ret;
- FAddr = UchAddress::Decode (&addr, alen);
+ FAddr = IvlAddress::Decode (&addr, alen);
return ret;
}
@@ -122,7 +122,7 @@ it sends \fun{len} bytes to the sender of the last received message.
If there is no such sender, it returns -1.
?*/
int
-UchDatagram :: Reply (byte* buf, int len)
+IvlDatagram :: Reply (byte* buf, int len)
{
if (! FAddr)
return -1;
@@ -131,7 +131,7 @@ UchDatagram :: Reply (byte* buf, int len)
/*?nextdoc?*/
int
-UchDatagram :: Send (UchMsgBuffer& buf, UchAddress& to, bool peek)
+IvlDatagram :: Send (IvlMsgBuffer& buf, IvlAddress& to, bool peek)
{
int n = Send (buf.Buffer (), buf.BufLength (), to);
if (! peek)
@@ -141,7 +141,7 @@ UchDatagram :: Send (UchMsgBuffer& buf, UchAddress& to, bool peek)
/*?nextdoc?*/
int
-UchDatagram :: Receive (UchMsgBuffer& buf)
+IvlDatagram :: Receive (IvlMsgBuffer& buf)
{
int n = Receive (buf.Free (), buf.FreeLength ());
if (n > 0)
@@ -150,11 +150,11 @@ UchDatagram :: Receive (UchMsgBuffer& buf)
}
/*?
-The same functions but with a \typ{UchMsgBuffer} argument instead of a byte pointer and size.
+The same functions but with a \typ{IvlMsgBuffer} argument instead of a byte pointer and size.
As usual, if \var{peek} is true the buffer is not flushed.
?*/
int
-UchDatagram :: Reply (UchMsgBuffer& buf, bool peek)
+IvlDatagram :: Reply (IvlMsgBuffer& buf, bool peek)
{
int n = Reply (buf.Buffer (), buf.BufLength ());
if (! peek)
diff --git a/comm/Datagram.h b/comm/Datagram.h
index cc7798f..e9ffd1e 100644
--- a/comm/Datagram.h
+++ b/comm/Datagram.h
@@ -16,27 +16,27 @@
#define Datagram_H_
#include "cplus_bugs.h"
-#include "ccu/bool.h"
-#include "ccu/word.h"
+#include "ivl/bool.h"
+#include "ivl/word.h"
#include "Socket.h"
-class UchDatagram : public UchSocket {
+class IvlDatagram : public IvlSocket {
protected:
- UchAddress* FAddr;
+ IvlAddress* FAddr;
public:
- UchDatagram (UchAddress* = 0, UchAddress* = 0);
- ~UchDatagram ();
- UchDatagram (const UchDatagram& d);
- UchChannel* Copy () const;
+ IvlDatagram (IvlAddress* = 0, IvlAddress* = 0);
+ ~IvlDatagram ();
+ IvlDatagram (const IvlDatagram& d);
+ IvlChannel* Copy () const;
int SockType ();
- int Send (byte*, int, UchAddress&);
+ int Send (byte*, int, IvlAddress&);
int Receive (byte*, int);
-inline UchAddress* From () { return FAddr; }
+inline IvlAddress* From () { return FAddr; }
int Reply (byte*, int);
- int Send (UchMsgBuffer& b, UchAddress& a, bool = false);
- int Receive (UchMsgBuffer& b);
- int Reply (UchMsgBuffer& b, bool = false);
+ int Send (IvlMsgBuffer& b, IvlAddress& a, bool = false);
+ int Receive (IvlMsgBuffer& b);
+ int Reply (IvlMsgBuffer& b, bool = false);
};
#endif /* Datagram_H_ */
diff --git a/comm/IOS.cc b/comm/IOS.cc
index 5f509bb..6975d0c 100644
--- a/comm/IOS.cc
+++ b/comm/IOS.cc
@@ -17,10 +17,10 @@
#endif
#include "IOS.h"
#include "error.h"
-#include "ccu/String.h"
+#include "ivl/String.h"
-/*?class UchIOS
-The class \typ{UchIOS} (for input/output stream) is a
+/*?class IvlIOS
+The class \typ{IvlIOS} (for input/output stream) is a
base class for all objects of \uch\ that can be written to or read
from, such as buffers or sockets. It declares a number of virtual
functions for reading and writing characters, integers, buffers and
@@ -31,44 +31,43 @@ used as shorthand for reading and writing.
/*?
Build a input/output stream.
?*/
-UchIOS :: UchIOS ()
+IvlIOS :: IvlIOS ()
{
}
-
/*?nodoc?*/
-UchIOS :: ~UchIOS ()
+IvlIOS :: ~IvlIOS ()
{
}
#ifdef DOC
/*?nextdoc?*/
void
-UchIOS :: WriteLong (lword l)
+IvlIOS :: WriteLong (lword l)
{
}
/*?nextdoc?*/
void
-UchIOS :: WriteShort (sword s)
+IvlIOS :: WriteShort (sword s)
{
}
/*?nextdoc?*/
void
-UchIOS :: WriteByte (byte b)
+IvlIOS :: WriteByte (byte b)
{
}
/*?nextdoc?*/
void
-UchIOS :: WriteChar (char c)
+IvlIOS :: WriteChar (char c)
{
}
/*?nextdoc?*/
void
-UchIOS :: WriteString (const char* s)
+IvlIOS :: WriteString (const char* s)
{
}
@@ -76,45 +75,43 @@ UchIOS :: WriteString (const char* s)
These virtual functions are used to write on a stream.
?*/
void
-UchIOS :: WriteBuf (const byte* b, int n)
+IvlIOS :: WriteBuf (const byte* b, int n)
{
}
-
-
/*?nextdoc?*/
void
-UchIOS :: ReadLong (lword& l)
+IvlIOS :: ReadLong (lword& l)
{
}
/*?nextdoc?*/
void
-UchIOS :: ReadShort (sword& s)
+IvlIOS :: ReadShort (sword& s)
{
}
/*?nextdoc?*/
void
-UchIOS :: ReadByte (byte& b)
+IvlIOS :: ReadByte (byte& b)
{
}
/*?nextdoc?*/
void
-UchIOS :: ReadChar (char& c)
+IvlIOS :: ReadChar (char& c)
{
}
/*?nextdoc?*/
void
-UchIOS :: ReadString (char* s)
+IvlIOS :: ReadString (char* s)
{
}
/*?nextdoc?*/
void
-UchIOS :: ReadString (CcuString& s)
+IvlIOS :: ReadString (IvlString& s)
{
}
@@ -122,7 +119,7 @@ UchIOS :: ReadString (CcuString& s)
These virtual functions are used to write on a stream.
?*/
void
-UchIOS :: ReadBuf (byte* b, int n)
+IvlIOS :: ReadBuf (byte* b, int n)
{
}
diff --git a/comm/IOS.h b/comm/IOS.h
index 9f87478..828393f 100644
--- a/comm/IOS.h
+++ b/comm/IOS.h
@@ -10,24 +10,25 @@
*
* $Id$
* $CurLog$
+ * Removed global.h
*/
-#ifndef UchIO_H_
-#define UchIO_H_
+#ifndef IvlIO_H_
+#define IvlIO_H_
#ifdef __GNUG__
#pragma interface
#endif
#include "cplus_bugs.h"
-#include "ccu/bool.h"
-#include "ccu/word.h"
-class CcuString;
+#include "ivl/bool.h"
+#include "ivl/word.h"
+class IvlString;
-class UchIOS {
+class IvlIOS {
public:
- UchIOS ();
-virtual ~UchIOS ();
+ IvlIOS ();
+virtual ~IvlIOS ();
virtual void WriteLong (lword) = 0;
virtual void WriteShort (sword) = 0;
@@ -42,21 +43,21 @@ virtual bool ReadByte (byte&) = 0;
virtual bool ReadChar (char&) = 0;
virtual bool ReadBuf (byte*, int) = 0;
virtual int ReadString (char*, int = -1) = 0;
-virtual int ReadString (CcuString&) = 0;
+virtual int ReadString (IvlString&) = 0;
-inline UchIOS& operator << (lword l) { WriteLong (l); return *this; }
-inline UchIOS& operator << (sword s) { WriteShort (s); return *this; }
-inline UchIOS& operator << (byte b) { WriteByte (b); return *this; }
-inline UchIOS& operator << (char c) { WriteChar (c); return *this; }
-inline UchIOS& operator << (const char* s) { WriteString (s); return *this; }
+inline IvlIOS& operator << (lword l) { WriteLong (l); return *this; }
+inline IvlIOS& operator << (sword s) { WriteShort (s); return *this; }
+inline IvlIOS& operator << (byte b) { WriteByte (b); return *this; }
+inline IvlIOS& operator << (char c) { WriteChar (c); return *this; }
+inline IvlIOS& operator << (const char* s) { WriteString (s); return *this; }
-inline UchIOS& operator >> (lword& l) { ReadLong (l); return *this; }
-inline UchIOS& operator >> (sword& s) { ReadShort (s); return *this; }
-inline UchIOS& operator >> (byte& b) { ReadByte (b); return *this; }
-inline UchIOS& operator >> (char& c) { ReadChar (c); return *this; }
-inline UchIOS& operator >> (char* s) { ReadString (s); return *this; }
-inline UchIOS& operator >> (CcuString& s) { ReadString (s); return *this; }
+inline IvlIOS& operator >> (lword& l) { ReadLong (l); return *this; }
+inline IvlIOS& operator >> (sword& s) { ReadShort (s); return *this; }
+inline IvlIOS& operator >> (byte& b) { ReadByte (b); return *this; }
+inline IvlIOS& operator >> (char& c) { ReadChar (c); return *this; }
+inline IvlIOS& operator >> (char* s) { ReadString (s); return *this; }
+inline IvlIOS& operator >> (IvlString& s) { ReadString (s); return *this; }
};
-#endif /* UchIO_H_ */
+#endif /* IvlIO_H_ */
diff --git a/comm/Imakefile b/comm/Imakefile
deleted file mode 100644
index 0b218fc..0000000
--- a/comm/Imakefile
+++ /dev/null
@@ -1,137 +0,0 @@
-#
-# The Unix Channel
-#
-# by Michel Beaudouin-Lafon and Stephane Chatty
-#
-# Copyright 1990-1997
-# Laboratoire de Recherche en Informatique (LRI)
-# Centre d'Etudes de la navigation Aerienne
-#
-# Imakefile
-#
-# $Id$
-# $CurLog$
-#
-
- CXXFLAGS = $(CXXOPTIONS) -g -I. -I$(LOCINCL) -DUNIX_SOCK
-
- cc = $(CXXSUFFIX)
- SRC = error.$(cc) IOS.$(cc) MsgBuffer.$(cc) Message.$(cc) \
- Channel.$(cc) TimeOut.$(cc) SignalHandler.$(cc) \
- Multiplexer.$(cc) Address.$(cc) \
- Socket.$(cc) Datagram.$(cc) Stream.$(cc) \
- BufStream.$(cc) MsgStream.$(cc) BusAccess.$(cc)
-
- HDR = error.h IOS.h MsgBuffer.h Message.h Channel.h \
- TimeOut.h SignalHandler.h Multiplexer.h \
- Address.h Socket.h Datagram.h Stream.h \
- BufStream.h MsgStream.h BusAccess.h TextStream.h
-
- UCHOBJ = error.o IOS.o MsgBuffer.o Message.o Channel.o \
- TimeOut.o SignalHandler.o Multiplexer.o \
- Address.o Socket.o Datagram.o Stream.o \
- BufStream.o MsgStream.o BusAccess.o TextStream.o
-
- CHANOBJ = error.o IOS.o MsgBuffer.o Message.o Channel.o \
- Multiplexer.o TimeOut.o SignalHandler.o
-
- UCHHDR = version.h \
- $(LOCINCL)/ccu/List.h $(LOCINCL)/ccu/HashTable.h \
- $(LOCINCL)/ccu/bool.h \
- $(LOCINCL)/ccu/word.h $(LOCINCL)/ccu/IdTable.h \
- $(LOCINCL)/ccu/String.h \
- $(LOCINCL)/ccu/Signal.h \
- $(LOCINCL)/ccu/Time.h $(LOCINCL)/ccu/Timer.h\
- $(LOCINCL)/ccu/Initializer.h \
- $(LOCINCL)/dnn/Event.h \
- $(LOCINCL)/dnn/Loop.h \
- error.h IOS.h MsgBuffer.h Message.h \
- Channel.h Multiplexer.h TimeOut.h SignalHandler.h \
- Address.h Socket.h Datagram.h Stream.h \
- BufStream.h MsgStream.h BusAccess.h TextStream.h
-
- CHANHDR = version.h \
- $(LOCINCL)/ccu/bool.h \
- $(LOCINCL)/ccu/word.h \
- $(LOCINCL)/ccu/List.h \
- $(LOCINCL)/ccu/Signal.h \
- $(LOCINCL)/ccu/Time.h $(LOCINCL)/ccu/Timer.h \
- $(LOCINCL)/ccu/Initializer.h \
- $(LOCINCL)/dnn/Loop.h \
- error.h IOS.h MsgBuffer.h Message.h \
- Channel.h Multiplexer.h
-
- LLIB = -L$(LOCLIB) -lUch -lDnn_g -lCcu
-
- LEX = lex
- YACC = yacc # or bison -y
-
- DOC = ../../DOC/UCH
- DISTRDOC = ../../DOC.distr
-
-CxxRule ()
-
-# UchTarget is 'chan' or 'chan comm'
-all : headers UchTarget
-
-headers: incldir \
- $(LOCINCL)/uch/IOS.h \
- $(LOCINCL)/uch/Channel.h \
- $(LOCINCL)/uch/Multiplexer.h \
- $(LOCINCL)/uch/TimeOut.h \
- $(LOCINCL)/uch/SignalHandler.h \
- $(LOCINCL)/uch/Address.h \
- $(LOCINCL)/uch/Socket.h \
- $(LOCINCL)/uch/Datagram.h \
- $(LOCINCL)/uch/Stream.h \
- $(LOCINCL)/uch/MsgBuffer.h \
- $(LOCINCL)/uch/BufStream.h \
- $(LOCINCL)/uch/Message.h \
- $(LOCINCL)/uch/MsgStream.h \
- $(LOCINCL)/uch/BusAccess.h \
- $(LOCINCL)/uch/TextStream.h
-
-comm : $(LOCLIB)/libUch.a \
- $(LOCINCL)/uch.h
-
-chan : $(LOCLIB)/libChan.a $(LOCINCL)/chan.h
-
-local : libUch.a libChan.a uch.h chan.h
-
-LibraryTarget (Uch, $(UCHOBJ))
-LibraryTarget (Chan, $(CHANOBJ))
-
-GenHeaderTarget (uch.h, $(UCHHDR))
-GenHeaderTarget (chan.h, $(CHANHDR))
-
-InstallLibsTarget($(LOCLIB),Uch)
-InstallLibsTarget($(LOCLIB),Chan)
-
-incldir:
- -mkdir $(LOCINCL)/uch
-
-InstallTarget($(LOCINCL)/uch.h, uch.h)
-InstallTarget($(LOCINCL)/chan.h, chan.h)
-InstallTarget ($(LOCINCL)/uch/IOS.h, IOS.h)
-InstallTarget ($(LOCINCL)/uch/Channel.h, Channel.h)
-InstallTarget ($(LOCINCL)/uch/Multiplexer.h, Multiplexer.h)
-InstallTarget ($(LOCINCL)/uch/TimeOut.h, TimeOut.h)
-InstallTarget ($(LOCINCL)/uch/SignalHandler.h, SignalHandler.h)
-InstallTarget ($(LOCINCL)/uch/Address.h, Address.h)
-InstallTarget ($(LOCINCL)/uch/Socket.h, Socket.h)
-InstallTarget ($(LOCINCL)/uch/Datagram.h, Datagram.h)
-InstallTarget ($(LOCINCL)/uch/Stream.h, Stream.h)
-InstallTarget ($(LOCINCL)/uch/MsgBuffer.h, MsgBuffer.h)
-InstallTarget ($(LOCINCL)/uch/BufStream.h, BufStream.h)
-InstallTarget ($(LOCINCL)/uch/Message.h, Message.h)
-InstallTarget ($(LOCINCL)/uch/MsgStream.h, MsgStream.h)
-InstallTarget ($(LOCINCL)/uch/BusAccess.h, BusAccess.h)
-InstallTarget ($(LOCINCL)/uch/TextStream.h, TextStream.h)
-
-DocRule ("The Unix Channel")
-TeXRule ()
-DistrDocRule (UCH)
-
-ProgramTarget (testbus, testbus.o,);
-
-
diff --git a/comm/InetAddress.cc b/comm/InetAddress.cc
new file mode 100644
index 0000000..ffb374e
--- /dev/null
+++ b/comm/InetAddress.cc
@@ -0,0 +1,251 @@
+/*
+ * The Unix Channel
+ *
+ * by Michel Beaudouin-Lafon
+ *
+ * Copyright 1990-1997
+ * Laboratoire de Recherche en Informatique (LRI)
+ *
+ * INET Addresses
+ *
+ * $Id$
+ * $CurLog$
+ * Created from Address.cc
+ */
+
+#include "InetAddress.h"
+
+#include <sys/utsname.h>
+#include <stdio.h>
+
+#ifdef __osf__
+extern "C" {
+ unsigned short htons (unsigned short);
+ unsigned short ntohs (unsigned short);
+ int gethostname (char*, int);
+#endif
+#include <netdb.h>
+#ifdef __osf__
+}
+#endif
+
+
+// constructors for inet addresses
+// inet address specified by:
+// hostname / port# (ANY if hostname is NIL, LOOPBACK if hostname is "")
+// hostid / port# (predefined hostids ANYADDR, ...)
+// todo:
+// hostname / service name ??
+//
+/*?
+IvlInetAddresses should only be allocated with new because they
+can be deleted and reallocated by \type{IvlSocket} class.
+?*/
+IvlInetAddress :: IvlInetAddress ()
+: IvlAddress (),
+ HostName (),
+ HasHostName (false)
+{
+}
+
+/*?
+Construct an inet address, from a hostname and a port number.
+The address is valid only if the host is valid.
+If \var{host} is the empty string, the loopback host is used;
+if it is the nil pointer, the wildcard (INADDR_ANY) is used.
+If the port number is 0, it will be allocated by the system.
+?*/
+IvlInetAddress :: IvlInetAddress (const char* name, sword port)
+: IvlAddress (),
+ HostName (),
+ HasHostName (false)
+{
+ if (name && *name) {
+ struct hostent *host = gethostbyname (name);
+ if (! host)
+ return;
+ memcpy (&Addr.sin_addr, host->h_addr, host->h_length);
+ } else
+ Addr.sin_addr.s_addr = name ? INADDR_LOOPBACK : INADDR_ANY;
+ Addr.sin_family = AF_INET;
+ Addr.sin_port = htons (port);
+ Valid = true;
+}
+
+/*?
+Construct an inet address, from a host id (internet address) and a port number.
+If the port number is 0, it is assigned by the system.
+The host ids \var{^{ANYADDR}}, \var{^{LOOPBACK}} and \var{^{BROADCAST}} are predefined.
+\var{ANYADDR} is used to receive messages from anywhere.
+\var{LOOPBACK} is the local host address.
+\var{BROADCAST} makes it possible to send data to all the hosts of a local area network.
+?*/
+IvlInetAddress :: IvlInetAddress (lword host, sword port)
+: IvlAddress (),
+ HostName (),
+ HasHostName (false)
+{
+ Addr.sin_family = AF_INET;
+ Addr.sin_port = htons (port);
+ Addr.sin_addr.s_addr = host;
+ Valid = true;
+}
+
+/*?nodoc?*/
+IvlInetAddress :: ~IvlInetAddress ()
+{
+}
+
+/*?nodoc?*/
+int
+IvlInetAddress :: Family ()
+{
+ return AF_INET;
+}
+
+/*?nodoc?*/
+int
+IvlInetAddress :: Length ()
+{
+ return sizeof (Addr);
+}
+
+/*?nodoc?*/
+SockAddr*
+IvlInetAddress :: GetSockAddr ()
+{
+ return (SockAddr*) &Addr;
+}
+
+
+/*?
+This is a global function (static member of class \typ{IvlInetAddress}.
+It returns the internet address of the local host.
+This is different from the predefined address \var{LOOPBACK}:
+\var{LOOPBACK} is the same constant on each machine, so that it cannot
+be communicated across the network.
+The value returned by \fun{LoopBack} is the unique internet address of the local host.
+Thus it can be communicated to another host across the network.
+?*/
+lword
+IvlInetAddress :: LoopBack ()
+{
+ static lword loopback = 0;
+
+ if (loopback)
+ return loopback;
+
+ struct hostent *host;
+
+#if 0
+ char name [128];
+ gethostname (name, sizeof (name));
+ host = gethostbyname (name);
+#else
+ struct utsname un;
+ if (uname (&un) < 0) {
+ Error (ErrFatal, "address", "cannot get name of local host");
+ return 0;
+ }
+ host = gethostbyname (un.nodename);
+#endif
+
+ if (! host) {
+ Error (ErrFatal, "address", "cannot get address of local host");
+ return 0;
+ }
+ return loopback = * ((lword *) host->h_addr);
+}
+
+#ifdef DOC
+// Ca c'est les super fake declarations pour avoir la DOC
+// merci au LRI...
+/*?
+Return the host number of the address.
+?*/
+lword
+IvlInetAddress :: Host ()
+{}
+
+/*?
+Return the port number of the address.
+?*/
+sword
+IvlInetAddress :: Port ()
+{}
+#endif /* DOC */
+
+/*?
+Return a const string representing the hostname part of the address if any
+or NULL if it does not exist (INADDR_ANY, INADDR_LOOPBACK or INADDR_BROADCAST).
+This is an interface to unix \fun{gethostbyaddr} system call.
+?*/
+const char*
+IvlInetAddress :: GetHostName ()
+{
+ struct hostent *host;
+ unsigned long saddr;
+
+ if (HasHostName)
+ return HostName;
+
+ saddr = Addr.sin_addr.s_addr;
+ host = gethostbyaddr ((char*) &saddr, sizeof (long), AF_INET);
+ if (host)
+ HostName = host->h_name;
+#if 0
+ } else
+ HostName = GetNoHostName();
+#endif
+ else {
+ struct utsname un;
+ if (uname (&un) < 0) {
+ Error (ErrFatal, "GetHostName", "cannot get name of local host");
+ HostName = 0;
+ }
+ HostName = un.nodename;
+ }
+ HasHostName = true;
+ return HostName;
+}
+
+/*?nodoc?*/
+const char*
+IvlInetAddress :: GetNoHostName ()
+{
+ const char* hname;
+ unsigned long saddr = Addr.sin_addr.s_addr;
+ if (saddr == INADDR_ANY)
+ hname = "ANY";
+ else if (saddr == INADDR_LOOPBACK)
+ hname = "LOOPBACK";
+ else if (saddr == INADDR_BROADCAST)
+ hname = "BROADCAST";
+ else
+ hname = "???";
+ return hname;
+}
+
+/*?
+Return a newly allocated \typ{char*} pointing to a string representing
+the internet address as "hostname:port". If no host name can be found
+then it can be "ANY" (INADDR_ANY), "LOOPBACK" (INADDR_LOOPBACK), "BROADCAST"
+(INADDR_BROADCAST) or "???".
+If argument \var{buf} is not null, return it's value in buf and do not
+allocate any memory.
+?*/
+char*
+IvlInetAddress :: StrRepr (char* buf)
+{
+ const char* hname;
+ if (HasHostName) {
+ hname = HostName;
+ if (!hname)
+ hname = GetNoHostName ();
+ } else
+ hname = GetHostName ();
+ if (! buf)
+ buf = new char [ strlen(hname) + 2 + 7 ];
+ sprintf (buf, "%s::%d",hname, ntohs (Addr.sin_port));
+ return buf;
+}
diff --git a/comm/InetAddress.h b/comm/InetAddress.h
new file mode 100644
index 0000000..eec1490
--- /dev/null
+++ b/comm/InetAddress.h
@@ -0,0 +1,58 @@
+/*
+ * The Unix Channel
+ *
+ * by Michel Beaudouin-Lafon
+ *
+ * Copyright 1990-1997
+ * Laboratoire de Recherche en Informatique (LRI)
+ *
+ * INET Addresses
+ *
+ * $Id$
+ * $CurLog$
+ * Created from Address.h
+ */
+
+#ifndef InetAddress_H_
+#define InetAddress_H_
+
+#include "cplus_bugs.h"
+#include "error.h"
+#include "Address.h"
+
+class IvlInetAddress : public IvlAddress {
+protected:
+ IvlString HostName;
+ bool HasHostName;
+ struct sockaddr_in Addr;
+
+ const char* GetNoHostName ();
+
+public:
+ IvlInetAddress ();
+ IvlInetAddress (lword, sword); // hostid, port#
+ IvlInetAddress (const char*, sword = 0); // hostname, port#
+ ~IvlInetAddress ();
+
+ int Family ();
+ int Length ();
+ SockAddr* GetSockAddr ();
+inline sword Port () { return Addr.sin_port; }
+inline lword Host () { return Addr.sin_addr.s_addr; }
+ char* StrRepr (char* buf = 0);
+ const char* GetHostName ();
+
+static lword LoopBack ();
+};
+
+#ifndef INADDR_LOOPBACK
+#define INADDR_LOOPBACK (INET_ADDR::LoopBack ())
+#endif
+
+#define ANYADDR ((lword) INADDR_ANY)
+#define LOOPBACK ((lword) INADDR_LOOPBACK)
+#define BROADCAST ((lword) INADDR_BROADCAST)
+
+
+
+#endif /* InetAddress_H_ */
diff --git a/comm/IrdaAddress.cc b/comm/IrdaAddress.cc
new file mode 100644
index 0000000..4beceb2
--- /dev/null
+++ b/comm/IrdaAddress.cc
@@ -0,0 +1,69 @@
+/*
+ * The Unix Channel
+ *
+ * by Michel Beaudouin-Lafon
+ *
+ * Copyright 1990-2000
+ * Laboratoire de Recherche en Informatique (LRI)
+ *
+ * IRDA Addresses,
+ * by Stephane Chatty
+ *
+ * $Id$
+ * $CurLog$
+ */
+
+#include "cplus_bugs.h"
+#include "IrdaAddress.h"
+#include <stdio.h>
+#include <memory.h>
+
+#ifndef AF_IRDA
+#define AF_IRDA 23
+#endif /* AF_IRDA */
+
+IvlIrdaAddress :: IvlIrdaAddress (const char* service)
+: IvlAddress (),
+ Service (service ? service : "OBEX")
+{
+ Addr.sir_family = AF_IRDA;
+ strncpy (Addr.sir_name, Service, 25);
+ Addr.sir_lsap_sel = LSAP_ANY;
+ Valid = true;
+}
+
+/*?nodoc?*/
+IvlIrdaAddress :: ~IvlIrdaAddress ()
+{
+}
+
+
+int
+IvlIrdaAddress :: Family ()
+{
+ return AF_IRDA;
+}
+
+
+int
+IvlIrdaAddress :: Length ()
+{
+ return sizeof (Addr);
+}
+
+
+SockAddr*
+IvlIrdaAddress :: GetSockAddr ()
+{
+ return (SockAddr*) &Addr;
+}
+
+
+char*
+IvlIrdaAddress :: StrRepr (char* buf)
+{
+ if (! buf)
+ buf = new char [ strlen (Service) + 1 + 5];
+ sprintf (buf, "IRDA:%s", (const char*) Service);
+ return buf;
+}
diff --git a/comm/IrdaAddress.h b/comm/IrdaAddress.h
new file mode 100644
index 0000000..c73b9f1
--- /dev/null
+++ b/comm/IrdaAddress.h
@@ -0,0 +1,38 @@
+/*
+ * The Unix Channel
+ *
+ * by Michel Beaudouin-Lafon
+ *
+ * Copyright 1990-1997
+ * Laboratoire de Recherche en Informatique (LRI)
+ *
+ * IRDA Addresses,
+ * by Stephane Chatty
+ *
+ * $Id$
+ * $CurLog$
+ */
+
+#ifndef IrdaAddress_H_
+#define IrdaAddress_H_
+
+#include "cplus_bugs.h"
+#include "Address.h"
+#include "ivl/String.h"
+
+class IvlIrdaAddress : public IvlAddress {
+protected:
+ IvlString Service;
+ struct sockaddr_irda Addr;
+
+public:
+ IvlIrdaAddress (const char* = 0); // service
+ ~IvlIrdaAddress ();
+
+ int Family ();
+ int Length ();
+ SockAddr* GetSockAddr ();
+ char* StrRepr (char* buf = 0);
+};
+
+#endif /* IrdaAddress_H_ */
diff --git a/comm/Makefile b/comm/Makefile
new file mode 100644
index 0000000..ade3cac
--- /dev/null
+++ b/comm/Makefile
@@ -0,0 +1,164 @@
+#
+# Ivy League
+#
+# by Stephane Chatty (from the Unix Channel, by Michel Beaudouin-Lafon)
+#
+# Copyright 1990-2000
+# Laboratoire de Recherche en Informatique (LRI)
+# Centre d'Etudes de la Navigation Aerienne
+#
+# Imakefile
+#
+# $Id$
+# $CurLog$
+#
+
+MAJOR = 1
+MINOR = 0
+LOCINCL = ../include
+CXX = g++
+CXXOPTIONS = -g
+CXXSUFFIX = cc
+LEX = lex
+YACC = yacc # or bison -y
+
+CXXFLAGS = $(CXXOPTIONS) -I$(LOCINCL)/ivl -I$(LOCINCL) -DUNIX_SOCK -DIRDA_SOCK
+
+cc = $(CXXSUFFIX)
+SRC = error.$(cc) IOS.$(cc) MsgBuffer.$(cc) Message.$(cc) \
+ Channel.$(cc) TimeOut.$(cc) SignalHandler.$(cc) \
+ Scheduler.$(cc) Address.$(cc) \
+ InetAddress.$(cc) UnixAddress.$(cc) IrdaAddress.$(cc) \
+ Socket.$(cc) Datagram.$(cc) Stream.$(cc) \
+ BufStream.$(cc) MsgStream.$(cc) BusAccess.$(cc) \
+ IrdaLink.$(cc)
+
+HDR = error.h IOS.h MsgBuffer.h Message.h \
+ Channel.h TimeOut.h SignalHandler.h \
+ Scheduler.h Address.h \
+ InetAddress.h UnixAddress.h IrdaAddress.h \
+ Socket.h Datagram.h Stream.h \
+ BufStream.h MsgStream.h BusAccess.h \
+ IrdaLink.h
+
+OBJ = error.o IOS.o MsgBuffer.o Message.o \
+ Channel.o TimeOut.o SignalHandler.o \
+ Scheduler.o Address.o \
+ InetAddress.o UnixAddress.o IrdaAddress.o \
+ Socket.o Datagram.o Stream.o \
+ BufStream.o MsgStream.o BusAccess.o \
+ IrdaLink.o
+
+all: libIvl.a libIvl.so.$(MAJOR).$(MINOR) headers
+
+LLIB = -L$(LOCLIB) -lUch -lDnn -lCcu
+
+libIvl.a: $(OBJ)
+ rm -f $@
+ ar q $@ $(OBJ)
+
+libIvl.so.$(MAJOR).$(MINOR): $(OBJ)
+ rm -f $@
+ $(CXX) -shared -Wl,-soname,libIvl.so.$(MAJOR) -o $@ $(OBJ) -lc
+
+headers: incldir \
+ $(LOCINCL)/ivl/IOS.h \
+ $(LOCINCL)/ivl/Channel.h \
+ $(LOCINCL)/ivl/Scheduler.h \
+ $(LOCINCL)/ivl/TimeOut.h \
+ $(LOCINCL)/ivl/SignalHandler.h \
+ $(LOCINCL)/ivl/Address.h \
+ $(LOCINCL)/ivl/UnixAddress.h \
+ $(LOCINCL)/ivl/InetAddress.h \
+ $(LOCINCL)/ivl/IrdaAddress.h \
+ $(LOCINCL)/ivl/Socket.h \
+ $(LOCINCL)/ivl/Datagram.h \
+ $(LOCINCL)/ivl/Stream.h \
+ $(LOCINCL)/ivl/MsgBuffer.h \
+ $(LOCINCL)/ivl/BufStream.h \
+ $(LOCINCL)/ivl/Message.h \
+ $(LOCINCL)/ivl/MsgStream.h \
+ $(LOCINCL)/ivl/BusAccess.h \
+ $(LOCINCL)/ivl/TextStream.h
+
+incldir:
+ test -d $(LOCINCL)/ivl || mkdirhier $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/IOS.h: IOS.h
+ cp IOS.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Channel.h: Channel.h
+ cp Channel.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Scheduler.h: Scheduler.h
+ cp Scheduler.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/TimeOut.h: TimeOut.h
+ cp TimeOut.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/SignalHandler.h: SignalHandler.h
+ cp SignalHandler.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Address.h: Address.h
+ cp Address.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/UnixAddress.h: UnixAddress.h
+ cp UnixAddress.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/InetAddress.h: InetAddress.h
+ cp InetAddress.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/IrdaAddress.h: IrdaAddress.h
+ cp IrdaAddress.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Socket.h: Socket.h
+ cp Socket.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Datagram.h: Datagram.h
+ cp Datagram.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Stream.h: Stream.h
+ cp Stream.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/MsgBuffer.h: MsgBuffer.h
+ cp MsgBuffer.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/BufStream.h: BufStream.h
+ cp BufStream.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/Message.h: Message.h
+ cp Message.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/MsgStream.h: MsgStream.h
+ cp MsgStream.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/BusAccess.h: BusAccess.h
+ cp BusAccess.h $(LOCINCL)/ivl
+
+$(LOCINCL)/ivl/TextStream.h: TextStream.h
+ cp TextStream.h $(LOCINCL)/ivl
+
+
+install:
+ test -d $(PREFIX)/usr/include/ivl || mkdirhier $(PREFIX)/usr/include/ivl
+ for f in `find $(LOCINCL)/ivl/*.h -type f -maxdepth 1`; do \
+ install -m 644 $$f $(PREFIX)/usr/include/ivl; \
+ done
+ test -d $(PREFIX)/usr/lib || mkdirhier $(PREFIX)/usr/lib
+ install -m 644 libIvl.a $(PREFIX)/usr/lib
+ install -m 644 libIvl.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib
+ ln -s /usr/lib/libIvl.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib/libIvl.so.$(MAJOR)
+ ln -s /usr/lib/libIvl.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib/libIvl.so
+
+
+
+clean:
+ rm -f *.o libIvl.a libIvl.so.$(MAJOR).$(MINOR) $(TESTS)
+
+
+testbus: testbus.$(cc) $(SRC) libIvl.a
+ $(CXX) -I$(LOCINCL) -I$(LOCINCL)/ivl -o $@ $@.$(cc) -L. -L../dnn -L../comm -lIvl -lIvlDnn -lIvlUtils
+
+testirda: testirda.$(cc) $(SRC) libIvl.a
+ $(CXX) $(CXXFLAGS) -o $@ $@.$(cc) -L. -L../dnn -L../comm -lIvl -lIvlDnn -lIvlUtils
+
diff --git a/comm/Message.cc b/comm/Message.cc
index fea0d80..50b9ac1 100644
--- a/comm/Message.cc
+++ b/comm/Message.cc
@@ -18,19 +18,19 @@
#include "MsgStream.h"
#include "IOS.h"
-/*?class UchMessage
-\typ{UchMessage} is the abstract base class for messages.
+/*?class IvlMessage
+\typ{IvlMessage} is the abstract base class for messages.
Each subclass must redefine the virtual functions \fun{WriteTo} and \fun{ReadFrom},
so that messages can be added to and retrieved from buffers.
?*/
/*?nodoc?*/
-UchMessage :: UchMessage ()
+IvlMessage :: IvlMessage ()
{
}
/*?nodoc?*/
-UchMessage :: ~UchMessage ()
+IvlMessage :: ~IvlMessage ()
{
}
@@ -39,12 +39,12 @@ This virtual function must write a message into a buffer.
Usually, the implementation of this function in a derived class starts by calling
the same function of its base class, because a derived class inherits the fields
of its base class and adds its own fields.
-Data is usually appended to the buffer by the \fun{UchMsgBuffer::Append}
+Data is usually appended to the buffer by the \fun{IvlMsgBuffer::Append}
functions or \fun{operator $<<$}.
The default implementation does nothing.
?*/
void
-UchMessage :: WriteTo (UchIOS&)
+IvlMessage :: WriteTo (IvlIOS&)
{
}
@@ -54,12 +54,12 @@ At most \var{len} bytes should be read from the buffer.
Usually, the implementation of this function in a derived class starts by calling
the same function of its base class, because a derived class inherits the fields
of its base class and adds its own fields.
-Data is usually retrieved from the buffer by the \fun{UchMsgBuffer::Get}
+Data is usually retrieved from the buffer by the \fun{IvlMsgBuffer::Get}
functions or \fun{operator $>>$}.
The default implementation does nothing.
?*/
void
-UchMessage :: ReadFrom (UchIOS&, lword)
+IvlMessage :: ReadFrom (IvlIOS&, lword)
{
}
@@ -70,14 +70,14 @@ after they have been loaded from a buffer.
In this case an answer must be sent back with \fun{Reply}.
Messages can be sent before replying; they will be buffered by the receiver for later processing.
But you cannot use \fun{Ask} before replying.
-In the class \typ{UchMessage} this function does nothing and returns true;
+In the class \typ{IvlMessage} this function does nothing and returns true;
if \var{ask} is true, it replies immediately with an empty message.
?*/
bool
-UchMessage :: Activate (UchMsgStream& s, bool ask)
+IvlMessage :: Activate (IvlMsgStream& s, bool ask)
{
if (ask) {
- UchMessage dummy;
+ IvlMessage dummy;
s.Reply (dummy);
}
return true;
diff --git a/comm/Message.h b/comm/Message.h
index c838286..b7d711d 100644
--- a/comm/Message.h
+++ b/comm/Message.h
@@ -10,24 +10,25 @@
*
* $Id$
* $CurLog$
+ * Removed global.h
*/
#ifndef Message_H_
#define Message_H_
#include "cplus_bugs.h"
-#include "ccu/bool.h"
-#include "ccu/word.h"
-class UchIOS;
-class UchMsgStream;
+#include "ivl/bool.h"
+#include "ivl/word.h"
+class IvlIOS;
+class IvlMsgStream;
-class UchMessage {
+class IvlMessage {
public:
- UchMessage ();
-virtual ~UchMessage ();
-virtual void WriteTo (UchIOS&);
-virtual void ReadFrom (UchIOS&, lword);
-virtual bool Activate (UchMsgStream&, bool);
+ IvlMessage ();
+virtual ~IvlMessage ();
+virtual void WriteTo (IvlIOS&);
+virtual void ReadFrom (IvlIOS&, lword);
+virtual bool Activate (IvlMsgStream&, bool);
};
#endif /* Message_H_ */
diff --git a/comm/MsgBuffer.cc b/comm/MsgBuffer.cc
index 225c764..55cec65 100644
--- a/comm/MsgBuffer.cc
+++ b/comm/MsgBuffer.cc
@@ -14,7 +14,7 @@
#include "MsgBuffer.h"
#include "Message.h"
-#include "ccu/String.h"
+#include "ivl/String.h"
#include <stdlib.h>
#include <string.h>
@@ -23,15 +23,15 @@
// management of buffers
// The buffer is said to be allocated if Begin is non zero.
// There is a special constructor that builds an allocated buffer with Begin = 0 :
-// UchMsgBuffer (UchMsgBuffer&, int len)
+// IvlMsgBuffer (IvlMsgBuffer&, int len)
// This buffer can only be read from and flushed
// This is useful for creating a fake buffer that is actually a pointer to
// a subpart of the original one. Thus, the new buffer can be safely read from
// without eating too far away
//
-/*?class UchMsgBuffer
-A \typ{UchMsgBuffer} is an array of bytes of a given size that can be partially filled.
+/*?class IvlMsgBuffer
+A \typ{IvlMsgBuffer} is an array of bytes of a given size that can be partially filled.
The buffer may grow whenever bytes are appended to it.
The initial size, the increments and the maximum sizes can be defined.
If the buffer exceeds its maximal size, it will be deleted when it becomes empty
@@ -54,8 +54,8 @@ Construct an empty buffer.
The buffer will be allocated with a default size whenever data is appended to it.
This default size is currently 128 bytes.
?*/
-UchMsgBuffer :: UchMsgBuffer ()
-: UchIOS ()
+IvlMsgBuffer :: IvlMsgBuffer ()
+: IvlIOS ()
{
Begin = Start = Stop = End = 0;
GetErr = false;
@@ -66,8 +66,8 @@ UchMsgBuffer :: UchMsgBuffer ()
/*?
Construct a buffer with \var{sz} bytes.
?*/
-UchMsgBuffer :: UchMsgBuffer (int sz)
-: UchIOS ()
+IvlMsgBuffer :: IvlMsgBuffer (int sz)
+: IvlIOS ()
{
MinSize = GrowSize = sz = pad (sz);
Begin = Start = Stop = new byte [sz];
@@ -80,8 +80,8 @@ UchMsgBuffer :: UchMsgBuffer (int sz)
Construct a buffer with minimum \var{sz} bytes, growing by \var{grow} bytes,
until a maximum size of \var{max} bytes.
?*/
-UchMsgBuffer :: UchMsgBuffer (int sz, int grow, int max)
-: UchIOS ()
+IvlMsgBuffer :: IvlMsgBuffer (int sz, int grow, int max)
+: IvlIOS ()
{
MinSize = sz = pad (sz);
Begin = Start = Stop = new byte [sz];
@@ -102,8 +102,8 @@ Note that the contents of the fake buffer can be overwritten if you read and the
the original buffer.
The rule of thumb is to avoid modifying the original buffer while there is a fake buffer on it.
?*/
-UchMsgBuffer :: UchMsgBuffer (const UchMsgBuffer& b, int l)
-: UchIOS (b)
+IvlMsgBuffer :: IvlMsgBuffer (const IvlMsgBuffer& b, int l)
+: IvlIOS (b)
{
Begin = 0;
Start = b.Start;
@@ -118,7 +118,7 @@ UchMsgBuffer :: UchMsgBuffer (const UchMsgBuffer& b, int l)
}
/*?nodoc?*/
-UchMsgBuffer :: ~UchMsgBuffer ()
+IvlMsgBuffer :: ~IvlMsgBuffer ()
{
Clear ();
}
@@ -129,7 +129,7 @@ The buffer can still be used after this function has been called (it will reallo
The destructor calls this function.
?*/
void
-UchMsgBuffer :: Clear ()
+IvlMsgBuffer :: Clear ()
{
if (Begin)
delete Begin;
@@ -137,11 +137,11 @@ UchMsgBuffer :: Clear ()
}
/*?
-Insure that a UchMsgBuffer.has at least \var{sz} free bytes.
+Insure that a IvlMsgBuffer.has at least \var{sz} free bytes.
The buffer may be reallocated with a new size to provide the necessary space.
?*/
void
-UchMsgBuffer :: NeedSize (int sz)
+IvlMsgBuffer :: NeedSize (int sz)
{
// brand new buffer
if (! Begin) {
@@ -183,9 +183,9 @@ Discard the \var{n} first bytes of a buffer, or the whole buffer if \var{n} is n
If the buffer becomes empty and had exceeded its maximum size, it is reset.
?*/
void
-UchMsgBuffer :: Flush (int n)
+IvlMsgBuffer :: Flush (int n)
{
-//printf ("UchMsgBuffer %x : Flush (%d)\n", this, n);
+//printf ("IvlMsgBuffer %x : Flush (%d)\n", this, n);
if (! Begin)
if (! End) // ! Begin && End => fake buffer
return;
@@ -205,7 +205,7 @@ This can be used when the buffer has been accessed through \fun{Buffer ()}
and you want to flush until a given position in the buffer.
?*/
void
-UchMsgBuffer :: Flush (byte* p)
+IvlMsgBuffer :: Flush (byte* p)
{
if (p >= Start && p <= Stop)
Flush (p - Start);
@@ -222,7 +222,7 @@ Note that the buffer can always grow as big as necessary to hold the appended da
the maximum size is only used to reallocate the buffer whenever it becomes empty.
?*/
void
-UchMsgBuffer :: SetSizes (int min, int grow, int max)
+IvlMsgBuffer :: SetSizes (int min, int grow, int max)
{
if (min >= 0)
MinSize = pad (min);
@@ -244,7 +244,7 @@ Append the \var{n} first bytes of \var{buf} to the buffer.
All append functions call \fun{NeedSize} so that appending always succeeds.
?*/
void
-UchMsgBuffer :: WriteBuf (const byte* buf, int n)
+IvlMsgBuffer :: WriteBuf (const byte* buf, int n)
{
GetErr = false;
if (! Begin || End - Stop < n)
@@ -255,7 +255,7 @@ UchMsgBuffer :: WriteBuf (const byte* buf, int n)
/*?nextdoc?*/
void
-UchMsgBuffer :: WriteByte (byte b)
+IvlMsgBuffer :: WriteByte (byte b)
{
GetErr = false;
if (! Begin || End - Stop < 1)
@@ -263,17 +263,16 @@ UchMsgBuffer :: WriteByte (byte b)
*Stop++ = b;
}
-
/*?nextdoc?*/
void
-UchMsgBuffer :: WriteChar (char c)
+IvlMsgBuffer :: WriteChar (char c)
{
WriteByte ((byte) c);
}
/*?nextdoc?*/
void
-UchMsgBuffer :: WriteLong (lword l)
+IvlMsgBuffer :: WriteLong (lword l)
{
WriteBuf ((const byte*)&l, lwsize);
}
@@ -283,14 +282,13 @@ Append a short word, a long word, a byte or a character to a buffer.
The buffer is extended as necessary.
?*/
void
-UchMsgBuffer :: WriteShort (sword s)
+IvlMsgBuffer :: WriteShort (sword s)
{
WriteBuf ((const byte*)&s, swsize);
}
-
void
-UchMsgBuffer :: WriteString (const char* s)
+IvlMsgBuffer :: WriteString (const char* s)
{
Append (s);
}
@@ -301,7 +299,7 @@ If the second argument is \var{true}, the terminating null byte is appended, els
If the string is the null pointer, nothing is appended to the buffer.
?*/
void
-UchMsgBuffer :: Append (const char* s, bool nullbyte)
+IvlMsgBuffer :: Append (const char* s, bool nullbyte)
{
if (! s)
return;
@@ -319,7 +317,7 @@ The virtual function \fun{WriteTo} of the buffer is called.
The length of the message is automatically computed and prepended to the message itself.
?*/
void
-UchMsgBuffer :: WriteMsg (UchMessage& msg)
+IvlMsgBuffer :: WriteMsg (IvlMessage& msg)
{
GetErr = false;
@@ -343,12 +341,11 @@ UchMsgBuffer :: WriteMsg (UchMessage& msg)
memcpy (p, &len, lwsize);
}
-
//----- get operations
//
bool
-UchMsgBuffer :: GetBuf (byte* b, int n, bool peek, int offset)
+IvlMsgBuffer :: GetBuf (byte* b, int n, bool peek, int offset)
{
if (GetErr)
return false;
@@ -364,10 +361,8 @@ UchMsgBuffer :: GetBuf (byte* b, int n, bool peek, int offset)
return true;
}
-
-
int
-UchMsgBuffer :: GetString (char* str, int n, const char* delim, bool peek, int offset)
+IvlMsgBuffer :: GetString (char* str, int n, const char* delim, bool peek, int offset)
{
if (GetErr)
return 0;
@@ -400,24 +395,23 @@ UchMsgBuffer :: GetString (char* str, int n, const char* delim, bool peek, int o
return i;
}
-
/*?nextdoc?*/
bool
-UchMsgBuffer :: ReadLong (lword& l)
+IvlMsgBuffer :: ReadLong (lword& l)
{
return GetBuf ((byte*) &l, lwsize, false);
}
/*?nextdoc?*/
bool
-UchMsgBuffer :: ReadShort (sword& s)
+IvlMsgBuffer :: ReadShort (sword& s)
{
return GetBuf ((byte*) &s, swsize, false);
}
/*?nextdoc?*/
bool
-UchMsgBuffer :: ReadByte (byte& b)
+IvlMsgBuffer :: ReadByte (byte& b)
{
return GetBuf (&b, 1, false);
}
@@ -428,17 +422,17 @@ Return true if the data was actually extracted, else return false and mark the b
If \var{peek} is true, the buffer is not flushed after extracting the data.
?*/
bool
-UchMsgBuffer :: ReadChar (char& c)
+IvlMsgBuffer :: ReadChar (char& c)
{
return GetBuf ((byte*) &c, 1, false);
}
/*?
-Extract a string from a buffer and copy it to a \typ{CcuString}.
+Extract a string from a buffer and copy it to a \typ{IvlString}.
This assumes that the string in the buffer is null-terminated.
?*/
int
-UchMsgBuffer :: ReadString (CcuString& s)
+IvlMsgBuffer :: ReadString (IvlString& s)
{
if (GetErr)
return 0;
@@ -463,14 +457,14 @@ If \var{peek} is true, the buffer is not flushed after extracting the data
?*/
bool
-UchMsgBuffer :: ReadBuf (byte* b, int n)
+IvlMsgBuffer :: ReadBuf (byte* b, int n)
{
return GetBuf (b, n, false);
}
/*?nextdoc?*/
int
-UchMsgBuffer :: ReadString (char* str, char delim, int n)
+IvlMsgBuffer :: ReadString (char* str, char delim, int n)
{
char ds [2];
ds [0] = delim;
@@ -480,7 +474,7 @@ UchMsgBuffer :: ReadString (char* str, char delim, int n)
/*?nextdoc?*/
int
-UchMsgBuffer :: ReadString (char* str, int n)
+IvlMsgBuffer :: ReadString (char* str, int n)
{
return GetString (str, n, 0, false);
}
@@ -493,21 +487,21 @@ The number of characters actually transferred is returned.
\var{str} is always terminated by a null character.
?*/
int
-UchMsgBuffer :: ReadString (char* str, const char* ds, int n)
+IvlMsgBuffer :: ReadString (char* str, const char* ds, int n)
{
return GetString (str, n, ds, false);
}
/*?
Get a message from the buffer.
-The message must be prefixed by its length, as done by \fun{Append(UchMessage*)}.
+The message must be prefixed by its length, as done by \fun{Append(IvlMessage*)}.
The virtual function \fun{ReadFrom} of the message is called to convert the buffer into a message.
If there is not enough data in the buffer, false is returned.
If \fun{ReadFrom} reads past the end of the message,
false is returned and the get error flag is set.
?*/
bool
-UchMsgBuffer :: ReadMsg (UchMessage& msg)
+IvlMsgBuffer :: ReadMsg (IvlMessage& msg)
{
if (GetErr || (Stop - Start < lwsize))
return false;
@@ -539,27 +533,25 @@ UchMsgBuffer :: ReadMsg (UchMessage& msg)
}
}
-
-
//------ peek operations
/*?nextdoc?*/
bool
-UchMsgBuffer :: PeekByte (byte& b, int offset)
+IvlMsgBuffer :: PeekByte (byte& b, int offset)
{
return GetBuf (&b, 1, true, offset);
}
/*?nextdoc?*/
bool
-UchMsgBuffer :: PeekShort (sword& sw, int offset)
+IvlMsgBuffer :: PeekShort (sword& sw, int offset)
{
return GetBuf ((byte*) &sw, swsize, true, offset);
}
/*?nextdoc?*/
bool
-UchMsgBuffer :: PeekLong (lword& lw, int offset)
+IvlMsgBuffer :: PeekLong (lword& lw, int offset)
{
return GetBuf ((byte*) &lw, lwsize, true, offset);
}
@@ -570,13 +562,13 @@ at \var{offset} bytes from the start of the buffer.
They return false if the data to peek falls outside the buffer, else true.
?*/
bool
-UchMsgBuffer :: PeekBuf (byte* b, int n, int offset)
+IvlMsgBuffer :: PeekBuf (byte* b, int n, int offset)
{
return GetBuf (b, n, true, offset);
}
int
-UchMsgBuffer :: PeekString (CcuString& s, int offset)
+IvlMsgBuffer :: PeekString (IvlString& s, int offset)
{
if (GetErr)
return 0;
@@ -594,7 +586,7 @@ UchMsgBuffer :: PeekString (CcuString& s, int offset)
/*?nextdoc?*/
int
-UchMsgBuffer :: PeekString (char* str, int n, char delim, int offset)
+IvlMsgBuffer :: PeekString (char* str, int n, char delim, int offset)
{
char ds [2];
ds [0] = delim;
@@ -610,12 +602,11 @@ The number of characters actually transferred is returned.
\var{str} is always terminated by a null character.
?*/
int
-UchMsgBuffer :: PeekString (char* str, int n, const char* delim, int offset)
+IvlMsgBuffer :: PeekString (char* str, int n, const char* delim, int offset)
{
return GetString (str, n, delim, true, offset);
}
-
//----- miscellaneous
//
@@ -633,7 +624,7 @@ if (nb > 0)
\end{ccode}
?*/
void
-UchMsgBuffer :: More (int n)
+IvlMsgBuffer :: More (int n)
{
GetErr = false;
if (End) // Begin == 0 for fake buffers
@@ -646,7 +637,7 @@ This is useful to remove erroneous data that has just been appended to the buffe
This is in some sense the reverse operation of \fun{More}.
?*/
void
-UchMsgBuffer :: Discard (int n)
+IvlMsgBuffer :: Discard (int n)
{
if (! Begin)
if (! End) // ! Begin && End => fake buffer
@@ -666,7 +657,7 @@ UchMsgBuffer :: Discard (int n)
/*?nextdoc?*/
byte*
-UchMsgBuffer :: Buffer ()
+IvlMsgBuffer :: Buffer ()
{ }
/*?
@@ -681,12 +672,12 @@ if (n > 0)
\end{ccode}
?*/
int
-UchMsgBuffer :: BufLength ()
+IvlMsgBuffer :: BufLength ()
{ }
/*?nextdoc?*/
byte*
-UchMsgBuffer :: Free ()
+IvlMsgBuffer :: Free ()
{ }
/*?
@@ -695,7 +686,7 @@ This may be used in conjunction with \fun{NeedSize} and \fun{More}
to append data to the buffer.
?*/
int
-UchMsgBuffer :: FreeLength ()
+IvlMsgBuffer :: FreeLength ()
{ }
/*?
@@ -703,7 +694,7 @@ Grow the buffer if its free size is less than its grow size.
This function can be called when a buffer is full.
?*/
void
-UchMsgBuffer :: Grow ()
+IvlMsgBuffer :: Grow ()
{ }
/*?
@@ -712,13 +703,13 @@ The type of the data can be a long word, a short word, a byte, a character, or a
for strings, the null character is included.
The operator returns the buffer so that several items can be added.
?*/
-UchMsgBuffer&
-UchMsgBuffer :: operator << (type data)
+IvlMsgBuffer&
+IvlMsgBuffer :: operator << (type data)
{ }
/*?nextdoc?*/
-UchMsgBuffer&
-UchMsgBuffer :: operator >> (type* data)
+IvlMsgBuffer&
+IvlMsgBuffer :: operator >> (type* data)
{ }
/*?
@@ -727,13 +718,13 @@ The type of the data can be a long word, a short word, a byte, or a character.
The operator returns the buffer so that several items can be read.
Errors can be tested by the functions \fun{Error} and \fun{Ok}.
?*/
-UchMsgBuffer&
-UchMsgBuffer :: operator >> (type& data)
+IvlMsgBuffer&
+IvlMsgBuffer :: operator >> (type& data)
{ }
/*?nextdoc?*/
bool
-UchMsgBuffer :: Error ()
+IvlMsgBuffer :: Error ()
{ }
/*?
@@ -742,7 +733,7 @@ Test the state of the buffer, as set by the get functions.
\fun{Ok} is the negation of \fun{Error}.
?*/
bool
-UchMsgBuffer :: Ok ()
+IvlMsgBuffer :: Ok ()
{ }
/*?
@@ -751,7 +742,7 @@ The error flag is automatically reset by the functions \fun{Append} and \fun{Mor
and by \fun{operator $<<$}.
?*/
void
-UchMsgBuffer :: ResetError ()
+IvlMsgBuffer :: ResetError ()
{ }
#endif /* DOC */
diff --git a/comm/MsgBuffer.h b/comm/MsgBuffer.h
index 442787e..24d201a 100644
--- a/comm/MsgBuffer.h
+++ b/comm/MsgBuffer.h
@@ -10,23 +10,25 @@
*
* $Id$
* $CurLog$
+ * Removed smart pointers
+ * Removed global.h
*/
#ifndef Buffer_H_
#define Buffer_H_
#include "cplus_bugs.h"
-#include "ccu/bool.h"
-#include "ccu/word.h"
+#include "ivl/bool.h"
+#include "ivl/word.h"
#include "IOS.h"
-class CcuString;
-class UchMessage;
+class IvlString;
+class IvlMessage;
// Buffer is the buffer itself, End points after its last byte
// Start and Stop limit its content
// a buffer grows and shrinks automatically
//
-class UchMsgBuffer : public UchIOS {
+class IvlMsgBuffer : public IvlIOS {
protected:
byte* Begin;
byte* Start;
@@ -39,11 +41,11 @@ protected:
int GetString (char*, int, const char*, bool, int = 0);
public:
- UchMsgBuffer ();
- UchMsgBuffer (int);
- UchMsgBuffer (int, int, int);
- UchMsgBuffer (const UchMsgBuffer&, int = 0); // construct a fake buffer
- ~UchMsgBuffer ();
+ IvlMsgBuffer ();
+ IvlMsgBuffer (int);
+ IvlMsgBuffer (int, int, int);
+ IvlMsgBuffer (const IvlMsgBuffer&, int = 0); // construct a fake buffer
+ ~IvlMsgBuffer ();
void Clear ();
void NeedSize (int n);
@@ -67,11 +69,11 @@ public:
int ReadString (char*, const char*, int = -1);
int ReadString (char*, char, int = -1);
int ReadString (char*, int = -1);
- int ReadString (CcuString&);
- bool ReadMsg (UchMessage&);
+ int ReadString (IvlString&);
+ bool ReadMsg (IvlMessage&);
void Append (const char*, bool = true);
- void WriteMsg (UchMessage&);
+ void WriteMsg (IvlMessage&);
bool PeekByte (byte&, int = 0);
bool PeekShort (sword&, int = 0);
@@ -79,7 +81,7 @@ public:
bool PeekBuf (byte*, int, int = 0);
int PeekString (char*, int=-1, const char* = 0, int = 0);
int PeekString (char*, int, char, int = 0);
- int PeekString (CcuString&, int = 0);
+ int PeekString (IvlString&, int = 0);
byte* Buffer () { return Start; }
int BufLength () { return Stop - Start; }
@@ -93,12 +95,12 @@ public:
void ResetError () { GetErr = false; }
#ifdef DOC
- UchMsgBuffer& operator << (type data);
- UchMsgBuffer& operator >> (type& data);
- UchMsgBuffer& operator >> (type* data);
+ IvlMsgBuffer& operator << (type data);
+ IvlMsgBuffer& operator >> (type& data);
+ IvlMsgBuffer& operator >> (type* data);
#endif
-friend UchMsgBuffer& DbgPrint (UchMsgBuffer&, int);
+friend IvlMsgBuffer& DbgPrint (IvlMsgBuffer&, int);
};
#endif /* Buffer_H_ */
diff --git a/comm/MsgStream.cc b/comm/MsgStream.cc
index 3a84eba..52d8623 100644
--- a/comm/MsgStream.cc
+++ b/comm/MsgStream.cc
@@ -16,9 +16,8 @@
#include "Message.h"
#include "error.h"
-
-/*?class UchMsgStream
-An object of class \typ{UchMsgStream} is a stream that sends and receives messages:
+/*?class IvlMsgStream
+An object of class \typ{IvlMsgStream} is a stream that sends and receives messages:
we call it a message stream.
Messages are sent with the function \fun{Send}.
@@ -26,7 +25,7 @@ Output messages are normally buffered to increase performance, but synchronous m
The output buffer can be flushed by the application, or by the stream itself if needed
(for instance when the buffer is full, or when a synchronous communication is needed).
-Incoming messages are handled by the virtual function \fun{HandleRead} of class \typ{UchChannel}:
+Incoming messages are handled by the virtual function \fun{HandleRead} of class \typ{IvlChannel}:
it is redefined so that incoming bytes are packed into messages.
When a full message is available, \fun{HandleRead} calls the virtual
function \fun{DecodeMessage} that instantiates a message, then calls the virtual function \fun{Activate} for that
@@ -57,7 +56,7 @@ The output mode can be switched to a synchronous mode where each message is sent
% This is mainly useful for debugging purposes.
\medskip
-To use a message stream, a program needs to derive the class \typ{UchMsgStream}
+To use a message stream, a program needs to derive the class \typ{IvlMsgStream}
in order to redefine the virtual functions \fun{DecodeMessage} and \fun{DecodeAnswer}.
\fun{DecodeMessage} treats the incoming message, and will probably call \fun{Send} and \fun{Ask}.
The top level of the program needs just call \fun{HandleRead} in a forever loop.
@@ -65,13 +64,13 @@ The top level of the program needs just call \fun{HandleRead} in a forever loop.
Most of the time, a program will use several message streams
(for instance to manage several clients).
In this case a channel set is the best way to implement the application:
-the definitions in the class \typ{UchMsgStream} of the functions
+the definitions in the class \typ{IvlMsgStream} of the functions
\fun{HandleRead}, \fun{HandleWrite} and \fun{HandleSelect} make it easy
-to use this class in combination with the class \typ{UchMultiplexer}.
+to use this class in combination with the class \typ{IvlMultiplexer}.
The virtual function \fun{HandeWrite} of channels is redefined to flush the output buffer.
The virtual function \fun{HandleSelect} of channels is redefined to handle the incoming messages
that were buffered while waiting for an answer.
-As for the single stream situation, you need just derive the class \fun{UchMsgStream} to
+As for the single stream situation, you need just derive the class \fun{IvlMsgStream} to
redefine the virtual functions \fun{DecodeMessage} and \fun{DecodeAnswer}.
?*/
@@ -79,10 +78,10 @@ redefine the virtual functions \fun{DecodeMessage} and \fun{DecodeAnswer}.
// ---- no locked sync mode ...
/*?
-These constructors are similar to those of class \typ{UchSocket}.
+These constructors are similar to those of class \typ{IvlSocket}.
?*/
-UchMsgStream :: UchMsgStream (UchAddress* bindTo, UchAddress* connectTo)
-: UchBufStream (bindTo, connectTo),
+IvlMsgStream :: IvlMsgStream (IvlAddress* bindTo, IvlAddress* connectTo)
+: IvlBufStream (bindTo, connectTo),
Buffered ()
{
State = WAITING;
@@ -92,27 +91,26 @@ UchMsgStream :: UchMsgStream (UchAddress* bindTo, UchAddress* connectTo)
// *** this copy constructor might be automatically generated
/*?nodoc?*/
-UchMsgStream :: UchMsgStream (const UchMsgStream& ms)
-: UchBufStream (ms), Buffered (*(UchMsgBuffer*)&ms.Buffered)
+IvlMsgStream :: IvlMsgStream (const IvlMsgStream& ms)
+: IvlBufStream (ms), Buffered (*(IvlMsgBuffer*)&ms.Buffered)
{
State = ms.State;
BufferedMessages = ms.BufferedMessages;
WaitingReply = ms.WaitingReply;
}
-
/*?nodoc?*/
-UchMsgStream :: ~UchMsgStream ()
+IvlMsgStream :: ~IvlMsgStream ()
{
Buffered.Clear ();
}
#if 0
/*?nodoc?*/
-UchChannel*
-UchMsgStream :: Copy () const
+IvlChannel*
+IvlMsgStream :: Copy () const
{
- return new UchMsgStream (*this);
+ return new IvlMsgStream (*this);
}
#endif
@@ -132,8 +130,8 @@ UchMsgStream :: Copy () const
/*!
Return a message when it's been fully read.
!*/
-UchMessage*
-UchMsgStream :: Process (UchMsgBuffer& buf, bool waitAnswer)
+IvlMessage*
+IvlMsgStream :: Process (IvlMsgBuffer& buf, bool waitAnswer)
{
for (;;) {
switch (State) {
@@ -175,8 +173,8 @@ UchMsgStream :: Process (UchMsgBuffer& buf, bool waitAnswer)
case DONE:
if (waitAnswer) {
if (InType == ANS) {
- UchMsgBuffer fake (buf, InLength);
- UchMessage* ans = DecodeAnswer (fake);
+ IvlMsgBuffer fake (buf, InLength);
+ IvlMessage* ans = DecodeAnswer (fake);
buf.Flush (InLength);
State = WAITING;
return ans;
@@ -189,8 +187,8 @@ UchMsgStream :: Process (UchMsgBuffer& buf, bool waitAnswer)
} else {
if (InType == MSG || InType == ASK) {
// pass a fake buffer to the handler
- UchMsgBuffer fake (buf, InLength);
- UchMessage* msg = DecodeMessage (fake);
+ IvlMsgBuffer fake (buf, InLength);
+ IvlMessage* msg = DecodeMessage (fake);
if (! msg || !msg->Activate (*this, WaitingReply))
return 0;
// *** these returns break the assumption that
@@ -209,7 +207,7 @@ UchMsgStream :: Process (UchMsgBuffer& buf, bool waitAnswer)
/*?nodoc?*/
void
-UchMsgStream :: HandleRead ()
+IvlMsgStream :: HandleRead ()
{
if (BufferedMessages) {
Process (Buffered, false);
@@ -224,7 +222,7 @@ UchMsgStream :: HandleRead ()
#if 0
/*?nodoc?*/
bool
-UchMsgStream :: HandleSelect ()
+IvlMsgStream :: HandleSelect ()
{
if (BufferedMessages) {
Process (Buffered, false);
@@ -238,13 +236,13 @@ UchMsgStream :: HandleSelect ()
This virtual function is called whenever a complete message is in the buffer.
The buffer contains exactly one message, so that you can use \com{buf.ReadMsg (msg)}
to extract the message from the buffer.
-\fun{DecodeMessage} must return the extracted message. The default version returns a dummy \typ{UchMessage}.
+\fun{DecodeMessage} must return the extracted message. The default version returns a dummy \typ{IvlMessage}.
If it returns false, it will be called again with the same arguments next time data arrives on this channel.
The function \typ{MyClient}::\fun{DecodeMessage}
may look like:
\begin{ccode}
-UchMessage*
-MyClient :: DecodeMessage (UchMsgBuffer& buffer)
+IvlMessage*
+MyClient :: DecodeMessage (IvlMsgBuffer& buffer)
{
MyRequest* m = 0;
lword type;
@@ -263,10 +261,10 @@ MyClient :: DecodeMessage (UchMsgBuffer& buffer)
}
\end{ccode}
?*/
-UchMessage*
-UchMsgStream :: DecodeMessage (UchMsgBuffer&)
+IvlMessage*
+IvlMsgStream :: DecodeMessage (IvlMsgBuffer&)
{
- return new UchMessage;
+ return new IvlMessage;
}
/*?
@@ -276,7 +274,7 @@ This also happens when the message stream is in synchronous mode,
or if the output buffer has exceeded its flush size (see \fun{FlushSize}).
?*/
void
-UchMsgStream :: Send (UchMessage& msg, bool flush)
+IvlMsgStream :: Send (IvlMessage& msg, bool flush)
{
OutBuffer.WriteByte (MSG);
WriteMsg (msg);
@@ -285,15 +283,15 @@ UchMsgStream :: Send (UchMessage& msg, bool flush)
}
void
-UchMsgStream :: WriteMsg (UchMessage& msg)
+IvlMsgStream :: WriteMsg (IvlMessage& msg)
{
OutBuffer.WriteMsg (msg);
}
bool
-UchMsgStream :: ReadMsg (UchMessage& msg)
+IvlMsgStream :: ReadMsg (IvlMessage& msg)
{
- UchMsgBuffer& buf = BufferedMessages ? Buffered : InBuffer;
+ IvlMsgBuffer& buf = BufferedMessages ? Buffered : InBuffer;
int l = buf.BufLength (); // store current offset in the buffer
lword msglen;
buf >> msglen;
@@ -316,18 +314,18 @@ Send a message and wait for an answer.
Incoming messages that are received while waiting for the answer are kept for later processing.
The answer message is returned by calling the virtual function \fun{DecodeAnswer}.
?*/
-UchMessage*
-UchMsgStream :: Ask (UchMessage& msg)
+IvlMessage*
+IvlMsgStream :: Ask (IvlMessage& msg)
{
if (WaitingReply) {
- ::Error (ErrWarn, "UchMsgStream::Ask", "cannot ask before replying");
+ ::Error (ErrWarn, "IvlMsgStream::Ask", "cannot ask before replying");
return 0;
}
OutBuffer.WriteByte (ASK);
WriteMsg (msg);
Flush ();
- UchMessage* ans = 0;
+ IvlMessage* ans = 0;
do {
if (ReadInput () <= 0)
return 0;
@@ -341,10 +339,10 @@ UchMsgStream :: Ask (UchMessage& msg)
This function must be used instead of \fun{Send} to send a reply to a message sent by \fun{Ask}.
?*/
void
-UchMsgStream :: Reply (UchMessage& msg)
+IvlMsgStream :: Reply (IvlMessage& msg)
{
if (! WaitingReply) {
- ::Error (ErrWarn, "UchMsgStream::Reply", "out of phase reply discarded");
+ ::Error (ErrWarn, "IvlMsgStream::Reply", "out of phase reply discarded");
return;
}
OutBuffer.WriteByte ((byte) ANS);
@@ -353,13 +351,12 @@ UchMsgStream :: Reply (UchMessage& msg)
WaitingReply = false;
}
-
/*?
This function is called by \fun{Ask} when the answer is in the buffer,
in order to convert it into an object usable by the application.
?*/
-UchMessage*
-UchMsgStream :: DecodeAnswer (UchMsgBuffer&)
+IvlMessage*
+IvlMsgStream :: DecodeAnswer (IvlMsgBuffer&)
{
return 0;
}
@@ -368,14 +365,14 @@ UchMsgStream :: DecodeAnswer (UchMsgBuffer&)
Send a buffer containing a message.
If \var{flush} is true, the output buffer will be flushed.
This also happens when the message stream is in synchronous mode,
-or if the output UchMsgBuffer.has exceeded its flush size (see \fun{FlushSize}).
+or if the output IvlMsgBuffer.has exceeded its flush size (see \fun{FlushSize}).
The buffer {\em must} contain a converted message.
This can be used for instance from inside \fun{DecodeMessage} to resend
the incoming message to another client, without having to convert
the buffer to a message.
?*/
void
-UchMsgStream :: Send (UchMsgBuffer& buf, bool flush)
+IvlMsgStream :: Send (IvlMsgBuffer& buf, bool flush)
{
OutBuffer.WriteByte ((byte) MSG);
OutBuffer.WriteBuf (buf.Buffer (), buf.BufLength ());
@@ -390,12 +387,12 @@ in asynchronous mode. By default the flush size is the maximum size of the
output buffer. As a consequence, it is changed by \fun{OutBuffer}.
?*/
void
-UchMsgStream :: FlushSize (int n)
+IvlMsgStream :: FlushSize (int n)
{ }
/*?nextdoc?*/
void
-UchMsgStream :: SetSyncMode (bool s)
+IvlMsgStream :: SetSyncMode (bool s)
{ }
/*?
@@ -406,7 +403,7 @@ because it makes more system calls to transfer data;
however synchronous mode can be useful for debugging applications.
?*/
bool
-UchMsgStream :: GetSyncMode ()
+IvlMsgStream :: GetSyncMode ()
{ }
#endif /* DOC */
diff --git a/comm/MsgStream.h b/comm/MsgStream.h
index 7660ae8..d3e613e 100644
--- a/comm/MsgStream.h
+++ b/comm/MsgStream.h
@@ -16,35 +16,35 @@
#define MsgStream_H_
#include "BufStream.h"
-class UchMessage;
+class IvlMessage;
-class UchMsgStream : public UchBufStream {
+class IvlMsgStream : public IvlBufStream {
protected:
enum STATE { WAITING, GOT_TYPE, GOT_LENGTH, DONE};
enum TYPE { MSG = 1, ASK, ANS, SYNC, ASYNC, OK };
STATE State;
bool BufferedMessages;
- UchMsgBuffer Buffered;
+ IvlMsgBuffer Buffered;
bool WaitingReply;
int InLength;
byte InType;
- UchMessage* Process (UchMsgBuffer&, bool);
- UchMsgStream (const UchMsgStream&);
- void WriteMsg (UchMessage&);
- bool ReadMsg (UchMessage&);
+ IvlMessage* Process (IvlMsgBuffer&, bool);
+ IvlMsgStream (const IvlMsgStream&);
+ void WriteMsg (IvlMessage&);
+ bool ReadMsg (IvlMessage&);
public:
- UchMsgStream (UchAddress* = 0, UchAddress* = 0);
- ~UchMsgStream ();
+ IvlMsgStream (IvlAddress* = 0, IvlAddress* = 0);
+ ~IvlMsgStream ();
void HandleRead ();
-virtual UchMessage* DecodeMessage (UchMsgBuffer&);
-virtual UchMessage* DecodeAnswer (UchMsgBuffer&);
- void Send (UchMessage&, bool = false);
- UchMessage* Ask (UchMessage&);
- void Reply (UchMessage&);
- void Send (UchMsgBuffer&, bool = false);
+virtual IvlMessage* DecodeMessage (IvlMsgBuffer&);
+virtual IvlMessage* DecodeAnswer (IvlMsgBuffer&);
+ void Send (IvlMessage&, bool = false);
+ IvlMessage* Ask (IvlMessage&);
+ void Reply (IvlMessage&);
+ void Send (IvlMsgBuffer&, bool = false);
};
#endif /* MsgStream_H_ */
diff --git a/comm/Multiplexer.cc b/comm/Scheduler.cc
index b879ce6..075c461 100644
--- a/comm/Multiplexer.cc
+++ b/comm/Scheduler.cc
@@ -10,9 +10,15 @@
*
* $Id$
* $CurLog$
+ * Amelioration de la gestion des timers dans Scan
+ * Amelioration de la gestion des timers dans LoopScan
+ * Modification du mecanisme d'ajout d'un Channel
+ * Remplacement du HandleSelect par un systeme de Hook
+ * Integration avec IvlBaseMultiplexer
+ * Meilleures verifications de NFILE, en attendant mieux
*/
-#include "Multiplexer.h"
+#include "Scheduler.h"
#include "TimeOut.h"
#include "SignalHandler.h"
@@ -38,7 +44,7 @@ extern "C" int select (int, fd_set*, fd_set*, fd_set*, struct timeval*);
extern int errno;
-UchBaseMultiplexer* UchMpx = 0;
+IvlBaseScheduler* IvlScd = 0;
#ifndef FD_SET
#ifndef NFDBITS
@@ -54,11 +60,10 @@ UchBaseMultiplexer* UchMpx = 0;
#endif
#endif
-
-/*?class UchBaseMultiplexer
-Multiplexers make it possible to handle several communication channels at the
+/*?class IvlBaseScheduler
+Schedulers make it possible to handle several communication channels at the
same time; their implementation is based on the Unix \com{select} system call
-or similar mechanisms. Multiplexers are also able to implement safe (ie. not
+or similar mechanisms. Schedulers are also able to implement safe (ie. not
interruption-based) timers and signal handlers.
Some of the channels in the set are active, others can be inactive. A
@@ -72,19 +77,19 @@ called before actually scanning. For example that's the case for a connection
with the X server, when some pending events have been buffered into the
client by the previous \fun{HandleRead} call and need to be processed.
-Multiplexers may have different implementations, depending on the
+Schedulers may have different implementations, depending on the
environment. When no other library is involved, they are simply
implemented on top of Unix. But if \uch\ channels have to be mixed
with the X Toolkit for instance, the implementation uses the
mechanisms provided by the X Toolkit to add new channels. The same
holds for Tcl/Tk or other environments. Every such implentation
-corresponds to a derived class of \typ{UchBaseMultiplexer}, which
+corresponds to a derived class of \typ{IvlBaseScheduler}, which
offers a uniform interface that hides the implementation
-differences. See the class \typ{UchMultiplexer} for a ``pure \uch''
+differences. See the class \typ{IvlScheduler} for a ``pure \uch''
implementation of multiplexers.
Note that the functions that take an integer file descriptor as
-argument can be passed a \typ{FILDES} or a \typ{UchChannel} because
+argument can be passed a \typ{FILDES} or a \typ{IvlChannel} because
the corresponding conversion operators are defined.
The way to Add/Remove a channel from a multiplexer is to call
@@ -96,24 +101,24 @@ argument for the first one.
/*?
Create an empty channel set.
?*/
-UchBaseMultiplexer :: UchBaseMultiplexer ()
-: DnnBaseMultiplexer (),
- Channels (new (UchChannel*) [NFILE]),
+IvlBaseScheduler :: IvlBaseScheduler ()
+: IvlBaseMultiplexer (),
+ Channels (new (IvlChannel*) [NFILE]),
Timers (),
ReadCount (0),
WriteCount (0),
SelectCount (0),
SigFired (false),
- Handlers (new UchBaseSignalHandler* [NSIG]),
+ Handlers (new IvlBaseScheduledHandler* [NSIG]),
NbSignals (new int [NSIG])
{
- memset (Handlers, 0, NSIG * sizeof (UchBaseSignalHandler*));
+ memset (Handlers, 0, NSIG * sizeof (IvlBaseScheduledHandler*));
memset (NbSignals, 0, NSIG * sizeof (int));
- memset (Channels, 0, NFILE * sizeof (UchChannel*));
+ memset (Channels, 0, NFILE * sizeof (IvlChannel*));
}
/*?nodoc?*/
-UchBaseMultiplexer :: ~UchBaseMultiplexer ()
+IvlBaseScheduler :: ~IvlBaseScheduler ()
{
#ifdef CPLUS_BUG4
delete [NFILE] Channels;
@@ -127,13 +132,12 @@ UchBaseMultiplexer :: ~UchBaseMultiplexer ()
Channels = 0;
}
-
/*?
This array operator returns a pointer to the channel corresponding to file descriptor \var{fd}.
If there is no such channel in this channel set, the operator returns NIL.
?*/
-UchChannel*
-UchBaseMultiplexer :: operator [] (int fd)
+IvlChannel*
+IvlBaseScheduler :: operator [] (int fd)
{
return (fd < 0 || fd >= NFILE) ? 0 : Channels [fd];
}
@@ -146,12 +150,12 @@ means that for a given file descriptor, there can be only one channel
working on it at a time.
?*/
bool
-UchBaseMultiplexer :: Add (UchChannel* chan)
+IvlBaseScheduler :: Add (IvlChannel* chan)
{
int fd = chan->FilDes ();
if (fd < 0 || fd >= NFILE)
return false;
- UchChannel* ochan = Channels [fd];
+ IvlChannel* ochan = Channels [fd];
if (ochan)
ochan->Remove ();
Channels [fd] = chan;
@@ -159,16 +163,15 @@ UchBaseMultiplexer :: Add (UchChannel* chan)
return true;
}
-
/*?
-Remove a channel from the set. This function can be passed a \var{UchChannel}.
+Remove a channel from the set. This function can be passed a \var{IvlChannel}.
?*/
bool
-UchBaseMultiplexer :: Remove (int fd)
+IvlBaseScheduler :: Remove (int fd)
{
if (fd < 0 || fd >= NFILE)
return false;
- UchChannel* ch = Channels [fd];
+ IvlChannel* ch = Channels [fd];
if (ch) {
SetMasks (fd, IONone);
Channels [fd] = 0;
@@ -182,22 +185,22 @@ This function calls \fun{Remove} for all channels of the set.
This is a way of exiting from \fun{LoopScan}.
?*/
void
-UchBaseMultiplexer :: RemoveAll ()
+IvlBaseScheduler :: RemoveAll ()
{
for (int fd = 0; fd < NFILE; fd++) {
- UchChannel* ch = Channels [fd];
+ IvlChannel* ch = Channels [fd];
if (ch)
- ch->Remove (); // Calls UchBaseMultiplexer::Remove
+ ch->Remove (); // Calls IvlBaseMultiplexer::Remove
}
}
/*?
Change the mode of a channel in the set.
Mode \var{IONone} makes the channel inactive (without removing it).
-This function can be passed a \var{UchChannel}.
+This function can be passed a \var{IvlChannel}.
?*/
void
-UchBaseMultiplexer :: SetMode (int fd, IOMODE mode)
+IvlBaseScheduler :: SetMode (int fd, IOMODE mode)
{
if (fd < 0)
return;
@@ -206,14 +209,13 @@ UchBaseMultiplexer :: SetMode (int fd, IOMODE mode)
Channels [fd] -> SetMode (mode);
}
-
/*!
-This function is called by UchSignalHandlers when a signal is
+This function is called by IvlScheduledHandlers when a signal is
received. It just stores the signal for future (and safe) handling.
!*/
/*?hidden?*/
void
-UchBaseMultiplexer :: HandleSignal (UchBaseSignalHandler& h)
+IvlBaseScheduler :: HandleSignal (IvlBaseScheduledHandler& h)
{
if (!SigFired)
AddSignalHook ();
@@ -233,12 +235,12 @@ to call implementation-dependant functions that defer the handling to
safer times.
!*/
/*
-Does not need to be defined in UchMultiplexer, because
+Does not need to be defined in IvlScheduler, because
they use the flag SigFired.
*/
/*?hidden?*/
void
-UchBaseMultiplexer :: AddSignalHook ()
+IvlBaseScheduler :: AddSignalHook ()
{
}
@@ -248,9 +250,9 @@ called when \fun{AddSignalHook} has been called and the times are safe.
!*/
/*?hidden?*/
void
-UchBaseMultiplexer :: HandleDeferredSignals ()
+IvlBaseScheduler :: HandleDeferredSignals ()
{
- CcuSignalBlocker b (AllSigs);
+ IvlSignalBlocker b (AllSigs);
int c;
for (int i = 0; i < NSIG; ++i)
if (c = NbSignals [i]) {
@@ -262,16 +264,16 @@ UchBaseMultiplexer :: HandleDeferredSignals ()
/*?hidden?*/
void
-UchBaseMultiplexer :: SetMasks (int, IOMODE)
+IvlBaseScheduler :: SetMasks (int, IOMODE)
{
}
static jmp_buf reset_run;
-class UchMpxAborter : public UchBaseSignalHandler {
+class IvlMpxAborter : public IvlBaseScheduledHandler {
public:
- UchMpxAborter (UchBaseMultiplexer& m, int s) : UchBaseSignalHandler (m, s) {}
- void DeferredHandle (int) { MyMpx.Abort (); }
+ IvlMpxAborter (IvlBaseScheduler& m, int s) : IvlBaseScheduledHandler (m, s) {}
+ void DeferredHandle (int) { MyScd.Abort (); }
};
/*?
@@ -288,13 +290,13 @@ or signals SIGINT or SIGTERM were received.\\
\end{tabular}
?*/
MPX_RES
-UchBaseMultiplexer :: Run ()
+IvlBaseScheduler :: Run ()
{
if (setjmp (reset_run))
return isMpxAborted;
- UchMpxAborter h1 (*this, SigTerm);
- UchMpxAborter h2 (*this, SigInt);
+ IvlMpxAborter h1 (*this, SigTerm);
+ IvlMpxAborter h2 (*this, SigInt);
return Loop ();
}
@@ -303,7 +305,7 @@ UchBaseMultiplexer :: Run ()
Remove all channels from the multiplexer, thus stopping it if running.
?*/
void
-UchBaseMultiplexer :: Close ()
+IvlBaseScheduler :: Close ()
{
RemoveAll ();
Looping = false;
@@ -313,14 +315,14 @@ UchBaseMultiplexer :: Close ()
Stop the multiplexer, without cleaning it.
?*/
void
-UchBaseMultiplexer :: Abort ()
+IvlBaseScheduler :: Abort ()
{
if (Looping)
longjmp (reset_run, 1);
}
-/*?class UchMultiplexer
-The class \typ{UchMultiplexer} is the default implementation of multiplexers,
+/*?class IvlScheduler
+The class \typ{IvlScheduler} is the default implementation of multiplexers,
used when there are no compatibility needs. For historical reasons, it offers
a number of additional methods.
?*/
@@ -328,8 +330,8 @@ a number of additional methods.
/*?
Build an empty multiplexer.
?*/
-UchMultiplexer :: UchMultiplexer ()
-: UchBaseMultiplexer (),
+IvlScheduler :: IvlScheduler ()
+: IvlBaseScheduler (),
TimeOut (-1),
Looping (false),
Hooks ()
@@ -341,17 +343,15 @@ UchMultiplexer :: UchMultiplexer ()
}
/*?nodoc?*/
-UchMultiplexer :: ~UchMultiplexer ()
+IvlScheduler :: ~IvlScheduler ()
{
}
-
-
// update the masks when channel fd changes its mode
//
/*?hidden?*/
void
-UchMultiplexer :: SetMasks (int fd, IOMODE mode)
+IvlScheduler :: SetMasks (int fd, IOMODE mode)
{
if (mode & IORead) {
if (! FD_ISSET (fd, &ReadMask)) {
@@ -398,7 +398,7 @@ It returns true as soon as one select handler returns true,
else it returns false when the select handlers have been called.
?*/
bool
-UchMultiplexer :: HandleSelect ()
+IvlScheduler :: HandleSelect ()
{
int fd, nfd;
@@ -423,7 +423,7 @@ UchMultiplexer :: HandleSelect ()
////// Scan should disappear anyway. Only use is in Xtv.
/*?nextdoc?*/
int
-UchMultiplexer :: Scan (bool nointr, bool poll)
+IvlScheduler :: Scan (bool nointr, bool poll)
{
fd_set rmsk, wmsk;
int nfd, ret = -1;
@@ -449,7 +449,7 @@ UchMultiplexer :: Scan (bool nointr, bool poll)
/* let's fiddle with ret to skip select if we are late with timers */
ret = -1;
if (!poll && TimeOut != -1) {
- CcuTimeStamp now;
+ IvlTimeStamp now;
Millisecond delay = TimeOut - now;
/* if delay < 0, select is unhappy */
if (delay < 0)
@@ -472,7 +472,7 @@ UchMultiplexer :: Scan (bool nointr, bool poll)
if (ret == 0) {
if (TimeOut != -1)
/* Fire might be called without reason if polling is on. Too bad... */
- CcuCoreTimer::Fire (&Timers);
+ IvlCoreTimer::Fire (&Timers);
else if (!poll)
fprintf (stderr, "select returned 0 without reason!\n");
return 0;
@@ -488,18 +488,17 @@ UchMultiplexer :: Scan (bool nointr, bool poll)
}
}
-
/* Finally, handle pending input and output */
for (fd = 0, nfd = ret; nfd; fd++) {
if (FD_ISSET (fd, &wmsk)) {
nfd--;
- UchChannel* ch = Channels [fd];
+ IvlChannel* ch = Channels [fd];
if (ch)
ch->HandleWrite ();
}
if (FD_ISSET (fd, &rmsk)) {
nfd--;
- UchChannel* ch = Channels [fd];
+ IvlChannel* ch = Channels [fd];
if (ch)
ch->HandleRead ();
}
@@ -508,10 +507,9 @@ UchMultiplexer :: Scan (bool nointr, bool poll)
return ret;
}
-
/*?
Scan the channels in the set and call the channel's handlers.
-First the select handler (\fun{UchChannel::HandleSelect}) of each channel with mode
+First the select handler (\fun{IvlChannel::HandleSelect}) of each channel with mode
\var{IOSelect} is called.
If it returns true, \fun{Scan} exits immediately, while \fun{LoopScan} loops immediately.
If no select handler returns true, the system call \fun{select} is used to poll or
@@ -536,7 +534,7 @@ it returns \var{isMpxError} when an error occured (the code is in \var{errno}),
and it returns \var{isMpxTerminated} if \fun{Stop} or \fun{Close} was called.
?*/
MPX_RES
-UchMultiplexer :: LoopScan (bool nointr)
+IvlScheduler :: LoopScan (bool nointr)
{
fd_set rmsk, wmsk;
register int nb_pending_fd, fd, fd0;
@@ -550,7 +548,7 @@ UchMultiplexer :: LoopScan (bool nointr)
#if 0
/* Then, timers */
- CcuCoreTimer::Fire (&Timers);
+ IvlCoreTimer::Fire (&Timers);
#endif
/* Then, check I/Os */
if (ReadCount == 0 && WriteCount == 0 && SelectCount == 0) {
@@ -569,7 +567,7 @@ UchMultiplexer :: LoopScan (bool nointr)
struct timeval tv;
struct timeval* timeout = 0;
if (TimeOut != -1) {
- CcuTimeStamp now;
+ IvlTimeStamp now;
Millisecond delay = TimeOut - now;
if (delay < 0)
nb_pending_fd = 0;
@@ -584,7 +582,7 @@ UchMultiplexer :: LoopScan (bool nointr)
/* Handle time out */
if (nb_pending_fd == 0) {
if (TimeOut != -1)
- CcuCoreTimer::Fire (&Timers);
+ IvlCoreTimer::Fire (&Timers);
else
fprintf (stderr, "select returned 0 without reason!\n");
continue;
@@ -626,7 +624,7 @@ UchMultiplexer :: LoopScan (bool nointr)
/*?nodoc?*/
char*
-UchMultiplexer :: StrRepr (char* buf)
+IvlScheduler :: StrRepr (char* buf)
{
sprintf (buf, "R:%ux W:%ux", ReadMask, WriteMask);
return buf;
@@ -634,36 +632,34 @@ UchMultiplexer :: StrRepr (char* buf)
/*?hidden?*/
void
-UchMultiplexer :: SetTimeOut (Millisecond delay)
+IvlScheduler :: SetTimeOut (Millisecond delay)
{
- CcuTimeStamp now;
+ IvlTimeStamp now;
TimeOut = now + delay;
}
/*?hidden?*/
void
-UchMultiplexer :: SuppressTimeOut ()
+IvlScheduler :: SuppressTimeOut ()
{
TimeOut = -1;
}
/*?hidden?*/
MPX_RES
-UchMultiplexer :: Loop ()
+IvlScheduler :: Loop ()
{
return LoopScan ();
}
-
void
-UchMultiplexer :: Stop ()
+IvlScheduler :: Stop ()
{
Looping = false;
}
-
void
-UchMultiplexer :: AddHook (UchMpxHook* h, bool final)
+IvlScheduler :: AddHook (IvlMpxHook* h, bool final)
{
Hooks.Append ((void*) h);
if (final)
@@ -671,7 +667,7 @@ UchMultiplexer :: AddHook (UchMpxHook* h, bool final)
}
void
-UchMultiplexer :: RemoveHook (UchMpxHook* h, bool final)
+IvlScheduler :: RemoveHook (IvlMpxHook* h, bool final)
{
Hooks.Remove ((void*) h);
if (final)
@@ -679,44 +675,45 @@ UchMultiplexer :: RemoveHook (UchMpxHook* h, bool final)
}
void
-UchMultiplexer :: AddFinalHook (UchMpxHook* h)
+IvlScheduler :: AddFinalHook (IvlMpxHook* h)
{
FinalHooks.Append ((void*) h);
}
void
-UchMultiplexer :: RemoveFinalHook (UchMpxHook* h)
+IvlScheduler :: RemoveFinalHook (IvlMpxHook* h)
{
FinalHooks.Remove ((void*) h);
}
-
void
-UchMultiplexer :: ExecHooks (bool final)
+IvlScheduler :: ExecHooks (bool final)
{
- CcuList* hooks = final ? &FinalHooks : &Hooks;
- CcuListIter li = *hooks;
+ IvlList* hooks = final ? &FinalHooks : &Hooks;
+ IvlListIter li = *hooks;
while (++li) {
- UchMpxHook* h = (UchMpxHook*) *li;
+ IvlMpxHook* h = (IvlMpxHook*) *li;
(*h)();
}
}
void
-UchOpen (UchBaseMultiplexer* m)
+IvlOpen (IvlBaseScheduler* m)
{
- UchMpx = m ? m : new UchMultiplexer;
- DnnMpx = UchMpx;
+ IvlScd = m ? m : new IvlScheduler;
+ IvlMpx = IvlScd;
}
+#if 0 /* rendu inutile par la fusion avec DNN ? */
MPX_RES
-UchLoop ()
+IvlLoop ()
{
- return UchMpx->Loop ();
+ return IvlScd->Loop ();
}
void
-UchStop ()
+IvlStop ()
{
- UchMpx->Stop ();
+ IvlScd->Stop ();
}
+#endif
diff --git a/comm/Multiplexer.h b/comm/Scheduler.h
index e955130..b6eec4d 100644
--- a/comm/Multiplexer.h
+++ b/comm/Scheduler.h
@@ -10,55 +10,56 @@
*
* $Id$
* $CurLog$
+ * Smart(ies) removed by Stephane Sire
+ * added Hooks
*/
-#ifndef UchMultiplexer_H_
-#define UchMultiplexer_H_
+#ifndef IvlScheduler_H_
+#define IvlScheduler_H_
-#include "dnn/Loop.h"
+#include "ivl/Loop.h"
#include "Channel.h"
#include <sys/types.h>
-#include "ccu/Timer.h"
+#include "ivl/Timer.h"
extern char* StrReprBuf;
// This class defines channel sets for multiplexing i/o
// Because of the coercion defined for FILDES -> int,
-// most arguments of type ints can be FILDES, UchChannel, ...
+// most arguments of type ints can be FILDES, IvlChannel, ...
// An array of pointers to channels is kept in the object;
// The masks for reading/writing are kept consistent with the IOMode of
// the channels, as long as it is not changed by a direct access to the channel
// operator[] returns a pointer and cannot be used as an lhs of an assignment.
//
-// WARNING: when the Multiplexer is deleted, the Channels it still
-// have in its channel set are not Removed; instead UchChannel::Removed
+// WARNING: when the Scheduler is deleted, the Channels it still
+// have in its channel set are not Removed; instead IvlChannel::Removed
// is called
-typedef DnnMpxHook UchMpxHook;
-class UchBaseMultiplexer : public DnnBaseMultiplexer {
-friend class UchBaseTimeOut;
-friend class UchBaseSignalHandler;
-friend class UchChannel;
-friend MPX_RES UchLoop ();
+class IvlBaseScheduler : public IvlBaseMultiplexer {
+friend class IvlBaseTimeOut;
+friend class IvlBaseScheduledHandler;
+friend class IvlChannel;
+friend MPX_RES IvlLoop ();
protected:
- UchChannel** Channels;
- CcuTimerSet Timers;
+ IvlChannel** Channels;
+ IvlTimerSet Timers;
short ReadCount;
short WriteCount;
short SelectCount;
bool Looping;
bool SigFired;
- UchBaseSignalHandler** Handlers;
+ IvlBaseScheduledHandler** Handlers;
int* NbSignals;
- bool Add (UchChannel*);
+ bool Add (IvlChannel*);
bool Remove (int);
- void HandleSignal (UchBaseSignalHandler&);
+ void HandleSignal (IvlBaseScheduledHandler&);
void HandleDeferredSignals ();
-inline CcuTimerSet* GetTimerSet () { return &Timers; }
+inline IvlTimerSet* GetTimerSet () { return &Timers; }
virtual void SetMasks (int, IOMODE);
virtual void SetTimeOut (Millisecond) = 0;
@@ -66,10 +67,10 @@ virtual void SuppressTimeOut () = 0;
virtual void AddSignalHook ();
public:
- UchBaseMultiplexer ();
- ~UchBaseMultiplexer ();
+ IvlBaseScheduler ();
+ ~IvlBaseScheduler ();
- UchChannel* operator [] (int);
+ IvlChannel* operator [] (int);
void RemoveAll ();
void SetMode (int, IOMODE);
@@ -79,14 +80,13 @@ public:
void Close ();
};
-
-class UchMultiplexer : public UchBaseMultiplexer {
+class IvlScheduler : public IvlBaseScheduler {
protected:
fd_set ReadMask;
fd_set WriteMask;
fd_set SelectMask;
- CcuList Hooks;
- CcuList FinalHooks;
+ IvlList Hooks;
+ IvlList FinalHooks;
bool Looping;
Millisecond TimeOut;
@@ -96,24 +96,26 @@ protected:
MPX_RES Loop ();
void ExecHooks (bool = false);
-
public:
- UchMultiplexer ();
- ~UchMultiplexer ();
+ IvlScheduler ();
+ ~IvlScheduler ();
MPX_RES LoopScan (bool nointr = true);
int Scan (bool nointr = true, bool poll = false);
void Stop ();
char* StrRepr (char* = StrReprBuf);
- void AddHook (DnnMpxHook*, bool = false);
- void RemoveHook (DnnMpxHook*, bool = false);
- void AddFinalHook (DnnMpxHook*);
- void RemoveFinalHook (DnnMpxHook*);
+ void AddHook (IvlMpxHook*, bool = false);
+ void RemoveHook (IvlMpxHook*, bool = false);
+ void AddFinalHook (IvlMpxHook*);
+ void RemoveFinalHook (IvlMpxHook*);
};
-extern UchBaseMultiplexer* UchMpx;
-extern void UchOpen (UchBaseMultiplexer* = 0);
-extern MPX_RES UchLoop ();
-extern void UchStop ();
+extern IvlBaseScheduler* IvlScd;
+extern void IvlOpen (IvlBaseScheduler* = 0);
+
+#if 0 /* rendu inutile par la fusion avec DNN ? */
+extern MPX_RES IvlLoop ();
+extern void IvlStop ();
+#endif
-#endif /* UchMultiplexer_H_ */
+#endif /* IvlScheduler_H_ */
diff --git a/comm/SignalHandler.cc b/comm/SignalHandler.cc
index 2bf3bba..86db5fe 100644
--- a/comm/SignalHandler.cc
+++ b/comm/SignalHandler.cc
@@ -7,7 +7,7 @@
* Laboratoire de Recherche en Informatique (LRI)
* Centre d'Etudes de la Navigation Aerienne
*
- * Multiplexer-based signal handlers
+ * Scheduler-based signal handlers
*
* $Id$
* $CurLog$
@@ -17,30 +17,30 @@
#pragma implementation "SignalHandler.h"
#endif
#include "SignalHandler.h"
-#include "Multiplexer.h"
+#include "Scheduler.h"
-/*?class UchBaseSignalHandler
-The class \typ{UchBaseSignalHandler} is provided as a base class for safe signal handlers,
+/*?class IvlBaseScheduledHandler
+The class \typ{IvlBaseScheduledHandler} is provided as a base class for safe signal handlers,
ie. signal handlers that are activated only when no data is being transferred on a channel.
-It is a derived class of \typ{CcuBaseSignalHandler}, in which the method \fun{Handle} is
+It is a derived class of \typ{IvlBaseScheduledHandler}, in which the method \fun{Handle} is
defined to hold the signal until safe times. The virtual function \fun{DeferredHandle},
that should be redefined in derived classes, is called later.
-The class \typ{UchBaseSignalHandler} comes with a derived class
-\typ{CcuSignalHandler} that can be used as is, without any derivation.
+The class \typ{IvlBaseScheduledHandler} comes with a derived class
+\typ{IvlScheduledHandler} that can be used as is, without any derivation.
?*/
/*?
Create a signal handler associated to the multiplexer \var{m},
for the signal \var{sig}.
?*/
-UchBaseSignalHandler :: UchBaseSignalHandler (UchBaseMultiplexer& m, int sig)
-: CcuBaseSignalHandler (sig),
- MyMpx (m)
+IvlBaseScheduledHandler :: IvlBaseScheduledHandler (IvlBaseScheduler& m, int sig)
+: IvlBaseSignalHandler (sig),
+ MyScd (m)
{
}
/*?nodoc?*/
-UchBaseSignalHandler :: ~UchBaseSignalHandler ()
+IvlBaseScheduledHandler :: ~IvlBaseScheduledHandler ()
{
}
@@ -49,9 +49,9 @@ Ask the multiplexer to hold the signal and call us when it is safe.
!*/
/*?hidden?*/
void
-UchBaseSignalHandler :: Handle ()
+IvlBaseScheduledHandler :: Handle ()
{
- MyMpx.HandleSignal (*this);
+ MyScd.HandleSignal (*this);
}
/*?
@@ -63,14 +63,14 @@ that were received. This function is not called during an
interruption, and does not suffer any constraint.
?*/
void
-UchBaseSignalHandler :: DeferredHandle (int nb)
+IvlBaseScheduledHandler :: DeferredHandle (int nb)
{
}
-/*?class UchSignalHandler
-The class \typ{UchSignalHandler} is a derived class of \typ{UchBaseSignalHandler} that
+/*?class IvlScheduledHandler
+The class \typ{IvlScheduledHandler} is a derived class of \typ{IvlBaseScheduledHandler} that
can be used without deriving a new class.
-Each \typ{UchSignalHandler} holds a pointer to a function which is called when a
+Each \typ{IvlScheduledHandler} holds a pointer to a function which is called when a
signal is received. This function, which is passed to the constructor, must
take an \typ{int} argument and return \typ{void}.
?*/
@@ -80,20 +80,20 @@ Create a signal handler for signal \var{sig}. The function \var{h} will be
called when a signal has to be handled. Its two arguments are the identification
of the signal, and the number of signals that were received.
?*/
-UchSignalHandler :: UchSignalHandler (UchBaseMultiplexer& m, int sig, void (*h) (int, int))
-: UchBaseSignalHandler (m, sig),
+IvlScheduledHandler :: IvlScheduledHandler (IvlBaseScheduler& m, int sig, void (*h) (int, int))
+: IvlBaseScheduledHandler (m, sig),
Handler (h)
{
}
/*?nodoc?*/
-UchSignalHandler :: ~UchSignalHandler ()
+IvlScheduledHandler :: ~IvlScheduledHandler ()
{
}
/*?hidden?*/
void
-UchSignalHandler :: DeferredHandle (int nb)
+IvlScheduledHandler :: DeferredHandle (int nb)
{
(*Handler) (Signal, nb);
}
diff --git a/comm/SignalHandler.h b/comm/SignalHandler.h
index 1ced680..162b496 100644
--- a/comm/SignalHandler.h
+++ b/comm/SignalHandler.h
@@ -7,47 +7,46 @@
* Laboratoire de Recherche en Informatique (LRI)
* Centre d'Etudes de la Navigation Aerienne
*
- * Multiplexer-based signal handlers
+ * Scheduler-based signal handlers
*
* $Id$
* $CurLog$
*/
-#ifndef UchSignal_H_
-#define UchSignal_H_
+#ifndef IvlSignal_H_
+#define IvlSignal_H_
#ifdef __GNUG__
#pragma interface
#endif
-#include "ccu/Signal.h"
+#include "ivl/Signal.h"
-class UchBaseSignalHandler : public CcuBaseSignalHandler {
-friend class UchBaseMultiplexer;
+class IvlBaseScheduledHandler : public IvlBaseSignalHandler {
+friend class IvlBaseScheduler;
protected:
- UchBaseMultiplexer& MyMpx;
+ IvlBaseScheduler& MyScd;
void Handle ();
public:
- UchBaseSignalHandler (UchBaseMultiplexer&, int);
-virtual ~UchBaseSignalHandler ();
+ IvlBaseScheduledHandler (IvlBaseScheduler&, int);
+virtual ~IvlBaseScheduledHandler ();
protected:
/*?public?*/
virtual void DeferredHandle (int);
};
-class UchSignalHandler : public UchBaseSignalHandler {
+class IvlScheduledHandler : public IvlBaseScheduledHandler {
protected:
void (*Handler) (int, int);
void DeferredHandle (int);
public:
- UchSignalHandler (UchBaseMultiplexer&, int, void (*) (int, int));
- ~UchSignalHandler ();
+ IvlScheduledHandler (IvlBaseScheduler&, int, void (*) (int, int));
+ ~IvlScheduledHandler ();
};
-#endif /* UchSignal_H_ */
-
+#endif /* IvlSignal_H_ */
diff --git a/comm/Socket.cc b/comm/Socket.cc
index b90fe66..61244fa 100644
--- a/comm/Socket.cc
+++ b/comm/Socket.cc
@@ -10,6 +10,8 @@
*
* $Id$
* $CurLog$
+ * Removed Smart pointers
+ * Added ReuseAddress and AllowBroadcast
*/
#include "Socket.h"
@@ -19,10 +21,9 @@
#include <sys/socket.h>
extern int errno;
-
-/*?class UchSocket
-The class \typ{UchSocket} derives from \typ{UchChannel}. It is a
-virtual base class: no objects of class \typ{UchSocket} are ever
+/*?class IvlSocket
+The class \typ{IvlSocket} derives from \typ{IvlChannel}. It is a
+virtual base class: no objects of class \typ{IvlSocket} are ever
created. It implements Unix sockets, that is file descriptors with
two addresses: the address the socket is bound to, and the address it
is connected to. An address needs to be bound to a socket only if
@@ -31,7 +32,7 @@ connected to an address only for streams or connected datagrams.
Thus, none of the addresses is mandatory.
A socket can have potentially two addresses (the one it is BoundTo and
-the one it is ConnectedTo. Once given to a socket, an \typ{UchAddress}
+the one it is ConnectedTo. Once given to a socket, an \typ{IvlAddress}
instance pointer is no more usable because it can be deleted and
reallocated by the Socket when it is bound/connected. These address
pointers are also deleted by the socket destructor. Thus, to know the
@@ -48,8 +49,8 @@ always allocated by new. Theses addresses are deleted and
reinstanciated after a \fun{Bind}. To obtain the addresses of a
socket, use \fun{BoundTo} and \fun{ConnectedTo}.
?*/
-UchSocket :: UchSocket (UchAddress* bound, UchAddress* connected)
-: UchChannel (),
+IvlSocket :: IvlSocket (IvlAddress* bound, IvlAddress* connected)
+: IvlChannel (),
BAddr (bound),
CAddr (connected),
AddrFamily (AF_UNSPEC),
@@ -58,8 +59,8 @@ UchSocket :: UchSocket (UchAddress* bound, UchAddress* connected)
}
/*?nodoc?*/
-UchSocket :: UchSocket (const UchSocket& s)
-: UchChannel (s),
+IvlSocket :: IvlSocket (const IvlSocket& s)
+: IvlChannel (s),
BAddr (s.BAddr),
CAddr (s.CAddr),
Ready (s.Ready)
@@ -67,7 +68,7 @@ UchSocket :: UchSocket (const UchSocket& s)
}
/*?nodoc?*/
-UchSocket :: ~UchSocket ()
+IvlSocket :: ~IvlSocket ()
{
if (BAddr) delete BAddr;
if (CAddr) delete CAddr;
@@ -80,14 +81,14 @@ one of \var{SOCK\_UNSPEC}, \var{SOCK\_STREAM}, \var{SOCK\_DGRAM},
depending on the class.
?*/
int
-UchSocket :: SockType ()
+IvlSocket :: SockType ()
{
}
#endif
/*?nextdoc?*/
void
-UchSocket :: BindTo (UchAddress* a)
+IvlSocket :: BindTo (IvlAddress* a)
{
if (BAddr)
delete BAddr;
@@ -98,7 +99,7 @@ UchSocket :: BindTo (UchAddress* a)
Set the address a socket is to be bound to or connected to.
?*/
void
-UchSocket :: ConnectTo (UchAddress* a)
+IvlSocket :: ConnectTo (IvlAddress* a)
{
if (CAddr)
delete CAddr;
@@ -112,7 +113,7 @@ or its family must have been defined with \fun{SetFamily}.
Return false if the family is undefined or if a system error occurred.
?*/
bool
-UchSocket :: Open ()
+IvlSocket :: Open ()
{
errno = 0;
if (Fd >= 0)
@@ -128,13 +129,13 @@ UchSocket :: Open ()
int fd = socket (AddrFamily, SockType (), 0);
if (fd < 0)
return false;
- UchChannel::Open (fd);
+ IvlChannel::Open (fd);
return true;
}
/*?nextdoc?*/
int
-UchSocket :: Bind (UchAddress* addr)
+IvlSocket :: Bind (IvlAddress* addr)
{
if (addr)
BindTo (addr);
@@ -148,10 +149,10 @@ UchSocket :: Bind (UchAddress* addr)
return ret;
GEN_ADDR naddr;
- int alen = sizeof (naddr);
+ socklen_t alen = sizeof (naddr);
if (getsockname (Fd, &naddr.sa, &alen) < 0)
return -1;
- BindTo (UchAddress::Decode (&naddr, alen));
+ BindTo (IvlAddress::Decode (&naddr, alen));
return ret;
}
@@ -163,7 +164,7 @@ The returned value is that of the system call, unless opening failed in which ca
-1 is returned.
?*/
int
-UchSocket :: Connect (UchAddress* addr)
+IvlSocket :: Connect (IvlAddress* addr)
{
if (addr)
ConnectTo (addr);
@@ -176,14 +177,13 @@ UchSocket :: Connect (UchAddress* addr)
return ret;
GEN_ADDR naddr;
- int alen = sizeof (naddr);
+ socklen_t alen = sizeof (naddr);
if (getpeername (Fd, &naddr.sa, &alen) < 0)
return -1;
- ConnectTo (UchAddress::Decode (&naddr, alen));
+ ConnectTo (IvlAddress::Decode (&naddr, alen));
return ret;
}
-
/*?
Open the socket if it is not already open.
Bind and connect it depending on the addresses that are defined.
@@ -193,7 +193,7 @@ This function returns false if a system error occurred. In this case, the caller
call \fun{SysError} to report the error.
?*/
bool
-UchSocket :: Setup ()
+IvlSocket :: Setup ()
{
if (! Open ())
return Ready = false;
@@ -213,15 +213,14 @@ This function is intended for sockets that accept connections.
It returns the file descriptor of the new connection, or -1 in case of failure.
?*/
int
-UchSocket :: Accept ()
+IvlSocket :: Accept ()
{
errno = 0;
return accept (Fd, 0, 0);
}
-
bool
-UchSocket :: ReuseAddress (bool on)
+IvlSocket :: ReuseAddress (bool on)
{
int parm = on;
int res = setsockopt (Fd, SOL_SOCKET, SO_REUSEADDR, (char *)&parm, sizeof (parm));
@@ -229,19 +228,18 @@ UchSocket :: ReuseAddress (bool on)
}
bool
-UchSocket :: AllowBroadcast (bool on)
+IvlSocket :: AllowBroadcast (bool on)
{
int parm = on;
int res = setsockopt (Fd, SOL_SOCKET, SO_BROADCAST, (char *)&parm, sizeof (parm));
return res < 0 ? false : true;
}
-
/*?nodoc?*/
char*
-UchSocket :: StrRepr (char* buf)
+IvlSocket :: StrRepr (char* buf)
{
- UchChannel :: StrRepr (buf);
+ IvlChannel :: StrRepr (buf);
strcat (buf, " / ");
if (BAddr)
BAddr->StrRepr (buf + strlen (buf));
@@ -259,7 +257,7 @@ UchSocket :: StrRepr (char* buf)
/*?nextdoc?*/
int
-UchSocket :: Family ()
+IvlSocket :: Family ()
{ }
/*?
@@ -271,19 +269,19 @@ If an address is bound or connected to the socket, its family is used.
Thus, an application seldom needs to call \fun{SetFamily}.
?*/
void
-UchSocket :: SetFamily (int f)
+IvlSocket :: SetFamily (int f)
{ }
/*?nextdoc?*/
-UchAddress*
-UchSocket :: BoundTo ()
+IvlAddress*
+IvlSocket :: BoundTo ()
{ }
/*?
Return the address currently bound or connected to the socket.
?*/
-UchAddress*
-UchSocket :: ConnectedTo ()
+IvlAddress*
+IvlSocket :: ConnectedTo ()
{ }
#endif /* DOC */
diff --git a/comm/Socket.h b/comm/Socket.h
index 7c0e323..82e1669 100644
--- a/comm/Socket.h
+++ b/comm/Socket.h
@@ -10,6 +10,8 @@
*
* $Id$
* $CurLog$
+ * Removed Smart pointers
+ * Added ReuseAddress and AllowBroadcast
*/
#ifndef Socket_H_
@@ -27,17 +29,17 @@ extern char* StrReprBuf;
// A socket is a channel and an address.
// As a channel, it is immutable, and must be initialized once and for all at creation.
//
-class UchSocket : public UchChannel {
+class IvlSocket : public IvlChannel {
protected:
- UchAddress* BAddr;
- UchAddress* CAddr;
+ IvlAddress* BAddr;
+ IvlAddress* CAddr;
int AddrFamily;
bool Ready;
/*?public?*/
- UchSocket (UchAddress*, UchAddress*);
- UchSocket (const UchSocket& s);
- ~UchSocket ();
+ IvlSocket (IvlAddress*, IvlAddress*);
+ IvlSocket (const IvlSocket& s);
+ ~IvlSocket ();
public:
@@ -45,13 +47,13 @@ virtual int SockType () = 0;
inline int Family () { return AddrFamily; }
inline void SetFamily (int f) { AddrFamily = f; }
inline bool IsReady () const { return Ready; }
- void BindTo (UchAddress*);
- void ConnectTo (UchAddress*);
-inline UchAddress* BoundTo () { return BAddr; }
-inline UchAddress* ConnectedTo () { return CAddr; }
+ void BindTo (IvlAddress*);
+ void ConnectTo (IvlAddress*);
+inline IvlAddress* BoundTo () { return BAddr; }
+inline IvlAddress* ConnectedTo () { return CAddr; }
bool Open ();
- int Bind (UchAddress* = 0);
- int Connect (UchAddress* = 0);
+ int Bind (IvlAddress* = 0);
+ int Connect (IvlAddress* = 0);
int Accept ();
bool Setup ();
bool ReuseAddress (bool = true);
diff --git a/comm/Stream.cc b/comm/Stream.cc
index 16f6bc7..02682ad 100644
--- a/comm/Stream.cc
+++ b/comm/Stream.cc
@@ -22,9 +22,9 @@ extern "C" {
}
#endif
-/*?class UchStream
+/*?class IvlStream
Streams implement reliable point to point connections.
-UchStream connections do not keep the message boundaries:
+IvlStream connections do not keep the message boundaries:
several messages can be read at a time, and a message can be read in several parts.
Establishing a stream connection is not a symmetric operation:
@@ -38,40 +38,40 @@ Because a server has to listen to pending connections and communicate
with its connected clients, using a channel set is highly recommended:
when a connection is pending, the channel is ready for reading,
and you can accept the connection with \fun{SockAccept} (instead of reading data).
-Note that because \typ{UchStream} derives from \typ{UchSocket}
-and thus from \typ{UchChannel}, the virtual functions
+Note that because \typ{IvlStream} derives from \typ{IvlSocket}
+and thus from \typ{IvlChannel}, the virtual functions
\fun{HandleRead} and \fun{HandeWrite} can be used.
?*/
/*?
-This constructor is similar to that of the class \typ{UchSocket}.
+This constructor is similar to that of the class \typ{IvlSocket}.
?*/
-UchStream :: UchStream (UchAddress* bound, UchAddress* connected)
-: UchSocket (bound, connected)
+IvlStream :: IvlStream (IvlAddress* bound, IvlAddress* connected)
+: IvlSocket (bound, connected)
{
}
/*?nodoc?*/
-UchStream :: UchStream (const UchStream& s)
-: UchSocket (s)
+IvlStream :: IvlStream (const IvlStream& s)
+: IvlSocket (s)
{
}
/*?nodoc?*/
-UchStream :: ~UchStream ()
+IvlStream :: ~IvlStream ()
{
}
/*?nodoc?*/
-UchChannel*
-UchStream :: Copy () const
+IvlChannel*
+IvlStream :: Copy () const
{
- return new UchStream (*this);
+ return new IvlStream (*this);
}
/*?nodoc?*/
int
-UchStream :: SockType ()
+IvlStream :: SockType ()
{
return SOCK_STREAM;
}
@@ -88,7 +88,7 @@ The returned value is that of the system call, unless the set up failed in which
Note that it is useless to listen on a socket if it is not bound to an address.
?*/
int
-UchStream :: Listen (int n)
+IvlStream :: Listen (int n)
{
if (! Setup ())
return -1;
diff --git a/comm/Stream.h b/comm/Stream.h
index a8c4a56..2ae76b7 100644
--- a/comm/Stream.h
+++ b/comm/Stream.h
@@ -18,12 +18,12 @@
#include "cplus_bugs.h"
#include "Socket.h"
-class UchStream : public UchSocket {
+class IvlStream : public IvlSocket {
public:
- UchStream (UchAddress* = 0, UchAddress* = 0);
- ~UchStream ();
- UchStream (const UchStream&);
- UchChannel* Copy () const;
+ IvlStream (IvlAddress* = 0, IvlAddress* = 0);
+ ~IvlStream ();
+ IvlStream (const IvlStream&);
+ IvlChannel* Copy () const;
int SockType ();
int Listen (int = 5);
};
diff --git a/comm/TimeOut.cc b/comm/TimeOut.cc
index 9f70636..60346a5 100644
--- a/comm/TimeOut.cc
+++ b/comm/TimeOut.cc
@@ -7,20 +7,20 @@
* Laboratoire de Recherche en Informatique (LRI)
* Centre d'Etudes de la Navigation Aerienne
*
- * Multiplexer-based timers
+ * Scheduler-based timers
*
* $Id$
* $CurLog$
*/
#include "TimeOut.h"
-#include "ccu/Signal.h"
-#include "Multiplexer.h"
+#include "ivl/Signal.h"
+#include "Scheduler.h"
-/*?class UchBaseTimeOut
-The class \typ{UchBaseTimeOut} is provided as a base class for multiplexer-based timers.
-It is a derived class of \typ{CcuCoreTimer}.
-It comes with a derived class \typ{UchTimeOut} that can be used as is.
+/*?class IvlBaseTimeOut
+The class \typ{IvlBaseTimeOut} is provided as a base class for multiplexer-based timers.
+It is a derived class of \typ{IvlCoreTimer}.
+It comes with a derived class \typ{IvlTimeOut} that can be used as is.
A timer is created with a period expressed in milliseconds. It will then
periodically call the member function \fun{Handle}, which should be redefined
in derived classes.
@@ -33,18 +33,18 @@ If \var{pulses} is negative, the timer will send signals forever.
Timers are activated at creation time. They are disactivated, but not destroyed, after
their last pulse.
?*/
-UchBaseTimeOut :: UchBaseTimeOut (Millisecond period, int pulses, UchBaseMultiplexer* m)
-: CcuCoreTimer (period, pulses, m->GetTimerSet ()),
- MyMpx (m)
+IvlBaseTimeOut :: IvlBaseTimeOut (Millisecond period, int pulses, IvlBaseScheduler* m)
+: IvlCoreTimer (period, pulses, m->GetTimerSet ()),
+ MyScd (m)
{
- CcuSignalBlocker b (SigAlrm);
+ IvlSignalBlocker b (SigAlrm);
if (PulsesLeft != 0)
Activate ();
}
/*?nodoc?*/
-UchBaseTimeOut :: ~UchBaseTimeOut ()
+IvlBaseTimeOut :: ~IvlBaseTimeOut ()
{
/* stop it */
if (StatusFlag == Active)
@@ -53,25 +53,22 @@ UchBaseTimeOut :: ~UchBaseTimeOut ()
/*?hidden?*/
void
-UchBaseTimeOut :: StopAlarm ()
+IvlBaseTimeOut :: StopAlarm ()
{
- MyMpx->SuppressTimeOut ();
+ MyScd->SuppressTimeOut ();
}
/*?hidden?*/
void
-UchBaseTimeOut :: SetAlarm (Millisecond delay)
+IvlBaseTimeOut :: SetAlarm (Millisecond delay)
{
- MyMpx->SetTimeOut (delay);
+ MyScd->SetTimeOut (delay);
}
-
-
-
-/*?class UchTimeOut
-The class \typ{UchTimeOut} is a derived class of \typ{UchBaseTimeOut} that
+/*?class IvlTimeOut
+The class \typ{IvlTimeOut} is a derived class of \typ{IvlBaseTimeOut} that
can be used without deriving a new class.
-Each \typ{UchTimeOut} holds a pointer to a function which is called when the timer
+Each \typ{IvlTimeOut} holds a pointer to a function which is called when the timer
expires. This function, which is passed to the constructor, must
take a \typ{Millisecond} argument and return \typ{void}.
?*/
@@ -81,20 +78,20 @@ Create a timer associated to the multiplexer \var{m},
that will expire every \var{period} milliseconds and call
the function \var{handler}.
?*/
-UchTimeOut :: UchTimeOut (Millisecond period, void (*handler) (Millisecond), int pulses, UchBaseMultiplexer* m)
-: UchBaseTimeOut (period, pulses, m),
+IvlTimeOut :: IvlTimeOut (Millisecond period, void (*handler) (Millisecond), int pulses, IvlBaseScheduler* m)
+: IvlBaseTimeOut (period, pulses, m),
Handler (handler)
{
}
/*?nodoc?*/
-UchTimeOut :: ~UchTimeOut ()
+IvlTimeOut :: ~IvlTimeOut ()
{
}
/*?hidden?*/
void
-UchTimeOut :: Handle (Millisecond ref)
+IvlTimeOut :: Handle (Millisecond ref)
{
(*Handler) (ref);
}
@@ -104,7 +101,7 @@ Change the handling function of a timer.
?*/
#ifdef DOC
void
-UchTimeOut :: SetHandler ((void)(*h)(Millisecond))
+IvlTimeOut :: SetHandler ((void)(*h)(Millisecond))
{
}
#endif
diff --git a/comm/TimeOut.h b/comm/TimeOut.h
index aaaae63..fef1e22 100644
--- a/comm/TimeOut.h
+++ b/comm/TimeOut.h
@@ -11,51 +11,52 @@
*
* $Id$
* $CurLog$
+ * CHange handling of multiplexer
*/
-#ifndef UchTimeOut_H_
-#define UchTimeOut_H_
+#ifndef IvlTimeOut_H_
+#define IvlTimeOut_H_
-#include "ccu/Timer.h"
-#include "Multiplexer.h"
+#include "ivl/Timer.h"
+#include "Scheduler.h"
-class UchBaseTimeOut : public CcuCoreTimer {
-friend class UchBaseMultiplexer;
+class IvlBaseTimeOut : public IvlCoreTimer {
+friend class IvlBaseScheduler;
protected:
- UchBaseMultiplexer* MyMpx;
+ IvlBaseScheduler* MyScd;
void SetAlarm (Millisecond);
void StopAlarm ();
public:
- UchBaseTimeOut (Millisecond, int = -1, UchBaseMultiplexer* = UchMpx);
- ~UchBaseTimeOut ();
+ IvlBaseTimeOut (Millisecond, int = -1, IvlBaseScheduler* = IvlScd);
+ ~IvlBaseTimeOut ();
};
-class UchTimeOut : public UchBaseTimeOut {
+class IvlTimeOut : public IvlBaseTimeOut {
protected:
void (*Handler) (Millisecond);
void Handle (Millisecond);
public:
- UchTimeOut (Millisecond, void (*) (Millisecond), int = -1, UchBaseMultiplexer* = UchMpx);
- ~UchTimeOut ();
+ IvlTimeOut (Millisecond, void (*) (Millisecond), int = -1, IvlBaseScheduler* = IvlScd);
+ ~IvlTimeOut ();
inline void SetHandler (void (*h) (Millisecond)) { Handler = h; }
};
#define SpecializedTimeOut(R,S) \
-class R : public UchBaseTimeOut { \
+class R : public IvlBaseTimeOut { \
protected: \
S& Object; \
void (S::*Handler) (Millisecond); \
public: \
- R (Millisecond t, S& s, void (S::*sc) (Millisecond), int nb = -1, UchBaseMultiplexer* m = UchMpx) : UchBaseTimeOut (t, nb, m), Object (s), Handler (sc) {} \
+ R (Millisecond t, S& s, void (S::*sc) (Millisecond), int nb = -1, IvlBaseScheduler* m = IvlScd) : IvlBaseTimeOut (t, nb, m), Object (s), Handler (sc) {} \
~R () {} \
void Handle (Millisecond t) { (Object.*Handler) (t); } \
inline void SetHandler (void (S::*h) (Millisecond)) { Handler = h; } \
};
-template <class T> class UchTimeOutFor : public UchBaseTimeOut {
+template <class T> class IvlTimeOutFor : public IvlBaseTimeOut {
protected:
T& Object;
void (T::*Handler) (Millisecond);
@@ -63,9 +64,9 @@ protected:
void Handle (Millisecond ref) { (Object.*Handler) (ref); }
public:
- UchTimeOutFor (Millisecond t, T& o, void (T::*h) (Millisecond), int nb = -1, UchBaseMultiplexer* m = UchMpx) : UchBaseTimeOut (t, nb, m), Object (o), Handler (h) {}
- ~UchTimeOutFor () {}
+ IvlTimeOutFor (Millisecond t, T& o, void (T::*h) (Millisecond), int nb = -1, IvlBaseScheduler* m = IvlScd) : IvlBaseTimeOut (t, nb, m), Object (o), Handler (h) {}
+ ~IvlTimeOutFor () {}
inline void SetHandler (void(T::*h)(Millisecond)) { Handler = h; }
};
-#endif /* UchTimeOut_H_ */
+#endif /* IvlTimeOut_H_ */
diff --git a/comm/TkMultiplexer.cc b/comm/TkMultiplexer.cc
index 28c76d3..7ce87a4 100644
--- a/comm/TkMultiplexer.cc
+++ b/comm/TkMultiplexer.cc
@@ -11,6 +11,7 @@
*
* $Id$
* $CurLog$
+ * Made consistent with Tcl7.0 and Tk3.3
*/
#include "TkMultiplexer.h"
@@ -29,28 +30,27 @@ extern "C" {
static void
ioHandler (ClientData client_data, int mask)
{
- UchChannel* ch = (UchChannel*) client_data;
+ IvlChannel* ch = (IvlChannel*) client_data;
if (mask & TK_WRITABLE)
ch->HandleWrite ();
if (mask & TK_READABLE)
ch->HandleRead ();
}
-UchTkMultiplexer :: UchTkMultiplexer ()
-: UchBaseMultiplexer ()
+IvlTkMultiplexer :: IvlTkMultiplexer ()
+: IvlBaseMultiplexer ()
{
memset (Active, 0, NFILE * sizeof (bool));
}
-
-UchTkMultiplexer :: ~UchTkMultiplexer ()
+IvlTkMultiplexer :: ~IvlTkMultiplexer ()
{
}
void
-UchTkMultiplexer :: SetMasks (int fd, IOMODE mode)
+IvlTkMultiplexer :: SetMasks (int fd, IOMODE mode)
{
- UchChannel* ch = Channels [fd];
+ IvlChannel* ch = Channels [fd];
if (!ch)
return;
@@ -80,38 +80,38 @@ UchTkMultiplexer :: SetMasks (int fd, IOMODE mode)
}
void
-UchTkMultiplexer :: FireTimers (ClientData mpx)
+IvlTkMultiplexer :: FireTimers (ClientData mpx)
{
- CcuCoreTimer::Fire (((UchTkMultiplexer*) mpx)->GetTimerSet ());
+ IvlCoreTimer::Fire (((IvlTkMultiplexer*) mpx)->GetTimerSet ());
}
void
-UchTkMultiplexer :: SetTimeOut (Millisecond delay)
+IvlTkMultiplexer :: SetTimeOut (Millisecond delay)
{
- TimeOut = Tk_CreateTimerHandler (int (delay), &UchTkMultiplexer::FireTimers, (ClientData) this);
+ TimeOut = Tk_CreateTimerHandler (int (delay), &IvlTkMultiplexer::FireTimers, (ClientData) this);
}
void
-UchTkMultiplexer :: SuppressTimeOut ()
+IvlTkMultiplexer :: SuppressTimeOut ()
{
Tk_DeleteTimerHandler (TimeOut);
TimeOut = 0;
}
void
-UchTkMultiplexer :: FireSignals (ClientData mpx)
+IvlTkMultiplexer :: FireSignals (ClientData mpx)
{
- ((UchTkMultiplexer*) mpx)->HandleDeferredSignals ();
+ ((IvlTkMultiplexer*) mpx)->HandleDeferredSignals ();
}
void
-UchTkMultiplexer :: AddSignalHook ()
+IvlTkMultiplexer :: AddSignalHook ()
{
- Tk_DoWhenIdle (&UchTkMultiplexer::FireSignals, (ClientData) this);
+ Tk_DoWhenIdle (&IvlTkMultiplexer::FireSignals, (ClientData) this);
}
MPX_RES
-UchTkMultiplexer :: Loop ()
+IvlTkMultiplexer :: Loop ()
{
Looping = true;
diff --git a/comm/TkMultiplexer.h b/comm/TkMultiplexer.h
index 08a6adc..b1d1741 100644
--- a/comm/TkMultiplexer.h
+++ b/comm/TkMultiplexer.h
@@ -11,6 +11,7 @@
*
* $Id$
* $CurLog$
+ * Made consistent with Tcl7.0 and Tk3.3
*/
#ifndef TkMultiplexer_H_
@@ -30,8 +31,7 @@ typedef struct Tk_TimerToken_ *Tk_TimerToken;
#define _CLIENTDATA
#endif
-
-class UchTkMultiplexer : public UchBaseMultiplexer {
+class IvlTkMultiplexer : public IvlBaseMultiplexer {
private:
static void FireSignals (ClientData);
static void FireTimers (ClientData);
@@ -47,8 +47,8 @@ protected:
MPX_RES Loop ();
public:
- UchTkMultiplexer ();
- ~UchTkMultiplexer ();
+ IvlTkMultiplexer ();
+ ~IvlTkMultiplexer ();
};
#endif /* TkMultiplexer_H_ */
diff --git a/comm/UnixAddress.cc b/comm/UnixAddress.cc
new file mode 100644
index 0000000..469fa2e
--- /dev/null
+++ b/comm/UnixAddress.cc
@@ -0,0 +1,86 @@
+/*
+ * The Unix Channel
+ *
+ * by Michel Beaudouin-Lafon
+ *
+ * Copyright 1990-1997
+ * Laboratoire de Recherche en Informatique (LRI)
+ *
+ * Unix Addresses
+ *
+ * $Id$
+ * $CurLog$
+ * Created from Address.cc
+ */
+
+#include "UnixAddress.h"
+#include "error.h"
+
+#include <stdio.h>
+
+// constructors for Unix addresses
+// a Unix domain address is just a filename
+// -> some problems: check for access, when to unlink it ?
+// to do : generate name from a template (for uniqueness)
+//
+
+/*?nodoc?*/
+IvlUnixAddress :: IvlUnixAddress ()
+: IvlAddress ()
+{
+}
+
+/*?
+Create a Unix domain address associated to file \var{filename}.
+The file is not unlinked when the address is destroyed;
+it should be unlinked by the application whenever the last socket using this address is closed.
+?*/
+IvlUnixAddress :: IvlUnixAddress (const char* filename)
+: IvlAddress ()
+{
+ Addr.sun_family = AF_UNIX;
+ strcpy (Addr.sun_path, filename);
+ Valid = true;
+ // should check access to file ???
+ // unlink if already there ?
+}
+
+/*?nodoc?*/
+IvlUnixAddress :: ~IvlUnixAddress ()
+{
+ // how to unlink the file ??
+}
+
+/*?nodoc?*/
+int
+IvlUnixAddress :: Family ()
+{
+ return AF_UNIX;
+}
+
+/*?nodoc?*/
+int
+IvlUnixAddress :: Length ()
+{
+ if (Valid)
+ return (Addr.sun_path + strlen (Addr.sun_path)) - (char*) &Addr;
+ return 0;
+}
+
+/*?nodoc?*/
+SockAddr*
+IvlUnixAddress :: GetSockAddr ()
+{
+ return (SockAddr*) &Addr;
+}
+
+/*?nodoc?*/
+char*
+IvlUnixAddress :: StrRepr (char* buf)
+{
+ sprintf (buf, "%s", Addr.sun_path);
+ return buf;
+}
+
+
+
diff --git a/comm/UnixAddress.h b/comm/UnixAddress.h
new file mode 100644
index 0000000..d21b619
--- /dev/null
+++ b/comm/UnixAddress.h
@@ -0,0 +1,43 @@
+/*
+ * The Unix Channel
+ *
+ * by Michel Beaudouin-Lafon
+ *
+ * Copyright 1990-1997
+ * Laboratoire de Recherche en Informatique (LRI)
+ *
+ * Unix Addresses
+ *
+ * $Id$
+ * $CurLog$
+ * Created from Address.h
+ */
+
+#ifndef UnixAddress_H_
+#define UnixAddress_H_
+
+#include "cplus_bugs.h"
+#include "error.h"
+#include "Address.h"
+
+
+
+class IvlUnixAddress : public IvlAddress {
+protected:
+ struct sockaddr_un Addr;
+
+public:
+ IvlUnixAddress ();
+ IvlUnixAddress (const char*);
+ ~IvlUnixAddress ();
+
+ int Family ();
+ int Length ();
+ SockAddr* GetSockAddr ();
+ char* StrRepr (char* buf);
+};
+
+
+
+
+#endif /* UnixAddress_H_ */
diff --git a/comm/XtMultiplexer.cc b/comm/XtMultiplexer.cc
index fbd49b5..f20894d 100644
--- a/comm/XtMultiplexer.cc
+++ b/comm/XtMultiplexer.cc
@@ -16,15 +16,14 @@
#include "XtMultiplexer.h"
#include "error.h"
-UchXtMultiplexer :: UchXtMultiplexer ()
-: UchBaseMultiplexer ()
+IvlXtMultiplexer :: IvlXtMultiplexer ()
+: IvlBaseMultiplexer ()
{
memset (ReadId, 0, NFILE * sizeof (XtInputId));
memset (WriteId, 0, NFILE * sizeof (XtInputId));
}
-
-UchXtMultiplexer :: ~UchXtMultiplexer ()
+IvlXtMultiplexer :: ~IvlXtMultiplexer ()
{
}
@@ -32,21 +31,21 @@ UchXtMultiplexer :: ~UchXtMultiplexer ()
static void
inputCB (XtPointer client_data, int*, XtInputId*)
{
- UchChannel* chan = (UchChannel*) client_data;
+ IvlChannel* chan = (IvlChannel*) client_data;
chan->HandleRead ();
}
static void
outputCB (XtPointer client_data, int*, XtInputId*)
{
- UchChannel* chan = (UchChannel*) client_data;
+ IvlChannel* chan = (IvlChannel*) client_data;
chan->HandleWrite ();
}
void
-UchXtMultiplexer :: SetMasks (int fd, IOMODE mode)
+IvlXtMultiplexer :: SetMasks (int fd, IOMODE mode)
{
- UchChannel* ch = Channels [fd];
+ IvlChannel* ch = Channels [fd];
if (!ch)
return;
@@ -78,42 +77,41 @@ UchXtMultiplexer :: SetMasks (int fd, IOMODE mode)
}
void
-UchXtMultiplexer :: FireTimers (void* mpx, XtIntervalId*)
+IvlXtMultiplexer :: FireTimers (void* mpx, XtIntervalId*)
{
- CcuCoreTimer::Fire (((UchXtMultiplexer*) mpx)->GetTimerSet ());
+ IvlCoreTimer::Fire (((IvlXtMultiplexer*) mpx)->GetTimerSet ());
}
void
-UchXtMultiplexer :: SetTimeOut (Millisecond delay)
+IvlXtMultiplexer :: SetTimeOut (Millisecond delay)
{
/* should replace with XtAppAddTimeOut */
- TimeOut = XtAddTimeOut (delay, &UchXtMultiplexer::FireTimers, this);
+ TimeOut = XtAddTimeOut (delay, &IvlXtMultiplexer::FireTimers, this);
}
void
-UchXtMultiplexer :: SuppressTimeOut ()
+IvlXtMultiplexer :: SuppressTimeOut ()
{
XtRemoveTimeOut (TimeOut);
TimeOut = 0;
}
void
-UchXtMultiplexer :: FireSignals (void* mpx)
+IvlXtMultiplexer :: FireSignals (void* mpx)
{
- ((UchXtMultiplexer*) mpx)->HandleDeferredSignals ();
+ ((IvlXtMultiplexer*) mpx)->HandleDeferredSignals ();
}
-
void
-UchXtMultiplexer :: AddSignalHook ()
+IvlXtMultiplexer :: AddSignalHook ()
{
/* should replace with XtAppAddWorkProc */
- XtAddWorkProc ((XtWorkProc) (&UchXtMultiplexer::FireSignals), this);
+ XtAddWorkProc ((XtWorkProc) (&IvlXtMultiplexer::FireSignals), this);
}
MPX_RES
-UchXtMultiplexer :: Loop ()
+IvlXtMultiplexer :: Loop ()
{
XEvent event;
bool waiting = true;
diff --git a/comm/XtMultiplexer.h b/comm/XtMultiplexer.h
index 6ce1301..0057cb5 100644
--- a/comm/XtMultiplexer.h
+++ b/comm/XtMultiplexer.h
@@ -23,7 +23,7 @@
#include <X11/Intrinsic.h>
#undef FALSE
-class UchXtMultiplexer : public UchBaseMultiplexer {
+class IvlXtMultiplexer : public IvlBaseMultiplexer {
private:
static void FireSignals (void*);
static void FireTimers (void*, XtIntervalId*);
@@ -40,8 +40,8 @@ protected:
MPX_RES Loop ();
public:
- UchXtMultiplexer ();
- ~UchXtMultiplexer ();
+ IvlXtMultiplexer ();
+ ~IvlXtMultiplexer ();
};
#endif /* XtMultiplexer_H_ */
diff --git a/comm/error.cc b/comm/error.cc
index f35725a..9ddc674 100644
--- a/comm/error.cc
+++ b/comm/error.cc
@@ -23,11 +23,11 @@ extern "C" int rename (const char*, const char*);
#include <fcntl.h>
#include <stdio.h>
#include <sys/file.h>
-#include "ccu/Time.h"
+#include "ivl/Time.h"
#include <sys/types.h>
#include <sys/stat.h>
-/*?class UchERROR
+/*?class IvlERROR
The set of global functions described here are designed to handle errors.
An error has a type, an origin, and a message.
The type defines how the error is handled.
@@ -235,7 +235,7 @@ LogMessage (const char* msg)
if (! LogOn || LogFd < 0)
return;
- CcuTimeStamp now;
+ IvlTimeStamp now;
// format of time: Sun Sep 16 01:03:52 1973\n\0
// 123456789012345678901234
LogSize += write (LogFd, now.AsString (), 20); // strip year
@@ -343,20 +343,23 @@ SysError (errtype how, const char* who, int exc1, int exc2)
{
extern int errno;
extern int sys_nerr;
- extern char* sys_errlist [];
- char* msg;
+ extern const char* const sys_errlist [];
+ const char* msg;
char defmsg [80];
if (! errno || errno == exc1 || errno == exc2)
return false;
- if (errno >= sys_nerr)
- sprintf (msg = defmsg, "system error code %d", errno);
- else
- if (errno == 0)
+ if (errno >= sys_nerr) {
+ sprintf (defmsg, "system error code %d", errno);
+ msg = defmsg;
+
+ } else if (errno == 0)
msg = "internal error";
+
else
msg = sys_errlist [errno];
+
return HandleError (how, who, msg);
}
diff --git a/comm/error.h b/comm/error.h
index 7d21204..f0245a3 100644
--- a/comm/error.h
+++ b/comm/error.h
@@ -10,17 +10,18 @@
*
* $Id$
* $CurLog$
+ * Removed global.h
*/
-#ifndef UchError_H_
-#define UchError_H_
+#ifndef IvlError_H_
+#define IvlError_H_
#include "cplus_bugs.h"
-#include "ccu/bool.h"
+#include "ivl/bool.h"
#ifdef DOC
// fake class for global functions
-class UchError {
+class IvlError {
};
#endif
@@ -55,5 +56,5 @@ extern void LogMessage (const char*);
extern int errno;
-#endif /* UchError_H_ */
+#endif /* IvlError_H_ */
diff --git a/comm/test.cc b/comm/test.cc
index a6dfabf..ac5faca 100644
--- a/comm/test.cc
+++ b/comm/test.cc
@@ -6,35 +6,35 @@
#define TESTMSG
#ifdef TESTMSG
-class MyRemoteAgent : public UchRemoteAgent {
+class MyRemoteAgent : public IvlRemoteAgent {
public:
- MyRemoteAgent (UchAgent* a, UchChannel* ch) : UchRemoteAgent (a, ch) {}
+ MyRemoteAgent (IvlAgent* a, IvlChannel* ch) : IvlRemoteAgent (a, ch) {}
~MyRemoteAgent () {}
-bool NewMessage (UchMsgBuffer&, bool);
+bool NewMessage (IvlMsgBuffer&, bool);
};
-class MyAgent : public UchAgent {
+class MyAgent : public IvlAgent {
public:
- MyAgent (UchAddress* a) : UchAgent (a) {}
+ MyAgent (IvlAddress* a) : IvlAgent (a) {}
~MyAgent () {}
-UchRemoteAgent* HandleNew (UchChannel* ch) { return new MyRemoteAgent (this, ch); }
+IvlRemoteAgent* HandleNew (IvlChannel* ch) { return new MyRemoteAgent (this, ch); }
};
-class MyMsg : public UchMessage {
- CcuString S1;
- CcuString S2;
+class MyMsg : public IvlMessage {
+ IvlString S1;
+ IvlString S2;
public:
- MyMsg (const char* s1, const char* s2) : UchMessage (), S1 (s1), S2 (s2) {}
- MyMsg () : UchMessage (), S1 ("S1"), S2 ("S2") {}
+ MyMsg (const char* s1, const char* s2) : IvlMessage (), S1 (s1), S2 (s2) {}
+ MyMsg () : IvlMessage (), S1 ("S1"), S2 ("S2") {}
~MyMsg () {}
- void ReadFrom (UchMsgBuffer&, lword);
- void WriteTo (UchMsgBuffer&);
+ void ReadFrom (IvlMsgBuffer&, lword);
+ void WriteTo (IvlMsgBuffer&);
void Dump () { printf ("[%s] [%s]\n", (const char*) S1, (const char*) S2); }
};
bool
-MyRemoteAgent :: NewMessage (UchMsgBuffer& b, bool)
+MyRemoteAgent :: NewMessage (IvlMsgBuffer& b, bool)
{
MyMsg m;
b.Get (m);
@@ -43,30 +43,30 @@ MyRemoteAgent :: NewMessage (UchMsgBuffer& b, bool)
}
void
-MyMsg :: WriteTo (UchMsgBuffer& b)
+MyMsg :: WriteTo (IvlMsgBuffer& b)
{
b << S1 << S2;
}
void
-MyMsg :: ReadFrom (UchMsgBuffer& b, lword len)
+MyMsg :: ReadFrom (IvlMsgBuffer& b, lword len)
{
b >> S1 >> S2;
}
#endif
-UchAgent* A;
-UchPortServer* PS;
+IvlAgent* A;
+IvlPortServer* PS;
const char* BUF;
int
fMatch (const char* match, lword host, sword port, const char*)
{
printf ("0x%lx:%d -> %s\n", host, port, match);
- UchInetAddress* addr = new UchInetAddress (host == UchInetAddress::LoopBack ()
+ IvlInetAddress* addr = new IvlInetAddress (host == IvlInetAddress::LoopBack ()
? LOOPBACK : host, port);
- UchRemoteAgent* ra = A->Contact (addr);
+ IvlRemoteAgent* ra = A->Contact (addr);
if (ra) {
printf ("joined\n");
#ifdef TESTMSG
@@ -84,7 +84,7 @@ void
fQuit (int, int)
{
printf ("quit\n");
- PS->Remove (BUF, *(UchInetAddress*) A->BoundTo ());
+ PS->Remove (BUF, *(IvlInetAddress*) A->BoundTo ());
exit (0);
}
@@ -97,15 +97,15 @@ fTick (Millisecond t)
main (int argc, char** argv)
{
const char* id = argc > 1 ? argv [1] : "";
- UchInetAddress addr (ANYADDR);
+ IvlInetAddress addr (ANYADDR);
#ifdef TESTMSG
MyAgent a (&addr);
#else
- UchAgent a (&addr);
+ IvlAgent a (&addr);
#endif
if (a.Setup ()) {
A = &a;
- UchPortServer ps ("portserv");
+ IvlPortServer ps ("portserv");
PS = &ps;
ps.Match ("portserv:chatty", fMatch);
char buf [64];
@@ -113,10 +113,10 @@ main (int argc, char** argv)
strcat (buf, id);
BUF = buf;
printf ("registering as %s\n", buf);
- ps.Register (buf, *(UchInetAddress*) a.BoundTo ());
- UchSignalHandler h (*a.GetMultiplexer (), SigHup, fQuit);
-// UchTimeOut to (*a.GetMultiplexer (), 1000, fTick);
+ ps.Register (buf, *(IvlInetAddress*) a.BoundTo ());
+ IvlSignalHandler h (*a.GetMultiplexer (), SigHup, fQuit);
+// IvlTimeOut to (*a.GetMultiplexer (), 1000, fTick);
a.Run ();
- ps.Remove (buf, *(UchInetAddress*) a.BoundTo ());
+ ps.Remove (buf, *(IvlInetAddress*) a.BoundTo ());
}
}
diff --git a/comm/testbus.cc b/comm/testbus.cc
index ec06f18..6edeaec 100644
--- a/comm/testbus.cc
+++ b/comm/testbus.cc
@@ -1,21 +1,18 @@
-
-#include "Multiplexer.h"
+#include "Scheduler.h"
#include "TimeOut.h"
#include "BusAccess.h"
-#include "dnn/Reaction.h"
+#include "ivl/Reaction.h"
#include <stdlib.h>
#include <stdio.h>
#include <ostream.h>
-class DnnEvent;
-
+class IvlEvent;
/*
-Global variables. This is because we use DnnCallbacks and functions
-instead of DnnReactions and objects. But this is only a test...
+Global variables. This is because we use IvlCallbacks and functions
+instead of IvlReactions and objects. But this is only a test...
*/
-UchBusAccess* A;
-DnnCallback* C;
-
+IvlBusAccess* A;
+IvlCallback* C;
/*
This is an example of how to emit messages on the bus.
@@ -39,15 +36,15 @@ from the bus. Here, this function is associated to a callback,
which in turn is associated to a regexp (see in main).
*/
void
-print_event (DnnEvent& ev)
+print_event (IvlEvent& ev)
{
- UchBusEvent* be = dynamic_cast<UchBusEvent*> (&ev);
+ IvlBusEvent* be = dynamic_cast<IvlBusEvent*> (&ev);
if (!be)
return;
cout << "Event matches '" << be->Regexp << "'\n";
cout << "\t(" << be->NbMatches << " matches: ";
- CcuListIterOf<CcuString> li = be->MatchList;
+ IvlListIterOf<IvlString> li = be->MatchList;
while (++li)
cout << "'" << **li << "' ";
cout << ")\n";
@@ -58,13 +55,13 @@ This is an example of how to handle a new agent connecting to
the bus. Most applications are not interested in such events...
*/
void
-agentready (DnnEvent& ev)
+agentready (IvlEvent& ev)
{
- UchAgentEvent* ae = dynamic_cast<UchAgentEvent*> (&ev);
+ IvlAgentEvent* ae = dynamic_cast<IvlAgentEvent*> (&ev);
if (!ae)
return;
- UchBusAgent* a = ae->GetAgent ();
+ IvlBusAgent* a = ae->GetAgent ();
cout << "Hello " << a->GetName () << "!\n";
C->SubscribeTo (a->Bye);
@@ -75,45 +72,43 @@ This is an example of how to handle an agent leaving
the bus. Most applications are not interested in such events...
*/
void
-agentbye (DnnEvent& ev)
+agentbye (IvlEvent& ev)
{
- UchAgentEvent* ae = dynamic_cast<UchAgentEvent*> (&ev);
+ IvlAgentEvent* ae = dynamic_cast<IvlAgentEvent*> (&ev);
if (!ae)
return;
- UchBusAgent* a = ae->GetAgent ();
+ IvlBusAgent* a = ae->GetAgent ();
cout << "BYE " << a->GetName () << "!\n";
}
-
-
main ()
{
/* initialize communication library */
- UchOpen ();
+ IvlOpen ();
/* create bus access */
- UchBusAccess a ("Uch test"); A = &a;
+ IvlBusAccess a ("Ivl test"); A = &a;
/* periodically send messages on the bus (see foo for timeout handling) */
- UchTimeOut t (1000, foo);
+ IvlTimeOut t (1000, foo);
/* subscribe to a few event types (see print_event for event handling) */
- /* Note that you can use every subclass of DnnBaseReaction instead
- of DnnCallback */
- DnnCallback c1 (print_event);
+ /* Note that you can use every subclass of IvlBaseReaction instead
+ of IvlCallback */
+ IvlCallback c1 (print_event);
a.Subscribe (c1, "^(CLOCK) (.*)");
a.Subscribe (c1, "TRAFFIC Start");
a.Subscribe (c1, "(.*Tick.*)");
a.Subscribe (c1, "^AIRCRAFT:(.*) Moved (.*)");
/* react to new agents calling (see agentready for event handling) */
- DnnCallback c3 (agentready);
+ IvlCallback c3 (agentready);
c3.SubscribeTo (a.NewAgents);
/* reaction to agents leaving (see agentready for subscription,
and agentbye for event handling) */
- DnnCallback c4 (agentbye); C = &c4;
+ IvlCallback c4 (agentbye); C = &c4;
- UchLoop ();
+ IvlLoop ();
}
diff --git a/comm/version.h b/comm/version.h
index 213c32d..ec6349f 100644
--- a/comm/version.h
+++ b/comm/version.h
@@ -67,10 +67,10 @@ e-mail mbl@lri.fr and chatty@dgac.fr
phone +33 01 69 15 69 10 and +33 05 62 25 95 42
**/
-#ifndef UchVersion
+#ifndef IvlVersion
-#define UchVersion 4
-#define UchRelease 0
-#define UchPatchLevel 0
+#define IvlVersion 4
+#define IvlRelease 0
+#define IvlPatchLevel 0
#endif