From: VMware, Inc <> Date: Tue, 17 Nov 2009 21:31:43 +0000 (-0800) Subject: Remove vmrpcdbg.h's dependency on util.h. X-Git-Tag: 2009.11.16-210370~41 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=869efe5cf560fa7ff92515dc874e95ffd1ba3a19;p=thirdparty%2Fopen-vm-tools.git Remove vmrpcdbg.h's dependency on util.h. This is (well, will be) a public header and should not depend on our internal headers. So change the macro that uses util.h into a function so we hide the dependency from consumers (and fix the few existing uses). Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/include/vmrpcdbg.h b/open-vm-tools/lib/include/vmrpcdbg.h index b906f9a81..9b1d17c75 100644 --- a/open-vm-tools/lib/include/vmrpcdbg.h +++ b/open-vm-tools/lib/include/vmrpcdbg.h @@ -30,7 +30,6 @@ */ #include "vmtoolsApp.h" -#include "util.h" struct RpcDebugPlugin; @@ -63,7 +62,7 @@ typedef struct RpcDebugRecvMapping { * validate the response. */ typedef gboolean (*RpcDebugValidateFn)(RpcInData *data, - Bool ret); + gboolean ret); /** Defines a mapping between a message and a "validate" function. */ typedef struct RpcDebugMsgMapping { @@ -135,26 +134,6 @@ typedef struct RpcDebugLibData { typedef RpcDebugLibData *(* RpcDebugInitializeFn)(ToolsAppCtx *, gchar *); -/** - * Helper macro to set @a result / @a resultLen when responding to an RPC. - * - * @param[in] resultStr The string to set. - * @param[out] result Where to store the result. - * @param[out] resultLen Where to store the length. - */ - -#define RPCDEBUG_SET_RESULT(resultStr, result, resultLen) do { \ - char *__resultStr = (resultStr); \ - char **__result = (result); \ - size_t *__resultLen = (resultLen); \ - if (__result != NULL) { \ - *__result = Util_SafeStrdup(__resultStr); \ - } \ - if (__resultLen != NULL) { \ - *__resultLen = strlen(__resultStr); \ - } \ -} while (0) - void RpcDebug_DecRef(ToolsAppCtx *ctx); @@ -173,6 +152,11 @@ gboolean RpcDebug_SendNext(RpcDebugMsgMapping *rpcdata, RpcDebugMsgList *list); +void +RpcDebug_SetResult(const char *str, + char **res, + size_t *len); + void RpcDebug_Shutdown(ToolsAppCtx *ctx, RpcDebugLibData *data); diff --git a/open-vm-tools/tests/testDebug/testDebug.c b/open-vm-tools/tests/testDebug/testDebug.c index 676f714f6..11201db71 100644 --- a/open-vm-tools/tests/testDebug/testDebug.c +++ b/open-vm-tools/tests/testDebug/testDebug.c @@ -33,10 +33,10 @@ #include "vmware/guestrpc/tclodefs.h" static gboolean -TestDebugValidateReset(RpcInData *data, Bool ret); +TestDebugValidateReset(RpcInData *data, gboolean ret); static gboolean -TestDebugValidateUnknown(RpcInData *data, Bool ret); +TestDebugValidateUnknown(RpcInData *data, gboolean ret); #define SET_OPTION_TEST ("Set_Option " TOOLSOPTION_BROADCASTIP " 1") @@ -89,7 +89,7 @@ TestDebugHandleSignal(gpointer src, static gboolean TestDebugValidateReset(RpcInData *data, - Bool ret) + gboolean ret) { ToolsAppCtx *ctx = data->appCtx; g_assert(data->result != NULL); @@ -162,7 +162,7 @@ TestDebugReceiveVersion(char *data, size_t *resultLen) { g_debug("Received tools version message: %s\n", data); - RPCDEBUG_SET_RESULT("", result, resultLen); + RpcDebug_SetResult("", result, resultLen); return TRUE; } @@ -178,7 +178,7 @@ TestDebugReceiveVersion(char *data, static gboolean TestDebugValidateUnknown(RpcInData *data, - Bool ret) + gboolean ret) { g_assert(strcmp(data->result, "Unknown Command") == 0); return !ret; diff --git a/open-vm-tools/tests/vmrpcdbg/debugChannel.c b/open-vm-tools/tests/vmrpcdbg/debugChannel.c index bc2782e4d..fd68994a6 100644 --- a/open-vm-tools/tests/vmrpcdbg/debugChannel.c +++ b/open-vm-tools/tests/vmrpcdbg/debugChannel.c @@ -219,7 +219,7 @@ RpcDebugSend(RpcChannel *chan, /* Find out where the XDR data starts. */ start = strchr(copy, ' '); if (start == NULL) { - RPCDEBUG_SET_RESULT("Can't find command delimiter.", result, resultLen); + RpcDebug_SetResult("Can't find command delimiter.", result, resultLen); ret = FALSE; goto exit; } @@ -230,7 +230,7 @@ RpcDebugSend(RpcChannel *chan, dataLen - (start - copy), mapping->xdrProc, xdrdata)) { - RPCDEBUG_SET_RESULT("XDR deserialization failed.", result, resultLen); + RpcDebug_SetResult("XDR deserialization failed.", result, resultLen); ret = FALSE; goto exit; } @@ -242,7 +242,7 @@ RpcDebugSend(RpcChannel *chan, if (recvFn != NULL) { ret = recvFn((xdrdata != NULL) ? xdrdata : copy, dataLen, result, resultLen); } else { - RPCDEBUG_SET_RESULT("", result, resultLen); + RpcDebug_SetResult("", result, resultLen); } exit: diff --git a/open-vm-tools/tests/vmrpcdbg/vmrpcdbg.c b/open-vm-tools/tests/vmrpcdbg/vmrpcdbg.c index 9679efca9..e072477f0 100644 --- a/open-vm-tools/tests/vmrpcdbg/vmrpcdbg.c +++ b/open-vm-tools/tests/vmrpcdbg/vmrpcdbg.c @@ -26,6 +26,7 @@ #include #include +#include "util.h" #include "vmrpcdbg.h" #if !defined(__APPLE__) @@ -139,6 +140,28 @@ RpcDebug_SendNext(RpcDebugMsgMapping *rpcdata, } +/** + * Sets @a res / @a len when responding to an RPC. + * + * @param[in] str The string to set. + * @param[out] res Where to store the result. + * @param[out] len Where to store the length. + */ + +void +RpcDebug_SetResult(const char *str, + char **res, + size_t *len) +{ + if (res != NULL) { + *res = Util_SafeStrdup(str); + } + if (len != NULL) { + *len = strlen(str); + } +} + + /** * Shuts down the debug library. Unloads the debug plugin. The plugin's data * shouldn't be used after this function is called.