Blame server/shadow/shadow_subsystem_builtin.c

Packit Service fa4841
/**
Packit Service fa4841
 * FreeRDP: A Remote Desktop Protocol Implementation
Packit Service fa4841
 *
Packit Service fa4841
 * Copyright 2016 Jiang Zihao <zihao.jiang@yahoo.com>
Packit Service fa4841
 *
Packit Service fa4841
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit Service fa4841
 * you may not use this file except in compliance with the License.
Packit Service fa4841
 * You may obtain a copy of the License at
Packit Service fa4841
 *
Packit Service fa4841
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit Service fa4841
 *
Packit Service fa4841
 * Unless required by applicable law or agreed to in writing, software
Packit Service fa4841
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit Service fa4841
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit Service fa4841
 * See the License for the specific language governing permissions and
Packit Service fa4841
 * limitations under the License.
Packit Service fa4841
 */
Packit Service fa4841
Packit Service fa4841
#ifdef HAVE_CONFIG_H
Packit Service fa4841
#include "config.h"
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#include <freerdp/server/shadow.h>
Packit Service fa4841
Packit Service fa4841
struct _RDP_SHADOW_SUBSYSTEM
Packit Service fa4841
{
Packit Service fa4841
	const char* name;
Packit Service fa4841
	pfnShadowSubsystemEntry entry;
Packit Service fa4841
};
Packit Service fa4841
typedef struct _RDP_SHADOW_SUBSYSTEM RDP_SHADOW_SUBSYSTEM;
Packit Service fa4841
Packit Service fa4841
#ifdef WITH_SHADOW_X11
Packit Service fa4841
extern int X11_ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints);
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#ifdef WITH_SHADOW_MAC
Packit Service fa4841
extern int Mac_ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints);
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#ifdef WITH_SHADOW_WIN
Packit Service fa4841
extern int Win_ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints);
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service b1ea74
static RDP_SHADOW_SUBSYSTEM g_Subsystems[] = {
Packit Service fa4841
Packit Service fa4841
#ifdef WITH_SHADOW_X11
Packit Service fa4841
	{ "X11", X11_ShadowSubsystemEntry },
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#ifdef WITH_SHADOW_MAC
Packit Service fa4841
	{ "Mac", Mac_ShadowSubsystemEntry },
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#ifdef WITH_SHADOW_WIN
Packit Service fa4841
	{ "Win", Win_ShadowSubsystemEntry },
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
	{ "", NULL }
Packit Service fa4841
};
Packit Service fa4841
Packit Service fa4841
static int g_SubsystemCount = (sizeof(g_Subsystems) / sizeof(g_Subsystems[0]));
Packit Service fa4841
Packit Service fa4841
static pfnShadowSubsystemEntry shadow_subsystem_load_static_entry(const char* name)
Packit Service fa4841
{
Packit Service fa4841
	int index;
Packit Service fa4841
Packit Service fa4841
	if (!name)
Packit Service fa4841
	{
Packit Service fa4841
		for (index = 0; index < g_SubsystemCount; index++)
Packit Service fa4841
		{
Packit Service fa4841
			if (g_Subsystems[index].name)
Packit Service fa4841
				return g_Subsystems[index].entry;
Packit Service fa4841
		}
Packit Service fa4841
Packit Service fa4841
		return NULL;
Packit Service fa4841
	}
Packit Service fa4841
Packit Service fa4841
	for (index = 0; index < g_SubsystemCount; index++)
Packit Service fa4841
	{
Packit Service fa4841
		if (strcmp(name, g_Subsystems[index].name) == 0)
Packit Service fa4841
			return g_Subsystems[index].entry;
Packit Service fa4841
	}
Packit Service fa4841
Packit Service fa4841
	return NULL;
Packit Service fa4841
}
Packit Service fa4841
Packit Service fa4841
void shadow_subsystem_set_entry_builtin(const char* name)
Packit Service fa4841
{
Packit Service fa4841
	pfnShadowSubsystemEntry entry;
Packit Service fa4841
Packit Service fa4841
	entry = shadow_subsystem_load_static_entry(name);
Packit Service fa4841
Packit Service fa4841
	if (entry)
Packit Service fa4841
		shadow_subsystem_set_entry(entry);
Packit Service fa4841
Packit Service fa4841
	return;
Packit Service fa4841
}