コード例 #1
0
ファイル: ZIP_Wrapper.cpp プロジェクト: DOCGroup/DAnCE
/// If entry in zipfile is a file, then read the file and write the
/// uncompressed data at the proper filepath.
int ZIP_Wrapper::handlethefile (char* filename_inzip, unzFile uf,
                                unz_file_info file_info, bool verbose,
                                ACE_CString arch_dir)
{
  int k = unzOpenCurrentFile(uf);
  if (k!=UNZ_OK)
    {
      DANCE_ERROR (DANCE_LOG_ERROR,
                   (LM_ERROR,ACE_TEXT("unzOpenCurrentFile failed in"
                                      " opening the current file")));
      return false;
    }
  else
    {
      size_t const file_size = file_info.uncompressed_size;
      char* temp = 0;
      ACE_NEW_RETURN (temp, char [file_size], false);
      ACE_Auto_Basic_Array_Ptr<char> buffer (temp);
      //read in the data
      unzReadCurrentFile(uf, &(*buffer), file_size);
      //close the zip handle
      unzCloseCurrentFile(uf);
      //create file name + path to open
      std::string file_path (arch_dir.c_str ());
     //NOTE: need the c-style char to stop at '\0'
      file_path += "/";
      file_path += filename_inzip;
      //print out the file to be uncompressed
      if (verbose)
        {
          ACE_OS::write(ACE_STDOUT, file_path.c_str (),
                              file_path.length () );
          ACE_OS::write(ACE_STDOUT, "\n", 1);
        }
      // Open a file handle to the local filesystem
      ACE_HANDLE handle = ACE_OS::open (file_path.c_str (),
                                        O_CREAT | O_TRUNC | O_WRONLY);
      if (handle == ACE_INVALID_HANDLE)
        {
          unzClose(uf);
          DANCE_ERROR_RETURN (DANCE_LOG_ERROR, (LM_ERROR,
                             ACE_TEXT ("%p\n"),
                             ACE_TEXT ("[uncompress] file creation error")),
                             0);
        }
      //write the uncompressed data to the file
      if (ACE_OS::write (handle, &(*buffer), file_size) == -1)
        {
          unzClose(uf);
          DANCE_ERROR_RETURN (DANCE_LOG_ERROR,
                              (LM_ERROR,
                               ACE_TEXT ("%p\n"),
                               ACE_TEXT ("[uncompress] file write error")),
                              0);
        }
      // Close the file handle
      ACE_OS::close (handle);
    }
  return 0;
}
コード例 #2
0
ファイル: CmpClient.cpp プロジェクト: asdlei00/ACE
    /// parses the arguments and extracts the params
  bool parse_args (int argc, ACE_TCHAR *argv[])
  {
    ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("t:u:d"));
    int c;
    while ((c = get_opts ()) != -1)
      switch (c)
      {
        case 't':
          stringified_TM_IOR = get_opts.opt_arg ();
          break;
        case 'u':
          host_name = get_opts.opt_arg ();
          call_update = true;
          break;
        case 'd':
          add_to_domain = false;
          break;
        case '?':  // display help for use of the server.
        default:
          DANCE_ERROR_RETURN (DANCE_LOG_EMERGENCY, (LM_ERROR,
                "usage:  %s\n"
                "-t <TM_IOR>\n"
                "-u <host_name in update>\n"
                "-n <delete , default add>\n"
                "\n",
                argv [0]),
              false);
      }

    return true;
  }
コード例 #3
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv [])
{
  // since this file is disabled by default, I guess
  DANCE_DISABLE_TRACE ();
  DANCE_TRACE ("ACE_TMAIN");

  int retval = 0;

  try
    {
      DAnCE::Logger_Service
        * dlf = ACE_Dynamic_Service<DAnCE::Logger_Service>::instance ("DAnCE_Logger");

      if (dlf)
        {
          dlf->init (argc, argv);
        }

      DAnCE::InstallationRepositoryManagerSvc
        * dirms = ACE_Dynamic_Service<DAnCE::InstallationRepositoryManagerSvc>::instance ("InstallationRepositoryManager");

      if (dirms)
        {
          dirms->init (argc, argv);
        }

      DAnCE::ArtifactInstallationHandlerSvc
        * dfihs = ACE_Dynamic_Service<DAnCE::ArtifactInstallationHandlerSvc>::instance ("FileInstallationHandler");

      if (dfihs)
        {
          dfihs->init (argc, argv);
        }

      DAnCE::ArtifactInstallationHandlerSvc
        * dhihs = ACE_Dynamic_Service<DAnCE::ArtifactInstallationHandlerSvc>::instance ("HttpInstallationHandler");

      if (dhihs)
        {
          dhihs->init (argc, argv);
        }

      DANCE_DEBUG (DANCE_LOG_EVENT_TRACE, (LM_TRACE, DLINFO
                       ACE_TEXT("dance_artifact_installation - initializing ORB\n")));

      // Need an ORB for the Config handlers
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      if (!parse_args (argc, argv))
        {
          return -1;
        }

      auto_ptr<Deployment::DeploymentPlan> plan;

      if (!cdr_encoded_)
        {
          plan.reset (DAnCE::Convert_Plan::read_xml_plan (input_filename));
        }
      else
        {
          plan.reset (DAnCE::Convert_Plan::read_cdr_plan (input_filename));
        }

      if (plan.get () == 0)
        {
          DANCE_ERROR_RETURN (DANCE_LOG_TERMINAL_ERROR,
            (LM_ERROR, DLINFO ACE_TEXT ("dance_artifact_installation - ")
            ACE_TEXT ("Unable to convert provided plan into IDL representation\n"))
            // @will   changed this to use DANCE_ERROR_RETURN and am still
            //         returning 0 rather than a real error code
            , 0);
        }

      // instantiate artifact installation service
      DAnCE::ArtifactInstallation_Impl* installer = 0;
      ACE_NEW_RETURN (installer,
                      DAnCE::ArtifactInstallation_Impl (),
                      1);
      PortableServer::Servant_var<DAnCE::ArtifactInstallation_Impl> pinstaller (installer);

      pinstaller->initialize ();

      // install artifacts
      for (CORBA::ULong i=0;
           i < plan->artifact.length ();
           ++i)
        {
          pinstaller->install(plan->UUID.in (),
                  plan->artifact[i]);
        }

      pinstaller->clear ();
    }
  catch (const CORBA::Exception &ex)
    {
      // @will I'm not as familiar with CORBA exceptions, but this appears
      //       to take control out of our hands for error logging
      //       this file doesn't seem to be included in default projects
      //       is this even an issue?
      ex._tao_print_exception ("dance_artifact_installation");
      retval = 1;
    }
  catch (...)
    {
      DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
        (LM_ERROR,
           "dance_artifact_installation - error: unknown c++ exception\n"));
      retval = 1;
    }

  return retval;
}