summaryrefslogtreecommitdiff
path: root/ACE/apps/Gateway/Peer/peerd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/apps/Gateway/Peer/peerd.cpp')
-rw-r--r--ACE/apps/Gateway/Peer/peerd.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/ACE/apps/Gateway/Peer/peerd.cpp b/ACE/apps/Gateway/Peer/peerd.cpp
new file mode 100644
index 00000000000..2b07f299b70
--- /dev/null
+++ b/ACE/apps/Gateway/Peer/peerd.cpp
@@ -0,0 +1,61 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// gateway
+//
+// = FILENAME
+// peerd.h
+//
+// = DESCRIPTION
+// Driver for the peer daemon (peerd). Note that this is
+// completely generic code due to the Service Configurator
+// framework!
+//
+// = AUTHOR
+// Douglas C. Schmidt
+//
+// ============================================================================
+
+#include "ace/OS_NS_unistd.h"
+#include "Peer.h"
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ if (ACE_OS::access (ACE_DEFAULT_SVC_CONF, F_OK) != 0)
+ {
+ // Use static linking.
+ ACE_Service_Object_Ptr sp = ACE_SVC_INVOKE (Peer_Factory);
+
+ if (sp->init (argc - 1, argv + 1) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("init")),
+ 1);
+
+ // Run forever, performing the configured services until we are
+ // shut down by a SIGINT/SIGQUIT signal.
+
+ ACE_Reactor::instance ()->run_reactor_event_loop ();
+
+ // Destructor of <ACE_Service_Object_Ptr> automagically call
+ // <fini>.
+ }
+ else
+ {
+ if (ACE_Service_Config::open (argc, argv) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("open")),
+ 1);
+ else // Use dynamic linking.
+
+ // Run forever, performing the configured services until we
+ // are shut down by a signal (e.g., SIGINT or SIGQUIT).
+
+ ACE_Reactor::instance ()->run_reactor_event_loop ();
+ }
+ return 0;
+}