summaryrefslogtreecommitdiff
path: root/ACE/examples/Misc
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/examples/Misc')
-rw-r--r--ACE/examples/Misc/.cvsignore16
-rw-r--r--ACE/examples/Misc/Makefile.am191
-rw-r--r--ACE/examples/Misc/Misc.mpc66
-rw-r--r--ACE/examples/Misc/test_XtReactor1.cpp173
-rw-r--r--ACE/examples/Misc/test_XtReactor2.cpp101
-rw-r--r--ACE/examples/Misc/test_dump.cpp33
-rw-r--r--ACE/examples/Misc/test_dump.h50
-rw-r--r--ACE/examples/Misc/test_get_opt.cpp54
-rw-r--r--ACE/examples/Misc/test_profile_timer.cpp38
-rw-r--r--ACE/examples/Misc/test_read_buffer.cpp34
-rw-r--r--ACE/examples/Misc/test_set.cpp57
-rw-r--r--ACE/examples/Misc/test_sstring.cpp26
-rw-r--r--ACE/examples/Misc/test_trace.cpp114
13 files changed, 953 insertions, 0 deletions
diff --git a/ACE/examples/Misc/.cvsignore b/ACE/examples/Misc/.cvsignore
new file mode 100644
index 00000000000..a31a7786288
--- /dev/null
+++ b/ACE/examples/Misc/.cvsignore
@@ -0,0 +1,16 @@
+test_XtReactor1
+test_XtReactor2
+test_dump
+test_dump
+test_get_opt
+test_get_opt
+test_profile_timer
+test_profile_timer
+test_read_buffer
+test_read_buffer
+test_set
+test_set
+test_sstring
+test_sstring
+test_trace
+test_trace
diff --git a/ACE/examples/Misc/Makefile.am b/ACE/examples/Misc/Makefile.am
new file mode 100644
index 00000000000..8bb0b8dc8d8
--- /dev/null
+++ b/ACE/examples/Misc/Makefile.am
@@ -0,0 +1,191 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+ACE_BUILDDIR = $(top_builddir)
+ACE_ROOT = $(top_srcdir)
+
+
+## Makefile.Misc_Test_Dump.am
+noinst_PROGRAMS = test_dump
+
+test_dump_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR)
+
+test_dump_SOURCES = \
+ test_dump.cpp \
+ test_dump.h
+
+test_dump_LDADD = \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+## Makefile.Misc_Test_Get_Opt.am
+noinst_PROGRAMS += test_get_opt
+
+test_get_opt_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR)
+
+test_get_opt_SOURCES = \
+ test_get_opt.cpp \
+ test_dump.h
+
+test_get_opt_LDADD = \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+## Makefile.Misc_Test_Profile_Timer.am
+
+if !BUILD_ACE_FOR_TAO
+noinst_PROGRAMS += test_profile_timer
+
+test_profile_timer_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR)
+
+test_profile_timer_SOURCES = \
+ test_profile_timer.cpp \
+ test_dump.h
+
+test_profile_timer_LDADD = \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif !BUILD_ACE_FOR_TAO
+
+## Makefile.Misc_Test_Read_Buffer.am
+noinst_PROGRAMS += test_read_buffer
+
+test_read_buffer_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR)
+
+test_read_buffer_SOURCES = \
+ test_read_buffer.cpp \
+ test_dump.h
+
+test_read_buffer_LDADD = \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+## Makefile.Misc_Test_Set.am
+noinst_PROGRAMS += test_set
+
+test_set_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR)
+
+test_set_SOURCES = \
+ test_set.cpp \
+ test_dump.h
+
+test_set_LDADD = \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+## Makefile.Misc_Test_Sstring.am
+noinst_PROGRAMS += test_sstring
+
+test_sstring_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR)
+
+test_sstring_SOURCES = \
+ test_sstring.cpp \
+ test_dump.h
+
+test_sstring_LDADD = \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+## Makefile.Misc_Test_Trace.am
+noinst_PROGRAMS += test_trace
+
+test_trace_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR)
+
+test_trace_SOURCES = \
+ test_trace.cpp \
+ test_dump.h
+
+test_trace_LDADD = \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+## Makefile.Misc_Test_XtReactor1.am
+
+if BUILD_ACE_XTREACTOR
+if BUILD_MOTIF
+if BUILD_X11
+if BUILD_XT
+
+noinst_PROGRAMS += test_XtReactor1
+
+test_XtReactor1_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ $(ACE_X11_CPPFLAGS) \
+ $(ACE_XT_CPPFLAGS)
+
+test_XtReactor1_SOURCES = \
+ test_XtReactor1.cpp \
+ test_dump.h
+
+test_XtReactor1_LDFLAGS = \
+ $(ACE_X11_LDFLAGS) $(ACE_XT_LDFLAGS)
+
+test_XtReactor1_LDADD = \
+ $(ACE_BUILDDIR)/ace/libACE_XtReactor.la \
+ $(ACE_BUILDDIR)/ace/libACE.la \
+ -lXm \
+ $(ACE_XT_LIBS) \
+ $(ACE_X11_LIBS)
+
+endif BUILD_XT
+endif BUILD_X11
+endif BUILD_MOTIF
+endif BUILD_ACE_XTREACTOR
+
+## Makefile.Misc_Test_XtReactor2.am
+
+if BUILD_ACE_XTREACTOR
+if BUILD_MOTIF
+if BUILD_X11
+if BUILD_XT
+
+noinst_PROGRAMS += test_XtReactor2
+
+test_XtReactor2_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ $(ACE_X11_CPPFLAGS) \
+ $(ACE_XT_CPPFLAGS)
+
+test_XtReactor2_SOURCES = \
+ test_XtReactor2.cpp \
+ test_dump.h
+
+test_XtReactor2_LDFLAGS = \
+ $(ACE_X11_LDFLAGS) $(ACE_XT_LDFLAGS)
+
+test_XtReactor2_LDADD = \
+ $(ACE_BUILDDIR)/ace/libACE_XtReactor.la \
+ $(ACE_BUILDDIR)/ace/libACE.la \
+ -lXm \
+ $(ACE_XT_LIBS) \
+ $(ACE_X11_LIBS)
+
+endif BUILD_XT
+endif BUILD_X11
+endif BUILD_MOTIF
+endif BUILD_ACE_XTREACTOR
+
+## Clean up template repositories, etc.
+clean-local:
+ -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.*
+ -rm -f gcctemp.c gcctemp so_locations *.ics
+ -rm -rf cxx_repository ptrepository ti_files
+ -rm -rf templateregistry ir.out
+ -rm -rf ptrepository SunWS_cache Templates.DB
diff --git a/ACE/examples/Misc/Misc.mpc b/ACE/examples/Misc/Misc.mpc
new file mode 100644
index 00000000000..b0ed858efbd
--- /dev/null
+++ b/ACE/examples/Misc/Misc.mpc
@@ -0,0 +1,66 @@
+// -*- MPC -*-
+// $Id$
+
+project(*test_dump) : aceexe {
+ exename = test_dump
+ Source_Files {
+ test_dump.cpp
+ }
+}
+
+project(*test_get_opt) : aceexe {
+ exename = test_get_opt
+ Source_Files {
+ test_get_opt.cpp
+ }
+}
+
+project(*test_profile_timer) : aceexe {
+ avoids += ace_for_tao
+ exename = test_profile_timer
+ Source_Files {
+ test_profile_timer.cpp
+ }
+}
+
+project(*test_read_buffer) : aceexe {
+ exename = test_read_buffer
+ Source_Files {
+ test_read_buffer.cpp
+ }
+}
+
+project(*test_set) : aceexe {
+ exename = test_set
+ Source_Files {
+ test_set.cpp
+ }
+}
+
+project(*test_sstring) : aceexe {
+ exename = test_sstring
+ Source_Files {
+ test_sstring.cpp
+ }
+}
+
+project(*test_trace) : aceexe {
+ exename = test_trace
+ Source_Files {
+ test_trace.cpp
+ }
+}
+
+project(*test_XtReactor1) : aceexe, ace_xtreactor, ace_motif {
+ exename = test_XtReactor1
+ Source_Files {
+ test_XtReactor1.cpp
+ }
+}
+
+project(*test_XtReactor2) : aceexe, ace_xtreactor, ace_motif {
+ exename = test_XtReactor2
+ Source_Files {
+ test_XtReactor2.cpp
+ }
+}
diff --git a/ACE/examples/Misc/test_XtReactor1.cpp b/ACE/examples/Misc/test_XtReactor1.cpp
new file mode 100644
index 00000000000..f4bef54aeae
--- /dev/null
+++ b/ACE/examples/Misc/test_XtReactor1.cpp
@@ -0,0 +1,173 @@
+// $Id$
+
+// The following is another test that exercises the Eric C. Newton's
+// <ecn@clark.net> XtReactor implementation.
+
+#include "ace/OS_main.h"
+#include "ace/XtReactor.h"
+#include "ace/Reactor.h"
+#include "ace/Message_Block.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_fcntl.h"
+
+ACE_RCSID (Misc,
+ test_XtReactor1,
+ "$Id$")
+
+//#define String XtString
+#include <Xm/PushB.h>
+
+class Stdout : public ACE_Event_Handler
+{
+public:
+ Stdout (ACE_Reactor * r)
+ : reactor_ (r),
+ msg_ (1000000) // Make a very big message block.
+ {
+ int flags = ACE_OS::fcntl (ACE_STDOUT, F_GETFL);
+
+ if (flags != -1
+ && ACE_OS::fcntl (ACE_STDOUT,
+ F_SETFL, flags | O_NONBLOCK) != -1)
+ return;
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ "Unable to set stdout to non-block."));
+ }
+
+ ACE_HANDLE get_handle (void) const { return ACE_STDOUT; }
+
+ int handle_output (ACE_HANDLE)
+ {
+ char *s = msg_.rd_ptr ();
+
+ if (ACE_OS::write (ACE_STDOUT, s, 1) == 1)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "wrote output '%d'\n",
+ (int) *s));
+ msg_.rd_ptr (1);
+ }
+
+ if (msg_.length () == 0)
+ {
+ reactor_->remove_handler (this,
+ ACE_Event_Handler::WRITE_MASK);
+ msg_.rd_ptr (msg_.base ());
+ msg_.wr_ptr (msg_.base ());
+ }
+ return 0;
+ }
+
+ void put (char c)
+ {
+ if (msg_.length () == 0)
+ reactor_->register_handler (this,
+ ACE_Event_Handler::WRITE_MASK);
+
+ if (msg_.wr_ptr () < msg_.end ())
+ {
+ *msg_.wr_ptr () = c;
+ msg_.wr_ptr (1);
+ }
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ "Oops... data falling off the end of the buffer!\n"));
+ }
+
+private:
+ ACE_Reactor *reactor_;
+ ACE_Message_Block msg_;
+};
+
+class Stdin : public ACE_Event_Handler
+{
+public:
+ Stdin (Stdout *out)
+ : out_ (out) {}
+
+ ACE_HANDLE get_handle () const { return ACE_STDIN; }
+
+ int handle_input (ACE_HANDLE)
+ {
+ char c;
+
+ if (ACE_OS::read (ACE_STDIN, &c, 1) == 1)
+ out_->put (c);
+
+ return 0;
+ }
+
+ int handle_timeout (const ACE_Time_Value &tv, const void *)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Timeout! %f\n",
+ (double) (tv.msec () / 1000.)));
+ return 0;
+ }
+
+private:
+ Stdout *out_;
+};
+
+static void
+ActivateCB (Widget, XtPointer, XtPointer)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "Button pushed!\n"));
+}
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR**argv)
+{
+ // The worlds most useless user interface
+ Widget top_level = XtVaAppInitialize (NULL,
+ "buttontest",
+ NULL,
+ 0,
+ &argc,
+ argv,
+ NULL,
+ NULL);
+ char change[] = "change"; // XmCreatePushButton() wants a non-const
+ // string.
+ Widget button = XmCreatePushButton (top_level,
+ change,
+ 0,
+ 0);
+ XtManageChild (button);
+ XtAddCallback (button,
+ XmNactivateCallback,
+ ActivateCB,
+ NULL);
+
+ // A reactor beastie.
+ ACE_XtReactor xreactor (XtWidgetToApplicationContext (top_level));
+ ACE_Reactor reactor (&xreactor);
+
+ // Print a message when data is recv'd on stdin...
+ ACE_Event_Handler *stdin_;
+ ACE_NEW_RETURN (stdin_,
+ Stdin (new Stdout (&reactor)),
+ -1);
+ reactor.register_handler (stdin_,
+ ACE_Event_Handler::READ_MASK);
+
+ // Print a message every 10 seconds.
+ if (reactor.schedule_timer (stdin_, 0,
+ ACE_Time_Value (10),
+ ACE_Time_Value (10)) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "schedule_timer"),
+ -1);
+
+ // Show the top_level widget.
+ XtRealizeWidget (top_level);
+
+ // Demonstrate Reactor/Xt event loop unification.
+ XtAppMainLoop (XtWidgetToApplicationContext (top_level));
+
+ return 0;
+}
diff --git a/ACE/examples/Misc/test_XtReactor2.cpp b/ACE/examples/Misc/test_XtReactor2.cpp
new file mode 100644
index 00000000000..2e2f4be0ba2
--- /dev/null
+++ b/ACE/examples/Misc/test_XtReactor2.cpp
@@ -0,0 +1,101 @@
+// $Id$
+
+// The following test exercises the Eric C. Newton's <ecn@clark.net>
+// XtReactor implementation.
+
+#include "ace/OS_main.h"
+#include "ace/XtReactor.h"
+#include "ace/Reactor.h"
+#include "ace/Message_Block.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_unistd.h"
+
+ACE_RCSID (Misc,
+ test_XtReactor2,
+ "$Id$")
+
+
+#include <Xm/PushB.h>
+
+class Stdin : public ACE_Event_Handler
+{
+public:
+ ACE_HANDLE get_handle (void) const { return ACE_STDIN; }
+
+ int handle_input (ACE_HANDLE)
+ {
+ char c;
+ if (ACE_OS::read (ACE_STDIN, &c, 1)==1)
+ ACE_DEBUG ((LM_DEBUG,
+ "Got input '%d'\n",
+ (int) c));
+ return 0;
+ }
+
+ int handle_timeout (const ACE_Time_Value &tv,
+ const void *)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Timeout! %f\n",
+ (double) (tv.msec ()/1000.)));
+ return 0;
+ }
+};
+
+static void
+ActivateCB (Widget, XtPointer, XtPointer)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "Button pushed!\n"));
+}
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR**argv)
+{
+ // The worlds most useless user interface
+ Widget top_level = XtVaAppInitialize (NULL,
+ "buttontest",
+ NULL,
+ 0,
+ &argc,
+ argv,
+ NULL,
+ NULL);
+ char change[] = "change"; // XmCreatePushButton() wants a non-const
+ // string.
+ Widget button = XmCreatePushButton (top_level,
+ change,
+ 0,
+ 0);
+ XtManageChild (button);
+ XtAddCallback (button,
+ XmNactivateCallback,
+ ActivateCB,
+ NULL);
+
+ // A reactor beastie.
+ ACE_XtReactor xreactor (XtWidgetToApplicationContext (top_level));
+ ACE_Reactor reactor (&xreactor);
+
+ // Print a message when data is recv'd on stdin...
+ ACE_Event_Handler * stdin_;
+ ACE_NEW_RETURN (stdin_,
+ Stdin,
+ -1);
+ reactor.register_handler (stdin_,
+ ACE_Event_Handler::READ_MASK);
+
+ // Print a message every 10 seconds
+ if (reactor.schedule_timer (stdin_, 0,
+ ACE_Time_Value (10),
+ ACE_Time_Value (10)) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "schedule_timer"), -1);
+
+ // Show the top_level widget
+ XtRealizeWidget (top_level);
+
+ // Demonstrate Reactor/Xt event loop unification:
+ XtAppMainLoop (XtWidgetToApplicationContext (top_level));
+}
diff --git a/ACE/examples/Misc/test_dump.cpp b/ACE/examples/Misc/test_dump.cpp
new file mode 100644
index 00000000000..bbffe66a2bf
--- /dev/null
+++ b/ACE/examples/Misc/test_dump.cpp
@@ -0,0 +1,33 @@
+// $Id$
+
+// The following code illustrates how the ACE_Dumpable mechanisms are
+// integrated into ACE components like the SOCK_Acceptor and
+// SOCK_Stream.
+
+#include "ace/OS_main.h"
+#include "ace/Dump.h"
+#include "test_dump.h"
+
+#include "ace/Reactor.h"
+
+ACE_RCSID(Misc, test_dump, "$Id$")
+
+int
+ACE_TMAIN (int, ACE_TCHAR *[])
+{
+ SOCK outer_sock;
+ // Note that the SOCK superclass is *not* printed.
+ SOCK_Stream outer_stream;
+ SOCK_Acceptor outer_acceptor;
+ ACE_ODB::instance ()->dump_objects ();
+ {
+ SOCK inner_sock;
+ // Note that the SOCK superclass is *not* printed.
+ SOCK_Stream inner_stream;
+ SOCK_Acceptor inner_acceptor;
+ ACE_ODB::instance ()->dump_objects ();
+ }
+ ACE_ODB::instance ()->dump_objects ();
+ return 0;
+}
+
diff --git a/ACE/examples/Misc/test_dump.h b/ACE/examples/Misc/test_dump.h
new file mode 100644
index 00000000000..9c7e0bb7de8
--- /dev/null
+++ b/ACE/examples/Misc/test_dump.h
@@ -0,0 +1,50 @@
+// $Id$
+
+// Define the classes used with templates in test_dump.cpp
+
+#ifndef __TEST_DUMP_H
+#define __TEST_DUMP_H
+
+#include "ace/Dump.h"
+#include "ace/OS_NS_stdio.h"
+
+class SOCK
+{
+public:
+ SOCK (void) { ACE_REGISTER_OBJECT (SOCK); }
+ ~SOCK (void) { ACE_REMOVE_OBJECT; }
+
+ void dump (void) const {
+ ACE_OS::fprintf (stderr, "hello from SOCK = %lu\n", (u_long) this);
+ }
+
+ // ...
+};
+
+class SOCK_Acceptor : public SOCK
+{
+public:
+ SOCK_Acceptor (void) { ACE_REGISTER_OBJECT (SOCK_Acceptor); }
+ ~SOCK_Acceptor (void) { ACE_REMOVE_OBJECT; }
+
+ void dump (void) const {
+ ACE_OS::fprintf (stderr, "hello from SOCK_Acceptor = %lu\n", (u_long) this);
+ }
+
+ // ...
+};
+
+class SOCK_Stream : public SOCK
+{
+public:
+ SOCK_Stream (void) { ACE_REGISTER_OBJECT (SOCK_Stream); }
+ ~SOCK_Stream (void) { ACE_REMOVE_OBJECT; }
+
+ void dump (void) const {
+ ACE_OS::fprintf (stderr, "hello from SOCK_Stream = %lu\n", (u_long) this);
+ }
+
+ // ...
+};
+
+#endif /* __TEST_DUMP_H */
diff --git a/ACE/examples/Misc/test_get_opt.cpp b/ACE/examples/Misc/test_get_opt.cpp
new file mode 100644
index 00000000000..3fd0a16ac80
--- /dev/null
+++ b/ACE/examples/Misc/test_get_opt.cpp
@@ -0,0 +1,54 @@
+// $Id$
+
+// Test the ACE_Get_Opt class.
+
+#include "ace/OS_main.h"
+#include "ace/Get_Opt.h"
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(Misc, test_get_opt, "$Id$")
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("ab:cd:ef:gh:"));
+ int c;
+
+ while ((c = get_opt ()) != EOF)
+ switch (c)
+ {
+ case 'a':
+ ACE_DEBUG ((LM_DEBUG, "got a\n"));
+ break;
+ case 'b':
+ ACE_DEBUG ((LM_DEBUG, "got b with arg %s\n", get_opt.opt_arg ()));
+ break;
+ case 'c':
+ ACE_DEBUG ((LM_DEBUG, "got c\n"));
+ break;
+ case 'd':
+ ACE_DEBUG ((LM_DEBUG, "got d with arg %s\n", get_opt.opt_arg ()));
+ break;
+ case 'e':
+ ACE_DEBUG ((LM_DEBUG, "got e\n"));
+ break;
+ case 'f':
+ ACE_DEBUG ((LM_DEBUG, "got f with arg %s\n", get_opt.opt_arg ()));
+ break;
+ case 'g':
+ ACE_DEBUG ((LM_DEBUG, "got g\n"));
+ break;
+ case 'h':
+ ACE_DEBUG ((LM_DEBUG, "got h with arg %s\n", get_opt.opt_arg ()));
+ break;
+ default:
+ ACE_DEBUG ((LM_DEBUG, "got %c, which is unrecognized!\n", c));
+ break;
+ }
+
+ for (int i = get_opt.opt_ind (); i < argc; i++)
+ ACE_DEBUG ((LM_DEBUG, "optind = %d, argv[optind] = %s\n",
+ i, argv[i]));
+
+ return 0;
+}
diff --git a/ACE/examples/Misc/test_profile_timer.cpp b/ACE/examples/Misc/test_profile_timer.cpp
new file mode 100644
index 00000000000..adb6f599f83
--- /dev/null
+++ b/ACE/examples/Misc/test_profile_timer.cpp
@@ -0,0 +1,38 @@
+// $Id$
+
+#include "ace/OS_main.h"
+#include "ace/Profile_Timer.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_stdlib.h"
+#include "ace/OS_NS_unistd.h"
+
+ACE_RCSID(Misc, test_profile_timer, "$Id$")
+
+static const int DEFAULT_ITERATIONS = 100000000;
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Profile_Timer timer;
+ int iterations = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_ITERATIONS;
+
+ timer.start ();
+
+ for (int i = 0; i < iterations; i++)
+ ACE_OS::getpid ();
+
+ timer.stop ();
+
+ ACE_Profile_Timer::ACE_Elapsed_Time et;
+
+ timer.elapsed_time (et);
+
+ ACE_DEBUG ((LM_DEBUG, "iterations = %d\n", iterations));
+ ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n",
+ et.real_time, et.user_time, et.system_time));
+
+ ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n",
+ (et.real_time / double (iterations)) * 1000000));
+ return 0;
+}
+
diff --git a/ACE/examples/Misc/test_read_buffer.cpp b/ACE/examples/Misc/test_read_buffer.cpp
new file mode 100644
index 00000000000..1c24aec98b7
--- /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;
+
+ while ((buf = rb.read (term, search, replace)) != 0)
+ {
+ ACE_OS::write (ACE_STDOUT, buf, rb.size ());
+ ACE_Allocator::instance ()->free (buf);
+ }
+ return 0;
+}
diff --git a/ACE/examples/Misc/test_set.cpp b/ACE/examples/Misc/test_set.cpp
new file mode 100644
index 00000000000..4b60d3b4b11
--- /dev/null
+++ b/ACE/examples/Misc/test_set.cpp
@@ -0,0 +1,57 @@
+// $Id$
+
+#include "ace/OS_main.h"
+#include "ace/Containers.h"
+#include "ace/Log_Msg.h"
+
+int
+ACE_TMAIN (int, ACE_TCHAR *[])
+{
+ ACE_Unbounded_Set<int> s1;
+
+ ACE_ASSERT (s1.size () == 0);
+ s1.insert_tail (10);
+ s1.insert_tail (20);
+ ACE_ASSERT (s1.size () == 2);
+
+ ACE_Unbounded_Set<int> s2 (s1);
+ ACE_ASSERT (s2.size () == 2);
+
+ ACE_Unbounded_Set<int> s3;
+ ACE_ASSERT (s3.size () == 0);
+
+ s3 = s2;
+ ACE_ASSERT (s3.size () == s2.size ());
+
+ ACE_Unbounded_Set<int> s4 (s3);
+ ACE_ASSERT (s4.size () == 2);
+
+ int *ip = 0;
+
+ ACE_DEBUG ((LM_DEBUG, "dumping s1\n"));
+ for (ACE_Unbounded_Set_Iterator<int> iter1 (s1);
+ iter1.next (ip) != 0;
+ iter1.advance ())
+ ACE_DEBUG ((LM_DEBUG, "item = %d\n", *ip));
+
+ ACE_DEBUG ((LM_DEBUG, "dumping s2\n"));
+ for (ACE_Unbounded_Set_Iterator<int> iter2 (s2);
+ iter2.next (ip) != 0;
+ iter2.advance ())
+ ACE_DEBUG ((LM_DEBUG, "item = %d\n", *ip));
+
+ ACE_DEBUG ((LM_DEBUG, "dumping s3\n"));
+ for (ACE_Unbounded_Set_Iterator<int> iter3 (s3);
+ iter3.next (ip) != 0;
+ iter3.advance ())
+ ACE_DEBUG ((LM_DEBUG, "item = %d\n", *ip));
+
+ ACE_DEBUG ((LM_DEBUG, "dumping s4\n"));
+ for (ACE_Unbounded_Set_Iterator<int> iter4 (s4);
+ iter4.next (ip) != 0;
+ iter4.advance ())
+ ACE_DEBUG ((LM_DEBUG, "item = %d\n", *ip));
+
+ return 0;
+}
+
diff --git a/ACE/examples/Misc/test_sstring.cpp b/ACE/examples/Misc/test_sstring.cpp
new file mode 100644
index 00000000000..75cfe8e1158
--- /dev/null
+++ b/ACE/examples/Misc/test_sstring.cpp
@@ -0,0 +1,26 @@
+// $Id$
+
+#include "ace/OS_main.h"
+#include "ace/SString.h"
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(Misc, test_sstring, "$Id$")
+
+int
+ACE_TMAIN (int, ACE_TCHAR *[])
+{
+ ACE_CString s1 ("hello");
+ ACE_CString s2 ("world");
+ ACE_CString s3 ("el");
+ ACE_NS_WString s4 ("hello");
+ ACE_NS_WString s5 ("world");
+ ACE_NS_WString s6 ("el");
+
+ ACE_ASSERT (s1 != s2);
+ ACE_ASSERT (s1.strstr (s2) == ACE_CString::npos);
+ ACE_ASSERT (s1.strstr (s2) == ACE_CString::npos);
+ ACE_ASSERT (s1.strstr (s3));
+ ACE_ASSERT (s4.strstr (s5) == ACE_NS_WString::npos);
+ ACE_ASSERT (s5.strstr (s6));
+ return 0;
+}
diff --git a/ACE/examples/Misc/test_trace.cpp b/ACE/examples/Misc/test_trace.cpp
new file mode 100644
index 00000000000..c400d94ec7f
--- /dev/null
+++ b/ACE/examples/Misc/test_trace.cpp
@@ -0,0 +1,114 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// examples/Misc
+//
+// = FILENAME
+// test_trace.cpp
+//
+// = DESCRIPTION
+// This example illustrates how to use the ACE tracing feature and
+// the ACE_TRACE macro. It also shows the use of the ACE_Task_Base
+// class running as an "active object".
+//
+// = AUTHOR
+// Douglas C. Schmidt <schmidt@cs.wustl.edu> and
+// Irfan Pyarali <irfan@cs.wustl.edu>
+//
+// ============================================================================
+
+// Enable tracing
+#define ACE_NTRACE 0
+
+#include "ace/OS_main.h"
+#include "ace/Signal.h"
+#include "ace/Task.h"
+
+ACE_RCSID(Misc, test_trace, "$Id$")
+
+class My_Task : public ACE_Task_Base
+{
+public:
+ My_Task (size_t depth)
+ : depth_ (depth)
+ {
+ }
+
+ int recursive (size_t depth);
+
+ virtual int svc (void)
+ {
+ return this->recursive (this->depth_);
+ }
+
+private:
+ size_t depth_;
+ // Depth of the recursion.
+};
+
+int
+My_Task::recursive (size_t depth)
+{
+ ACE_TRACE ("My_Task::recursive");
+
+ if (depth > 0)
+ return recursive (depth - 1);
+ else
+ return 0;
+ // Destructor of <ACE_Trace> automatically called.
+}
+
+extern "C"
+void
+exithook (void)
+{
+ ACE_TRACE ("void exithook (void)");
+
+ ACE_DEBUG ((LM_DEBUG,
+ "we're outta here!\n"));
+}
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ const size_t MAX_DEPTH = argc == 1 ? 10 : ACE_OS::atoi (argv[1]);
+
+ ACE_OS::atexit (exithook);
+
+ if (argc > 2)
+ ACE_Trace::set_nesting_indent (ACE_OS::atoi (argv[2]));
+
+ ACE_TRACE ("int ACE_TMAIN (int argc, ACE_TCHAR *argv[])");
+
+ ACE_Sig_Action sig1 ((ACE_SignalHandler) ACE_Trace::start_tracing,
+ SIGUSR1);
+ ACE_UNUSED_ARG (sig1);
+ ACE_Sig_Action sig2 ((ACE_SignalHandler) ACE_Trace::stop_tracing,
+ SIGUSR2);
+ ACE_UNUSED_ARG (sig2);
+
+ My_Task task (MAX_DEPTH);
+
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ int n_threads = argc > 3 ? ACE_OS::atoi (argv[3]) : 4;
+
+ if (task.activate (THR_BOUND | THR_DETACHED, n_threads) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "activate"),
+ -1);
+
+ // Wait for all the threads to exit.
+ ACE_Thread_Manager::instance ()->wait ();
+#else
+ const int MAX_ITERATIONS = argc > 3 ? ACE_OS::atoi (argv[3]) : 10;
+
+ for (int i = 0; i < MAX_ITERATIONS; i++)
+ task.svc ();
+#endif /* ACE_MT_SAFE */
+
+ // Destructor automatically called.
+ return 0;
+}