VirtualBox

source: vbox/trunk/src/VBox/Runtime/tools/RTGzip.cpp@ 47506

Last change on this file since 47506 was 47359, checked in by vboxsync, 11 years ago

IPRT: Added compression to the gzip VFS I/O stream class (RTZipGzipCompressIoStream) and implemented compression in the RTGzip example tool (testcase\RTGzip.exe).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.1 KB
Line 
1/* $Id: RTGzip.cpp 47359 2013-07-24 00:45:47Z vboxsync $ */
2/** @file
3 * IPRT - GZIP Utility.
4 */
5
6/*
7 * Copyright (C) 2010-2011 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#include <iprt/zip.h>
32
33#include <iprt/buildconfig.h>
34#include <iprt/file.h>
35#include <iprt/getopt.h>
36#include <iprt/initterm.h>
37#include <iprt/message.h>
38#include <iprt/param.h>
39#include <iprt/path.h>
40#include <iprt/stream.h>
41#include <iprt/string.h>
42#include <iprt/vfs.h>
43#include <iprt/zip.h>
44
45
46/*******************************************************************************
47* Structures and Typedefs *
48*******************************************************************************/
49/**
50 * Gzip command options.
51 */
52typedef struct RTGZIPCMDOPTS
53{
54 bool fAscii;
55 bool fStdOut;
56 bool fDecompress;
57 bool fForce;
58 bool fKeep;
59 bool fList;
60 bool fName;
61 bool fQuiet;
62 bool fRecursive;
63 const char *pszSuff;
64 bool fTest;
65 unsigned uLevel;
66 /** The current output filename (for deletion). */
67 char szOutput[RTPATH_MAX];
68 /** The current input filename (for deletion and messages). */
69 const char *pszInput;
70} RTGZIPCMDOPTS;
71/** Pointer to GZIP options. */
72typedef RTGZIPCMDOPTS *PRTGZIPCMDOPTS;
73/** Pointer to const GZIP options. */
74typedef RTGZIPCMDOPTS const *PCRTGZIPCMDOPTS;
75
76
77
78/**
79 * Checks if the given standard handle is a TTY.
80 *
81 * @returns true / false
82 * @param enmStdHandle The standard handle.
83 */
84static bool gzipIsStdHandleATty(RTHANDLESTD enmStdHandle)
85{
86 /** @todo Add isatty() to IPRT. */
87 return false;
88}
89
90
91/**
92 * Pushes data from the input to the output I/O streams.
93 *
94 * @returns RTEXITCODE_SUCCESS or RTEXITCODE_FAILURE.
95 * @param hVfsSrc The source I/O stream.
96 * @param hVfsDst The destination I/O stream.
97 */
98static RTEXITCODE gzipPush(RTVFSIOSTREAM hVfsSrc, RTVFSIOSTREAM hVfsDst)
99{
100 for (;;)
101 {
102 uint8_t abBuf[_64K];
103 size_t cbRead;
104 int rc = RTVfsIoStrmRead(hVfsSrc, abBuf, sizeof(abBuf), true /*fBlocking*/, &cbRead);
105 if (RT_FAILURE(rc))
106 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTVfsIoStrmRead failed: %Rrc", rc);
107 if (rc == VINF_EOF && cbRead == 0)
108 return RTEXITCODE_SUCCESS;
109
110 rc = RTVfsIoStrmWrite(hVfsDst, abBuf, cbRead, true /*fBlocking*/, NULL /*cbWritten*/);
111 if (RT_FAILURE(rc))
112 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTVfsIoStrmWrite failed: %Rrc", rc);
113 }
114}
115
116
117/**
118 * Pushes the bytes from the input to the output stream, flushes the output
119 * stream and closes both of them.
120 *
121 * On failure, we will delete the output file, if it's a file. The input file
122 * may be deleted, if we're not told to keep it (--keep, --to-stdout).
123 *
124 * @returns RTEXITCODE_SUCCESS or RTEXITCODE_FAILURE.
125 * @param phVfsSrc The input stream. Set to NIL if closed.
126 * @param pOpts The options.
127 * @param phVfsDst The output stream. Set to NIL if closed.
128 */
129static RTEXITCODE gzipPushFlushAndClose(PRTVFSIOSTREAM phVfsSrc, PCRTGZIPCMDOPTS pOpts, PRTVFSIOSTREAM phVfsDst)
130{
131 /*
132 * Push bytes, flush and close the streams.
133 */
134 RTEXITCODE rcExit = gzipPush(*phVfsSrc, *phVfsDst);
135
136 RTVfsIoStrmRelease(*phVfsSrc);
137 *phVfsSrc = NIL_RTVFSIOSTREAM;
138
139 int rc = RTVfsIoStrmFlush(*phVfsDst);
140 if (RT_FAILURE(rc))
141 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to flush the output file: %Rrc", rc);
142 RTVfsIoStrmRelease(*phVfsDst);
143 *phVfsDst = NIL_RTVFSIOSTREAM;
144
145 /*
146 * Do the cleaning up, if needed. Remove the input file, if that's the
147 * desire of the user, or remove the output file on failure.
148 */
149 if (!pOpts->fStdOut)
150 {
151 if (rcExit == RTEXITCODE_SUCCESS)
152 {
153 if (!pOpts->fKeep)
154 {
155 rc = RTFileDelete(pOpts->pszInput);
156 if (RT_FAILURE(rc))
157 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to delete '%s': %Rrc", pOpts->pszInput, rc);
158 }
159 }
160 else
161 {
162 rc = RTFileDelete(pOpts->szOutput);
163 if (RT_FAILURE(rc))
164 RTMsgError("Failed to delete '%s': %Rrc", pOpts->szOutput, rc);
165 }
166 }
167
168 return rcExit;
169}
170
171
172/**
173 * Compresses one stream to another.
174 *
175 * @returns Exit code.
176 * @param phVfsSrc The input stream. Set to NIL if closed.
177 * @param pOpts The options.
178 * @param phVfsDst The output stream. Set to NIL if closed.
179 */
180static RTEXITCODE gzipCompressFile(PRTVFSIOSTREAM phVfsSrc, PCRTGZIPCMDOPTS pOpts, PRTVFSIOSTREAM phVfsDst)
181{
182 /*
183 * Attach the ompressor to the output stream.
184 */
185 RTVFSIOSTREAM hVfsGzip;
186 int rc = RTZipGzipCompressIoStream(*phVfsDst, 0 /*fFlags*/, pOpts->uLevel, &hVfsGzip);
187 if (RT_FAILURE(rc))
188 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTZipGzipCompressIoStream failed: %Rrc", rc);
189
190 uint32_t cRefs = RTVfsIoStrmRelease(*phVfsDst);
191 Assert(cRefs > 0);
192 *phVfsDst = hVfsGzip;
193
194 return gzipPushFlushAndClose(phVfsSrc, pOpts, phVfsDst);
195}
196
197
198/**
199 * Attach a decompressor to the given source stream, replacing and releasing the
200 * input handle with the decompressor.
201 *
202 * @returns Exit code.
203 * @param phVfsSrc The input stream. Replaced on success.
204 */
205static RTEXITCODE gzipSetupDecompressor(PRTVFSIOSTREAM phVfsSrc)
206{
207 /*
208 * Attach the decompressor to the input stream.
209 */
210 RTVFSIOSTREAM hVfsGunzip;
211 int rc = RTZipGzipDecompressIoStream(*phVfsSrc, 0 /*fFlags*/, &hVfsGunzip);
212 if (RT_FAILURE(rc))
213 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTZipGzipDecompressIoStream failed: %Rrc", rc);
214
215 uint32_t cRefs = RTVfsIoStrmRelease(*phVfsSrc);
216 Assert(cRefs > 0);
217 *phVfsSrc = hVfsGunzip;
218
219 return RTEXITCODE_SUCCESS;
220}
221
222
223/**
224 * Decompresses one stream to another.
225 *
226 * @returns Exit code.
227 * @param phVfsSrc The input stream. Set to NIL if closed.
228 * @param pOpts The options.
229 * @param phVfsDst The output stream. Set to NIL if closed.
230 */
231static RTEXITCODE gzipDecompressFile(PRTVFSIOSTREAM phVfsSrc, PCRTGZIPCMDOPTS pOpts, PRTVFSIOSTREAM phVfsDst)
232{
233 RTEXITCODE rcExit = gzipSetupDecompressor(phVfsSrc);
234 if (rcExit == RTEXITCODE_SUCCESS)
235 rcExit = gzipPushFlushAndClose(phVfsSrc, pOpts, phVfsDst);
236 return rcExit;
237}
238
239
240/**
241 * For testing the archive (todo).
242 *
243 * @returns Exit code.
244 * @param phVfsSrc The input stream. Set to NIL if closed.
245 * @param pOpts The options.
246 */
247static RTEXITCODE gzipTestFile(PRTVFSIOSTREAM phVfsSrc, PCRTGZIPCMDOPTS pOpts)
248{
249 /*
250 * Read the whole stream.
251 */
252 RTEXITCODE rcExit = gzipSetupDecompressor(phVfsSrc);
253 if (rcExit == RTEXITCODE_SUCCESS)
254 {
255 for (;;)
256 {
257 uint8_t abBuf[_64K];
258 size_t cbRead;
259 int rc = RTVfsIoStrmRead(*phVfsSrc, abBuf, sizeof(abBuf), true /*fBlocking*/, &cbRead);
260 if (RT_FAILURE(rc))
261 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTVfsIoStrmRead failed: %Rrc", rc);
262 if (rc == VINF_EOF && cbRead == 0)
263 return RTEXITCODE_SUCCESS;
264 }
265 }
266 return rcExit;
267}
268
269
270static RTEXITCODE gzipListFile(PRTVFSIOSTREAM phVfsSrc, PCRTGZIPCMDOPTS pOpts)
271{
272 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Listing has not been implemented");
273}
274
275
276/**
277 * Opens the output file.
278 *
279 * @returns Command exit, error messages written using RTMsg*.
280 *
281 * @param pszFile The input filename.
282 * @param pOpts The options, szOutput will be filled in by this
283 * function on success.
284 * @param phVfsIos Where to return the output stream handle.
285 *
286 * @remarks This is actually not quite the way we need to do things.
287 *
288 * First of all, we need a GZIP file system stream for a real GZIP
289 * implementation, since there may be more than one file in the gzipped
290 * file.
291 *
292 * Second, we need to open the output files as we encounter files in the input
293 * file system stream. The gzip format contains timestamp and usually a
294 * filename, the default is to use this name (see the --no-name
295 * option).
296 */
297static RTEXITCODE gzipOpenOutput(const char *pszFile, PRTGZIPCMDOPTS pOpts, PRTVFSIOSTREAM phVfsIos)
298{
299 int rc;
300 if (!strcmp(pszFile, "-") || pOpts->fStdOut)
301 {
302 strcpy(pOpts->szOutput, "-");
303
304 if ( !pOpts->fForce
305 && !pOpts->fDecompress
306 && gzipIsStdHandleATty(RTHANDLESTD_OUTPUT))
307 return RTMsgErrorExit(RTEXITCODE_SYNTAX,
308 "Yeah, right. I'm not writing any compressed data to the terminal without --force.\n");
309
310 rc = RTVfsIoStrmFromStdHandle(RTHANDLESTD_OUTPUT,
311 RTFILE_O_WRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE,
312 true /*fLeaveOpen*/,
313 phVfsIos);
314 if (RT_FAILURE(rc))
315 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error opening standard output: %Rrc", rc);
316 }
317 else
318 {
319 Assert(!RTVfsChainIsSpec(pszFile));
320
321 /* Construct an output filename. */
322 rc = RTStrCopy(pOpts->szOutput, sizeof(pOpts->szOutput), pszFile);
323 if (RT_FAILURE(rc))
324 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error constructing output filename: %Rrc", rc);
325 if (pOpts->fDecompress)
326 {
327 /** @todo take filename from archive? */
328 size_t cchSuff = strlen(pOpts->pszSuff); Assert(cchSuff > 0);
329 size_t cch = strlen(pOpts->szOutput);
330 if ( cch <= cchSuff
331 || strcmp(&pOpts->szOutput[cch - cchSuff], pOpts->pszSuff))
332 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Input file does not end with: '%s'", pOpts->pszSuff);
333 pOpts->szOutput[cch - cchSuff] = '\0';
334 if (!RTPathFilename(pOpts->szOutput))
335 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error constructing output filename: Input file name is all suffix.");
336 }
337 else
338 {
339 rc = RTStrCat(pOpts->szOutput, sizeof(pOpts->szOutput), pOpts->pszSuff);
340 if (RT_FAILURE(rc))
341 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error constructing output filename: %Rrc", rc);
342 }
343
344 /* Open the output file. */
345 uint32_t fOpen = RTFILE_O_WRITE | RTFILE_O_DENY_WRITE;
346 if (pOpts->fForce)
347 fOpen |= RTFILE_O_CREATE_REPLACE;
348 else
349 fOpen |= RTFILE_O_CREATE;
350 rc = RTVfsIoStrmOpenNormal(pOpts->szOutput, fOpen, phVfsIos);
351 if (RT_FAILURE(rc))
352 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error opening output file '%s': %Rrc", pOpts->szOutput, rc);
353 }
354
355 return RTEXITCODE_SUCCESS;
356}
357
358
359/**
360 * Opens the input file.
361 *
362 * @returns Command exit, error messages written using RTMsg*.
363 *
364 * @param pszFile The input filename.
365 * @param pOpts The options, szOutput will be filled in by this
366 * function on success.
367 * @param phVfsIos Where to return the input stream handle.
368 */
369static RTEXITCODE gzipOpenInput(const char *pszFile, PRTGZIPCMDOPTS pOpts, PRTVFSIOSTREAM phVfsIos)
370{
371 int rc;
372
373 pOpts->pszInput = pszFile;
374 if (!strcmp(pszFile, "-"))
375 {
376 if ( !pOpts->fForce
377 && pOpts->fDecompress
378 && gzipIsStdHandleATty(RTHANDLESTD_OUTPUT))
379 return RTMsgErrorExit(RTEXITCODE_SYNTAX,
380 "Yeah, right. I'm not reading any compressed data from the terminal without --force.\n");
381
382 rc = RTVfsIoStrmFromStdHandle(RTHANDLESTD_INPUT,
383 RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE,
384 true /*fLeaveOpen*/,
385 phVfsIos);
386 if (RT_FAILURE(rc))
387 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error opening standard input: %Rrc", rc);
388 }
389 else
390 {
391 const char *pszError;
392 rc = RTVfsChainOpenIoStream(pszFile, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, phVfsIos, &pszError);
393 if (RT_FAILURE(rc))
394 {
395 if (pszError && *pszError)
396 return RTMsgErrorExit(RTEXITCODE_FAILURE,
397 "RTVfsChainOpenIoStream failed with rc=%Rrc:\n"
398 " '%s'\n",
399 " %*s^\n",
400 rc, pszFile, pszError - pszFile, "");
401 return RTMsgErrorExit(RTEXITCODE_FAILURE,
402 "RTVfsChainOpenIoStream failed with rc=%Rrc: '%s'",
403 rc, pszFile);
404 }
405 }
406
407 return RTEXITCODE_SUCCESS;
408
409}
410
411
412/**
413 * A mini GZIP program.
414 *
415 * @returns Program exit code.
416 *
417 * @param cArgs The number of arguments.
418 * @param papszArgs The argument vector. (Note that this may be
419 * reordered, so the memory must be writable.)
420 */
421RTEXITCODE RTZipGzipCmd(unsigned cArgs, char **papszArgs)
422{
423
424 /*
425 * Parse the command line.
426 */
427 static const RTGETOPTDEF s_aOptions[] =
428 {
429 { "--ascii", 'a', RTGETOPT_REQ_NOTHING },
430 { "--stdout", 'c', RTGETOPT_REQ_NOTHING },
431 { "--to-stdout", 'c', RTGETOPT_REQ_NOTHING },
432 { "--decompress", 'd', RTGETOPT_REQ_NOTHING },
433 { "--uncompress", 'd', RTGETOPT_REQ_NOTHING },
434 { "--force", 'f', RTGETOPT_REQ_NOTHING },
435 { "--keep", 'k', RTGETOPT_REQ_NOTHING },
436 { "--list", 'l', RTGETOPT_REQ_NOTHING },
437 { "--no-name", 'n', RTGETOPT_REQ_NOTHING },
438 { "--name", 'N', RTGETOPT_REQ_NOTHING },
439 { "--quiet", 'q', RTGETOPT_REQ_NOTHING },
440 { "--recursive", 'r', RTGETOPT_REQ_NOTHING },
441 { "--suffix", 'S', RTGETOPT_REQ_STRING },
442 { "--test", 't', RTGETOPT_REQ_NOTHING },
443 { "--verbose", 'v', RTGETOPT_REQ_NOTHING },
444 { "--fast", '1', RTGETOPT_REQ_NOTHING },
445 { "-1", '1', RTGETOPT_REQ_NOTHING },
446 { "-2", '2', RTGETOPT_REQ_NOTHING },
447 { "-3", '3', RTGETOPT_REQ_NOTHING },
448 { "-4", '4', RTGETOPT_REQ_NOTHING },
449 { "-5", '5', RTGETOPT_REQ_NOTHING },
450 { "-6", '6', RTGETOPT_REQ_NOTHING },
451 { "-7", '7', RTGETOPT_REQ_NOTHING },
452 { "-8", '8', RTGETOPT_REQ_NOTHING },
453 { "-9", '9', RTGETOPT_REQ_NOTHING },
454 { "--best", '9', RTGETOPT_REQ_NOTHING }
455 };
456
457 RTGZIPCMDOPTS Opts;
458 Opts.fAscii = false;
459 Opts.fStdOut = false;
460 Opts.fDecompress = false;
461 Opts.fForce = false;
462 Opts.fKeep = false;
463 Opts.fList = false;
464 Opts.fName = true;
465 Opts.fQuiet = false;
466 Opts.fRecursive = false;
467 Opts.pszSuff = ".gz";
468 Opts.fTest = false;
469 Opts.uLevel = 6;
470
471 RTEXITCODE rcExit = RTEXITCODE_SUCCESS;
472 unsigned cProcessed = 0;
473 RTVFSIOSTREAM hVfsStdOut= NIL_RTVFSIOSTREAM;
474
475 RTGETOPTSTATE GetState;
476 int rc = RTGetOptInit(&GetState, cArgs, papszArgs, s_aOptions, RT_ELEMENTS(s_aOptions), 1,
477 RTGETOPTINIT_FLAGS_OPTS_FIRST);
478 if (RT_FAILURE(rc))
479 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "RTGetOptInit: %Rrc", rc);
480
481 for (;;)
482 {
483 RTGETOPTUNION ValueUnion;
484 int chOpt = RTGetOpt(&GetState, &ValueUnion);
485 switch (chOpt)
486 {
487 case 0:
488 /*
489 * If we've processed any files we're done. Otherwise take
490 * input from stdin and write the output to stdout.
491 */
492 if (cProcessed > 0)
493 return rcExit;
494 ValueUnion.psz = "-";
495 Opts.fStdOut = true;
496 /* Fall thru. */
497 case VINF_GETOPT_NOT_OPTION:
498 {
499 if (!*Opts.pszSuff && !Opts.fStdOut)
500 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "The --suffix option specified an empty string");
501 if (!Opts.fStdOut && RTVfsChainIsSpec(ValueUnion.psz))
502 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Must use standard out with VFS chain specifications");
503 if (Opts.fName)
504 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "The --name option has not yet been implemented. Use --no-name.");
505 if (Opts.fAscii)
506 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "The --ascii option has not yet been implemented.");
507 if (Opts.fRecursive)
508 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "The --recursive option has not yet been implemented.");
509
510 /* Open the input file. */
511 RTVFSIOSTREAM hVfsSrc;
512 RTEXITCODE rcExit2 = gzipOpenInput(ValueUnion.psz, &Opts, &hVfsSrc);
513 if (rcExit2 == RTEXITCODE_SUCCESS)
514 {
515 if (Opts.fList)
516 rcExit2 = gzipListFile(&hVfsSrc, &Opts);
517 else if (Opts.fTest)
518 rcExit2 = gzipTestFile(&hVfsSrc, &Opts);
519 else
520 {
521 RTVFSIOSTREAM hVfsDst;
522 rcExit2 = gzipOpenOutput(ValueUnion.psz, &Opts, &hVfsDst);
523 if (rcExit2 == RTEXITCODE_SUCCESS)
524 {
525 if (Opts.fDecompress)
526 rcExit2 = gzipDecompressFile(&hVfsSrc, &Opts, &hVfsDst);
527 else
528 rcExit2 = gzipCompressFile(&hVfsSrc, &Opts, &hVfsDst);
529 RTVfsIoStrmRelease(hVfsDst);
530 }
531 }
532 RTVfsIoStrmRelease(hVfsSrc);
533 }
534 if (rcExit2 != RTEXITCODE_SUCCESS)
535 rcExit = rcExit2;
536
537 cProcessed++;
538 break;
539 }
540
541 case 'a': Opts.fAscii = true; break;
542 case 'c':
543 Opts.fStdOut = true;
544 Opts.fKeep = true;
545 break;
546 case 'd': Opts.fDecompress = true; break;
547 case 'f': Opts.fForce = true; break;
548 case 'k': Opts.fKeep = true; break;
549 case 'l': Opts.fList = true; break;
550 case 'n': Opts.fName = false; break;
551 case 'N': Opts.fName = true; break;
552 case 'q': Opts.fQuiet = true; break;
553 case 'r': Opts.fRecursive = true; break;
554 case 'S': Opts.pszSuff = ValueUnion.psz; break;
555 case 't': Opts.fTest = true; break;
556 case 'v': Opts.fQuiet = false; break;
557 case '1': Opts.uLevel = 1; break;
558 case '2': Opts.uLevel = 2; break;
559 case '3': Opts.uLevel = 3; break;
560 case '4': Opts.uLevel = 4; break;
561 case '5': Opts.uLevel = 5; break;
562 case '6': Opts.uLevel = 6; break;
563 case '7': Opts.uLevel = 7; break;
564 case '8': Opts.uLevel = 8; break;
565 case '9': Opts.uLevel = 9; break;
566
567 case 'h':
568 RTPrintf("Usage: to be written\nOption dump:\n");
569 for (unsigned i = 0; i < RT_ELEMENTS(s_aOptions); i++)
570 RTPrintf(" -%c,%s\n", s_aOptions[i].iShort, s_aOptions[i].pszLong);
571 return RTEXITCODE_SUCCESS;
572
573 case 'V':
574 RTPrintf("%sr%d\n", RTBldCfgVersion(), RTBldCfgRevision());
575 return RTEXITCODE_SUCCESS;
576
577 default:
578 return RTGetOptPrintError(chOpt, &ValueUnion);
579 }
580 }
581}
582
583
584int main(int argc, char **argv)
585{
586 int rc = RTR3InitExe(argc, &argv, 0);
587 if (RT_FAILURE(rc))
588 return RTMsgInitFailure(rc);
589 return RTZipGzipCmd(argc, argv);
590}
591
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette