This source file includes following definitions.
- freadptrbufsize
- 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 "freadptr.h"
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <unistd.h>
26
27 #include "macros.h"
28
29 static int
30 freadptrbufsize (FILE *fp)
31 {
32 size_t size = 0;
33
34 freadptr (fp, &size);
35 return size;
36 }
37
38 int
39 main (int argc, char **argv)
40 {
41 int nbytes = atoi (argv[1]);
42 if (nbytes > 0)
43 {
44 void *buf = malloc (nbytes);
45 ASSERT (fread (buf, 1, nbytes, stdin) == nbytes);
46 free (buf);
47 }
48
49 if (nbytes == 0)
50 ASSERT (freadptrbufsize (stdin) == 0);
51 else
52 {
53 if (lseek (0, 0, SEEK_CUR) == nbytes)
54
55
56 ASSERT (freadptrbufsize (stdin) == 0);
57 else
58
59 ASSERT (freadptrbufsize (stdin) != 0);
60 }
61
62 return 0;
63 }