summaryrefslogtreecommitdiff
path: root/ACE/examples/Misc/test_read_buffer.cpp
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2008-03-04 14:51:23 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2008-03-04 14:51:23 +0000
commit99aa8c60282c7b8072eb35eb9ac815702f5bf586 (patch)
treebda96bf8c3a4c2875a083d7b16720533c8ffeaf4 /ACE/examples/Misc/test_read_buffer.cpp
parentc4078c377d74290ebe4e66da0b4975da91732376 (diff)
downloadATCD-99aa8c60282c7b8072eb35eb9ac815702f5bf586.tar.gz
undoing accidental deletion
Diffstat (limited to 'ACE/examples/Misc/test_read_buffer.cpp')
-rw-r--r--ACE/examples/Misc/test_read_buffer.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/ACE/examples/Misc/test_read_buffer.cpp b/ACE/examples/Misc/test_read_buffer.cpp
new file mode 100644
index 00000000000..5c53b37b637
--- /dev/null
+++ b/ACE/examples/Misc/test_read_buffer.cpp
@@ -0,0 +1,34 @@
+// $Id$
+
+#include "ace/OS_main.h"
+#include "ace/OS_NS_fcntl.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/Malloc_Base.h"
+#include "ace/Service_Config.h"
+#include "ace/Read_Buffer.h"
+#include "ace/OS_NS_stdlib.h"
+
+
+ACE_RCSID (Misc,
+ test_read_buffer,
+ "$Id$")
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ ACE_HANDLE handle = argc > 1 ? ACE_OS::open (argv[1], O_RDONLY) : ACE_STDIN;
+ int term = argc > 2 ? ACE_OS::atoi (argv[2]) : EOF;
+ int search = argc > 3 ? ACE_OS::atoi (argv[3]) : '\n';
+ int replace = argc > 4 ? ACE_OS::atoi (argv[4]) : '\0';
+
+ ACE_Read_Buffer rb (handle);
+
+ char *buf = 0;
+
+ while ((buf = rb.read (term, search, replace)) != 0)
+ {
+ ACE_OS::write (ACE_STDOUT, buf, rb.size ());
+ ACE_Allocator::instance ()->free (buf);
+ }
+ return 0;
+}