*Backed out changeset 3be01fb200a5

--HG--
branch : trunk
This commit is contained in:
maximius
2009-10-17 15:51:44 -07:00
parent 26b5e033ff
commit e585187b24
2257 changed files with 103863 additions and 761 deletions
+87
View File
@@ -1,4 +1,5 @@
// $Id: Naming_Context.cpp 81286 2008-04-09 07:27:30Z johnnyw $
#include "ace/Get_Opt.h"
#include "ace/Naming_Context.h"
#include "ace/Remote_Name_Space.h"
@@ -12,32 +13,43 @@
# include "ace/OS_NS_strings.h"
# include "ace/Trace.h"
#endif /* ACE_HAS_TRACE */
ACE_RCSID(ace, Naming_Context, "$Id: Naming_Context.cpp 81286 2008-04-09 07:27:30Z johnnyw $")
#if !defined (__ACE_INLINE__)
#include "ace/Naming_Context.inl"
#endif /* __ACE_INLINE__ */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Make life easier later on...
typedef ACE_Local_Name_Space <ACE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> LOCAL_NAME_SPACE;
typedef ACE_Local_Name_Space <ACE_LITE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> LITE_LOCAL_NAME_SPACE;
// The ACE_Naming_Context static service object is now defined
// by the ACE_Object_Manager, in Object_Manager.cpp.
int
ACE_Naming_Context::info (ACE_TCHAR **strp,
size_t length) const
{
ACE_TRACE ("ACE_Naming_Context::info");
ACE_TCHAR buf[BUFSIZ];
ACE_OS::sprintf (buf,
ACE_TEXT ("%s\t#%s\n"),
ACE_TEXT ("ACE_Naming_Context"),
ACE_TEXT ("Proxy for making calls to a Name Server"));
if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
return -1;
else
ACE_OS::strsncpy (*strp, buf, length);
return static_cast<int> (ACE_OS::strlen (buf));
}
int
ACE_Naming_Context::local (void)
{
@@ -47,20 +59,25 @@ ACE_Naming_Context::local (void)
|| ACE_OS::strcmp (this->netnameserver_host_,
this->hostname_) == 0;
}
int
ACE_Naming_Context::open (Context_Scope_Type scope_in, int lite)
{
ACE_TRACE ("ACE_Naming_Context::open");
ACE_OS::hostname (this->hostname_,
(sizeof this->hostname_ / sizeof (ACE_TCHAR)));
this->netnameserver_host_ =
this->name_options_->nameserver_host ();
this->netnameserver_port_ =
this->name_options_->nameserver_port ();
// Perform factory operation to select appropriate type of
// Name_Space subclass.
#if (defined (ACE_WIN32) && defined (ACE_USES_WCHAR))
// This only works on Win32 platforms when ACE_USES_WCHAR is turned on
if (this->name_options_->use_registry ())
// Use ACE_Registry
ACE_NEW_RETURN (this->name_space_,
@@ -91,36 +108,46 @@ ACE_Naming_Context::open (Context_Scope_Type scope_in, int lite)
-1);
}
}
if (ACE_LOG_MSG->op_status () != 0 || this->name_space_ == 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("NAME_SPACE::NAME_SPACE\n")),
-1);
return 0;
}
int
ACE_Naming_Context::close_down (void)
{
ACE_TRACE ("ACE_Naming_Context::close_down");
delete this->name_options_;
this->name_options_ = 0;
return this->close ();
}
int
ACE_Naming_Context::close (void)
{
ACE_TRACE ("ACE_Naming_Context::close");
delete this->name_space_;
this->name_space_ = 0;
return 0;
}
ACE_Naming_Context::ACE_Naming_Context (void)
: name_options_ (0),
name_space_ (0)
{
ACE_TRACE ("ACE_Naming_Context::ACE_Naming_Context");
ACE_NEW (this->name_options_,
ACE_Name_Options);
}
ACE_Naming_Context::ACE_Naming_Context (Context_Scope_Type scope_in,
int lite)
: name_options_ (0),
@@ -128,19 +155,23 @@ ACE_Naming_Context::ACE_Naming_Context (Context_Scope_Type scope_in,
netnameserver_host_ (0)
{
ACE_TRACE ("ACE_Naming_Context::ACE_Naming_Context");
ACE_NEW (this->name_options_,
ACE_Name_Options);
// Initialize.
if (this->open (scope_in, lite) == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_Naming_Context::ACE_Naming_Context")));
}
ACE_Name_Options *
ACE_Naming_Context::name_options (void)
{
return this->name_options_;
}
int
ACE_Naming_Context::bind (const ACE_NS_WString &name_in,
const ACE_NS_WString &value_in,
@@ -149,6 +180,7 @@ ACE_Naming_Context::bind (const ACE_NS_WString &name_in,
ACE_TRACE ("ACE_Naming_Context::bind");
return this->name_space_->bind (name_in, value_in, type_in);
}
int
ACE_Naming_Context::bind (const char *name_in,
const char *value_in,
@@ -159,6 +191,7 @@ ACE_Naming_Context::bind (const char *name_in,
ACE_NS_WString (value_in),
type_in);
}
int
ACE_Naming_Context::rebind (const ACE_NS_WString &name_in,
const ACE_NS_WString &value_in,
@@ -169,6 +202,7 @@ ACE_Naming_Context::rebind (const ACE_NS_WString &name_in,
value_in,
type_in);
}
int
ACE_Naming_Context::rebind (const char *name_in,
const char *value_in,
@@ -179,6 +213,7 @@ ACE_Naming_Context::rebind (const char *name_in,
ACE_NS_WString (value_in),
type_in);
}
int
ACE_Naming_Context::resolve (const ACE_NS_WString &name_in,
ACE_NS_WString &value_out,
@@ -189,6 +224,7 @@ ACE_Naming_Context::resolve (const ACE_NS_WString &name_in,
value_out,
type_out);
}
int
ACE_Naming_Context::resolve (const char *name_in,
ACE_NS_WString &value_out,
@@ -199,6 +235,7 @@ ACE_Naming_Context::resolve (const char *name_in,
value_out,
type_out);
}
int
ACE_Naming_Context::resolve (const char *name_in,
char *&value_out,
@@ -206,27 +243,33 @@ ACE_Naming_Context::resolve (const char *name_in,
{
ACE_TRACE ("ACE_Naming_Context::resolve");
ACE_NS_WString val_str;
if (this->resolve (ACE_NS_WString (name_in),
val_str,
type_out) == -1)
return -1;
// Note that <char_rep> *allocates* the memory! Thus, caller is
// responsible for deleting it!
value_out = val_str.char_rep ();
return value_out == 0 ? -1 : 0;
}
int
ACE_Naming_Context::unbind (const ACE_NS_WString &name_in)
{
ACE_TRACE ("ACE_Naming_Context::unbind");
return this->name_space_->unbind (name_in);
}
int
ACE_Naming_Context::unbind (const char *name_in)
{
ACE_TRACE ("ACE_Naming_Context::unbind");
return this->unbind (ACE_NS_WString (name_in));
}
int
ACE_Naming_Context::list_names (ACE_PWSTRING_SET &set_out,
const ACE_NS_WString &pattern_in)
@@ -235,6 +278,7 @@ ACE_Naming_Context::list_names (ACE_PWSTRING_SET &set_out,
return this->name_space_->list_names (set_out,
pattern_in);
}
int
ACE_Naming_Context::list_names (ACE_PWSTRING_SET &set_out,
const char *pattern_in)
@@ -243,6 +287,7 @@ ACE_Naming_Context::list_names (ACE_PWSTRING_SET &set_out,
return this->list_names (set_out,
ACE_NS_WString (pattern_in));
}
int
ACE_Naming_Context::list_values (ACE_PWSTRING_SET &set_out,
const ACE_NS_WString &pattern_in)
@@ -251,6 +296,7 @@ ACE_Naming_Context::list_values (ACE_PWSTRING_SET &set_out,
return this->name_space_->list_values (set_out,
pattern_in);
}
int
ACE_Naming_Context::list_values (ACE_PWSTRING_SET &set_out,
const char *pattern_in)
@@ -259,6 +305,7 @@ ACE_Naming_Context::list_values (ACE_PWSTRING_SET &set_out,
return this->list_values (set_out,
ACE_NS_WString (pattern_in));
}
int
ACE_Naming_Context::list_types (ACE_PWSTRING_SET &set_out,
const ACE_NS_WString &pattern_in)
@@ -267,6 +314,7 @@ ACE_Naming_Context::list_types (ACE_PWSTRING_SET &set_out,
return this->name_space_->list_types (set_out,
pattern_in);
}
int
ACE_Naming_Context::list_types (ACE_PWSTRING_SET &set_out,
const char *pattern_in)
@@ -275,6 +323,7 @@ ACE_Naming_Context::list_types (ACE_PWSTRING_SET &set_out,
return this->list_types (set_out,
ACE_NS_WString (pattern_in));
}
int
ACE_Naming_Context::list_name_entries (ACE_BINDING_SET &set_out,
const ACE_NS_WString &pattern_in)
@@ -283,6 +332,7 @@ ACE_Naming_Context::list_name_entries (ACE_BINDING_SET &set_out,
return this->name_space_->list_name_entries (set_out,
pattern_in);
}
int
ACE_Naming_Context::list_name_entries (ACE_BINDING_SET &set_out,
const char *pattern_in)
@@ -291,6 +341,7 @@ ACE_Naming_Context::list_name_entries (ACE_BINDING_SET &set_out,
return this->list_name_entries (set_out,
ACE_NS_WString (pattern_in));
}
int
ACE_Naming_Context::list_value_entries (ACE_BINDING_SET &set_out,
const ACE_NS_WString &pattern_in)
@@ -299,6 +350,7 @@ ACE_Naming_Context::list_value_entries (ACE_BINDING_SET &set_out,
return this->name_space_->list_value_entries (set_out,
pattern_in);
}
int
ACE_Naming_Context::list_value_entries (ACE_BINDING_SET &set_out,
const char *pattern_in)
@@ -307,6 +359,7 @@ ACE_Naming_Context::list_value_entries (ACE_BINDING_SET &set_out,
return this->list_value_entries (set_out,
ACE_NS_WString (pattern_in));
}
int
ACE_Naming_Context::list_type_entries (ACE_BINDING_SET &set_out,
const ACE_NS_WString &pattern_in)
@@ -315,6 +368,7 @@ ACE_Naming_Context::list_type_entries (ACE_BINDING_SET &set_out,
return this->name_space_->list_type_entries (set_out,
pattern_in);
}
int
ACE_Naming_Context::list_type_entries (ACE_BINDING_SET &set_out,
const char *pattern_in)
@@ -323,11 +377,14 @@ ACE_Naming_Context::list_type_entries (ACE_BINDING_SET &set_out,
return this->list_type_entries (set_out,
ACE_NS_WString (pattern_in));
}
ACE_Naming_Context::~ACE_Naming_Context (void)
{
ACE_TRACE ("ACE_Naming_Context::~ACE_Naming_Context");
this->close_down ();
}
void
ACE_Naming_Context::dump ()
{
@@ -336,6 +393,7 @@ ACE_Naming_Context::dump ()
this->name_space_->dump();
#endif /* ACE_HAS_DUMP */
}
int
ACE_Naming_Context::init (int argc, ACE_TCHAR *argv[])
{
@@ -345,6 +403,7 @@ ACE_Naming_Context::init (int argc, ACE_TCHAR *argv[])
this->name_options_->parse_args (argc, argv);
return this->open (this->name_options_->context ());
}
int
ACE_Naming_Context::fini (void)
{
@@ -354,6 +413,7 @@ ACE_Naming_Context::fini (void)
this->close_down ();
return 0;
}
ACE_Name_Options::ACE_Name_Options (void)
: debugging_ (0),
verbosity_ (0),
@@ -365,11 +425,13 @@ ACE_Name_Options::ACE_Name_Options (void)
base_address_ (ACE_DEFAULT_BASE_ADDR)
{
ACE_TRACE ("ACE_Name_Options::ACE_Name_Options");
#if defined (ACE_DEFAULT_NAMESPACE_DIR)
this->namespace_dir_ = ACE_OS::strdup (ACE_DEFAULT_NAMESPACE_DIR);
#else /* ACE_DEFAULT_NAMESPACE_DIR */
size_t pathsize = (MAXPATHLEN + 1) * sizeof (ACE_TCHAR);
this->namespace_dir_ = static_cast <ACE_TCHAR *> (ACE_OS::malloc (pathsize));
if (ACE::get_temp_dir (this->namespace_dir_, MAXPATHLEN) == -1)
{
ACE_ERROR ((LM_ERROR,
@@ -380,26 +442,31 @@ ACE_Name_Options::ACE_Name_Options (void)
}
#endif /* ACE_DEFAULT_NAMESPACE_DIR */
}
ACE_Name_Options::~ACE_Name_Options (void)
{
ACE_TRACE ("ACE_Name_Options::~ACE_Name_Options");
ACE_OS::free ((void *) this->nameserver_host_);
ACE_OS::free ((void *) this->namespace_dir_ );
ACE_OS::free ((void *) this->process_name_ );
ACE_OS::free ((void *) this->database_ );
}
void
ACE_Name_Options::nameserver_port (int port)
{
ACE_TRACE ("ACE_Name_Options::nameserver_port");
this->nameserver_port_ = port;
}
int
ACE_Name_Options::nameserver_port (void)
{
ACE_TRACE ("ACE_Name_Options::nameserver_port");
return this->nameserver_port_;
}
void
ACE_Name_Options::namespace_dir (const ACE_TCHAR *dir)
{
@@ -407,6 +474,7 @@ ACE_Name_Options::namespace_dir (const ACE_TCHAR *dir)
ACE_OS::free ((void *) this->namespace_dir_ );
this->namespace_dir_ = ACE_OS::strdup (dir);
}
void
ACE_Name_Options::process_name (const ACE_TCHAR *pname)
{
@@ -415,6 +483,7 @@ ACE_Name_Options::process_name (const ACE_TCHAR *pname)
ACE_OS::free ((void *) this->process_name_ );
this->process_name_ = ACE_OS::strdup (t);
}
void
ACE_Name_Options::nameserver_host (const ACE_TCHAR *host)
{
@@ -422,18 +491,21 @@ ACE_Name_Options::nameserver_host (const ACE_TCHAR *host)
ACE_OS::free ((void *) this->nameserver_host_);
this->nameserver_host_ = ACE_OS::strdup (host);
}
const ACE_TCHAR *
ACE_Name_Options::nameserver_host (void)
{
ACE_TRACE ("ACE_Name_Options::nameserver_host");
return this->nameserver_host_;
}
const ACE_TCHAR *
ACE_Name_Options::database (void)
{
ACE_TRACE ("ACE_Name_Options::database");
return this->database_;
}
void
ACE_Name_Options::database (const ACE_TCHAR *db)
{
@@ -441,47 +513,59 @@ ACE_Name_Options::database (const ACE_TCHAR *db)
ACE_OS::free ((void *) this->database_);
this->database_ = ACE_OS::strdup (db);
}
char *
ACE_Name_Options::base_address (void)
{
ACE_TRACE ("ACE_Name_Options::base_address");
return this->base_address_;
}
void
ACE_Name_Options::base_address (char *base_address)
{
ACE_TRACE ("ACE_Name_Options::base_address");
this->base_address_ = base_address;
}
ACE_Naming_Context::Context_Scope_Type
ACE_Name_Options::context (void)
{
ACE_TRACE ("ACE_Name_Options::context");
return this->context_;
}
void
ACE_Name_Options::context (ACE_Naming_Context::Context_Scope_Type context)
{
ACE_TRACE ("ACE_Name_Options::context");
this->context_ = context;
}
void
ACE_Name_Options::parse_args (int argc, ACE_TCHAR *argv[])
{
ACE_TRACE ("ACE_Name_Options::parse_args");
const ACE_TCHAR* program_name = 0;
// Argc can be 0 on some platforms like VxWorks.
if (argc > 0)
program_name = argv[0];
ACE_LOG_MSG->open (program_name);
this->process_name (program_name);
// Default is to use the PROC_LOCAL context...
this->context (ACE_Naming_Context::PROC_LOCAL);
// Make the database name the same as the process name by default
// (note that this makes a copy of the process_name_ so that we can
// clean it up in the destructor).
this->database (this->process_name ());
ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("b:c:dh:l:P:p:s:T:vr"));
for (int c; (c = get_opt ()) != -1; )
switch (c)
{
@@ -547,10 +631,13 @@ ACE_Name_Options::parse_args (int argc, ACE_TCHAR *argv[])
break;
}
}
ACE_END_VERSIONED_NAMESPACE_DECL
// The following Factory is used by the ACE_Service_Config and
// svc.conf file to dynamically initialize the state of the Name
// Server client.
ACE_FACTORY_DEFINE (ACE, ACE_Naming_Context)
ACE_STATIC_SVC_DEFINE (ACE_Naming_Context,
ACE_TEXT ("ACE_Naming_Context"),