summaryrefslogtreecommitdiff
path: root/ACEXML
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-05-08 21:54:10 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-05-08 21:54:10 +0000
commit0ecf5205b86fec6836445d8df3272cc613b83ea9 (patch)
tree010302338ac8df945f024f8f90d1d9d7cd2b2356 /ACEXML
parente7eaa5dec5d01f5094ff207feea5ebb0d224b1c6 (diff)
downloadATCD-0ecf5205b86fec6836445d8df3272cc613b83ea9.tar.gz
ChangeLogTag:Wed May 8 15:15:41 2002 Nanbor Wang <nanbor@cs.wustl.edu>
Diffstat (limited to 'ACEXML')
-rw-r--r--ACEXML/Makefile1
-rw-r--r--ACEXML/Makefile.bor3
-rw-r--r--ACEXML/apps/Makefile17
-rw-r--r--ACEXML/apps/Makefile.bor8
-rw-r--r--ACEXML/apps/XML_Apps.dsw29
-rw-r--r--ACEXML/apps/svcconf/Makefile40
-rw-r--r--ACEXML/apps/svcconf/Makefile.bor20
-rw-r--r--ACEXML/apps/svcconf/README4
-rw-r--r--ACEXML/apps/svcconf/Svcconf.cpp95
-rw-r--r--ACEXML/apps/svcconf/Svcconf.h46
-rw-r--r--ACEXML/apps/svcconf/Svcconf_Handler.cpp671
-rw-r--r--ACEXML/apps/svcconf/Svcconf_Handler.h305
-rw-r--r--ACEXML/apps/svcconf/Svcconf_Handler.i133
-rw-r--r--ACEXML/apps/svcconf/XML_Svc_Conf_Parser.dsp119
-rw-r--r--ACEXML/common/Makefile1
-rw-r--r--ACEXML/common/Makefile.bor1
-rw-r--r--ACEXML/common/StrCharStream.cpp97
-rw-r--r--ACEXML/common/StrCharStream.h76
-rw-r--r--ACEXML/common/XML_Common.dsp12
-rw-r--r--ACEXML/examples/SAXPrint/main.cpp82
-rw-r--r--ACEXML/examples/SAXPrint/svc.conf.xml14
-rw-r--r--ACEXML/examples/svcconf/README3
-rw-r--r--ACEXML/examples/svcconf/Svcconf.dsp110
-rw-r--r--ACEXML/examples/svcconf/Svcconf.dsw29
-rw-r--r--ACEXML/examples/svcconf/Svcconf_Handler.cpp495
-rw-r--r--ACEXML/examples/svcconf/Svcconf_Handler.h305
-rw-r--r--ACEXML/examples/svcconf/Svcconf_Handler.i133
-rw-r--r--ACEXML/examples/svcconf/main.cpp71
-rw-r--r--ACEXML/examples/test_docs/svcconf.dtd17
-rw-r--r--ACEXML/parser/parser/Makefile2
-rw-r--r--ACEXML/parser/parser/Parser.cpp12
31 files changed, 2900 insertions, 51 deletions
diff --git a/ACEXML/Makefile b/ACEXML/Makefile
index e355ff86344..ccba2b77d1c 100644
--- a/ACEXML/Makefile
+++ b/ACEXML/Makefile
@@ -6,6 +6,7 @@
DIRS = common \
parser \
+ apps \
tests \
examples
diff --git a/ACEXML/Makefile.bor b/ACEXML/Makefile.bor
index 0e25ede588e..85ed6f2c300 100644
--- a/ACEXML/Makefile.bor
+++ b/ACEXML/Makefile.bor
@@ -4,6 +4,7 @@
DIRS = \
common \
- parser
+ parser \
+ apps
!include <$(ACE_ROOT)\include\makeinclude\recurse.bor>
diff --git a/ACEXML/apps/Makefile b/ACEXML/apps/Makefile
new file mode 100644
index 00000000000..a5f05b99ae5
--- /dev/null
+++ b/ACEXML/apps/Makefile
@@ -0,0 +1,17 @@
+#----------------------------------------------------------------------------
+# $Id$
+#
+# Makefile for the client programs that test the ACE network services
+#----------------------------------------------------------------------------
+
+DIRS = svcconf
+
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
+
+include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
+include $(ACE_ROOT)/include/makeinclude/macros.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.common.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.nested.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.nolocal.GNU
diff --git a/ACEXML/apps/Makefile.bor b/ACEXML/apps/Makefile.bor
new file mode 100644
index 00000000000..1da5c84407c
--- /dev/null
+++ b/ACEXML/apps/Makefile.bor
@@ -0,0 +1,8 @@
+#
+# Makefile for building the ACE XML Library
+#
+
+DIRS = \
+ svcconf
+
+!include <$(ACE_ROOT)\include\makeinclude\recurse.bor>
diff --git a/ACEXML/apps/XML_Apps.dsw b/ACEXML/apps/XML_Apps.dsw
new file mode 100644
index 00000000000..0ed29a77e72
--- /dev/null
+++ b/ACEXML/apps/XML_Apps.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "XML_Svc_Conf_Parser"=.\svcconf\XML_Svc_Conf_Parser.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/ACEXML/apps/svcconf/Makefile b/ACEXML/apps/svcconf/Makefile
new file mode 100644
index 00000000000..fced65f587e
--- /dev/null
+++ b/ACEXML/apps/svcconf/Makefile
@@ -0,0 +1,40 @@
+#----------------------------------------------------------------------------
+# $Id$
+#
+# Makefile for the server-side ACE network services
+#----------------------------------------------------------------------------
+
+LIB = libACEXML_XML_Svc_Conf_Parser.a
+SHLIB = libACEXML_XML_Svc_Conf_Parser.$(SOEXT)
+
+FILES = Svcconf_Handler \
+ Svcconf
+
+DEFS = $(addsuffix .h,$(FILES))
+LSRC = $(addsuffix .cpp,$(FILES))
+
+LIBS += -lACEXML_Parser -lACEXML $(ACELIB)
+CCFLAGS += -I../..
+
+BUILD = $(VLIB) $(VSHLIB)
+
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
+
+include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
+include $(ACE_ROOT)/include/makeinclude/macros.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.common.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
+
+#----------------------------------------------------------------------------
+# Local targets
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Dependencies
+#----------------------------------------------------------------------------
+# DO NOT DELETE THIS LINE -- g++dep uses it.
+# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
diff --git a/ACEXML/apps/svcconf/Makefile.bor b/ACEXML/apps/svcconf/Makefile.bor
new file mode 100644
index 00000000000..0f40444b564
--- /dev/null
+++ b/ACEXML/apps/svcconf/Makefile.bor
@@ -0,0 +1,20 @@
+# Makefile for building the parser
+
+NAME = ACEXML_XML_Svc_Conf_Parser
+
+OBJFILES = \
+ $(OBJDIR)\Svcconf.obj \
+ $(OBJDIR)\Svcconf_Handler.obj
+
+CFLAGS = \
+ $(ACE_CFLAGS) \
+ $(ACE_XML_CFLAGS)
+
+CPPDIR = .;..
+
+LIBFILES = \
+ $(ACE_LIB) \
+ $(ACE_XML_LIB)
+# WE need both -lACEXML and -lACEXML_Parser here
+
+!include <$(ACE_ROOT)\include\makeinclude\build_core_library.bor>
diff --git a/ACEXML/apps/svcconf/README b/ACEXML/apps/svcconf/README
new file mode 100644
index 00000000000..8a39a40bfe3
--- /dev/null
+++ b/ACEXML/apps/svcconf/README
@@ -0,0 +1,4 @@
+$Id$
+
+This directory implement a DLL that contains the parser for XML based
+service configurator.
diff --git a/ACEXML/apps/svcconf/Svcconf.cpp b/ACEXML/apps/svcconf/Svcconf.cpp
new file mode 100644
index 00000000000..919b5f39818
--- /dev/null
+++ b/ACEXML/apps/svcconf/Svcconf.cpp
@@ -0,0 +1,95 @@
+// $Id$
+
+
+#include "Svcconf.h"
+#include "common/FileCharStream.h"
+#include "common/StrCharStream.h"
+#include "parser/parser/Parser.h"
+
+extern "C" ACE_Proper_Export_Flag ACE_XML_Svc_Conf *
+_ACEXML_create_XML_Svc_Conf_Object (void)
+{
+ ACE_XML_Svc_Conf *retp = 0;
+
+ ACE_NEW_RETURN (retp,
+ ACEXML_Svcconf_Parser (),
+ 0);
+
+ return retp;
+}
+
+ACEXML_Svcconf_Parser::ACEXML_Svcconf_Parser ()
+{
+ this->parser_.setContentHandler (&this->svcconf_handler_);
+ this->parser_.setDTDHandler (&this->svcconf_handler_);
+ this->parser_.setErrorHandler (&this->svcconf_handler_);
+ this->parser_.setEntityResolver (&this->svcconf_handler_);
+}
+
+ACEXML_Svcconf_Parser::~ACEXML_Svcconf_Parser ()
+{
+
+}
+
+void *
+ACEXML_Svcconf_Parser::operator new (size_t s)
+{
+ return ::new char[s];
+}
+
+void
+ACEXML_Svcconf_Parser::operator delete (void *p)
+{
+ delete[] (char *)p;
+}
+
+int
+ACEXML_Svcconf_Parser::parse_file (const ACE_TCHAR file[])
+{
+ if (file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: No filename specified\n"), -1);
+
+ ACEXML_FileCharStream *fstm = 0;
+ ACE_NEW_RETURN (fstm,
+ ACEXML_FileCharStream (),
+ 1);
+
+ if (fstm->open (file) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACEXML_Svcconf_Parser: Fail to open XML file: %s\n"),
+ file),
+ -1);
+
+ this->input_stream_.setCharStream (fstm);
+
+ this->parser_.parse (&this->input_stream_, this->env_);
+ if (this->env_.exception ())
+ {
+ this->env_.exception ()->print ();
+ return -1;
+ }
+ return 0;
+}
+
+
+int
+ACEXML_Svcconf_Parser::parse_string (const ACE_TCHAR str[])
+{
+ if (str == 0)
+ ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: Can't parse a null string\n"), -1);
+
+ ACEXML_StrCharStream *stm = 0;
+ ACE_NEW_RETURN (stm,
+ ACEXML_StrCharStream (str),
+ -1);
+
+ this->input_stream_.setCharStream (stm);
+
+ this->parser_.parse (&this->input_stream_, this->env_);
+ if (this->env_.exception ())
+ {
+ this->env_.exception ()->print ();
+ return -1;
+ }
+ return 0;
+}
diff --git a/ACEXML/apps/svcconf/Svcconf.h b/ACEXML/apps/svcconf/Svcconf.h
new file mode 100644
index 00000000000..0775658dac5
--- /dev/null
+++ b/ACEXML/apps/svcconf/Svcconf.h
@@ -0,0 +1,46 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ * @file Svcconf.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef ACEXML_SVCCONF_H
+#define ACEXML_SVCCONF_H
+
+#include "ace/pre.h"
+#include "ace/XML_Svc_Conf.h"
+#include "parser/parser/Parser.h"
+#include "Svcconf_Handler.h"
+
+
+class ACEXML_Svcconf_Parser : public ACE_XML_Svc_Conf
+{
+public:
+ ACEXML_Svcconf_Parser ();
+
+ virtual ~ACEXML_Svcconf_Parser ();
+
+ virtual int parse_file (const ACE_TCHAR file[]);
+
+ virtual int parse_string (const ACE_TCHAR str[]);
+
+ void * operator new (size_t bytes);
+
+ void operator delete (void *ptr);
+
+protected:
+ ACEXML_Parser parser_;
+ ACEXML_Svcconf_Handler svcconf_handler_;
+ ACEXML_InputSource input_stream_;
+ ACEXML_Env env_;
+};
+
+#include "ace/post.h"
+#endif /* ACEXML_SVCCONF_H */
diff --git a/ACEXML/apps/svcconf/Svcconf_Handler.cpp b/ACEXML/apps/svcconf/Svcconf_Handler.cpp
new file mode 100644
index 00000000000..87a908f067e
--- /dev/null
+++ b/ACEXML/apps/svcconf/Svcconf_Handler.cpp
@@ -0,0 +1,671 @@
+// -*- C++ -*- $Id$
+
+#include "Svcconf_Handler.h"
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+#include "ace/Service_Config.h"
+#include "ace/Service_Types.h"
+#include "ace/Service_Repository.h"
+#include "ace/DLL.h"
+#include "ace/ARGV.h"
+#include "ace/Module.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "Svcconf_Handler.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_Svcconf_Handler::ACEXML_Svcconf_Handler (void)
+ : in_stream_def_ (0),
+ in_module_ (0),
+ stream_svc_type_ (0),
+ stream_ (0),
+ dll_handle_ (0)
+{
+ // no-op
+}
+
+ACEXML_Svcconf_Handler::~ACEXML_Svcconf_Handler (void)
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::characters (const ACEXML_Char *,
+ int,
+ int,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::endDocument (ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::endElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *qName,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (ACE_OS_String::strcmp (qName, ACE_TEXT ("dynamic")) == 0)
+ {
+ ACE_Parsed_Info *active_info = (this->in_stream_def_ == 0 ?
+ &this->parsed_info_ :
+ &this->stream_info_);
+
+ ACE_DLL svc_dll;
+
+ if (svc_dll.open (active_info->path ()) == -1)
+ {
+ xmlenv.exception (new ACEXML_SAXException ("Cannot locate DLL\n"));
+ return;
+ }
+
+ void *(*func) (ACE_Service_Object_Exterminator *) = 0;
+ ACE_Service_Object_Exterminator gobbler = 0;
+ void *symbol = 0;
+
+ long temp_ptr =
+ ACE_reinterpret_cast(long, svc_dll.symbol (active_info->init_func ()));
+ func = ACE_reinterpret_cast(void *(*)(ACE_Service_Object_Exterminator *),
+ temp_ptr);
+
+ if (func == 0)
+ {
+ xmlenv.exception (new ACEXML_SAXException ("Cannot locator init function\n"));
+ return;
+ }
+ symbol = (*func)(&gobbler); // target object created in the loaded DLL.
+
+ ACE_Service_Type_Impl *stp = ACE_Service_Config::create_service_type_impl
+ (active_info->name (),
+ active_info->service_type (),
+ symbol,
+ ACE_Service_Type::DELETE_THIS |
+ ACE_Service_Type::DELETE_OBJ,
+ gobbler);
+
+ if (this->in_stream_def_)
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Create dynamic %s for stream\n"),
+// this->stream_info_.name ()));
+ if (active_info->service_type () == ACE_Service_Type::STREAM)
+ {
+ this->stream_ = (ACE_Stream_Type *) stp;
+ this->dll_handle_ = svc_dll.get_handle (1);
+ }
+ else
+ {
+ xmlenv.exception (new ACEXML_SAXException
+ ("Expecting Stream type in stream header\n"));
+ return;
+ }
+
+ this->stream_svc_type_ =
+ ACE_Service_Config::create_service_type (this->stream_info_.name (),
+ this->stream_,
+ this->dll_handle_,
+ this->stream_info_.active ());
+
+ }
+ else
+ {
+ if (this->in_module_)
+ {
+ ACE_ARGV args (active_info->init_params ());
+
+ ACE_Module_Type *mt = (ACE_Module_Type *) stp;
+
+ ACE_Module<ACE_SYNCH> *mp = (ACE_Module<ACE_SYNCH> *) mt->object ();
+
+ if (ACE_OS::strcmp (mp->name (), active_info->name ()) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_LIB_TEXT ("warning: assigning Module_Type name %s to Module %s since names differ\n"),
+ active_info->name (),
+ mp->name ()));
+ mp->name (active_info->name ());
+ }
+
+ if (mt->init (args.argc (), args.argv ()) == -1
+ || this->stream_->push (mt) == -1)
+ {
+ xmlenv.exception (new ACEXML_SAXException ("Error initializing module"));
+ }
+
+
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Push dynamic %s into stream %s\n"),
+// this->parsed_info_.name (),
+// this->stream_info_.name ()));
+ }
+ else
+ {
+ ACE_Service_Type *stype =
+ ACE_Service_Config::create_service_type (active_info->name (),
+ stp,
+ svc_dll.get_handle (1),
+ active_info->active ());
+ // @@ Check error here.
+
+ // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply dynamic %s\n"),
+// this->parsed_info_.name ()));
+ if (ACE_Service_Config::initialize (stype,
+ active_info->init_params ()) == -1)
+ {
+ xmlenv.exception (new ACEXML_SAXException
+ ("Fail to initialize dynamic service\n"));
+ return;
+ }
+ }
+ this->parsed_info_.reset ();
+ }
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("static")) == 0)
+ {
+ if (this->in_stream_def_)
+ {
+ // @@ Couldn't make sense out of the original Svc_Conf.y.
+ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Create static %s for stream\n"),
+ this->stream_info_.name ()));
+ }
+ else
+ {
+ if (this->in_module_)
+ {
+ // @@ Couldn't make sense out of the original Svc_Conf.y.
+ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Push static %s into stream %s\n"),
+ this->parsed_info_.name (),
+ this->stream_info_.name ()));
+ }
+ else
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply static %s\n"),
+// this->parsed_info_.name ()));
+ if (ACE_Service_Config::initialize (this->parsed_info_.name (),
+ this->parsed_info_.init_params ()) == -1)
+ {
+ xmlenv.exception (new ACEXML_SAXException
+ (ACE_TEXT ("Fail initializing static service\n")));
+ }
+ }
+ this->parsed_info_.reset ();
+ }
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("module")) == 0)
+ {
+ this->in_module_ = 0;
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("streamdef")) == 0)
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply stream %s of type %s\n"),
+// this->stream_info_.name (),
+// this->stream_info_.name ()));
+ ACE_Service_Config::initialize (this->stream_svc_type_,
+ this->stream_info_.init_params ());
+
+ this->stream_info_.reset ();
+ this->stream_svc_type_ = 0;
+ this->stream_ = 0;
+ this->dll_handle_ = 0;
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("stream")) == 0)
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply stream %s of type %s\n"),
+// this->stream_info_.name (),
+// this->stream_info_.name ()));
+ this->stream_info_.reset ();
+ }
+ else
+ {
+ }
+}
+
+void
+ACEXML_Svcconf_Handler::endPrefixMapping (const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::ignorableWhitespace (const ACEXML_Char *,
+ int,
+ int,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::processingInstruction (const ACEXML_Char *,
+ const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::setDocumentLocator (ACEXML_Locator *,
+ ACEXML_Env &)
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::skippedEntity (const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::startDocument (ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::startElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (ACE_OS_String::strcmp (qName, ACE_TEXT ("dynamic")) == 0)
+ {
+ this->get_dynamic_attrs (alist, xmlenv);
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("initializer")) == 0)
+ {
+ this->get_initializer_attrs (alist, xmlenv);
+
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("static")) == 0)
+ {
+ this->get_static_attrs (alist, xmlenv);
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("stream")) == 0)
+ {
+ this->get_stream_id (alist, xmlenv);
+
+ if (ACE_Service_Repository::instance()->find
+ (this->stream_info_.name (),
+ (const ACE_Service_Type **) &this->stream_svc_type_) == -1)
+ {
+ xmlenv.exception (new ACEXML_SAXException ("Can not find stream\n"));
+ return;
+ }
+ this->stream_ = this->stream_svc_type_ == 0
+ ? 0
+ : ACE_dynamic_cast (ACE_Stream_Type *,
+ ACE_const_cast (ACE_Service_Type_Impl *,
+ this->stream_svc_type_->type ()));
+
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Retrieve stream %s from repository\n"),
+// this->stream_info_.name ()));
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("streamdef")) == 0)
+ {
+ this->in_stream_def_ = 1;
+ // @@ Set up stream service object
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("module")) == 0)
+ {
+ this->in_stream_def_ = 0;
+ this->in_module_ = 1;
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("resume")) == 0)
+ {
+ this->get_id (alist, xmlenv);
+ if (this->in_module_)
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s in stream %s\n"),
+// this->parsed_info_.name (),
+// this->stream_info_.name ()));
+ ACE_Module_Type *mt = (this->stream_ == 0)
+ ? 0
+ : this->stream_->find (this->parsed_info_.name ());
+
+ if (mt == 0)
+ {
+ xmlenv.exception (new ACEXML_SAXException ("Can't locate module\n"));
+ return;
+ }
+
+ mt->resume ();
+ }
+ else
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s\n"),
+// this->parsed_info_.name ()));
+ if (ACE_Service_Config::resume (this->parsed_info_.name ()) == -1)
+ {
+ xmlenv.exception (new ACEXML_SAXException (ACE_TEXT ("Resume fail\n")));
+ }
+ }
+ this->parsed_info_.reset ();
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("suspend")) == 0)
+ {
+ this->get_id (alist, xmlenv);
+ if (this->in_module_)
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s in stream %s\n"),
+// this->parsed_info_.name (),
+// this->stream_info_.name ()));
+ ACE_Module_Type *mt = (this->stream_ == 0)
+ ? 0
+ : this->stream_->find (this->parsed_info_.name ());
+
+ if (mt == 0)
+ {
+ xmlenv.exception (new ACEXML_SAXException ("Can't locate module\n"));
+ return;
+ }
+
+ mt->suspend ();
+ }
+ else
+ {
+ // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s\n"),
+ // this->parsed_info_.name ()));
+ if (ACE_Service_Config::suspend (this->parsed_info_.name ()) == -1)
+ {
+ xmlenv.exception (new ACEXML_SAXException (ACE_TEXT ("Suspend fail\n")));
+ }
+ }
+ this->parsed_info_.reset ();
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("remove")) == 0)
+ {
+ this->get_id (alist, xmlenv);
+ if (this->in_module_)
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s in stream %s\n"),
+// this->parsed_info_.name (),
+// this->stream_info_.name ()));
+ ACE_Module_Type *mt = (this->stream_ == 0)
+ ? 0
+ : this->stream_->find (this->parsed_info_.name ());
+
+ if (mt == 0)
+ {
+ xmlenv.exception (new ACEXML_SAXException ("Can't locate module\n"));
+ return;
+ }
+
+ this->stream_->remove (mt);
+ }
+ else
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s\n"),
+// this->parsed_info_.name ()));
+ if (ACE_Service_Config::remove (this->parsed_info_.name ()) == -1)
+ {
+ xmlenv.exception (new ACEXML_SAXException (ACE_TEXT ("Remove fail\n")));
+ }
+ }
+ this->parsed_info_.reset ();
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("ACE_Svc_Conf")) == 0)
+ {
+ // Main document tag. no-op.
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("ACE_Svc_Conf tag\n")));
+ }
+ else
+ {
+ // @@ Error. Perhaps we should relay to user event handler here, if available.
+ }
+
+ return;
+}
+
+void
+ACEXML_Svcconf_Handler::startPrefixMapping (const ACEXML_Char *,
+ const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+// *** Methods inherit from ACEXML_DTDHandler.
+
+void
+ACEXML_Svcconf_Handler::notationDecl (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_Svcconf_Handler::unparsedEntityDecl (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+// Methods inherit from ACEXML_EnitityResolver.
+
+ACEXML_InputSource *
+ACEXML_Svcconf_Handler::resolveEntity (const ACEXML_Char *,
+ const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+ return 0;
+}
+
+// Methods inherit from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+void
+ACEXML_Svcconf_Handler::error (ACEXML_SAXParseException &,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_Svcconf_Handler::fatalError (ACEXML_SAXParseException &,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_Svcconf_Handler::warning (ACEXML_SAXParseException &,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+int
+ACEXML_Svcconf_Handler::get_stream_id (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv)
+{
+ if (alist != 0)
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
+ {
+ this->stream_info_.name (alist->getValue (i));
+ }
+ else
+ {
+ xmlenv.exception (new ACEXML_SAXException ("Invalid stream attribute\n"));
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Svcconf_Handler::get_id (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv)
+{
+ if (alist != 0)
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
+ {
+ this->parsed_info_.name (alist->getValue (i));
+ }
+ else
+ {
+ xmlenv.exception (new ACEXML_SAXException ("Invalid attribute, expecting 'id'\n"));
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Svcconf_Handler::get_dynamic_attrs (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv)
+{
+ if (alist != 0)
+ {
+ ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
+ &this->parsed_info_ :
+ &this->stream_info_);
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
+ {
+ info->name (alist->getValue (i));
+ }
+ else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("status")) == 0)
+ {
+ if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("inactive")) == 0)
+ {
+ info->active (0);
+ }
+ else if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("active")) == 0)
+ {
+ info->active (1);
+ }
+ else
+ {
+ xmlenv.exception
+ (new ACEXML_SAXException ("Invalid attribute value, expecting 'active' or 'inactive'\n"));
+ return -1;
+ }
+ }
+ else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("type")) == 0)
+ {
+ if (ACE_OS_String::strcasecmp (alist->getValue (i), ACE_TEXT ("service_object")) == 0)
+ {
+ info->service_type (ACE_Service_Type::SERVICE_OBJECT);
+ }
+ else if (ACE_OS_String::strcasecmp (alist->getValue (i), ACE_TEXT ("stream")) == 0)
+ {
+ info->service_type (ACE_Service_Type::STREAM);
+ }
+ else if (ACE_OS_String::strcasecmp (alist->getValue (i), ACE_TEXT ("module")) == 0)
+ {
+ info->service_type (ACE_Service_Type::MODULE);
+ }
+ else
+ {
+ xmlenv.exception
+ (new ACEXML_SAXException ("Invalid Service_Object attribute value\n"));
+ return -1;
+ }
+ }
+ else
+ {
+ xmlenv.exception (new ACEXML_SAXException ("Invalid attribute\n"));
+ return -1;
+ }
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Svcconf_Handler::get_initializer_attrs (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv)
+{
+ if (alist != 0)
+ {
+ ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
+ &this->parsed_info_ :
+ &this->stream_info_);
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("init")) == 0)
+ {
+ info->init_func (alist->getValue (i));
+ }
+ else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("path")) == 0)
+ {
+ info->path (alist->getValue (i));
+ }
+ else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0)
+ {
+ info->init_params (alist->getValue (i));
+ }
+ else
+ {
+ xmlenv.exception (new ACEXML_SAXException ("Invalid initializer attribute.\n"));
+ return -1;
+ }
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Svcconf_Handler::get_static_attrs (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv)
+{
+ if (alist != 0)
+ {
+ ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
+ &this->parsed_info_ :
+ &this->stream_info_);
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
+ {
+ info->name (alist->getValue (i));
+ }
+ else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0)
+ {
+ info->init_params (alist->getValue (i));
+ }
+ else
+ {
+ xmlenv.exception (new ACEXML_SAXException ("Invalid static attribute.\n"));
+ return -1;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/ACEXML/apps/svcconf/Svcconf_Handler.h b/ACEXML/apps/svcconf/Svcconf_Handler.h
new file mode 100644
index 00000000000..22069f8b97f
--- /dev/null
+++ b/ACEXML/apps/svcconf/Svcconf_Handler.h
@@ -0,0 +1,305 @@
+// $Id$
+
+//=============================================================================
+/**
+ * @file Svcconf_Handler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef ACEXML_SVCCONF_HANDLER_H
+#define ACEXML_SVCCONF_HANDLER_H
+
+#include "common/DefaultHandler.h"
+#include "ace/Service_Types.h"
+
+class ACE_Parsed_Info
+{
+public:
+ ACE_Parsed_Info ();
+ ~ACE_Parsed_Info ();
+
+ /**
+ * Set/get name of a parsed entity.
+ */
+ int name (const ACEXML_Char *n);
+ const ACEXML_Char *name (void);
+
+ /**
+ * Set/get type of a dynamic node.
+ */
+ int service_type (int type);
+ int service_type (void);
+
+ /**
+ * Set/Get active status.
+ */
+ int active (int a);
+ int active (void);
+
+ /**
+ * Set/get initializer path.
+ */
+ int path (const ACEXML_Char *n);
+ const ACEXML_Char *path (void);
+
+ /**
+ * Set/get initializer init function.
+ */
+ int init_func (const ACEXML_Char *n);
+ const ACEXML_Char *init_func (void);
+
+ /**
+ * Set/get initializer init parameter.
+ */
+ int init_params (const ACEXML_Char *n);
+ const ACEXML_Char *init_params (void);
+
+ /**
+ * Reset Parsed_Info.
+ */
+ void reset (void);
+
+protected:
+ ACEXML_Char *name_;
+ int service_type_;
+ int active_;
+ ACEXML_Char *path_;
+ ACEXML_Char *init_func_;
+ ACEXML_Char *init_params_;
+};
+
+/**
+ * @class ACEXML_Svcconf_Handler
+ *
+ * @brief ACEXML_Svcconf_Handler is an example SAX event handler.
+ *
+ * This SAX event handler try to regenerate the XML document it
+ * reads with correct indentation.
+ */
+class ACEXML_Svcconf_Handler : public ACEXML_DefaultHandler
+{
+public:
+ /*
+ * Default constructor.
+ */
+ ACEXML_Svcconf_Handler (void);
+
+ /*
+ * Default destructor.
+ */
+ virtual ~ACEXML_Svcconf_Handler (void);
+
+ // Methods inherit from ACEXML_ContentHandler.
+
+ /*
+ * Receive notification of character data.
+ */
+ virtual void characters (const ACEXML_Char *ch,
+ int start,
+ int length,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the end of a document.
+ */
+ virtual void endDocument (ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the end of an element.
+ */
+ virtual void endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * End the scope of a prefix-URI mapping.
+ */
+ virtual void endPrefixMapping (const ACEXML_Char *prefix,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of ignorable whitespace in element content.
+ */
+ virtual void ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a processing instruction.
+ */
+ virtual void processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive an object for locating the origin of SAX document events.
+ */
+ virtual void setDocumentLocator (ACEXML_Locator *locator,
+ ACEXML_Env &xmlenv) ;
+
+ /*
+ * Receive notification of a skipped entity.
+ */
+ virtual void skippedEntity (const ACEXML_Char *name,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the beginning of a document.
+ */
+ virtual void startDocument (ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the beginning of an element.
+ */
+ virtual void startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Begin the scope of a prefix-URI Namespace mapping.
+ */
+ virtual void startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // *** Methods inherit from ACEXML_DTDHandler.
+
+ /*
+ * Receive notification of a notation declaration event.
+ */
+ virtual void notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of an unparsed entity declaration event.
+ */
+ virtual void unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // Methods inherit from ACEXML_EnitityResolver.
+
+ /*
+ * Allow the application to resolve external entities.
+ */
+ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // Methods inherit from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+ virtual void error (ACEXML_SAXParseException &exception,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a non-recoverable error.
+ */
+ virtual void fatalError (ACEXML_SAXParseException &exception,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a warning.
+ */
+ virtual void warning (ACEXML_SAXParseException &exception,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+protected:
+ /**
+ * Get the only attribute in <stream> or <streamdef>.
+ */
+ int get_stream_id (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv);
+
+ /**
+ * Get the only attribute in <resume>, <suspend>, <remove>
+ */
+ int get_id (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv);
+
+ /**
+ * Get the dynamic tag attributes.
+ */
+ int get_dynamic_attrs (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv);
+
+ /**
+ * Get the initializer tag attributes.
+ */
+ int get_initializer_attrs (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv);
+
+ /**
+ * Get the static tag attributes.
+ */
+ int get_static_attrs (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv);
+
+private:
+ /// We are parsing a stream definition
+ int in_stream_def_;
+
+ /// We are defining a steam module
+ int in_module_;
+
+ /// @a stream_ holds the actually Stream_Type object managed by @a stream_svc_type_.
+ ACE_Service_Type *stream_svc_type_;
+ ACE_Stream_Type *stream_;
+
+ ACE_SHLIB_HANDLE dll_handle_;
+
+ ACE_Parsed_Info parsed_info_;
+
+ ACE_Parsed_Info stream_info_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "Svcconf_Handler.i"
+#endif /* __ACEXML_INLINE__ */
+#endif /* ACEXML_SVCCONF_HANDLER_H */
diff --git a/ACEXML/apps/svcconf/Svcconf_Handler.i b/ACEXML/apps/svcconf/Svcconf_Handler.i
new file mode 100644
index 00000000000..c78a345e2f6
--- /dev/null
+++ b/ACEXML/apps/svcconf/Svcconf_Handler.i
@@ -0,0 +1,133 @@
+// -*- C++ -*- $Id$
+
+ACE_INLINE
+ACE_Parsed_Info::ACE_Parsed_Info ()
+ : name_ (0),
+ service_type_ (ACE_Service_Type::INVALID_TYPE),
+ active_ (1),
+ path_ (0),
+ init_func_ (0),
+ init_params_ (0)
+{
+}
+
+ACE_INLINE
+ACE_Parsed_Info::~ACE_Parsed_Info ()
+{
+ delete this->name_;
+ delete this->path_;
+ delete this->init_func_;
+ delete this->init_params_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::name (const ACEXML_Char *n)
+{
+ if (this->name_ == 0)
+ {
+ this->name_ = ACE::strnew (n);
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE const ACEXML_Char *
+ACE_Parsed_Info::name (void)
+{
+ return this->name_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::service_type (int type)
+{
+ if (this->service_type_ == -1)
+ {
+ this->service_type_ = type;
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::service_type (void)
+{
+ return this->service_type_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::active (int a)
+{
+ this->active_ = a;
+ return 0;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::active (void)
+{
+ return this->active_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::path (const ACEXML_Char *p)
+{
+ if (this->path_ == 0)
+ {
+ this->path_ = ACE::strnew (p);
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE const ACEXML_Char *
+ACE_Parsed_Info::path (void)
+{
+ return this->path_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::init_func (const ACEXML_Char *n)
+{
+ if (this->init_func_ == 0)
+ {
+ this->init_func_ = ACE::strnew (n);
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE const ACEXML_Char *
+ACE_Parsed_Info::init_func (void)
+{
+ return this->init_func_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::init_params (const ACEXML_Char *n)
+{
+ if (this->init_params_ == 0)
+ {
+ this->init_params_ = ACE::strnew (n);
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE const ACEXML_Char *
+ACE_Parsed_Info::init_params (void)
+{
+ return this->init_params_;
+}
+
+ACE_INLINE void
+ACE_Parsed_Info::reset (void)
+{
+ delete this->name_;
+ this->name_ = 0;
+ this->service_type_ = -1;
+ delete this->path_;
+ this->path_ = 0;
+ delete this->init_func_;
+ this->init_func_ = 0;
+ delete this->init_params_;
+ this->init_params_ = 0;
+}
diff --git a/ACEXML/apps/svcconf/XML_Svc_Conf_Parser.dsp b/ACEXML/apps/svcconf/XML_Svc_Conf_Parser.dsp
new file mode 100644
index 00000000000..1560ec4e6de
--- /dev/null
+++ b/ACEXML/apps/svcconf/XML_Svc_Conf_Parser.dsp
@@ -0,0 +1,119 @@
+# Microsoft Developer Studio Project File - Name="XML_Svc_Conf_Parser" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=XML_Svc_Conf_Parser - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "XML_Svc_Conf_Parser.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "XML_Svc_Conf_Parser.mak" CFG="XML_Svc_Conf_Parser - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "XML_Svc_Conf_Parser - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "XML_Svc_Conf_Parser - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "XML_Svc_Conf_Parser - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XML_SVC_CONF_PARSER_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\.." /I "..\.." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 ace.lib ACEXML.lib ACEXML_Parser.lib /nologo /dll /machine:I386 /out:"..\..\..\bin\ACEXML_XML_Svc_Conf_Parser.dll" /libpath:"..\..\..\ace" /libpath:"..\..\Common" /libpath:"..\..\parser\parser"
+
+!ELSEIF "$(CFG)" == "XML_Svc_Conf_Parser - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "XML_Svc_Conf_Parser___Win32_Debug"
+# PROP BASE Intermediate_Dir "XML_Svc_Conf_Parser___Win32_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XML_SVC_CONF_PARSER_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\.." /I "..\.." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib ACEXMLd.lib ACEXML_Parserd.lib /nologo /dll /debug /machine:I386 /out:"..\..\..\bin\ACEXML_XML_Svc_Conf_Parserd.dll" /pdbtype:sept /libpath:"..\..\..\ace" /libpath:"..\..\Common" /libpath:"..\..\parser\parser"
+
+!ENDIF
+
+# Begin Target
+
+# Name "XML_Svc_Conf_Parser - Win32 Release"
+# Name "XML_Svc_Conf_Parser - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\Svcconf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Svcconf_Handler.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\Svcconf.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Svcconf_Handler.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/ACEXML/common/Makefile b/ACEXML/common/Makefile
index 85e52bedbc9..50e8fb3875e 100644
--- a/ACEXML/common/Makefile
+++ b/ACEXML/common/Makefile
@@ -20,6 +20,7 @@ FILES = Attributes_Def_Builder \
LocatorImpl \
NamespaceSupport \
SAXExceptions \
+ StrCharStream \
Transcode \
Validator \
XMLFilterImpl
diff --git a/ACEXML/common/Makefile.bor b/ACEXML/common/Makefile.bor
index 30be682e3b0..2b182b02afb 100644
--- a/ACEXML/common/Makefile.bor
+++ b/ACEXML/common/Makefile.bor
@@ -16,6 +16,7 @@ OBJFILES = \
$(OBJDIR)\LocatorImpl.obj \
$(OBJDIR)\NamespaceSupport.obj \
$(OBJDIR)\SAXExceptions.obj \
+ $(OBJDIR)\StrCharStream.obj \
$(OBJDIR)\Transcode.obj \
$(OBJDIR)\Validator.obj \
$(OBJDIR)\XMLFilterImpl.obj
diff --git a/ACEXML/common/StrCharStream.cpp b/ACEXML/common/StrCharStream.cpp
new file mode 100644
index 00000000000..55e5b93f201
--- /dev/null
+++ b/ACEXML/common/StrCharStream.cpp
@@ -0,0 +1,97 @@
+// $Id$
+
+#include "common/StrCharStream.h"
+#include "ace/ACE.h"
+
+ACEXML_StrCharStream::ACEXML_StrCharStream (void)
+ : start_ (0),
+ ptr_ (0),
+ end_ (0)
+{
+}
+
+ACEXML_StrCharStream::ACEXML_StrCharStream (const ACEXML_Char *str)
+ : start_ (0),
+ ptr_ (0),
+ end_ (0)
+{
+ this->open (str);
+}
+
+
+ACEXML_StrCharStream::~ACEXML_StrCharStream (void)
+{
+ delete this->start_;
+}
+
+int
+ACEXML_StrCharStream::open (const ACEXML_Char *str)
+{
+ delete this->start_;
+
+ if (str != 0 &&
+ (this->start_ = ACE::strnew (str)) != 0)
+ {
+ this->ptr_ = this->start_;
+ this->end_ = this->start_ + ACE_OS_String::strlen (this->start_);
+ return 0;
+ }
+
+ this->start_ = this->ptr_ = this->end_ = 0;
+ return -1; // Invalid string passed.
+}
+
+int
+ACEXML_StrCharStream::available (void)
+{
+ if (this->start_ != 0)
+ return (this->end_ - this->start_); // @@ Will this work on all platforms?
+ return -1;
+}
+
+int
+ACEXML_StrCharStream::close (void)
+{
+ delete this->start_;
+ this->start_ = this->ptr_ = this->end_ = 0;
+ return 0;
+}
+
+int
+ACEXML_StrCharStream::get (ACEXML_Char& ch)
+{
+ if (this->start_ != 0 && this->ptr_ != this->end_)
+ {
+ ch = *this->ptr_++;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int
+ACEXML_StrCharStream::read (ACEXML_Char *str,
+ size_t len)
+{
+ if (this->start_ != 0 &&
+ this->ptr_ != this->end_)
+ {
+ if (len > this->end_ - this->ptr_)
+ len = this->end_ - this->ptr_;
+
+ ACE_OS_String::strncpy (str, this->ptr_, len);
+ this->ptr_ += len;
+ return len;
+ }
+ return 0;
+}
+
+int
+ACEXML_StrCharStream::peek (void)
+{
+ if (this->start_ !=0 &&
+ this->ptr_ != this->end_)
+ return *this->ptr_;
+ return -1;
+}
diff --git a/ACEXML/common/StrCharStream.h b/ACEXML/common/StrCharStream.h
new file mode 100644
index 00000000000..17f8e33d914
--- /dev/null
+++ b/ACEXML/common/StrCharStream.h
@@ -0,0 +1,76 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file StrCharStream.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_STRCHARSTREAM_H_
+#define _ACEXML_STRCHARSTREAM_H_
+
+#include "common/CharStream.h"
+
+/**
+ * @class ACEXML_StrCharStream StrCharStream.h "common/StrCharStream.h"
+ *
+ * An implementation of ACEXML_CharStream for reading
+ * input from a null-terminated ACEXML_Char string.
+ */
+class ACEXML_Export ACEXML_StrCharStream : public ACEXML_CharStream
+{
+public:
+ /// Default constructor.
+ ACEXML_StrCharStream (void);
+
+ /// Initializing Constructor.
+ ACEXML_StrCharStream (const ACEXML_Char *str);
+
+ /// Destructor
+ virtual ~ACEXML_StrCharStream (void);
+
+ /// Initializing and reset the StrCharStream with @a str.
+ int open (const ACEXML_Char *str);
+
+ /**
+ * Returns the available ACEXML_Char in the buffer. -1
+ * if the object is not initialized properly.
+ */
+ virtual int available (void);
+
+ /**
+ * Close this stream and release all resources used by it.
+ */
+ virtual int close (void);
+
+ /**
+ * Read the next ACEXML_Char. Return -1 if we are not able to
+ * return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed.
+ */
+ virtual int get (ACEXML_Char& ch);
+
+ /**
+ * Read the next batch of ACEXML_Char strings
+ */
+ virtual int read (ACEXML_Char *str,
+ size_t len);
+
+ /**
+ * Peek the next ACEXML_Char in the CharStream. Return the
+ * character if succeess, -1 if EOS is reached.
+ */
+ virtual int peek (void);
+
+private:
+ ACEXML_Char *start_;
+
+ ACEXML_Char *ptr_;
+
+ ACEXML_Char *end_;
+};
+
+#endif /* _ACEXML_STRCHARSTREAM_H_ */
diff --git a/ACEXML/common/XML_Common.dsp b/ACEXML/common/XML_Common.dsp
index 58a0361e595..761a07eac5c 100644
--- a/ACEXML/common/XML_Common.dsp
+++ b/ACEXML/common/XML_Common.dsp
@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XML_COMMON_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "../.." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "ACEXML_BUILD_DLL" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../.." /I ".." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "ACEXML_BUILD_DLL" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -69,7 +69,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XML_COMMON_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "../.." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D ACEXML_HAS_DLL=1 /D "ACEXML_BUILD_DLL" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "../.." /I ".." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D ACEXML_HAS_DLL=1 /D "ACEXML_BUILD_DLL" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
@@ -144,6 +144,10 @@ SOURCE=.\SAXExceptions.cpp
# End Source File
# Begin Source File
+SOURCE=.\StrCharStream.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\Transcode.cpp
# End Source File
# Begin Source File
@@ -240,6 +244,10 @@ SOURCE=.\SAXExceptions.h
# End Source File
# Begin Source File
+SOURCE=.\StrCharStream.h
+# End Source File
+# Begin Source File
+
SOURCE=.\Transcode.h
# End Source File
# Begin Source File
diff --git a/ACEXML/examples/SAXPrint/main.cpp b/ACEXML/examples/SAXPrint/main.cpp
index 2d51dac2fec..86bf8ed86c5 100644
--- a/ACEXML/examples/SAXPrint/main.cpp
+++ b/ACEXML/examples/SAXPrint/main.cpp
@@ -2,33 +2,77 @@
#include "ACEXML/common/FileCharStream.h"
#include "ACEXML/parser/parser/Parser.h"
+#include "ACEXML/parser/parser/Parser.h"
#include "Print_Handler.h"
#include "SAXPrint_Handler.h"
+#include "ace/Get_Opt.h"
+
+static ACE_TCHAR *test_string =
+ACE_TEXT ("<?xml version='1.0'?> <ACE_Svc_Conf> <static id=\"ACE_Service_Manager\" params='-d -p 4911'/> <dynamic id=\"Test_Task\" type=\"service_object\"> &#65; &amp; <initializer path=\"CCM_App\" init='_make_Test_Task' params='-p 3000'/> </dynamic> </ACE_Svc_Conf>");
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
+ ACE_TCHAR *filename = 0;
+ int sax = 0; // Use SAXPrint handler or not.
+ int str = 0;
+
+ ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("sf:l"));
+ ACE_TCHAR c;
+
+ while ((c = get_opt ()) != -1)
+ {
+ switch (c)
+ {
+ case 's':
+ sax = 1;
+ break;
+ case 'l':
+ str = 1;
+ break;
+ case 'f':
+ filename = get_opt.opt_arg ();
+ break;
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Usage: %s [-sl] [-f <filename>]\n")
+ ACE_TEXT (" -s: Use SAXPrint_Handler (Default is Print_Handler\n")
+ ACE_TEXT (" -l: Parse the internal strings (test the StrCharStream class\n")
+ ACE_TEXT (" -f: Specify the filename when -l is not specified\n"),
+ argv[0]),
+ -1);
+ }
+ };
+
+ if (str == 0 && filename == 0)
+ ACE_ERROR_RETURN ((LM_ERROR, "No filename specified\n"), -1);
+
ACEXML_DefaultHandler *handler = 0;
{
- if (argc < 2)
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_LIB_TEXT ("Usage: %s <XML filename> [-n]\n"),
- argv [0]),
- -1);
-
- ACEXML_FileCharStream *fstm = 0;
- ACE_NEW_RETURN (fstm,
- ACEXML_FileCharStream (),
- 1);
-
- if (fstm->open (argv [1]) != 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_LIB_TEXT ("Fail to open XML file: %s\n"),
- argv [1]),
- -1);
-
- if (argc == 2) //
+ ACEXML_CharStream *stm = 0;
+ if (str == 0)
+ {
+ ACEXML_FileCharStream *fstm = 0;
+ ACE_NEW_RETURN (fstm,
+ ACEXML_FileCharStream (),
+ 1);
+
+ if (fstm->open (filename) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Fail to open XML file: %s\n"),
+ filename),
+ -1);
+ stm = fstm;
+ }
+ else
+ {
+ ACE_NEW_RETURN (stm,
+ ACEXML_StrCharStream (test_string),
+ 1);
+ }
+
+ if (sax == 0)
ACE_NEW_RETURN (handler,
ACEXML_Print_Handler (),
-1);
@@ -38,7 +82,7 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
-1);
ACEXML_Parser parser;
- ACEXML_InputSource input(fstm);
+ ACEXML_InputSource input(stm);
parser.setContentHandler (handler);
parser.setDTDHandler (handler);
diff --git a/ACEXML/examples/SAXPrint/svc.conf.xml b/ACEXML/examples/SAXPrint/svc.conf.xml
index ff0eebe831f..152f3b44406 100644
--- a/ACEXML/examples/SAXPrint/svc.conf.xml
+++ b/ACEXML/examples/SAXPrint/svc.conf.xml
@@ -19,15 +19,10 @@
]>
<ACE_Svc_Conf>
-<static id="ACE_Service_Manager">
- <params>-d</params>
- <params>-p 4911</params>
-</static>
+<static id="ACE_Service_Manager" params="-d -p 4911"/>
<dynamic id="Test_Task" type="service_object"> &#65; &amp;
- <initializer path="CCM_App" init="_make_Test_Task">
- <params>-p 3000</params>
- </initializer>
+ <initializer path="CCM_App" init="_make_Test_Task" params="-p 3000" />
</dynamic>
<streamdef>
@@ -42,10 +37,7 @@
<initializer path="CCM_App" init="make_ea"/>
</dynamic>
<dynamic id="Multicast_Router" type="module">
- <initializer path="CCM_App" init="make_mr">
- <params>-p</params>
- <params>3001</params>
- </initializer>
+ <initializer path="CCM_App" init="make_mr" params="-p 3001"/>
</dynamic>
</module>
</streamdef>
diff --git a/ACEXML/examples/svcconf/README b/ACEXML/examples/svcconf/README
new file mode 100644
index 00000000000..7463c7e9572
--- /dev/null
+++ b/ACEXML/examples/svcconf/README
@@ -0,0 +1,3 @@
+$Id$
+
+A test workspace for svc.conf handler. \ No newline at end of file
diff --git a/ACEXML/examples/svcconf/Svcconf.dsp b/ACEXML/examples/svcconf/Svcconf.dsp
new file mode 100644
index 00000000000..15911671e1c
--- /dev/null
+++ b/ACEXML/examples/svcconf/Svcconf.dsp
@@ -0,0 +1,110 @@
+# Microsoft Developer Studio Project File - Name="Svcconf" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=Svcconf - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "Svcconf.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "Svcconf.mak" CFG="Svcconf - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Svcconf - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "Svcconf - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "Svcconf - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\\" /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ace.lib ACEXML.lib ACEXML_Parser.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\ace" /libpath:"..\..\Common" /libpath:"..\..\parser\parser"
+
+!ELSEIF "$(CFG)" == "Svcconf - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\\" /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib ACEXMLd.lib ACEXML_Parserd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\ace" /libpath:"..\..\Common" /libpath:"..\..\parser\parser"
+
+!ENDIF
+
+# Begin Target
+
+# Name "Svcconf - Win32 Release"
+# Name "Svcconf - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\main.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Svcconf_Handler.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\Svcconf_Handler.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/ACEXML/examples/svcconf/Svcconf.dsw b/ACEXML/examples/svcconf/Svcconf.dsw
new file mode 100644
index 00000000000..f25a54a4e72
--- /dev/null
+++ b/ACEXML/examples/svcconf/Svcconf.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "Svcconf"=.\Svcconf.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/ACEXML/examples/svcconf/Svcconf_Handler.cpp b/ACEXML/examples/svcconf/Svcconf_Handler.cpp
new file mode 100644
index 00000000000..8376c7e41d2
--- /dev/null
+++ b/ACEXML/examples/svcconf/Svcconf_Handler.cpp
@@ -0,0 +1,495 @@
+// -*- C++ -*- $Id$
+
+#include "Svcconf_Handler.h"
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "Svcconf_Handler.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_Svcconf_Handler::ACEXML_Svcconf_Handler (void)
+ : in_stream_def_ (0),
+ in_module_ (0)
+{
+ // no-op
+}
+
+ACEXML_Svcconf_Handler::~ACEXML_Svcconf_Handler (void)
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::characters (const ACEXML_Char *,
+ int,
+ int,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::endDocument (ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::endElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *qName,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (ACE_OS_String::strcmp (qName, ACE_TEXT ("dynamic")) == 0)
+ {
+ if (this->in_stream_def_)
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Create dynamic %s for stream\n"),
+ this->stream_info_.name ()));
+ }
+ else
+ {
+ if (this->in_module_)
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Push dynamic %s into stream %s\n"),
+ this->parsed_info_.name (),
+ this->stream_info_.name ()));
+ }
+ else
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply dynamic %s\n"),
+ this->parsed_info_.name ()));
+ }
+ this->parsed_info_.reset ();
+ }
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("static")) == 0)
+ {
+ if (this->in_stream_def_)
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Create sttaic %s for stream\n"),
+ this->stream_info_.name ()));
+ }
+ else
+ {
+ if (this->in_module_)
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Push static %s into stream %s\n"),
+ this->parsed_info_.name (),
+ this->stream_info_.name ()));
+ }
+ else
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply static %s\n"),
+ this->parsed_info_.name ()));
+ }
+ this->parsed_info_.reset ();
+ }
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("module")) == 0)
+ {
+ this->in_module_ = 0;
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("streamdef")) == 0 ||
+ ACE_OS_String::strcmp (qName, ACE_TEXT ("stream")) == 0)
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply stream %s of type %s\n"),
+ this->stream_info_.name (),
+ this->stream_info_.name ()));
+ this->stream_info_.reset ();
+ }
+ else
+ {
+ }
+}
+
+void
+ACEXML_Svcconf_Handler::endPrefixMapping (const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::ignorableWhitespace (const ACEXML_Char *,
+ int,
+ int,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::processingInstruction (const ACEXML_Char *,
+ const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::setDocumentLocator (ACEXML_Locator *,
+ ACEXML_Env &)
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::skippedEntity (const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::startDocument (ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::startElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (ACE_OS_String::strcmp (qName, ACE_TEXT ("dynamic")) == 0)
+ {
+ this->get_dynamic_attrs (alist, xmlenv);
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("initializer")) == 0)
+ {
+ this->get_initializer_attrs (alist, xmlenv);
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("static")) == 0)
+ {
+ this->get_static_attrs (alist, xmlenv);
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("stream")) == 0)
+ {
+ this->get_stream_id (alist, xmlenv);
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Retrieve stream %s from repository\n"),
+ this->stream_info_.name ()));
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("streamdef")) == 0)
+ {
+ this->in_stream_def_ = 1;
+ // @@ Set up stream service object
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("module")) == 0)
+ {
+ this->in_stream_def_ = 0;
+ this->in_module_ = 1;
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("resume")) == 0)
+ {
+ this->get_id (alist, xmlenv);
+ if (this->in_module_)
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s in stream %s\n"),
+ this->parsed_info_.name (),
+ this->stream_info_.name ()));
+ }
+ else
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s\n"),
+ this->parsed_info_.name ()));
+ }
+ this->parsed_info_.reset ();
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("suspend")) == 0)
+ {
+ this->get_id (alist, xmlenv);
+ if (this->in_module_)
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s in stream %s\n"),
+ this->parsed_info_.name (),
+ this->stream_info_.name ()));
+ }
+ else
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s\n"),
+ this->parsed_info_.name ()));
+ }
+ this->parsed_info_.reset ();
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("remove")) == 0)
+ {
+ this->get_id (alist, xmlenv);
+ if (this->in_module_)
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s in stream %s\n"),
+ this->parsed_info_.name (),
+ this->stream_info_.name ()));
+ }
+ else
+ {
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s\n"),
+ this->parsed_info_.name ()));
+ }
+ this->parsed_info_.reset ();
+ }
+ else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("ACE_Svc_Conf")) == 0)
+ {
+ // Main document tag. no-op.
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("ACE_Svc_Conf tag\n")));
+ }
+ else
+ {
+ // @@ Error. Perhaps we should relay to user event handler here, if available.
+ }
+
+ return;
+
+ if (alist != 0)
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_LIB_TEXT (" %s = \"%s\""),
+ alist->getQName (i), alist->getValue (i)));
+ }
+ ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT (">")));
+}
+
+void
+ACEXML_Svcconf_Handler::startPrefixMapping (const ACEXML_Char *,
+ const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+// *** Methods inherit from ACEXML_DTDHandler.
+
+void
+ACEXML_Svcconf_Handler::notationDecl (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_Svcconf_Handler::unparsedEntityDecl (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+// Methods inherit from ACEXML_EnitityResolver.
+
+ACEXML_InputSource *
+ACEXML_Svcconf_Handler::resolveEntity (const ACEXML_Char *,
+ const ACEXML_Char *,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+ return 0;
+}
+
+// Methods inherit from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+void
+ACEXML_Svcconf_Handler::error (ACEXML_SAXParseException &,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_Svcconf_Handler::fatalError (ACEXML_SAXParseException &,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_Svcconf_Handler::warning (ACEXML_SAXParseException &,
+ ACEXML_Env &)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+int
+ACEXML_Svcconf_Handler::get_stream_id (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv)
+{
+ if (alist != 0)
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
+ {
+ this->stream_info_.name (alist->getValue (i));
+ }
+ else
+ {
+ // @@ Exception...
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Svcconf_Handler::get_id (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv)
+{
+ if (alist != 0)
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
+ {
+ this->parsed_info_.name (alist->getValue (i));
+ }
+ else
+ {
+ // @@ Exception...
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Svcconf_Handler::get_dynamic_attrs (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv)
+{
+ if (alist != 0)
+ {
+ ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
+ &this->parsed_info_ :
+ &this->stream_info_);
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
+ {
+ info->name (alist->getValue (i));
+ }
+ else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("status")) == 0)
+ {
+ if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("inactive")) == 0)
+ {
+ }
+ else if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("active")) == 0)
+ {
+ }
+ else
+ {
+ // @@ error, invalid 'status' value.
+ }
+ }
+ else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("type")) == 0)
+ {
+ if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("service_object")) == 0)
+ {
+ info->service_type (ACE_Parsed_Info::SERVICE_OBJECT_TYPE);
+ }
+ else if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("stream")) == 0)
+ {
+ info->service_type (ACE_Parsed_Info::STREAM_TYPE);
+ }
+ else if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("module")) == 0)
+ {
+ info->service_type (ACE_Parsed_Info::MODULE_TYPE);
+ }
+ else
+ {
+ // @@ error, invalid 'type' value.
+ }
+ }
+ else
+ {
+ // @@ Exception...
+ return -1;
+ }
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Svcconf_Handler::get_initializer_attrs (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv)
+{
+ if (alist != 0)
+ {
+ ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
+ &this->parsed_info_ :
+ &this->stream_info_);
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("init")) == 0)
+ {
+ info->init_func (alist->getValue (i));
+ }
+ else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("path")) == 0)
+ {
+ info->path (alist->getValue (i));
+ }
+ else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0)
+ {
+ info->init_params (alist->getValue (i));
+ }
+ else
+ {
+ // @@ Exception...
+ return -1;
+ }
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Svcconf_Handler::get_static_attrs (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv)
+{
+ if (alist != 0)
+ {
+ ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
+ &this->parsed_info_ :
+ &this->stream_info_);
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
+ {
+ info->name (alist->getValue (i));
+ }
+ else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0)
+ {
+ info->init_params (alist->getValue (i));
+ }
+ else
+ {
+ // @@ Exception...
+ return -1;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/ACEXML/examples/svcconf/Svcconf_Handler.h b/ACEXML/examples/svcconf/Svcconf_Handler.h
new file mode 100644
index 00000000000..1cff80eee87
--- /dev/null
+++ b/ACEXML/examples/svcconf/Svcconf_Handler.h
@@ -0,0 +1,305 @@
+// $Id$
+
+//=============================================================================
+/**
+ * @file Svcconf_Handler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef ACEXML_SVCCONF_HANDLER_H
+#define ACEXML_SVCCONF_HANDLER_H
+
+#include "common/DefaultHandler.h"
+
+class ACE_Parsed_Info
+{
+public:
+ typedef enum {
+ MODULE_TYPE,
+ SERVICE_OBJECT_TYPE,
+ STREAM_TYPE,
+ INVALID_TYPE
+ } Service_Type;
+
+ ACE_Parsed_Info ();
+ ~ACE_Parsed_Info ();
+
+ /**
+ * Set/get name of a parsed entity.
+ */
+ int name (const ACEXML_Char *n);
+ const ACEXML_Char *name (void);
+
+ /**
+ * Set/get type of a dynamic node.
+ */
+ int service_type (Service_Type type);
+ Service_Type service_type (void);
+
+ /**
+ * Set/Get active status.
+ */
+ int active (int a);
+ int active (void);
+
+ /**
+ * Set/get initializer path.
+ */
+ int path (const ACEXML_Char *n);
+ const ACEXML_Char *path (void);
+
+ /**
+ * Set/get initializer init function.
+ */
+ int init_func (const ACEXML_Char *n);
+ const ACEXML_Char *init_func (void);
+
+ /**
+ * Set/get initializer init parameter.
+ */
+ int init_params (const ACEXML_Char *n);
+ const ACEXML_Char *init_params (void);
+
+ /**
+ * Reset Parsed_Info.
+ */
+ void reset (void);
+
+protected:
+ ACEXML_Char *name_;
+ Service_Type service_type_;
+ int active_;
+ ACEXML_Char *path_;
+ ACEXML_Char *init_func_;
+ ACEXML_Char *init_params_;
+};
+
+/**
+ * @class ACEXML_Svcconf_Handler
+ *
+ * @brief ACEXML_Svcconf_Handler is an example SAX event handler.
+ *
+ * This SAX event handler try to regenerate the XML document it
+ * reads with correct indentation.
+ */
+class ACEXML_Svcconf_Handler : public ACEXML_DefaultHandler
+{
+public:
+ /*
+ * Default constructor.
+ */
+ ACEXML_Svcconf_Handler (void);
+
+ /*
+ * Default destructor.
+ */
+ virtual ~ACEXML_Svcconf_Handler (void);
+
+ // Methods inherit from ACEXML_ContentHandler.
+
+ /*
+ * Receive notification of character data.
+ */
+ virtual void characters (const ACEXML_Char *ch,
+ int start,
+ int length,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the end of a document.
+ */
+ virtual void endDocument (ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the end of an element.
+ */
+ virtual void endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * End the scope of a prefix-URI mapping.
+ */
+ virtual void endPrefixMapping (const ACEXML_Char *prefix,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of ignorable whitespace in element content.
+ */
+ virtual void ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a processing instruction.
+ */
+ virtual void processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive an object for locating the origin of SAX document events.
+ */
+ virtual void setDocumentLocator (ACEXML_Locator *locator,
+ ACEXML_Env &xmlenv) ;
+
+ /*
+ * Receive notification of a skipped entity.
+ */
+ virtual void skippedEntity (const ACEXML_Char *name,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the beginning of a document.
+ */
+ virtual void startDocument (ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the beginning of an element.
+ */
+ virtual void startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Begin the scope of a prefix-URI Namespace mapping.
+ */
+ virtual void startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // *** Methods inherit from ACEXML_DTDHandler.
+
+ /*
+ * Receive notification of a notation declaration event.
+ */
+ virtual void notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of an unparsed entity declaration event.
+ */
+ virtual void unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // Methods inherit from ACEXML_EnitityResolver.
+
+ /*
+ * Allow the application to resolve external entities.
+ */
+ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // Methods inherit from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+ virtual void error (ACEXML_SAXParseException &exception,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a non-recoverable error.
+ */
+ virtual void fatalError (ACEXML_SAXParseException &exception,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a warning.
+ */
+ virtual void warning (ACEXML_SAXParseException &exception,
+ ACEXML_Env &xmlenv)
+ // ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+protected:
+ /**
+ * Get the only attribute in <stream> or <streamdef>.
+ */
+ int get_stream_id (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv);
+
+ /**
+ * Get the only attribute in <resume>, <suspend>, <remove>
+ */
+ int get_id (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv);
+
+ /**
+ * Get the dynamic tag attributes.
+ */
+ int get_dynamic_attrs (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv);
+
+ /**
+ * Get the initializer tag attributes.
+ */
+ int get_initializer_attrs (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv);
+
+ /**
+ * Get the static tag attributes.
+ */
+ int get_static_attrs (ACEXML_Attributes *alist,
+ ACEXML_Env &xmlenv);
+
+private:
+ /// We are parsing a stream definition
+ int in_stream_def_;
+
+ /// We are defining a steam module
+ int in_module_;
+
+ ACE_Parsed_Info parsed_info_;
+
+ ACE_Parsed_Info stream_info_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "Svcconf_Handler.i"
+#endif /* __ACEXML_INLINE__ */
+#endif /* ACEXML_SVCCONF_HANDLER_H */
diff --git a/ACEXML/examples/svcconf/Svcconf_Handler.i b/ACEXML/examples/svcconf/Svcconf_Handler.i
new file mode 100644
index 00000000000..fb6ea3db2ce
--- /dev/null
+++ b/ACEXML/examples/svcconf/Svcconf_Handler.i
@@ -0,0 +1,133 @@
+// -*- C++ -*- $Id$
+
+ACE_INLINE
+ACE_Parsed_Info::ACE_Parsed_Info ()
+ : name_ (0),
+ service_type_ (INVALID_TYPE),
+ active_ (1),
+ path_ (0),
+ init_func_ (0),
+ init_params_ (0)
+{
+}
+
+ACE_INLINE
+ACE_Parsed_Info::~ACE_Parsed_Info ()
+{
+ delete this->name_;
+ delete this->path_;
+ delete this->init_func_;
+ delete this->init_params_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::name (const ACEXML_Char *n)
+{
+ if (this->name_ == 0)
+ {
+ this->name_ = ACE::strnew (n);
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE const ACEXML_Char *
+ACE_Parsed_Info::name (void)
+{
+ return this->name_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::service_type (Service_Type type)
+{
+ if (this->service_type_ == INVALID_TYPE)
+ {
+ this->service_type_ = type;
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE ACE_Parsed_Info::Service_Type
+ACE_Parsed_Info::service_type (void)
+{
+ return this->service_type_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::active (int a)
+{
+ this->active_ = a;
+ return 0;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::active (void)
+{
+ return this->active_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::path (const ACEXML_Char *p)
+{
+ if (this->path_ == 0)
+ {
+ this->path_ = ACE::strnew (p);
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE const ACEXML_Char *
+ACE_Parsed_Info::path (void)
+{
+ return this->path_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::init_func (const ACEXML_Char *n)
+{
+ if (this->init_func_ == 0)
+ {
+ this->init_func_ = ACE::strnew (n);
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE const ACEXML_Char *
+ACE_Parsed_Info::init_func (void)
+{
+ return this->init_func_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::init_params (const ACEXML_Char *n)
+{
+ if (this->init_params_ == 0)
+ {
+ this->init_params_ = ACE::strnew (n);
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE const ACEXML_Char *
+ACE_Parsed_Info::init_params (void)
+{
+ return this->init_params_;
+}
+
+ACE_INLINE void
+ACE_Parsed_Info::reset (void)
+{
+ delete this->name_;
+ this->name_ = 0;
+ this->service_type_ = INVALID_TYPE;
+ delete this->path_;
+ this->path_ = 0;
+ delete this->init_func_;
+ this->init_func_ = 0;
+ delete this->init_params_;
+ this->init_params_ = 0;
+}
diff --git a/ACEXML/examples/svcconf/main.cpp b/ACEXML/examples/svcconf/main.cpp
new file mode 100644
index 00000000000..bbadfdc0bc0
--- /dev/null
+++ b/ACEXML/examples/svcconf/main.cpp
@@ -0,0 +1,71 @@
+// $Id$
+
+#include "common/FileCharStream.h"
+#include "common/StrCharStream.h"
+#include "parser/parser/Parser.h"
+#include "Svcconf_Handler.h"
+#include "ace/Get_Opt.h"
+
+int
+main (int argc, ACE_TCHAR *argv[])
+{
+ ACE_TCHAR *filename = 0;
+
+ ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("f:"));
+ ACE_TCHAR c;
+
+ while ((c = get_opt ()) != -1)
+ {
+ switch (c)
+ {
+ case 'f':
+ filename = get_opt.opt_arg ();
+ break;
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Usage: %s [-f <filename>]\n")
+ ACE_TEXT (" -f: Specify the svcconf filename\n"),
+ argv[0]),
+ -1);
+ }
+ };
+
+ if (filename == 0)
+ ACE_ERROR_RETURN ((LM_ERROR, "No filename specified\n"), -1);
+
+ ACEXML_DefaultHandler *handler = 0;
+ {
+ ACEXML_CharStream *stm = 0;
+ ACEXML_FileCharStream *fstm = 0;
+ ACE_NEW_RETURN (fstm,
+ ACEXML_FileCharStream (),
+ 1);
+
+ if (fstm->open (filename) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Fail to open XML file: %s\n"),
+ filename),
+ -1);
+ stm = fstm;
+
+ ACE_NEW_RETURN (handler,
+ ACEXML_Svcconf_Handler (),
+ -1);
+
+ ACEXML_Parser parser;
+ ACEXML_InputSource input(stm);
+
+ parser.setContentHandler (handler);
+ parser.setDTDHandler (handler);
+ parser.setErrorHandler (handler);
+ parser.setEntityResolver (handler);
+
+ ACEXML_Env xmlenv;
+
+ parser.parse (&input, xmlenv);
+ if (xmlenv.exception ())
+ xmlenv.exception ()->print ();
+ }
+ delete handler;
+ return 0;
+}
diff --git a/ACEXML/examples/test_docs/svcconf.dtd b/ACEXML/examples/test_docs/svcconf.dtd
index dded178c1f7..b9e6cc41c8e 100644
--- a/ACEXML/examples/test_docs/svcconf.dtd
+++ b/ACEXML/examples/test_docs/svcconf.dtd
@@ -36,14 +36,16 @@
type (module|service_object|stream) #REQUIRED>
<!-- Initializing function for dynamic entry. -->
-<!ELEMENT initializer (params)*>
+<!ELEMENT initializer EMPTY>
<!ATTLIST initializer init CDATA #REQUIRED
- path CDATA #IMPLIED>
+ path CDATA #IMPLIED
+ params CDATA #IMPLIED>
<!-- A 'static' entry takes an ID attribute and an optional -->
<!-- parameter lists. -->
-<!ELEMENT static (params)*>
-<!ATTLIST static id ID #REQUIRED>
+<!ELEMENT static EMPTY>
+<!ATTLIST static id ID #REQUIRED
+ params CDATA #IMPLIED>
<!-- A 'suspend' entry takes an ID attribute. -->
<!ELEMENT suspend EMPTY>
@@ -56,10 +58,3 @@
<!-- A 'remove' entry takes an ID attribute. -->
<!ELEMENT remove EMPTY>
<!ATTLIST remove id IDREF #REQUIRED>
-
-<!-- A params entry can appear within dynamic and static. -->
-<!-- Parameters can appear multiple time and the SAX handler -->
-<!-- for Service_Configurator is supposed to concatinate -->
-<!-- them together with appropriate white space to separate -->
-<!-- parameters appeared in separate elements. -->
-<!ELEMENT params (#PCDATA)> \ No newline at end of file
diff --git a/ACEXML/parser/parser/Makefile b/ACEXML/parser/parser/Makefile
index ffd88d5c13e..63af2ae6557 100644
--- a/ACEXML/parser/parser/Makefile
+++ b/ACEXML/parser/parser/Makefile
@@ -13,7 +13,7 @@ FILES = Entity_Manager \
DEFS = $(addsuffix .h,$(FILES))
LSRC = $(addsuffix .cpp,$(FILES))
-LIBS += $(ACELIB) -lACEXML
+LIBS += -lACEXML $(ACELIB)
BUILD = $(VLIB) $(VSHLIB)
diff --git a/ACEXML/parser/parser/Parser.cpp b/ACEXML/parser/parser/Parser.cpp
index 7ff342bd92e..ca428c94a2c 100644
--- a/ACEXML/parser/parser/Parser.cpp
+++ b/ACEXML/parser/parser/Parser.cpp
@@ -264,7 +264,7 @@ ACEXML_Parser::parse_xml_prolog (ACEXML_Env &xmlenv)
this->get () != 'l')
{
xmlenv.exception (new ACEXML_SAXParseException
- (ACE_LIB_TEXT ("Unrecognized XML Decl")));
+ (ACE_LIB_TEXT ("Unrecognized XML Decl ('<?xml' ?)")));
return;
}
@@ -281,7 +281,7 @@ ACEXML_Parser::parse_xml_prolog (ACEXML_Env &xmlenv)
this->get_quoted_string (astring) != 0)
{
xmlenv.exception (new ACEXML_SAXParseException
- (ACE_LIB_TEXT ("Unrecognized XML Decl")));
+ (ACE_LIB_TEXT ("Unrecognized XML Decl ('version'?)")));
return;
}
@@ -329,7 +329,7 @@ ACEXML_Parser::parse_xml_prolog (ACEXML_Env &xmlenv)
else
{
xmlenv.exception (new ACEXML_SAXParseException
- (ACE_LIB_TEXT ("Unrecognized XML Decl")));
+ (ACE_LIB_TEXT ("Unrecognized XML Decl ('encoding'?)")));
return;
}
}
@@ -360,13 +360,13 @@ ACEXML_Parser::parse_xml_prolog (ACEXML_Env &xmlenv)
}
}
xmlenv.exception (new ACEXML_SAXParseException
- (ACE_LIB_TEXT ("Unrecognized XML Decl")));
+ (ACE_LIB_TEXT ("Unrecognized XML Decl ('standalone'?)")));
return;
}
else
{
xmlenv.exception (new ACEXML_SAXParseException
- (ACE_LIB_TEXT ("Unrecognized XML Decl")));
+ (ACE_LIB_TEXT ("Unrecognized XML Decl ('standalone'?)")));
return;
}
}
@@ -377,7 +377,7 @@ ACEXML_Parser::parse_xml_prolog (ACEXML_Env &xmlenv)
if (this->get() != '>')
{
xmlenv.exception (new ACEXML_SAXParseException
- (ACE_LIB_TEXT ("Unrecognized XML Decl")));
+ (ACE_LIB_TEXT ("Unrecognized XML Decl ('>'?)")));
return;
}
return;