Stefan Dirsch
f264e6c6cd
This is former Xvnc but rebuilt to use dynamic server link and containing untested patches. Handle with care. OBS-URL: https://build.opensuse.org/request/show/107750 OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/tigervnc?expand=0&rev=1
243 lines
6.6 KiB
Diff
243 lines
6.6 KiB
Diff
Tylko w o/common/network: Makefile
|
|
diff -aur o/common/network/Socket.h n/common/network/Socket.h
|
|
--- o/common/network/Socket.h 2011-08-09 23:16:40.000000000 +0200
|
|
+++ n/common/network/Socket.h 2012-03-01 15:36:05.274711896 +0100
|
|
@@ -22,9 +22,9 @@
|
|
#define __NETWORK_SOCKET_H__
|
|
|
|
#include <limits.h>
|
|
-#include <rdr/FdInStream.h>
|
|
-#include <rdr/FdOutStream.h>
|
|
-#include <rdr/Exception.h>
|
|
+#include "../rdr/FdInStream.h"
|
|
+#include "../rdr/FdOutStream.h"
|
|
+#include "../rdr/Exception.h"
|
|
|
|
namespace network {
|
|
|
|
diff -aur o/common/network/TcpSocket.cxx n/common/network/TcpSocket.cxx
|
|
--- o/common/network/TcpSocket.cxx 2011-08-09 23:16:40.000000000 +0200
|
|
+++ n/common/network/TcpSocket.cxx 2012-03-01 15:47:39.684622379 +0100
|
|
@@ -20,6 +20,9 @@
|
|
#include <config.h>
|
|
#endif
|
|
|
|
+#include <memory>
|
|
+#include <limits>
|
|
+
|
|
#ifdef WIN32
|
|
//#include <io.h>
|
|
#include <winsock2.h>
|
|
@@ -41,10 +44,10 @@
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
-#include <network/TcpSocket.h>
|
|
-#include <os/net.h>
|
|
-#include <rfb/util.h>
|
|
-#include <rfb/LogWriter.h>
|
|
+#include "../network/TcpSocket.h"
|
|
+#include "../os/net.h"
|
|
+#include "../rfb/util.h"
|
|
+#include "../rfb/LogWriter.h"
|
|
|
|
#ifndef INADDR_NONE
|
|
#define INADDR_NONE ((unsigned long)-1)
|
|
@@ -53,6 +56,71 @@
|
|
#define INADDR_LOOPBACK ((unsigned long)0x7F000001)
|
|
#endif
|
|
|
|
+template < class P_T >
|
|
+class temporary_buffer:protected::std::pair < P_T *,::std::ptrdiff_t >
|
|
+{
|
|
+public:typedef P_T
|
|
+ item_type;
|
|
+public:typedef class
|
|
+ temporary_buffer <
|
|
+ item_type >
|
|
+ itself, &
|
|
+ ref;
|
|
+ typedef itself const &
|
|
+ cref;
|
|
+public:typedef
|
|
+ class::std::pair <
|
|
+ item_type *,::std::ptrdiff_t >
|
|
+ inherited;
|
|
+public:typedef typename
|
|
+ inherited::second_type
|
|
+ size_type;
|
|
+public:
|
|
+temporary_buffer (::std::ptrdiff_t const &p_s = 01)
|
|
+:inherited (::std::get_temporary_buffer < item_type > (p_s))
|
|
+ {
|
|
+ }
|
|
+private:temporary_buffer (cref);
|
|
+ ref
|
|
+ operator = (cref);
|
|
+public:~temporary_buffer ()
|
|
+ {
|
|
+ ::std::return_temporary_buffer (inherited::first);
|
|
+ }
|
|
+public:size_type const &
|
|
+ size () const
|
|
+ {
|
|
+ return
|
|
+ inherited::second;
|
|
+ }
|
|
+public:item_type * const &
|
|
+ buffer () const
|
|
+ {
|
|
+ return
|
|
+ inherited::first;
|
|
+ }
|
|
+public:ref
|
|
+ clear ()
|
|
+ {
|
|
+ inherited::second = size_type ();
|
|
+ return *this;
|
|
+ }
|
|
+protected:inherited & base ()
|
|
+ {
|
|
+ return *this;
|
|
+ }
|
|
+protected:inherited const &
|
|
+ base () const
|
|
+ {
|
|
+ return *
|
|
+ this;
|
|
+ }
|
|
+public:void
|
|
+ swap (ref that)
|
|
+ {
|
|
+ ::std::swap (base (), that.base ());
|
|
+}};
|
|
+
|
|
using namespace network;
|
|
using namespace rdr;
|
|
|
|
@@ -433,8 +501,36 @@
|
|
}
|
|
|
|
void TcpListener::getMyAddresses(std::list<char*>* result) {
|
|
- const hostent* addrs = gethostbyname(0);
|
|
- if (addrs == 0)
|
|
+ hostent a_he, *addrs; typedef ::temporary_buffer < char > tbuf;
|
|
+ tbuf a_hb ((BUFSIZ));
|
|
+ {
|
|
+ tbuf a_hn ((BUFSIZ)); int a_herr;
|
|
+ typedef::std::numeric_limits < tbuf::size_type > tlp;
|
|
+ /* TASK: get host name */
|
|
+ while (a_hn.size ())
|
|
+ if (::gethostname (a_hn.buffer (), a_hn.size ()))
|
|
+ if (a_hn.size () <= tlp::max () >> 01)
|
|
+ if (ENAMETOOLONG == errno)
|
|
+ {
|
|
+ tbuf a_h1 (a_hn.size () << 01);
|
|
+ if (a_h1.size () > a_hn.size ()) a_hn.swap (a_h1);
|
|
+ else throw rdr::SystemException("gethostname", errorNumber);
|
|
+ } else throw rdr::SystemException("gethostname", errorNumber);
|
|
+ else throw rdr::SystemException("gethostname", errorNumber);
|
|
+ else break;
|
|
+ /* TASK: get host address */
|
|
+ while
|
|
+ (::gethostbyname_r (a_hn. buffer (), &a_he, a_hb. buffer (), a_hb. size (), &addrs, &a_herr))
|
|
+ if (ERANGE == errno)
|
|
+ if (a_hb .size () < tlp ::max () >> 01)
|
|
+ {
|
|
+ tbuf a_h1 (a_hb. size () << 01);
|
|
+ if (a_h1. size () > a_hb .size ()) a_hb. swap (a_h1);
|
|
+ else break;
|
|
+ } else break;
|
|
+ else throw rdr::SystemException("gethostbyname", errorNumber);
|
|
+ }
|
|
+ if (addrs != &a_he)
|
|
throw rdr::SystemException("gethostbyname", errorNumber);
|
|
if (addrs->h_addrtype != AF_INET)
|
|
throw rdr::Exception("getMyAddresses: bad family");
|
|
diff -aur o/common/network/TcpSocket.h n/common/network/TcpSocket.h
|
|
--- o/common/network/TcpSocket.h 2011-08-09 23:16:40.000000000 +0200
|
|
+++ n/common/network/TcpSocket.h 2012-03-01 15:35:15.950711772 +0100
|
|
@@ -28,7 +28,7 @@
|
|
#ifndef __NETWORK_TCP_SOCKET_H__
|
|
#define __NETWORK_TCP_SOCKET_H__
|
|
|
|
-#include <network/Socket.h>
|
|
+#include "../network/Socket.h"
|
|
|
|
#include <list>
|
|
|
|
diff -aur o/common/rdr/FdInStream.h n/common/rdr/FdInStream.h
|
|
--- o/common/rdr/FdInStream.h 2011-08-09 23:16:40.000000000 +0200
|
|
+++ n/common/rdr/FdInStream.h 2012-03-01 15:37:56.128712175 +0100
|
|
@@ -23,7 +23,7 @@
|
|
#ifndef __RDR_FDINSTREAM_H__
|
|
#define __RDR_FDINSTREAM_H__
|
|
|
|
-#include <rdr/InStream.h>
|
|
+#include "../rdr/InStream.h"
|
|
|
|
namespace rdr {
|
|
|
|
diff -aur o/common/rdr/FdOutStream.h n/common/rdr/FdOutStream.h
|
|
--- o/common/rdr/FdOutStream.h 2011-08-09 23:16:40.000000000 +0200
|
|
+++ n/common/rdr/FdOutStream.h 2012-03-01 15:39:48.662712452 +0100
|
|
@@ -23,7 +23,7 @@
|
|
#ifndef __RDR_FDOUTSTREAM_H__
|
|
#define __RDR_FDOUTSTREAM_H__
|
|
|
|
-#include <rdr/OutStream.h>
|
|
+#include "../rdr/OutStream.h"
|
|
|
|
namespace rdr {
|
|
|
|
diff -aur o/common/rdr/InStream.h n/common/rdr/InStream.h
|
|
--- o/common/rdr/InStream.h 2011-08-09 23:16:40.000000000 +0200
|
|
+++ n/common/rdr/InStream.h 2012-03-01 15:38:39.737712279 +0100
|
|
@@ -24,7 +24,7 @@
|
|
#ifndef __RDR_INSTREAM_H__
|
|
#define __RDR_INSTREAM_H__
|
|
|
|
-#include <rdr/types.h>
|
|
+#include "../rdr/types.h"
|
|
#include <string.h> // for memcpy
|
|
|
|
namespace rdr {
|
|
diff -aur o/common/rdr/OutStream.h n/common/rdr/OutStream.h
|
|
--- o/common/rdr/OutStream.h 2011-08-09 23:16:40.000000000 +0200
|
|
+++ n/common/rdr/OutStream.h 2012-03-01 15:40:25.833712551 +0100
|
|
@@ -24,7 +24,7 @@
|
|
#ifndef __RDR_OUTSTREAM_H__
|
|
#define __RDR_OUTSTREAM_H__
|
|
|
|
-#include <rdr/types.h>
|
|
+#include "../rdr/types.h"
|
|
#include <string.h> // for memcpy
|
|
|
|
namespace rdr {
|
|
diff -aur o/common/rfb/Configuration.h n/common/rfb/Configuration.h
|
|
--- o/common/rfb/Configuration.h 2011-08-09 23:16:44.000000000 +0200
|
|
+++ n/common/rfb/Configuration.h 2012-03-01 15:43:33.825713012 +0100
|
|
@@ -43,7 +43,7 @@
|
|
#ifndef __RFB_CONFIGURATION_H__
|
|
#define __RFB_CONFIGURATION_H__
|
|
|
|
-#include <rfb/util.h>
|
|
+#include "../rfb/util.h"
|
|
|
|
namespace rfb {
|
|
class VoidParameter;
|
|
diff -aur o/common/rfb/LogWriter.h n/common/rfb/LogWriter.h
|
|
--- o/common/rfb/LogWriter.h 2011-08-09 23:16:44.000000000 +0200
|
|
+++ n/common/rfb/LogWriter.h 2012-03-01 15:42:44.843712885 +0100
|
|
@@ -22,8 +22,8 @@
|
|
#define __RFB_LOG_WRITER_H__
|
|
|
|
#include <stdarg.h>
|
|
-#include <rfb/Logger.h>
|
|
-#include <rfb/Configuration.h>
|
|
+#include "../rfb/Logger.h"
|
|
+#include "../rfb/Configuration.h"
|
|
|
|
// Each log writer instance has a unique textual name,
|
|
// and is attached to a particular Log instance and
|