summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Roskin <plroskin@gmail.com>2016-07-08 05:09:09 +0000
committerPavel Roskin <plroskin@gmail.com>2016-07-08 05:09:09 +0000
commitace7d2c822937a9cb0637946f85d1fbd63562c44 (patch)
tree37dbd54c8eb00f496f18aebf6e24c5b893550970
parent2c13ef5c6dd90ee2dcbcba282b2ee702e2ee9f84 (diff)
downloadxrdp-proprietary-ace7d2c822937a9cb0637946f85d1fbd63562c44.tar.gz
xrdp-proprietary-ace7d2c822937a9cb0637946f85d1fbd63562c44.zip
Declare unified module interface and use it in modules
This fixes loading modules compiled with a C++ compiler. Remote thandle type, it's unused. Use tintptr for module data. Don't cast pointers to long, they won't fit on Win64.
-rw-r--r--common/arch.h11
-rw-r--r--mc/mc.c10
-rw-r--r--neutrinordp/xrdp-neutrinordp.c10
-rw-r--r--rdp/rdp.c10
-rw-r--r--vnc/vnc.c9
-rw-r--r--xup/xup.c10
6 files changed, 39 insertions, 21 deletions
diff --git a/common/arch.h b/common/arch.h
index 5c67cb66..7070d6ae 100644
--- a/common/arch.h
+++ b/common/arch.h
@@ -113,7 +113,6 @@ typedef __int64 tbus;
#else
typedef long tbus;
#endif
-typedef tbus thandle;
typedef tbus tintptr;
/* wide char, socket */
#if defined(_WIN32)
@@ -137,4 +136,14 @@ typedef signed long long tsi64;
#define printflike(arg_format, arg_first_check)
#endif
+/* module interface */
+#ifdef __cplusplus
+extern "C" {
+#endif
+ tintptr mod_init();
+ int mod_exit(tintptr);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/mc/mc.c b/mc/mc.c
index 3bcf16f1..3e0909d4 100644
--- a/mc/mc.c
+++ b/mc/mc.c
@@ -81,7 +81,7 @@ lib_mod_set_param(struct mod *mod, const char *name, char *value)
}
/******************************************************************************/
-struct mod *EXPORT_CC
+tintptr EXPORT_CC
mod_init(void)
{
struct mod *mod;
@@ -89,20 +89,22 @@ mod_init(void)
mod = (struct mod *)g_malloc(sizeof(struct mod), 1);
mod->size = sizeof(struct mod);
mod->version = CURRENT_MOD_VER;
- mod->handle = (long)mod;
+ mod->handle = (tintptr) mod;
mod->mod_connect = lib_mod_connect;
mod->mod_start = lib_mod_start;
mod->mod_event = lib_mod_event;
mod->mod_signal = lib_mod_signal;
mod->mod_end = lib_mod_end;
mod->mod_set_param = lib_mod_set_param;
- return mod;
+ return (tintptr) mod;
}
/******************************************************************************/
int EXPORT_CC
-mod_exit(struct mod *mod)
+mod_exit(tintptr handle)
{
+ struct mod *mod = (struct mod *) handle;
+
if (mod == 0)
{
return 0;
diff --git a/neutrinordp/xrdp-neutrinordp.c b/neutrinordp/xrdp-neutrinordp.c
index 9fb3b20d..34ed9c2c 100644
--- a/neutrinordp/xrdp-neutrinordp.c
+++ b/neutrinordp/xrdp-neutrinordp.c
@@ -1955,7 +1955,7 @@ lfreerdp_verify_certificate(freerdp *instance, char *subject, char *issuer,
}
/******************************************************************************/
-struct mod *EXPORT_CC
+tintptr EXPORT_CC
mod_init(void)
{
struct mod *mod;
@@ -1968,7 +1968,7 @@ mod_init(void)
mod->vmaj, mod->vmin, mod->vrev));
mod->size = sizeof(struct mod);
mod->version = CURRENT_MOD_VER;
- mod->handle = (tbus)mod;
+ mod->handle = (tintptr) mod;
mod->mod_connect = lxrdp_connect;
mod->mod_start = lxrdp_start;
mod->mod_event = lxrdp_event;
@@ -1995,13 +1995,15 @@ mod_init(void)
lcon->modi = mod;
LLOGLN(10, ("mod_init: mod %p", mod));
- return mod;
+ return (tintptr) mod;
}
/******************************************************************************/
int EXPORT_CC
-mod_exit(struct mod *mod)
+mod_exit(tintptr handle)
{
+ struct mod *mod = (struct mod *) handle;
+
LLOGLN(0, ("mod_exit:"));
if (mod == 0)
diff --git a/rdp/rdp.c b/rdp/rdp.c
index ffced90b..5dc13363 100644
--- a/rdp/rdp.c
+++ b/rdp/rdp.c
@@ -318,7 +318,7 @@ lib_mod_check_wait_objs(struct mod *mod)
}
/******************************************************************************/
-struct mod *EXPORT_CC
+tintptr EXPORT_CC
mod_init(void)
{
struct mod *mod;
@@ -327,7 +327,7 @@ mod_init(void)
mod = (struct mod *)g_malloc(sizeof(struct mod), 1);
mod->size = sizeof(struct mod);
mod->version = CURRENT_MOD_VER;
- mod->handle = (long)mod;
+ mod->handle = (tintptr) mod;
mod->mod_connect = lib_mod_connect;
mod->mod_start = lib_mod_start;
mod->mod_event = lib_mod_event;
@@ -338,13 +338,15 @@ mod_init(void)
mod->mod_check_wait_objs = lib_mod_check_wait_objs;
mod->rdp_layer = rdp_rdp_create(mod);
DEBUG(("out mod_init"));
- return mod;
+ return (tintptr) mod;
}
/******************************************************************************/
int EXPORT_CC
-mod_exit(struct mod *mod)
+mod_exit(tintptr handle)
{
+ struct mod *mod = (struct mod *) handle;
+
DEBUG(("in mod_exit"));
g_free(mod);
DEBUG(("out mod_exit"));
diff --git a/vnc/vnc.c b/vnc/vnc.c
index 99245b53..8da35f5a 100644
--- a/vnc/vnc.c
+++ b/vnc/vnc.c
@@ -1465,7 +1465,7 @@ lib_mod_check_wait_objs(struct vnc *v)
}
/******************************************************************************/
-struct vnc *EXPORT_CC
+tintptr EXPORT_CC
mod_init(void)
{
struct vnc *v;
@@ -1474,7 +1474,7 @@ mod_init(void)
/* set client functions */
v->size = sizeof(struct vnc);
v->version = CURRENT_MOD_VER;
- v->handle = (long)v;
+ v->handle = (tintptr) v;
v->mod_connect = lib_mod_connect;
v->mod_start = lib_mod_start;
v->mod_event = lib_mod_event;
@@ -1483,13 +1483,14 @@ mod_init(void)
v->mod_set_param = lib_mod_set_param;
v->mod_get_wait_objs = lib_mod_get_wait_objs;
v->mod_check_wait_objs = lib_mod_check_wait_objs;
- return v;
+ return (tintptr) v;
}
/******************************************************************************/
int EXPORT_CC
-mod_exit(struct vnc *v)
+mod_exit(tintptr handle)
{
+ struct vnc *v = (struct vnc *) handle;
log_message(LOG_LEVEL_DEBUG, "VNC mod_exit");
if (v == 0)
diff --git a/xup/xup.c b/xup/xup.c
index b841985e..e2c34ca8 100644
--- a/xup/xup.c
+++ b/xup/xup.c
@@ -1552,7 +1552,7 @@ lib_mod_frame_ack(struct mod *amod, int flags, int frame_id)
}
/******************************************************************************/
-struct mod *EXPORT_CC
+tintptr EXPORT_CC
mod_init(void)
{
struct mod *mod;
@@ -1560,7 +1560,7 @@ mod_init(void)
mod = (struct mod *)g_malloc(sizeof(struct mod), 1);
mod->size = sizeof(struct mod);
mod->version = CURRENT_MOD_VER;
- mod->handle = (tbus)mod;
+ mod->handle = (tintptr) mod;
mod->mod_connect = lib_mod_connect;
mod->mod_start = lib_mod_start;
mod->mod_event = lib_mod_event;
@@ -1570,13 +1570,15 @@ mod_init(void)
mod->mod_get_wait_objs = lib_mod_get_wait_objs;
mod->mod_check_wait_objs = lib_mod_check_wait_objs;
mod->mod_frame_ack = lib_mod_frame_ack;
- return mod;
+ return (tintptr) mod;
}
/******************************************************************************/
int EXPORT_CC
-mod_exit(struct mod *mod)
+mod_exit(tintptr handle)
{
+ struct mod *mod = (struct mod *) handle;
+
if (mod == 0)
{
return 0;