00001 #include "ace_pch.h"
00002
00003
00004 #include "ace/Registry.h"
00005
00006 ACE_RCSID(ace, Registry, "$Id: Registry.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:22 chad Exp $")
00007
00008 #if defined (ACE_WIN32)
00009
00010
00011
00012 #define ACE_REGISTRY_CALL_RETURN(X) \
00013 do { \
00014 if (X != ERROR_SUCCESS) \
00015 { \
00016 errno = X; \
00017 return -1; \
00018 } \
00019 else \
00020 return 0; \
00021 } while (0)
00022
00023
00024
00025
00026 const ACE_TCHAR *ACE_Registry::STRING_SEPARATOR = ACE_LIB_TEXT ("\\");
00027
00028 int
00029 ACE_Registry::Name_Component::operator== (const Name_Component &rhs) const
00030 {
00031 return
00032 rhs.id_ == this->id_ &&
00033 rhs.kind_ == this->kind_;
00034 }
00035
00036 int
00037 ACE_Registry::Name_Component::operator!= (const Name_Component &rhs) const
00038 {
00039 return !this->operator== (rhs);
00040 }
00041
00042
00043 ACE_Registry::Binding::Binding ()
00044 : name_ (),
00045 type_ (INVALID)
00046 {
00047 }
00048
00049
00050
00051
00052 ACE_Registry::Binding::Binding (const Name &name,
00053 Binding_Type type)
00054 : name_ (ACE_Registry::make_string (name)),
00055 type_ (type)
00056 {
00057 }
00058
00059
00060
00061
00062 ACE_Registry::Binding::Binding (const ACE_TString &name,
00063 Binding_Type type)
00064 : name_ (name),
00065 type_ (type)
00066 {
00067 }
00068
00069
00070 int
00071 ACE_Registry::Binding::operator== (const Binding &rhs) const
00072 {
00073 return
00074 rhs.name_ == this->name_ &&
00075 rhs.type_ == this->type_;
00076 }
00077
00078 int
00079 ACE_Registry::Binding::operator!= (const Binding &rhs) const
00080 {
00081 return !this->operator== (rhs);
00082 }
00083
00084
00085
00086 void
00087 ACE_Registry::Binding::name (Name &name)
00088 {
00089 name = ACE_Registry::make_name (this->name_);
00090 }
00091
00092
00093
00094
00095 void
00096 ACE_Registry::Binding::name (ACE_TString &name)
00097 {
00098 name = this->name_;
00099 }
00100
00101
00102
00103
00104 ACE_TString
00105 ACE_Registry::Binding::name (void)
00106 {
00107 return this->name_;
00108 }
00109
00110
00111
00112 ACE_Registry::Binding_Type
00113 ACE_Registry::Binding::type (void)
00114 {
00115 return this->type_;
00116 }
00117
00118
00119
00120 ACE_Registry::Object::Object (void *data,
00121 u_long size,
00122 u_long type)
00123 : data_ (data),
00124 size_ (size),
00125 type_ (type)
00126 {
00127 }
00128
00129
00130 void
00131 ACE_Registry::Object::data (void *data)
00132 {
00133 this->data_ = data;
00134 }
00135
00136
00137 void *
00138 ACE_Registry::Object::data (void) const
00139 {
00140 return this->data_;
00141 }
00142
00143
00144 void
00145 ACE_Registry::Object::size (u_long size)
00146 {
00147 this->size_ = size;
00148 }
00149
00150
00151 u_long
00152 ACE_Registry::Object::size (void) const
00153 {
00154 return this->size_;
00155 }
00156
00157
00158 void
00159 ACE_Registry::Object::type (u_long type)
00160 {
00161 this->type_ = type;
00162 }
00163
00164
00165 u_long
00166 ACE_Registry::Object::type (void) const
00167 {
00168 return this->type_;
00169 }
00170
00171
00172
00173 ACE_Registry::Naming_Context::Naming_Context (void)
00174 : key_ ((HKEY) 0),
00175 parent_key_ ((HKEY) 0),
00176 name_ ()
00177 {
00178 }
00179
00180
00181
00182 ACE_Registry::Naming_Context::Naming_Context (const HKEY &key)
00183 : key_ (key),
00184 parent_key_ ((HKEY) 0),
00185 name_ ()
00186 {
00187 }
00188
00189
00190 ACE_Registry::Naming_Context::Naming_Context (const Naming_Context &rhs)
00191 : key_ (rhs.key_),
00192 parent_key_ (rhs.parent_key_),
00193 name_ (rhs.name_)
00194 {
00195
00196
00197
00198 }
00199
00200
00201 const ACE_Registry::Naming_Context &
00202 ACE_Registry::Naming_Context::operator= (const Naming_Context &rhs)
00203 {
00204 ACE_UNUSED_ARG(rhs);
00205
00206
00207 return *this;
00208 }
00209
00210
00211
00212 ACE_Registry::Naming_Context::~Naming_Context ()
00213 {
00214 this->close ();
00215 }
00216
00217
00218
00219
00220 int
00221 ACE_Registry::Naming_Context::bind_new (const Name &name,
00222 const Object &object)
00223 {
00224 return this->bind_new (ACE_Registry::make_string (name), object);
00225 }
00226
00227
00228
00229
00230 int
00231 ACE_Registry::Naming_Context::bind_new (const ACE_TString &name,
00232 const Object &object)
00233 {
00234
00235 Object temp;
00236 long result = this->resolve (name, temp);
00237 if (result == 0)
00238
00239 result = -1;
00240 else
00241
00242 result = this->bind (name, object);
00243 return result;
00244 }
00245
00246
00247
00248
00249 int
00250 ACE_Registry::Naming_Context::bind (const Name &name,
00251 const Object &object)
00252 {
00253 return this->bind (ACE_Registry::make_string (name), object);
00254 }
00255
00256
00257
00258
00259 int
00260 ACE_Registry::Naming_Context::bind (const ACE_TString &name,
00261 const Object &object)
00262 {
00263 long result = ACE_TEXT_RegSetValueEx (this->key_,
00264 name.c_str (),
00265 0,
00266 object.type (),
00267 (const BYTE *) object.data (),
00268 object.size ());
00269 ACE_REGISTRY_CALL_RETURN (result);
00270 }
00271
00272
00273
00274
00275 int
00276 ACE_Registry::Naming_Context::rebind (const Name &name,
00277 const Object &new_object)
00278 {
00279 return this->rebind (ACE_Registry::make_string (name), new_object);
00280 }
00281
00282
00283
00284
00285 int
00286 ACE_Registry::Naming_Context::rebind (const ACE_TString &name,
00287 const Object &new_object)
00288 {
00289 Object old_object;
00290
00291 long result = this->resolve (name, old_object);
00292 if (result == 0)
00293
00294 result = this->bind (name, new_object);
00295 return result;
00296 }
00297
00298
00299
00300
00301 int
00302 ACE_Registry::Naming_Context::resolve (const Name &name,
00303 Object &object)
00304 {
00305 return this->resolve (ACE_Registry::make_string (name), object);
00306 }
00307
00308
00309
00310
00311 int
00312 ACE_Registry::Naming_Context::resolve (const ACE_TString &name,
00313 Object &object)
00314 {
00315
00316 u_long type;
00317 void *data = object.data ();
00318 u_long size = object.size ();
00319
00320 long result = ACE_TEXT_RegQueryValueEx (this->key_,
00321 name.c_str (),
00322 0,
00323 &type,
00324 (BYTE *)data,
00325 &size);
00326 if (result == ERROR_SUCCESS)
00327 {
00328
00329
00330 object.type (type);
00331 object.size (size);
00332 }
00333
00334 ACE_REGISTRY_CALL_RETURN (result);
00335 }
00336
00337
00338
00339
00340 int
00341 ACE_Registry::Naming_Context::unbind (const Name &name)
00342 {
00343 return this->unbind (ACE_Registry::make_string (name));
00344 }
00345
00346
00347
00348
00349 int
00350 ACE_Registry::Naming_Context::unbind (const ACE_TString &name)
00351 {
00352 long result = ACE_TEXT_RegDeleteValue (this->key_,
00353 name.c_str ());
00354
00355 ACE_REGISTRY_CALL_RETURN (result);
00356 }
00357
00358
00359
00360
00361 int
00362 ACE_Registry::Naming_Context::new_context (Naming_Context &naming_context)
00363 {
00364
00365 return naming_context.close ();
00366 }
00367
00368
00369
00370
00371 int
00372 ACE_Registry::Naming_Context::bind_new_context (const Name &name,
00373 Naming_Context &naming_context,
00374 u_long persistence,
00375 u_long security_access,
00376 LPSECURITY_ATTRIBUTES security_attributes)
00377 {
00378 return this->bind_new_context (ACE_Registry::make_string (name),
00379 naming_context,
00380 persistence,
00381 security_access,
00382 security_attributes);
00383 }
00384
00385
00386
00387
00388 int
00389 ACE_Registry::Naming_Context::bind_new_context (const ACE_TString &name,
00390 Naming_Context &naming_context,
00391 u_long persistence,
00392 u_long security_access,
00393 LPSECURITY_ATTRIBUTES security_attributes)
00394 {
00395 u_long reason;
00396
00397 long result = ACE_TEXT_RegCreateKeyEx (this->key_,
00398 name.c_str (),
00399 0,
00400 0,
00401 persistence,
00402 security_access,
00403 security_attributes,
00404 &naming_context.key_,
00405 &reason);
00406 if (result == ERROR_SUCCESS)
00407
00408 {
00409 if (reason == REG_CREATED_NEW_KEY)
00410
00411 {
00412
00413 naming_context.parent (this->key_);
00414
00415 naming_context.name (name);
00416 }
00417 else
00418
00419
00420 {
00421
00422 result = -1;
00423
00424 ::RegCloseKey (naming_context.key_);
00425
00426 naming_context.key_ = (HKEY) 0;
00427 }
00428 }
00429
00430 ACE_REGISTRY_CALL_RETURN (result);
00431 }
00432
00433
00434
00435
00436 int
00437 ACE_Registry::Naming_Context::bind_context (const Name &name,
00438 Naming_Context &naming_context,
00439 u_long persistence,
00440 u_long security_access,
00441 LPSECURITY_ATTRIBUTES security_attributes)
00442 {
00443 return this->bind_context (ACE_Registry::make_string (name),
00444 naming_context,
00445 persistence,
00446 security_access,
00447 security_attributes);
00448 }
00449
00450
00451
00452
00453 int
00454 ACE_Registry::Naming_Context::bind_context (const ACE_TString &name,
00455 Naming_Context &naming_context,
00456 u_long persistence,
00457 u_long security_access,
00458 LPSECURITY_ATTRIBUTES security_attributes)
00459 {
00460 u_long reason;
00461
00462 long result = ACE_TEXT_RegCreateKeyEx (this->key_,
00463 name.c_str (),
00464 0,
00465 0,
00466 persistence,
00467 security_access,
00468 security_attributes,
00469 &naming_context.key_,
00470 &reason);
00471 if (result == ERROR_SUCCESS)
00472 {
00473
00474 naming_context.parent (this->key_);
00475
00476 naming_context.name (name);
00477 }
00478
00479 ACE_REGISTRY_CALL_RETURN (result);
00480 }
00481
00482
00483
00484
00485 int
00486 ACE_Registry::Naming_Context::rebind_context (const Name &name,
00487 Naming_Context &new_naming_context)
00488 {
00489 return this->rebind_context (ACE_Registry::make_string (name),
00490 new_naming_context);
00491 }
00492
00493
00494
00495
00496 int
00497 ACE_Registry::Naming_Context::rebind_context (const ACE_TString &name,
00498 Naming_Context &new_naming_context)
00499 {
00500 Naming_Context old_naming_context;
00501
00502 long result = this->resolve_context (name,
00503 old_naming_context);
00504 if (result == 0)
00505 {
00506
00507 result = this->unbind_context (name);
00508 if (result == 0)
00509 {
00510
00511
00512
00513 result = this->bind_new_context (name, new_naming_context);
00514 }
00515 }
00516 return result;
00517 }
00518
00519
00520
00521
00522 int
00523 ACE_Registry::Naming_Context::unbind_context (const Name &name)
00524 {
00525 return this->unbind_context (ACE_Registry::make_string (name));
00526 }
00527
00528
00529
00530
00531 int
00532 ACE_Registry::Naming_Context::unbind_context (const ACE_TString &name)
00533 {
00534 long result = ACE_TEXT_RegDeleteKey (this->key_,
00535 name.c_str ());
00536
00537 ACE_REGISTRY_CALL_RETURN (result);
00538 }
00539
00540
00541
00542
00543 int
00544 ACE_Registry::Naming_Context::resolve_context (const Name &name,
00545 Naming_Context &naming_context,
00546 u_long security_access)
00547 {
00548 return this->resolve_context (ACE_Registry::make_string (name),
00549 naming_context,
00550 security_access);
00551 }
00552
00553
00554
00555
00556 int
00557 ACE_Registry::Naming_Context::resolve_context (const ACE_TString &name,
00558 Naming_Context &naming_context,
00559 u_long security_access)
00560 {
00561 long result = ACE_TEXT_RegOpenKeyEx (this->key_,
00562 name.c_str (),
00563 0,
00564 security_access,
00565 &naming_context.key_);
00566 if (result == ERROR_SUCCESS)
00567 {
00568
00569 naming_context.parent (this->key_);
00570
00571 naming_context.name (name);
00572 }
00573
00574 ACE_REGISTRY_CALL_RETURN (result);
00575 }
00576
00577
00578
00579 int
00580 ACE_Registry::Naming_Context::destroy (void)
00581 {
00582
00583 long result = ACE_TEXT_RegDeleteKey (this->parent_key_,
00584 this->name_.c_str ());
00585
00586 ACE_REGISTRY_CALL_RETURN (result);
00587 }
00588
00589
00590
00591 int
00592 ACE_Registry::Naming_Context::flush (void)
00593 {
00594 long result = ::RegFlushKey (this->key_);
00595 ACE_REGISTRY_CALL_RETURN (result);
00596 }
00597
00598
00599
00600 int
00601 ACE_Registry::Naming_Context::close (void)
00602 {
00603 long result = this->key_ ? ::RegCloseKey (this->key_) : ERROR_SUCCESS;
00604 ACE_REGISTRY_CALL_RETURN (result);
00605 }
00606
00607
00608
00609 ACE_TString
00610 ACE_Registry::make_string (const Name &const_name)
00611 {
00612 ACE_TString string;
00613 Name &name = ACE_const_cast (Name &, const_name);
00614
00615
00616 for (Name::iterator iterator = name.begin ();
00617 iterator != name.end ();
00618 iterator++)
00619 {
00620 if (iterator != name.begin ())
00621
00622 string += ACE_Registry::STRING_SEPARATOR;
00623 const Name_Component &component = *iterator;
00624
00625 string += component.id_;
00626 }
00627
00628 return string;
00629 }
00630
00631
00632
00633 ACE_Registry::Name
00634 ACE_Registry::make_name (const ACE_TString &string)
00635 {
00636 ssize_t new_position = 0;
00637 ssize_t last_position = 0;
00638 Name name;
00639
00640
00641 while (new_position != ACE_TString::npos)
00642 {
00643 Name_Component component;
00644
00645 new_position = string.find (ACE_Registry::STRING_SEPARATOR, new_position);
00646 if (new_position != ACE_TString::npos)
00647
00648 {
00649
00650 component.id_ = string.substr (last_position,
00651 new_position - last_position);
00652
00653 new_position +=
00654 ACE_OS_String::strlen (ACE_Registry::STRING_SEPARATOR);
00655 }
00656 else
00657 {
00658
00659 component.id_ = string.substr (last_position);
00660 }
00661
00662 last_position = new_position;
00663
00664 name.insert (component);
00665 }
00666
00667 return name;
00668 }
00669
00670
00671
00672 void
00673 ACE_Registry::Naming_Context::key (HKEY key)
00674 {
00675 this->key_ = key;
00676 }
00677
00678
00679
00680 HKEY
00681 ACE_Registry::Naming_Context::key (void)
00682 {
00683 return this->key_;
00684 }
00685
00686
00687
00688 void
00689 ACE_Registry::Naming_Context::parent (HKEY parent)
00690 {
00691 this->parent_key_ = parent;
00692 }
00693
00694
00695
00696 HKEY
00697 ACE_Registry::Naming_Context::parent (void)
00698 {
00699 return this->parent_key_;
00700 }
00701
00702
00703
00704
00705 void
00706 ACE_Registry::Naming_Context::name (const Name &name)
00707 {
00708 this->name_ = ACE_Registry::make_string (name);
00709 }
00710
00711
00712
00713
00714 void
00715 ACE_Registry::Naming_Context::name (Name &name)
00716 {
00717 name = ACE_Registry::make_name (this->name_);
00718 }
00719
00720
00721
00722
00723 void
00724 ACE_Registry::Naming_Context::name (const ACE_TString &name)
00725 {
00726 this->name_ = name;
00727 }
00728
00729
00730
00731
00732 ACE_TString
00733 ACE_Registry::Naming_Context::name (void)
00734 {
00735 return this->name_;
00736 }
00737
00738
00739
00740
00741 void
00742 ACE_Registry::Naming_Context::name (ACE_TString &name)
00743 {
00744 name = this->name_;
00745 }
00746
00747
00748
00749
00750
00751
00752 int
00753 ACE_Registry::Naming_Context::list (u_long how_many,
00754 Binding_List &list,
00755 Binding_Iterator &iter)
00756 {
00757
00758 static const ACE_Registry::Binding_List empty_list;
00759
00760 list = empty_list;
00761
00762
00763 iter.reset ();
00764
00765
00766 iter.naming_context (*this);
00767
00768
00769 iter.current_enumeration (iter.object_iteration_);
00770
00771
00772 long result = iter.next_n (how_many,
00773 list);
00774 return result;
00775 }
00776
00777
00778
00779
00780 int
00781 ACE_Registry::Naming_Context::list (Binding_List &list)
00782 {
00783
00784 static const ACE_Registry::Binding_List empty_list;
00785
00786 list = empty_list;
00787
00788
00789 ACE_Registry::Binding_Iterator iterator;
00790
00791
00792 iterator.naming_context (*this);
00793
00794
00795 iterator.current_enumeration (iterator.object_iteration_);
00796
00797 long result = 0;
00798 while (1)
00799 {
00800 ACE_Registry::Binding binding;
00801 result = iterator.next_one (binding);
00802 if (result == 0)
00803 list.insert (binding);
00804 else
00805 break;
00806 }
00807 return 0;
00808 }
00809
00810
00811
00812 ACE_Registry::Binding_Iterator::Binding_Iterator ()
00813 : object_iteration_ (*this),
00814 context_iteration_ (*this),
00815 iteration_complete_ (*this)
00816 {
00817 this->reset ();
00818 }
00819
00820
00821 void
00822 ACE_Registry::Binding_Iterator::reset ()
00823 {
00824 this->current_enumeration_ = &this->iteration_complete_;
00825 this->iteration_complete_.reset ();
00826 this->object_iteration_.reset ();
00827 this->context_iteration_.reset ();
00828 }
00829
00830
00831 void
00832 ACE_Registry::Binding_Iterator::Iteration_State::reset ()
00833 {
00834 this->index_ = 0;
00835 }
00836
00837
00838 ACE_Registry::Binding_Iterator::Iteration_State::Iteration_State (Binding_Iterator &iter)
00839 : parent_ (&iter),
00840 index_ (0)
00841 {
00842 }
00843
00844
00845 ACE_Registry::Binding_Iterator::Object_Iteration::Object_Iteration (Binding_Iterator &iter)
00846 : Iteration_State (iter)
00847 {
00848 }
00849
00850
00851 ACE_Registry::Binding_Iterator::Context_Iteration::Context_Iteration (Binding_Iterator &iter)
00852 : Iteration_State (iter)
00853 {
00854 }
00855
00856
00857 ACE_Registry::Binding_Iterator::Iteration_Complete::Iteration_Complete (Binding_Iterator &iter)
00858 : Iteration_State (iter)
00859 {
00860 }
00861
00862
00863
00864 int
00865 ACE_Registry::Binding_Iterator::next_one (Binding &binding)
00866 {
00867 u_long how_many = 1;
00868 Binding_List list;
00869
00870
00871 long result = this->next_n (how_many, list);
00872
00873 if (result == 0)
00874
00875 binding = (*list.begin ());
00876
00877 return result;
00878 }
00879
00880
00881
00882 int
00883 ACE_Registry::Binding_Iterator::next_n (u_long how_many,
00884 Binding_List &list)
00885 {
00886
00887 static const ACE_Registry::Binding_List empty_list;
00888
00889 list = empty_list;
00890
00891 return this->current_enumeration_->next_n (how_many, list);
00892 }
00893
00894
00895
00896 int
00897 ACE_Registry::Binding_Iterator::destroy (void)
00898 {
00899 this->reset ();
00900 return 0;
00901 }
00902
00903
00904
00905 void
00906 ACE_Registry::Binding_Iterator::naming_context (Naming_Context &naming_context)
00907 {
00908 this->naming_context_ = &naming_context;
00909 }
00910
00911
00912 ACE_Registry::Naming_Context &
00913 ACE_Registry::Binding_Iterator::naming_context (void)
00914 {
00915 return *this->naming_context_;
00916 }
00917
00918
00919
00920 void
00921 ACE_Registry::Binding_Iterator::current_enumeration (Iteration_State ¤t_enumeration)
00922 {
00923 this->current_enumeration_ = ¤t_enumeration;
00924 }
00925
00926
00927 ACE_Registry::Binding_Iterator::Iteration_State &
00928 ACE_Registry::Binding_Iterator::current_enumeration (void)
00929 {
00930 return *this->current_enumeration_;
00931 }
00932
00933
00934 int
00935 ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many,
00936 Binding_List &list)
00937 {
00938
00939 u_long requested = how_many;
00940
00941
00942 while (how_many > 0)
00943 {
00944 ACE_TCHAR string [ACE_Registry::Naming_Context::MAX_OBJECT_NAME_SIZE];
00945 u_long size = sizeof string / sizeof (ACE_TCHAR);
00946 long result = ACE_TEXT_RegEnumValue (this->parent_->naming_context ().key (),
00947 this->index_,
00948 string,
00949 &size,
00950 0,
00951 0,
00952 0,
00953 0);
00954 switch (result)
00955 {
00956 case ERROR_SUCCESS:
00957
00958 {
00959
00960 this->index_++;
00961 how_many--;
00962
00963
00964
00965 Binding binding (string, OBJECT);
00966
00967 list.insert (binding);
00968 }
00969
00970 break;
00971
00972 case ERROR_NO_MORE_ITEMS:
00973
00974
00975 this->index_ = 0;
00976
00977
00978 this->parent_->current_enumeration (this->parent_->context_iteration_);
00979 result = this->parent_->current_enumeration ().next_n (how_many,
00980 list);
00981
00982 if (requested != how_many)
00983 return 0;
00984 else
00985 return result;
00986
00987 default:
00988
00989
00990 this->index_ = 0;
00991
00992 this->parent_->current_enumeration (this->parent_->iteration_complete_);
00993
00994 return -1;
00995 }
00996 }
00997
00998
00999
01000 return 0;
01001 }
01002
01003
01004 int
01005 ACE_Registry::Binding_Iterator::Context_Iteration::next_n (u_long how_many,
01006 Binding_List &list)
01007 {
01008
01009 u_long requested = how_many;
01010
01011
01012 while (how_many > 0)
01013 {
01014 ACE_TCHAR string [ACE_Registry::Naming_Context::MAX_CONTEXT_NAME_SIZE];
01015 u_long size = sizeof string / sizeof (ACE_TCHAR);
01016 long result = ACE_TEXT_RegEnumKeyEx (this->parent_->naming_context (). key (),
01017 this->index_,
01018 string,
01019 &size,
01020 0,
01021 0,
01022 0,
01023 0);
01024 switch (result)
01025 {
01026 case ERROR_SUCCESS:
01027
01028 {
01029
01030 this->index_++;
01031 how_many--;
01032
01033
01034
01035 Binding binding (string, CONTEXT);
01036
01037 list.insert (binding);
01038 }
01039
01040 break;
01041
01042 case ERROR_NO_MORE_ITEMS:
01043
01044
01045
01046
01047 default:
01048
01049
01050
01051 this->index_ = 0;
01052
01053 this->parent_->current_enumeration (this->parent_->iteration_complete_);
01054
01055
01056 if (requested != how_many)
01057 return 0;
01058 else
01059 return -1;
01060 }
01061 }
01062
01063
01064
01065 return 0;
01066 }
01067
01068
01069 int
01070 ACE_Registry::Binding_Iterator::Iteration_Complete::next_n (u_long how_many,
01071 Binding_List &list)
01072 {
01073 ACE_UNUSED_ARG(list);
01074 ACE_UNUSED_ARG(how_many);
01075
01076
01077 return -1;
01078 }
01079
01080
01081
01082
01083
01084
01085
01086 int
01087 ACE_Predefined_Naming_Contexts::connect (ACE_Registry::Naming_Context &naming_context,
01088 HKEY predefined,
01089 const ACE_TCHAR *machine_name)
01090 {
01091 #if defined (ACE_HAS_WINCE)
01092 return -1;
01093 #else
01094 long result = -1;
01095
01096 if (machine_name != 0 && ACE_OS::strcmp (ACE_LIB_TEXT ("localhost"), machine_name) == 0)
01097 machine_name = 0;
01098
01099 if (predefined == HKEY_LOCAL_MACHINE || predefined == HKEY_USERS)
01100 result = ACE_TEXT_RegConnectRegistry (ACE_const_cast(ACE_TCHAR *, machine_name),
01101 predefined,
01102 &naming_context.key_);
01103 if (predefined == HKEY_CURRENT_USER || predefined == HKEY_CLASSES_ROOT)
01104
01105 if (machine_name == 0 ||
01106 ACE_Predefined_Naming_Contexts::is_local_host (machine_name))
01107 {
01108 naming_context.key_ = predefined;
01109 result = 0;
01110 }
01111 else
01112 result = -1;
01113
01114 ACE_REGISTRY_CALL_RETURN (result);
01115 #endif // ACE_HAS_WINCE
01116 }
01117
01118
01119
01120 int
01121 ACE_Predefined_Naming_Contexts::is_local_host (const ACE_TCHAR *machine_name)
01122 {
01123 ACE_TCHAR local_host[MAXHOSTNAMELEN];
01124 int result = ACE_OS::hostname (local_host, sizeof local_host / sizeof (ACE_TCHAR));
01125 if (result == 0)
01126 result = !ACE_OS::strcmp (local_host, machine_name);
01127 else
01128 result = 0;
01129 return result;
01130 }
01131
01132 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
01133 template class ACE_Node<ACE_Registry::Binding>;
01134 template class ACE_Unbounded_Set<ACE_Registry::Binding>;
01135 template class ACE_Unbounded_Set_Iterator<ACE_Registry::Binding>;
01136 template class ACE_Node<ACE_Registry::Name_Component>;
01137 template class ACE_Unbounded_Set<ACE_Registry::Name_Component>;
01138 template class ACE_Unbounded_Set_Iterator<ACE_Registry::Name_Component>;
01139 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
01140 #pragma instantiate ACE_Node<ACE_Registry::Binding>
01141 #pragma instantiate ACE_Unbounded_Set<ACE_Registry::Binding>
01142 #pragma instantiate ACE_Unbounded_Set_Iterator<ACE_Registry::Binding>
01143 #pragma instantiate ACE_Node<ACE_Registry::Name_Component>
01144 #pragma instantiate ACE_Unbounded_Set<ACE_Registry::Name_Component>
01145 #pragma instantiate ACE_Unbounded_Set_Iterator<ACE_Registry::Name_Component>
01146 #endif
01147
01148 #endif