bool
ImR_Locator_i::split_key (ACE_CString &full, ACE_CString &key, Server_Info_Ptr &si)
{
  key = full;
  if (this->get_info_for_name (full.c_str(), si))
    {
      return true;
    }

  ACE_CString::size_type pos = full.rfind ('/');
  while (pos != ACE_CString::npos)
    {
      ACE_CString server = full.substring (0, pos);
      if (this->get_info_for_name (server.c_str (), si))
        {
          return true;
        }
      pos = server.rfind ('/');
    }

  return false;
}
Exemplo n.º 2
0
ACE_TCHAR *
ACE::HTBP::ID_Requestor::get_HTID ()
{
  if (ACE::HTBP::ID_Requestor::htid_.length() != 0)
    return ACE::HTBP::ID_Requestor::htid_.rep();

  ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, ACE::HTBP::ID_Requestor::htid_lock_, 0);

  if (ACE::HTBP::ID_Requestor::htid_.length() != 0)
    return ACE::HTBP::ID_Requestor::htid_.rep();

  ACE_SOCK_Stream cli_stream;
  ACE_TCHAR * htid = 0;

  if (this->url_.length() == 0 ||
      this->connect_to_server (&cli_stream) == -1 ||
      this->send_request (&cli_stream) == -1)
    {
      ACE_Utils::UUID_Generator gen;
      ACE_Utils::UUID *uuid = gen.generate_UUID ();
      const ACE_CString *uuidstr = uuid->to_string();
      ACE::HTBP::ID_Requestor::htid_ = ACE_TEXT_CHAR_TO_TCHAR (uuidstr->c_str());
      delete uuid;
      return ACE::HTBP::ID_Requestor::htid_.rep();
    }
  iovec recv_buf;
  ssize_t result = cli_stream.recvv (&recv_buf);
  cli_stream.close();

  if (result > 0)
    {
      ACE_CString answer ((char *)recv_buf.iov_base,recv_buf.iov_len);
      ACE_CString::size_type start = answer.rfind (ACE_TEXT('\n'));
      if (start == ACE_CString::npos)
        start = 0;
      else
        start++;
      ACE::HTBP::ID_Requestor::htid_ = ACE_TEXT_CHAR_TO_TCHAR(answer.substr (start).c_str());
      htid = ACE::HTBP::ID_Requestor::htid_.rep();
    }
  return htid;
}
Exemplo n.º 3
0
void
Library::set_path (const char *p)
{
  char abspath[1000];
  ACE_OS::memset (abspath,0,1000);
  ssize_t abspathlen = ACE_OS::readlink(p,abspath,999);
  ACE_CString path (p);
  if (abspathlen > 0) {
    abspath[abspathlen] = 0;
    path = abspath;
  }

  ACE_CString::size_type pathsep = path.rfind('/');

  if (pathsep == ACE_CString::npos) {
    path_ = ".";
  } else {
    path_ = path.substr(0,pathsep);
  }
}
Exemplo n.º 4
0
int
BE_GlobalData::outfile_init (TAO_OutStream *& os,
                             const char *file_prefix,
                             const char *file_suffix,
                             const char *guard_prefix,
                             const char *guard_suffix)
{
  ACE_NEW_RETURN (os,
                  TAO_SunSoft_OutStream,
                  -1);

  ACE_CString fn (idl_global->stripped_filename ()->get_string ());
  fn = fn.substr (0, fn.rfind ('.'));
  fn += file_suffix;

  const char *path = be_global->output_dir ();
  ACE_CString target_name;

  if (path != 0)
    {
      target_name = path;
      target_name += "/";
    }

  target_name += file_prefix;
  target_name += fn;

  if (os->open (target_name.c_str ()) != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "Failed to open file %s for writing.\n",
                         target_name.c_str ()),
                        -1);
    }

  *os << be_nl;

  os->gen_ifndef_string (fn.c_str (), guard_prefix, guard_suffix);

  return 0;
}
Exemplo n.º 5
0
//
// get_target_basename
//
const ACE_CString & BE_GlobalData::get_target_basename (void) const
{
  if (!this->target_basename_.empty ())
    return this->target_basename_;

  // Normalize the source file name.
  ACE_CString dup_src_file (this->source_file_);
  std::replace (dup_src_file.begin (), dup_src_file.end (), '\\', '/');

  // Extract the basename of the source file. This include removing
  // the path from the source file, and removing its extension.
  size_t pos = dup_src_file.rfind ('/');
  ACE_CString filename;
  BE_GlobalData::get_filename (dup_src_file, filename);

  pos = filename.rfind ('.');
  this->target_basename_ = pos == ACE_CString::npos ? filename : filename.substring (0, pos);
  this->target_basename_ += this->suffix_;

  return this->target_basename_;
}
Exemplo n.º 6
0
int
be_visitor_servant_svh::visit_consumes (be_consumes *node)
{
  if(!be_global->gen_noeventccm ())
    {
      const char *obj_name = node->consumes_type ()->full_name ();
      const char *port_name = node->local_name ()->get_string ();

      ACE_CString holder (obj_name);
      ACE_CString::size_type pos = holder.rfind (':');
      const char *ev_lname = 0;

      if (pos == ACE_CString::npos)
        {
          ev_lname = obj_name;
        }
      else
        {
          holder = holder.substr (pos + 1);
          ev_lname = holder.c_str ();
        }

      os_ << be_uidt_nl << be_nl
          << "public:" << be_idt_nl;

      os_ << "// Servant class for the " << port_name
          << " consumer." << be_nl
          << "class " << export_macro_.c_str () << " " << ev_lname
          << "Consumer_" << port_name << "_Servant" << be_idt_nl
          << ": public virtual ::POA_" << obj_name << "Consumer"
          << be_uidt_nl
          << "{" << be_nl
          << "public:" << be_idt_nl;

      ACE_CString sname_str (
        ScopeAsDecl (node_->defined_in ())->full_name ());
      const char *sname = sname_str.c_str ();
      const char *lname = node_->local_name ();
      const char *global = (sname_str == "" ? "" : "::");

      os_ << ev_lname << "Consumer_" << port_name
          << "_Servant (" << be_idt_nl
          << global << sname << "::CCM_" << lname
          << "_ptr executor," << be_nl
          << global << sname << "::CCM_" << lname
          << "_Context_ptr c);" << be_uidt_nl << be_nl;

      os_ << "virtual ~" << ev_lname << "Consumer_" << port_name
          << "_Servant (void);";

      os_ << be_nl_2
          << "virtual void" << be_nl
          << "push_" << ev_lname << " (" << be_idt_nl
          << "::" << obj_name << " * evt);" << be_uidt;

      os_ << be_nl_2
          << "/// Inherited from ::Components::EventConsumerBase." << be_nl
          << "virtual void" << be_nl
          << "push_event ( ::Components::EventBase * ev);";

      os_ << be_nl_2
          << "/// Get component implementation." << be_nl
          << "virtual ::CORBA::Object_ptr" << be_nl
          << "_get_component (void);";

      os_ << be_uidt_nl << be_nl
          << "protected:" << be_idt_nl;

      os_ << global << sname << "::CCM_" << lname << "_var" << be_nl
          << "executor_;";

      os_ << be_nl_2
          << global << sname << "::CCM_"
          << lname << "_Context_var" << be_nl
          << "ctx_;";

      os_ << be_uidt_nl
          << "};";

      if (!be_global->gen_lwccm ())
        {
          os_ << be_nl_2
              << "virtual ::" << obj_name << "Consumer_ptr" << be_nl
              << "get_consumer_" << port_name << " (void);";
        }

      os_ << be_uidt_nl << be_nl
          << "private:" << be_idt_nl;

      os_ << "void" << be_nl
          << "setup_consumer_" << port_name << "_i (void);";

      os_ << be_uidt_nl << be_nl
          << "private:" << be_idt_nl;

      os_ << "::" << obj_name << "Consumer_var" << be_nl
          << "consumes_" << port_name << "_;";
    }
  return 0;
}
Exemplo n.º 7
0
void
Obj_Module::add_source(const char *p, int imports_only)
{
  ACE_Process nmproc;
  ACE_Process_Options nm_opts;
  ACE_CString path (p);

  ACE_CString::size_type pathsep = path.rfind('/');

  ACE_CString src_name;
  ACE_CString workpath;

  if (pathsep == ACE_CString::npos) {
    src_name = path;
    workpath = ".";
  } else {
    src_name = path.substr(pathsep+1);
    workpath= path.substr(0,pathsep);
  }

  ACE_HANDLE pipe[2];
  ACE_Pipe io(pipe);

  nm_opts.working_directory (workpath.c_str());
  nm_opts.set_handles (ACE_STDIN,pipe[1]);

  // Options for the command line shown here are for the GNU nm 2.9.5

  int result = nm_opts.command_line ("nm -C %s",src_name.c_str());
  // Prevent compiler warning about "unused variable" if ACE_ASSERT is
  // an empty macro.
  ACE_UNUSED_ARG (result);
  ACE_ASSERT (result == 0);

  nmproc.spawn (nm_opts);
  if (ACE_OS::close(pipe[1]) == -1)
    ACE_DEBUG ((LM_DEBUG, "%p\n", "close"));
  nm_opts.release_handles();

  int import_lines = 0;
  int export_lines = 0;
  ACE_Message_Block im_buffer (102400);
  ACE_Message_Block ex_buffer (102400);
  ACE_Message_Block *im_buf_cur = &im_buffer;
  ACE_Message_Block *ex_buf_cur = &ex_buffer;
  char dummy;
  int eoln = 1;
  //  ACE_Time_Value timeout (1,0);
  int is_import = 1;
  int is_export = 1;

  while (eoln == 1) {
    for (int i = 0; i < 10; i++) {
      if (ACE_OS::read(pipe[0],&dummy,1) != 1) {
        eoln = 2;
        break;
      }
    }
    if (eoln == 2)
      break;
    is_import = dummy == 'U';
    is_export = !imports_only && (ACE_OS::strchr("BCDRTVW",dummy) != 0);

    //    if (ACE::recv(pipe[0],&dummy,1,&timeout) != 1)
    if (ACE_OS::read(pipe[0],&dummy,1) != 1)
      break;

    eoln = this->read_line (pipe[0], is_import ? &im_buf_cur :
                            (is_export ? &ex_buf_cur : 0));
    import_lines += is_import;
    export_lines += is_export;
  }
  //  ACE_DEBUG ((LM_DEBUG, "read %d import lines and %d export lines\n",
  //            import_lines, export_lines));

  nmproc.wait ();
  ACE_OS::close (pipe[0]);

  this->populate_sig_list (imports_,import_lines,&im_buffer);
  if (!imports_only)
    this->populate_sig_list (exports_,export_lines,&ex_buffer);
}
Exemplo n.º 8
0
int
be_visitor_servant_svs::visit_consumes (be_consumes *node)
{
  AST_Type  *obj = node->consumes_type ();
  const char *port_name = node->local_name ()->get_string ();

  const char *comp_lname = node_->local_name ();
  ACE_CString comp_sname_str (
    ScopeAsDecl (node_->defined_in ())->full_name ());
  const char *comp_sname = comp_sname_str.c_str ();
  const char *global = (comp_sname_str == "" ? "" : "::");

  const char *lname = obj->local_name ()->get_string ();
  const char *fname = obj->full_name ();

  os_ << be_nl_2
      << comp_lname << "_Servant::" << lname << "Consumer_"
      << port_name << "_Servant::" << lname << "Consumer_"
      << port_name << "_Servant (" << be_idt << be_idt_nl
      << global << comp_sname << "::CCM_" << comp_lname
      << "_ptr executor," << be_nl
      << global << comp_sname << "::CCM_" << comp_lname
      << "_Context_ptr c)" << be_uidt_nl
      << ": executor_ ( " << global << comp_sname << "::CCM_"
      << comp_lname << "::_duplicate (executor))," << be_idt_nl
      << "ctx_ ( " << global << comp_sname
      << "::CCM_" << comp_lname
      << "_Context::_duplicate (c))" << be_uidt << be_uidt_nl
      << "{" << be_nl
      << "}";

  os_ << be_nl_2
      << comp_lname << "_Servant::" << lname << "Consumer_"
      << port_name << "_Servant::~" << lname << "Consumer_"
      << port_name << "_Servant (void)" << be_nl
      << "{" << be_nl
      << "}";

  os_ << be_nl_2
      << "::CORBA::Object_ptr" << be_nl
      << comp_lname << "_Servant::" << lname << "Consumer_"
      << port_name << "_Servant::_get_component (void)" << be_nl
      << "{" << be_idt_nl;

  if (ACE_OS::strcmp (be_global->ciao_container_type (), "Session") == 0)
    {
      os_ << "return this->ctx_->get_CCM_object ();";
    }
  else
    {
      os_ << "return ::CORBA::Object::_nil ();";
    }

  os_ << be_uidt_nl << "}";

  os_ << be_nl_2
      << "void" << be_nl
      << comp_lname << "_Servant::" << lname << "Consumer_"
      << port_name << "_Servant::push_" << lname
      << " (" << be_idt_nl
      << "::" << fname << " * evt)" << be_uidt_nl
      << "{" << be_idt_nl
      << "this->executor_->push_" << port_name
      << " (evt);" << be_uidt_nl
      << "}";

  os_ << be_nl_2
      << "/// Inherited from ::Components::EventConsumerBase."
      << be_nl
      << "void" << be_nl
      << comp_lname << "_Servant::" << lname << "Consumer_"
      << port_name << "_Servant::push_event (" << be_idt_nl
      << "::Components::EventBase * ev)" << be_uidt_nl
      << "{" << be_idt_nl
      << "::" << fname << " * ev_type =" << be_idt_nl
      << "::" << fname << "::_downcast (ev);"
      << be_uidt_nl << be_nl
      << "if (ev_type != 0)" << be_idt_nl
      << "{" << be_idt_nl
      << "this->push_" << lname << " (ev_type);" << be_nl
      << "return;" << be_uidt_nl
      << "}" << be_uidt_nl << be_nl
      << "throw ::Components::BadEventType ();" << be_uidt_nl
      << "}";

  if (!be_global->gen_lwccm ())
    {
      os_ << be_nl_2
          << "::" << fname << "Consumer_ptr" << be_nl
          << node_->local_name () << "_Servant::get_consumer_"
          << port_name << " (void)" << be_nl
          << "{" << be_idt_nl
          << "return" << be_idt_nl
          << "::" << fname << "Consumer::_duplicate (" << be_idt_nl
          << "this->consumes_" << port_name << "_.in ());"
          << be_uidt << be_uidt << be_uidt_nl
          << "}";
    }

  os_ << be_nl_2
      << "void" << be_nl
      << node_->local_name () << "_Servant::setup_consumer_"
      << port_name << "_i (void)" << be_nl
      << "{" << be_idt_nl
      << "ACE_CString obj_id (this->ins_name_);" << be_nl
      << "obj_id += \"_" << port_name << "\";" << be_nl_2
      << "::CIAO::Container_var cnt_safe =" << be_idt_nl
      << "::CIAO::Container::_duplicate ("
      << "this->container_.in ());" << be_uidt_nl << be_nl
      << "if (::CORBA::is_nil (cnt_safe.in ()))" << be_idt_nl
      << "{" << be_idt_nl << "throw ::CORBA::INV_OBJREF ();" << be_uidt_nl
      << "}" << be_uidt_nl << be_nl
      << "PortableServer::POA_var POA = cnt_safe->the_port_POA ();" << be_nl
      << node_->local_name () << "_Servant::" << lname
      << "Consumer_" << port_name << "_Servant *"
      << port_name << "_servant_impl = " << be_idt_nl
      << "new "   << node_->local_name () << "_Servant::" << lname
      << "Consumer_" << port_name << "_Servant (" << be_idt_nl
      << " this->executor_, this->context_);" << be_uidt_nl << be_uidt_nl << be_nl
      << "PortableServer::ServantBase_var safe_base_servant ("
      << port_name << "_servant_impl);" << be_nl
      << "PortableServer::ObjectId_var " << port_name << "_servant_oid =" << be_idt_nl
      << "PortableServer::string_to_ObjectId (obj_id.c_str());" << be_uidt_nl << be_nl
      << "POA->activate_object_with_id(" << be_idt_nl
      << port_name << "_servant_oid.in()," << be_nl
      <<  port_name << "_servant_impl);" << be_uidt_nl << be_nl

      << "::CORBA::Object_var " << port_name << "_servant_impl_obj = " << be_idt_nl
      << "cnt_safe->generate_reference ( " << be_idt_nl
      << "obj_id.c_str ()," << be_nl
      << "\"";

      ACE_CString work (obj->repoID ());
      ACE_CString result (work.substr (0, work.rfind (':')));
      result += "Consumer:1.0";

      os_ << result.c_str ();

      os_ << "\"," << be_nl
      << "::CIAO::Container_Types::FACET_CONSUMER_t);"
      << be_uidt_nl << be_uidt_nl
      << "::Components::EventConsumerBase_var ecb =" << be_idt_nl
      << "::Components::EventConsumerBase::_narrow ("
      << port_name << "_servant_impl_obj.in ());"
      << be_uidt_nl << be_nl
      << "this->add_consumer (\"" << port_name << "\", ecb.in ());"
      << be_uidt_nl
      << "}";

  return 0;
}