00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <OB/CORBA.h>
00024 #include <OB/CosNaming.h>
00025 #include "NameClient_impl.h"
00026
00027
00028
00029
00030
00031
00032
00033
00034 SimpleNameServer::SimpleNamingClient_impl::SimpleNamingClient_impl(CosNaming::NamingContext_ptr inc)
00035 : inc_ (inc)
00036 {
00037 }
00038
00039 SimpleNameServer::SimpleNamingClient_impl::~SimpleNamingClient_impl()
00040 {
00041 }
00042
00043
00044
00045
00046 CORBA::Object_ptr
00047 SimpleNameServer::SimpleNamingClient_impl::Resolve(const char* name)
00048 throw(CORBA::SystemException)
00049 {
00050 char *dup = strdup (name);
00051 char *psl;
00052 int n = 1;
00053 for (psl = strchr (dup, '/'); psl != NULL; psl = strchr (psl + 1, '/')) n ++;
00054 CosNaming::Name findName;
00055 findName.length (n);
00056 int i;
00057 char *ppart = dup;
00058 for (i = 0; i < n; i ++) {
00059 psl = strchr (ppart, '/');
00060 if (psl) *psl = 0;
00061 findName [i].id = CORBA::string_dup (ppart);
00062 findName [i].kind = CORBA::string_dup ("");
00063 if (psl) ppart = psl + 1;
00064 }
00065 free (dup);
00066 CORBA::Object_ptr p = NULL;
00067 try {
00068 p = inc_->resolve (findName);
00069 }
00070 catch (...) {
00071 printf ("Resolve '%s' failed\n", name);
00072 }
00073 return p;
00074 }
00075