libfreerdp-core: server-side virtual channel code style cleanup
This commit is contained in:
parent
cdbfc51daf
commit
d6a2f76dd6
@ -296,30 +296,30 @@ static void wts_read_drdynvc_pdu(rdpPeerChannel* channel)
|
||||
}
|
||||
}
|
||||
|
||||
static int wts_write_variable_uint(wStream* stream, UINT32 val)
|
||||
static int wts_write_variable_uint(wStream* s, UINT32 val)
|
||||
{
|
||||
int cb;
|
||||
|
||||
if (val <= 0xFF)
|
||||
{
|
||||
cb = 0;
|
||||
Stream_Write_UINT8(stream, val);
|
||||
Stream_Write_UINT8(s, val);
|
||||
}
|
||||
else if (val <= 0xFFFF)
|
||||
{
|
||||
cb = 1;
|
||||
Stream_Write_UINT16(stream, val);
|
||||
Stream_Write_UINT16(s, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
cb = 2;
|
||||
Stream_Write_UINT32(stream, val);
|
||||
Stream_Write_UINT32(s, val);
|
||||
}
|
||||
|
||||
return cb;
|
||||
}
|
||||
|
||||
static void wts_write_drdynvc_header(wStream *s, BYTE Cmd, UINT32 ChannelId)
|
||||
static void wts_write_drdynvc_header(wStream* s, BYTE Cmd, UINT32 ChannelId)
|
||||
{
|
||||
BYTE* bm;
|
||||
int cbChId;
|
||||
@ -477,9 +477,10 @@ HANDLE WTSVirtualChannelManagerGetEventHandle(HANDLE hServer)
|
||||
return MessageQueue_Event(vcm->queue);
|
||||
}
|
||||
|
||||
static rdpMcsChannel* wts_get_joined_channel_by_name(rdpMcs *mcs, const char *channel_name)
|
||||
static rdpMcsChannel* wts_get_joined_channel_by_name(rdpMcs* mcs, const char* channel_name)
|
||||
{
|
||||
UINT32 index;
|
||||
|
||||
if (!mcs || !channel_name || !strlen(channel_name))
|
||||
return NULL;
|
||||
|
||||
@ -489,14 +490,16 @@ static rdpMcsChannel* wts_get_joined_channel_by_name(rdpMcs *mcs, const char *ch
|
||||
{
|
||||
if (_strnicmp(mcs->channels[index].Name, channel_name, strlen(channel_name)) == 0)
|
||||
return &mcs->channels[index];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static rdpMcsChannel* wts_get_joined_channel_by_id(rdpMcs *mcs, const UINT16 channel_id)
|
||||
static rdpMcsChannel* wts_get_joined_channel_by_id(rdpMcs* mcs, const UINT16 channel_id)
|
||||
{
|
||||
UINT32 index;
|
||||
|
||||
if (!mcs || !channel_id)
|
||||
return NULL;
|
||||
|
||||
@ -506,12 +509,13 @@ static rdpMcsChannel* wts_get_joined_channel_by_id(rdpMcs *mcs, const UINT16 cha
|
||||
{
|
||||
if (mcs->channels[index].ChannelId == channel_id)
|
||||
return &mcs->channels[index];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL WTSIsChannelJoinedByName(freerdp_peer *client, const char *channel_name)
|
||||
BOOL WTSIsChannelJoinedByName(freerdp_peer* client, const char* channel_name)
|
||||
{
|
||||
if (!client || !client->context || !client->context->rdp)
|
||||
return FALSE;
|
||||
@ -519,7 +523,7 @@ BOOL WTSIsChannelJoinedByName(freerdp_peer *client, const char *channel_name)
|
||||
return wts_get_joined_channel_by_name(client->context->rdp->mcs, channel_name) == NULL ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
BOOL WTSIsChannelJoinedById(freerdp_peer *client, const UINT16 channel_id)
|
||||
BOOL WTSIsChannelJoinedById(freerdp_peer* client, const UINT16 channel_id)
|
||||
{
|
||||
if (!client || !client->context || !client->context->rdp)
|
||||
return FALSE;
|
||||
@ -537,27 +541,30 @@ BOOL WTSVirtualChannelManagerIsChannelJoined(HANDLE hServer, const char* name)
|
||||
return wts_get_joined_channel_by_name(vcm->rdp->mcs, name) == NULL ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
UINT16 WTSChannelGetId(freerdp_peer *client, const char *channel_name)
|
||||
UINT16 WTSChannelGetId(freerdp_peer* client, const char* channel_name)
|
||||
{
|
||||
rdpMcsChannel *channel;
|
||||
rdpMcsChannel* channel;
|
||||
|
||||
if (!client || !client->context || !client->context->rdp)
|
||||
return 0;
|
||||
|
||||
channel = wts_get_joined_channel_by_name(client->context->rdp->mcs, channel_name);
|
||||
|
||||
if (!channel)
|
||||
return 0;
|
||||
|
||||
return channel->ChannelId;
|
||||
}
|
||||
|
||||
BOOL WTSChannelSetHandleByName(freerdp_peer *client, const char *channel_name, void *handle)
|
||||
BOOL WTSChannelSetHandleByName(freerdp_peer* client, const char* channel_name, void* handle)
|
||||
{
|
||||
rdpMcsChannel *channel;
|
||||
rdpMcsChannel* channel;
|
||||
|
||||
if (!client || !client->context || !client->context->rdp)
|
||||
return FALSE;
|
||||
|
||||
channel = wts_get_joined_channel_by_name(client->context->rdp->mcs, channel_name);
|
||||
|
||||
if (!channel)
|
||||
return FALSE;
|
||||
|
||||
@ -565,13 +572,15 @@ BOOL WTSChannelSetHandleByName(freerdp_peer *client, const char *channel_name, v
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL WTSChannelSetHandleById(freerdp_peer *client, const UINT16 channel_id, void *handle)
|
||||
BOOL WTSChannelSetHandleById(freerdp_peer* client, const UINT16 channel_id, void* handle)
|
||||
{
|
||||
rdpMcsChannel *channel;
|
||||
rdpMcsChannel* channel;
|
||||
|
||||
if (!client || !client->context || !client->context->rdp)
|
||||
return FALSE;
|
||||
|
||||
channel = wts_get_joined_channel_by_id(client->context->rdp->mcs, channel_id);
|
||||
|
||||
if (!channel)
|
||||
return FALSE;
|
||||
|
||||
@ -579,26 +588,30 @@ BOOL WTSChannelSetHandleById(freerdp_peer *client, const UINT16 channel_id, void
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void *WTSChannelGetHandleByName(freerdp_peer *client, const char *channel_name)
|
||||
void* WTSChannelGetHandleByName(freerdp_peer* client, const char *channel_name)
|
||||
{
|
||||
rdpMcsChannel *channel;
|
||||
rdpMcsChannel* channel;
|
||||
|
||||
if (!client || !client->context || !client->context->rdp)
|
||||
return NULL;
|
||||
|
||||
channel = wts_get_joined_channel_by_name(client->context->rdp->mcs, channel_name);
|
||||
|
||||
if (!channel)
|
||||
return NULL;
|
||||
|
||||
return channel->handle;
|
||||
}
|
||||
|
||||
void *WTSChannelGetHandleById(freerdp_peer *client, const UINT16 channel_id)
|
||||
void* WTSChannelGetHandleById(freerdp_peer* client, const UINT16 channel_id)
|
||||
{
|
||||
rdpMcsChannel *channel;
|
||||
rdpMcsChannel* channel;
|
||||
|
||||
if (!client || !client->context || !client->context->rdp)
|
||||
return NULL;
|
||||
|
||||
channel = wts_get_joined_channel_by_id(client->context->rdp->mcs, channel_id);
|
||||
|
||||
if (!channel)
|
||||
return NULL;
|
||||
|
||||
@ -1054,15 +1067,18 @@ BOOL WINAPI FreeRDP_WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut,
|
||||
buffer = (BYTE*) (messageCtx + 1);
|
||||
|
||||
*pBytesRead = messageCtx->length - messageCtx->offset;
|
||||
|
||||
if (Buffer == NULL || BufferSize == 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (*pBytesRead > BufferSize)
|
||||
*pBytesRead = BufferSize;
|
||||
|
||||
CopyMemory(Buffer, buffer + messageCtx->offset, *pBytesRead);
|
||||
messageCtx->offset += *pBytesRead;
|
||||
|
||||
if (messageCtx->offset >= messageCtx->length)
|
||||
{
|
||||
MessageQueue_Peek(channel->queue, &message, TRUE);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <winpr/stream.h>
|
||||
#include <winpr/collections.h>
|
||||
|
||||
typedef struct rdp_peer_channel rdpPeerChannel;
|
||||
typedef struct WTSVirtualChannelManager WTSVirtualChannelManager;
|
||||
|
||||
#include "rdp.h"
|
||||
@ -59,8 +60,6 @@ enum
|
||||
DVC_OPEN_STATE_CLOSED = 3
|
||||
};
|
||||
|
||||
typedef struct rdp_peer_channel rdpPeerChannel;
|
||||
|
||||
struct rdp_peer_channel
|
||||
{
|
||||
WTSVirtualChannelManager* vcm;
|
||||
|
Loading…
Reference in New Issue
Block a user