diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/dktools/testlzw.c |
Initial commit
Diffstat (limited to 'support/dktools/testlzw.c')
-rw-r--r-- | support/dktools/testlzw.c | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/support/dktools/testlzw.c b/support/dktools/testlzw.c new file mode 100644 index 0000000000..7d28b3b913 --- /dev/null +++ b/support/dktools/testlzw.c @@ -0,0 +1,109 @@ +/* + WARNING: This file was generated by dkct. + Changes you make here will be lost if dkct is run again! + You should modify the original source and run dkct on it. + Original source: testlzw.ctr +*/ + +/** @file testlzw.c The testlzw module. +*/ + + +#line 1 "testlzw.ctr" + +#include <stdio.h> + +#include <dk4conf.h> +#include "dk4lzwe.h" +#include <dk4edstm.h> + + + +#line 9 "testlzw.ctr" + + +static const unsigned char teststr[] = { + 45, 45, 45, 45, 45, 65, 45, 45, 45, 66 +}; + + + +static +void +show_bytes(dk4_lzwe_t *lzwe) +{ + const unsigned char *cptr = NULL; + size_t nbt = 0; + size_t i; + + + +#line 26 "testlzw.ctr" + if (0 != dk4lzwe_output(&cptr, &nbt, lzwe, NULL)) { + if ((NULL != cptr) && (0 < nbt)) { + for (i = 0; i < nbt; i++) { + printf("%2x\n", (unsigned)(cptr[i])); + } + } + else { + +#line 33 "testlzw.ctr" + } + } + else { + +#line 36 "testlzw.ctr" + } + + +#line 38 "testlzw.ctr" +} + + + +int main(int argc, char *argv[]) +{ + dk4_lzwe_t lzwe; + size_t i; + + + +#line 48 "testlzw.ctr" + + +#line 49 "testlzw.ctr" + if (0 != dk4lzwe_init(&lzwe, NULL)) { + for (i = 0; i < sizeof(teststr); i++) { + switch (dk4lzwe_add(&lzwe, teststr[i], NULL)) { + case DK4_EDSTM_FINISHED : { + show_bytes(&lzwe); + } break; + case DK4_EDSTM_ERROR : { + +#line 56 "testlzw.ctr" + } break; + } + } + switch (dk4lzwe_finish(&lzwe, NULL)) { + case DK4_EDSTM_FINISHED : { + show_bytes(&lzwe); + } break; + case DK4_EDSTM_ERROR : { + +#line 64 "testlzw.ctr" + } break; + } + } + else { + } + + +#line 70 "testlzw.ctr" + + +#line 71 "testlzw.ctr" + return 0; +} + +/* vim: set ai sw=4 ts=4 : */ + |