#include "dk4conf.h" #include #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 : */