00001 #include "ace/Parse_Node.h"
00002
00003 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
00004
00005 #include "ace/Service_Config.h"
00006 #include "ace/Service_Repository.h"
00007 #include "ace/Service_Types.h"
00008 #include "ace/Task.h"
00009 #include "ace/DLL.h"
00010 #include "ace/ACE.h"
00011 #include "ace/OS_NS_string.h"
00012 #include "ace/ARGV.h"
00013
00014 #include <list>
00015
00016 ACE_RCSID (ace,
00017 Parse_Node,
00018 "$Id: Parse_Node.cpp 86389 2009-08-05 23:35:46Z shuston $")
00019
00020 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00021
00022 ACE_ALLOC_HOOK_DEFINE (ACE_Stream_Node)
00023
00024
00025
00026
00027 void
00028 ACE_Stream_Node::dump (void) const
00029 {
00030 #if defined (ACE_HAS_DUMP)
00031 ACE_TRACE ("ACE_Stream_Node::dump");
00032 #endif
00033 }
00034
00035 void
00036 ACE_Stream_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
00037 {
00038 ACE_TRACE ("ACE_Stream_Node::apply");
00039
00040 const ACE_Service_Type *sst = this->node_->record (config);
00041 if (sst == 0)
00042 const_cast<ACE_Static_Node *> (this->node_)->apply (config, yyerrno);
00043
00044 if (yyerrno != 0) return;
00045
00046 sst = this->node_->record (config);
00047 ACE_Stream_Type *st =
00048 dynamic_cast<ACE_Stream_Type *> (const_cast<ACE_Service_Type_Impl *> (sst->type ()));
00049
00050
00051
00052
00053
00054 std::list<const ACE_Static_Node *> mod_list;
00055 const ACE_Static_Node *module;
00056 for (module = dynamic_cast<const ACE_Static_Node*> (this->mods_);
00057 module != 0;
00058 module = dynamic_cast<ACE_Static_Node*> (module->link()))
00059 mod_list.push_front (module);
00060
00061 std::list<const ACE_Static_Node *>::const_iterator iter;
00062 for (iter = mod_list.begin (); iter != mod_list.end (); ++iter)
00063 {
00064 module = *iter;
00065 ACE_ARGV args (module->parameters ());
00066
00067 const ACE_Service_Type *mst = module->record (config);
00068 if (mst == 0)
00069 const_cast<ACE_Static_Node *> (module)->apply (config, yyerrno);
00070
00071 if (yyerrno != 0)
00072 {
00073 if (ACE::debug ())
00074 {
00075 ACE_ERROR ((LM_ERROR,
00076 ACE_TEXT ("dynamic initialization failed for Module %s\n"),
00077 module->name ()));
00078 }
00079 ++yyerrno;
00080 continue;
00081 }
00082
00083 ACE_Module_Type const * const mt1 =
00084 static_cast <ACE_Module_Type const *> (module->record (config)->type());
00085
00086 ACE_Module_Type *mt = const_cast<ACE_Module_Type *>(mt1);
00087
00088 if (st->push (mt) == -1)
00089 {
00090 if (ACE::debug ())
00091 {
00092 ACE_ERROR ((LM_ERROR,
00093 ACE_TEXT ("dynamic initialization failed for Stream %s\n"),
00094 this->node_->name ()));
00095 }
00096 ++yyerrno;
00097 }
00098
00099 }
00100
00101 #ifndef ACE_NLOGGING
00102 if (ACE::debug ())
00103 ACE_DEBUG ((LM_DEBUG,
00104 ACE_TEXT ("(%P|%t) Did stream on %s, error = %d\n"),
00105 this->node_->name (),
00106 yyerrno));
00107 #endif
00108 }
00109
00110 ACE_ALLOC_HOOK_DEFINE (ACE_Parse_Node)
00111
00112 void
00113 ACE_Parse_Node::dump (void) const
00114 {
00115 #if defined (ACE_HAS_DUMP)
00116 ACE_TRACE ("ACE_Parse_Node::dump");
00117 #endif
00118 }
00119
00120 const ACE_TCHAR *
00121 ACE_Parse_Node::name (void) const
00122 {
00123 ACE_TRACE ("ACE_Parse_Node::name");
00124 return this->name_;
00125 }
00126
00127 ACE_Parse_Node *
00128 ACE_Parse_Node::link (void) const
00129 {
00130 ACE_TRACE ("ACE_Parse_Node::link");
00131 return this->next_;
00132 }
00133
00134 void
00135 ACE_Parse_Node::link (ACE_Parse_Node *n)
00136 {
00137 ACE_TRACE ("ACE_Parse_Node::link");
00138
00139
00140 ACE_Parse_Node *t = this;
00141 while (t->next_ != 0)
00142 t = t->next_;
00143
00144
00145 t->next_ = n;
00146 }
00147
00148 ACE_Stream_Node::ACE_Stream_Node (const ACE_Static_Node *str_ops,
00149 const ACE_Parse_Node *str_mods)
00150 : ACE_Parse_Node ((str_ops == 0 ? ACE_TEXT ("<unknown>") : str_ops->name ())),
00151 node_ (str_ops),
00152 mods_ (str_mods)
00153 {
00154 ACE_TRACE ("ACE_Stream_Node::ACE_Stream_Node");
00155 }
00156
00157
00158 ACE_Stream_Node::~ACE_Stream_Node (void)
00159 {
00160 ACE_TRACE ("ACE_Stream_Node::~ACE_Stream_Node");
00161 ACE_Static_Node *n = const_cast<ACE_Static_Node *> (this->node_);
00162 delete n;
00163 ACE_Parse_Node *m = const_cast<ACE_Parse_Node *> (this->mods_);
00164 delete m;
00165 }
00166
00167 ACE_Parse_Node::ACE_Parse_Node (void)
00168 : name_ (0),
00169 next_ (0)
00170 {
00171 ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node");
00172 }
00173
00174
00175 ACE_Parse_Node::ACE_Parse_Node (const ACE_TCHAR *nm)
00176 : name_ (ACE::strnew (nm)),
00177 next_ (0)
00178 {
00179 ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node");
00180 }
00181
00182 void
00183 ACE_Parse_Node::print (void) const
00184 {
00185 ACE_TRACE ("ACE_Parse_Node::print");
00186
00187 ACE_DEBUG ((LM_DEBUG,
00188 ACE_TEXT ("svc = %s\n"),
00189 this->name ()));
00190
00191 if (this->next_)
00192 this->next_->print ();
00193 }
00194
00195
00196 ACE_Parse_Node::~ACE_Parse_Node (void)
00197 {
00198 ACE_TRACE ("ACE_Parse_Node::~ACE_Parse_Node");
00199 delete[] const_cast<ACE_TCHAR*> (this->name_);
00200 delete this->next_;
00201 }
00202
00203 ACE_ALLOC_HOOK_DEFINE (ACE_Suspend_Node)
00204
00205 void
00206 ACE_Suspend_Node::dump (void) const
00207 {
00208 #if defined (ACE_HAS_DUMP)
00209 ACE_TRACE ("ACE_Suspend_Node::dump");
00210 #endif
00211 }
00212
00213 ACE_Suspend_Node::ACE_Suspend_Node (const ACE_TCHAR *name)
00214 : ACE_Parse_Node (name)
00215 {
00216 ACE_TRACE ("ACE_Suspend_Node::ACE_Suspend_Node");
00217 }
00218
00219 ACE_Suspend_Node::~ACE_Suspend_Node (void)
00220 {
00221 }
00222
00223 ACE_ALLOC_HOOK_DEFINE (ACE_Resume_Node)
00224
00225 void
00226 ACE_Resume_Node::dump (void) const
00227 {
00228 #if defined (ACE_HAS_DUMP)
00229 ACE_TRACE ("ACE_Resume_Node::dump");
00230 #endif
00231 }
00232
00233 ACE_Resume_Node::ACE_Resume_Node (const ACE_TCHAR *name)
00234 : ACE_Parse_Node (name)
00235 {
00236 ACE_TRACE ("ACE_Resume_Node::ACE_Resume_Node");
00237 }
00238
00239 ACE_Resume_Node::~ACE_Resume_Node (void)
00240 {
00241 }
00242
00243 void
00244 ACE_Suspend_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
00245 {
00246 ACE_TRACE ("ACE_Suspend_Node::apply");
00247
00248 if (config->suspend (this->name ()) == -1)
00249 ++yyerrno;
00250
00251 #ifndef ACE_NLOGGING
00252 if (ACE::debug ())
00253 ACE_DEBUG ((LM_DEBUG,
00254 ACE_TEXT ("did suspend on %s, error = %d\n"),
00255 this->name (),
00256 yyerrno));
00257 #endif
00258 }
00259
00260 void
00261 ACE_Resume_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
00262 {
00263 ACE_TRACE ("ACE_Resume_Node::apply");
00264
00265 if (config->resume (this->name ()) == -1)
00266 ++yyerrno;
00267
00268 #ifndef ACE_NLOGGING
00269 if (ACE::debug ())
00270 ACE_DEBUG ((LM_DEBUG,
00271 ACE_TEXT ("did resume on %s, error = %d\n"),
00272 this->name (),
00273 yyerrno));
00274 #endif
00275 }
00276
00277 ACE_ALLOC_HOOK_DEFINE (ACE_Remove_Node)
00278
00279 void
00280 ACE_Remove_Node::dump (void) const
00281 {
00282 #if defined (ACE_HAS_DUMP)
00283 ACE_TRACE ("ACE_Remove_Node::dump");
00284 #endif
00285 }
00286
00287 ACE_Remove_Node::ACE_Remove_Node (const ACE_TCHAR *name)
00288 : ACE_Parse_Node (name)
00289 {
00290 ACE_TRACE ("ACE_Remove_Node::ACE_Remove_Node");
00291 }
00292
00293 ACE_Remove_Node::~ACE_Remove_Node (void)
00294 {
00295 }
00296
00297 void
00298 ACE_Remove_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
00299 {
00300 ACE_TRACE ("ACE_Remove_Node::apply");
00301
00302 if (config->remove (this->name ()) == -1)
00303 ++yyerrno;
00304
00305 #ifndef ACE_NLOGGING
00306 if (ACE::debug ())
00307 ACE_DEBUG ((LM_DEBUG,
00308 ACE_TEXT ("ACE (%P|%t) Remove_Node::apply")
00309 ACE_TEXT (" - did remove on %s, error = %d\n"),
00310 this->name (),
00311 yyerrno));
00312 #endif
00313 }
00314
00315
00316 ACE_Dynamic_Node::ACE_Dynamic_Node (ACE_Service_Type_Factory const *stf,
00317 ACE_TCHAR *parms)
00318 : ACE_Static_Node (stf->name (), parms)
00319 , factory_ (stf)
00320 {
00321 ACE_TRACE ("ACE_Dynamic_Node::ACE_Dynamic_Node");
00322 }
00323
00324 void
00325 ACE_Dynamic_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
00326 {
00327 ACE_TRACE ("ACE_Dynamic_Node::apply");
00328
00329 if (config->initialize (this->factory_.get (),
00330 this->parameters ()) == -1)
00331 ++yyerrno;
00332
00333 #ifndef ACE_NLOGGING
00334 if (ACE::debug ())
00335 ACE_DEBUG ((LM_DEBUG,
00336 ACE_TEXT ("ACE (%P|%t) Dynamic_Node::apply")
00337 ACE_TEXT (" - Did dynamic on %s (yyerrno=%d)\n"),
00338 this->name (),
00339 yyerrno));
00340 #endif
00341 }
00342
00343 ACE_ALLOC_HOOK_DEFINE (ACE_Dynamic_Node)
00344
00345 void
00346 ACE_Dynamic_Node::dump (void) const
00347 {
00348 #if defined (ACE_HAS_DUMP)
00349 ACE_TRACE ("ACE_Dynamic_Node::dump");
00350 #endif
00351 }
00352
00353 ACE_Dynamic_Node::~ACE_Dynamic_Node (void)
00354 {
00355 ACE_TRACE ("ACE_Dynamic_Node::~ACE_Dynamic_Node");
00356 }
00357
00358 ACE_ALLOC_HOOK_DEFINE (ACE_Static_Node)
00359
00360 void
00361 ACE_Static_Node::dump (void) const
00362 {
00363 #if defined (ACE_HAS_DUMP)
00364 ACE_TRACE ("ACE_Static_Node::dump");
00365 #endif
00366 }
00367
00368 ACE_Static_Node::ACE_Static_Node (const ACE_TCHAR *nm,
00369 ACE_TCHAR *params)
00370 : ACE_Parse_Node (nm),
00371 parameters_ (ACE::strnew (params))
00372 {
00373 ACE_TRACE ("ACE_Static_Node::ACE_Static_Node");
00374 }
00375
00376 const ACE_Service_Type *
00377 ACE_Static_Node::record (const ACE_Service_Gestalt *config) const
00378 {
00379 ACE_TRACE ("ACE_Static_Node::record");
00380 ACE_Service_Type *sr = 0;
00381
00382 if (config->find (this->name (), (const ACE_Service_Type **) &sr) == -1)
00383 return 0;
00384
00385 return sr;
00386 }
00387
00388 ACE_TCHAR *
00389 ACE_Static_Node::parameters (void) const
00390 {
00391 ACE_TRACE ("ACE_Static_Node::parameters");
00392 return this->parameters_;
00393 }
00394
00395 void
00396 ACE_Static_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
00397 {
00398 ACE_TRACE ("ACE_Static_Node::apply");
00399 if (config->initialize (this->name (),
00400 this->parameters ()) == -1)
00401 ++yyerrno;
00402
00403 #ifndef ACE_NLOGGING
00404 if (ACE::debug ())
00405 ACE_DEBUG ((LM_DEBUG,
00406 ACE_TEXT ("ACE (%P|%t) Static_Node::apply -")
00407 ACE_TEXT (" Did static on %s (yyerrno=%d)\n"),
00408 this->name (),
00409 yyerrno));
00410 #endif
00411 }
00412
00413 ACE_Static_Node::~ACE_Static_Node (void)
00414 {
00415 ACE_TRACE ("ACE_Static_Node::~ACE_Static_Node");
00416 delete[] this->parameters_;
00417 }
00418
00419
00420 ACE_ALLOC_HOOK_DEFINE (ACE_Location_Node)
00421
00422 void
00423 ACE_Location_Node::dump (void) const
00424 {
00425 #if defined (ACE_HAS_DUMP)
00426 ACE_TRACE ("ACE_Location_Node::dump");
00427 #endif
00428 }
00429
00430 ACE_Location_Node::ACE_Location_Node (void)
00431 : pathname_ (0),
00432 dll_ (),
00433 symbol_ (0)
00434 {
00435 ACE_TRACE ("ACE_Location_Node::ACE_Location_Node");
00436 }
00437
00438 ACE_Location_Node::~ACE_Location_Node (void)
00439 {
00440 ACE_TRACE ("ACE_Location_Node::~ACE_Location_Node");
00441 }
00442
00443 const ACE_DLL &
00444 ACE_Location_Node::dll (void)
00445 {
00446 return this->dll_;
00447 }
00448
00449 const ACE_TCHAR *
00450 ACE_Location_Node::pathname (void) const
00451 {
00452 ACE_TRACE ("ACE_Location_Node::pathname");
00453 return this->pathname_;
00454 }
00455
00456 void
00457 ACE_Location_Node::pathname (const ACE_TCHAR *p)
00458 {
00459 ACE_TRACE ("ACE_Location_Node::pathname");
00460 this->pathname_ = p;
00461 }
00462
00463 int
00464 ACE_Location_Node::dispose (void) const
00465 {
00466 ACE_TRACE ("ACE_Location_Node::dispose");
00467 return this->must_delete_;
00468 }
00469
00470 int
00471 ACE_Location_Node::open_dll (int & yyerrno)
00472 {
00473 ACE_TRACE ("ACE_Location_Node::open_dll");
00474
00475 #ifndef ACE_NLOGGING
00476 if (ACE::debug ())
00477 ACE_DEBUG ((LM_DEBUG,
00478 ACE_TEXT ("ACE (%P|%t) LN::open_dll - path=%s\n"),
00479 this->pathname ()));
00480 #endif
00481
00482 if (-1 == this->dll_.open (this->pathname ()))
00483 {
00484 ++yyerrno;
00485
00486 #ifndef ACE_NLOGGING
00487 if (ACE::debug ())
00488 {
00489 ACE_TCHAR *errmsg = this->dll_.error ();
00490 ACE_ERROR ((LM_ERROR,
00491 ACE_TEXT ("ACE (%P|%t) LN::open_dll - Failed to open %s: %s\n"),
00492 this->pathname (),
00493 errmsg ? errmsg : ACE_TEXT ("no error reported")));
00494 }
00495 #endif
00496
00497 return -1;
00498 }
00499
00500 return 0;
00501
00502 }
00503
00504 void
00505 ACE_Location_Node::set_symbol (void *s)
00506 {
00507 ACE_TRACE ("ACE_Location_Node::set_symbol");
00508 this->symbol_ = s;
00509 }
00510
00511 ACE_ALLOC_HOOK_DEFINE (ACE_Object_Node)
00512
00513 void
00514 ACE_Object_Node::dump (void) const
00515 {
00516 #if defined (ACE_HAS_DUMP)
00517 ACE_TRACE ("ACE_Object_Node::dump");
00518 #endif
00519 }
00520
00521 ACE_Object_Node::ACE_Object_Node (const ACE_TCHAR *path,
00522 const ACE_TCHAR *obj_name)
00523 : object_name_ (ACE::strnew (obj_name))
00524 {
00525 ACE_TRACE ("ACE_Object_Node::ACE_Object_Node");
00526 this->pathname (ACE::strnew (path));
00527 this->must_delete_ = 0;
00528 }
00529
00530 void *
00531 ACE_Object_Node::symbol (ACE_Service_Gestalt *,
00532 int &yyerrno,
00533 ACE_Service_Object_Exterminator *)
00534 {
00535 ACE_TRACE ("ACE_Object_Node::symbol");
00536 if (this->open_dll (yyerrno) == 0)
00537 {
00538 ACE_TCHAR *object_name = const_cast<ACE_TCHAR *> (this->object_name_);
00539
00540 this->symbol_ = this->dll_.symbol (object_name);
00541 if (this->symbol_ == 0)
00542 {
00543 ++yyerrno;
00544
00545 #ifndef ACE_NLOGGING
00546 if (ACE::debug ())
00547 {
00548 ACE_TCHAR *errmsg = this->dll_.error ();
00549 ACE_ERROR ((LM_ERROR,
00550 ACE_TEXT ("ACE (%P|%t) DLL::symbol -")
00551 ACE_TEXT (" Failed for object %s: %s\n"),
00552 object_name,
00553 errmsg ? errmsg : ACE_TEXT ("no error reported")));
00554 }
00555 #endif
00556
00557 return 0;
00558 }
00559
00560 return this->symbol_;
00561 }
00562
00563 return 0;
00564 }
00565
00566 ACE_Object_Node::~ACE_Object_Node (void)
00567 {
00568 ACE_TRACE ("ACE_Object_Node::~ACE_Object_Node");
00569 delete[] const_cast<ACE_TCHAR *> (this->object_name_);
00570 }
00571
00572 ACE_ALLOC_HOOK_DEFINE (ACE_Function_Node)
00573
00574 void
00575 ACE_Function_Node::dump (void) const
00576 {
00577 #if defined (ACE_HAS_DUMP)
00578 ACE_TRACE ("ACE_Function_Node::dump");
00579 #endif
00580 }
00581
00582 ACE_Function_Node::ACE_Function_Node (const ACE_TCHAR *path,
00583 const ACE_TCHAR *func_name)
00584 : function_name_ (make_func_name (func_name))
00585 {
00586 ACE_TRACE ("ACE_Function_Node::ACE_Function_Node");
00587 this->pathname (ACE::strnew (path));
00588 this->must_delete_ = 1;
00589 }
00590
00591 ACE_TCHAR *
00592 ACE_Function_Node::make_func_name (ACE_TCHAR const * func_name)
00593 {
00594
00595
00596
00597
00598 #if defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1
00599 # define ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING_IMPL(NAME) #NAME
00600 # define ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING(NAME) ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING_IMPL(NAME)
00601 # define ACE_VERSIONED_NAMESPACE_NAME_STRING ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING(ACE_VERSIONED_NAMESPACE_NAME)
00602
00603
00604
00605
00606
00607
00608
00609
00610 static ACE_TCHAR const make_prefix[] = ACE_TEXT ("_make_");
00611 static size_t const make_prefix_len =
00612 sizeof (make_prefix) / sizeof (make_prefix[0]) - 1;
00613
00614 if (ACE_OS::strncmp (make_prefix, func_name, make_prefix_len) == 0)
00615 {
00616 static ACE_TCHAR const versioned_namespace_name[] =
00617 ACE_TEXT (ACE_VERSIONED_NAMESPACE_NAME_STRING) ACE_TEXT("_") ;
00618
00619
00620
00621 static size_t const versioned_namespace_name_len =
00622 sizeof (versioned_namespace_name)
00623 / sizeof (versioned_namespace_name[0]);
00624
00625 size_t const len =
00626 ACE_OS::strlen (func_name)
00627 + versioned_namespace_name_len;
00628
00629
00630 ACE_TCHAR * mangled_func_name;
00631 ACE_NEW_RETURN (mangled_func_name,
00632 ACE_TCHAR[len],
00633 0);
00634
00635 ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> safe (mangled_func_name);
00636
00637 ACE_OS::snprintf (mangled_func_name,
00638 len,
00639 ACE_TEXT ("%s%s%s"),
00640 make_prefix,
00641 versioned_namespace_name,
00642 func_name + make_prefix_len);
00643
00644 return safe.release ();
00645 }
00646 #endif
00647
00648 return ACE::strnew (func_name);
00649 }
00650
00651 void *
00652 ACE_Function_Node::symbol (ACE_Service_Gestalt *,
00653 int &yyerrno,
00654 ACE_Service_Object_Exterminator *gobbler)
00655 {
00656 typedef ACE_Service_Object *(*ACE_Service_Factory_Ptr)
00657 (ACE_Service_Object_Exterminator *);
00658
00659 ACE_TRACE ("ACE_Function_Node::symbol");
00660 if (this->open_dll (yyerrno) == 0)
00661 {
00662 this->symbol_ = 0;
00663
00664
00665
00666 ACE_TCHAR * const function_name =
00667 const_cast<ACE_TCHAR *> (this->function_name_);
00668
00669 void * const func_p = this->dll_.symbol (function_name);
00670 if (func_p == 0)
00671 {
00672 ++yyerrno;
00673
00674 #ifndef ACE_NLOGGING
00675 if (ACE::debug ())
00676 {
00677 ACE_TCHAR * const errmsg = this->dll_.error ();
00678 ACE_ERROR ((LM_ERROR,
00679 ACE_TEXT ("DLL::symbol failed for function %s: ")
00680 ACE_TEXT ("%s\n"),
00681 function_name,
00682 errmsg ? errmsg : ACE_TEXT ("no error reported")));
00683 }
00684 #endif
00685
00686 return 0;
00687 }
00688
00689 #if defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64))
00690 int const temp_p = reinterpret_cast<int> (func_p);
00691 #else
00692 intptr_t const temp_p = reinterpret_cast<intptr_t> (func_p);
00693 #endif
00694
00695 ACE_Service_Factory_Ptr func =
00696 reinterpret_cast<ACE_Service_Factory_Ptr> (temp_p);
00697
00698
00699 this->symbol_ = (*func) (gobbler);
00700
00701 if (this->symbol_ == 0)
00702 {
00703 ++yyerrno;
00704 if (ACE::debug ())
00705 {
00706 ACE_ERROR ((LM_ERROR,
00707 ACE_TEXT ("%p\n"),
00708 this->function_name_));
00709 }
00710 return 0;
00711 }
00712 }
00713 return this->symbol_;
00714 }
00715
00716 ACE_Function_Node::~ACE_Function_Node (void)
00717 {
00718 ACE_TRACE ("ACE_Function_Node::~ACE_Function_Node");
00719 delete[] const_cast<ACE_TCHAR *> (function_name_);
00720 delete[] const_cast<ACE_TCHAR *> (pathname_);
00721 }
00722
00723 ACE_ALLOC_HOOK_DEFINE (ACE_Dummy_Node)
00724
00725 void
00726 ACE_Dummy_Node::dump (void) const
00727 {
00728 #if defined (ACE_HAS_DUMP)
00729 ACE_TRACE ("ACE_Dummy_Node::dump");
00730 #endif
00731 }
00732
00733 ACE_Dummy_Node::ACE_Dummy_Node (const ACE_Static_Node *static_node,
00734 const ACE_Parse_Node *str_mods)
00735 : ACE_Parse_Node (static_node->name ()),
00736 node_ (static_node),
00737 mods_ (str_mods)
00738 {
00739 ACE_TRACE ("ACE_Dummy_Node::ACE_Dummy_Node");
00740 }
00741
00742 void
00743 ACE_Dummy_Node::apply (ACE_Service_Gestalt *, int &yyerrno)
00744 {
00745 ACE_TRACE ("ACE_Dummy_Node::apply");
00746
00747 #ifndef ACE_NLOGGING
00748 if (ACE::debug ())
00749 ACE_DEBUG ((LM_DEBUG,
00750 ACE_TEXT ("did operations on stream %s, error = %d\n"),
00751 this->name (),
00752 yyerrno));
00753 #else
00754 ACE_UNUSED_ARG (yyerrno);
00755 #endif
00756 }
00757
00758 ACE_Dummy_Node::~ACE_Dummy_Node (void)
00759 {
00760 ACE_TRACE ("ACE_Dummy_Node::~ACE_Dummy_Node");
00761 ACE_Static_Node *n = const_cast<ACE_Static_Node *> (this->node_);
00762 delete n;
00763 ACE_Parse_Node *m = const_cast<ACE_Parse_Node *> (this->mods_);
00764 delete m;
00765 }
00766
00767 ACE_ALLOC_HOOK_DEFINE (ACE_Static_Function_Node)
00768
00769 void
00770 ACE_Static_Function_Node::dump (void) const
00771 {
00772 #if defined (ACE_HAS_DUMP)
00773 ACE_TRACE ("ACE_Static_Function_Node::dump");
00774 #endif
00775 }
00776
00777 ACE_Static_Function_Node::ACE_Static_Function_Node (const ACE_TCHAR *func_name)
00778 : function_name_ (ACE::strnew (func_name))
00779 {
00780 ACE_TRACE ("ACE_Static_Function_Node::ACE_Static_Function_Node");
00781 this->must_delete_ = 1;
00782 }
00783
00784 void *
00785 ACE_Static_Function_Node::symbol (ACE_Service_Gestalt *config,
00786 int &yyerrno,
00787 ACE_Service_Object_Exterminator *gobbler)
00788 {
00789 ACE_TRACE ("ACE_Static_Function_Node::symbol");
00790
00791 this->symbol_ = 0;
00792
00793
00794
00795
00796 ACE_Static_Svc_Descriptor *ssd = 0;
00797 if (config->find_static_svc_descriptor (this->function_name_, &ssd) == -1)
00798 {
00799 ++yyerrno;
00800 if (ACE::debug ())
00801 {
00802 ACE_ERROR ((LM_ERROR,
00803 ACE_TEXT ("(%P|%t) No static service ")
00804 ACE_TEXT ("registered for function %s\n"),
00805 this->function_name_));
00806 }
00807 return 0;
00808 }
00809
00810 if (ssd->alloc_ == 0)
00811 {
00812 ++yyerrno;
00813
00814 if (this->symbol_ == 0)
00815 {
00816 ++yyerrno;
00817
00818 if (ACE::debug ())
00819 {
00820 ACE_ERROR ((LM_ERROR,
00821 ACE_TEXT ("(%P|%t) No static service factory ")
00822 ACE_TEXT ("function registered for function %s\n"),
00823 this->function_name_));
00824 }
00825 return 0;
00826 }
00827 }
00828
00829
00830 this->symbol_ = (*ssd->alloc_) (gobbler);
00831
00832 if (this->symbol_ == 0)
00833 {
00834 ++yyerrno;
00835 if (ACE::debug ())
00836 {
00837 ACE_ERROR ((LM_ERROR,
00838 ACE_TEXT ("%p\n"),
00839 this->function_name_));
00840 }
00841 return 0;
00842 }
00843
00844 return this->symbol_;
00845 }
00846
00847 ACE_Static_Function_Node::~ACE_Static_Function_Node (void)
00848 {
00849 ACE_TRACE ("ACE_Static_Function_Node::~ACE_Static_Function_Node");
00850 delete[] const_cast<ACE_TCHAR *> (this->function_name_);
00851 }
00852
00853 ACE_ALLOC_HOOK_DEFINE (ACE_Service_Type_Factory)
00854
00855 ACE_Service_Type_Factory::ACE_Service_Type_Factory (ACE_TCHAR const *name,
00856 int type,
00857 ACE_Location_Node *location,
00858 int active)
00859 : name_ (name)
00860 , type_ (type)
00861 , location_ (location)
00862 , is_active_ (active)
00863 {
00864 }
00865
00866
00867 ACE_Service_Type_Factory::~ACE_Service_Type_Factory (void)
00868 {
00869 }
00870
00871
00872 ACE_Service_Type *
00873 ACE_Service_Type_Factory::make_service_type (ACE_Service_Gestalt *cfg) const
00874 {
00875 ACE_TRACE ("ACE_Service_Type_Factory::make_service_type");
00876
00877 u_int const flags = ACE_Service_Type::DELETE_THIS
00878 | (this->location_->dispose () == 0 ? 0 : ACE_Service_Type::DELETE_OBJ);
00879
00880 int yyerrno = 0;
00881 ACE_Service_Object_Exterminator gobbler = 0;
00882
00883 void *sym = this->location_->symbol (cfg, yyerrno, &gobbler);
00884
00885 if (sym != 0)
00886 {
00887 ACE_Service_Type_Impl *stp =
00888 ACE_Service_Config::create_service_type_impl (this->name (),
00889 this->type_,
00890 sym,
00891 flags,
00892 gobbler);
00893 if (stp == 0)
00894 ++yyerrno;
00895
00896 ACE_Service_Type *tmp = 0;
00897 ACE_NEW_RETURN (tmp,
00898 ACE_Service_Type (this->name (),
00899 stp,
00900 this->location_->dll (),
00901 this->is_active_),
00902 0);
00903 return tmp;
00904 }
00905
00906 #ifndef ACE_NLOGGING
00907 if (ACE::debug ())
00908 {
00909 ACE_ERROR ((LM_ERROR,
00910 ACE_TEXT ("ACE (%P|%t) Unable to create ")
00911 ACE_TEXT ("service object for %s\n"),
00912 this->name ()));
00913 }
00914 #endif
00915 ++yyerrno;
00916 return 0;
00917 }
00918
00919 ACE_TCHAR const*
00920 ACE_Service_Type_Factory::name (void) const
00921 {
00922 return name_.c_str ();
00923 }
00924
00925
00926 ACE_END_VERSIONED_NAMESPACE_DECL
00927
00928 #endif