*/
#include "vmtoolsApp.h"
-#include "util.h"
struct RpcDebugPlugin;
* 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 {
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);
RpcDebug_SendNext(RpcDebugMsgMapping *rpcdata,
RpcDebugMsgList *list);
+void
+RpcDebug_SetResult(const char *str,
+ char **res,
+ size_t *len);
+
void
RpcDebug_Shutdown(ToolsAppCtx *ctx,
RpcDebugLibData *data);
#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")
static gboolean
TestDebugValidateReset(RpcInData *data,
- Bool ret)
+ gboolean ret)
{
ToolsAppCtx *ctx = data->appCtx;
g_assert(data->result != NULL);
size_t *resultLen)
{
g_debug("Received tools version message: %s\n", data);
- RPCDEBUG_SET_RESULT("", result, resultLen);
+ RpcDebug_SetResult("", result, resultLen);
return TRUE;
}
static gboolean
TestDebugValidateUnknown(RpcInData *data,
- Bool ret)
+ gboolean ret)
{
g_assert(strcmp(data->result, "Unknown Command") == 0);
return !ret;
/* 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;
}
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;
}
if (recvFn != NULL) {
ret = recvFn((xdrdata != NULL) ? xdrdata : copy, dataLen, result, resultLen);
} else {
- RPCDEBUG_SET_RESULT("", result, resultLen);
+ RpcDebug_SetResult("", result, resultLen);
}
exit:
#include <gmodule.h>
#include <rpc/rpc.h>
+#include "util.h"
#include "vmrpcdbg.h"
#if !defined(__APPLE__)
}
+/**
+ * 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.