summaryrefslogtreecommitdiff
path: root/support/dktools/test-dk4strmco.c
blob: fb89b49fd4a672b075c378ee1adadd03f324089d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
	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: test-dk4strmco.ctr
*/

/**	@file test-dk4strmco.c The test-dk4strmco module.
*/


#line 1 "test-dk4strmco.ctr"

#include "dk4conf.h"

#include <stdio.h>

#include "dk4strmf.h"
#include "dk4strmco.h"





#line 12 "test-dk4strmco.ctr"



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;
	

#line 24 "test-dk4strmco.ctr"
	

#line 25 "test-dk4strmco.ctr"
	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);
		}
	}
	

#line 73 "test-dk4strmco.ctr"
	

#line 74 "test-dk4strmco.ctr"
	return 0;
}


/* vim: set ai sw=4 ts=4 : */