diff --git a/channels/cliprdr/cliprdr_format.c b/channels/cliprdr/cliprdr_format.c index 6cce75823..4562d592f 100644 --- a/channels/cliprdr/cliprdr_format.c +++ b/channels/cliprdr/cliprdr_format.c @@ -87,7 +87,7 @@ void cliprdr_process_format_list(cliprdrPlugin* cliprdr, STREAM* data_in, uint32 cb_event->formats = (uint32*)xmalloc(sizeof(uint32) * num_formats); cb_event->num_formats = 0; if (num_formats * 36 != dataLen) - DEBUG_WARN("dataLen %d not devided by 36!"); + DEBUG_WARN("dataLen %d not devided by 36!", dataLen); for (i = 0; i < num_formats; i++) { stream_read_uint32(data_in, format); diff --git a/channels/cliprdr/cliprdr_main.c b/channels/cliprdr/cliprdr_main.c index 090b5302e..d9c5e6e7b 100644 --- a/channels/cliprdr/cliprdr_main.c +++ b/channels/cliprdr/cliprdr_main.c @@ -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) diff --git a/channels/rdpdbg/rdpdbg_main.c b/channels/rdpdbg/rdpdbg_main.c index e1067417b..939aa66b5 100644 --- a/channels/rdpdbg/rdpdbg_main.c +++ b/channels/rdpdbg/rdpdbg_main.c @@ -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) diff --git a/include/freerdp/utils/svc_plugin.h b/include/freerdp/utils/svc_plugin.h index cccb82ba2..17023d2ea 100644 --- a/include/freerdp/utils/svc_plugin.h +++ b/include/freerdp/utils/svc_plugin.h @@ -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 */