channels: simplify API
This commit is contained in:
parent
65e51b9bbf
commit
8e424f7e4c
@ -550,4 +550,3 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "tables.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@ -33,6 +37,7 @@
|
||||
#include <freerdp/utils/memory.h>
|
||||
#include <freerdp/utils/wait_obj.h>
|
||||
#include <freerdp/utils/load_plugin.h>
|
||||
#include <freerdp/utils/file.h>
|
||||
#include <freerdp/utils/event.h>
|
||||
#include <freerdp/utils/debug.h>
|
||||
|
||||
@ -64,7 +69,7 @@
|
||||
|
||||
extern const STATIC_ENTRY_TABLE CLIENT_STATIC_ENTRY_TABLES[];
|
||||
|
||||
void* freerdp_channels_find_static_entry_in_table(const STATIC_ENTRY_TABLE* table, const char* entry)
|
||||
void* freerdp_channels_find_static_entry_in_table(const STATIC_ENTRY_TABLE* table, const char* identifier)
|
||||
{
|
||||
int index = 0;
|
||||
STATIC_ENTRY* pEntry;
|
||||
@ -73,7 +78,7 @@ void* freerdp_channels_find_static_entry_in_table(const STATIC_ENTRY_TABLE* tabl
|
||||
|
||||
while (pEntry->entry != NULL)
|
||||
{
|
||||
if (strcmp(pEntry->name, entry) == 0)
|
||||
if (strcmp(pEntry->name, identifier) == 0)
|
||||
{
|
||||
return (void*) pEntry->entry;
|
||||
}
|
||||
@ -84,7 +89,7 @@ void* freerdp_channels_find_static_entry_in_table(const STATIC_ENTRY_TABLE* tabl
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* freerdp_channels_find_static_entry(const char* name, const char* entry)
|
||||
void* freerdp_channels_client_find_static_entry(const char* name, const char* identifier)
|
||||
{
|
||||
int index = 0;
|
||||
STATIC_ENTRY_TABLE* pEntry;
|
||||
@ -95,7 +100,7 @@ void* freerdp_channels_find_static_entry(const char* name, const char* entry)
|
||||
{
|
||||
if (strcmp(pEntry->name, name) == 0)
|
||||
{
|
||||
return freerdp_channels_find_static_entry_in_table(pEntry, entry);
|
||||
return freerdp_channels_find_static_entry_in_table(pEntry, identifier);
|
||||
}
|
||||
|
||||
pEntry = (STATIC_ENTRY_TABLE*) &CLIENT_STATIC_ENTRY_TABLES[index++];
|
||||
@ -104,14 +109,35 @@ void* freerdp_channels_find_static_entry(const char* name, const char* entry)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* freerdp_channels_find_static_virtual_channel_entry(const char* name)
|
||||
void* freerdp_channels_client_find_dynamic_entry(const char* name, const char* identifier)
|
||||
{
|
||||
return freerdp_channels_find_static_entry("VirtualChannelEntry", name);
|
||||
char* path;
|
||||
void* entry;
|
||||
char* module;
|
||||
|
||||
module = freerdp_append_shared_library_suffix((char*) identifier);
|
||||
path = freerdp_construct_path(FREERDP_CLIENT_PLUGIN_PATH, module);
|
||||
|
||||
entry = freerdp_load_library_symbol(path, module);
|
||||
|
||||
free(module);
|
||||
free(path);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
void* freerdp_channels_find_static_device_service_entry(const char* name)
|
||||
void* freerdp_channels_client_find_entry(const char* name, const char* identifier)
|
||||
{
|
||||
return freerdp_channels_find_static_entry("DeviceServiceEntry", name);
|
||||
void* pChannelEntry = NULL;
|
||||
|
||||
pChannelEntry = freerdp_channels_client_find_static_entry(name, identifier);
|
||||
|
||||
if (!pChannelEntry)
|
||||
{
|
||||
pChannelEntry = freerdp_channels_client_find_dynamic_entry(name, identifier);
|
||||
}
|
||||
|
||||
return pChannelEntry;
|
||||
}
|
||||
|
||||
struct lib_data
|
||||
|
@ -76,7 +76,7 @@ BOOL devman_load_device_service(DEVMAN* devman, RDP_PLUGIN_DATA* plugin_data)
|
||||
PDEVICE_SERVICE_ENTRY entry = NULL;
|
||||
|
||||
name = (char*) plugin_data->data[0];
|
||||
entry = (PDEVICE_SERVICE_ENTRY) freerdp_channels_find_static_device_service_entry(name);
|
||||
entry = (PDEVICE_SERVICE_ENTRY) freerdp_channels_client_find_static_entry("DeviceServiceEntry", name);
|
||||
|
||||
if (!entry)
|
||||
{
|
||||
|
@ -227,7 +227,7 @@ static int df_process_plugin_args(rdpSettings* settings, const char* name,
|
||||
void* entry = NULL;
|
||||
rdpChannels* channels = (rdpChannels*) user_data;
|
||||
|
||||
entry = freerdp_channels_find_static_virtual_channel_entry(name);
|
||||
entry = freerdp_channels_client_find_static_entry("VirtualChannelEntry", name);
|
||||
|
||||
if (entry)
|
||||
{
|
||||
|
@ -457,7 +457,7 @@ int wf_process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_D
|
||||
void* entry = NULL;
|
||||
rdpChannels* channels = (rdpChannels*) user_data;
|
||||
|
||||
entry = freerdp_channels_find_static_virtual_channel_entry(name);
|
||||
entry = freerdp_channels_client_find_static_entry("VirtualChannelEntry", name);
|
||||
|
||||
if (entry)
|
||||
{
|
||||
|
@ -949,7 +949,7 @@ int xf_process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_D
|
||||
void* entry = NULL;
|
||||
rdpChannels* channels = (rdpChannels*) user_data;
|
||||
|
||||
entry = freerdp_channels_find_static_virtual_channel_entry(name);
|
||||
entry = freerdp_channels_client_find_static_entry("VirtualChannelEntry", name);
|
||||
|
||||
if (entry)
|
||||
{
|
||||
|
@ -22,9 +22,9 @@
|
||||
|
||||
#include <freerdp/api.h>
|
||||
|
||||
FREERDP_API void* freerdp_channels_find_static_virtual_channel_entry(const char* name);
|
||||
FREERDP_API void* freerdp_channels_find_static_device_service_entry(const char* name);
|
||||
FREERDP_API void* freerdp_channels_find_static_entry(const char* name, const char* entry);
|
||||
FREERDP_API void* freerdp_channels_client_find_static_entry(const char* name, const char* identifier);
|
||||
FREERDP_API void* freerdp_channels_client_find_dynamic_entry(const char* name, const char* identifier);
|
||||
FREERDP_API void* freerdp_channels_client_find_entry(const char* name, const char* identifier);
|
||||
|
||||
#endif /* FREERDP_CHANNELS_CLIENT */
|
||||
|
||||
|
65
winpr/libwinpr/path/include/PathCchAddSeparator.c
Normal file
65
winpr/libwinpr/path/include/PathCchAddSeparator.c
Normal file
@ -0,0 +1,65 @@
|
||||
|
||||
/*
|
||||
#define DEFINE_UNICODE FALSE
|
||||
#define PATH_SEPARATOR '\\'
|
||||
#define PATH_CCH_ADD_SEPARATOR PathCchAddBackslashA
|
||||
*/
|
||||
|
||||
#if DEFINE_UNICODE
|
||||
|
||||
HRESULT PATH_CCH_ADD_SEPARATOR(PWSTR pszPath, size_t cchPath)
|
||||
{
|
||||
size_t pszPathLength;
|
||||
|
||||
if (!pszPath)
|
||||
return S_FALSE;
|
||||
|
||||
pszPathLength = lstrlenW(pszPath);
|
||||
|
||||
if (pszPath[pszPathLength - 1] == PATH_SEPARATOR)
|
||||
return S_FALSE;
|
||||
|
||||
if (cchPath > (pszPathLength + 1))
|
||||
{
|
||||
pszPath[pszPathLength] = PATH_SEPARATOR;
|
||||
pszPath[pszPathLength + 1] = '\0';
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
HRESULT PATH_CCH_ADD_SEPARATOR(PSTR pszPath, size_t cchPath)
|
||||
{
|
||||
size_t pszPathLength;
|
||||
|
||||
if (!pszPath)
|
||||
return S_FALSE;
|
||||
|
||||
pszPathLength = lstrlenA(pszPath);
|
||||
|
||||
if (pszPath[pszPathLength - 1] == PATH_SEPARATOR)
|
||||
return S_FALSE;
|
||||
|
||||
if (cchPath > (pszPathLength + 1))
|
||||
{
|
||||
pszPath[pszPathLength] = PATH_SEPARATOR;
|
||||
pszPath[pszPathLength + 1] = '\0';
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
#undef DEFINE_UNICODE
|
||||
#undef PATH_SEPARATOR
|
||||
#undef PATH_CCH_ADD_SEPARATOR
|
||||
*/
|
||||
|
65
winpr/libwinpr/path/include/PathCchAddSeparatorEx.c
Normal file
65
winpr/libwinpr/path/include/PathCchAddSeparatorEx.c
Normal file
@ -0,0 +1,65 @@
|
||||
|
||||
/*
|
||||
#define DEFINE_UNICODE FALSE
|
||||
#define PATH_SEPARATOR '\\'
|
||||
#define PATH_CCH_ADD_SEPARATOR_EX PathCchAddBackslashExA
|
||||
*/
|
||||
|
||||
#if DEFINE_UNICODE
|
||||
|
||||
HRESULT PATH_CCH_ADD_SEPARATOR_EX(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, size_t* pcchRemaining)
|
||||
{
|
||||
size_t pszPathLength;
|
||||
|
||||
if (!pszPath)
|
||||
return S_FALSE;
|
||||
|
||||
pszPathLength = lstrlenW(pszPath);
|
||||
|
||||
if (pszPath[pszPathLength - 1] == PATH_SEPARATOR)
|
||||
return S_FALSE;
|
||||
|
||||
if (cchPath > (pszPathLength + 1))
|
||||
{
|
||||
pszPath[pszPathLength] = PATH_SEPARATOR;
|
||||
pszPath[pszPathLength + 1] = '\0';
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
HRESULT PATH_CCH_ADD_SEPARATOR_EX(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, size_t* pcchRemaining)
|
||||
{
|
||||
size_t pszPathLength;
|
||||
|
||||
if (!pszPath)
|
||||
return S_FALSE;
|
||||
|
||||
pszPathLength = lstrlenA(pszPath);
|
||||
|
||||
if (pszPath[pszPathLength - 1] == PATH_SEPARATOR)
|
||||
return S_FALSE;
|
||||
|
||||
if (cchPath > (pszPathLength + 1))
|
||||
{
|
||||
pszPath[pszPathLength] = PATH_SEPARATOR;
|
||||
pszPath[pszPathLength + 1] = '\0';
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
#undef DEFINE_UNICODE
|
||||
#undef PATH_SEPARATOR
|
||||
#undef PATH_CCH_ADD_SEPARATOR_EX
|
||||
*/
|
||||
|
@ -27,51 +27,21 @@
|
||||
|
||||
#include <winpr/path.h>
|
||||
|
||||
HRESULT PathCchAddBackslashA(PSTR pszPath, size_t cchPath)
|
||||
{
|
||||
size_t pszPathLength;
|
||||
#define DEFINE_UNICODE FALSE
|
||||
#define PATH_SEPARATOR '\\'
|
||||
#define PATH_CCH_ADD_SEPARATOR PathCchAddBackslashA
|
||||
#include "include/PathCchAddSeparator.c"
|
||||
#undef DEFINE_UNICODE
|
||||
#undef PATH_SEPARATOR
|
||||
#undef PATH_CCH_ADD_SEPARATOR
|
||||
|
||||
if (!pszPath)
|
||||
return S_FALSE;
|
||||
|
||||
pszPathLength = lstrlenA(pszPath);
|
||||
|
||||
if (pszPath[pszPathLength - 1] == '\\')
|
||||
return S_FALSE;
|
||||
|
||||
if (cchPath > (pszPathLength + 1))
|
||||
{
|
||||
pszPath[pszPathLength] = '\\';
|
||||
pszPath[pszPathLength + 1] = '\0';
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT PathCchAddBackslashW(PWSTR pszPath, size_t cchPath)
|
||||
{
|
||||
size_t pszPathLength;
|
||||
|
||||
if (!pszPath)
|
||||
return S_FALSE;
|
||||
|
||||
pszPathLength = lstrlenW(pszPath);
|
||||
|
||||
if (pszPath[pszPathLength - 1] == '\\')
|
||||
return S_FALSE;
|
||||
|
||||
if (cchPath > (pszPathLength + 1))
|
||||
{
|
||||
pszPath[pszPathLength] = '\\';
|
||||
pszPath[pszPathLength + 1] = '\0';
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
#define DEFINE_UNICODE TRUE
|
||||
#define PATH_SEPARATOR '\\'
|
||||
#define PATH_CCH_ADD_SEPARATOR PathCchAddBackslashW
|
||||
#include "include/PathCchAddSeparator.c"
|
||||
#undef DEFINE_UNICODE
|
||||
#undef PATH_SEPARATOR
|
||||
#undef PATH_CCH_ADD_SEPARATOR
|
||||
|
||||
HRESULT PathCchRemoveBackslashA(PSTR pszPath, size_t cchPath)
|
||||
{
|
||||
@ -83,51 +53,21 @@ HRESULT PathCchRemoveBackslashW(PWSTR pszPath, size_t cchPath)
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT PathCchAddBackslashExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, size_t* pcchRemaining)
|
||||
{
|
||||
size_t pszPathLength;
|
||||
#define DEFINE_UNICODE FALSE
|
||||
#define PATH_SEPARATOR '\\'
|
||||
#define PATH_CCH_ADD_SEPARATOR_EX PathCchAddBackslashExA
|
||||
#include "include/PathCchAddSeparatorEx.c"
|
||||
#undef DEFINE_UNICODE
|
||||
#undef PATH_SEPARATOR
|
||||
#undef PATH_CCH_ADD_SEPARATOR_EX
|
||||
|
||||
if (!pszPath)
|
||||
return S_FALSE;
|
||||
|
||||
pszPathLength = lstrlenA(pszPath);
|
||||
|
||||
if (pszPath[pszPathLength - 1] == '\\')
|
||||
return S_FALSE;
|
||||
|
||||
if (cchPath > (pszPathLength + 1))
|
||||
{
|
||||
pszPath[pszPathLength] = '\\';
|
||||
pszPath[pszPathLength + 1] = '\0';
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT PathCchAddBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, size_t* pcchRemaining)
|
||||
{
|
||||
size_t pszPathLength;
|
||||
|
||||
if (!pszPath)
|
||||
return S_FALSE;
|
||||
|
||||
pszPathLength = lstrlenW(pszPath);
|
||||
|
||||
if (pszPath[pszPathLength - 1] == '\\')
|
||||
return S_FALSE;
|
||||
|
||||
if (cchPath > (pszPathLength + 1))
|
||||
{
|
||||
pszPath[pszPathLength] = '\\';
|
||||
pszPath[pszPathLength + 1] = '\0';
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
#define DEFINE_UNICODE TRUE
|
||||
#define PATH_SEPARATOR '\\'
|
||||
#define PATH_CCH_ADD_SEPARATOR_EX PathCchAddBackslashExW
|
||||
#include "include/PathCchAddSeparatorEx.c"
|
||||
#undef DEFINE_UNICODE
|
||||
#undef PATH_SEPARATOR
|
||||
#undef PATH_CCH_ADD_SEPARATOR_EX
|
||||
|
||||
HRESULT PathCchRemoveBackslashExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, size_t* pcchRemaining)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user