VirtualBox

source: vbox/trunk/include/VBox/GuestHost/clipboard-helper.h@ 80990

Last change on this file since 80990 was 80990, checked in by vboxsync, 5 years ago

Shared Clipboard/Transfers: Update.

  • Property eol-style set to native
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 7.5 KB
Line 
1/* $Id: clipboard-helper.h 80990 2019-09-25 06:20:09Z vboxsync $ */
2/** @file
3 * Shared Clipboard - Some helper function for converting between the various EOLs.
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
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
27#ifndef VBOX_INCLUDED_GuestHost_clipboard_helper_h
28#define VBOX_INCLUDED_GuestHost_clipboard_helper_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <iprt/string.h>
34
35#include <VBox/GuestHost/SharedClipboard.h>
36
37/** Constants needed for string conversions done by the Linux/Mac clipboard code. */
38enum {
39 /** In Linux, lines end with a linefeed character. */
40 LINEFEED = 0xa,
41 /** In Windows, lines end with a carriage return and a linefeed character. */
42 CARRIAGERETURN = 0xd,
43 /** Little endian "real" UTF-16 strings start with this marker. */
44 UTF16LEMARKER = 0xfeff,
45 /** Big endian "real" UTF-16 strings start with this marker. */
46 UTF16BEMARKER = 0xfffe
47};
48
49/**
50 * Get the size of the buffer needed to hold a UTF-16-LE zero terminated string
51 * with Windows EOLs converted from a UTF-16 string with Linux EOLs.
52 *
53 * @returns VBox status code.
54 *
55 * @param pwszSrc The source UTF-16 string.
56 * @param cwcSrc The length of the source string in RTUTF16 units.
57 * @param pcwcDst The length of the destination string in RTUTF16 units.
58 */
59int vboxClipboardUtf16GetWinSize(PRTUTF16 pwszSrc, size_t cwcSrc, size_t *pcwcDst);
60
61/**
62 * Convert a UTF-16 text with Linux EOLs to null-terminated UTF-16-LE with
63 * Windows EOLs.
64 *
65 * Does no checking for validity.
66 *
67 * @returns VBox status code
68 *
69 * @param pwszSrc Source UTF-16 text to convert.
70 * @param cwcSrc Size of the source text int RTUTF16 units
71 * @param pwszDst Buffer to store the converted text to.
72 * @param cwcDst Size of the buffer for the converted text in RTUTF16 units.
73 */
74int vboxClipboardUtf16LinToWin(PRTUTF16 pwszSrc, size_t cwcSrc, PRTUTF16 pwszDst, size_t cwcDst);
75
76/**
77 * Get the size of the buffer needed to hold a zero-terminated UTF-16 string
78 * with Linux EOLs converted from a UTF-16 string with Windows EOLs.
79 *
80 * @returns RT status code
81 *
82 * @param pwszSrc The source UTF-16 string
83 * @param cwcSrc The length of the source string in RTUTF16 units.
84 * @retval pcwcDst The length of the destination string in RTUTF16 units.
85 */
86int vboxClipboardUtf16GetLinSize(PRTUTF16 pwszSrc, size_t cwcSrc, size_t *pcwcDst);
87
88/**
89 * Convert UTF-16-LE text with Windows EOLs to zero-terminated UTF-16 with Linux
90 * EOLs. This function does not verify that the UTF-16 is valid.
91 *
92 * @returns VBox status code
93 *
94 * @param pwszSrc Text to convert
95 * @param cwcSrc Size of the source text in RTUTF16 units.
96 * @param pwszDst The buffer to store the converted text to
97 * @param cwcDst The size of the buffer for the destination text in RTUTF16
98 * chars.
99 */
100int vboxClipboardUtf16WinToLin(PRTUTF16 pwszSrc, size_t cwcSrc, PRTUTF16 pwszDst, size_t cwcDst);
101
102#pragma pack(1)
103/** @todo r=bird: Why duplicate these structures here, we've got them in
104 * DevVGA.cpp already! */
105/**
106 * Bitmap File Header. Official win32 name is BITMAPFILEHEADER
107 * Always Little Endian.
108 */
109typedef struct BMFILEHEADER
110{
111/** @todo r=bird: this type centric prefixing is what give hungarian notation a bad name... */
112 uint16_t u16Type;
113 uint32_t u32Size;
114 uint16_t u16Reserved1;
115 uint16_t u16Reserved2;
116 uint32_t u32OffBits;
117} BMFILEHEADER;
118/** Pointer to a BMFILEHEADER structure. */
119typedef BMFILEHEADER *PBMFILEHEADER;
120/** BMP file magic number */
121#define BITMAPHEADERMAGIC (RT_H2LE_U16_C(0x4d42))
122
123/**
124 * Bitmap Info Header. Official win32 name is BITMAPINFOHEADER
125 * Always Little Endian.
126 */
127typedef struct BMINFOHEADER
128{
129/** @todo r=bird: this type centric prefixing is what give hungarian notation a bad name... */
130 uint32_t u32Size;
131 uint32_t u32Width;
132 uint32_t u32Height;
133 uint16_t u16Planes;
134 uint16_t u16BitCount;
135 uint32_t u32Compression;
136 uint32_t u32SizeImage;
137 uint32_t u32XBitsPerMeter;
138 uint32_t u32YBitsPerMeter;
139 uint32_t u32ClrUsed;
140 uint32_t u32ClrImportant;
141} BMINFOHEADER;
142/** Pointer to a BMINFOHEADER structure. */
143typedef BMINFOHEADER *PBMINFOHEADER;
144#pragma pack() /** @todo r=bird: Only BMFILEHEADER needs packing. The BMINFOHEADER is perfectly aligned. */
145
146/**
147 * Convert CF_DIB data to full BMP data by prepending the BM header.
148 * Allocates with RTMemAlloc.
149 *
150 * @returns VBox status code
151 *
152 * @param pvSrc DIB data to convert
153 * @param cbSrc Size of the DIB data to convert in bytes
154 * @param ppvDst Where to store the pointer to the buffer for the
155 * destination data
156 * @param pcbDst Pointer to the size of the buffer for the destination
157 * data in bytes.
158 */
159int vboxClipboardDibToBmp(const void *pvSrc, size_t cbSrc, void **ppvDst, size_t *pcbDst);
160
161/**
162 * Get the address and size of CF_DIB data in a full BMP data in the input buffer.
163 * Does not do any allocation.
164 *
165 * @returns VBox status code
166 *
167 * @param pvSrc BMP data to convert
168 * @param cbSrc Size of the BMP data to convert in bytes
169 * @param ppvDst Where to store the pointer to the destination data
170 * @param pcbDst Pointer to the size of the destination data in bytes
171 */
172int vboxClipboardBmpGetDib(const void *pvSrc, size_t cbSrc, const void **ppvDst, size_t *pcbDst);
173
174#ifdef LOG_ENABLED
175/**
176 * Dumps HTML data to the debug log.
177 *
178 * @returns VBox status code.
179 * @param pszSrc HTML data to dump.
180 * @param cbSrc Size (in bytes) of HTML data to dump.
181 */
182int VBoxShClDbgDumpHtml(const char *pszSrc, size_t cbSrc);
183
184/**
185 * Dumps data using a specified clipboard format.
186 *
187 * @param pv Pointer to data to dump.
188 * @param cb Size (in bytes) of data to dump.
189 * @param u32Format Clipboard format to use for dumping.
190 */
191void VBoxShClDbgDumpData(const void *pv, size_t cb, SHCLFORMAT u32Format);
192#endif /* LOG_ENABLED */
193
194/**
195 * Translates a Shared Clipboard host function number to a string.
196 *
197 * @returns Function ID string name.
198 * @param uFn The function to translate.
199 */
200const char *VBoxShClHostFunctionToStr(uint32_t uFn);
201
202/**
203 * Translates a Shared Clipboard host message enum to a string.
204 *
205 * @returns Message ID string name.
206 * @param uMsg The message to translate.
207 */
208const char *VBoxShClHostMsgToStr(uint32_t uMsg);
209
210/**
211 * Translates a Shared Clipboard guest message enum to a string.
212 *
213 * @returns Message ID string name.
214 * @param uMsg The message to translate.
215 */
216const char *VBoxShClGuestMsgToStr(uint32_t uMsg);
217
218#endif /* !VBOX_INCLUDED_GuestHost_clipboard_helper_h */
219
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette