summaryrefslogtreecommitdiff
path: root/support/dktools/test-dk4strmco.ctr
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/dktools/test-dk4strmco.ctr
Initial commit
Diffstat (limited to 'support/dktools/test-dk4strmco.ctr')
-rw-r--r--support/dktools/test-dk4strmco.ctr79
1 files changed, 79 insertions, 0 deletions
diff --git a/support/dktools/test-dk4strmco.ctr b/support/dktools/test-dk4strmco.ctr
new file mode 100644
index 0000000000..4f2e20855e
--- /dev/null
+++ b/support/dktools/test-dk4strmco.ctr
@@ -0,0 +1,79 @@
+
+#include "dk4conf.h"
+
+#include <stdio.h>
+
+#include "dk4strmf.h"
+#include "dk4strmco.h"
+
+
+
+$!trace-include
+
+
+
+int main(void)
+{
+ char buf[4096];
+ dk4_stream_t *fstrm = NULL;
+ dk4_stream_t *cstrm = NULL;
+ size_t szbuf = sizeof(buf);
+ size_t br;
+ int res;
+ $!trace-init test-dk4strmco.deb
+ $? "+ main"
+ fstrm = dk4stream_open_for_file(
+ stdout, DK4_STREAM_WRITE, 0, 4096, NULL
+ );
+ if (NULL == fstrm) {
+ fputs("ERROR: Failed to open stream for stdout!\n", stderr);
+ fflush(stderr);
+ goto finished;
+ }
+
+ cstrm = dk4strmco_open(
+ fstrm,
+ DK4_STRMCO_PP_NONE, DK4_STRMCO_CO_FLATE, DK4_STRMCO_OE_ASCII85,
+ (DK4_STRMCO_FL_EOD_OE | DK4_STRMCO_FL_NL_OE),
+ NULL
+ );
+ if (NULL == cstrm) {
+ fputs("ERROR: Failed to open compressing stream!\n", stderr);
+ fflush(stderr);
+ goto finished;
+ }
+
+ do {
+ br = fread(buf, 1, szbuf, stdin);
+ if (0 < br) {
+ res = dk4stream_write(cstrm, buf, br, NULL);
+ if (0 == res) {
+ fputs("ERROR: Write operation failed!\n", stderr);
+ fflush(stderr);
+ }
+ }
+ } while ((!feof(stdin)) && (0 < br));
+
+ finished:
+ if (NULL != cstrm) {
+ res = dk4stream_close(cstrm, NULL);
+ if (0 == res) {
+ fputs("ERROR: Failed to close compressed stream!\n", stderr);
+ fflush(stderr);
+ }
+ }
+ if (NULL != fstrm) {
+ res = dk4stream_close(fstrm, NULL);
+ if (0 == res) {
+ fputs("ERROR: Failed to close file stream!\n", stderr);
+ fflush(stderr);
+ }
+ }
+ $? "- main"
+ $!trace-end
+ return 0;
+}
+
+
+/* vim: set ai sw=4 ts=4 : */
+