Index: trunk/src/VBox/HostServices/SharedClipboard/Makefile.kmk
===================================================================
--- trunk/src/VBox/HostServices/SharedClipboard/Makefile.kmk	(revision 18245)
+++ trunk/src/VBox/HostServices/SharedClipboard/Makefile.kmk	(revision 18398)
@@ -38,10 +38,10 @@
 VBoxSharedClipboard_SOURCES.darwin = \
 	darwin.cpp \
-	clipboard-helper.cpp \
+	$(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/clipboard-helper.cpp \
 	darwin-pasteboard.cpp
 if1of ($(KBUILD_TARGET), linux solaris) ## @todo X11
  ifndef VBOX_HEADLESS
   VBoxSharedClipboard_SOURCES += \
-  	clipboard-helper.cpp \
+  	$(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/clipboard-helper.cpp \
   	x11-clipboard.cpp
  else
Index: trunk/src/VBox/HostServices/SharedClipboard/clipboard-helper.cpp
===================================================================
--- trunk/src/VBox/HostServices/SharedClipboard/clipboard-helper.cpp	(revision 18245)
+++ 	(revision )
@@ -1,265 +1,0 @@
-/* $Id$ */
-/** @file
- * Shared Clipboard: Some helper function for converting between the various eol.
- */
-
-/*
- * Copyright (C) 2006-2008 Sun Microsystems, Inc.
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
- * Clara, CA 95054 USA or visit http://www.sun.com if you need
- * additional information or have any questions.
- */
-
-#include "clipboard-helper.h"
-#include "VBox/log.h"
-#include <iprt/assert.h>
-
-/** @todo use const where appropriate; delinuxifiy the code (*Lin* -> *Host*); use AssertLogRel*. */
-
-int vboxClipboardUtf16GetWinSize(PRTUTF16 pwszSrc, size_t cwSrc, size_t *pcwDest)
-{
-    size_t cwDest, i;
-
-    LogFlowFunc(("pwszSrc=%.*ls, cwSrc=%u\n", cwSrc, pwszSrc, cwSrc));
-    AssertLogRelMsgReturn(pwszSrc != NULL, ("vboxClipboardUtf16GetWinSize: received a null Utf16 string, returning VERR_INVALID_PARAMETER\n"), VERR_INVALID_PARAMETER);
-/** @todo convert the remainder of the Assert stuff to AssertLogRel. */
-    /* We only take little endian Utf16 */
-    if (pwszSrc[0] == UTF16BEMARKER)
-    {
-        LogRel(("vboxClipboardUtf16GetWinSize: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
-        AssertReturn(pwszSrc[0] != UTF16BEMARKER, VERR_INVALID_PARAMETER);
-    }
-    if (cwSrc == 0)
-    {
-        *pcwDest = 0;
-        LogFlowFunc(("empty source string, returning\n"));
-        return VINF_SUCCESS;
-    }
-    cwDest = 0;
-    /* Calculate the size of the destination text string. */
-    /* Is this Utf16 or Utf16-LE? */
-    for (i = (pwszSrc[0] == UTF16LEMARKER ? 1 : 0); i < cwSrc; ++i, ++cwDest)
-    {
-        /* Check for a single line feed */
-        if (pwszSrc[i] == LINEFEED)
-            ++cwDest;
-        /* Check for a single carriage return (MacOS) */
-        if (pwszSrc[i] == CARRIAGERETURN)
-            ++cwDest;
-        if (pwszSrc[i] == 0)
-        {
-            /* Don't count this, as we do so below. */
-            break;
-        }
-    }
-    /* Count the terminating null byte. */
-    ++cwDest;
-    LogFlowFunc(("returning VINF_SUCCESS, %d 16bit words\n", cwDest));
-    *pcwDest = cwDest;
-    return VINF_SUCCESS;
-}
-
-int vboxClipboardUtf16LinToWin(PRTUTF16 pwszSrc, size_t cwSrc, PRTUTF16 pu16Dest,
-                               size_t cwDest)
-{
-    size_t i, j;
-    LogFlowFunc(("pwszSrc=%.*ls, cwSrc=%u\n", cwSrc, pwszSrc, cwSrc));
-    if (!VALID_PTR(pwszSrc) || !VALID_PTR(pu16Dest))
-    {
-        LogRel(("vboxClipboardUtf16LinToWin: received an invalid pointer, pwszSrc=%p, pu16Dest=%p, returning VERR_INVALID_PARAMETER\n", pwszSrc, pu16Dest));
-        AssertReturn(VALID_PTR(pwszSrc) && VALID_PTR(pu16Dest), VERR_INVALID_PARAMETER);
-    }
-    /* We only take little endian Utf16 */
-    if (pwszSrc[0] == UTF16BEMARKER)
-    {
-        LogRel(("vboxClipboardUtf16LinToWin: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
-        AssertReturn(pwszSrc[0] != UTF16BEMARKER, VERR_INVALID_PARAMETER);
-    }
-    if (cwSrc == 0)
-    {
-        if (cwDest == 0)
-        {
-            LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
-            return VERR_BUFFER_OVERFLOW;
-        }
-        pu16Dest[0] = 0;
-        LogFlowFunc(("empty source string, returning\n"));
-        return VINF_SUCCESS;
-    }
-    /* Don't copy the endian marker. */
-    for (i = (pwszSrc[0] == UTF16LEMARKER ? 1 : 0), j = 0; i < cwSrc; ++i, ++j)
-    {
-        /* Don't copy the null byte, as we add it below. */
-        if (pwszSrc[i] == 0)
-            break;
-        if (j == cwDest)
-        {
-            LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
-            return VERR_BUFFER_OVERFLOW;
-        }
-        if (pwszSrc[i] == LINEFEED)
-        {
-            pu16Dest[j] = CARRIAGERETURN;
-            ++j;
-            if (j == cwDest)
-            {
-                LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
-                return VERR_BUFFER_OVERFLOW;
-            }
-        }
-        /* Check for a single carriage return (MacOS) */
-        else if (pwszSrc[i] == CARRIAGERETURN)
-        {
-            /* set cr */
-            pu16Dest[j] = CARRIAGERETURN;
-            ++j;
-            if (j == cwDest)
-            {
-                LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
-                return VERR_BUFFER_OVERFLOW;
-            }
-            /* add the lf */
-            pu16Dest[j] = LINEFEED;
-            continue;
-        }
-        pu16Dest[j] = pwszSrc[i];
-    }
-    /* Add the trailing null. */
-    if (j == cwDest)
-    {
-        LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
-        return VERR_BUFFER_OVERFLOW;
-    }
-    pu16Dest[j] = 0;
-    LogFlowFunc(("rc=VINF_SUCCESS, pu16Dest=%ls\n", pu16Dest));
-    return VINF_SUCCESS;
-}
-
-int vboxClipboardUtf16GetLinSize(PRTUTF16 pwszSrc, size_t cwSrc, size_t *pcwDest)
-{
-    size_t cwDest;
-
-    LogFlowFunc(("pwszSrc=%.*ls, cwSrc=%u\n", cwSrc, pwszSrc, cwSrc));
-    if (!VALID_PTR(pwszSrc))
-    {
-        LogRel(("vboxClipboardUtf16GetLinSize: received an invalid Utf16 string %p.  Returning VERR_INVALID_PARAMETER.\n", pwszSrc));
-        AssertReturn(VALID_PTR(pwszSrc), VERR_INVALID_PARAMETER);
-    }
-    /* We only take little endian Utf16 */
-    if (pwszSrc[0] == UTF16BEMARKER)
-    {
-        LogRel(("vboxClipboardUtf16GetLinSize: received a big endian Utf16 string.  Returning VERR_INVALID_PARAMETER.\n"));
-        AssertReturn(pwszSrc[0] != UTF16BEMARKER, VERR_INVALID_PARAMETER);
-    }
-    if (cwSrc == 0)
-    {
-        LogFlowFunc(("empty source string, returning VINF_SUCCESS\n"));
-        *pcwDest = 0;
-        return VINF_SUCCESS;
-    }
-    /* Calculate the size of the destination text string. */
-    /* Is this Utf16 or Utf16-LE? */
-    if (pwszSrc[0] == UTF16LEMARKER)
-        cwDest = 0;
-    else
-        cwDest = 1;
-    for (size_t i = 0; i < cwSrc; ++i, ++cwDest)
-    {
-        if (   (i + 1 < cwSrc)
-            && (pwszSrc[i] == CARRIAGERETURN)
-            && (pwszSrc[i + 1] == LINEFEED))
-        {
-            ++i;
-        }
-        if (pwszSrc[i] == 0)
-        {
-            break;
-        }
-    }
-    /* Terminating zero */
-    ++cwDest;
-    LogFlowFunc(("returning %d\n", cwDest));
-    *pcwDest = cwDest;
-    return VINF_SUCCESS;
-}
-
-int vboxClipboardUtf16WinToLin(PRTUTF16 pwszSrc, size_t cwSrc, PRTUTF16 pu16Dest,
-                               size_t cwDest)
-{
-    size_t cwDestPos;
-
-    LogFlowFunc(("pwszSrc=%.*ls, cwSrc=%u, pu16Dest=%p, cwDest=%u\n",
-                 cwSrc, pwszSrc, cwSrc, pu16Dest, cwDest));
-    /* A buffer of size 0 may not be an error, but it is not a good idea either. */
-    Assert(cwDest > 0);
-    if (!VALID_PTR(pwszSrc) || !VALID_PTR(pu16Dest))
-    {
-        LogRel(("vboxClipboardUtf16WinToLin: received an invalid ptr, pwszSrc=%p, pu16Dest=%p, returning VERR_INVALID_PARAMETER\n", pwszSrc, pu16Dest));
-        AssertReturn(VALID_PTR(pwszSrc) && VALID_PTR(pu16Dest), VERR_INVALID_PARAMETER);
-    }
-    /* We only take little endian Utf16 */
-    if (pwszSrc[0] == UTF16BEMARKER)
-    {
-        LogRel(("vboxClipboardUtf16WinToLin: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
-        AssertMsgFailedReturn(("received a big endian string\n"), VERR_INVALID_PARAMETER);
-    }
-    if (cwDest == 0)
-    {
-        LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
-        return VERR_BUFFER_OVERFLOW;
-    }
-    if (cwSrc == 0)
-    {
-        pu16Dest[0] = 0;
-        LogFlowFunc(("received empty string.  Returning VINF_SUCCESS\n"));
-        return VINF_SUCCESS;
-    }
-    /* Prepend the Utf16 byte order marker if it is missing. */
-    if (pwszSrc[0] == UTF16LEMARKER)
-    {
-        cwDestPos = 0;
-    }
-    else
-    {
-        pu16Dest[0] = UTF16LEMARKER;
-        cwDestPos = 1;
-    }
-    for (size_t i = 0; i < cwSrc; ++i, ++cwDestPos)
-    {
-        if (pwszSrc[i] == 0)
-        {
-            break;
-        }
-        if (cwDestPos == cwDest)
-        {
-            LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
-            return VERR_BUFFER_OVERFLOW;
-        }
-        if (   (i + 1 < cwSrc)
-            && (pwszSrc[i] == CARRIAGERETURN)
-            && (pwszSrc[i + 1] == LINEFEED))
-        {
-            ++i;
-        }
-        pu16Dest[cwDestPos] = pwszSrc[i];
-    }
-    /* Terminating zero */
-    if (cwDestPos == cwDest)
-    {
-        LogFlowFunc(("returning VERR_BUFFER_OVERFLOW\n"));
-        return VERR_BUFFER_OVERFLOW;
-    }
-    pu16Dest[cwDestPos] = 0;
-    LogFlowFunc(("set string %ls.  Returning\n", pu16Dest + 1));
-    return VINF_SUCCESS;
-}
-
Index: trunk/src/VBox/HostServices/SharedClipboard/clipboard-helper.h
===================================================================
--- trunk/src/VBox/HostServices/SharedClipboard/clipboard-helper.h	(revision 18245)
+++ 	(revision )
@@ -1,90 +1,0 @@
-/* $Id$ */
-/** @file
- * Shared Clipboard: Some helper function for converting between the various eol.
- */
-
-/*
- * Copyright (C) 2006-2008 Sun Microsystems, Inc.
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
- * Clara, CA 95054 USA or visit http://www.sun.com if you need
- * additional information or have any questions.
- */
-
-#ifndef ___CLIPBOARD_HELPER_H
-#define ___CLIPBOARD_HELPER_H
-
-#include <iprt/string.h>
-
-/** Constants needed for string conversions done by the Linux/Mac clipboard code. */
-enum {
-    /** In Linux, lines end with a linefeed character. */
-    LINEFEED = 0xa,
-    /** In Windows, lines end with a carriage return and a linefeed character. */
-    CARRIAGERETURN = 0xd,
-    /** Little endian "real" Utf16 strings start with this marker. */
-    UTF16LEMARKER = 0xfeff,
-    /** Big endian "real" Utf16 strings start with this marker. */
-    UTF16BEMARKER = 0xfffe
-};
-
-/**
- * Get the size of the buffer needed to hold a Utf16-LE zero terminated string with Windows EOLs
- * converted from a Utf16 string with Linux EOLs.
- *
- * @returns RT error code
- *
- * @param   pwszSrc  The source Utf16 string
- * @param   cwSrc    The length in 16 bit words of the source string
- * @retval  pcwDest  The length of the destination string in 16 bit words
- */
-int vboxClipboardUtf16GetWinSize(PRTUTF16 pwszSrc, size_t cwSrc, size_t *pcwDest);
-
-/**
- * Convert a Utf16 text with Linux EOLs to null-terminated Utf16-LE with Windows EOLs.  Does no
- * checking for validity.
- *
- * @returns VBox status code
- *
- * @param   pwszSrc  Source Utf16 text to convert
- * @param   cwSrc    Size of the source text in 16 bit words
- * @retval  pu16Dest Buffer to store the converted text to.
- * @retval  pcwDest  Size of the buffer for the converted text in 16 bit words
- */
-int vboxClipboardUtf16LinToWin(PRTUTF16 pwszSrc, size_t cwSrc, PRTUTF16 pu16Dest, size_t cwDest);
-
-/**
- * Get the size of the buffer needed to hold a zero-terminated Utf16 string with Linux EOLs
- * converted from a Utf16 string with Windows EOLs.
- *
- * @returns RT status code
- *
- * @param   pwszSrc  The source Utf16 string
- * @param   cwSrc    The length in 16 bit words of the source string
- * @retval  pcwDest  The length of the destination string in 16 bit words
- */
-int vboxClipboardUtf16GetLinSize(PRTUTF16 pwszSrc, size_t cwSrc, size_t *pcwDest);
-
-/**
- * Convert Utf16-LE text with Windows EOLs to zero-terminated Utf16 with Linux EOLs.  This
- * function does not verify that the Utf16 is valid.
- *
- * @returns VBox status code
- *
- * @param   pwszSrc       Text to convert
- * @param   cwSrc         Size of the source text in 16 bit words
- * @param   pu16Dest      The buffer to store the converted text to
- * @param   cwDest        The size of the buffer for the destination text in 16 bit words
- */
-int vboxClipboardUtf16WinToLin(PRTUTF16 pwszSrc, size_t cwSrc, PRTUTF16 pu16Dest, size_t cwDest);
-
-#endif
-
Index: trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp
===================================================================
--- trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp	(revision 18245)
+++ trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp	(revision 18398)
@@ -29,5 +29,5 @@
 #include "VBox/log.h"
 #include "VBox/HostServices/VBoxClipboardSvc.h"
-#include "clipboard-helper.h"
+#include "VBox/GuestHost/clipboard-helper.h"
 
 /* For debugging */
Index: trunk/src/VBox/HostServices/SharedClipboard/x11-clipboard.cpp
===================================================================
--- trunk/src/VBox/HostServices/SharedClipboard/x11-clipboard.cpp	(revision 18245)
+++ trunk/src/VBox/HostServices/SharedClipboard/x11-clipboard.cpp	(revision 18398)
@@ -21,7 +21,20 @@
  */
 
+#include <string.h>
+#include <stdio.h>
+#include <stdint.h>
+
+#ifdef RT_OS_SOLARIS
+#include <tsol/label.h>
+#endif
+
 #include <vector>
 
-#include <VBox/HostServices/VBoxClipboardSvc.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Intrinsic.h>
+#include <X11/Shell.h>
+#include <X11/Xproto.h>
+#include <X11/StringDefs.h>
 
 #include <iprt/alloc.h>
@@ -34,21 +47,9 @@
 #include <iprt/process.h>
 #include <iprt/semaphore.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdint.h>
+
+#include <VBox/GuestHost/clipboard-helper.h>
+#include <VBox/HostServices/VBoxClipboardSvc.h>
 
 #include "VBoxClipboard.h"
-#include "clipboard-helper.h"
-
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/Intrinsic.h>
-#include <X11/Shell.h>
-#include <X11/Xproto.h>
-#include <X11/StringDefs.h>
-
-#ifdef RT_OS_SOLARIS
-#include <tsol/label.h>
-#endif
 
 /** Do we want to test Utf16 by disabling other text formats? */
