• Main Page
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

lib/include/vmware/tools/guestrpc.h

Go to the documentation of this file.
00001 /*********************************************************
00002  * Copyright (C) 2008 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_GUESTRPC_H_
00020 #define _VMWARE_TOOLS_GUESTRPC_H_
00021 
00039 #include <glib.h>
00040 #include "vmware/tools/utils.h"
00041 
00042 G_BEGIN_DECLS
00043 
00045 #define RPCIN_SETRETVALS RpcChannel_SetRetVals
00046 
00047 struct RpcChannel;
00048 
00050 typedef struct RpcInData {
00052    const char *name;
00057    const char *args;
00059    size_t argsSize;
00064    char *result;
00066    size_t resultLen;
00071    gboolean freeResult;
00073    void *appCtx;
00075    void *clientData;
00076 } RpcInData;
00077 
00078 
00083 typedef gboolean (*RpcIn_Callback)(RpcInData *data);
00084 
00085 
00087 typedef struct RpcChannelCallback {
00089    const char       *name;
00091    RpcIn_Callback    callback;
00093    gpointer          clientData;
00095    gpointer          xdrIn;
00102    gpointer          xdrOut;
00107    size_t            xdrInSize;
00108 } RpcChannelCallback;
00109 
00110 
00111 typedef gboolean (*RpcChannelStartFn)(struct RpcChannel *);
00112 typedef void (*RpcChannelStopFn)(struct RpcChannel *);
00113 typedef void (*RpcChannelShutdownFn)(struct RpcChannel *);
00114 typedef gboolean (*RpcChannelSendFn)(struct RpcChannel *,
00115                                      char *data,
00116                                      size_t dataLen,
00117                                      char **result,
00118                                      size_t *resultLen);
00119 typedef void (*RpcChannelSetupFn)(struct RpcChannel *chan,
00120                                   GMainContext *mainCtx,
00121                                   const char *appName,
00122                                   gpointer appCtx);
00123 
00124 
00132 typedef void (*RpcChannelResetCb)(struct RpcChannel *chan,
00133                                   gboolean success,
00134                                   gpointer data);
00135 
00136 
00138 typedef struct RpcChannel {
00139    RpcChannelStartFn       start;
00140    RpcChannelStopFn        stop;
00141    RpcChannelSendFn        send;
00142    RpcChannelSetupFn       setup;
00143    RpcChannelShutdownFn    shutdown;
00144    gpointer                _private;
00145 } RpcChannel;
00146 
00147 
00156 G_INLINE_FUNC gboolean
00157 RpcChannel_Start(RpcChannel *chan)
00158 {
00159    g_return_val_if_fail(chan != NULL, FALSE);
00160    g_return_val_if_fail(chan->start != NULL, FALSE);
00161 
00162    return chan->start(chan);
00163 }
00164 
00165 
00172 G_INLINE_FUNC void
00173 RpcChannel_Stop(RpcChannel *chan)
00174 {
00175    g_return_if_fail(chan != NULL);
00176    g_return_if_fail(chan->stop != NULL);
00177 
00178    chan->stop(chan);
00179 }
00180 
00181 
00194 G_INLINE_FUNC gboolean
00195 RpcChannel_Send(RpcChannel *chan,
00196                 char *data,
00197                 size_t dataLen,
00198                 char **result,
00199                 size_t *resultLen)
00200 {
00201    g_return_val_if_fail(chan != NULL, FALSE);
00202    g_return_val_if_fail(chan->send != NULL, FALSE);
00203 
00204    return chan->send(chan, data, dataLen, result, resultLen);
00205 }
00206 
00207 gboolean
00208 RpcChannel_BuildXdrCommand(const char *cmd,
00209                            void *xdrProc,
00210                            void *xdrData,
00211                            char **result,
00212                            size_t *resultLen);
00213 
00214 RpcChannel *
00215 RpcChannel_Create(void);
00216 
00217 gboolean
00218 RpcChannel_Destroy(RpcChannel *chan);
00219 
00220 gboolean
00221 RpcChannel_Dispatch(RpcInData *data);
00222 
00223 void
00224 RpcChannel_Setup(RpcChannel *chan,
00225                  const gchar *appName,
00226                  GMainContext *mainCtx,
00227                  gpointer appCtx,
00228                  RpcChannelResetCb resetCb,
00229                  gpointer resetData);
00230 
00231 void
00232 RpcChannel_RegisterCallback(RpcChannel *chan,
00233                             RpcChannelCallback *rpc);
00234 
00235 gboolean
00236 RpcChannel_SetRetVals(RpcInData *data,
00237                       char *result,
00238                       gboolean retVal);
00239 
00240 void
00241 RpcChannel_UnregisterCallback(RpcChannel *chan,
00242                               RpcChannelCallback *rpc);
00243 
00244 
00245 RpcChannel *
00246 BackdoorChannel_New(void);
00247 
00248 G_END_DECLS
00249 
00252 #endif
00253 

Generated on Tue Nov 9 2010 for open-vm-tools 2010.09.19 by  doxygen 1.7.1