VirtualBox

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

Last change on this file since 76558 was 76558, checked in by vboxsync, 6 years ago

include/VBox: Use VBOX_INCLUDED_ rather than _vbox_ as header guard prefix, letting scm enforce this (thereby avoiding copy&paste errors like NativeEventQueue.h).

  • Property eol-style set to native
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 6.2 KB
Line 
1/* $Id: clipboard-helper.h 76558 2019-01-01 02:51:45Z 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/** Constants needed for string conversions done by the Linux/Mac clipboard code. */
36enum {
37 /** In Linux, lines end with a linefeed character. */
38 LINEFEED = 0xa,
39 /** In Windows, lines end with a carriage return and a linefeed character. */
40 CARRIAGERETURN = 0xd,
41 /** Little endian "real" UTF-16 strings start with this marker. */
42 UTF16LEMARKER = 0xfeff,
43 /** Big endian "real" UTF-16 strings start with this marker. */
44 UTF16BEMARKER = 0xfffe
45};
46
47/**
48 * Get the size of the buffer needed to hold a UTF-16-LE zero terminated string
49 * with Windows EOLs converted from a UTF-16 string with Linux EOLs.
50 *
51 * @returns VBox status code.
52 *
53 * @param pwszSrc The source UTF-16 string.
54 * @param cwcSrc The length of the source string in RTUTF16 units.
55 * @param pcwcDst The length of the destination string in RTUTF16 units.
56 */
57int vboxClipboardUtf16GetWinSize(PRTUTF16 pwszSrc, size_t cwcSrc, size_t *pcwcDst);
58
59/**
60 * Convert a UTF-16 text with Linux EOLs to null-terminated UTF-16-LE with
61 * Windows EOLs.
62 *
63 * Does no checking for validity.
64 *
65 * @returns VBox status code
66 *
67 * @param pwszSrc Source UTF-16 text to convert.
68 * @param cwcSrc Size of the source text int RTUTF16 units
69 * @param pwszDst Buffer to store the converted text to.
70 * @param cwcDst Size of the buffer for the converted text in RTUTF16 units.
71 */
72int vboxClipboardUtf16LinToWin(PRTUTF16 pwszSrc, size_t cwcSrc, PRTUTF16 pwszDst, size_t cwcDst);
73
74/**
75 * Get the size of the buffer needed to hold a zero-terminated UTF-16 string
76 * with Linux EOLs converted from a UTF-16 string with Windows EOLs.
77 *
78 * @returns RT status code
79 *
80 * @param pwszSrc The source UTF-16 string
81 * @param cwcSrc The length of the source string in RTUTF16 units.
82 * @retval pcwcDst The length of the destination string in RTUTF16 units.
83 */
84int vboxClipboardUtf16GetLinSize(PRTUTF16 pwszSrc, size_t cwcSrc, size_t *pcwcDst);
85
86/**
87 * Convert UTF-16-LE text with Windows EOLs to zero-terminated UTF-16 with Linux
88 * EOLs. This function does not verify that the UTF-16 is valid.
89 *
90 * @returns VBox status code
91 *
92 * @param pwszSrc Text to convert
93 * @param cwcSrc Size of the source text in RTUTF16 units.
94 * @param pwszDst The buffer to store the converted text to
95 * @param cwcDst The size of the buffer for the destination text in RTUTF16
96 * chars.
97 */
98int vboxClipboardUtf16WinToLin(PRTUTF16 pwszSrc, size_t cwcSrc, PRTUTF16 pwszDst, size_t cwcDst);
99
100#pragma pack(1)
101/** @todo r=bird: Why duplicate these structures here, we've got them in
102 * DevVGA.cpp already! */
103/**
104 * Bitmap File Header. Official win32 name is BITMAPFILEHEADER
105 * Always Little Endian.
106 */
107typedef struct BMFILEHEADER
108{
109/** @todo r=bird: this type centric prefixing is what give hungarian notation a bad name... */
110 uint16_t u16Type;
111 uint32_t u32Size;
112 uint16_t u16Reserved1;
113 uint16_t u16Reserved2;
114 uint32_t u32OffBits;
115} BMFILEHEADER;
116/** Pointer to a BMFILEHEADER structure. */
117typedef BMFILEHEADER *PBMFILEHEADER;
118/** BMP file magic number */
119#define BITMAPHEADERMAGIC (RT_H2LE_U16_C(0x4d42))
120
121/**
122 * Bitmap Info Header. Official win32 name is BITMAPINFOHEADER
123 * Always Little Endian.
124 */
125typedef struct BMINFOHEADER
126{
127/** @todo r=bird: this type centric prefixing is what give hungarian notation a bad name... */
128 uint32_t u32Size;
129 uint32_t u32Width;
130 uint32_t u32Height;
131 uint16_t u16Planes;
132 uint16_t u16BitCount;
133 uint32_t u32Compression;
134 uint32_t u32SizeImage;
135 uint32_t u32XBitsPerMeter;
136 uint32_t u32YBitsPerMeter;
137 uint32_t u32ClrUsed;
138 uint32_t u32ClrImportant;
139} BMINFOHEADER;
140/** Pointer to a BMINFOHEADER structure. */
141typedef BMINFOHEADER *PBMINFOHEADER;
142#pragma pack() /** @todo r=bird: Only BMFILEHEADER needs packing. The BMINFOHEADER is perfectly aligned. */
143
144/**
145 * Convert CF_DIB data to full BMP data by prepending the BM header.
146 * Allocates with RTMemAlloc.
147 *
148 * @returns VBox status code
149 *
150 * @param pvSrc DIB data to convert
151 * @param cbSrc Size of the DIB data to convert in bytes
152 * @param ppvDst Where to store the pointer to the buffer for the
153 * destination data
154 * @param pcbDst Pointer to the size of the buffer for the destination
155 * data in bytes.
156 */
157int vboxClipboardDibToBmp(const void *pvSrc, size_t cbSrc, void **ppvDst, size_t *pcbDst);
158
159/**
160 * Get the address and size of CF_DIB data in a full BMP data in the input buffer.
161 * Does not do any allocation.
162 *
163 * @returns VBox status code
164 *
165 * @param pvSrc BMP data to convert
166 * @param cbSrc Size of the BMP data to convert in bytes
167 * @param ppvDst Where to store the pointer to the destination data
168 * @param pcbDst Pointer to the size of the destination data in bytes
169 */
170int vboxClipboardBmpGetDib(const void *pvSrc, size_t cbSrc, const void **ppvDst, size_t *pcbDst);
171
172
173#endif
174
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