Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / ACE / ace / Registry.cpp
blobcc98d8033955a0ae8cec6cf5650589e1fa658988
1 #include "ace/Registry.h"
3 #if defined (ACE_WIN32)
5 # include "ace/os_include/os_netdb.h"
6 # include "ace/OS_NS_unistd.h"
8 // Funky macro to deal with strange error passing semantics
9 // of Win32 Reg*() functions
10 #define ACE_REGISTRY_CALL_RETURN(X) \
11 do { \
12 if (X != ERROR_SUCCESS) \
13 { \
14 errno = X; \
15 return -1; \
16 } \
17 else \
18 return 0; \
19 } while (0)
22 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
24 ACE_TCHAR const ACE_Registry::STRING_SEPARATOR[] = ACE_TEXT ("\\");
26 bool
27 ACE_Registry::Name_Component::operator== (const Name_Component &rhs) const
29 return
30 rhs.id_ == this->id_ &&
31 rhs.kind_ == this->kind_;
34 bool
35 ACE_Registry::Name_Component::operator!= (const Name_Component &rhs) const
37 return !this->operator== (rhs);
40 // Simple binding constructor
41 ACE_Registry::Binding::Binding ()
42 : name_ (),
43 type_ (INVALID)
48 // Binding constructor
49 // (Name version)
50 ACE_Registry::Binding::Binding (const Name &name,
51 Binding_Type type)
52 : name_ (ACE_Registry::make_string (name)),
53 type_ (type)
58 // Binding constructor
59 // (String version)
60 ACE_Registry::Binding::Binding (const ACE_TString &name,
61 Binding_Type type)
62 : name_ (name),
63 type_ (type)
68 bool
69 ACE_Registry::Binding::operator== (const Binding &rhs) const
71 return
72 rhs.name_ == this->name_ &&
73 rhs.type_ == this->type_;
76 bool
77 ACE_Registry::Binding::operator!= (const Binding &rhs) const
79 return !this->operator== (rhs);
82 // Name accessor
83 // (Name version)
84 void
85 ACE_Registry::Binding::name (Name &name)
87 name = ACE_Registry::make_name (this->name_);
91 // Name accessors
92 // (String version)
93 void
94 ACE_Registry::Binding::name (ACE_TString &name)
96 name = this->name_;
100 // Name accessors
101 // (String version)
102 ACE_TString
103 ACE_Registry::Binding::name ()
105 return this->name_;
109 // Type accessor
110 ACE_Registry::Binding_Type
111 ACE_Registry::Binding::type ()
113 return this->type_;
117 // Simple object constructor
118 ACE_Registry::Object::Object (void *data,
119 u_long size,
120 u_long type)
121 : data_ (data),
122 size_ (size),
123 type_ (type)
127 // Object accessors and set methods
128 void
129 ACE_Registry::Object::data (void *data)
131 this->data_ = data;
135 void *
136 ACE_Registry::Object::data () const
138 return this->data_;
142 void
143 ACE_Registry::Object::size (u_long size)
145 this->size_ = size;
149 u_long
150 ACE_Registry::Object::size () const
152 return this->size_;
156 void
157 ACE_Registry::Object::type (u_long type)
159 this->type_ = type;
163 u_long
164 ACE_Registry::Object::type () const
166 return this->type_;
170 // Simple context constructor
171 ACE_Registry::Naming_Context::Naming_Context ()
172 : key_ ((HKEY) 0),
173 parent_key_ ((HKEY) 0),
174 name_ ()
179 // Context constructor
180 ACE_Registry::Naming_Context::Naming_Context (const HKEY &key)
181 : key_ (key),
182 parent_key_ ((HKEY) 0),
183 name_ ()
188 ACE_Registry::Naming_Context::Naming_Context (const Naming_Context &rhs)
189 : key_ (rhs.key_),
190 parent_key_ (rhs.parent_key_),
191 name_ (rhs.name_)
193 // This is incorrect.
194 // Rather than copying key, we should call ::DuplicateHandle()
195 // But since this is private (and not used), I don't care much
199 const ACE_Registry::Naming_Context &
200 ACE_Registry::Naming_Context::operator= (const Naming_Context &rhs)
202 ACE_UNUSED_ARG(rhs);
204 // Not implemented
205 return *this;
209 // Destructor
210 ACE_Registry::Naming_Context::~Naming_Context ()
212 this->close ();
216 // Insert <object> with <name> into <this> context
217 // (Name version)
219 ACE_Registry::Naming_Context::bind_new (const Name &name,
220 const Object &object)
222 return this->bind_new (ACE_Registry::make_string (name), object);
226 // Insert <object> with <name> into <this> context
227 // (String version)
229 ACE_Registry::Naming_Context::bind_new (const ACE_TString &name,
230 const Object &object)
232 // temporary object
233 Object temp;
234 long result = this->resolve (name, temp);
235 if (result == 0)
236 // resolve succeeded
237 result = -1;
238 else
239 // resolve failed
240 result = this->bind (name, object);
241 return result;
245 // Insert or update <object> with <name> into <this> context
246 // (Name version)
248 ACE_Registry::Naming_Context::bind (const Name &name,
249 const Object &object)
251 return this->bind (ACE_Registry::make_string (name), object);
255 // Insert or update <object> with <name> into <this> context
256 // (String version)
258 ACE_Registry::Naming_Context::bind (const ACE_TString &name,
259 const Object &object)
261 long result = ACE_TEXT_RegSetValueEx (this->key_,
262 name.c_str (),
264 object.type (),
265 (const BYTE *) object.data (),
266 object.size ());
267 ACE_REGISTRY_CALL_RETURN (result);
271 // Update <object> with <name> in <this> context
272 // (Name version)
274 ACE_Registry::Naming_Context::rebind (const Name &name,
275 const Object &new_object)
277 return this->rebind (ACE_Registry::make_string (name), new_object);
281 // Update <object> with <name> in <this> context
282 // (String version)
284 ACE_Registry::Naming_Context::rebind (const ACE_TString &name,
285 const Object &new_object)
287 Object old_object;
288 // find the old one first
289 long result = this->resolve (name, old_object);
290 if (result == 0)
291 // no need to delete first
292 result = this->bind (name, new_object);
293 return result;
297 // Find <object> with <name> in <this> context
298 // (Name version)
300 ACE_Registry::Naming_Context::resolve (const Name &name,
301 Object &object)
303 return this->resolve (ACE_Registry::make_string (name), object);
307 // Find <object> with <name> in <this> context
308 // (String version)
310 ACE_Registry::Naming_Context::resolve (const ACE_TString &name,
311 Object &object)
313 // Get object state
314 u_long type;
315 void *data = object.data ();
316 u_long size = object.size ();
318 long result = ACE_TEXT_RegQueryValueEx (this->key_,
319 name.c_str (),
321 &type,
322 (BYTE *)data,
323 &size);
324 if (result == ERROR_SUCCESS)
326 // Reset object state
327 // No need to set object.data()
328 object.type (type);
329 object.size (size);
332 ACE_REGISTRY_CALL_RETURN (result);
336 // Remove object with <name> in <this> context
337 // (Name version)
339 ACE_Registry::Naming_Context::unbind (const Name &name)
341 return this->unbind (ACE_Registry::make_string (name));
345 // Remove object with <name> in <this> context
346 // (String version)
348 ACE_Registry::Naming_Context::unbind (const ACE_TString &name)
350 long result = ACE_TEXT_RegDeleteValue (this->key_,
351 name.c_str ());
353 ACE_REGISTRY_CALL_RETURN (result);
357 // Create new <naming_context> relative to <this> context
358 // This method may not mean a lot in this implementation
360 ACE_Registry::Naming_Context::new_context (Naming_Context &naming_context)
362 // Make sure that we reset the state and close keys
363 return naming_context.close ();
367 // Insert <naming_context> with <name> relative to <this> context
368 // (Name version)
370 ACE_Registry::Naming_Context::bind_new_context (const Name &name,
371 Naming_Context &naming_context,
372 u_long persistence,
373 u_long security_access,
374 LPSECURITY_ATTRIBUTES security_attributes)
376 return this->bind_new_context (ACE_Registry::make_string (name),
377 naming_context,
378 persistence,
379 security_access,
380 security_attributes);
384 // Insert <naming_context> with <name> relative to <this> context
385 // (String version)
387 ACE_Registry::Naming_Context::bind_new_context (const ACE_TString &name,
388 Naming_Context &naming_context,
389 u_long persistence,
390 u_long security_access,
391 LPSECURITY_ATTRIBUTES security_attributes)
393 u_long reason;
395 long result = ACE_TEXT_RegCreateKeyEx (this->key_,
396 name.c_str (),
399 persistence,
400 security_access,
401 security_attributes,
402 &naming_context.key_,
403 &reason);
404 if (result == ERROR_SUCCESS)
405 // If create succeeds
407 if (reason == REG_CREATED_NEW_KEY)
408 // If new key: success
410 // Set the correct parent
411 naming_context.parent (this->key_);
412 // Set the correct name
413 naming_context.name (name);
415 else
416 // reason == REG_OPENED_EXISTING_KEY
417 // Failed to make new key
419 // reset result to failure
420 result = -1;
421 // Close the key first
422 ::RegCloseKey (naming_context.key_);
423 // Reset key
424 naming_context.key_ = (HKEY) 0;
428 ACE_REGISTRY_CALL_RETURN (result);
432 // Insert or update <naming_context> with <name> relative to <this> context
433 // (Name version)
435 ACE_Registry::Naming_Context::bind_context (const Name &name,
436 /* const */ Naming_Context &naming_context,
437 u_long persistence,
438 u_long security_access,
439 LPSECURITY_ATTRIBUTES security_attributes)
441 return this->bind_context (ACE_Registry::make_string (name),
442 naming_context,
443 persistence,
444 security_access,
445 security_attributes);
449 // Insert or update <naming_context> with <name> relative to <this> context
450 // (String version)
452 ACE_Registry::Naming_Context::bind_context (const ACE_TString &name,
453 /* const */ Naming_Context &naming_context,
454 u_long persistence,
455 u_long security_access,
456 LPSECURITY_ATTRIBUTES security_attributes)
458 u_long reason;
460 long result = ACE_TEXT_RegCreateKeyEx (this->key_,
461 name.c_str (),
464 persistence,
465 security_access,
466 security_attributes,
467 &naming_context.key_,
468 &reason);
469 if (result == ERROR_SUCCESS)
471 // Set the correct parent
472 naming_context.parent (this->key_);
473 // Set the correct name
474 naming_context.name (name);
477 ACE_REGISTRY_CALL_RETURN (result);
481 // Rename <naming_context> to <name>
482 // (Name version)
484 ACE_Registry::Naming_Context::rebind_context (const Name &name,
485 /* const */ Naming_Context &new_naming_context)
487 return this->rebind_context (ACE_Registry::make_string (name),
488 new_naming_context);
492 // Rename <naming_context> to <name>
493 // (String version)
495 ACE_Registry::Naming_Context::rebind_context (const ACE_TString &name,
496 /* const */ Naming_Context &new_naming_context)
498 Naming_Context old_naming_context;
499 // find the old one first
500 long result = this->resolve_context (name,
501 old_naming_context);
502 if (result == 0)
504 // naming_context is found: delete entry
505 result = this->unbind_context (name);
506 if (result == 0)
508 // successful deletion; rebind
509 // beware of race conditions here
510 // (lets resolve this later)
511 result = this->bind_new_context (name, new_naming_context);
514 return result;
518 // Remove naming_context with <name> from <this> context
519 // (Name version)
521 ACE_Registry::Naming_Context::unbind_context (const Name &name)
523 return this->unbind_context (ACE_Registry::make_string (name));
527 // Remove naming_context with <name> from <this> context
528 // (String version)
530 ACE_Registry::Naming_Context::unbind_context (const ACE_TString &name)
532 long result = ACE_TEXT_RegDeleteKey (this->key_,
533 name.c_str ());
535 ACE_REGISTRY_CALL_RETURN (result);
539 // Find <naming_context> with <name> in <this> context
540 // (Name version)
542 ACE_Registry::Naming_Context::resolve_context (const Name &name,
543 Naming_Context &naming_context,
544 u_long security_access)
546 return this->resolve_context (ACE_Registry::make_string (name),
547 naming_context,
548 security_access);
552 // Find <naming_context> with <name> in <this> context
553 // (String version)
555 ACE_Registry::Naming_Context::resolve_context (const ACE_TString &name,
556 Naming_Context &naming_context,
557 u_long security_access)
559 long result = ACE_TEXT_RegOpenKeyEx (this->key_,
560 name.c_str (),
562 security_access,
563 &naming_context.key_);
564 if (result == ERROR_SUCCESS)
566 // set the correct parent
567 naming_context.parent (this->key_);
568 // set the correct name
569 naming_context.name (name);
572 ACE_REGISTRY_CALL_RETURN (result);
576 // Same as unbind_context() with <this> as naming_context
578 ACE_Registry::Naming_Context::destroy ()
580 // hopefully the parent_key_ is still open
581 long result = ACE_TEXT_RegDeleteKey (this->parent_key_,
582 this->name_.c_str ());
584 ACE_REGISTRY_CALL_RETURN (result);
588 // Sync content of context to disk
590 ACE_Registry::Naming_Context::flush ()
592 long result = ::RegFlushKey (this->key_);
593 ACE_REGISTRY_CALL_RETURN (result);
597 // Close the handle of the context
599 ACE_Registry::Naming_Context::close ()
601 long result = this->key_ ? ::RegCloseKey (this->key_) : ERROR_SUCCESS;
602 ACE_REGISTRY_CALL_RETURN (result);
606 // Convert a <name> to a <string>
607 ACE_TString
608 ACE_Registry::make_string (const Name &const_name)
610 ACE_TString string;
611 Name &name = const_cast<Name &> (const_name);
613 // Iterator through the components of name
614 for (Name::iterator iterator = name.begin ();
615 iterator != name.end ();
616 iterator++)
618 if (iterator != name.begin ())
619 // If this is not the first component, we will add separators
620 string += STRING_SEPARATOR;
621 const Name_Component &component = *iterator;
622 // Add to string
623 string += component.id_;
626 return string;
630 // Convert a <string> to a <name>
631 ACE_Registry::Name
632 ACE_Registry::make_name (const ACE_TString &string)
634 ACE_TString::size_type new_position = 0;
635 ACE_TString::size_type last_position = 0;
636 Name name;
638 // Rememeber: NPOS is -1
639 while (new_position != ACE_TString::npos)
641 Name_Component component;
642 // Find the separator
643 new_position = string.find (STRING_SEPARATOR, new_position);
644 if (new_position != ACE_TString::npos)
645 // If we have not gone past the end
647 // Get the substring
648 component.id_ = string.substr (last_position,
649 new_position - last_position);
650 // Skip past the seperator
651 new_position +=
652 ACE_OS::strlen (STRING_SEPARATOR);
654 else
656 // Get the last substring
657 component.id_ = string.substr (last_position);
659 // Update positions
660 last_position = new_position;
661 // Insert component into name
662 name.insert (component);
665 return name;
669 // Set key
670 void
671 ACE_Registry::Naming_Context::key (HKEY key)
673 this->key_ = key;
677 // Get key
678 HKEY
679 ACE_Registry::Naming_Context::key ()
681 return this->key_;
685 // Set parent
686 void
687 ACE_Registry::Naming_Context::parent (HKEY parent)
689 this->parent_key_ = parent;
693 // Get parent
694 HKEY
695 ACE_Registry::Naming_Context::parent ()
697 return this->parent_key_;
701 // Set name
702 // (Name version)
703 void
704 ACE_Registry::Naming_Context::name (const Name &name)
706 this->name_ = ACE_Registry::make_string (name);
710 // Get name
711 // (Name version)
712 void
713 ACE_Registry::Naming_Context::name (Name &name)
715 name = ACE_Registry::make_name (this->name_);
719 // Set name
720 // (String version)
721 void
722 ACE_Registry::Naming_Context::name (const ACE_TString &name)
724 this->name_ = name;
728 // Get name
729 // (String version)
730 ACE_TString
731 ACE_Registry::Naming_Context::name ()
733 return this->name_;
737 // Get name
738 // (String version)
739 void
740 ACE_Registry::Naming_Context::name (ACE_TString &name)
742 name = this->name_;
745 // Empty list
746 static const ACE_Registry::Binding_List ace_binding_empty_list;
748 // listing function: iterator creator
749 // This is useful when there are many objects and contexts
750 // in <this> context and you only want to look at a few entries
751 // at a time
753 ACE_Registry::Naming_Context::list (u_long how_many,
754 Binding_List &list,
755 Binding_Iterator &iter)
757 // Make sure that the list is empty
758 list = ace_binding_empty_list;
760 // Correctly initalize the iterator
761 iter.reset ();
763 // Make sure that the iterator uses <this> naming context
764 iter.naming_context (*this);
766 // Start iterations from the objects
767 iter.current_enumeration (iter.object_iteration_);
769 // Get the next <how_many> values
770 return iter.next_n (how_many, list);
774 // listing function: iterator creator
775 // This gives back a listing of all entries in <this> context.
777 ACE_Registry::Naming_Context::list (Binding_List &list)
779 // Make sure that the list is empty
780 list = ace_binding_empty_list;
782 // Create an iterator
783 ACE_Registry::Binding_Iterator iterator;
785 // Make sure that the iterator uses <this> naming context
786 iterator.naming_context (*this);
788 // Start iterations from the objects
789 iterator.current_enumeration (iterator.object_iteration_);
791 long result = 0;
792 while (1)
794 ACE_Registry::Binding binding;
795 result = iterator.next_one (binding);
796 if (result == 0)
797 list.insert (binding);
798 else
799 break;
801 return 0;
805 // Default constructor
806 ACE_Registry::Binding_Iterator::Binding_Iterator ()
808 this->object_iteration_.iterator (this);
809 this->context_iteration_.iterator (this);
810 this->iteration_complete_.iterator (this);
811 this->reset ();
815 void
816 ACE_Registry::Binding_Iterator::reset ()
818 this->current_enumeration_ = &this->iteration_complete_;
819 this->iteration_complete_.reset ();
820 this->object_iteration_.reset ();
821 this->context_iteration_.reset ();
825 void
826 ACE_Registry::Binding_Iterator::Iteration_State::reset ()
828 this->index_ = 0;
832 void
833 ACE_Registry::Binding_Iterator::Iteration_State::iterator (Binding_Iterator *iter)
835 this->parent_ = iter;
839 ACE_Registry::Binding_Iterator::Iteration_State::Iteration_State ()
840 : index_ (0)
844 ACE_Registry::Binding_Iterator::Iteration_State::~Iteration_State ()
848 // Next entry
850 ACE_Registry::Binding_Iterator::next_one (Binding &binding)
852 u_long how_many = 1;
853 Binding_List list;
855 // Get next n (where n is one)
856 long result = this->next_n (how_many, list);
858 if (result == 0)
859 // Success
860 binding = (*list.begin ());
862 return result;
866 // Next <how_many> entries
868 ACE_Registry::Binding_Iterator::next_n (u_long how_many,
869 Binding_List &list)
871 // Make sure that the list is empty
872 list = ace_binding_empty_list;
874 return this->current_enumeration_->next_n (how_many, list);
878 // Destroy iterator
880 ACE_Registry::Binding_Iterator::destroy ()
882 this->reset ();
883 return 0;
887 // Set/Get naming_context
888 void
889 ACE_Registry::Binding_Iterator::naming_context (Naming_Context &naming_context)
891 this->naming_context_ = &naming_context;
895 ACE_Registry::Naming_Context &
896 ACE_Registry::Binding_Iterator::naming_context ()
898 return *this->naming_context_;
902 // Set/Get current enumeration
903 void
904 ACE_Registry::Binding_Iterator::current_enumeration (Iteration_State &current_enumeration)
906 this->current_enumeration_ = &current_enumeration;
910 ACE_Registry::Binding_Iterator::Iteration_State &
911 ACE_Registry::Binding_Iterator::current_enumeration ()
913 return *this->current_enumeration_;
918 ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many,
919 Binding_List &list)
921 // Make a copy
922 u_long requested = how_many;
924 // While there are more entries to be added to the list
925 while (how_many > 0)
927 ACE_TCHAR string [ACE_Registry::Naming_Context::MAX_OBJECT_NAME_SIZE];
928 u_long size = sizeof string / sizeof (ACE_TCHAR);
929 long result = ACE_TEXT_RegEnumValue (this->parent_->naming_context ().key (),
930 this->index_,
931 string,
932 &size,
937 switch (result)
939 case ERROR_SUCCESS:
940 // Object found
942 // Readjust counters
943 this->index_++;
944 how_many--;
946 // Add to list
947 // Create binding
948 Binding binding (string, OBJECT);
949 // Add to binding list
950 list.insert (binding);
952 // Continue to add to list
953 break;
955 case ERROR_NO_MORE_ITEMS:
956 // Enumeration of objects complete
957 // Reset index
958 this->index_ = 0;
960 // Current enumeration will become CONTEXTS
961 this->parent_->current_enumeration (this->parent_->context_iteration_);
962 result = this->parent_->current_enumeration ().next_n (how_many,
963 list);
964 // If we were able to add objects
965 if (requested != how_many)
966 return 0;
967 else
968 return result;
970 default:
971 // Strange error
972 // Reset index
973 this->index_ = 0;
974 // Current enumeration will become COMPLETE
975 this->parent_->current_enumeration (this->parent_->iteration_complete_);
976 // strange error
977 return -1;
980 // If we reach here, all of <how_many> pairs were added to the list
981 // Since more entries may be available
982 // current enumeration will remain OBJECTS
983 return 0;
988 ACE_Registry::Binding_Iterator::Context_Iteration::next_n (u_long how_many,
989 Binding_List &list)
991 // Make a copy
992 u_long requested = how_many;
994 // While there are more entries to be added to the list
995 while (how_many > 0)
997 ACE_TCHAR string [ACE_Registry::Naming_Context::MAX_CONTEXT_NAME_SIZE];
998 u_long size = sizeof string / sizeof (ACE_TCHAR);
999 long result = ACE_TEXT_RegEnumKeyEx (this->parent_->naming_context (). key (),
1000 this->index_,
1001 string,
1002 &size,
1007 switch (result)
1009 case ERROR_SUCCESS:
1010 // Object found
1012 // Readjust counters
1013 this->index_++;
1014 how_many--;
1016 // Add to list
1017 // Create binding
1018 Binding binding (string, CONTEXT);
1019 // Add to binding list
1020 list.insert (binding);
1022 // Continue to add to list
1023 break;
1025 case ERROR_NO_MORE_ITEMS:
1026 // Enumeration of objects complete
1028 /* FALL THROUGH */
1030 default:
1031 // Strange error
1033 // Reset index
1034 this->index_ = 0;
1035 // Current enumeration will become CONTEXTS
1036 this->parent_->current_enumeration (this->parent_->iteration_complete_);
1038 // If we were able to add contexts
1039 if (requested != how_many)
1040 return 0;
1041 else
1042 return -1;
1045 // If we reach here, all of <how_many> pairs were added to the list
1046 // Since more entries may be available
1047 // current enumeration will remain CONTEXTS
1048 return 0;
1053 ACE_Registry::Binding_Iterator::Iteration_Complete::next_n (u_long how_many,
1054 Binding_List &list)
1056 ACE_UNUSED_ARG(list);
1057 ACE_UNUSED_ARG(how_many);
1059 // No more values
1060 return -1;
1064 // Factory method to connect to predefined registries
1065 // This method works for both remote and local machines
1066 // However, for remote machines CLASSES_ROOT and CURRENT_USER
1067 // types are not allowed
1068 /* static */
1070 ACE_Predefined_Naming_Contexts::connect (ACE_Registry::Naming_Context &naming_context,
1071 HKEY predefined,
1072 const ACE_TCHAR *machine_name)
1074 long result = -1;
1076 if (machine_name != 0 && ACE_OS::strcmp (ACE_TEXT ("localhost"), machine_name) == 0)
1077 machine_name = 0;
1079 if (predefined == HKEY_LOCAL_MACHINE || predefined == HKEY_USERS)
1080 result =
1081 ACE_TEXT_RegConnectRegistry (const_cast<ACE_TCHAR *> (machine_name),
1082 predefined,
1083 &naming_context.key_);
1084 if (predefined == HKEY_CURRENT_USER || predefined == HKEY_CLASSES_ROOT)
1086 // Make sure that for these types, the machine is local
1087 if (machine_name == 0 ||
1088 ACE_Predefined_Naming_Contexts::is_local_host (machine_name))
1090 naming_context.key_ = predefined;
1091 result = 0;
1093 else
1094 result = -1;
1097 ACE_REGISTRY_CALL_RETURN (result);
1100 /// Check if @a machine_name is the local host
1101 /* static */
1103 ACE_Predefined_Naming_Contexts::is_local_host (const ACE_TCHAR *machine_name)
1105 ACE_TCHAR local_host[MAXHOSTNAMELEN];
1106 int result = ACE_OS::hostname (local_host, sizeof local_host / sizeof (ACE_TCHAR));
1107 if (result == 0)
1108 result = !ACE_OS::strcmp (local_host, machine_name);
1109 else
1110 result = 0;
1111 return result;
1114 ACE_END_VERSIONED_NAMESPACE_DECL
1116 #endif /* ACE_WIN32 */