1 // Print a file in reverse by using the ACE memory mapped file
2 // wrapper. It is SO easy to do compared with alternatives!
4 #include "ace/OS_main.h"
5 #include "ace/Mem_Map.h"
6 #include "ace/Log_Msg.h"
7 #include "ace/Truncate.h"
11 putline (const char *s
)
13 while (putchar (*s
++) != '\n')
18 print_array_in_reverse (char *array
,
26 if (array
[size
] == '\0')
30 if (array
[size
] == '\n')
31 putline (array
+ size
+ 1);
37 ACE_TMAIN (int argc
, ACE_TCHAR
**argv
)
39 ACE_LOG_MSG
->open (argv
[0]);
42 ACE_ERROR_RETURN ((LM_ERROR
,
48 if (mmap
.map (argv
[1], static_cast<size_t> (-1), O_RDWR
) == -1)
49 ACE_ERROR_RETURN ((LM_ERROR
,
54 print_array_in_reverse ((char *) mmap
.addr (),
55 ACE_Utils::truncate_cast
<int> (mmap
.size ()));