Mercurial > hg > dmlib
changeset 1104:8a4df37ffe13
Add header skip option to the dmzlib test.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 03 Mar 2015 23:56:12 +0200 |
parents | fd1ccfc62ceb |
children | 62ccecea1317 |
files | tests/testdmzlib.c |
diffstat | 1 files changed, 23 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/testdmzlib.c Tue Mar 03 23:54:38 2015 +0200 +++ b/tests/testdmzlib.c Tue Mar 03 23:56:12 2015 +0200 @@ -10,7 +10,8 @@ char *optInFilename = NULL, *optOutFilename = NULL; -int optCompressLevel = Z_BEST_COMPRESSION; +unsigned int optSkip = 0; +unsigned int optCompressLevel = Z_BEST_COMPRESSION; BOOL optCompress = FALSE, optUseZLIB = FALSE; @@ -21,7 +22,8 @@ { 1, 'q', "quiet", "Decrease verbosity", OPT_NONE }, { 2, 'Z', "zlib", "Use ZLIB instead of dmzlib", OPT_NONE }, { 3, 'c', "compress", "Compress instead of decompressing (ZLIB only)", OPT_NONE }, - { 10, 'l', "level", "Set zlib compression level 1-9", OPT_ARGREQ }, + { 4, 'l', "level", "Set zlib compression level 1-9", OPT_ARGREQ }, + { 5, 's', "skip", "Skip bytes from input start", OPT_ARGREQ }, }; static const int optListN = sizeof(optList) / sizeof(optList[0]); @@ -57,15 +59,23 @@ optCompress = TRUE; break; - case 10: - optCompressLevel = atoi(optArg); - if (optCompressLevel < 1 || optCompressLevel > 9) + case 4: + if (!dmGetIntVal(optArg, &optCompressLevel) || + optCompressLevel < 1 || optCompressLevel > 9) { dmErrorMsg("Invalid compression level argument '%s', must be 1 .. 9.\n", optArg); return FALSE; } break; + case 5: + if (!dmGetIntVal(optArg, &optSkip)) + { + dmErrorMsg("Invalid skip value.\n", optArg); + return FALSE; + } + break; + default: return FALSE; } @@ -288,6 +298,14 @@ goto out; } + if (optSkip > 0 && DM_FSEEK64(inFile, optSkip, SEEK_CUR) != 0) + { + int res = dmGetErrno(); + dmErrorMsg("Failed to seek in input stream: %s\n", + dmErrorStr(res)); + goto out; + } + if (optUseZLIB) ret = dmTestZlib(inFile, outFile, &inSize, &outSize, optCompress, optCompressLevel); else