Exemplo n.º 1
0
    bool Response::read(istream& str)
      {
        ACE_CString version;
        ACE_CString status;
        ACE_CString reason;

        int ch =  str.peek ();
        if (ch == eof_)
          {
            str.get (); // skip to eof
            return false;
          }
        // skip whitespace
        while (ACE_OS::ace_isspace (str.peek ()))
          {
            str.get ();
          }
        // get version
        ch = this->read_ws_field (str, version, MAX_VERSION_LENGTH);
        if (ch == eof_  || !ACE_OS::ace_isspace (ch))
          return false; // invalid HTTP version string
        // skip whitespace
        while (ACE_OS::ace_isspace (str.peek ()))
          {
            str.get ();
          }
        // get status
        ch = this->read_ws_field (str, status, MAX_STATUS_LENGTH);
        if (ch == eof_ || !ACE_OS::ace_isspace (ch))
          return false; // invalid HTTP status code
        // skip whitespace
        while (ACE_OS::ace_isspace (str.peek ()))
          {
            str.get ();
          }
        // get reason
        ch = this->read_field (str, reason, MAX_REASON_LENGTH, '\r');
        if (ch == '\r')
          ch = str.get (); // get lf
        if (ch != '\n')
          return false; // HTTP reason string too long

        INET_DEBUG (6, (LM_DEBUG, DLINFO
                        ACE_TEXT ("ACE_INet_HTTP: <-- %C %C %C\n"),
                        version.c_str (),
                        status.c_str (),
                        reason.c_str()));

        // get header lines
        if (!Header::read (str))
          return false;
        // skip empty line
        ch = str.get ();
        while (ch != '\n' && ch != eof_)
          ch = str.get ();
        this->set_version(version);
        this->status_.set_status (status);
        this->status_.set_reason (reason);
        return true;
      }
Exemplo n.º 2
0
int
TAO::SSLIOP::Protocol_Factory::match_prefix (const ACE_CString &prefix)
{
  // Check for the proper prefix for this protocol.
  return (ACE_OS::strcasecmp (prefix.c_str (), ::the_prefix[0]) == 0)
     || (ACE_OS::strcasecmp (prefix.c_str (), ::the_prefix[1]) == 0);
}
//
// handle_activate
//
int IOR_File_Trait::
handle_activate (::CORBA::Object_ptr obj, const ACE_CString & value)
{
  OASIS_TAO_TRACE ("int IOR_File_Trait::handle_activate (::CORBA::Object_ptr, const ACE_CString &)");

  // Get the ORB for this object.
  ::CORBA::ORB_var orb = obj->_get_orb ();

  if (::CORBA::is_nil (orb.in ()))
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%T (%t) - %M - failed to resolve ORB\n")),
                       1);

  // Convert the object to a string.
  ::CORBA::String_var str = orb->object_to_string (obj);

  // Write the string to the specified file.
  std::ofstream file;
  file.open (value.c_str ());

  if (!file.is_open ())
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%T (%t) - %M - failed to open %s for writing\n"),
                       value.c_str ()),
                       1);

  file << str.in ();
  file.close ();

  return 0;
}
Exemplo n.º 4
0
int
TAO::SSLIOP::Acceptor::parse_options_i (int &argc, ACE_CString ** argv)
{
  //first, do the base class parser, then parse the leftovers.
  int result = this->IIOP_SSL_Acceptor::parse_options_i(argc,argv);
  if (result == -1)
    return result;

  // then parse out our own options.
  int i = 0;
  while (i < argc)
    {
      // since the base class has already iterated over the list once,
      // it has vound any ill-formed options. Therefore we don't need
      // to do that again here.
      int slot = argv[i]->find ("=");
      ACE_CString name = argv[i]->substring (0, slot);
      ACE_CString value = argv[i]->substring (slot + 1);

      if (name == "priority")
        {
          ORBSVCS_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("TAO (%P|%t) Invalid SSLIOP endpoint format: ")
                             ACE_TEXT ("endpoint priorities no longer supported.\n"),
                             value.c_str ()),
                            -1);
        }
      else if (ACE_OS::strcmp (name.c_str (), "ssl_port") == 0)
        {
          int ssl_port = ACE_OS::atoi (value.c_str ());

          if (ssl_port >= 0 && ssl_port < 65536)
            this->ssl_component_.port = ssl_port;
          else
            ORBSVCS_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT ("TAO (%P|%t) Invalid ")
                               ACE_TEXT ("IIOP/SSL endpoint ")
                               ACE_TEXT ("port: <%s>\n"),
                               value.c_str ()),
                              -1);
        }
      else
        {
          // the name is not known, skip to the next option
          i++;
          continue;
        }
      // at the end, we've consumed this argument. Shift the list and
      // put this one on the end. This technique has the effect of
      // putting them in reverse order, but that doesn't matter, since
      // these arguments are only whole strings.
      argc--;
      ACE_CString *temp = argv[i];
      for (int j = i; j <= argc-1; j++)
        argv[j] = argv[j+1];
      argv[argc] = temp;

    }
  return 0;
}
Exemplo n.º 5
0
int
Fill_ACE_QoS::fill_duplex_qos (ACE_QoS &ace_qos,
                               const ACE_CString &recv_flow_name,
                               const ACE_CString &send_flow_name)
{
  ACE_Flow_Spec *send_flow_spec = 0;
  ACE_Flow_Spec *recv_flow_spec = 0;

  if (this->map ().find (recv_flow_name, recv_flow_spec) != 0)
    ACE_ERROR_RETURN ((LM_DEBUG,
                       "Unable to find a FlowSpec with name %s",
                       recv_flow_name.c_str ()),
                      -1);

  if (this->map ().find (send_flow_name, send_flow_spec) != 0)
    ACE_ERROR_RETURN ((LM_DEBUG,
                       "Unable to find a FlowSpec with name %s",
                       send_flow_name.c_str ()),
                      -1);

  ace_qos.receiving_flowspec (recv_flow_spec);
  ace_qos.sending_flowspec (send_flow_spec);
  ace_qos.provider_specific (Fill_ACE_QoS::iov_);

  return 0;
}
Exemplo n.º 6
0
void
MPC_Generator::write_prolog (const ACE_CString& path)
{
  ACE_CString fname (path + "/" + mpcfilename_);
  ACE_DEBUG ((LM_DEBUG, "writing file %s\n",fname.c_str()));
  mpcfile_.open(fname.c_str());
  if (!mpcfile_)
    ACE_DEBUG ((LM_DEBUG,"mpc file open failed\n"));

  mpcfile_
    << "// Generated mpc file for producing a subset of the "
    << libname_ << " library " << endl << endl
    << "project(" << libname_ << "_subset)";

  this->write_baseprojects ();

  mpcfile_
    << " {" << endl
    << "  sharedname   = " << libname_ << "_subset" << endl
    << "  pch_header   = " << endl
    << "  pch_source   = " << endl;

  this->write_projectinfo ();

  mpcfile_ << endl
           << "  Source_Files {" << endl;
}
Exemplo n.º 7
0
 void
 Sender_exec_i::tick ()
 {
   // Start writing after DataWriter find first DataReader that matched the
   // Topic It is still possible that other Readers aren't yet ready to
   // receive data, for that case in the profile the durability is set to
   // TRANSIENT_DURABILITY_QOS, so each Reader should receive each message.
   if(this->ready_to_start_.value())
     {
       if (this->iteration_ < this->iterations_)
         {
           Hello::Writer_var writer =
             this->ciao_context_->get_connection_info_in_data ();
           if (! ::CORBA::is_nil (writer.in ()))
             {
               DDSHello new_msg;
               ACE_CString msg = create_message (this->msg_);
               new_msg.hello = msg.c_str ();
               new_msg.iterator = ++this->iteration_;
               writer->write_one (new_msg, ::DDS::HANDLE_NIL);
               ACE_DEBUG ((LM_DEBUG, "Sender_exec_i::tick - "
                                     "Written sample: <%C> - <%u>\n",
                                     msg.c_str (),
                                     new_msg.iterator));
             }
         }
       else
         {
           // We are done
           this->stop ();
         }
      }
 }
void ClientErrorComponent::TestReceiveRemoteException() 
{
    ACS_TRACE("ClientErrorComponent::TestReceiveRemoteException");

    if (CORBA::is_nil(foo_m.in()) == true)
	{
	throw ACSErrTypeCommon::CouldntAccessComponentExImpl(
				   __FILE__, __LINE__,
				   "ClientErrorComponent::TestReceiveRemoteException");
	}
    ACS_SHORT_LOG((LM_INFO, "Example 1: Calls a method that throws an exception."));
    try
	{
	foo_m->badMethod(5);
        ACS_SHORT_LOG((LM_INFO, "UNEXPECTED: should have thrown an exception"));
	}
    catch(ACSErrTypeCommon::GenericErrorEx &ex)
	{
	ACSErrTypeCommon::GenericErrorExImpl badMethodEx(ex,
				   __FILE__, __LINE__,
				   "ClientErrorComponent::TestReceiveRemoteException");
	badMethodEx.setErrorDesc("badMethod has thrown the expected exception");
	badMethodEx.log();

	ACS::Time timeStamp = badMethodEx.getTimeStamp();
	ACE_CString tString = getStringifiedUTC(timeStamp);
	ACS_DEBUG_PARAM("ClientErrorComponent::TestReceiveRemoteException", 
			"Time of the exception: %s\n", tString.c_str());
	}
    catch(CORBA::SystemException &ex)
	{
	ACSErrTypeCommon::CORBAProblemExImpl corbaProblemEx(
				   __FILE__, __LINE__,
				   "ClientErrorComponent::TestReceiveRemoteException");
	corbaProblemEx.setMinor(ex.minor());
	corbaProblemEx.setCompletionStatus(ex.completed());
	corbaProblemEx.setInfo(ex._info().c_str());
	corbaProblemEx.log();

	//Is this really necessary? The exceptions already have a timeStamp
	ACS::Time timeStamp = corbaProblemEx.getTimeStamp();
	ACE_CString tString = getStringifiedUTC(timeStamp);
	ACS_DEBUG_PARAM("ClientErrorComponent::TestReceiveRemoteException", 
			"Time of the CORBA exception: %s\n", tString.c_str());
	}
    catch(...)
	{
	ACSErrTypeCommon::GenericErrorExImpl badMethodEx(__FILE__, __LINE__,
		      				 "ClientErrorComponent::TestReceiveRemoteException");
	badMethodEx.setErrorDesc("badMethod has thrown an UNEXPECTED exception");
	badMethodEx.log();

	ACS::Time timeStamp = badMethodEx.getTimeStamp();
	ACE_CString tString = getStringifiedUTC(timeStamp);
	ACS_DEBUG_PARAM("ClientErrorComponent::TestReceiveRemoteException", 
			"Time of the unexpected exception: %s\n", tString.c_str());
	}

}
Exemplo n.º 9
0
Server_Info_Ptr
Locator_Repository::get_active_server (const ACE_CString& name, int pid)
{
  sync_load ();
  ACE_CString key;
  Server_Info_Ptr si;
  if (name.length() == 0)
    {
      return si;
    }
  Server_Info::fqname_to_key (name.c_str(), key);
  servers ().find (key, si);
  if (si.null())
    {
      if (this->opts_.debug() > 5)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) get_active_server could not find %C\n"),
                          name.c_str()));
        }
      si = find_by_poa (key);
      if (si.null())
        {
          if (name.find ("JACORB:") == ACE_CString::npos)
            {
              ACE_CString jo_key ("JACORB:");
              ACE_CString::size_type pos = name.find (':');
              if (pos == ACE_CString::npos)
                {
                  jo_key += name;
                }
              else
                {
                  jo_key += name.substring (0, pos);
                  jo_key += '/';
                  jo_key += name.substring (pos+1);
                }
              return this->get_active_server (jo_key, pid);
            }
          else
            {
              return si;
            }
        }
    }

  if (pid != 0 && si->pid != 0 && si->pid != pid)
    {
      if (this->opts_.debug() > 5)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) get_active_server could not")
                          ACE_TEXT (" find %C, %d != %d\n"),
                          name.c_str(), pid, si->pid));
        }
      si.reset ();
    }
  return si;
}
Exemplo n.º 10
0
void
TAO_Notify_Tests_Command_Builder::_register (ACE_CString command_factory_name, TAO_Notify_Tests_Command_Factory* command_factory)
{
  if (this->factory_map_.bind (command_factory_name, command_factory) == -1)
    ACE_DEBUG ((LM_DEBUG, "Failed to register command factory for %s\n", command_factory_name.c_str ()));
  else
    ACE_DEBUG ((LM_DEBUG, "Registered command factory for %s\n", command_factory_name.c_str ()));
}
Exemplo n.º 11
0
    bool HeaderBase::read(std::istream& str)
      {

        ACE_CString name (64, '\0');
        ACE_CString value (128, '\0');
        int ch = str.peek ();
        while (ch != eof_ && ch != '\r' && ch != '\n')
          {
            name.fast_clear ();
            value.fast_clear ();
            // parse name
            ch = this->read_field (str, name, MAX_NAME_LENGTH, ':');
            if (ch == '\n')
              {
                ch = str.get ();
                continue; // ignore invalid headers
              }
            if (ch != ':')
              {
                return false; // name too long/missing colon; cannot continue
              }

            // skip leading whitespace before next field
            while (ACE_OS::ace_isspace (str.peek ()))
              {
                ch = str.get ();
              }

            // parse value
            ch = this->read_field (str, value, MAX_VALUE_LENGTH, '\r');
            if (ch == '\r')
              ch = str.get (); // get lf
            if (ch != '\n')
              return false; // value too long/no crlf found; cannot continue

            // followup lines starting with ws are continuations of the value
            // and must be appended
            ch = str.peek ();
            while (ch == ' ' || ch == '\t')
            {
              ch = this->read_field (str, value, MAX_VALUE_LENGTH, '\r');
              if (ch == '\r')
                ch = str.get (); // get lf
              if (ch != '\n')
                return false; // multiline value too long/no crlf; cannot continue

              ch = str.peek ();
            }

            this->add (name, value);

            INET_DEBUG (9, (LM_DEBUG, DLINFO
                            ACE_TEXT ("ACE_INet_HTTP: <-+ %C: %C\n"),
                            name.c_str (),
                            value.c_str ()));
          }
        return true;
      }
Exemplo n.º 12
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  if (parse_args (argc,
                  argv) == -1)
    return -1;

  try
    {
      ACE_Argv_Type_Converter satc (argc, argv);
      CORBA::ORB_var sorb =
        CORBA::ORB_init (satc.get_argc (),
                         satc.get_TCHAR_argv (),
                         server_orb.c_str ());

      ACE_Manual_Event me;
      Server_Task server_task (output,
                               sorb.in (),
                               me,
                               ACE_Thread_Manager::instance ());

      if (server_task.activate (THR_NEW_LWP | THR_JOINABLE,
                                1,
                                1) == -1)
        {
          ACE_ERROR ((LM_ERROR, "Error activating server task\n"));
        }

      // Wait for the server thread to do some processing
      me.wait ();

      ACE_Argv_Type_Converter catc (argc, argv);
      CORBA::ORB_var corb =
        CORBA::ORB_init (catc.get_argc (),
                         catc.get_TCHAR_argv (),
                         client_orb.c_str ());

      Client_Task client_task (input,
                               corb.in (),
                               syncMode,
                               ACE_Thread_Manager::instance ());

      if (client_task.activate (THR_NEW_LWP | THR_JOINABLE,
                                1,
                                1) == -1)
        {
          ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
        }

      ACE_Thread_Manager::instance ()->wait ();
    }
  catch (const CORBA::Exception&)
    {
      // Ignore exceptions..
    }
  return 0;
}
Exemplo n.º 13
0
CORBA::Boolean
CORBA::ValueBase::_tao_write_repository_id (TAO_OutputCDR &strm,
                                            ACE_CString& id)
{
#ifdef TAO_HAS_VALUETYPE_OUT_INDIRECTION

  VERIFY_MAP (TAO_OutputCDR, repo_id_map, Repo_Id_Map);
  char* pos = 0;
  if (strm.get_repo_id_map ()->get()->find (id, pos) == 0)
  {
    if (!strm.write_long (TAO_OBV_GIOP_Flags::Indirection_tag))
      {
        return false;
      }
    CORBA::Long offset= -strm.offset (pos);
    if (TAO_debug_level)
      {
        TAOLIB_DEBUG ((LM_DEBUG,
          ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_write_repository_id,  id %C indirection %d\n"),
          id.c_str(), offset));
      }
    if (!strm.write_long (offset))
      {
        return false;
      }
  }
  else
  {
    if (strm.align_write_ptr (ACE_CDR::LONG_SIZE) != 0)
      {
        throw CORBA::INTERNAL ();
      }
    if (strm.get_repo_id_map ()->get ()->bind (id, strm.current()->wr_ptr ()) != 0)
      {
        throw CORBA::INTERNAL ();
      }
    if (TAO_debug_level)
      {
        TAOLIB_DEBUG ((LM_DEBUG,
          ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_write_repository_id, bound %C - %x\n"),
          id.c_str (), strm.current()->wr_ptr ()));
      }
    if (! strm.write_string (id.c_str ()))
      {
        return false;
      }
  }
#else
  if (! strm.write_string (id.c_str ()))
    {
      return 0;
    }
#endif

  return 1;
}
Exemplo n.º 14
0
bool
FE_Utils::validate_orb_include (UTL_String * idl_file_name)
{
  char foundpath[MAXPATHLEN] = "";

  {
    // Check in the current folder.
    char abspath[MAXPATHLEN] = "";
    ACE_CString cwd_path = ACE_OS::getcwd (abspath,
                                           sizeof (abspath) / sizeof (char));
    if (FE_Utils::is_include_file_found (cwd_path, idl_file_name))
      {
        ACE_OS::strcpy (foundpath, cwd_path.c_str ());
      }
  }

  for (IDL_GlobalData::Unbounded_Paths_Queue_Iterator iter (
         idl_global->include_paths ());
       !iter.done ();
       iter.advance ())
    {
      IDL_GlobalData::Include_Path_Info *path_info = 0;
      iter.next (path_info);

      ACE_CString partial = path_info->path_;

      // We don't need to check anything if the file is already
      // found and the folder where are currently checking is
      // provided by user.
      if (foundpath[0] != 0 && !path_info->is_system_)
        {
          continue;
        }

      if (FE_Utils::is_include_file_found (partial, idl_file_name))
        {
          if (path_info->is_system_)
            {
              if (foundpath[0] == 0 ||
                  ACE_OS::strcmp (foundpath, partial.c_str ()) == 0)
                {
                  return true;
                }
            }
          else
            {
              // We can fill in foundpath here since we are sure
              // that it was not set before. Check above ensures that.
              ACE_OS::strcpy (foundpath, partial.c_str ());
              continue;
            }
        }
    }

  return false;
}
Exemplo n.º 15
0
bool BACIValue::fromString(const ACE_CString value, bool specifyType)
{

  ACE_CString strType;
  ACE_CString strContent;
  const char *szType;
  const char *szContent;
  unsigned long ulBound = 0;

  if (specifyType)
    {
      ACE_CString::size_type nPos0 = value.find('<');
      ACE_CString::size_type nPos1 = value.find(':');
      ACE_CString::size_type nPos2 = value.find('>');

      if((nPos1 != ACE_CString::npos) && (nPos1 < (nPos2-1)))
		ulBound = atoi(value.substr(nPos1+1, nPos2-nPos1-1).c_str());
      else
		nPos1 = nPos2;

      strType = value.substr(nPos0+1, nPos1-nPos0-1);
      strContent = value.substr(nPos2+1);
      szType = strType.c_str();
      szContent = strContent.c_str();

    }
  else
    {
      strType = typeName[type_m];
      strContent = value;
      szType = strType.c_str();
      szContent = strContent.c_str();
    }

/// User defined

  // special threathment for string (no conversion needed)
  if(strType.compare(BACIValue::typeName[type_string]) == 0)
    {
      if ((ulBound != 0) && (strContent.length() > ulBound))
	return false;
      if(!setType(type_string, ulBound))
	return 0;
      return stringValue(szContent);
    }

   PROCESS_INLINE_TYPE(double, BACIdouble)
   PROCESS_INLINE_TYPE(float, BACIfloat)
   PROCESS_INLINE_TYPE(long, BACIlong)
   PROCESS_INLINE_TYPE(longLong, BACIlongLong)
   PROCESS_INLINE_TYPE(uLongLong, BACIuLongLong)
//TBDeleted   PROCESS_INLINE_TYPE(pattern, BACIpattern)

  return false;

}
Exemplo n.º 16
0
void
Object_Group_i::unbind (const char * id)
{
  // Check whether the this->member_ is NULL
  if (this->members_ == 0)
    {
      ACE_CString id = this->id ();

      id += server_id_name_bind;

      void *tmp_members (0);

      if (this->allocator_->find (id.c_str (),
                                  tmp_members) == -1)
        {
          throw Load_Balancer::no_such_member ();
        }

      this->members_ = reinterpret_cast <HASH_MAP *> (tmp_members);
    }
  // Check to make sure we have it.
  if (this->members_->find (const_cast<char *> (id),
                            this->allocator_) == -1)
    throw Load_Balancer::no_such_member ();

  // Remove all entries for this member.
  this->members_->unbind (const_cast<char *> (id),
                          this->allocator_);

  if (this->member_id_list_ == 0)
    {
      ACE_CString id = dll_name_bind;
      id += this->id ();

      void *tmp_id_list (0);

      if (this->allocator_->find (id.c_str (),
                                  tmp_id_list)
          == -1)
        throw Load_Balancer::no_such_member ();

      this->member_id_list_ = reinterpret_cast <LIST *> (tmp_id_list);
    }



  Object_Group_i::ITERATOR iter (*(this->member_id_list_));

  while (ACE_OS::strcmp (id,*(iter.next ())))
    iter.advance ();

  this->allocator_->free ((void *) iter.next ());

  iter.remove ();
}
Exemplo n.º 17
0
void
Library::write_export_list (int show_ref_counts)
{
  if (num_modules_ < 1)
    return;

  ACE_CString excludedfilename = path_ + "/excluded_modules";
  ACE_CString rcpath = path_ + "/usage_metrics";

  ofstream exclusions (excludedfilename.c_str());
  if (!exclusions) {
    ACE_ERROR ((LM_ERROR, "%p\n", "open exclusions list"));
  }

  if (show_ref_counts) {
    ACE_DEBUG ((LM_DEBUG, "Making directory %s\n",rcpath.c_str()));
    if (ACE_OS::mkdir(ACE_TEXT_CHAR_TO_TCHAR (rcpath.c_str())) == -1 &&
        errno != EEXIST)
      ACE_ERROR ((LM_ERROR, "%p\n", "mkdir"));
  }

  ACE_DEBUG ((LM_DEBUG,"%s: %d out of %d modules required\n",
              name_.c_str(), num_extrefs_, num_modules_));

  mpcfile_->write_prolog(path_);

  for (int i = 0; i < num_modules_ ; i++)
    if (modules_[i]->extref()) {
      if (show_ref_counts) {
        ACE_CString fname = rcpath + "/" +  modules_[i]->name();
        ofstream countfile (fname.c_str());
        countfile << "Exported symbols:" << endl;
        for (const Signature *sig = modules_[i]->exports().first();
             modules_[i]->exports().hasmore();
             sig = modules_[i]->exports().next())
          {
            countfile.width(5);
            countfile << sig->used_count() << " " << sig->name() << endl;
          }
        countfile << "\nImported symbols:" << endl;
        for (const Signature *n_sig = modules_[i]->imports().first();
             modules_[i]->imports().hasmore();
             n_sig = modules_[i]->imports().next())
          countfile << n_sig->name() << endl;
      }
      mpcfile_->write_file(modules_[i]->name().substring(0,modules_[i]->name().length()-2));
    } else {
      //      const char * modname = modules_[i]->name().c_str();
      exclusions
        << modules_[i]->name().substring(0,modules_[i]->name().length()-2)
        << endl;
    }

  mpcfile_->write_epilog();
}
Exemplo n.º 18
0
Arquivo: driver.cpp Projeto: SEDS/CUTS
int main (int argc, char * argv [])
{
  std::cout << "Testing Command Substition:" << std::endl;
  ACE_CString in = "before `echo` after";
  ACE_CString out;
  std::cout << "  input = " << in.c_str () << std::endl;
  CUTS_Command_Substitution cs;
  std::cout << "  retval: " << cs.evaluate (in.c_str (), out) << std::endl;
  std::cout << "  output = " << out.c_str () << std::endl;
  return 0;
}
//
// parse
//
bool
Configuration_Manager::parse (Configuration_Group & group,
                              const ACE_CString & file)
{
  std::ifstream stream;
  stream.open (file.c_str ());
  if (!stream)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%T (%t) - %M - Unable to open configuration file at %s\n"),
                       file.c_str()),
                       false);
  return this->parser_.read_data (stream, group);
}
Exemplo n.º 20
0
int
check_temp_file (const ACE_TString &tmpfilename)
{
  ACE_DIRENT *dir = 0;
  ACE_Dirent entr;
  ACE_stat stat;
  char filename[MAXPATHLEN + 1];

  ACE_OS::memset (&stat, 0, sizeof (stat));
  ACE_OS::memset (&entr, 0, sizeof (entr));

  // Loop through /proc/self/fs/
  if (entr.open (ACE_TEXT_CHAR_TO_TCHAR(proc_self_fd)) == -1)
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("Could not open dir %C\n"),
                         proc_self_fd),
                         -1);

  while ((dir = entr.read ()))
    {
      ACE_CString fullp = proc_self_fd;
#if defined (ACE_HAS_TCHAR_DIRENT)
      fullp += ACE_TEXT_ALWAYS_CHAR(dir->d_name);
#else
      fullp += dir->d_name;
#endif

      if ((ACE_OS::lstat (fullp.c_str (), &stat)) == -1)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("Stat failed for %C\n"),
                           fullp.c_str ()),
                          -1);

      if (S_ISLNK (stat.st_mode))
        {
          ssize_t size = 0;
          if ((size= ACE_OS::readlink (fullp.c_str (),
                                       filename,
                                       MAXPATHLEN + 1)) == -1)
            ACE_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT ("Readlink failed for %C\n"),
                               fullp.c_str ()),
                              -1);
          filename[size] = '\0';
          if (tmpfilename == ACE_TString (ACE_TEXT_CHAR_TO_TCHAR (filename)))
            return 1;
        }
    }

  return 0;
}
void ClientErrorComponent::TestReceiveCorbaSystemException() 
{
    ACS_TRACE("ClientErrorComponent::TestReceiveCorbaSystemException");

    if (CORBA::is_nil(foo_m.in()) == true)
	{
	throw ACSErrTypeCommon::CouldntAccessComponentExImpl(
				   __FILE__, __LINE__,
				   "ClientErrorComponent::TestReceiveRemoteException");
	}
    ACS_SHORT_LOG((LM_INFO, "Example 5: Calls a method that throws a CORBA System Exception."));
    try
	{
	foo_m->corbaSystemException();
	}
    catch(CORBA::SystemException &ex)
	{
	// This show how to map a CORBA System exception from TAO
        // in the ACS wrapper ACSErrTypeCommon::CORBAProblemExImpl.
        /**
	 * @todo Implement a real wrapper exception class, 
	 *        to make the conversion transparent 
	 */
	ACSErrTypeCommon::CORBAProblemExImpl corbaProblemEx(
				   __FILE__, __LINE__,
				   "ClientErrorComponent::TestReceiveRemoteException");
	corbaProblemEx.setMinor(ex.minor());
	corbaProblemEx.setCompletionStatus(ex.completed());
	corbaProblemEx.setInfo(ex._info().c_str());
	corbaProblemEx.log();

	ACS::Time timeStamp = corbaProblemEx.getTimeStamp();
	ACE_CString tString = getStringifiedUTC(timeStamp);
	ACS_DEBUG_PARAM("ClientErrorComponent::TestReceiveRemoteException", 
			"Time of the CORBA::SystemException exception: %s\n", tString.c_str());
	}
    catch(...)
	{
	ACSErrTypeCommon::GenericErrorExImpl badMethodEx(__FILE__, __LINE__,
		      				 "ClientErrorComponent::TestReceiveRemoteException");
	badMethodEx.setErrorDesc("corbaSystemException has thrown an UNEXPECTED exception");
	badMethodEx.log();

	ACS::Time timeStamp = badMethodEx.getTimeStamp();
	ACE_CString tString = getStringifiedUTC(timeStamp);
	ACS_DEBUG_PARAM("ClientErrorComponent::TestReceiveRemoteException", 
			"Time of the unexpected exception: %s\n", tString.c_str());
	}

}
Exemplo n.º 22
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  ACE_CString srcname;
  if (argc > 1)
    srcname.set(argv[1]);
  else
    ACE_ERROR_RETURN ((LM_ERROR,"Usage: %s <source_file>\nwhere source file is the full path to a code set registry text file.\n",argv[0]),-1);
  csdb_generator csdb;
  if (csdb.init_output(srcname.c_str()) == -1)
    return 0;
  if (csdb.read_from (srcname.c_str()) == 0)
    csdb.fini_output ("Codeset_Registry_db.cpp");
  return 0;
}
Exemplo n.º 23
0
CORBA::Object_ptr
TAO_CORBANAME_Parser::
parse_string_dynamic_request_helper (CORBA::Object_ptr naming_context,
                                     ACE_CString &key_string)
{
  TAO::Arg_Traits<CORBA::Object>::ret_val _tao_retval;
  TAO::Arg_Traits<CORBA::Char *>::in_arg_val _tao_id (key_string.c_str ());

  TAO::Argument *_tao_signature [] =
      {
        &_tao_retval,
        &_tao_id
      };

  TAO::Invocation_Adapter tao_call (naming_context,
                                    _tao_signature,
                                    2,
                                    "resolve_str",
                                    11,
                                    TAO::TAO_CO_NONE | TAO::TAO_CO_THRU_POA_STRATEGY);

  tao_call.invoke (0, 0);

  return _tao_retval.retn ();
}
Exemplo n.º 24
0
    ::DDS::StatusMask
    PublisherListener::get_mask (
      ::CCM_DDS::ConnectorStatusListener_ptr error_listener)
    {
      ::DDS::StatusMask mask = 0;

      if (! ::CORBA::is_nil (error_listener) ||
          DDS4CCM_debug_level >= DDS4CCM_LOG_LEVEL_DDS_STATUS)
        {
          mask = ::DDS::OFFERED_DEADLINE_MISSED_STATUS |
                 ::DDS::OFFERED_INCOMPATIBLE_QOS_STATUS |
    #if (CIAO_DDS4CCM_NDDS==1)
                 ::DDS::RELIABLE_WRITER_CACHE_CHANGED_STATUS |
                 ::DDS::RELIABLE_READER_ACTIVITY_CHANGED_STATUS |
    #endif
                 ::DDS::LIVELINESS_LOST_STATUS |
                 ::DDS::PUBLICATION_MATCHED_STATUS;
        }

      if (DDS4CCM_debug_level >= DDS4CCM_LOG_LEVEL_DDS_STATUS)
        {
          ACE_CString msk;
          translate_statusmask (msk, mask);
          DDS4CCM_DEBUG (DDS4CCM_LOG_LEVEL_DDS_STATUS, (LM_DEBUG, DDS4CCM_INFO
                        "PublisherListener::get_mask - "
                        "Mask becomes %C\n",
                        msk.c_str ()));
        }
      return mask;
    }
Exemplo n.º 25
0
int
MCT_Event_Handler::find (const char *buf)
{
  size_t const size = this->address_vec_.size ();
  size_t i = 0;
  for (i = 0; i < size; ++i)
    {
      if (ACE_OS::strcasecmp (buf, this->address_vec_[i]->c_str ()) == 0)
        return 0;
    }

  // Not found, so output message we received along with a list of groups
  // we've joined for debugging.
  ACE_CString local;
  for (i = 0; i < size; ++i)
    {
      local += "\t";
      local += this->address_vec_[i]->c_str ();
      local += "\n";
    }
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%C not in:\n%C"),
              buf, local.c_str ()));

  return -1;
}
Exemplo n.º 26
0
void
FE_Utils::original_local_name (Identifier *local_name)
{
  const char *lname = local_name->get_string ();

  // Remove _cxx_ if:
  // 1. it occurs and
  // 2. it occurs at the beginning of the string and
  // 3. the rest of the string is a C++ keyword
  if (ACE_OS::strstr (lname, "_cxx_") == lname)
    {
      TAO_IDL_CPP_Keyword_Table cpp_key_tbl;

      unsigned int len =
        static_cast<unsigned int> (ACE_OS::strlen (lname + 5));

      const TAO_IDL_CPP_Keyword_Entry *entry =
        cpp_key_tbl.lookup (lname + 5, len);

      if (entry != 0)
        {
          ACE_CString tmp (lname + 5);
          local_name->replace_string (tmp.c_str ());
        }
    }
}
Exemplo n.º 27
0
FILE *
FE_Utils::open_included_file (char const * filename,
                              char const *& directory)
{
  FILE * f = 0;
  ACE_CString const the_file (ACE_CString ('/')
                              + ACE_CString (filename));

  for (IDL_GlobalData::Unbounded_Paths_Queue_Iterator i (
         idl_global->include_paths ());
       !i.done () && f == 0;
       i.advance ())
    {
      IDL_GlobalData::Include_Path_Info *path_info = 0;
      (void) i.next (path_info);

      if (path_info->path_ != 0)
        {
          ACE_CString const complete_filename (ACE_CString (path_info->path_)
                                               + the_file);

          f = ACE_OS::fopen (complete_filename.c_str (), "r");

          if (f != 0)
            directory = path_info->path_;
        }
    }

  return f;
}
Exemplo n.º 28
0
    ::DDS::StatusMask
    PortStatusListener::get_mask (
         ::CCM_DDS::PortStatusListener_ptr psl)
    {
      DDS4CCM_TRACE ("CIAO::DDS4CCM::PortStatusListener::get_mask");

      ::DDS::StatusMask mask = 0;
      if (! ::CORBA::is_nil (psl) ||
          DDS4CCM_debug_level >= DDS4CCM_LOG_LEVEL_DDS_STATUS)
        {
          mask = ::DDS::REQUESTED_DEADLINE_MISSED_STATUS |
                 ::DDS::SAMPLE_LOST_STATUS;
        }

      if (DDS4CCM_debug_level >= DDS4CCM_LOG_LEVEL_DDS_STATUS)
        {
          ACE_CString msk;
          translate_statusmask (msk, mask);
          DDS4CCM_DEBUG (DDS4CCM_LOG_LEVEL_DDS_STATUS, (LM_DEBUG, DDS4CCM_INFO
              "PortStatusListener::get_mask - "
              "Mask becomes %C\n",
              msk.c_str ()));
        }
      return mask;
    }
Exemplo n.º 29
0
void LameMP3::Close()
{
    if(!m_hMp3Stream)
        return;

    DWORD outLen = 0;
    int err = deinitStream(m_hMp3Stream, &m_out_mp3data[0], &outLen);
    assert(err == 0);
    if(outLen)
        m_outfile.send((const char*)&m_out_mp3data[0], outLen);

    ACE_TString filename = GetFileName();
    
    closeStream(m_hMp3Stream);
    
    m_outfile.close();
    
    if(filename.length())
    {
#if defined(UNICODE)
        //LAME doesn't support Unicode, so we just convert to locale
        //and hope for the best
        ACE_CString ascii = UnicodeToLocal(filename.c_str());
        err = writeInfoTag(m_hMp3Stream, ascii.c_str());
#else
        err = writeInfoTag(m_hMp3Stream, filename.c_str());
#endif
    }
    m_out_mp3data.resize(0);
    m_hMp3Stream = 0;
}
Exemplo n.º 30
0
ACE_BEGIN_VERSIONED_NAMESPACE_DECL

int
ACE_Codeset_Registry::locale_to_registry_i (const ACE_CString &locale,
                                            ACE_CDR::ULong &codeset_id,
                                            ACE_CDR::UShort *num_sets,
                                            ACE_CDR::UShort **char_sets)
{
  registry_entry const *element = 0;
  for (size_t i = 0; element == 0 && i < num_registry_entries_; i++)
    if (ACE_OS::strcmp (registry_db_[i].loc_name_, locale.c_str ()) == 0)
      element = &registry_db_[i];
  if (element == 0)
    return 0;
  codeset_id = element->codeset_id_;
  if (num_sets != 0)
    *num_sets = element->num_sets_;
  if (char_sets != 0)
    {
      ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0);
      ACE_OS::memcpy (*char_sets, element->char_sets_,
                      element->num_sets_ * sizeof (ACE_CDR::UShort));
    }
  return 1;
}