libfreerdp-utils/svc_plugin: use a macro to simplify plugin entry.

This commit is contained in:
Vic Lee 2011-07-15 23:39:38 +08:00
parent cce6518336
commit c8a5b83186
3 changed files with 27 additions and 42 deletions

View File

@ -170,24 +170,6 @@ static void cliprdr_process_terminate(rdpSvcPlugin* plugin)
xfree(plugin);
}
int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
{
cliprdrPlugin* cliprdr;
cliprdr = (cliprdrPlugin*)xmalloc(sizeof(cliprdrPlugin));
memset(cliprdr, 0, sizeof(cliprdrPlugin));
cliprdr->plugin.channel_def.options = CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP | CHANNEL_OPTION_COMPRESS_RDP |
CHANNEL_OPTION_SHOW_PROTOCOL;
strcpy(cliprdr->plugin.channel_def.name, "cliprdr");
cliprdr->plugin.connect_callback = cliprdr_process_connect;
cliprdr->plugin.receive_callback = cliprdr_process_receive;
cliprdr->plugin.event_callback = cliprdr_process_event;
cliprdr->plugin.terminate_callback = cliprdr_process_terminate;
svc_plugin_init((rdpSvcPlugin*)cliprdr, pEntryPoints);
return 1;
}
DEFINE_SVC_PLUGIN(cliprdr, "cliprdr",
CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL)

View File

@ -64,24 +64,6 @@ static void rdpdbg_process_terminate(rdpSvcPlugin* plugin)
xfree(plugin);
}
int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
{
rdpdbgPlugin* rdpdbg;
rdpdbg = (rdpdbgPlugin*)xmalloc(sizeof(rdpdbgPlugin));
memset(rdpdbg, 0, sizeof(rdpdbgPlugin));
rdpdbg->plugin.channel_def.options = CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP | CHANNEL_OPTION_COMPRESS_RDP |
CHANNEL_OPTION_SHOW_PROTOCOL;
strcpy(rdpdbg->plugin.channel_def.name, "rdpdbg");
rdpdbg->plugin.connect_callback = rdpdbg_process_connect;
rdpdbg->plugin.receive_callback = rdpdbg_process_receive;
rdpdbg->plugin.event_callback = rdpdbg_process_event;
rdpdbg->plugin.terminate_callback = rdpdbg_process_terminate;
svc_plugin_init((rdpSvcPlugin*)rdpdbg, pEntryPoints);
return 1;
}
DEFINE_SVC_PLUGIN(rdpdbg, "rdpdbg",
CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL)

View File

@ -53,4 +53,25 @@ int svc_plugin_send_event(rdpSvcPlugin* plugin, FRDP_EVENT* event);
#define DEBUG_SVC(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__)
#endif
#define DEFINE_SVC_PLUGIN(_prefix, _name, _options) \
\
int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) \
{ \
_prefix##Plugin* _p; \
\
_p = xnew(_prefix##Plugin); \
\
_p->plugin.channel_def.options = _options; \
strcpy(_p->plugin.channel_def.name, _name); \
\
_p->plugin.connect_callback = _prefix##_process_connect; \
_p->plugin.receive_callback = _prefix##_process_receive; \
_p->plugin.event_callback = _prefix##_process_event; \
_p->plugin.terminate_callback = _prefix##_process_terminate; \
\
svc_plugin_init((rdpSvcPlugin*)_p, pEntryPoints); \
\
return 1; \
}
#endif /* __SVC_PLUGIN_UTILS_H */