~n-muench/ubuntu/quantal/open-vm-tools/open-vm-tools.march-merge2b

« back to all changes in this revision

Viewing changes to toolbox/toolbox-cmd.c

  • Committer: Bazaar Package Importer
  • Author(s): Nate Muench
  • Date: 2010-09-06 21:06:01 UTC
  • mfrom: (2.4.19 sid)
  • Revision ID: james.westby@ubuntu.com-20100906210601-gxxy30e5roil4srt
Tags: 2010.06.16-268169-3ubuntu1
* Merge from Debian testing (LP: #632101), remaining changes:
  - Recommend open-vm-toolbox in open-vm-tools.
  - Rediffing vsock.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "toolboxCmdInt.h"
33
33
#include "toolboxcmd_version.h"
34
34
#include "system.h"
 
35
#include "vmware/tools/guestrpc.h"
35
36
#include "vmware/tools/i18n.h"
36
37
#include "vmware/tools/utils.h"
37
38
 
75
76
   { 0, 0, 0, 0 } };
76
77
#endif
77
78
 
 
79
static gboolean gQuiet = FALSE;
78
80
static const char *options = "hqv";
79
81
 
80
82
/*
101
103
   { "disk",      Disk_Command,     TRUE,    TRUE,    Disk_Help},
102
104
   { "stat",      Stat_Command,     TRUE,    FALSE,   Stat_Help},
103
105
   { "device",    Device_Command,   TRUE,    FALSE,   Device_Help},
 
106
#if (defined(_WIN32) || defined(linux)) && !defined(OPEN_VM_TOOLS)
 
107
   { "upgrade",   Upgrade_Command,  TRUE,    FALSE,   Upgrade_Help},
 
108
#endif
104
109
   { "help",      HelpCommand,      FALSE,   FALSE,   ToolboxCmdHelp},
105
110
};
106
111
 
132
137
/*
133
138
 *-----------------------------------------------------------------------------
134
139
 *
 
140
 * ToolsCmd_Print --
 
141
 *
 
142
 *      Prints a message to stdout unless quiet output was requested.
 
143
 *
 
144
 * Results:
 
145
 *      None.
 
146
 *
 
147
 * Side effects:
 
148
 *      None.
 
149
 *
 
150
 *-----------------------------------------------------------------------------
 
151
 */
 
152
 
 
153
void
 
154
ToolsCmd_Print(const char *fmt,
 
155
               ...)
 
156
{
 
157
   if (!gQuiet) {
 
158
      gchar *str;
 
159
      va_list args;
 
160
 
 
161
      va_start(args, fmt);
 
162
      g_vasprintf(&str, fmt, args);
 
163
      va_end(args);
 
164
 
 
165
      g_print("%s", str);
 
166
      g_free(str);
 
167
   }
 
168
}
 
169
 
 
170
 
 
171
/*
 
172
 *-----------------------------------------------------------------------------
 
173
 *
 
174
 * ToolsCmd_PrintErr --
 
175
 *
 
176
 *      Prints a message to stderr unless quiet output was requested.
 
177
 *
 
178
 * Results:
 
179
 *      None.
 
180
 *
 
181
 * Side effects:
 
182
 *      None.
 
183
 *
 
184
 *-----------------------------------------------------------------------------
 
185
 */
 
186
 
 
187
void
 
188
ToolsCmd_PrintErr(const char *fmt,
 
189
                  ...)
 
190
{
 
191
   if (!gQuiet) {
 
192
      gchar *str;
 
193
      va_list args;
 
194
 
 
195
      va_start(args, fmt);
 
196
      g_vasprintf(&str, fmt, args);
 
197
      va_end(args);
 
198
 
 
199
      g_printerr("%s", str);
 
200
      g_free(str);
 
201
   }
 
202
}
 
203
 
 
204
 
 
205
/*
 
206
 *-----------------------------------------------------------------------------
 
207
 *
 
208
 * ToolsCmd_SendRPC --
 
209
 *
 
210
 *    Sends an RPC message to the host.
 
211
 *
 
212
 * Results:
 
213
 *    The return value from the RPC.
 
214
 *
 
215
 * Side effects:
 
216
 *    None.
 
217
 *
 
218
 *-----------------------------------------------------------------------------
 
219
 */
 
220
 
 
221
gboolean
 
222
ToolsCmd_SendRPC(const char *rpc,      // IN
 
223
                 size_t rpcLen,        // IN
 
224
                 char **result,        // OUT
 
225
                 size_t *resultLen)    // OUT
 
226
{
 
227
   char *lrpc = (char *) rpc;
 
228
   RpcChannel *chan = BackdoorChannel_New();
 
229
   gboolean ret = RpcChannel_Start(chan);
 
230
 
 
231
   if (!ret) {
 
232
      g_warning("Error starting RPC channel.");
 
233
      goto exit;
 
234
   }
 
235
 
 
236
   ret = RpcChannel_Send(chan, lrpc, rpcLen, result, resultLen);
 
237
 
 
238
exit:
 
239
   RpcChannel_Destroy(chan);
 
240
   return ret;
 
241
}
 
242
 
 
243
 
 
244
/*
 
245
 *-----------------------------------------------------------------------------
 
246
 *
135
247
 * ToolsCmd_UnknownEntityError --
136
248
 *
137
249
 *      Print out error message regarding unknown argument.
184
296
                          "   disk\n"
185
297
                          "   script\n"
186
298
                          "   stat\n"
187
 
                          "   timesync\n\n"
 
299
                          "   timesync\n"
 
300
                          "   upgrade (not available on all operating systems)\n"
 
301
                          "\n"
188
302
                          "For additional information please visit http://www.vmware.com/support/\n\n"),
189
303
           progName, progName, cmd, progName);
190
304
}
293
407
   CmdTable *cmd = NULL;
294
408
   int c;
295
409
   int retval;
296
 
   gboolean quiet = FALSE;
297
410
 
298
411
   setlocale(LC_ALL, "");
299
412
   VMTools_ConfigLogging("toolboxcmd", NULL, FALSE, FALSE);
335
448
         break;
336
449
 
337
450
      case 'q':
338
 
         quiet = TRUE;
 
451
         gQuiet = TRUE;
339
452
         break;
340
453
 
341
454
      case '?':
380
493
         ToolsCmd_MissingEntityError(argv[0], SU_(arg.subcommand, "subcommand"));
381
494
         retval = EX_USAGE;
382
495
      } else {
383
 
         retval = cmd->func(argv, argc, quiet);
 
496
         retval = cmd->func(argv, argc, gQuiet);
384
497
      }
385
498
 
386
499
      if (retval == EX_USAGE && (cmd == NULL || strcmp(cmd->command, "help"))) {