summaryrefslogtreecommitdiffstats
path: root/src/lib/common
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2018-04-25 18:07:30 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2018-04-25 18:07:30 -0400
commit9b1b081cfdb1c0fb6457278775e0823f8bc10f62 (patch)
treece8840148d8445055ba9e4f12263b2208f234c16 /src/lib/common
Import Upstream version 2.0.0+dfsgupstream/2.0.0+dfsg
Diffstat (limited to 'src/lib/common')
-rw-r--r--src/lib/common/CMakeLists.txt24
-rw-r--r--src/lib/common/IInterface.h32
-rw-r--r--src/lib/common/MacOSXPrecomp.h23
-rw-r--r--src/lib/common/Version.cpp29
-rw-r--r--src/lib/common/Version.h39
-rw-r--r--src/lib/common/basic_types.h92
-rw-r--r--src/lib/common/common.h58
-rw-r--r--src/lib/common/stdbitset.h21
-rw-r--r--src/lib/common/stddeque.h21
-rw-r--r--src/lib/common/stdexcept.h23
-rw-r--r--src/lib/common/stdfstream.h22
-rw-r--r--src/lib/common/stdistream.h47
-rw-r--r--src/lib/common/stdlist.h21
-rw-r--r--src/lib/common/stdmap.h21
-rw-r--r--src/lib/common/stdostream.h25
-rw-r--r--src/lib/common/stdpost.h21
-rw-r--r--src/lib/common/stdpre.h31
-rw-r--r--src/lib/common/stdset.h21
-rw-r--r--src/lib/common/stdsstream.h376
-rw-r--r--src/lib/common/stdstring.h21
-rw-r--r--src/lib/common/stdvector.h21
21 files changed, 989 insertions, 0 deletions
diff --git a/src/lib/common/CMakeLists.txt b/src/lib/common/CMakeLists.txt
new file mode 100644
index 0000000..56d9fc9
--- /dev/null
+++ b/src/lib/common/CMakeLists.txt
@@ -0,0 +1,24 @@
+# barrier -- mouse and keyboard sharing utility
+# Copyright (C) 2012-2016 Symless Ltd.
+# Copyright (C) 2009 Nick Bolton
+#
+# This package is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# found in the file LICENSE that should have accompanied this file.
+#
+# This package is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+file(GLOB headers "*.h")
+file(GLOB sources "*.cpp")
+
+if (BARRIER_ADD_HEADERS)
+ list(APPEND sources ${headers})
+endif()
+
+add_library(common STATIC ${sources})
diff --git a/src/lib/common/IInterface.h b/src/lib/common/IInterface.h
new file mode 100644
index 0000000..84a76a9
--- /dev/null
+++ b/src/lib/common/IInterface.h
@@ -0,0 +1,32 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "common/common.h"
+
+//! Base class of interfaces
+/*!
+This is the base class of all interface classes. An interface class has
+only pure virtual methods.
+*/
+class IInterface {
+public:
+ //! Interface destructor does nothing
+ virtual ~IInterface() { }
+};
diff --git a/src/lib/common/MacOSXPrecomp.h b/src/lib/common/MacOSXPrecomp.h
new file mode 100644
index 0000000..7dbc8d0
--- /dev/null
+++ b/src/lib/common/MacOSXPrecomp.h
@@ -0,0 +1,23 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ //
+// Prefix header for all source files of the 'deleteme' target in the 'deleteme' project.
+//
+
+#include <Carbon/Carbon.h>
diff --git a/src/lib/common/Version.cpp b/src/lib/common/Version.cpp
new file mode 100644
index 0000000..94d6c5d
--- /dev/null
+++ b/src/lib/common/Version.cpp
@@ -0,0 +1,29 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2004 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/Version.h"
+
+const char* kApplication = "Barrier";
+const char* kCopyright = "Copyright (C) 2018 Debauchee Open Source Group\n"
+ "Copyright (C) 2012-2016 Symless Ltd.\n"
+ "Copyright (C) 2008-2014 Nick Bolton\n"
+ "Copyright (C) 2002-2014 Chris Schoeneman";
+const char* kContact = "Email: todo@mail.com";
+const char* kWebsite = "https://github.com/debauchee/barrier/";
+const char* kVersion = BARRIER_VERSION;
+const char* kAppVersion = "Barrier " BARRIER_VERSION;
diff --git a/src/lib/common/Version.h b/src/lib/common/Version.h
new file mode 100644
index 0000000..66bb2e2
--- /dev/null
+++ b/src/lib/common/Version.h
@@ -0,0 +1,39 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "common/common.h"
+
+// set version macro if not set yet
+#if !defined(BARRIER_VERSION)
+#error Version was not set (should be passed to compiler).
+#endif
+
+// important strings
+extern const char* kApplication;
+extern const char* kCopyright;
+extern const char* kContact;
+extern const char* kWebsite;
+
+// build version. follows linux kernel style: an even minor number implies
+// a release version, odd implies development version.
+extern const char* kVersion;
+
+// application version
+extern const char* kAppVersion;
diff --git a/src/lib/common/basic_types.h b/src/lib/common/basic_types.h
new file mode 100644
index 0000000..f84550c
--- /dev/null
+++ b/src/lib/common/basic_types.h
@@ -0,0 +1,92 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "common/common.h"
+
+//
+// pick types of particular sizes
+//
+
+#if !defined(TYPE_OF_SIZE_1)
+# if SIZEOF_CHAR == 1
+# define TYPE_OF_SIZE_1 char
+# endif
+#endif
+
+#if !defined(TYPE_OF_SIZE_2)
+# if SIZEOF_INT == 2
+# define TYPE_OF_SIZE_2 int
+# else
+# define TYPE_OF_SIZE_2 short
+# endif
+#endif
+
+#if !defined(TYPE_OF_SIZE_4)
+ // Carbon defines SInt32 and UInt32 in terms of long
+# if SIZEOF_INT == 4 && !defined(__APPLE__)
+# define TYPE_OF_SIZE_4 int
+# else
+# define TYPE_OF_SIZE_4 long
+# endif
+#endif
+
+ //
+// verify existence of required types
+//
+
+#if !defined(TYPE_OF_SIZE_1)
+# error No 1 byte integer type
+#endif
+#if !defined(TYPE_OF_SIZE_2)
+# error No 2 byte integer type
+#endif
+#if !defined(TYPE_OF_SIZE_4)
+# error No 4 byte integer type
+#endif
+
+
+//
+// make typedefs
+//
+// except for SInt8 and UInt8 these types are only guaranteed to be
+// at least as big as indicated (in bits). that is, they may be
+// larger than indicated.
+//
+
+// Added this because it doesn't compile on OS X 10.6 because they are already defined in Carbon
+#if !defined(__MACTYPES__)
+#if defined(__APPLE__)
+#include <CoreServices/CoreServices.h>
+#else
+typedef signed TYPE_OF_SIZE_1 SInt8;
+typedef signed TYPE_OF_SIZE_2 SInt16;
+typedef signed TYPE_OF_SIZE_4 SInt32;
+typedef unsigned TYPE_OF_SIZE_1 UInt8;
+typedef unsigned TYPE_OF_SIZE_2 UInt16;
+typedef unsigned TYPE_OF_SIZE_4 UInt32;
+#endif
+#endif
+//
+// clean up
+//
+
+#undef TYPE_OF_SIZE_1
+#undef TYPE_OF_SIZE_2
+#undef TYPE_OF_SIZE_4
diff --git a/src/lib/common/common.h b/src/lib/common/common.h
new file mode 100644
index 0000000..5ea215f
--- /dev/null
+++ b/src/lib/common/common.h
@@ -0,0 +1,58 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#if defined(_WIN32)
+# define SYSAPI_WIN32 1
+# define WINAPI_MSWINDOWS 1
+#elif HAVE_CONFIG_H
+# include "config.h"
+#else
+# error "config.h missing"
+#endif
+
+// VC++ has built-in sized types
+#if defined(_MSC_VER)
+# include <wchar.h>
+# define TYPE_OF_SIZE_1 __int8
+# define TYPE_OF_SIZE_2 __int16
+# define TYPE_OF_SIZE_4 __int32
+#else
+# define SIZE_OF_CHAR 1
+# define SIZE_OF_SHORT 2
+# define SIZE_OF_INT 4
+# define SIZE_OF_LONG 4
+#endif
+
+// define NULL
+#include <stddef.h>
+
+// make assert available since we use it a lot
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+enum {
+ kExitSuccess = 0, // successful completion
+ kExitFailed = 1, // general failure
+ kExitTerminated = 2, // killed by signal
+ kExitArgs = 3, // bad arguments
+ kExitConfig = 4, // cannot read configuration
+ kExitSubscription = 5 // subscription error
+};
diff --git a/src/lib/common/stdbitset.h b/src/lib/common/stdbitset.h
new file mode 100644
index 0000000..1096249
--- /dev/null
+++ b/src/lib/common/stdbitset.h
@@ -0,0 +1,21 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/stdpre.h"
+#include <bitset>
+#include "common/stdpost.h"
diff --git a/src/lib/common/stddeque.h b/src/lib/common/stddeque.h
new file mode 100644
index 0000000..ffaed24
--- /dev/null
+++ b/src/lib/common/stddeque.h
@@ -0,0 +1,21 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/stdpre.h"
+#include <deque>
+#include "common/stdpost.h"
diff --git a/src/lib/common/stdexcept.h b/src/lib/common/stdexcept.h
new file mode 100644
index 0000000..2bd96b3
--- /dev/null
+++ b/src/lib/common/stdexcept.h
@@ -0,0 +1,23 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2014-2016 Symless Ltd.
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdexcept>
+
+// apple declares _NOEXCEPT
+#ifndef _NOEXCEPT
+# define _NOEXCEPT throw()
+#endif
diff --git a/src/lib/common/stdfstream.h b/src/lib/common/stdfstream.h
new file mode 100644
index 0000000..e9aa263
--- /dev/null
+++ b/src/lib/common/stdfstream.h
@@ -0,0 +1,22 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/stdpre.h"
+#include <fstream>
+#include "common/stdpost.h"
+#include "common/stdistream.h"
diff --git a/src/lib/common/stdistream.h b/src/lib/common/stdistream.h
new file mode 100644
index 0000000..b19e2ab
--- /dev/null
+++ b/src/lib/common/stdistream.h
@@ -0,0 +1,47 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/stdpre.h"
+#if HAVE_ISTREAM
+#include <istream>
+#else
+#include <iostream>
+#endif
+#include "common/stdpost.h"
+
+#if defined(_MSC_VER) && _MSC_VER <= 1200
+// VC++6 istream has no overloads for __int* types, .NET does
+inline
+std::istream& operator>>(std::istream& s, SInt8& i)
+{ return s >> (signed char&)i; }
+inline
+std::istream& operator>>(std::istream& s, SInt16& i)
+{ return s >> (short&)i; }
+inline
+std::istream& operator>>(std::istream& s, SInt32& i)
+{ return s >> (int&)i; }
+inline
+std::istream& operator>>(std::istream& s, UInt8& i)
+{ return s >> (unsigned char&)i; }
+inline
+std::istream& operator>>(std::istream& s, UInt16& i)
+{ return s >> (unsigned short&)i; }
+inline
+std::istream& operator>>(std::istream& s, UInt32& i)
+{ return s >> (unsigned int&)i; }
+#endif
diff --git a/src/lib/common/stdlist.h b/src/lib/common/stdlist.h
new file mode 100644
index 0000000..d530e57
--- /dev/null
+++ b/src/lib/common/stdlist.h
@@ -0,0 +1,21 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/stdpre.h"
+#include <list>
+#include "common/stdpost.h"
diff --git a/src/lib/common/stdmap.h b/src/lib/common/stdmap.h
new file mode 100644
index 0000000..2351074
--- /dev/null
+++ b/src/lib/common/stdmap.h
@@ -0,0 +1,21 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/stdpre.h"
+#include <map>
+#include "common/stdpost.h"
diff --git a/src/lib/common/stdostream.h b/src/lib/common/stdostream.h
new file mode 100644
index 0000000..bb82285
--- /dev/null
+++ b/src/lib/common/stdostream.h
@@ -0,0 +1,25 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/stdpre.h"
+#if HAVE_OSTREAM
+#include <ostream>
+#else
+#include <iostream>
+#endif
+#include "common/stdpost.h"
diff --git a/src/lib/common/stdpost.h b/src/lib/common/stdpost.h
new file mode 100644
index 0000000..8046da0
--- /dev/null
+++ b/src/lib/common/stdpost.h
@@ -0,0 +1,21 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif
diff --git a/src/lib/common/stdpre.h b/src/lib/common/stdpre.h
new file mode 100644
index 0000000..8ccd308
--- /dev/null
+++ b/src/lib/common/stdpre.h
@@ -0,0 +1,31 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if defined(_MSC_VER)
+#pragma warning(disable: 4786) // identifier truncated
+#pragma warning(disable: 4514) // unreferenced inline
+#pragma warning(disable: 4710) // not inlined
+#pragma warning(disable: 4663) // C++ change, template specialization
+#pragma warning(disable: 4503) // decorated name length too long
+#pragma warning(push, 3)
+#pragma warning(disable: 4018) // signed/unsigned mismatch
+#pragma warning(disable: 4284)
+#pragma warning(disable: 4146) // unary minus on unsigned value
+#pragma warning(disable: 4127) // conditional expression is constant
+#pragma warning(disable: 4701) // variable possibly used uninitialized
+#endif
diff --git a/src/lib/common/stdset.h b/src/lib/common/stdset.h
new file mode 100644
index 0000000..1c98971
--- /dev/null
+++ b/src/lib/common/stdset.h
@@ -0,0 +1,21 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/stdpre.h"
+#include <set>
+#include "common/stdpost.h"
diff --git a/src/lib/common/stdsstream.h b/src/lib/common/stdsstream.h
new file mode 100644
index 0000000..43671ff
--- /dev/null
+++ b/src/lib/common/stdsstream.h
@@ -0,0 +1,376 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/stdpre.h"
+
+#if HAVE_SSTREAM || !defined(__GNUC__) || (__GNUC__ >= 3)
+
+#include <sstream>
+
+#elif defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 95)
+// g++ 2.95 didn't ship with sstream. the following is a backport
+// by Magnus Fromreide of the sstream in g++ 3.0.
+
+/* This is part of libio/iostream, providing -*- C++ -*- input/output.
+Copyright (C) 2012-2016 Symless Ltd.
+Copyright (C) 2000 Free Software Foundation
+
+This file is part of the GNU IO Library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this library; see the file LICENSE. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+/* Written by Magnus Fromreide (magfr@lysator.liu.se). */
+/* seekoff and ideas for overflow is largely borrowed from libstdc++-v3 */
+
+#include <iostream.h>
+#include <streambuf.h>
+#include <string>
+
+namespace std
+{
+ class stringbuf : public streambuf
+ {
+ public:
+ typedef char char_type;
+ typedef int int_type;
+ typedef streampos pos_type;
+ typedef streamoff off_type;
+
+ explicit
+ stringbuf(int which=ios::in|ios::out)
+ : streambuf(), mode(static_cast<ios::open_mode>(which)),
+ stream(NULL), stream_len(0)
+ {
+ stringbuf_init();
+ }
+
+ explicit
+ stringbuf(const string &str, int which=ios::in|ios::out)
+ : streambuf(), mode(static_cast<ios::open_mode>(which)),
+ stream(NULL), stream_len(0)
+ {
+ if (mode & (ios::in|ios::out))
+ {
+ stream_len = str.size();
+ stream = new char_type[stream_len];
+ str.copy(stream, stream_len);
+ }
+ stringbuf_init();
+ }
+
+ virtual
+ ~stringbuf()
+ {
+ delete[] stream;
+ }
+
+ string
+ str() const
+ {
+ if (pbase() != 0)
+ return string(stream, pptr()-pbase());
+ else
+ return string();
+ }
+
+ void
+ str(const string& str)
+ {
+ delete[] stream;
+ stream_len = str.size();
+ stream = new char_type[stream_len];
+ str.copy(stream, stream_len);
+ stringbuf_init();
+ }
+
+ protected:
+ // The buffer is already in gptr, so if it ends then it is out of data.
+ virtual int
+ underflow()
+ {
+ return EOF;
+ }
+
+ virtual int
+ overflow(int c = EOF)
+ {
+ int res;
+ if (mode & ios::out)
+ {
+ if (c != EOF)
+ {
+ streamsize old_stream_len = stream_len;
+ stream_len += 1;
+ char_type* new_stream = new char_type[stream_len];
+ memcpy(new_stream, stream, old_stream_len);
+ delete[] stream;
+ stream = new_stream;
+ stringbuf_sync(gptr()-eback(), pptr()-pbase());
+ sputc(c);
+ res = c;
+ }
+ else
+ res = EOF;
+ }
+ else
+ res = 0;
+ return res;
+ }
+
+ virtual streambuf*
+ setbuf(char_type* s, streamsize n)
+ {
+ if (n != 0)
+ {
+ delete[] stream;
+ stream = new char_type[n];
+ memcpy(stream, s, n);
+ stream_len = n;
+ stringbuf_sync(0, 0);
+ }
+ return this;
+ }
+
+ virtual pos_type
+ seekoff(off_type off, ios::seek_dir way, int which = ios::in | ios::out)
+ {
+ pos_type ret = pos_type(off_type(-1));
+ bool testin = which & ios::in && mode & ios::in;
+ bool testout = which & ios::out && mode & ios::out;
+ bool testboth = testin && testout && way != ios::cur;
+
+ if (stream_len && ((testin != testout) || testboth))
+ {
+ char_type* beg = stream;
+ char_type* curi = NULL;
+ char_type* curo = NULL;
+ char_type* endi = NULL;
+ char_type* endo = NULL;
+
+ if (testin)
+ {
+ curi = gptr();
+ endi = egptr();
+ }
+ if (testout)
+ {
+ curo = pptr();
+ endo = epptr();
+ }
+
+ off_type newoffi = 0;
+ off_type newoffo = 0;
+ if (way == ios::beg)
+ {
+ newoffi = beg - curi;
+ newoffo = beg - curo;
+ }
+ else if (way == ios::end)
+ {
+ newoffi = endi - curi;
+ newoffo = endo - curo;
+ }
+
+ if (testin && newoffi + off + curi - beg >= 0 &&
+ endi - beg >= newoffi + off + curi - beg)
+ {
+ gbump(newoffi + off);
+ ret = pos_type(newoffi + off + curi);
+ }
+ if (testout && newoffo + off + curo - beg >= 0 &&
+ endo - beg >= newoffo + off + curo - beg)
+ {
+ pbump(newoffo + off);
+ ret = pos_type(newoffo + off + curo);
+ }
+ }
+ return ret;
+ }
+
+ virtual pos_type
+ seekpos(pos_type sp, int which = ios::in | ios::out)
+ {
+ pos_type ret = seekoff(sp, ios::beg, which);
+ return ret;
+ }
+
+ private:
+ void
+ stringbuf_sync(streamsize i, streamsize o)
+ {
+ if (mode & ios::in)
+ setg(stream, stream + i, stream + stream_len);
+ if (mode & ios::out)
+ {
+ setp(stream, stream + stream_len);
+ pbump(o);
+ }
+ }
+ void
+ stringbuf_init()
+ {
+ if (mode & ios::ate)
+ stringbuf_sync(0, stream_len);
+ else
+ stringbuf_sync(0, 0);
+ }
+
+ private:
+ ios::open_mode mode;
+ char_type* stream;
+ streamsize stream_len;
+ };
+
+ class istringstream : public istream {
+ public:
+ typedef char char_type;
+ typedef int int_type;
+ typedef streampos pos_type;
+ typedef streamoff off_type;
+
+ explicit
+ istringstream(int which=ios::in)
+ : istream(&sb), sb(which | ios::in)
+ { }
+
+ explicit
+ istringstream(const string& str, int which=ios::in)
+ : istream(&sb), sb(str, which | ios::in)
+ { }
+
+ stringbuf*
+ rdbuf() const
+ {
+ return const_cast<stringbuf*>(&sb);
+ }
+
+ string
+ str() const
+ {
+ return rdbuf()->str();
+ }
+ void
+ str(const string& s)
+ {
+ rdbuf()->str(s);
+ }
+ private:
+ stringbuf sb;
+ };
+
+ class ostringstream : public ostream {
+ public:
+ typedef char char_type;
+ typedef int int_type;
+ typedef streampos pos_type;
+ typedef streamoff off_type;
+
+ explicit
+ ostringstream(int which=ios::out)
+ : ostream(&sb), sb(which | ios::out)
+ { }
+
+ explicit
+ ostringstream(const string& str, int which=ios::out)
+ : ostream(&sb), sb(str, which | ios::out)
+ { }
+
+ stringbuf*
+ rdbuf() const
+ {
+ return const_cast<stringbuf*>(&sb);
+ }
+
+ string
+ str() const
+ {
+ return rdbuf()->str();
+ }
+
+ void str(const string& s)
+ {
+ rdbuf()->str(s);
+ }
+ private:
+ stringbuf sb;
+ };
+
+ class stringstream : public iostream {
+ public:
+ typedef char char_type;
+ typedef int int_type;
+ typedef streampos pos_type;
+ typedef streamoff off_type;
+
+ explicit
+ stringstream(int which=ios::out|ios::in)
+ : iostream(&sb), sb(which)
+ { }
+
+ explicit
+ stringstream(const string& str, int which=ios::out|ios::in)
+ : iostream(&sb), sb(str, which)
+ { }
+
+ stringbuf*
+ rdbuf() const
+ {
+ return const_cast<stringbuf*>(&sb);
+ }
+
+ string
+ str() const
+ {
+ return rdbuf()->str();
+ }
+
+ void
+ str(const string& s)
+ {
+ rdbuf()->str(s);
+ }
+ private:
+ stringbuf sb;
+ };
+};
+
+#else /* not g++ 2.95 and no <sstream> */
+
+#error "Standard C++ library is missing required sstream header."
+
+#endif /* not g++ 2.95 and no <sstream> */
+
+#include "common/stdpost.h"
+#include "common/stdistream.h"
diff --git a/src/lib/common/stdstring.h b/src/lib/common/stdstring.h
new file mode 100644
index 0000000..f320ca8
--- /dev/null
+++ b/src/lib/common/stdstring.h
@@ -0,0 +1,21 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/stdpre.h"
+#include <string>
+#include "common/stdpost.h"
diff --git a/src/lib/common/stdvector.h b/src/lib/common/stdvector.h
new file mode 100644
index 0000000..ab4b853
--- /dev/null
+++ b/src/lib/common/stdvector.h
@@ -0,0 +1,21 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/stdpre.h"
+#include <vector>
+#include "common/stdpost.h"