From fb7a4992194089c849f6b15091e3478689e14b8b Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 4 Dec 2006 21:55:55 +0000 Subject: [PATCH] use env for dl_debug --- .../java/src/jni/vmware/vmcontrol_wrapper.c | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/bindings/java/src/jni/vmware/vmcontrol_wrapper.c b/bindings/java/src/jni/vmware/vmcontrol_wrapper.c index 0a985b8b..8ee3d778 100644 --- a/bindings/java/src/jni/vmware/vmcontrol_wrapper.c +++ b/bindings/java/src/jni/vmware/vmcontrol_wrapper.c @@ -130,12 +130,16 @@ int vmcontrol_wrapper_api_init(const char *lib) { int i; char *api; + int dl_debug = getenv("VMCONTROL_DEBUG") != NULL; if (vmcontrol_api) { return 0; } if (!lib) { /* sanity check */ + if (dl_debug) { + fprintf(stderr, "[vmcontrol_init] lib==NULL\n"); + } return DL_ENOENT; } @@ -160,25 +164,27 @@ int vmcontrol_wrapper_api_init(const char *lib) (any_function_t)DL_SYM(vmcontrol_api->handle, vmcontrol_entries[i].alias); -#ifdef DL_DEBUG - printf("%s -> %s\n", - vmcontrol_entries[i].name, - vmcontrol_entries[i].alias); -#endif + if (dl_debug) { + fprintf(stderr, "[vmcontrol_init] alias %s -> %s\n", + vmcontrol_entries[i].name, + vmcontrol_entries[i].alias); + } } if (!*ptr) { -#ifdef DL_DEBUG - printf("%s -> UNDEFINED\n", vmcontrol_entries[i].name); -#endif + if (dl_debug) { + fprintf(stderr, "[vmcontrol_init] %s -> UNDEFINED\n", + vmcontrol_entries[i].name); + } *ptr = (any_function_t)unsupported_function; } } if ((void *)vmcontrol_api->xVMControl_VMInit == (void *)&unsupported_function) { -#ifdef DL_DEBUG - printf("%s unuseable\n", lib); -#endif + if (dl_debug) { + fprintf(stderr, "[vmcontrol_init] %s unuseable\n", lib); + } + vmcontrol_wrapper_api_shutdown(); return DL_ENOENT; }