winpr: add pragma pack, bitmap + clipboard definitions

This commit is contained in:
Marc-André Moreau 2014-10-16 21:45:47 -04:00
parent f6b3b24c22
commit 334dec3c1f
12 changed files with 635 additions and 303 deletions

View File

@ -214,8 +214,6 @@ void cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 data
{
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
WLog_Print(cliprdr->log, WLOG_DEBUG, "ServerFormatList");
if (context->custom)
{
UINT32 index;
@ -227,7 +225,7 @@ void cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 data
formatList.msgFlags = msgFlags;
formatList.dataLen = dataLen;
formatList.cFormats = 0;
formatList.numFormats = 0;
while (dataLen)
{
@ -237,14 +235,14 @@ void cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 data
formatNameLength = _wcslen((WCHAR*) Stream_Pointer(s));
Stream_Seek(s, (formatNameLength + 1) * 2);
dataLen -= ((formatNameLength + 1) * 2);
formatList.cFormats++;
formatList.numFormats++;
}
index = 0;
dataLen = formatList.dataLen;
Stream_Rewind(s, dataLen);
formats = (CLIPRDR_FORMAT*) malloc(sizeof(CLIPRDR_FORMAT) * formatList.cFormats);
formats = (CLIPRDR_FORMAT*) malloc(sizeof(CLIPRDR_FORMAT) * formatList.numFormats);
formatList.formats = formats;
while (dataLen)
@ -272,10 +270,13 @@ void cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 data
index++;
}
WLog_Print(cliprdr->log, WLOG_DEBUG, "ServerFormatList: numFormats: %d",
formatList.numFormats);
if (context->ServerFormatList)
context->ServerFormatList(context, &formatList);
for (index = 0; index < formatList.cFormats; index++)
for (index = 0; index < formatList.numFormats; index++)
free(formats[index].formatName);
free(formats);
@ -369,6 +370,9 @@ void cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 data
cliprdr->num_format_names = 0;
WLog_Print(cliprdr->log, WLOG_DEBUG, "ServerFormatList: numFormats: %d",
cb_event->num_formats);
cliprdr_send_format_list_response(cliprdr);
svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) cb_event);
}

View File

@ -499,7 +499,7 @@ int cliprdr_client_format_list(CliprdrClientContext* context, CLIPRDR_FORMAT_LIS
CLIPRDR_FORMAT* format;
cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
for (index = 0; index < formatList->cFormats; index++)
for (index = 0; index < formatList->numFormats; index++)
{
format = (CLIPRDR_FORMAT*) &(formatList->formats[index]);
length += 4;
@ -513,7 +513,7 @@ int cliprdr_client_format_list(CliprdrClientContext* context, CLIPRDR_FORMAT_LIS
s = cliprdr_packet_new(CB_FORMAT_LIST, 0, length);
for (index = 0; index < formatList->cFormats; index++)
for (index = 0; index < formatList->numFormats; index++)
{
format = (CLIPRDR_FORMAT*) &(formatList->formats[index]);
Stream_Write_UINT32(s, format->formatId); /* formatId (4 bytes) */
@ -535,7 +535,7 @@ int cliprdr_client_format_list(CliprdrClientContext* context, CLIPRDR_FORMAT_LIS
}
WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFormatList: numFormats: %d",
formatList->cFormats);
formatList->numFormats);
cliprdr_packet_send(cliprdr, s);
return 0;

View File

@ -30,6 +30,7 @@
#endif
#include <winpr/crt.h>
#include <winpr/image.h>
#include <winpr/stream.h>
#include <freerdp/log.h>
@ -93,6 +94,23 @@ struct xf_clipboard
int xf_cliprdr_send_client_format_list(xfClipboard* clipboard);
static void xf_cliprdr_check_owner(xfClipboard* clipboard)
{
Window owner;
xfContext* xfc = clipboard->xfc;
if (clipboard->sync)
{
owner = XGetSelectionOwner(xfc->display, clipboard->clipboard_atom);
if (clipboard->owner != owner)
{
clipboard->owner = owner;
xf_cliprdr_send_client_format_list(clipboard);
}
}
}
static BOOL xf_cliprdr_is_self_owned(xfClipboard* clipboard)
{
Atom type;
@ -168,79 +186,7 @@ static xfCliprdrFormat* xf_cliprdr_get_format_by_atom(xfClipboard* clipboard, At
return NULL;
}
static void xf_cliprdr_send_data_request(xfClipboard* clipboard, UINT32 formatId)
{
CLIPRDR_FORMAT_DATA_REQUEST request;
ZeroMemory(&request, sizeof(CLIPRDR_FORMAT_DATA_REQUEST));
request.requestedFormatId = formatId;
clipboard->context->ClientFormatDataRequest(clipboard->context, &request);
}
static void xf_cliprdr_send_data_response(xfClipboard* clipboard, BYTE* data, int size)
{
CLIPRDR_FORMAT_DATA_RESPONSE response;
ZeroMemory(&response, sizeof(CLIPRDR_FORMAT_DATA_RESPONSE));
response.msgFlags = CB_RESPONSE_OK;
response.dataLen = size;
response.requestedFormatData = data;
clipboard->context->ClientFormatDataResponse(clipboard->context, &response);
}
static void xf_cliprdr_get_requested_targets(xfClipboard* clipboard)
{
int i;
Atom atom;
BYTE* data = NULL;
int format_property;
unsigned long length;
unsigned long bytes_left;
UINT32 numFormats = 0;
CLIPRDR_FORMAT_LIST formatList;
xfCliprdrFormat* format = NULL;
CLIPRDR_FORMAT* formats = NULL;
xfContext* xfc = clipboard->xfc;
if (!clipboard->numServerFormats)
return; /* server format list was not yet received */
XGetWindowProperty(xfc->display, xfc->drawable, clipboard->property_atom,
0, 200, 0, XA_ATOM, &atom, &format_property, &length, &bytes_left, &data);
if (length > 0)
formats = (CLIPRDR_FORMAT*) calloc(length, sizeof(CLIPRDR_FORMAT));
for (i = 0; i < length; i++)
{
atom = ((Atom*) data)[i];
format = xf_cliprdr_get_format_by_atom(clipboard, atom);
if (format)
{
formats[numFormats].formatId = format->formatId;
formats[numFormats].formatName = NULL;
numFormats++;
}
}
XFree(data);
ZeroMemory(&formatList, sizeof(CLIPRDR_FORMAT_LIST));
formatList.msgFlags = CB_RESPONSE_OK;
formatList.cFormats = numFormats;
formatList.formats = formats;
clipboard->context->ClientFormatList(clipboard->context, &formatList);
}
static BYTE* xf_cliprdr_process_requested_raw(BYTE* data, int* size)
static BYTE* xf_cliprdr_format_raw_to_wire(BYTE* data, int* size)
{
BYTE* outbuf;
outbuf = (BYTE*) malloc(*size);
@ -248,7 +194,45 @@ static BYTE* xf_cliprdr_process_requested_raw(BYTE* data, int* size)
return outbuf;
}
static BYTE* xf_cliprdr_process_requested_unicodetext(BYTE* data, int* size)
static int xf_cliprdr_format_text_from_wire(BYTE* pSrcData, int SrcSize, BYTE** ppDstData)
{
int DstSize = -1;
BYTE* pDstData = NULL;
pDstData = (BYTE*) malloc(SrcSize);
CopyMemory(pDstData, pSrcData, SrcSize);
DstSize = ConvertLineEndingToLF((char*) pDstData, SrcSize);
*ppDstData = pDstData;
return DstSize;
}
static BYTE* xf_cliprdr_format_text_to_wire(BYTE* data, int* size)
{
char* outbuf;
outbuf = ConvertLineEndingToCRLF((char*) data, size);
return (BYTE*) outbuf;
}
static int xf_cliprdr_format_unicode_text_from_wire(BYTE* pSrcData, int SrcSize, BYTE** ppDstData)
{
int DstSize = -1;
BYTE* pDstData = NULL;
DstSize = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) pSrcData,
SrcSize / 2, (CHAR**) &pDstData, 0, NULL, NULL);
DstSize = ConvertLineEndingToLF((char*) pDstData, DstSize);
*ppDstData = pDstData;
return DstSize;
}
static BYTE* xf_cliprdr_format_unicode_text_to_wire(BYTE* data, int* size)
{
char* inbuf;
WCHAR* outbuf = NULL;
@ -263,16 +247,49 @@ static BYTE* xf_cliprdr_process_requested_unicodetext(BYTE* data, int* size)
return (BYTE*) outbuf;
}
static BYTE* xf_cliprdr_process_requested_text(BYTE* data, int* size)
static int xf_cliprdr_format_dib_from_wire(BYTE* pSrcData, int SrcSize, BYTE** ppDstData)
{
char* outbuf;
wStream* s;
UINT16 bpp;
UINT32 offset;
UINT32 ncolors;
int DstSize = -1;
BYTE* pDstData = NULL;
outbuf = ConvertLineEndingToCRLF((char*) data, size);
/* size should be at least sizeof(BITMAPINFOHEADER) */
return (BYTE*) outbuf;
if (SrcSize < 40)
return -1;
s = Stream_New(pSrcData, SrcSize);
Stream_Seek(s, 14);
Stream_Read_UINT16(s, bpp);
if ((bpp < 1) || (bpp > 32))
return -1;
Stream_Read_UINT32(s, ncolors);
offset = 14 + 40 + (bpp <= 8 ? (ncolors == 0 ? (1 << bpp) : ncolors) * 4 : 0);
Stream_Free(s, FALSE);
s = Stream_New(NULL, 14 + SrcSize);
Stream_Write_UINT8(s, 'B');
Stream_Write_UINT8(s, 'M');
Stream_Write_UINT32(s, 14 + SrcSize);
Stream_Write_UINT32(s, 0);
Stream_Write_UINT32(s, offset);
Stream_Write(s, pSrcData, SrcSize);
pDstData = Stream_Buffer(s);
DstSize = Stream_GetPosition(s);
Stream_Free(s, FALSE);
*ppDstData = pDstData;
return DstSize;
}
static BYTE* xf_cliprdr_process_requested_dib(BYTE* data, int* size)
static BYTE* xf_cliprdr_format_dib_to_wire(BYTE* data, int* size)
{
BYTE* outbuf;
@ -288,7 +305,38 @@ static BYTE* xf_cliprdr_process_requested_dib(BYTE* data, int* size)
return outbuf;
}
static BYTE* xf_cliprdr_process_requested_html(BYTE* data, int* size)
static int xf_cliprdr_format_html_from_wire(BYTE* pSrcData, int SrcSize, BYTE** ppDstData)
{
int start;
int end;
char* start_str;
char* end_str;
int DstSize = -1;
BYTE* pDstData = NULL;
start_str = strstr((char*) pSrcData, "StartHTML:");
end_str = strstr((char*) pSrcData, "EndHTML:");
if (!start_str || !end_str)
return -1;
start = atoi(start_str + 10);
end = atoi(end_str + 8);
if ((start > SrcSize) || (end > SrcSize) || (start >= end))
return -1;
DstSize = end - start;
pDstData = (BYTE*) malloc(SrcSize - start + 1);
CopyMemory(pDstData, &pSrcData[start], DstSize);
DstSize = ConvertLineEndingToLF((char*) pDstData, DstSize);
*ppDstData = pDstData;
return DstSize;
}
static BYTE* xf_cliprdr_format_html_to_wire(BYTE* data, int* size)
{
char* inbuf;
BYTE* in;
@ -365,6 +413,80 @@ static BYTE* xf_cliprdr_process_requested_html(BYTE* data, int* size)
return outbuf;
}
static void xf_cliprdr_send_data_request(xfClipboard* clipboard, UINT32 formatId)
{
CLIPRDR_FORMAT_DATA_REQUEST request;
ZeroMemory(&request, sizeof(CLIPRDR_FORMAT_DATA_REQUEST));
request.requestedFormatId = formatId;
clipboard->context->ClientFormatDataRequest(clipboard->context, &request);
}
static void xf_cliprdr_send_data_response(xfClipboard* clipboard, BYTE* data, int size)
{
CLIPRDR_FORMAT_DATA_RESPONSE response;
ZeroMemory(&response, sizeof(CLIPRDR_FORMAT_DATA_RESPONSE));
response.msgFlags = CB_RESPONSE_OK;
response.dataLen = size;
response.requestedFormatData = data;
clipboard->context->ClientFormatDataResponse(clipboard->context, &response);
}
static void xf_cliprdr_get_requested_targets(xfClipboard* clipboard)
{
int i;
Atom atom;
BYTE* data = NULL;
int format_property;
unsigned long length;
unsigned long bytes_left;
UINT32 numFormats = 0;
CLIPRDR_FORMAT_LIST formatList;
xfCliprdrFormat* format = NULL;
CLIPRDR_FORMAT* formats = NULL;
xfContext* xfc = clipboard->xfc;
if (!clipboard->numServerFormats)
return; /* server format list was not yet received */
XGetWindowProperty(xfc->display, xfc->drawable, clipboard->property_atom,
0, 200, 0, XA_ATOM, &atom, &format_property, &length, &bytes_left, &data);
if (length > 0)
formats = (CLIPRDR_FORMAT*) calloc(length, sizeof(CLIPRDR_FORMAT));
for (i = 0; i < length; i++)
{
atom = ((Atom*) data)[i];
format = xf_cliprdr_get_format_by_atom(clipboard, atom);
if (format)
{
formats[numFormats].formatId = format->formatId;
formats[numFormats].formatName = format->formatName;
numFormats++;
}
}
XFree(data);
ZeroMemory(&formatList, sizeof(CLIPRDR_FORMAT_LIST));
formatList.msgFlags = CB_RESPONSE_OK;
formatList.numFormats = numFormats;
formatList.formats = formats;
clipboard->context->ClientFormatList(clipboard->context, &formatList);
free(formats);
}
static void xf_cliprdr_process_requested_data(xfClipboard* clipboard, BOOL has_data, BYTE* data, int size)
{
BYTE* outbuf;
@ -387,23 +509,23 @@ static void xf_cliprdr_process_requested_data(xfClipboard* clipboard, BOOL has_d
case CB_FORMAT_PNG:
case CB_FORMAT_JPEG:
case CB_FORMAT_GIF:
outbuf = xf_cliprdr_process_requested_raw(data, &size);
break;
case CLIPRDR_FORMAT_UNICODETEXT:
outbuf = xf_cliprdr_process_requested_unicodetext(data, &size);
outbuf = xf_cliprdr_format_raw_to_wire(data, &size);
break;
case CLIPRDR_FORMAT_TEXT:
outbuf = xf_cliprdr_process_requested_text(data, &size);
outbuf = xf_cliprdr_format_text_to_wire(data, &size);
break;
case CLIPRDR_FORMAT_UNICODETEXT:
outbuf = xf_cliprdr_format_unicode_text_to_wire(data, &size);
break;
case CB_FORMAT_DIB:
outbuf = xf_cliprdr_process_requested_dib(data, &size);
outbuf = xf_cliprdr_format_dib_to_wire(data, &size);
break;
case CB_FORMAT_HTML:
outbuf = xf_cliprdr_process_requested_html(data, &size);
outbuf = xf_cliprdr_format_html_to_wire(data, &size);
break;
default:
@ -552,108 +674,6 @@ static void xf_cliprdr_provide_data(xfClipboard* clipboard, XEvent* respond)
}
}
static int xf_cliprdr_process_text(BYTE* pSrcData, int SrcSize, BYTE** ppDstData)
{
int DstSize = -1;
BYTE* pDstData = NULL;
pDstData = (BYTE*) malloc(SrcSize);
CopyMemory(pDstData, pSrcData, SrcSize);
DstSize = ConvertLineEndingToLF((char*) pDstData, SrcSize);
*ppDstData = pDstData;
return DstSize;
}
static int xf_cliprdr_process_unicodetext(BYTE* pSrcData, int SrcSize, BYTE** ppDstData)
{
int DstSize = -1;
BYTE* pDstData = NULL;
DstSize = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) pSrcData,
SrcSize / 2, (CHAR**) &pDstData, 0, NULL, NULL);
DstSize = ConvertLineEndingToLF((char*) pDstData, DstSize);
*ppDstData = pDstData;
return DstSize;
}
static int xf_cliprdr_process_dib(BYTE* pSrcData, int SrcSize, BYTE** ppDstData)
{
wStream* s;
UINT16 bpp;
UINT32 offset;
UINT32 ncolors;
int DstSize = -1;
BYTE* pDstData = NULL;
/* size should be at least sizeof(BITMAPINFOHEADER) */
if (SrcSize < 40)
return -1;
s = Stream_New(pSrcData, SrcSize);
Stream_Seek(s, 14);
Stream_Read_UINT16(s, bpp);
if ((bpp < 1) || (bpp > 32))
return -1;
Stream_Read_UINT32(s, ncolors);
offset = 14 + 40 + (bpp <= 8 ? (ncolors == 0 ? (1 << bpp) : ncolors) * 4 : 0);
Stream_Free(s, FALSE);
s = Stream_New(NULL, 14 + SrcSize);
Stream_Write_UINT8(s, 'B');
Stream_Write_UINT8(s, 'M');
Stream_Write_UINT32(s, 14 + SrcSize);
Stream_Write_UINT32(s, 0);
Stream_Write_UINT32(s, offset);
Stream_Write(s, pSrcData, SrcSize);
pDstData = Stream_Buffer(s);
DstSize = Stream_GetPosition(s);
Stream_Free(s, FALSE);
*ppDstData = pDstData;
return DstSize;
}
static int xf_cliprdr_process_html(BYTE* pSrcData, int SrcSize, BYTE** ppDstData)
{
int start;
int end;
char* start_str;
char* end_str;
int DstSize = -1;
BYTE* pDstData = NULL;
start_str = strstr((char*) pSrcData, "StartHTML:");
end_str = strstr((char*) pSrcData, "EndHTML:");
if (!start_str || !end_str)
return -1;
start = atoi(start_str + 10);
end = atoi(end_str + 8);
if ((start > SrcSize) || (end > SrcSize) || (start >= end))
return -1;
DstSize = end - start;
pDstData = (BYTE*) malloc(SrcSize - start + 1);
CopyMemory(pDstData, &pSrcData[start], DstSize);
DstSize = ConvertLineEndingToLF((char*) pDstData, DstSize);
*ppDstData = pDstData;
return DstSize;
}
static BOOL xf_cliprdr_process_selection_notify(xfClipboard* clipboard, XEvent* xevent)
{
if (xevent->xselection.target == clipboard->targets[1])
@ -821,23 +841,6 @@ static BOOL xf_cliprdr_process_property_notify(xfClipboard* clipboard, XEvent* x
return TRUE;
}
static void xf_cliprdr_check_owner(xfClipboard* clipboard)
{
Window owner;
xfContext* xfc = clipboard->xfc;
if (clipboard->sync)
{
owner = XGetSelectionOwner(xfc->display, clipboard->clipboard_atom);
if (clipboard->owner != owner)
{
clipboard->owner = owner;
xf_cliprdr_send_client_format_list(clipboard);
}
}
}
void xf_cliprdr_handle_xevent(xfContext* xfc, XEvent* event)
{
xfClipboard* clipboard;
@ -936,7 +939,7 @@ int xf_cliprdr_send_client_format_list(xfClipboard* clipboard)
}
formatList.msgFlags = CB_RESPONSE_OK;
formatList.cFormats = numFormats;
formatList.numFormats = numFormats;
formatList.formats = formats;
clipboard->context->ClientFormatList(clipboard->context, &formatList);
@ -1023,13 +1026,13 @@ static int xf_cliprdr_server_format_list(CliprdrClientContext* context, CLIPRDR_
clipboard->numServerFormats = 0;
}
clipboard->numServerFormats = formatList->cFormats;
clipboard->numServerFormats = formatList->numFormats;
clipboard->serverFormats = (CLIPRDR_FORMAT*) calloc(clipboard->numServerFormats, sizeof(CLIPRDR_FORMAT));
if (!clipboard->serverFormats)
return -1;
for (i = 0; i < formatList->cFormats; i++)
for (i = 0; i < formatList->numFormats; i++)
{
format = &formatList->formats[i];
clipboard->serverFormats[i].formatId = format->formatId;
@ -1038,7 +1041,7 @@ static int xf_cliprdr_server_format_list(CliprdrClientContext* context, CLIPRDR_
clipboard->numTargets = 2;
for (i = 0; i < formatList->cFormats; i++)
for (i = 0; i < formatList->numFormats; i++)
{
format = &formatList->formats[i];
@ -1145,19 +1148,19 @@ static int xf_cliprdr_server_format_data_response(CliprdrClientContext* context,
break;
case CLIPRDR_FORMAT_TEXT:
status = xf_cliprdr_process_text(data, size, &pDstData);
status = xf_cliprdr_format_text_from_wire(data, size, &pDstData);
break;
case CLIPRDR_FORMAT_UNICODETEXT:
status = xf_cliprdr_process_unicodetext(data, size, &pDstData);
status = xf_cliprdr_format_unicode_text_from_wire(data, size, &pDstData);
break;
case CLIPRDR_FORMAT_DIB:
status = xf_cliprdr_process_dib(data, size, &pDstData);
status = xf_cliprdr_format_dib_from_wire(data, size, &pDstData);
break;
case CB_FORMAT_HTML:
status = xf_cliprdr_process_html(data, size, &pDstData);
status = xf_cliprdr_format_html_from_wire(data, size, &pDstData);
break;
default:

View File

@ -149,7 +149,7 @@ struct _CLIPRDR_FORMAT_LIST
{
DEFINE_CLIPRDR_HEADER_COMMON();
UINT32 cFormats;
UINT32 numFormats;
CLIPRDR_FORMAT* formats;
};
typedef struct _CLIPRDR_FORMAT_LIST CLIPRDR_FORMAT_LIST;

View File

@ -25,7 +25,8 @@
#include <freerdp/codec/mppc.h>
#pragma pack(push,1)
#define WINPR_PACK_PUSH
#include <winpr/pack.h>
struct _XCRUSH_MATCH_INFO
{
@ -67,7 +68,8 @@ struct _RDP61_COMPRESSED_DATA
};
typedef struct _RDP61_COMPRESSED_DATA RDP61_COMPRESSED_DATA;
#pragma pack(pop)
#define WINPR_PACK_POP
#include <winpr/pack.h>
struct _XCRUSH_CONTEXT
{

View File

@ -23,6 +23,48 @@
#include <winpr/winpr.h>
#include <winpr/wtypes.h>
#define WINPR_PACK_PUSH
#include <winpr/pack.h>
struct _WINPR_BITMAP_FILE_HEADER
{
BYTE bfType[2];
UINT32 bfSize;
UINT16 bfReserved1;
UINT16 bfReserved2;
UINT32 bfOffBits;
};
typedef struct _WINPR_BITMAP_FILE_HEADER WINPR_BITMAP_FILE_HEADER;
struct _WINPR_BITMAP_INFO_HEADER
{
UINT32 biSize;
INT32 biWidth;
INT32 biHeight;
UINT16 biPlanes;
UINT16 biBitCount;
UINT32 biCompression;
UINT32 biSizeImage;
INT32 biXPelsPerMeter;
INT32 biYPelsPerMeter;
UINT32 biClrUsed;
UINT32 biClrImportant;
};
typedef struct _WINPR_BITMAP_INFO_HEADER WINPR_BITMAP_INFO_HEADER;
struct _WINPR_BITMAP_CORE_HEADER
{
UINT32 bcSize;
UINT16 bcWidth;
UINT16 bcHeight;
UINT16 bcPlanes;
UINT16 bcBitCount;
};
typedef struct _WINPR_BITMAP_CORE_HEADER WINPR_BITMAP_CORE_HEADER;
#define WINPR_PACK_POP
#include <winpr/pack.h>
#define WINPR_IMAGE_BITMAP 0
#define WINPR_IMAGE_PNG 1

101
winpr/include/winpr/pack.h Normal file
View File

@ -0,0 +1,101 @@
/**
* WinPR: Windows Portable Runtime
* Pragma Pack
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This header is meant to be repeatedly included
* after defining the operation to be done:
*
* #define WINPR_PACK_PUSH
* #include <winpr/pack.h> // enables packing
*
* #define WINPR_PACK_POP
* #include <winpr/pack.h> // disables packing
*
* On each include, WINPR_PACK_* macros are undefined.
*/
#if !defined(__APPLE__)
#ifndef WINPR_PRAGMA_PACK_EXT
#define WINPR_PRAGMA_PACK_EXT
#endif
#endif
#ifdef PRAGMA_PACK_PUSH
#ifndef PRAGMA_PACK_PUSH1
#define PRAGMA_PACK_PUSH1
#endif
#undef PRAGMA_PACK_PUSH
#endif
#ifdef PRAGMA_PACK_PUSH1
#ifdef WINPR_PRAGMA_PACK_EXT
#pragma pack(push, 1)
#else
#pragma pack(1)
#endif
#undef PRAGMA_PACK_PUSH1
#endif
#ifdef PRAGMA_PACK_PUSH2
#ifdef WINPR_PRAGMA_PACK_EXT
#pragma pack(push, 2)
#else
#pragma pack(2)
#endif
#undef PRAGMA_PACK_PUSH2
#endif
#ifdef PRAGMA_PACK_PUSH4
#ifdef WINPR_PRAGMA_PACK_EXT
#pragma pack(push, 4)
#else
#pragma pack(4)
#endif
#undef PRAGMA_PACK_PUSH4
#endif
#ifdef PRAGMA_PACK_PUSH8
#ifdef WINPR_PRAGMA_PACK_EXT
#pragma pack(push, 8)
#else
#pragma pack(8)
#endif
#undef PRAGMA_PACK_PUSH8
#endif
#ifdef PRAGMA_PACK_PUSH16
#ifdef WINPR_PRAGMA_PACK_EXT
#pragma pack(push, 16)
#else
#pragma pack(16)
#endif
#undef PRAGMA_PACK_PUSH16
#endif
#ifdef PRAGMA_PACK_POP
#ifdef WINPR_PRAGMA_PACK_EXT
#pragma pack(pop)
#else
#pragma pack()
#endif
#undef PRAGMA_PACK_POP
#endif
#undef WINPR_PRAGMA_PACK_EXT

View File

@ -227,11 +227,8 @@
#define SCARD_NEGOTIABLE 5
#define SCARD_SPECIFIC 6
#if defined(__APPLE__) | defined(sun)
#pragma pack(1)
#else
#pragma pack(push, 1)
#endif
#define WINPR_PACK_PUSH
#include <winpr/pack.h>
typedef struct _SCARD_IO_REQUEST
{
@ -557,11 +554,8 @@ typedef struct
SCARDHANDLE hCardHandle;
} OPENCARDNAMEW, *POPENCARDNAMEW, *LPOPENCARDNAMEW;
#if defined(__APPLE__) | defined(sun)
#pragma pack()
#else
#pragma pack(pop)
#endif
#define WINPR_PACK_POP
#include <winpr/pack.h>
#ifdef UNICODE
#define LPOCNCONNPROC LPOCNCONNPROCW

246
winpr/include/winpr/user.h Normal file
View File

@ -0,0 +1,246 @@
/**
* WinPR: Windows Portable Runtime
* User Environment
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef WINPR_USER_H
#define WINPR_USER_H
#include <winpr/winpr.h>
#include <winpr/wtypes.h>
/**
* Standard Clipboard Formats
*/
#ifndef _WIN32
#define CF_TEXT 1
#define CF_BITMAP 2
#define CF_METAFILEPICT 3
#define CF_SYLK 4
#define CF_DIF 5
#define CF_TIFF 6
#define CF_OEMTEXT 7
#define CF_DIB 8
#define CF_PALETTE 9
#define CF_PENDATA 10
#define CF_RIFF 11
#define CF_WAVE 12
#define CF_UNICODETEXT 13
#define CF_ENHMETAFILE 14
#define CF_HDROP 15
#define CF_LOCALE 16
#define CF_DIBV5 17
#define CF_MAX 18
#define CF_OWNERDISPLAY 0x0080
#define CF_DSPTEXT 0x0081
#define CF_DSPBITMAP 0x0082
#define CF_DSPMETAFILEPICT 0x0083
#define CF_DSPENHMETAFILE 0x008E
#define CF_PRIVATEFIRST 0x0200
#define CF_PRIVATELAST 0x02FF
#define CF_GDIOBJFIRST 0x0300
#define CF_GDIOBJLAST 0x03FF
#endif
/**
* Bitmap Definitions
*/
#ifndef _WIN32
#define WINPR_PACK_PUSH
#include <winpr/pack.h>
typedef LONG FXPT16DOT16, FAR *LPFXPT16DOT16;
typedef LONG FXPT2DOT30, FAR *LPFXPT2DOT30;
typedef struct tagCIEXYZ
{
FXPT2DOT30 ciexyzX;
FXPT2DOT30 ciexyzY;
FXPT2DOT30 ciexyzZ;
} CIEXYZ;
typedef CIEXYZ FAR *LPCIEXYZ;
typedef struct tagICEXYZTRIPLE
{
CIEXYZ ciexyzRed;
CIEXYZ ciexyzGreen;
CIEXYZ ciexyzBlue;
} CIEXYZTRIPLE;
typedef CIEXYZTRIPLE FAR *LPCIEXYZTRIPLE;
typedef struct tagBITMAP
{
LONG bmType;
LONG bmWidth;
LONG bmHeight;
LONG bmWidthBytes;
WORD bmPlanes;
WORD bmBitsPixel;
LPVOID bmBits;
} BITMAP, *PBITMAP, NEAR *NPBITMAP, FAR *LPBITMAP;
typedef struct tagRGBTRIPLE
{
BYTE rgbtBlue;
BYTE rgbtGreen;
BYTE rgbtRed;
} RGBTRIPLE, *PRGBTRIPLE, NEAR *NPRGBTRIPLE, FAR *LPRGBTRIPLE;
typedef struct tagRGBQUAD
{
BYTE rgbBlue;
BYTE rgbGreen;
BYTE rgbRed;
BYTE rgbReserved;
} RGBQUAD;
typedef RGBQUAD FAR* LPRGBQUAD;
#define BI_RGB 0
#define BI_RLE8 1
#define BI_RLE4 2
#define BI_BITFIELDS 3
#define BI_JPEG 4
#define BI_PNG 5
#define PROFILE_LINKED 'LINK'
#define PROFILE_EMBEDDED 'MBED'
typedef struct tagBITMAPCOREHEADER
{
DWORD bcSize;
WORD bcWidth;
WORD bcHeight;
WORD bcPlanes;
WORD bcBitCount;
} BITMAPCOREHEADER, FAR *LPBITMAPCOREHEADER, *PBITMAPCOREHEADER;
typedef struct tagBITMAPINFOHEADER
{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER, FAR *LPBITMAPINFOHEADER, *PBITMAPINFOHEADER;
typedef struct
{
DWORD bV4Size;
LONG bV4Width;
LONG bV4Height;
WORD bV4Planes;
WORD bV4BitCount;
DWORD bV4V4Compression;
DWORD bV4SizeImage;
LONG bV4XPelsPerMeter;
LONG bV4YPelsPerMeter;
DWORD bV4ClrUsed;
DWORD bV4ClrImportant;
DWORD bV4RedMask;
DWORD bV4GreenMask;
DWORD bV4BlueMask;
DWORD bV4AlphaMask;
DWORD bV4CSType;
CIEXYZTRIPLE bV4Endpoints;
DWORD bV4GammaRed;
DWORD bV4GammaGreen;
DWORD bV4GammaBlue;
} BITMAPV4HEADER, FAR *LPBITMAPV4HEADER, *PBITMAPV4HEADER;
typedef struct
{
DWORD bV5Size;
LONG bV5Width;
LONG bV5Height;
WORD bV5Planes;
WORD bV5BitCount;
DWORD bV5Compression;
DWORD bV5SizeImage;
LONG bV5XPelsPerMeter;
LONG bV5YPelsPerMeter;
DWORD bV5ClrUsed;
DWORD bV5ClrImportant;
DWORD bV5RedMask;
DWORD bV5GreenMask;
DWORD bV5BlueMask;
DWORD bV5AlphaMask;
DWORD bV5CSType;
CIEXYZTRIPLE bV5Endpoints;
DWORD bV5GammaRed;
DWORD bV5GammaGreen;
DWORD bV5GammaBlue;
DWORD bV5Intent;
DWORD bV5ProfileData;
DWORD bV5ProfileSize;
DWORD bV5Reserved;
} BITMAPV5HEADER, FAR *LPBITMAPV5HEADER, *PBITMAPV5HEADER;
typedef struct tagBITMAPINFO
{
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO, FAR *LPBITMAPINFO, *PBITMAPINFO;
typedef struct tagBITMAPCOREINFO
{
BITMAPCOREHEADER bmciHeader;
RGBTRIPLE bmciColors[1];
} BITMAPCOREINFO, FAR *LPBITMAPCOREINFO, *PBITMAPCOREINFO;
typedef struct tagBITMAPFILEHEADER
{
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} BITMAPFILEHEADER, FAR *LPBITMAPFILEHEADER, *PBITMAPFILEHEADER;
#define WINPR_PACK_POP
#include <winpr/pack.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* WINPR_USER_H */

View File

@ -379,4 +379,6 @@ typedef WORD LANGID;
#endif
#include <winpr/user.h>
#endif /* WINPR_WTYPES_H */

View File

@ -78,9 +78,8 @@ typedef long PCSC_LONG;
#define PCSC_SCARD_CTL_CODE(code) (0x42000000 + (code))
#define PCSC_CM_IOCTL_GET_FEATURE_REQUEST SCARD_CTL_CODE(3400)
#ifdef __APPLE__
#pragma pack(1)
#endif
#define WINPR_PACK_PUSH
#include <winpr/pack.h>
typedef struct
{
@ -99,16 +98,6 @@ typedef struct
PCSC_DWORD cbPciLength;
} PCSC_SCARD_IO_REQUEST;
#ifdef __APPLE__
#pragma pack()
#endif
#if defined(__APPLE__) | defined(sun)
#pragma pack(1)
#else
#pragma pack(push, 1)
#endif
typedef struct
{
BYTE tag;
@ -116,11 +105,8 @@ typedef struct
UINT32 value;
} PCSC_TLV_STRUCTURE;
#if defined(__APPLE__) | defined(sun)
#pragma pack()
#else
#pragma pack(pop)
#endif
#define WINPR_PACK_POP
#include <winpr/pack.h>
struct _PCSCFunctionTable
{

View File

@ -34,54 +34,6 @@
* Refer to "Compressed Image File Formats: JPEG, PNG, GIF, XBM, BMP" book
*/
#if defined(__APPLE__)
#pragma pack(1)
#else
#pragma pack(push, 1)
#endif
struct _WINPR_BITMAP_FILE_HEADER
{
BYTE bfType[2];
UINT32 bfSize;
UINT16 bfReserved1;
UINT16 bfReserved2;
UINT32 bfOffBits;
};
typedef struct _WINPR_BITMAP_FILE_HEADER WINPR_BITMAP_FILE_HEADER;
struct _WINPR_BITMAP_INFO_HEADER
{
UINT32 biSize;
INT32 biWidth;
INT32 biHeight;
UINT16 biPlanes;
UINT16 biBitCount;
UINT32 biCompression;
UINT32 biSizeImage;
INT32 biXPelsPerMeter;
INT32 biYPelsPerMeter;
UINT32 biClrUsed;
UINT32 biClrImportant;
};
typedef struct _WINPR_BITMAP_INFO_HEADER WINPR_BITMAP_INFO_HEADER;
struct _WINPR_BITMAP_CORE_HEADER
{
UINT32 bcSize;
UINT16 bcWidth;
UINT16 bcHeight;
UINT16 bcPlanes;
UINT16 bcBitCount;
};
typedef struct _WINPR_BITMAP_CORE_HEADER WINPR_BITMAP_CORE_HEADER;
#if defined(__APPLE__)
#pragma pack()
#else
#pragma pack(pop)
#endif
int winpr_bitmap_write(const char* filename, BYTE* data, int width, int height, int bpp)
{
FILE* fp;