GUACAMOLE-25: Convert guac_client pointer to/from a string for sake of FreeRDP's DVC API.
This commit is contained in:
parent
21ab9d765d
commit
36cc9f492f
@ -27,6 +27,7 @@ libguac_client_rdp_la_SOURCES = \
|
|||||||
audio_input.c \
|
audio_input.c \
|
||||||
client.c \
|
client.c \
|
||||||
input.c \
|
input.c \
|
||||||
|
ptr_string.c \
|
||||||
rdp.c \
|
rdp.c \
|
||||||
rdp_bitmap.c \
|
rdp_bitmap.c \
|
||||||
rdp_cliprdr.c \
|
rdp_cliprdr.c \
|
||||||
@ -46,7 +47,8 @@ libguac_client_rdp_la_SOURCES = \
|
|||||||
user.c
|
user.c
|
||||||
|
|
||||||
guacai_sources = \
|
guacai_sources = \
|
||||||
guac_ai/ai_service.c
|
guac_ai/ai_service.c \
|
||||||
|
ptr_string.c
|
||||||
|
|
||||||
guacsvc_sources = \
|
guacsvc_sources = \
|
||||||
guac_svc/svc_service.c \
|
guac_svc/svc_service.c \
|
||||||
@ -87,6 +89,7 @@ noinst_HEADERS = \
|
|||||||
audio_input.h \
|
audio_input.h \
|
||||||
client.h \
|
client.h \
|
||||||
input.h \
|
input.h \
|
||||||
|
ptr_string.h \
|
||||||
rdp.h \
|
rdp.h \
|
||||||
rdp_bitmap.h \
|
rdp_bitmap.h \
|
||||||
rdp_cliprdr.h \
|
rdp_cliprdr.h \
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "audio_input.h"
|
#include "audio_input.h"
|
||||||
|
#include "ptr_string.h"
|
||||||
|
#include "rdp.h"
|
||||||
|
|
||||||
#include <freerdp/freerdp.h>
|
#include <freerdp/freerdp.h>
|
||||||
#include <freerdp/channels/channels.h>
|
#include <freerdp/channels/channels.h>
|
||||||
@ -63,11 +65,14 @@ int guac_rdp_audio_end_handler(guac_user* user, guac_stream* stream) {
|
|||||||
|
|
||||||
void guac_rdp_audio_load_plugin(rdpContext* context) {
|
void guac_rdp_audio_load_plugin(rdpContext* context) {
|
||||||
|
|
||||||
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
||||||
|
|
||||||
/* Add "AUDIO_INPUT" channel */
|
/* Add "AUDIO_INPUT" channel */
|
||||||
ADDIN_ARGV* args = malloc(sizeof(ADDIN_ARGV));
|
ADDIN_ARGV* args = malloc(sizeof(ADDIN_ARGV));
|
||||||
args->argc = 1;
|
args->argc = 1;
|
||||||
args->argv = malloc(sizeof(char**) * 1);
|
args->argv = malloc(sizeof(char**) * 1);
|
||||||
args->argv[0] = strdup("guacai");
|
args->argv[0] = strdup("guacai");
|
||||||
|
args->argv[1] = guac_rdp_ptr_to_string(client);
|
||||||
freerdp_dynamic_channel_collection_add(context->settings, args);
|
freerdp_dynamic_channel_collection_add(context->settings, args);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "ai_service.h"
|
#include "ai_service.h"
|
||||||
|
#include "ptr_string.h"
|
||||||
#include "rdp.h"
|
#include "rdp.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -41,10 +42,8 @@
|
|||||||
*/
|
*/
|
||||||
int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) {
|
int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) {
|
||||||
|
|
||||||
rdpSettings* settings = pEntryPoints->GetRdpSettings(pEntryPoints);
|
ADDIN_ARGV* args = pEntryPoints->GetPluginData(pEntryPoints);
|
||||||
freerdp* instance = settings->instance;
|
guac_client* client = (guac_client*) guac_rdp_string_to_ptr(args->argv[1]);
|
||||||
rdpContext* context = instance->context;
|
|
||||||
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
|
||||||
|
|
||||||
/* STUB */
|
/* STUB */
|
||||||
guac_client_log(client, GUAC_LOG_DEBUG,
|
guac_client_log(client, GUAC_LOG_DEBUG,
|
||||||
|
55
src/protocols/rdp/ptr_string.c
Normal file
55
src/protocols/rdp/ptr_string.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "ptr_string.h"
|
||||||
|
|
||||||
|
#include <guacamole/client.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of bytes required to represent a pointer printed using
|
||||||
|
* printf()'s "%p". This will be the size of the hex prefix ("0x"), null
|
||||||
|
* terminator, plus two bytes for every byte required by a pointer.
|
||||||
|
*/
|
||||||
|
#define GUAC_RDP_PTR_STRING_LENGTH (sizeof("0x") + (sizeof(void*) * 2))
|
||||||
|
|
||||||
|
char* guac_rdp_ptr_to_string(void* data) {
|
||||||
|
|
||||||
|
/* Convert pointer to string */
|
||||||
|
char* str = malloc(GUAC_RDP_PTR_STRING_LENGTH);
|
||||||
|
sprintf(str, "%p", data);
|
||||||
|
|
||||||
|
return str;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void* guac_rdp_string_to_ptr(const char* str) {
|
||||||
|
|
||||||
|
void* data;
|
||||||
|
|
||||||
|
/* Convert string to pointer */
|
||||||
|
sscanf(str, "%p", &data);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
57
src/protocols/rdp/ptr_string.h
Normal file
57
src/protocols/rdp/ptr_string.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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 GUAC_RDP_PTR_STRING_H
|
||||||
|
#define GUAC_RDP_PTR_STRING_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <guacamole/client.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the given string back into a void pointer. The string MUST have
|
||||||
|
* been produced via guac_rdp_ptr_to_string().
|
||||||
|
*
|
||||||
|
* @param str
|
||||||
|
* The string to convert back to a pointer.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The pointer value of the given string, as originally passed to
|
||||||
|
* guac_rdp_ptr_to_string().
|
||||||
|
*/
|
||||||
|
void* guac_rdp_string_to_ptr(const char* str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a void pointer into a string representation, safe for use with
|
||||||
|
* parts of the FreeRDP API which provide only for passing arbitrary strings,
|
||||||
|
* despite being within the same memory area. The returned string must
|
||||||
|
* eventually be freed with a call to free().
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* The void pointer to convert to a string.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* A newly-allocated string containing the string representation of the
|
||||||
|
* given void pointer. This string must eventually be freed with a call to
|
||||||
|
* free().
|
||||||
|
*/
|
||||||
|
char* guac_rdp_ptr_to_string(void* data);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user