[shadow,subsystem] refactor builtin loader
This commit is contained in:
parent
53023a0627
commit
3648c05c56
@ -656,7 +656,12 @@ static macShadowSubsystem* mac_shadow_subsystem_new(void)
|
|||||||
return subsystem;
|
return subsystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
FREERDP_API int Mac_ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints)
|
FREERDP_API const char* ShadowSubsystemName(void)
|
||||||
|
{
|
||||||
|
return "Mac";
|
||||||
|
}
|
||||||
|
|
||||||
|
FREERDP_API int ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints)
|
||||||
{
|
{
|
||||||
pEntryPoints->New = (pfnShadowSubsystemNew)mac_shadow_subsystem_new;
|
pEntryPoints->New = (pfnShadowSubsystemNew)mac_shadow_subsystem_new;
|
||||||
pEntryPoints->Free = (pfnShadowSubsystemFree)mac_shadow_subsystem_free;
|
pEntryPoints->Free = (pfnShadowSubsystemFree)mac_shadow_subsystem_free;
|
||||||
|
@ -11,6 +11,7 @@ add_library(freerdp-shadow-subsystem-impl STATIC
|
|||||||
win_wds.h
|
win_wds.h
|
||||||
)
|
)
|
||||||
target_link_libraries(freerdp-shadow-subsystem-impl PRIVATE
|
target_link_libraries(freerdp-shadow-subsystem-impl PRIVATE
|
||||||
|
freerdp-client
|
||||||
freerdp
|
freerdp
|
||||||
winpr
|
winpr
|
||||||
)
|
)
|
||||||
|
@ -537,7 +537,12 @@ static rdpShadowSubsystem* win_shadow_subsystem_new(void)
|
|||||||
return &subsystem->base;
|
return &subsystem->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
FREERDP_API int Win_ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints)
|
FREERDP_API const char* ShadowSubsystemName(void)
|
||||||
|
{
|
||||||
|
return "Win";
|
||||||
|
}
|
||||||
|
|
||||||
|
FREERDP_API int ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints)
|
||||||
{
|
{
|
||||||
pEntryPoints->New = win_shadow_subsystem_new;
|
pEntryPoints->New = win_shadow_subsystem_new;
|
||||||
pEntryPoints->Free = win_shadow_subsystem_free;
|
pEntryPoints->Free = win_shadow_subsystem_free;
|
||||||
|
@ -1483,7 +1483,12 @@ static void x11_shadow_subsystem_free(rdpShadowSubsystem* subsystem)
|
|||||||
free(subsystem);
|
free(subsystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
FREERDP_API int X11_ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints)
|
FREERDP_API const char* ShadowSubsystemName(void)
|
||||||
|
{
|
||||||
|
return "X11";
|
||||||
|
}
|
||||||
|
|
||||||
|
FREERDP_API int ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints)
|
||||||
{
|
{
|
||||||
if (!pEntryPoints)
|
if (!pEntryPoints)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -22,60 +22,43 @@
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* (*name)(void);
|
||||||
pfnShadowSubsystemEntry entry;
|
pfnShadowSubsystemEntry entry;
|
||||||
} RDP_SHADOW_SUBSYSTEM;
|
} RDP_SHADOW_SUBSYSTEM;
|
||||||
|
|
||||||
#ifdef WITH_SHADOW_X11
|
extern int ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints);
|
||||||
extern int X11_ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints);
|
extern const char* ShadowSubsystemName(void);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WITH_SHADOW_MAC
|
|
||||||
extern int Mac_ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WITH_SHADOW_WIN
|
|
||||||
extern int Win_ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static RDP_SHADOW_SUBSYSTEM g_Subsystems[] = {
|
static RDP_SHADOW_SUBSYSTEM g_Subsystems[] = {
|
||||||
|
|
||||||
#ifdef WITH_SHADOW_X11
|
{ ShadowSubsystemName, ShadowSubsystemEntry }
|
||||||
{ "X11", X11_ShadowSubsystemEntry },
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WITH_SHADOW_MAC
|
|
||||||
{ "Mac", Mac_ShadowSubsystemEntry },
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WITH_SHADOW_WIN
|
|
||||||
{ "Win", Win_ShadowSubsystemEntry },
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{ "", NULL }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int g_SubsystemCount = (sizeof(g_Subsystems) / sizeof(g_Subsystems[0]));
|
static size_t g_SubsystemCount = ARRAYSIZE(g_Subsystems);
|
||||||
|
|
||||||
static pfnShadowSubsystemEntry shadow_subsystem_load_static_entry(const char* name)
|
static pfnShadowSubsystemEntry shadow_subsystem_load_static_entry(const char* name)
|
||||||
{
|
{
|
||||||
int index;
|
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
{
|
{
|
||||||
for (index = 0; index < g_SubsystemCount; index++)
|
for (size_t index = 0; index < g_SubsystemCount; index++)
|
||||||
{
|
{
|
||||||
if (g_Subsystems[index].name)
|
const RDP_SHADOW_SUBSYSTEM* cur = &g_Subsystems[index];
|
||||||
return g_Subsystems[index].entry;
|
WINPR_ASSERT(cur->entry);
|
||||||
|
|
||||||
|
return cur->entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (index = 0; index < g_SubsystemCount; index++)
|
for (size_t index = 0; index < g_SubsystemCount; index++)
|
||||||
{
|
{
|
||||||
if (strcmp(name, g_Subsystems[index].name) == 0)
|
const RDP_SHADOW_SUBSYSTEM* cur = &g_Subsystems[index];
|
||||||
return g_Subsystems[index].entry;
|
WINPR_ASSERT(cur->name);
|
||||||
|
WINPR_ASSERT(cur->entry);
|
||||||
|
|
||||||
|
if (strcmp(name, cur->name()) == 0)
|
||||||
|
return cur->entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -83,9 +66,7 @@ static pfnShadowSubsystemEntry shadow_subsystem_load_static_entry(const char* na
|
|||||||
|
|
||||||
void shadow_subsystem_set_entry_builtin(const char* name)
|
void shadow_subsystem_set_entry_builtin(const char* name)
|
||||||
{
|
{
|
||||||
pfnShadowSubsystemEntry entry;
|
pfnShadowSubsystemEntry entry = shadow_subsystem_load_static_entry(name);
|
||||||
|
|
||||||
entry = shadow_subsystem_load_static_entry(name);
|
|
||||||
|
|
||||||
if (entry)
|
if (entry)
|
||||||
shadow_subsystem_set_entry(entry);
|
shadow_subsystem_set_entry(entry);
|
||||||
|
Loading…
Reference in New Issue
Block a user