summaryrefslogtreecommitdiff
path: root/support/dktools/test-dk4strm.c
blob: f8174116062475a96b95debf2c43bcb45a647b34 (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
/*
	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-dk4strm.ctr
*/

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


#line 1 "test-dk4strm.ctr"

#include "dk4strm.h"
#include "dk4strmf.h"
#include "dk4fopc8.h"
#include <stdio.h>





#line 10 "test-dk4strm.ctr"




int main(int argc, char *argv[])
{
  FILE		*fipo;
  dk4_stream_t	*outstrm;
  dk4_stream_t	*instrm;
  dk4_er_t	 er;
  char		 c;
  

#line 22 "test-dk4strm.ctr"
  

#line 23 "test-dk4strm.ctr"
  if (1 < argc) {
    dk4error_init(&er);
    fipo = dk4fopen_c8(argv[1], "w", 0, &er);
    if (NULL != fipo) {
      dk4error_init(&er);
      instrm = dk4stream_open_for_file(stdin, DK4_STREAM_READ, 4096, 0, &er);
      if (NULL != instrm) {
        outstrm = dk4stream_open_for_file(fipo, DK4_STREAM_WRITE, 0, 4096, &er);
	if (NULL != outstrm) {
	  while (dk4stream_c8_read_byte(&c, instrm, &er)) {
	    dk4stream_write_byte(outstrm, (char)c, &er);
	  }
	  (void)dk4stream_close(outstrm, &er);
	}
        (void)dk4stream_close(instrm, &er);
      }
      fclose(fipo);
    } else {
      fprintf(stderr, "Failed to open file %d %d\n", er.ec, er.dt.iDetails1);
    }
  } else {
    dk4error_init(&er);
    instrm = dk4stream_open_for_file(stdin, DK4_STREAM_READ, 4096, 0, &er);
    if (NULL != instrm) {		

#line 47 "test-dk4strm.ctr"
      outstrm = dk4stream_open_for_file(stdout, DK4_STREAM_WRITE, 0, 4096, &er);
      if (NULL != outstrm) {	

#line 49 "test-dk4strm.ctr"
        while (dk4stream_c8_read_byte(&c, instrm, &er)) {
          dk4stream_write_byte(outstrm, (char)c, &er);
        }
        dk4stream_close(outstrm, &er);
      }
      dk4stream_close(instrm, &er);
    }
  }
  

#line 58 "test-dk4strm.ctr"
  

#line 59 "test-dk4strm.ctr"
  fprintf(stderr, "Error code: %d\n", er.ec);
  return 0;
}