This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include "binary-io.h"
22
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <fcntl.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29
30 #include "macros.h"
31
32 int
33 main (int argc, char *argv[])
34 {
35
36 {
37 int fd =
38 open ("t-bin-out0.tmp", O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0600);
39 if (write (fd, "Hello\n", 6) < 0)
40 exit (1);
41 close (fd);
42 }
43 {
44 struct stat statbuf;
45 if (stat ("t-bin-out0.tmp", &statbuf) < 0)
46 exit (1);
47 ASSERT (statbuf.st_size == 6);
48 }
49
50 switch (argv[1][0])
51 {
52 case '1':
53
54 set_binary_mode (1, O_BINARY);
55 fputs ("Hello\n", stdout);
56 break;
57
58 default:
59 break;
60 }
61
62 return 0;
63 }