Merge branch 'master' into jwi-bcc64xsingletonwarning
[ACE_TAO.git] / ACE / examples / Misc / test_read_buffer.cpp
blob5b906cd2ed1020f8dd1abfd1f14dd8f6a045d0fc
1 #include "ace/OS_main.h"
2 #include "ace/OS_NS_fcntl.h"
3 #include "ace/OS_NS_unistd.h"
4 #include "ace/Malloc_Base.h"
5 #include "ace/Service_Config.h"
6 #include "ace/Read_Buffer.h"
7 #include "ace/OS_NS_stdlib.h"
9 int
10 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
12 ACE_HANDLE handle = argc > 1 ? ACE_OS::open (argv[1], O_RDONLY) : ACE_STDIN;
13 int term = argc > 2 ? ACE_OS::atoi (argv[2]) : EOF;
14 int search = argc > 3 ? ACE_OS::atoi (argv[3]) : '\n';
15 int replace = argc > 4 ? ACE_OS::atoi (argv[4]) : '\0';
17 ACE_Read_Buffer rb (handle);
19 char *buf = 0;
21 while ((buf = rb.read (term, search, replace)) != 0)
23 ACE_OS::write (ACE_STDOUT, buf, rb.size ());
24 ACE_Allocator::instance ()->free (buf);
26 return 0;