11 #define TEST_FILE "test-1"
16 const char blah
[] = "BLAH";
23 /* setup the physical file, and use it */
24 if ((fp
= fopen (TEST_FILE
, "w+")) == NULL
)
26 if (fwrite (blah
, 1, strlen (blah
), fp
) != strlen (blah
))
32 while ((ch
= getc (fp
)) != EOF
)
37 printf ("\ncharacter %td: '%c' instead of '%c'\n",
58 /* Now, mmap the file into a buffer, and do that too */
59 if ((fd
= open (TEST_FILE
, O_RDONLY
)) == -1)
61 if (fstat (fd
, &fs
) == -1)
64 if ((mmap_data
= (char *) mmap (NULL
, fs
.st_size
, PROT_READ
,
65 MAP_SHARED
, fd
, 0)) == MAP_FAILED
)
72 if ((fp
= fmemopen (mmap_data
, fs
.st_size
, "r")) == NULL
)
77 while ((ch
= getc (fp
)) != EOF
)
82 printf ("%td character: '%c' instead of '%c'\n",
106 munmap (mmap_data
, fs
.st_size
);