Index: src/xplcommon/Acceptor.h
===================================================================
--- src/xplcommon/Acceptor.h	(revision 17)
+++ src/xplcommon/Acceptor.h	(revision 17)
@@ -0,0 +1,116 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef XPLCOMMON_ACCEPTOR_H
+#define XPLCOMMON_ACCEPTOR_H
+//------------------------------------------------------------------------------
+
+#include "Failable.h"
+
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of a connection acceptor for a socket
+
+//------------------------------------------------------------------------------
+
+namespace xplcommon {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Class representing the accepting of an incoming connection on a
+ * socket. It cannot be created directly, only acquired from a server
+ * socket. Usually some more concrete subclass is returned from which
+ * the socket representing the accepted connection can be queried.
+ */
+class Acceptor : public FailableReference<Acceptor>
+{
+public:
+    /**
+     * Destroy the acceptor.
+     */
+    virtual ~Acceptor();
+
+    /**
+     * Start accepting a connection.
+     *
+     * If a connection is already accepted, but not retrieved yet, it
+     * returns true.
+     *
+     * If a new socket becomes immediately available, it returns true.
+     *
+     * If some error occurs, the acceptor is marked as failed.
+     */
+    bool accept();
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace xplcommon */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of a connection acceptor for a socket
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "win32/Acceptor.h"
+
+namespace xplcommon { typedef win32::Acceptor Acceptor; }
+
+//------------------------------------------------------------------------------
+
+#else // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "posix/Acceptor.h"
+
+namespace xplcommon { typedef posix::Acceptor Acceptor; }
+
+//------------------------------------------------------------------------------
+
+#endif // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+#endif // XPLCOMMON_ACCEPTOR_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/xplcommon/BufferedStream.h
===================================================================
--- src/xplcommon/BufferedStream.h	(revision 17)
+++ src/xplcommon/BufferedStream.h	(revision 17)
@@ -0,0 +1,120 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef XPLCOMMON_BUFFEREDSTREAM_H
+#define XPLCOMMON_BUFFEREDSTREAM_H
+//------------------------------------------------------------------------------
+
+#include "Failable.h"
+
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of a buffered stream
+
+//------------------------------------------------------------------------------
+
+namespace xplcommon {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Base class for streams on which a waiter can wait and provides a
+ * reading and/or a writing buffer.
+ */
+class BufferedStream : public Failable
+{
+public:
+    /**
+     * The default buffer capacity.
+     */
+    static const size_t DEFAULT_CAPACITY = 4096;
+
+public:
+    /**
+     * Destroy the buffered waitable.
+     */
+    virtual ~BufferedStream();
+
+    /**
+     * Get the reference of the reading buffer. Note, that it can be a
+     * 0 reference, if the waitable has no reading buffer.
+     */
+    ReadingBuffer& getReadingBuffer();
+
+    /**
+     * Get the reference of the writing buffer. Note, that it can be a
+     * 0 reference, if the waitable has no writing buffer.
+     */
+    WritingBuffer& getWritingBuffer();
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace xplcommon */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of a buffered stream
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+// #include "win32/BufferedStream.h"
+
+// namespace xplcommon { typedef win32::BufferedStream BufferedStream; }
+
+//------------------------------------------------------------------------------
+
+#else // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "posix/BufferedStream.h"
+
+namespace xplcommon { typedef posix::BufferedStream BufferedStream; }
+
+//------------------------------------------------------------------------------
+
+#endif // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+#endif // XPLCOMMON_BUFFEREDSTREAM_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/xplcommon/ClientSocket.h
===================================================================
--- src/xplcommon/ClientSocket.h	(revision 17)
+++ src/xplcommon/ClientSocket.h	(revision 17)
@@ -0,0 +1,107 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef XPLCOMMON_CLIENTSOCKET_H
+#define XPLCOMMON_CLIENTSOCKET_H
+//------------------------------------------------------------------------------
+
+#include "BufferedStream.h"
+
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of a client socket (i.e. one that
+      // connects to a server socket)
+
+//------------------------------------------------------------------------------
+
+namespace xplcommon {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A socket that can be connected to another one.
+ */
+class ClientSocket : public BufferedStream
+{
+public:
+    /**
+     * Destroy the socket.
+     */
+    virtual ~ClientSocket();
+
+    /**
+     * Get the connector. Use this object to connect to another socket.
+     */
+    Connector& getConnector();
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace xplcommon */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of a client socket
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "win32/ClientSocket.h"
+
+namespace xplcommon { typedef win32::ClientSocket ClientSocket; }
+
+//------------------------------------------------------------------------------
+
+#else // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "posix/ClientSocket.h"
+
+namespace xplcommon { typedef posix::ClientSocket ClientSocket; }
+
+//------------------------------------------------------------------------------
+
+#endif // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+#endif // XPLCOMMON_CLIENTSOCKET_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/xplcommon/Connector.h
===================================================================
--- src/xplcommon/Connector.h	(revision 17)
+++ src/xplcommon/Connector.h	(revision 17)
@@ -0,0 +1,112 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef XPLCOMMON_CONNECTOR_H
+#define XPLCOMMON_CONNECTOR_H
+//------------------------------------------------------------------------------
+
+#include "Failable.h"
+
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of a connector for a client socket
+
+//------------------------------------------------------------------------------
+
+namespace xplcommon {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Class representing the creation of a connection to some remote
+ * entity, like a socket or a pipe. It cannot be created directly,
+ * only acquired from a client socket.
+ */
+class Connector : public FailableReference<Connector>
+{
+public:
+    /**
+     * Connect to an address properly set up.
+     *
+     * If the connection succeeds immediately, it indicates success.
+     *
+     * If the connection does not succeed, because it would block, it
+     * sets up the socket to wait for the connection to succeed, and
+     * returns failure.
+     *
+     * If the connection fails for another reason, the error code is
+     * set, and false is returned.
+     */
+    bool connect();
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace xplcommon */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of a connector for a client socket
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "win32/Connector.h"
+
+namespace xplcommon { typedef win32::Connector Connector; }
+
+//------------------------------------------------------------------------------
+
+#else // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "posix/Connector.h"
+
+namespace xplcommon { typedef posix::Connector Connector; }
+
+//------------------------------------------------------------------------------
+
+#endif // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+#endif // XPLCOMMON_CONNECTOR_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/xplcommon/LocalAcceptor.h
===================================================================
--- src/xplcommon/LocalAcceptor.h	(revision 17)
+++ src/xplcommon/LocalAcceptor.h	(revision 17)
@@ -0,0 +1,113 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef XPLCOMMON_LOCALACCEPTOR_H
+#define XPLCOMMON_LOCALACCEPTOR_H
+//------------------------------------------------------------------------------
+
+#include "Acceptor.h"
+
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of a connection acceptor working with local sockets
+
+//------------------------------------------------------------------------------
+
+namespace xplcommon {
+
+//------------------------------------------------------------------------------
+
+/**
+ * An acceptor that provides a LocalSocket for each accepted
+ * connection.
+ */
+class LocalAcceptor : public Acceptor
+{
+public:
+    /**
+     * Get the local socket accepted last. If no socket was accepted,
+     * return 0. The local socket's waiter will be the given one
+     * (which can be 0).
+     */
+    LocalSocket* getSocket(Waiter* waiter,
+                           size_t readingCapacity = LocalSocket::DEFAULT_CAPACITY,
+                           size_t writingCapacity = LocalSocket::DEFAULT_CAPACITY);
+    /**
+     * Get the local socket accepted last. If no socket was accepted,
+     * return 0. The local socket's waiter will be the same as that of
+     * the associated server socket.
+     */
+    LocalSocket* getSocket(size_t readingCapacity = LocalSocket::DEFAULT_CAPACITY,
+                           size_t writingCapacity = LocalSocket::DEFAULT_CAPACITY);
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace xplcommon */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of a connection acceptor working with local sockets
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "win32/LocalAcceptor.h"
+
+namespace xplcommon { typedef win32::LocalAcceptor LocalAcceptor; }
+
+//------------------------------------------------------------------------------
+
+#else // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "posix/LocalAcceptor.h"
+
+namespace xplcommon { typedef posix::LocalAcceptor LocalAcceptor; }
+
+//------------------------------------------------------------------------------
+
+#endif // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+#endif // XPLCOMMON_LOCALACCEPTOR_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/xplcommon/LocalClientSocket.h
===================================================================
--- src/xplcommon/LocalClientSocket.h	(revision 17)
+++ src/xplcommon/LocalClientSocket.h	(revision 17)
@@ -0,0 +1,112 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef XPLCOMMON_LOCALCLIENTSOCKET_H
+#define XPLCOMMON_LOCALCLIENTSOCKET_H
+//------------------------------------------------------------------------------
+
+#include "ClientSocket.h"
+
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of a socket that can be connected to a local, named access point provided by a LocalServerSocket
+
+//------------------------------------------------------------------------------
+
+namespace xplcommon {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Client socket that connects to a server socket locally. On Linux it
+ * is a Unix socket, on Windows it is a named pipe.
+ *
+ * The server socket's name should be given.
+ */
+class LocalClientSocket : public ClientSocket
+{
+public:
+    /**
+     * Construct the client socket with the given name.
+     *
+     * @param waiter the waiter to use for waiting a possible event
+     * occuring on the socket. If given, the socket will be
+     * non-blocking. Otherwise, it will be blocking, and the connect()
+     * function of the Connector might block as well as the reading
+     * and writing buffers.
+     */
+    LocalClientSocket(const char* name, Waiter* waiter = 0,
+                      size_t readingCapacity = DEFAULT_CAPACITY,
+                      size_t writingCapacity = DEFAULT_CAPACITY);
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace xplcommon */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, // The public interface of a socket that can be connected to a local, named access point provided by a LocalServerSocket
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "win32/LocalClientSocket.h"
+
+namespace xplcommon { typedef win32::LocalClientSocket LocalClientSocket; }
+
+//------------------------------------------------------------------------------
+
+#else // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "posix/LocalClientSocket.h"
+
+namespace xplcommon { typedef posix::LocalClientSocket LocalClientSocket; }
+
+//------------------------------------------------------------------------------
+
+#endif // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+#endif // XPLCOMMON_LOCALCLIENTSOCKET_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/xplcommon/LocalServerSocket.h
===================================================================
--- src/xplcommon/LocalServerSocket.h	(revision 17)
+++ src/xplcommon/LocalServerSocket.h	(revision 17)
@@ -0,0 +1,113 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef XPLCOMMON_LOCALSERVERSOCKET_H
+#define XPLCOMMON_LOCALSERVERSOCKET_H
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of a server socket providing a local, named access point
+
+//------------------------------------------------------------------------------
+
+namespace xplcommon {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A server socket that provides a local, named access point. On
+ * Linux, it is a Unix socket, on Windows it is a named pipe.
+ *
+ * It is identified by a name that should be unique for the user.
+ */
+class LocalServerSocket
+{
+public:
+    /**
+     * Construct the socket with the given name.
+     *
+     * It will be bound to the name and able to listen for incoming
+     * connections.
+     *
+     * @param waiter the waiter to use for waiting a possible event
+     * occuring on the socket. If given, the socket will be
+     * non-blocking. Otherwise, it will be blocking, and the accept()
+     * function of the Acceptor might block.
+     */
+    LocalServerSocket(const char* name, Waiter* waiter = 0);
+
+    /**
+     * Get the acceptor.
+     */
+    LocalAcceptor& getAcceptor();
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace xplcommon */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of a server socket providing a local, named access point
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "win32/LocalServerSocket.h"
+
+namespace xplcommon { typedef win32::LocalServerSocket LocalServerSocket; }
+
+//------------------------------------------------------------------------------
+
+#else // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "posix/LocalServerSocket.h"
+
+namespace xplcommon { typedef posix::LocalServerSocket LocalServerSocket; }
+
+//------------------------------------------------------------------------------
+
+#endif // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+#endif // XPLCOMMON_LOCALSERVERSOCKET_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/xplcommon/LocalSocket.h
===================================================================
--- src/xplcommon/LocalSocket.h	(revision 17)
+++ src/xplcommon/LocalSocket.h	(revision 17)
@@ -0,0 +1,97 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef XPLCOMMON_LOCALSOCKET_H
+#define XPLCOMMON_LOCALSOCKET_H
+//------------------------------------------------------------------------------
+
+#include "BufferedStream.h"
+
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of a socket accepted from a local server socket
+
+//------------------------------------------------------------------------------
+
+namespace xplcommon {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A socket that works on a local connection. On Linux, it is a Unix
+ * socket, on Windows it is a named pipe.
+ */
+class LocalSocket : public BufferedStream
+{
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace xplcommon */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of a socket accepted from a local server socket
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "win32/LocalSocket.h"
+
+namespace xplcommon { typedef win32::LocalSocket LocalSocket; }
+
+//------------------------------------------------------------------------------
+
+#else // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "posix/LocalSocket.h"
+
+namespace xplcommon { typedef posix::LocalSocket LocalSocket; }
+
+//------------------------------------------------------------------------------
+
+#endif // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+#endif // XPLCOMMON_LOCALSOCKET_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/xplcommon/Makefile.am
===================================================================
--- src/xplcommon/Makefile.am	(revision 6)
+++ src/xplcommon/Makefile.am	(revision 17)
@@ -22,9 +22,19 @@
 include_xplcommondir=$(includedir)/xplcommon
 include_xplcommon_HEADERS=\
-	config.h	\
-	types.h		\
-	Failable.h	\
-	Thread.h	\
-	Waiter.h	\
-	WaitableEvent.h	\
-	Buffer.h
+	config.h		\
+	types.h			\
+	Failable.h		\
+	Thread.h		\
+	Waiter.h		\
+	WaitableEvent.h		\
+	Buffer.h		\
+	BufferedStream.h	\
+	ReadingBuffer.h		\
+	WritingBuffer.h		\
+	Acceptor.h		\
+	LocalAcceptor.h		\
+	LocalSocket.h		\
+	LocalServerSocket.h	\
+	Connector.h		\
+	ClientSocket.h		\
+	LocalClientSocket.h
Index: src/xplcommon/ReadingBuffer.h
===================================================================
--- src/xplcommon/ReadingBuffer.h	(revision 17)
+++ src/xplcommon/ReadingBuffer.h	(revision 17)
@@ -0,0 +1,122 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef XPLCOMMON_READINGBUFFER_H
+#define XPLCOMMON_READINGBUFFER_H
+//------------------------------------------------------------------------------
+
+#include "Buffer.h"
+#include "Failable.h"
+
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of a reading buffer
+
+//------------------------------------------------------------------------------
+
+namespace xplcommon {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A buffer used for reading from a buffered stream. It cannot be
+ * created directly, only acquired from the stream.
+ *
+ * It should be made empty, and then the function read() should be
+ * called on it. If it returns true, some data could be read. If the
+ * amount of data read is 0, that indicates and end-of-file condition.
+ */
+class ReadingBuffer : public Buffer, public FailableReference<ReadingBuffer>
+{
+public:
+    /**
+     * Read into the buffer using the buffered stream if possible.
+     *
+     * If the buffer contains data, this function returns immediately
+     * with success, so the buffer should be reset before reading.
+     *
+     * If some data can be read immediately, that is stored in the
+     * buffer, and success is indicated. Success is indicated even if
+     * the amount of data read is 0, allowing for signalling the
+     * end-of-file or end-of-connection condition.
+     *
+     * If the reading operation would block, the stream is set up so
+     * that it would read, and failure is returned.
+     *
+     * Otherwise, if the reading operation fails for some other
+     * reason, the buffer's error code is set, so it should always be
+     * checked on a failure!
+     */
+    bool read();
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace xplcommon */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of a reading buffer
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+// #include "win32/ReadingBuffer.h"
+
+// namespace xplcommon { typedef win32::ReadingBuffer ReadingBuffer; }
+
+//------------------------------------------------------------------------------
+
+#else // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "posix/ReadingBuffer.h"
+
+namespace xplcommon { typedef posix::ReadingBuffer ReadingBuffer; }
+
+//------------------------------------------------------------------------------
+
+#endif // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+#endif // XPLCOMMON_READINGBUFFER_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/xplcommon/WaitableEvent.h
===================================================================
--- src/xplcommon/WaitableEvent.h	(revision 9)
+++ src/xplcommon/WaitableEvent.h	(revision 17)
@@ -30,4 +30,8 @@
 #ifndef XPLCOMMON_WAITABLEEVENT_H
 #define XPLCOMMON_WAITABLEEVENT_H
+//------------------------------------------------------------------------------
+
+#include "Failable.h"
+
 //------------------------------------------------------------------------------
 
Index: src/xplcommon/Waiter.h
===================================================================
--- src/xplcommon/Waiter.h	(revision 14)
+++ src/xplcommon/Waiter.h	(revision 17)
@@ -30,4 +30,8 @@
 #ifndef XPLCOMMON_WAITER_H
 #define XPLCOMMON_WAITER_H
+//------------------------------------------------------------------------------
+
+#include "Failable.h"
+
 //------------------------------------------------------------------------------
 
Index: src/xplcommon/WritingBuffer.h
===================================================================
--- src/xplcommon/WritingBuffer.h	(revision 17)
+++ src/xplcommon/WritingBuffer.h	(revision 17)
@@ -0,0 +1,128 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef XPLCOMMON_WRITINGBUFFER_H
+#define XPLCOMMON_WRITINGBUFFER_H
+//------------------------------------------------------------------------------
+
+#include "Buffer.h"
+#include "Failable.h"
+
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of a writing buffer
+
+//------------------------------------------------------------------------------
+
+namespace xplcommon {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A buffer used for writing into a buffered stream.  It cannot be
+ * created directly, only acquired from the stream.
+ *
+ * The data to write should be stored in the buffer. Then write()
+ * should be called. If it returns true, it indicates that all data
+ * has been written. In that case the buffer is automatically emptied.
+ */
+class WritingBuffer : public Buffer, public FailableReference<WritingBuffer>
+{
+public:
+    /**
+     * Reset the buffer. It resets the offset too.
+     */
+    void reset();
+
+    /**
+     * Write the contents of the buffer using the associated buffered
+     * stream.
+     *
+     * If the buffer is empty, the function returns indicating
+     * success.
+     *
+     * If the complete remaining contents could be written, it also indicates
+     * success, and the buffer is reset, ready to be used again.
+     *
+     * If not everything can be written and the write operation
+     * indicates that it would block, this function returns failure
+     * after the stream has been set up  to handle the corresponding
+     * poll events.
+     *
+     * Otherwise, if the writing operation fails for some other
+     * reason, the buffer's error code is set to the error's code and
+     * false is returned.
+     */
+    bool write();
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace xplcommon */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of a writing buffer
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+// #include "win32/WritingBuffer.h"
+
+// namespace xplcommon { typedef win32::WritingBuffer WritingBuffer; }
+
+//------------------------------------------------------------------------------
+
+#else // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "posix/WritingBuffer.h"
+
+namespace xplcommon { typedef posix::WritingBuffer WritingBuffer; }
+
+//------------------------------------------------------------------------------
+
+#endif // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+#endif // XPLCOMMON_WRITINGBUFFER_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/xplcommon/hgccwrapper
===================================================================
--- src/xplcommon/hgccwrapper	(revision 17)
+++ src/xplcommon/hgccwrapper	(revision 17)
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+# Create a skeleton of a wrapper header for a certain class
+
+classname=$1
+uppername=`echo ${classname} | tr a-z A-Z`
+
+cat > "${classname}.h" <<EOF
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef XPLCOMMON_${uppername}_H
+#define XPLCOMMON_${uppername}_H
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of ${classname}
+
+//------------------------------------------------------------------------------
+
+namespace xplcommon {
+
+//------------------------------------------------------------------------------
+
+class ${classname}
+{
+public:
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace xplcommon */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of ${classname}
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "win32/${classname}.h"
+
+namespace xplcommon { typedef win32::${classname} ${classname}; }
+
+//------------------------------------------------------------------------------
+
+#else // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+
+#include "posix/${classname}.h"
+
+namespace xplcommon { typedef posix::${classname} ${classname}; }
+
+//------------------------------------------------------------------------------
+
+#endif // TARGET_API_WIN32
+
+//------------------------------------------------------------------------------
+#endif // XPLCOMMON_${uppername}_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
+EOF
+
+hg add "${classname}.h"
