#include "includeCheck.h"
#include "vmware.h"
-#include "rpcin.h"
/*
* Global functions
*/
+#if !defined(VMTOOLS_USE_GLIB)
+
+#include "rpcin.h"
+
Bool Resolution_Init(const char *tcloChannel, InitHandle handle);
void Resolution_Cleanup(void);
Bool Resolution_RegisterCaps(void);
Bool Resolution_UnregisterCaps(void);
+#endif
+
#endif // ifndef _LIB_RESOLUTION_H_
# error "This library needs to be compiled with VMTOOLS_USE_GLIB."
#endif
-#include <rpc/rpc.h>
-#include "vm_basic_types.h"
-#include "vm_assert.h"
-#include "rpcin.h"
+#include <glib.h>
+#include "vmware.h"
+
+/** Alias for RpcChannel_SetRetVals. */
+#define RPCIN_SETRETVALS RpcChannel_SetRetVals
struct RpcChannel;
+/** Data structure passed to RPC callbacks. */
+typedef struct RpcInData {
+ /** RPC name. */
+ const char *name;
+ /**
+ * RPC arguments. Either the raw argument data, or de-serialized XDR data
+ * in case @a xdrIn was provided in the registration data.
+ */
+ const char *args;
+ /** Size of raw argument data, in bytes. */
+ size_t argsSize;
+ /**
+ * Data to be returned to the caller, or pointer to XDR structure if
+ * @a xdrOut was provided in the registration data.
+ */
+ char *result;
+ /** Length in bytes of raw data being returned (ignored for XDR structures). */
+ size_t resultLen;
+ /**
+ * Whether the RPC library should free the contents of the @a result
+ * field (using vm_free()).
+ */
+ gboolean freeResult;
+ /** Application context. */
+ void *appCtx;
+ /** Client data specified in the registration data. */
+ void *clientData;
+} RpcInData;
+
+
+/**
+ * Type for RpcIn callbacks. The callback function is responsible for
+ * allocating memory for the result string.
+ */
+typedef gboolean (*RpcIn_Callback)(RpcInData *data);
+
+
/** Defines the registration data for a GuestRPC application. */
typedef struct RpcChannelCallback {
/** String identifying the RPC message. */
} RpcChannelCallback;
-typedef Bool (*RpcChannelStartFn)(struct RpcChannel *);
+typedef gboolean (*RpcChannelStartFn)(struct RpcChannel *);
typedef void (*RpcChannelStopFn)(struct RpcChannel *);
typedef void (*RpcChannelShutdownFn)(struct RpcChannel *);
-typedef Bool (*RpcChannelSendFn)(struct RpcChannel *,
- char *data,
- size_t dataLen,
- char **result,
- size_t *resultLen);
+typedef gboolean (*RpcChannelSendFn)(struct RpcChannel *,
+ char *data,
+ size_t dataLen,
+ char **result,
+ size_t *resultLen);
/**
*
* @return TRUE on success.
*/
-static INLINE Bool
+
+static INLINE gboolean
RpcChannel_Start(RpcChannel *chan)
{
ASSERT(chan != NULL);
chan->stop(chan);
}
+
/**
* Wrapper for the send function of an RPC channel struct.
*
* @return The status from the remote end (TRUE if call was successful).
*/
-static INLINE Bool
+static INLINE gboolean
RpcChannel_Send(RpcChannel *chan,
char *data,
size_t dataLen,
return chan->send(chan, data, dataLen, result, resultLen);
}
-Bool
+gboolean
RpcChannel_BuildXdrCommand(const char *cmd,
void *xdrProc,
void *xdrData,
gboolean
RpcChannel_Destroy(RpcChannel *chan);
-Bool
+gboolean
RpcChannel_Dispatch(RpcInData *data);
void
RpcChannel_RegisterCallback(RpcChannel *chan,
RpcChannelCallback *rpc);
+gboolean
+RpcChannel_SetRetVals(RpcInData *data,
+ char *result,
+ gboolean retVal);
+
void
RpcChannel_UnregisterCallback(RpcChannel *chan,
RpcChannelCallback *rpc);
#if defined(VMTOOLS_USE_GLIB)
# include <glib.h>
+ typedef gboolean RpcInRet;
#else
# include "dbllnklst.h"
+ typedef Bool RpcInRet;
#endif
-/* Helper macro for porting old callbacks that currently use RpcIn_SetRetVals. */
-#define RPCIN_SETRETVALS(data, val, retVal) \
- RpcIn_SetRetVals((char const **) &(data)->result, &(data)->resultLen, \
- (val), (retVal))
-
typedef void RpcIn_ErrorFunc(void *clientData, char const *status);
typedef struct RpcIn RpcIn;
+#if defined(VMTOOLS_USE_GLIB)
+
+RpcIn *RpcIn_Construct(GMainContext *mainCtx,
+ RpcIn_Callback dispatch,
+ gpointer clientData);
+
+Bool RpcIn_start(RpcIn *in, unsigned int delay,
+ RpcIn_ErrorFunc *errorFunc, void *errorData);
+
+#else
+
/* Data passed to new-style RpcIn callbacks. */
typedef struct RpcInData {
/* Data from the host's RPC request. */
* Type for RpcIn callbacks. The callback function is responsible for
* allocating memory for the result string.
*/
-typedef Bool (*RpcIn_Callback)(RpcInData *data);
-
+typedef RpcInRet (*RpcIn_Callback)(RpcInData *data);
-#if defined(VMTOOLS_USE_GLIB)
-
-RpcIn *RpcIn_Construct(GMainContext *mainCtx,
- RpcIn_Callback dispatch,
- gpointer clientData);
-
-Bool RpcIn_start(RpcIn *in, unsigned int delay,
- RpcIn_ErrorFunc *errorFunc, void *errorData);
-
-#else
/*
* Type for old RpcIn callbacks. Don't use this anymore - this is here
RpcIn_Callback callback, void *clientData);
void RpcIn_UnregisterCallback(RpcIn *in, const char *name);
+/* Helper macro for porting old callbacks that currently use RpcIn_SetRetVals. */
+#define RPCIN_SETRETVALS(data, val, retVal) \
+ RpcIn_SetRetVals((char const **) &(data)->result, &(data)->resultLen, \
+ (val), (retVal))
+
+unsigned int RpcIn_SetRetVals(char const **result, size_t *resultLen,
+ const char *resultVal, Bool retVal);
+
#endif
void RpcIn_Destruct(RpcIn *in);
Bool RpcIn_restart(RpcIn *in);
Bool RpcIn_stop(RpcIn *in);
-unsigned int RpcIn_SetRetVals(char const **result, size_t *resultLen,
- const char *resultVal, Bool retVal);
#endif /* __RPCIN_H__ */
*
* @return TRUE if COM is initialized when the function returns.
*/
-static INLINE gboolean
+G_INLINE_FUNC gboolean
ToolsCore_InitializeCOM(ToolsAppCtx *ctx)
{
if (!ctx->comInitialized) {
#include "vm_assert.h"
#include "rpcChannelInt.h"
+#include "rpcin.h"
#include "rpcout.h"
#include "util.h"
* @return TRUE on success.
*/
-static Bool
+static gboolean
RpcInStart(RpcChannel *chan)
{
gboolean ret;
* @return The status from the remote end (TRUE if call was successful).
*/
-static Bool
+static gboolean
RpcInSend(RpcChannel *chan,
char *data,
size_t dataLen,
/** Max number of times to attempt a channel restart. */
#define RPCIN_MAX_RESTARTS 60
-static Bool
+static gboolean
RpcChannelPing(RpcInData *data);
static RpcChannelCallback gRpcHandlers[] = {
* @return TRUE.
*/
-static Bool
+static gboolean
RpcChannelPing(RpcInData *data)
{
return RPCIN_SETRETVALS(data, "", TRUE);
* @return TRUE.
*/
-static Bool
+static gboolean
RpcChannelReset(RpcInData *data)
{
gchar *msg;
* @return Whether successfully built the command.
*/
-Bool
+gboolean
RpcChannel_BuildXdrCommand(const char *cmd,
void *xdrProc,
void *xdrData,
* @return Whether the RPC was handled successfully.
*/
-Bool
+gboolean
RpcChannel_Dispatch(RpcInData *data)
{
char *name = NULL;
}
+
+/**
+ * Sets the result of the given RPC context to the given value. The result
+ * should be a NULL-terminated string.
+ *
+ * @param[in] data RPC context.
+ * @param[in] result Result string.
+ * @param[in] retVal Return value of this function.
+ *
+ * @return @a retVal
+ */
+
+gboolean
+RpcChannel_SetRetVals(RpcInData *data,
+ char *result,
+ gboolean retVal)
+{
+ ASSERT(data);
+
+ data->result = result;
+ data->resultLen = strlen(data->result);
+
+ return retVal;
+}
+
+
/**
* Registers a new RPC handler in the given RPC channel. This function is
* not thread-safe.
# include "strutil.h"
#endif
-
+#if defined(VMTOOLS_USE_GLIB)
+# include "rpcChannel.h"
+#endif
#include "vmware.h"
#include "message.h"
}
+#if !defined(VMTOOLS_USE_GLIB)
/*
*-----------------------------------------------------------------------------
*
return retVal;
}
-
+#endif
* @return TRUE on success.
*/
-static Bool
+static gboolean
GuestInfoVMSupport(RpcInData *data)
{
#if defined(_WIN32)
* @return TRUE on success, FALSE on error.
*/
-static Bool
+static gboolean
HgfsServerRpcInDispatch(RpcInData *data)
{
size_t packetSize;
* @return TRUE on success.
*/
-static Bool
+static gboolean
PowerOpsStateChange(RpcInData *data)
{
size_t i;
}
g_free(script);
- return RPCIN_SETRETVALS(data, result, ret);
+ return RPCIN_SETRETVALS(data, (char *) result, ret);
}
}
* Local function prototypes
*/
-static Bool ResolutionResolutionSetCB(RpcInData *data);
-static Bool ResolutionDisplayTopologySetCB(RpcInData *data);
static void ResolutionSetServerCapability(unsigned int value);
-#if defined(RESOLUTION_WIN32)
-static Bool ResolutionDisplayTopologyModesSetCB(RpcInData *data);
-static Bool ResolutionChangeHost3DAvailabilityHintCB(RpcInData *data);
-#endif
/*
* Global function definitions
* @return TRUE if we can reply, FALSE otherwise.
*/
-static Bool
+static gboolean
ResolutionResolutionSetCB(RpcInData *data)
{
uint32 width = 0 ;
uint32 height = 0;
unsigned int index = 0;
- Bool retval = FALSE;
+ gboolean retval = FALSE;
ResolutionInfoType *resInfo = &resolutionInfo;
* @return TRUE if we can reply, FALSE otherwise.
*/
-static Bool
+static gboolean
ResolutionChangeHost3DAvailabilityHintCB(RpcInData *data)
{
unsigned int set;
- Bool success = FALSE;
+ gboolean success = FALSE;
unsigned int index = 0;
Debug("%s: enter\n", __FUNCTION__);
* @return TRUE if we can reply, FALSE otherwise.
*/
-static Bool
+static gboolean
ResolutionDisplayTopologyModesSetCB(RpcInData *data)
{
DisplayTopologyInfo *displays = NULL;
unsigned int i;
unsigned int cmd;
unsigned int screen;
- Bool success = FALSE;
+ gboolean success = FALSE;
const char *p;
Debug("%s: enter\n", __FUNCTION__);
* @return TRUE if we can reply, FALSE otherwise.
*/
-static Bool
+static gboolean
ResolutionDisplayTopologySetCB(RpcInData *data)
{
DisplayTopologyInfo *displays = NULL;
unsigned int count, i;
- Bool success = FALSE;
+ gboolean success = FALSE;
const char *p;
ResolutionInfoType *resInfo = &resolutionInfo;
* @return TRUE on success.
*/
-static Bool
+static gboolean
TimeSyncTcloHandler(RpcInData *data)
{
Bool backwardSync = !strcmp(data->args, "1");
static char * ToolsDaemonTcloGetEncodedQuotedString(const char *args,
const char **endOfArg);
-Bool ToolsDaemonTcloReceiveVixCommand(RpcInData *data);
+RpcInRet ToolsDaemonTcloReceiveVixCommand(RpcInData *data);
-#if !defined(N_PLAT_NLM)
-Bool ToolsDaemonHgfsImpersonated(RpcInData *data);
-#endif
+RpcInRet ToolsDaemonHgfsImpersonated(RpcInData *data);
#if defined(linux) || defined(_WIN32)
-Bool ToolsDaemonTcloSyncDriverFreeze(RpcInData *data);
+RpcInRet ToolsDaemonTcloSyncDriverFreeze(RpcInData *data);
-Bool ToolsDaemonTcloSyncDriverThaw(RpcInData *data);
+RpcInRet ToolsDaemonTcloSyncDriverThaw(RpcInData *data);
#endif
-Bool ToolsDaemonTcloMountHGFS(RpcInData *data);
+RpcInRet ToolsDaemonTcloMountHGFS(RpcInData *data);
void ToolsDaemonTcloReportProgramCompleted(const char *requestName,
VixError err,
*-----------------------------------------------------------------------------
*/
-Bool
+RpcInRet
FoundryToolsDaemonRunProgram(RpcInData *data) // IN
{
VixError err = VIX_OK;
*-----------------------------------------------------------------------------
*/
-Bool
+RpcInRet
FoundryToolsDaemonGetToolsProperties(RpcInData *data) // IN
{
VixError err = VIX_OK;
*-----------------------------------------------------------------------------
*/
-Bool
+RpcInRet
ToolsDaemonTcloCheckUserAccount(RpcInData *data) // IN
{
VixError err = VIX_OK;
*-----------------------------------------------------------------------------
*/
-Bool
+RpcInRet
ToolsDaemonTcloOpenUrl(RpcInData *data) // IN
{
static char resultBuffer[DEFAULT_RESULT_MSG_MAX_LENGTH];
*-----------------------------------------------------------------------------
*/
-Bool
+RpcInRet
ToolsDaemonTcloSetPrinter(RpcInData *data) // IN
{
static char resultBuffer[DEFAULT_RESULT_MSG_MAX_LENGTH];
*/
#if defined(linux) || defined(_WIN32)
-Bool
+RpcInRet
ToolsDaemonTcloSyncDriverFreeze(RpcInData *data)
{
static char resultBuffer[DEFAULT_RESULT_MSG_MAX_LENGTH];
*/
#if defined(linux) || defined(_WIN32)
-Bool
+RpcInRet
ToolsDaemonTcloSyncDriverThaw(RpcInData *data) // IN
{
static char resultBuffer[DEFAULT_RESULT_MSG_MAX_LENGTH];
*-----------------------------------------------------------------------------
*/
-Bool
+RpcInRet
ToolsDaemonTcloMountHGFS(RpcInData *data) // IN
{
VixError err = VIX_OK;
*-----------------------------------------------------------------------------
*/
-Bool
+RpcInRet
ToolsDaemonHgfsImpersonated(RpcInData *data) // IN
{
VixError err;
*-----------------------------------------------------------------------------
*/
-Bool
+RpcInRet
ToolsDaemonTcloReceiveVixCommand(RpcInData *data) // IN
{
VixError err = VIX_OK;
#define Warning g_warning
#include "vmtoolsApp.h"
+#include "rpcin.h"
-Bool
+RpcInRet
ToolsDaemonTcloCheckUserAccount(RpcInData *data);
-Bool
+RpcInRet
FoundryToolsDaemonGetToolsProperties(RpcInData *data);
-Bool
+RpcInRet
ToolsDaemonHgfsImpersonated(RpcInData *data);
-Bool
+RpcInRet
ToolsDaemonTcloMountHGFS(RpcInData *data);
-Bool
+RpcInRet
ToolsDaemonTcloReceiveVixCommand(RpcInData *data);
-Bool
+RpcInRet
FoundryToolsDaemonRunProgram(RpcInData *data);
#if defined(linux) || defined(_WIN32)
-Bool
+RpcInRet
ToolsDaemonTcloSyncDriverFreeze(RpcInData *data);
-Bool
+RpcInRet
ToolsDaemonTcloSyncDriverThaw(RpcInData *data);
#endif
* @return TRUE on success, FALSE on failure.
*/
-static Bool
+static gboolean
VixUserOpenUrl(RpcInData *data)
{
static char resultBuffer[DEFAULT_RESULT_MSG_MAX_LENGTH];
* @return TRUE on success, FALSE on failure.
*/
-static Bool
+static gboolean
VixUserSetPrinter(RpcInData *data)
{
static char resultBuffer[DEFAULT_RESULT_MSG_MAX_LENGTH];
* @return TRUE on success.
*/
-static Bool
+static gboolean
VmBackupStart(RpcInData *data)
{
g_debug("*** %s\n", __FUNCTION__);
* @return TRUE
*/
-static Bool
+static gboolean
VmBackupAbort(RpcInData *data)
{
g_debug("*** %s\n", __FUNCTION__);
* @return TRUE
*/
-static Bool
+static gboolean
VmBackupSnapshotDone(RpcInData *data)
{
g_debug("*** %s\n", __FUNCTION__);
* @return TRUE.
*/
-static Bool
+static gboolean
ToolsCoreRpcCapReg(RpcInData *data)
{
char *confPath = GuestApp_GetConfPath();
*
* @param[in] data The RPC data.
*
- * @return TRUE.
+ * @return Whether the option was successfully processed.
*/
-static Bool
+static gboolean
ToolsCoreRpcSetOption(RpcInData *data)
{
} else {
RPCIN_SETRETVALS(data, "Unknown or invalid option", retVal);
}
- return (Bool) retVal;
+ return retVal;
}
* @return TRUE on success.
*/
-static Bool
+static gboolean
TestPluginRpc1(RpcInData *data)
{
ToolsAppCtx *ctx = data->appCtx;
* @return TRUE on success.
*/
-static Bool
+static gboolean
TestPluginRpc2(RpcInData *data)
{
g_debug("%s: %s\n", __FUNCTION__, data->name);
* @return TRUE on success.
*/
-static Bool
+static gboolean
TestPluginRpc3(RpcInData *data)
{
TestPluginData *ret;
static gboolean
RpcDebugDispatch(gpointer _chan)
{
- Bool ret;
+ gboolean ret;
RpcChannel *chan = _chan;
DbgChannelData *cdata = chan->_private;
RpcDebugPlugin *plugin = cdata->plugin;
ret = RpcChannel_Dispatch(&data);
if (rpcdata.validateFn != NULL) {
- ret = (Bool) rpcdata.validateFn(&data, ret);
+ ret = rpcdata.validateFn(&data, ret);
} else if (!ret) {
g_debug("RpcChannel_Dispatch returned error for RPC.\n");
}
* @return TRUE.
*/
-static Bool
+static gboolean
RpcDebugStart(RpcChannel *chan)
{
DbgChannelData *data = chan->_private;
* a validation function was not provided.
*/
-static Bool
+static gboolean
RpcDebugSend(RpcChannel *chan,
char *data,
size_t dataLen,
RpcDebugPlugin *plugin = ((DbgChannelData *)chan->_private)->plugin;
RpcDebugRecvMapping *mapping = NULL;
RpcDebugRecvFn recvFn = NULL;
- Bool ret = TRUE;
+ gboolean ret = TRUE;
g_assert(chan->appName != NULL);