1 | /* $Id: clipboard-helper.h 18824 2009-04-07 13:48:13Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Shared Clipboard: Some helper function for converting between the various eol.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | *
|
---|
26 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
27 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
28 | * additional information or have any questions.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #ifndef ___CLIPBOARD_HELPER_H
|
---|
32 | #define ___CLIPBOARD_HELPER_H
|
---|
33 |
|
---|
34 | #include <iprt/string.h>
|
---|
35 |
|
---|
36 | /** Constants needed for string conversions done by the Linux/Mac clipboard code. */
|
---|
37 | enum {
|
---|
38 | /** In Linux, lines end with a linefeed character. */
|
---|
39 | LINEFEED = 0xa,
|
---|
40 | /** In Windows, lines end with a carriage return and a linefeed character. */
|
---|
41 | CARRIAGERETURN = 0xd,
|
---|
42 | /** Little endian "real" Utf16 strings start with this marker. */
|
---|
43 | UTF16LEMARKER = 0xfeff,
|
---|
44 | /** Big endian "real" Utf16 strings start with this marker. */
|
---|
45 | UTF16BEMARKER = 0xfffe
|
---|
46 | };
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Get the size of the buffer needed to hold a Utf16-LE zero terminated string with Windows EOLs
|
---|
50 | * converted from a Utf16 string with Linux EOLs.
|
---|
51 | *
|
---|
52 | * @returns RT error code
|
---|
53 | *
|
---|
54 | * @param pwszSrc The source Utf16 string
|
---|
55 | * @param cwSrc The length in 16 bit words of the source string
|
---|
56 | * @retval pcwDest The length of the destination string in 16 bit words
|
---|
57 | */
|
---|
58 | int vboxClipboardUtf16GetWinSize(PRTUTF16 pwszSrc, size_t cwSrc, size_t *pcwDest);
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Convert a Utf16 text with Linux EOLs to null-terminated Utf16-LE with Windows EOLs. Does no
|
---|
62 | * checking for validity.
|
---|
63 | *
|
---|
64 | * @returns VBox status code
|
---|
65 | *
|
---|
66 | * @param pwszSrc Source Utf16 text to convert
|
---|
67 | * @param cwSrc Size of the source text in 16 bit words
|
---|
68 | * @retval pu16Dest Buffer to store the converted text to.
|
---|
69 | * @retval pcwDest Size of the buffer for the converted text in 16 bit words
|
---|
70 | */
|
---|
71 | int vboxClipboardUtf16LinToWin(PRTUTF16 pwszSrc, size_t cwSrc, PRTUTF16 pu16Dest, size_t cwDest);
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * Get the size of the buffer needed to hold a zero-terminated Utf16 string with Linux EOLs
|
---|
75 | * converted from a Utf16 string with Windows EOLs.
|
---|
76 | *
|
---|
77 | * @returns RT status code
|
---|
78 | *
|
---|
79 | * @param pwszSrc The source Utf16 string
|
---|
80 | * @param cwSrc The length in 16 bit words of the source string
|
---|
81 | * @retval pcwDest The length of the destination string in 16 bit words
|
---|
82 | */
|
---|
83 | int vboxClipboardUtf16GetLinSize(PRTUTF16 pwszSrc, size_t cwSrc, size_t *pcwDest);
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Convert Utf16-LE text with Windows EOLs to zero-terminated Utf16 with Linux EOLs. This
|
---|
87 | * function does not verify that the Utf16 is valid.
|
---|
88 | *
|
---|
89 | * @returns VBox status code
|
---|
90 | *
|
---|
91 | * @param pwszSrc Text to convert
|
---|
92 | * @param cwSrc Size of the source text in 16 bit words
|
---|
93 | * @param pu16Dest The buffer to store the converted text to
|
---|
94 | * @param cwDest The size of the buffer for the destination text in 16 bit words
|
---|
95 | */
|
---|
96 | int vboxClipboardUtf16WinToLin(PRTUTF16 pwszSrc, size_t cwSrc, PRTUTF16 pu16Dest, size_t cwDest);
|
---|
97 |
|
---|
98 | #endif
|
---|
99 |
|
---|