summaryrefslogtreecommitdiff
path: root/ACE/examples/Misc
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
parentc4078c377d74290ebe4e66da0b4975da91732376 (diff)
downloadATCD-99aa8c60282c7b8072eb35eb9ac815702f5bf586.tar.gz
undoing accidental deletion
Diffstat (limited to 'ACE/examples/Misc')
-rw-r--r--ACE/examples/Misc/Makefile.am213
-rw-r--r--ACE/examples/Misc/Misc.mpc73
-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_timestamp.cpp21
-rw-r--r--ACE/examples/Misc/test_trace.cpp131
13 files changed, 1004 insertions, 0 deletions
diff --git a/ACE/examples/Misc/Makefile.am b/ACE/examples/Misc/Makefile.am
new file mode 100644
index 00000000000..f1b726742c1
--- /dev/null
+++ b/ACE/examples/Misc/Makefile.am
@@ -0,0 +1,213 @@
+## 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:
+## ./bin/mwc.pl -type automake -noreldefs ACE.mwc
+
+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_Timestamp.am
+
+noinst_PROGRAMS += test_timestamp
+
+test_timestamp_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR)
+
+test_timestamp_SOURCES = \
+ test_timestamp.cpp \
+ test_dump.h
+
+test_timestamp_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..84be1f4d1e6
--- /dev/null
+++ b/ACE/examples/Misc/Misc.mpc
@@ -0,0 +1,73 @@
+// -*- 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_timestamp) : aceexe {
+ exename = test_timestamp
+ Source_Files {
+ test_timestamp.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..6e1732c1ee0
--- /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/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 (0,
+ "buttontest",
+ 0,
+ 0,
+ &argc,
+ argv,
+ 0,
+ 0);
+ char change[] = "change"; // XmCreatePushButton() wants a non-const
+ // string.
+ Widget button = XmCreatePushButton (top_level,
+ change,
+ 0,
+ 0);
+ XtManageChild (button);
+ XtAddCallback (button,
+ XmNactivateCallback,
+ ActivateCB,
+ 0);
+
+ // 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..88b53e04869
--- /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/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 (0,
+ "buttontest",
+ 0,
+ 0,
+ &argc,
+ argv,
+ 0,
+ 0);
+ char change[] = "change"; // XmCreatePushButton() wants a non-const
+ // string.
+ Widget button = XmCreatePushButton (top_level,
+ change,
+ 0,
+ 0);
+ XtManageChild (button);
+ XtAddCallback (button,
+ XmNactivateCallback,
+ ActivateCB,
+ 0);
+
+ // 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..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;
+}
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_timestamp.cpp b/ACE/examples/Misc/test_timestamp.cpp
new file mode 100644
index 00000000000..e61ddace9b3
--- /dev/null
+++ b/ACE/examples/Misc/test_timestamp.cpp
@@ -0,0 +1,21 @@
+// $Id$
+
+// Test the ACE::timestamp method.
+
+#include "ace/OS_main.h"
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+
+ACE_RCSID(Misc, test_timestamp, "$Id$")
+
+int
+ACE_TMAIN (int, ACE_TCHAR *[])
+{
+ ACE_TCHAR day_and_time[35];
+ ACE::timestamp (day_and_time,
+ sizeof day_and_time);
+
+ ACE_DEBUG ((LM_DEBUG, "%s", day_and_time));
+
+ return 0;
+}
diff --git a/ACE/examples/Misc/test_trace.cpp b/ACE/examples/Misc/test_trace.cpp
new file mode 100644
index 00000000000..b2d3167d290
--- /dev/null
+++ b/ACE/examples/Misc/test_trace.cpp
@@ -0,0 +1,131 @@
+// $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".
+//
+// When adding ACE tracing to an application one option is to add
+//
+// #define ACE_NTRACE 0
+//
+// in the line above #include "ace/Log_Msg.h". That's the approach shown below.
+//
+// Another option is to add this line in $ACE_ROOT/ace/config.h.
+// Note, however, that if you add the line in config.h, you need to
+// add it *after* you've built ACE, i.e., don't build ACE with it
+// set to 0 as then you will get all the internal ACE_TRACE calls
+// showing up as well! In a nutshell, in this second option you
+// do this:
+//
+// 1. Build ACE without tracing (i.e., don't #define ACE_NTRACE 0 in config.h)
+// 2. Add #define ACE_NTRACE 0 in config.h
+// 3. Build your app with tracing.
+//
+// = 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;
+}