]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Remove vmrpcdbg.h's dependency on util.h.
authorVMware, Inc <>
Tue, 17 Nov 2009 21:31:43 +0000 (13:31 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 17 Nov 2009 21:31:43 +0000 (13:31 -0800)
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 <mvanzin@vmware.com>
open-vm-tools/lib/include/vmrpcdbg.h
open-vm-tools/tests/testDebug/testDebug.c
open-vm-tools/tests/vmrpcdbg/debugChannel.c
open-vm-tools/tests/vmrpcdbg/vmrpcdbg.c

index b906f9a814c955f53d42894cebc863d667d224e0..9b1d17c75d10b631c0b351e5c6dd15ed7ca8bd08 100644 (file)
@@ -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);
index 676f714f61367205d82130e0cc003f4272e9e4e0..11201db712442221d519b844e161580b2bf19bbb 100644 (file)
 #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;
index bc2782e4d18ca0b329ffc1b982ffad6fe4749195..fd68994a6efe9a9df697e8ececd78b8fd477afa1 100644 (file)
@@ -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:
index 9679efca9c0ec8006258540fb0fddf9ee64b70af..e072477f0f28cd85070cc15810e654b24cb178f0 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <gmodule.h>
 #include <rpc/rpc.h>
+#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.