open-vm-tools 2015.01.29
lib/include/vmware/tools/rpcdebug.h
Go to the documentation of this file.
00001 /*********************************************************
00002  * Copyright (C) 2008-2015 VMware, Inc. All rights reserved.
00003  *
00004  * This program is free software; you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License as published
00006  * by the Free Software Foundation version 2.1 and no later version.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00010  * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
00011  * License for more details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this program; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
00016  *
00017  *********************************************************/
00018 
00019 #ifndef _VMWARE_TOOLS_RPCDEBUG_H_
00020 #define _VMWARE_TOOLS_RPCDEBUG_H_
00021 
00032 #include "vmware/tools/plugin.h"
00033 
00034 
00041 #define RPCDEBUG_ASSERT(test, retval) do {   \
00042    CU_ASSERT(test);                          \
00043    g_return_val_if_fail(test, retval);       \
00044 } while (0)
00045 
00046 
00047 struct RpcDebugPlugin;
00048 
00053 typedef gboolean (*RpcDebugRecvFn)(char *data,
00054                                    size_t dataLen,
00055                                    char **result,
00056                                    size_t *resultLen);
00057 
00059 typedef struct RpcDebugRecvMapping {
00060    gchar            *name;
00061    RpcDebugRecvFn    recvFn;
00066    gpointer          xdrProc;
00068    size_t            xdrSize;
00069 } RpcDebugRecvMapping;
00070 
00071 
00077 typedef gboolean (*RpcDebugValidateFn)(RpcInData *data,
00078                                        gboolean ret);
00079 
00081 typedef struct RpcDebugMsgMapping {
00082    gchar                  *message;
00083    size_t                  messageLen;
00084    RpcDebugValidateFn      validateFn;
00085    gboolean                freeMsg;
00086 } RpcDebugMsgMapping;
00087 
00089 typedef struct RpcDebugMsgList {
00090    RpcDebugMsgMapping     *mappings;
00091    size_t                  index;
00092 } RpcDebugMsgList;
00093 
00094 
00102 typedef gboolean (*RpcDebugSendFn)(RpcDebugMsgMapping *rpcdata);
00103 
00105 typedef void (*RpcDebugShutdownFn)(ToolsAppCtx *ctx,
00106                                    struct RpcDebugPlugin *plugin);
00107 
00112 typedef struct RpcDebugPlugin {
00114    RpcDebugRecvMapping *recvFns;
00119    RpcDebugRecvFn       dfltRecvFn;
00121    RpcDebugSendFn       sendFn;
00123    RpcDebugShutdownFn   shutdownFn;
00125    ToolsPluginData     *plugin;
00126 } RpcDebugPlugin;
00127 
00128 
00133 typedef RpcDebugPlugin *(*RpcDebugOnLoadFn)(ToolsAppCtx *ctx);
00134 
00135 struct RpcDebugLibData;
00136 
00142 typedef struct RpcDebugLibData {
00143    RpcChannel *    (*newDebugChannel)  (ToolsAppCtx *,
00144                                         struct RpcDebugLibData *);
00145    int             (*run)              (ToolsAppCtx *,
00146                                         gpointer runMainLoop,
00147                                         gpointer runData,
00148                                         struct RpcDebugLibData *);
00149    RpcDebugPlugin   *debugPlugin;
00150 } RpcDebugLibData;
00151 
00153 typedef RpcDebugLibData *(* RpcDebugInitializeFn)(ToolsAppCtx *, gchar *);
00154 
00155 
00156 G_BEGIN_DECLS
00157 
00158 void
00159 RpcDebug_DecRef(ToolsAppCtx *ctx);
00160 
00161 void
00162 RpcDebug_IncRef(void);
00163 
00164 RpcDebugLibData *
00165 RpcDebug_Initialize(ToolsAppCtx *ctx,
00166                     gchar *dbgPlugin);
00167 
00168 gboolean
00169 RpcDebug_SendNext(RpcDebugMsgMapping *rpcdata,
00170                   RpcDebugMsgList *list);
00171 
00172 void
00173 RpcDebug_SetResult(const char *str,
00174                    char **res,
00175                    size_t *len);
00176 
00177 G_END_DECLS
00178 
00181 #endif /* _VMWARE_TOOLS_RPCDEBUG_H_ */
00182