コード例 #1
0
static void
parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_LOG_MSG->open (argv[0]);

  //FUZZ: disable check_for_lack_ACE_OS
  // Start at argv[1]
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT("m:ui:"), 1);

  for (int c; (c = getopt ()) != -1; )
  //FUZZ: enable check_for_lack_ACE_OS
    switch (c)
      {
      case 'm':
        max_message_size = ACE_OS::atoi (getopt.opt_arg ()) * BUFSIZ;
        break;
      case 'i':
        iterations = ACE_OS::atoi (getopt.opt_arg ());
        break;
      case 'u':
        // usage fallthrough
      default:
        ACE_ERROR ((LM_ERROR,
                    "%n: -m max_message_size (in k) -i iterations\n%a",
                    1));
        /* NOTREACHED */
      }
}
コード例 #2
0
ファイル: server.cpp プロジェクト: OspreyHub/ATCD
int
Server::parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt opts (argc, argv, ACE_TEXT("f:p:"));

  int c;
  while ((c = opts ()) != -1)
    {
      switch (c)
        {
        case 'f':
          this->fp_ = ACE_OS::fopen (opts.opt_arg (),"w");
          if (this->fp_ != 0)
            {
              ACE_DEBUG ((LM_DEBUG,"file opened successfully\n"));
            }
          break;
        case 'p':
          this->protocol_ = ACE_OS::strdup (ACE_TEXT_ALWAYS_CHAR (opts.opt_arg ()));
          break;
        default:
          ACE_ERROR_RETURN ((LM_ERROR,"Usage: server -f filename\n"),-1);
        }
    }

    if( ! this->fp_ )
    {
       ACE_ERROR_RETURN ((LM_ERROR, "Invalid file!\nUsage: server -f filename\n"),-1);
    }

  return 0;
}
コード例 #3
0
int
Options::parse_args (int argc, ACE_TCHAR *argv[])
{
  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("p:r:v"), 1);

  for (int c; (c = getopt ()) != -1; )
  //FUZZ: enable check_for_lack_ACE_OS
    switch (c)
      {
      case 'p':
        this->port_ = ACE_OS::atoi (getopt.opt_arg ());
        break;
      case 'r':
        this->reply_message_len_ = ACE_OS::atoi (getopt.opt_arg ());
        break;
      case 'v':
        this->verbose_ = 1;
        break;
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("(%P|%t) usage: %n [-p <port>] [-v]")),
                          -1);
      }

  return 0;
}
コード例 #4
0
ファイル: server.cpp プロジェクト: OspreyHub/ATCD
int
parse_args (int argc,
            ACE_TCHAR *argv[])
{
  ACE_Get_Opt opts (argc,
                    argv,
                    "f:");

  int c;
  while ((c = opts ()) != -1)
    {
      switch (c)
        {
        case 'f':
          output_file_name = opts.opt_arg ();
          break;
        default:
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Usage: server -f filename"),
                            -1);
        }
    }

  return 0;
}
コード例 #5
0
ファイル: receiver.cpp プロジェクト: CCJY/ATCD
int
Receiver::parse_args (int argc, ACE_TCHAR *argv[])
{
  // Parse the command line arguments
  ACE_Get_Opt opts (argc,
                    argv,
                    "f:s:r:a:");

  int c;
  while ((c = opts ()) != -1)
    {
      switch (c)
        {
        case 'a':
          this->addr_file_ = opts.opt_arg ();
          break;
        case 'f':
          this->output_file_name_ = opts.opt_arg ();
          break;
        case 's':
          this->sender_name_ = ACE_TEXT_ALWAYS_CHAR (opts.opt_arg ());
          break;
        case 'r':
          this->receiver_name_ = ACE_TEXT_ALWAYS_CHAR (opts.opt_arg ());
          break;
        default:
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Usage: receiver -f filename"),
                            -1);
        }
    }

  return 0;
}
コード例 #6
0
ファイル: sender.cpp プロジェクト: asdlei00/ACE
int
Sender::parse_args (int argc,
                    ACE_TCHAR *argv[])
{
  // Parse command line arguments
  ACE_Get_Opt opts (argc, argv, ACE_TEXT("f:p:r:d"));

  int c;
  while ((c= opts ()) != -1)
    {
      switch (c)
        {
        case 'f':
          this->filename_ = ACE_TEXT_ALWAYS_CHAR (opts.opt_arg ());
          break;
        case 'p':
          this->protocol_ = ACE_TEXT_ALWAYS_CHAR (opts.opt_arg ());
          break;
        case 'r':
          this->frame_rate_ = ACE_OS::atoi (opts.opt_arg ());
          break;
        case 'd':
          TAO_debug_level++;
          break;
        default:
          ACE_DEBUG ((LM_DEBUG, "Unknown Option\n"));
          return -1;
        }
    }
  return 0;
}
コード例 #7
0
ファイル: Server.cpp プロジェクト: CCJY/ACE
void
JAWS_Server::parse_args (int argc, ACE_TCHAR *argv[])
{
  int c;
  int t = 0;

  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT("t" "p:c:d:n:m:f:r:"));
  while ((c = getopt ()) != -1)
  //FUZZ: enable check_for_lack_ACE_OS
    switch (c)
      {
      case 't':
        t = !t;
        break;
      case 'p':
        this->port_ = ACE_OS::atoi (getopt.opt_arg ());
        break;
      case 'c':
        if (ACE_OS::strcmp (getopt.opt_arg (), "PER_REQUEST") == 0)
          this->concurrency_ = 1;
        else this->concurrency_ = 0;
        break;
      case 'd':
        if (ACE_OS::strcmp (getopt.opt_arg (), "ASYNCH") == 0)
          this->dispatch_ = 1;
        else this->dispatch_ = 0;
        break;
      case 'n':
        this->nthreads_ = ACE_OS::atoi (getopt.opt_arg ());
        break;
      case 'm':
        this->maxthreads_ = ACE_OS::atoi (getopt.opt_arg ());
        break;
      case 'f':
        if (ACE_OS::strcmp (getopt.opt_arg (), "THR_BOUND") == 0)
          this->flags_ |= THR_BOUND;
        else if (ACE_OS::strcmp (getopt.opt_arg (), "THR_DAEMON") == 0)
          this->flags_ |= THR_DAEMON;
        else if (ACE_OS::strcmp (getopt.opt_arg (), "THR_DETACHED") == 0)
          this->flags_ |= THR_DETACHED;
        break;
      case 'r':
        this->ratio_ = ACE_OS::atoi (getopt.opt_arg ());
        break;
      }

#if (ACE_NTRACE != 1)
  if (t)
    ACE_Trace::start_tracing ();
  else
    ACE_Trace::stop_tracing ();
#endif /* ACE_NTRACE != 1*/

  if (this->port_ == 0) this->port_ = 5432;
  if (this->nthreads_ == 0) this->nthreads_ = 5;
  if (this->maxthreads_ == 0) this->maxthreads_ = 20;
}
コード例 #8
0
ファイル: Service_Config.cpp プロジェクト: Desch/MythCore
int
ACE_Service_Config::parse_args_i (int argc, ACE_TCHAR *argv[])
{
  ACE_TRACE ("ACE_Service_Config::parse_args_i");

  // Using PERMUTE_ARGS (default) in order to have all
  // unrecognized options and their value arguments moved
  // to the end of the argument vector. We'll pick them up
  // after processing our options and pass them on to the
  // base class for further parsing.
  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc,
                      argv,
                      ACE_TEXT ("bs:p:"),
                      1  ,                       // Start at argv[1].
                      0,                       // Do not report errors
                      ACE_Get_Opt::RETURN_IN_ORDER);
  //FUZZ: enable check_for_lack_ACE_OS

  //FUZZ: disable check_for_lack_ACE_OS
  for(int c; (c = getopt ()) != -1; )
  //FUZZ: enable check_for_lack_ACE_OS
    switch(c)
      {
      case 'p':
        ACE_Service_Config::pid_file_name_ = getopt.opt_arg ();
        break;
      case 'b':
        ACE_Service_Config::be_a_daemon_ = true;
        break;
      case 's':
        {
          // There's no point in dealing with this on NT since it
          // doesn't really support signals very well...
#if !defined (ACE_LACKS_UNIX_SIGNALS)
          ACE_Service_Config::signum_ =
            ACE_OS::atoi (getopt.opt_arg ());

          if(ACE_Reactor::instance ()->register_handler
              (ACE_Service_Config::signum_,
               ACE_Service_Config::signal_handler_) == -1)
            ACE_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT ("cannot obtain signal handler\n")),
                              -1);
#endif /* ACE_LACKS_UNIX_SIGNALS */
          break;
        }
      default:; // unknown arguments are benign

      }

  return 0;
} /* parse_args_i () */
コード例 #9
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("csn:xi:d:"));

  int is_consumer = 1;          // By default, make us a consumer.
  int delete_sema = 0;
  int iteration = 0;
  int exit_delay = 0;
  const ACE_TCHAR *sema_name = ACE_TEXT ("Process_Semaphore_Test");

  int opt;

  while ((opt = getopt ()) != -1)
    {
      switch (opt)
        {
        case 'c':               // Make us a consumer.
          is_consumer = 1;
          break;
        case 's':               // Make us a supplier.
          is_consumer = 0;
          break;
        case 'x':               // Remove the semaphore after we're done.
          delete_sema = 1;
          break;
        case 'n':               // Specify the name of the semaphore.
          sema_name = getopt.opt_arg ();
          break;
        case 'i':               // Number of acquire/release we'll perform.
          iteration = ACE_OS::atoi (getopt.opt_arg ());
          break;
        case 'd':
          exit_delay = ACE_OS::atoi (getopt.opt_arg ());
          break;
        default:
          return -1;
        }
    };

  ACE_SYNCH_PROCESS_SEMAPHORE sema (0, sema_name);

  if (is_consumer != 0)
    consumer (sema, iteration);
  else
    producer (sema, iteration);

  ACE_OS::sleep (exit_delay);

  if (delete_sema != 0)
    sema.remove ();
  return 0;
}
コード例 #10
0
ファイル: Globals.cpp プロジェクト: CCJY/ATCD
int
Globals::parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt opts (argc, argv, ACE_TEXT("e:t:f:rm"));
  int c;

  while ((c = opts ()) != -1)
    {
      switch (c)
      {
      case 'm':
        use_multiple_priority = 1;
        break;
      case 'r':
        thread_per_rate = 1;
        break;
      case 'f':
        ACE_NEW_RETURN (ior_file,
                        ACE_TCHAR[BUFSIZ],
                        -1);
        ACE_OS::strcpy (ior_file,
                        opts.opt_arg ());
        break;
      case 'e':
        ACE_OS::strcpy (endpoint,
                        opts.opt_arg ());
        break;
      case 't':
        num_of_objs = ACE_OS::atoi (opts.opt_arg ());
        break;
      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s \t"
                           "[-e <endpoint>]                // starting endpoint                  \n\t\t\t"
                           "[-t <number_of_servants>]      // # of servant threads to create     \n\t\t\t"
                           "[-f <ior_file> ]               // specify a file to output all ior's \n\t\t\t"
                           "[-m ]                          // Use multiple priorities for threads\n\t\t\t"
                           "[-r ]                          // Run the thread-per-rate test      \n"
                           ,argv [0]),
                          -1);
      }
    }

  if (thread_per_rate == 1)
    num_of_objs = THREAD_PER_RATE_OBJS;

  // Indicates successful parsing of the command-line.
  return 0;
}
コード例 #11
0
ファイル: SOCK_Dgram_Bcast_Test.cpp プロジェクト: esohns/ATCD
int run_main (int argc, ACE_TCHAR *argv[])
{
  // parse options and run in appropriate mode
  int opt             = 0;
  int auto_test_recv  = 0;
  int result          = 0;
  ACE_Get_Opt opts (argc, argv, ACE_TEXT ("p:t:n:sra"));
  while ((opt = opts ()) != -1)
    switch (opt)
      {
      case 'a':
        auto_test_recv = 1;
        break;
      case 's':
        return (run_sender());
      case 'r':
        {
          if (auto_test_recv)
            {
              ACE_START_TEST (ACE_TEXT ("SOCK_Dgram_Bcast_Test_Child"));
              result = run_receiver ();
              ACE_END_TEST;
              return result;
            }
          return (run_receiver ());
        }
      case 'n':
        dgrams_no = ACE_OS::atoi (opts.opt_arg ());
        break;
      case 't':
        dgram_recv_timeout.msec (ACE_OS::atoi (opts.opt_arg ()));
        break;
      case 'p':
        dgram_port = ACE_OS::atoi (opts.opt_arg ());
        break;
      default:
        print_usage ();
        return -1;
      }
  ACE_START_TEST (ACE_TEXT ("SOCK_Dgram_Bcast_Test"));

#ifndef ACE_LACKS_IOCTL
  result = run_auto_test (argc > 0 ? argv[0] : ACE_TEXT ("SOCK_Dgram_Bcast_Test"));
#endif

  ACE_END_TEST;
  return result;
}
コード例 #12
0
ファイル: Baseline_Test.cpp プロジェクト: azraelly/knetwork
int
Baseline_Test_Base::parse_args (int argc, ACE_TCHAR *argv[])
{
  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT("i:ylrw"), 0);
  int c;

  while ((c = getopt ()) != -1)
  //FUZZ: enable check_for_lack_ACE_OS
    switch (c)
      {
      case 'i':                 // Total iterations
        {
          int tmp = ACE_OS::atoi (getopt.opt_arg ());
          if (tmp <= 0)
            ACE_ERROR_RETURN ((LM_ERROR,
                               "%d is not a valid value for iteration\n",
                               tmp), -1);
          else
            this->iteration_ = static_cast<size_t> (tmp);
        }
        break;

      case 'y':                 // Use thr_yield.
        this->yield_method_ = Baseline_Test_Options::USE_THR_YIELD;
        break;

      case 'l':
        this->what_ = TEST_LOCK;
        break;

      case 'r':
        this->what_ = TEST_READLOCK;
        break;

      case 'w':
        this->what_ = TEST_WRITELOCK;
        break;

      default:
        ACE_ERROR ((LM_ERROR, "Invalid argument %c used\n", c));
        break;
      }
  return 0;
}
コード例 #13
0
ファイル: Service_Manager.cpp プロジェクト: binary42/OCI
int
ACE_Service_Manager::init (int argc, ACE_TCHAR *argv[])
{
  ACE_TRACE ("ACE_Service_Manager::init");
  ACE_INET_Addr local_addr (ACE_Service_Manager::DEFAULT_PORT_);

  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("dp:s:"), 0); // Start at argv[0]

  for (int c; (c = getopt ()) != -1; )
  //FUZZ: enable check_for_lack_ACE_OS
     switch (c)
       {
       case 'd':
         this->debug_ = true;
         break;
       case 'p':
         local_addr.set ((u_short) ACE_OS::atoi (getopt.opt_arg ()));
         break;
       case 's':
         this->signum_ = ACE_OS::atoi (getopt.opt_arg ());
         break;
       default:
         break;
       }

  if (this->get_handle () == ACE_INVALID_HANDLE &&
      this->open (local_addr) == -1)
    {
      ACELIB_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("%p\n"),
                         ACE_TEXT ("open")), -1);
    }
  else if (ACE_Reactor::instance ()->register_handler
           (this,
            ACE_Event_Handler::ACCEPT_MASK) == -1)
    {
      ACELIB_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("registering service with ACE_Reactor\n")),
                        -1);
    }

  return 0;
}
コード例 #14
0
ファイル: Log_Backend.cpp プロジェクト: DOCGroup/DAnCE
  int
  NDDS_Log_Backend::init (int argc, ACE_TCHAR **argv)
  {
    ACE_Get_Opt opts (argc, argv, ACE_TEXT ("t:d:q:n:"), 0, 0,
                      ACE_Get_Opt::RETURN_IN_ORDER);
    opts.long_option (ACE_TEXT ("topic"), 't', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT ("domain"), 'd', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT ("qos-file"), 'q', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT ("node-name"), 'n', ACE_Get_Opt::ARG_REQUIRED);

    int c = 0;

    while ((c = opts ()) != -1)
      {
        switch (c)
          {
          case 't':
            this->topic_name_ = opts.opt_arg ();
            break;

          case 'd':
            this->domain_ = ACE_OS::atoi (opts.opt_arg ());
            break;

          case 'q':
            this->qos_file_ = opts.opt_arg ();
            break;

          case 'n':
            this->node_ = opts.opt_arg ();
            break;

          default:
            ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unknown option for NDDS_Log_Backend: %s\n"),
                        opts.last_option ()));
          }

      }

    return this->open (ACE_TEXT (""));
  }
コード例 #15
0
ファイル: Latency_Query_Client.cpp プロジェクト: CCJY/ATCD
int
Latency_Query_Client::parse_args (int argc,
                                  ACE_TCHAR *argv[])
{
  ACE_Get_Opt opts (argc, argv, ACE_TEXT("dhi:"));
  int c;
  int result = 0;

  while ((c = opts ()) != -1)
    {
      switch (c)
        {
        case 'd':
          this->debug_ = true;
          break;
        case 'h':
          this->do_dump_history_ = true;
          break;
        case 'i':
          result = ACE_OS::atoi (opts.opt_arg ());

          if (result > 0)
            {
              this->iterations_ = result;
            }

          break;
        case '?':
        default:
          ACE_ERROR_RETURN ((LM_ERROR,
                            "usage: %s"
                            " [-d]"
                            " [-i iterations]"
                            "\n",
                            argv [0]),
                            -1);
        }
    }

  return 0;
}
コード例 #16
0
ファイル: test_client.cpp プロジェクト: OspreyHub/ATCD
int
parse_args (int argc,
            ACE_TCHAR* argv [])
{
  // Parse command line arguments
  ACE_Get_Opt opts (argc, argv, ACE_TEXT("f:"));

  int c;
  while ((c= opts ()) != -1)
    {
      switch (c)
        {
        case 'f':
          ior = ACE_TEXT("file://");
          ior += opts.opt_arg ();
          break;
        default:
          ACE_DEBUG ((LM_DEBUG, "Unknown Option\n"));
          return -1;
        }
    }
  return 0;
}
コード例 #17
0
static void
parse_arg (int argc, ACE_TCHAR *argv[])
{
  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("r:s:c:d:i:n:"));

  int c;

  while ((c = getopt ()) != -1)
    {
  //FUZZ: enable check_for_lack_ACE_OS
      switch (c)
        {
        case 'r':                   // hostname:port
          rendezvous = getopt.opt_arg ();
          break;
        case 's':
          svr_thrno = ACE_OS::atoi (getopt.opt_arg ());
          break;
        case 'c':
          cli_thrno = ACE_OS::atoi (getopt.opt_arg ());
          break;
        case 'd':
          req_delay = ACE_OS::atoi (getopt.opt_arg ());
          break;
        case 'i':
          cli_conn_no = ACE_OS::atoi (getopt.opt_arg ());
          break;
        case 'n':
          cli_req_no = ACE_OS::atoi (getopt.opt_arg ());
          break;
        default:
          ACE_ERROR ((LM_ERROR,
                      "Usage: Thread_Pool_Reactor_Test [-r <hostname:port#>]"
                      "\t[-s <server thr#>] [-c <client thr#>] [-d <delay>]"
                      "\t[-i <client conn attempt#>]"
                      "[-n <client request# per conn>]\n"));
          break;
        }
    }
}
コード例 #18
0
static void
parse_args (int argc, ACE_TCHAR *argv[])
{
  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("r:t:d:i:n:"));

  int c;

  while ((c = getopt ()) != -1)
    {
  //FUZZ: enable check_for_lack_ACE_OS
      switch (c)
        {
        case 'r':                   // hostname:port
          rendezvous = getopt.opt_arg ();
          break;
        case 't':
          num_threads = ACE_OS::atoi (getopt.opt_arg ());
          break;
        case 'd':
          req_delay = ACE_OS::atoi (getopt.opt_arg ());
          break;
        case 'i':
          cli_conn_no = ACE_OS::atoi (getopt.opt_arg ());
          break;
        case 'n':
          cli_req_no = ACE_OS::atoi (getopt.opt_arg ());
          break;
        default:
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("Usage: %s [-r <hostname:port#>]")
                      ACE_TEXT ("\t[-t <nr threads>] [-d <delay>]")
                      ACE_TEXT ("\t[-i <client conn attempt#>]")
                      ACE_TEXT ("\t[-n <client request# per conn>]\n"),
                      argv[0]));
          break;
        }
    }
}
コード例 #19
0
ファイル: MEM_Stream_Test.cpp プロジェクト: asdlei00/ACE
int
run_main (int argc, ACE_TCHAR *argv[])
{
  u_short port = 0;

  if (argc == 1)
    {
      // This is the "master" process.

      ACE_START_TEST (ACE_TEXT ("MEM_Stream_Test"));
      create_reactor ();
      ACE_MEM_Addr server_addr (port);

      reset_handler (NUMBER_OF_REACTIVE_CONNECTIONS);

      test_reactive (argc > 0 ? argv[0] : ACE_TEXT ("MEM_Stream_Test"), server_addr);

      ACE_Reactor::instance ()->reset_reactor_event_loop ();

#if !defined (ACE_WIN32) && defined (_ACE_USE_SV_SEM)
      ACE_ERROR ((LM_DEBUG,
                  ACE_TEXT ("\n *** Platform only supports non-scalable SysV semaphores ***\n\n")));
#endif /* !ACE_WIN32 && _ACE_USE_SV_SEM */
      reset_handler (NUMBER_OF_MT_CONNECTIONS);

      test_concurrent (argc > 0 ? argv[0] : ACE_TEXT ("MEM_Stream_Test"), server_addr);

      ACE_END_TEST;
      return 0;
    }
  else
    {
      // We end up here if this is a child process spawned for one of
      // the test passes.  command line is: -p <port> -r (reactive) |
      // -m (multithreaded)

      ACE_TCHAR lognm[MAXPATHLEN];
      int mypid (ACE_OS::getpid ());
      ACE_OS::sprintf(lognm, ACE_TEXT ("MEM_Stream_Test-%d"), mypid);
      ACE_START_TEST (lognm);

      ACE_Get_Opt opts (argc, argv, ACE_TEXT ("p:rm"));
      int opt, iport, status;
      ACE_MEM_IO::Signal_Strategy model = ACE_MEM_IO::Reactive;

      while ((opt = opts()) != -1)
        {
          switch (opt)
            {
            case 'p':
              iport = ACE_OS::atoi (opts.opt_arg ());
              port = static_cast <u_short> (iport);
              break;

            case 'r':
              model = ACE_MEM_IO::Reactive;
              break;

            case 'm':
              model = ACE_MEM_IO::MT;
              break;

            default:
              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("Invalid option (-p <port> -r | -m)\n")),
                                1);
            }
        }
      status = run_client (port, model);
      ACE_END_TEST;
      return status;
    }
}
コード例 #20
0
int 
Options::parse_args (int argc, ACE_TCHAR *argv[])
{
  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("df:h:i:l:rt:u:vo:p:"));
  //FUZZ: enable check_for_lack_ACE_OS

  ACE_LOG_MSG->open (argv[0]);

  this->hostname_ = ACE_TEXT ("www.cs.wustl.edu");
  this->uri_ = ACE_TEXT ("index.html");
  this->recurse_ = 0;
  this->debug_ = 0;
  this->timeout_.sec (ACE_DEFAULT_TIMEOUT);
  this->url_filter_ = 0;
  this->verbose_ = 0;
  this->order_ = ACE_TEXT ("FIFO");
  this->port_no_ = ACE_DEFAULT_HTTP_PORT;
  
  // The default is to make this limit as large as possible.
  this->handle_limit_ = -1;

  //FUZZ: disable check_for_lack_ACE_OS
  for (int c;
       (c = getopt ()) != EOF;
       )
  //FUZZ: enable check_for_lack_ACE_OS
    switch (c)
      {
      case ACE_TEXT ('d'):
        this->debug_ = 1;
        break;
      case ACE_TEXT ('f'):
        this->url_filter_ = getopt.opt_arg ();
        break;
      case ACE_TEXT ('h'):
        this->hostname_ = getopt.opt_arg ();
        break;
      case ACE_TEXT ('i'):
        this->uri_ = getopt.opt_arg ();
        break;
      case ACE_TEXT ('l'):
        this->handle_limit_ = ACE_OS::atoi (getopt.opt_arg ());
        break;
      case ACE_TEXT ('r'):
        this->recurse_ = 1;
        break;
      case ACE_TEXT ('t'):
        this->timeout_.sec (ACE_OS::atoi (getopt.opt_arg ()));
        break;
      case ACE_TEXT ('u'):
        {
          this->hostname_ = getopt.opt_arg ();
          ACE_TCHAR *s = ACE_OS::strchr (getopt.opt_arg (), ACE_TEXT ('/'));
          if (s != 0)
            {
              this->uri_ = s + 1;
              *s = ACE_TEXT ('\0');
            }
          else
            ACE_ERROR ((LM_ERROR,
                        ACE_TEXT ("invalid URL %s\n"),
                        getopt.opt_arg ()));
        }
        break;
      case ACE_TEXT ('v'):
        this->verbose_ = 1;
        break;
      case ACE_TEXT ('o'):
        {
        this->order_ = getopt.opt_arg ();
        }
        break;
      case ACE_TEXT ('p'):
        this->port_no_ = ACE_OS::atoi (getopt.opt_arg ());
        break;
      default:
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT ("usage: %n [-d] [-f filter] [-h hostname]")
                    ACE_TEXT (" [-l handle-limit] [-r] [-t timeout] [-u URI]")
                    ACE_TEXT (" [-v]\n%a"),
                    1));

        /* NOTREACHED */
      }

  return 0;
}
コード例 #21
0
ファイル: map_parser.cpp プロジェクト: bhutnath/yarp
bool
do_processArguments (const int argc_in,
                     ACE_TCHAR** argv_in, // cannot be const...
                     bool& debugScanner_out,
                     bool& debugParser_out,
                     std::string& mapFile_out,
                     bool& traceInformation_out,
                     bool& printVersionAndExit_out)
{
  RPG_TRACE (ACE_TEXT ("::do_processArguments"));

  std::string data_path =
    RPG_Common_File_Tools::getConfigurationDataDirectory (ACE_TEXT_ALWAYS_CHAR (BASEDIR),
                                                          false);
#if defined (DEBUG_DEBUGGER)
  data_path = Common_File_Tools::getWorkingDirectory ();
#endif

  // init results
  debugScanner_out = MAP_PARSER_DEF_DEBUG_SCANNER;
  debugParser_out = MAP_PARSER_DEF_DEBUG_PARSER;

  mapFile_out = data_path;
  mapFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#if defined (DEBUG_DEBUGGER)
  mapFile_out += (MAP_GENERATOR_DEF_LEVEL ? ACE_TEXT_ALWAYS_CHAR ("engine")
                                          : ACE_TEXT_ALWAYS_CHAR ("map"));
  mapFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
  mapFile_out += ACE_TEXT_ALWAYS_CHAR("data");
  mapFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#else
  mapFile_out += ACE_TEXT_ALWAYS_CHAR(RPG_MAP_MAPS_SUB);
  mapFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#endif
  mapFile_out += (MAP_GENERATOR_DEF_LEVEL ? RPG_Common_Tools::sanitize (ACE_TEXT_ALWAYS_CHAR (RPG_ENGINE_LEVEL_DEF_NAME))
                                          : ACE_TEXT_ALWAYS_CHAR (RPG_MAP_DEF_MAP_FILE));
  mapFile_out += (MAP_GENERATOR_DEF_LEVEL ? ACE_TEXT_ALWAYS_CHAR(RPG_ENGINE_LEVEL_FILE_EXT)
                                          : ACE_TEXT_ALWAYS_CHAR(RPG_MAP_FILE_EXT));

  traceInformation_out = false;
  printVersionAndExit_out = false;

  ACE_Get_Opt argumentParser (argc_in,
                              argv_in,
                              ACE_TEXT ("m:pstv"));

  int option = 0;
  while ((option = argumentParser ()) != EOF)
  {
    switch (option)
    {
      case 'm':
      {
        mapFile_out = argumentParser.opt_arg ();

        break;
      }
      case 'p':
      {
        debugParser_out = true;

        break;
      }
      case 's':
      {
        debugScanner_out = true;

        break;
      }
      case 't':
      {
        traceInformation_out = true;

        break;
      }
      case 'v':
      {
        printVersionAndExit_out = true;

        break;
      }
      // error handling
      case '?':
      {
        ACE_DEBUG((LM_ERROR,
                   ACE_TEXT("unrecognized option \"%s\", aborting\n"),
                   argumentParser.last_option()));

        return false;
      }
      default:
      {
        ACE_DEBUG((LM_ERROR,
                   ACE_TEXT("unrecognized option \"%c\", aborting\n"),
                   option));

        return false;
      }
    } // end SWITCH
  } // end WHILE

  return true;
}
コード例 #22
0
ファイル: Multicast_Test.cpp プロジェクト: CCJY/ACE
int
MCT_Config::open (int argc, ACE_TCHAR *argv[])
{
  int retval = 0;
  int help = 0;

  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT (":?"), 1, 1);
  //FUZZ: enable check_for_lack_ACE_OS

  if (getopt.long_option (ACE_TEXT ("GroupStart"),
                          'g',
                          ACE_Get_Opt::ARG_REQUIRED) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT (" Unable to add GroupStart option.\n")),
                      1);

  if (getopt.long_option (ACE_TEXT ("Groups"),
                          'n',
                          ACE_Get_Opt::ARG_REQUIRED) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT (" Unable to add Groups option.\n")), 1);

  if (getopt.long_option (ACE_TEXT ("Debug"),
                          'd',
                          ACE_Get_Opt::NO_ARG) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT (" Unable to add Debug option.\n")), 1);

  if (getopt.long_option (ACE_TEXT ("Role"),
                          'r',
                          ACE_Get_Opt::ARG_REQUIRED) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT (" Unable to add Role option.\n")), 1);

  if (getopt.long_option (ACE_TEXT ("SDM_options"),
                          'm',
                          ACE_Get_Opt::ARG_REQUIRED) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT (" Unable to add Multicast_Options option.\n")),
                      1);

  if (getopt.long_option (ACE_TEXT ("Iterations"),
                          'i',
                          ACE_Get_Opt::ARG_REQUIRED) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT (" Unable to add iterations option.\n")),
                      1);

  if (getopt.long_option (ACE_TEXT ("TTL"),
                          't',
                          ACE_Get_Opt::ARG_REQUIRED) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT (" Unable to add TTL option.\n")),
                      1);

  if (getopt.long_option (ACE_TEXT ("Wait"),
                          'w',
                          ACE_Get_Opt::ARG_REQUIRED) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT (" Unable to add wait option.\n")),
                      1);

  if (getopt.long_option (ACE_TEXT ("help"),
                          'h',
                          ACE_Get_Opt::NO_ARG) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT (" Unable to add help option.\n")),
                      1);

  //FUZZ: disable check_for_lack_ACE_OS
  // Now, let's parse it...
  int c = 0;
  while ((c = getopt ()) != EOF)
    {
      //FUZZ: enable check_for_lack_ACE_OS
      switch (c)
        {
        case 0:
          // Long Option. This should never happen.
          retval = -1;
           break;
        case 'g':
          {
            // @todo validate all these, i.e., must be within range
            // 224.255.0.0 to 238.255.255.255, but we only allow the
            // administrative "site local" range, 239.255.0.0 to
            // 239.255.255.255.
            ACE_TCHAR *group = getopt.opt_arg ();
            if (this->group_start_.set (group) != 0)
              {
                ACE_ERROR ((LM_ERROR, ACE_TEXT ("Bad group address:%s\n"),
                            group));
              }
          }
          break;
        case 'i':
          this->iterations_ = ACE_OS::atoi (getopt.opt_arg ());
          break;
        case 'n':
          {
            int n = ACE_OS::atoi (getopt.opt_arg ());
            // I'm assuming 0 means unlimited, so just use whatever the
            // user provides.  Seems to work okay on Solaris 5.8.
            if (IP_MAX_MEMBERSHIPS == 0)
              this->groups_ = n;
            else
              this->groups_ = ACE_MIN (ACE_MAX (n, MCT_MIN_GROUPS),
                                       IP_MAX_MEMBERSHIPS);
            break;
          }
        case 'd':
          this->debug_ = 1;
          break;
        case 'r':
          {
            ACE_TCHAR *c = getopt.opt_arg ();
            if (ACE_OS::strcasecmp (c, ACE_TEXT ("CONSUMER")) == 0)
              this->role_ = CONSUMER;
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("PRODUCER")) == 0)
              this->role_ = PRODUCER;
            else
              {
                help = 1;
                retval = -1;
              }
          }
          break;
        case 'm':
          {
            //@todo add back OPT_BINDADDR_NO...
            ACE_TCHAR *c = getopt.opt_arg ();
            if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_BINDADDR_YES")) == 0)
              ACE_SET_BITS (this->sdm_opts_,
                            ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES);
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_BINDADDR_NO")) == 0)
              ACE_CLR_BITS (this->sdm_opts_,
                            ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES);
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("DEFOPT_BINDADDR")) == 0)
              {
                ACE_CLR_BITS (this->sdm_opts_,
                              ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES);
                ACE_SET_BITS (this->sdm_opts_,
                              ACE_SOCK_Dgram_Mcast::DEFOPT_BINDADDR);
              }
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_NULLIFACE_ALL")) == 0)
              ACE_SET_BITS (this->sdm_opts_,
                            ACE_SOCK_Dgram_Mcast::OPT_NULLIFACE_ALL);
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_NULLIFACE_ONE")) == 0)
              ACE_CLR_BITS (this->sdm_opts_,
                            ACE_SOCK_Dgram_Mcast::OPT_NULLIFACE_ALL);
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("DEFOPT_NULLIFACE")) == 0)
              {
                ACE_CLR_BITS (this->sdm_opts_,
                              ACE_SOCK_Dgram_Mcast::OPT_NULLIFACE_ALL);
                ACE_SET_BITS (this->sdm_opts_,
                              ACE_SOCK_Dgram_Mcast::DEFOPT_NULLIFACE);
              }
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("DEFOPTS")) == 0)
              this->sdm_opts_ = ACE_SOCK_Dgram_Mcast::DEFOPTS;
            else
              {
                help = 1;
                retval = -1;
              }
          }
          break;
        case 't':
          this->ttl_ = ACE_OS::atoi (getopt.opt_arg ());
          break;
        case 'w':
          this->wait_ = ACE_OS::atoi (getopt.opt_arg ());
          break;
        case ':':
          // This means an option requiring an argument didn't have one.
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT (" Option '%c' requires an argument but ")
                      ACE_TEXT ("none was supplied\n"),
                      getopt.opt_opt ()));
          help = 1;
          retval = -1;
          break;
        case '?':
        case 'h':
        default:
          if (ACE_OS::strcmp (argv[getopt.opt_ind () - 1], ACE_TEXT ("-?")) != 0
              && getopt.opt_opt () != 'h')
            // Don't allow unknown options.
            ACE_ERROR ((LM_ERROR,
                        ACE_TEXT (" Found an unknown option (%c) ")
                        ACE_TEXT ("we couldn't handle.\n"),
                        getopt.opt_opt ()));
                        // getopt.last_option ())); //readd with "%s" when
                        // last_option() is available.
          help = 1;
          retval = -1;
          break;
        }
    }

  if (retval == -1)
    {
      if (help)
        // print usage here
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT ("usage: %s [options]\n")
                    ACE_TEXT ("Options:\n")
                    ACE_TEXT ("  -g {STRING}  --GroupStart={STRING}  ")
                    ACE_TEXT ("starting multicast group address\n")
                    ACE_TEXT ("                                      ")
                    ACE_TEXT ("(default=239.255.0.1:16000)\n")
                    ACE_TEXT ("  -n {#}       --Groups={#}           ")
                    ACE_TEXT ("number of groups (default=5)\n")
                    ACE_TEXT ("  -d           --Debug                ")
                    ACE_TEXT ("debug flag (default=off)\n")
                    ACE_TEXT ("  -r {STRING}  --Role={STRING}        ")
                    ACE_TEXT ("role {PRODUCER|CONSUMER|BOTH}\n")
                    ACE_TEXT ("                                      ")
                    ACE_TEXT ("(default=BOTH)\n")
                    ACE_TEXT ("  -m {STRING}  --SDM_options={STRING} ")
                    ACE_TEXT ("ACE_SOCK_Dgram_Mcast ctor options\n")
                    ACE_TEXT ("                                      ")
                    ACE_TEXT ("(default=DEFOPTS)\n")
                    ACE_TEXT ("  -i {#}       --Iterations={#}       ")
                    ACE_TEXT ("number of iterations (default=100)\n")
                    ACE_TEXT ("  -t {#}       --TTL={#}              ")
                    ACE_TEXT ("time to live (default=1)\n")
                    ACE_TEXT ("  -w {#}       --Wait={#}             ")
                    ACE_TEXT ("number of seconds to wait on CONSUMER\n")
                    ACE_TEXT ("                                      ")
                    ACE_TEXT ("(default=2)\n")
                    ACE_TEXT ("  -h/?         --help                 ")
                    ACE_TEXT ("show this message\n"),
                    argv[0]));

      return -1;
    }

  return 0;
}
コード例 #23
0
ファイル: shmiop_test.cpp プロジェクト: milan-mpathix/ATCD
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      ACE_Get_Opt opts (argc, argv, ACE_TEXT ("s:c:"));
      const ACE_TCHAR *server = 0, *client = 0;
      for (int o; (o = opts ()) != -1;)
        {
          switch (o)
            {
            case 's':
              server = opts.opt_arg ();
              break;
            case 'c':
              client = opts.opt_arg ();
              break;
            }
        }

      Servant srv (orb);
      ORBTask task (orb);

      if (server)
        {
          CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
          PortableServer::POA_var poa = PortableServer::POA::_narrow (obj);
          PortableServer::POAManager_var pm = poa->the_POAManager ();
          pm->activate ();
          Test::Hello_var srv_obj = srv._this ();
          CORBA::String_var srv_str = orb->object_to_string (srv_obj);
          FILE *f = ACE_OS::fopen (server, "w");
          ACE_OS::fputs (srv_str, f);
          ACE_OS::fclose (f);
          if (!client)
            task.activate();
        }

      if (client)
        {
          ACE_CString ior ("file://");
          ior += ACE_TEXT_ALWAYS_CHAR (client);
          CORBA::Object_var obj = orb->string_to_object (ior.c_str ());
          Test::Hello_var hello = Test::Hello::_narrow (obj);
          CORBA::String_var str = hello->get_string ();
          ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) - returned <%C>\n"),
                      str.in ()));
          hello->shutdown ();
        }
      else if (server)
        {
          task.wait ();
        }

      orb->destroy ();
      return 0;
    }
  catch (const CORBA::Exception &e)
    {
      e._tao_print_exception ("Exception caught:");
    }
  catch (...)
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR unknown exception ")
                            ACE_TEXT ("caught in main\n")));
    }
  return 1;
}
コード例 #24
0
int
ACE_Service_Gestalt::parse_args_i (int argc,
                                   ACE_TCHAR *argv[],
                                   bool &ignore_default_svc_conf_file)
{
  ACE_TRACE ("ACE_Service_Gestalt::parse_args_i");
  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc,
                      argv,
                      ACE_TEXT ("df:k:nyS:"),
                      1); // Start at argv[1].
  //FUZZ: enable check_for_lack_ACE_OS

  if (this->init_svc_conf_file_queue () == -1)
    return -1;

  //FUZZ: disable check_for_lack_ACE_OS
  for (int c; (argc != 0) && ((c = getopt ()) != -1); )
  //FUZZ: enable check_for_lack_ACE_OS
    switch (c)
      {
      case 'd':
        ACE::debug (1);
        break;
      case 'f':
        if (this->svc_conf_file_queue_->enqueue_tail (ACE_TString (getopt.opt_arg ())) == -1)
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("%p\n"),
                             ACE_TEXT ("enqueue_tail")),
                            -1);
        ignore_default_svc_conf_file = true;
        break;
      case 'k':
        /*
         * @TODO: Is this always a static storage? Shouldn't we copy
         * & gain ownership of the value?
         */
        this->logger_key_ = getopt.opt_arg ();
        break;
      case 'n':
        this->no_static_svcs_ = 1;
        break;
      case 'y':
        this->no_static_svcs_ = 0;
        break;
      case 'S':
        if (this->svc_queue_ == 0)
          {
            ACE_NEW_RETURN (this->svc_queue_,
                            ACE_SVC_QUEUE,
                            -1);
          }

        if (this->svc_queue_->enqueue_tail (ACE_TString (getopt.opt_arg ())) == -1)
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("%p\n"),
                             ACE_TEXT ("enqueue_tail")),
                            -1);
        break;
      default:
        if (ACE::debug ())
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("ACE (%P|%t) %c is not a ACE_Service_Config option\n"),
                      c));
      }

  return 0;
} /* parse_args_i () */
コード例 #25
0
ファイル: MonitorManager.cpp プロジェクト: asdlei00/ACE
int
TAO_MonitorManager::init (int argc, ACE_TCHAR* argv[])
{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->task_.mutex_, -1);

  this->task_.argv_.add (ACE_TEXT("fake_process_name"));

  ACE_Get_Opt opts (argc,
                    argv,
                    ACE_TEXT ("o:"),
                    0,
                    0,
                    ACE_Get_Opt::PERMUTE_ARGS,
                    1);

  static const ACE_TCHAR* orbarg = ACE_TEXT ("ORBArg");
  static const ACE_TCHAR* nonamesvc = ACE_TEXT ("NoNameSvc");
  opts.long_option (orbarg, ACE_Get_Opt::ARG_REQUIRED);
  opts.long_option (nonamesvc, ACE_Get_Opt::NO_ARG);

  int c;
  while ((c = opts ()) != -1)
    switch (c)
      {
        case 'o':
          this->task_.ior_output_ = opts.opt_arg ();
          if (TAO_debug_level > 7)
            {
              ORBSVCS_DEBUG((LM_INFO,
                ACE_TEXT("(%P|%t) TAO_MonitorManager: Setting IOR output file to: %s"),
                  this->task_.ior_output_.c_str ()));
            }
          break;
        case 0:
          if (ACE_OS::strcmp (opts.long_option (), orbarg) == 0)
            {
              ACE_TCHAR * orbArgs = opts.opt_arg ();
              if (TAO_debug_level > 7)
                {
                  ORBSVCS_DEBUG((LM_INFO,
                    ACE_TEXT("(%P|%t) TAO_MonitorManager: Setting Orb arguments to: %s"),
                      orbArgs));
                }
              this->task_.argv_.add (orbArgs);
            }
          else if (ACE_OS::strcmp (opts.long_option (), nonamesvc) == 0)
            {
              if (TAO_debug_level > 7)
                {
                  ORBSVCS_DEBUG((LM_INFO,
                    ACE_TEXT("(%P|%t) TAO_MonitorManager: Not using naming service")));
                }
              this->task_.use_name_svc_ = false;
            }
          break;
        case ':':
          ORBSVCS_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("(%P|%t) TAO_MonitorManager: %s requires an argument\n"),
                             opts.last_option ()),
                             -1);
      }

  // Force the ARGV_T to copy the elements added by the add() method
  this->task_.argv_.argv ();

  // Rember that Monitor has been configured
  this->initialized_ = true;
  return 0;
}
コード例 #26
0
ファイル: Locality_Manager_Task.cpp プロジェクト: Yijtx/ACE
  void
  LocalityManager_Task::parse_args (int argc, ACE_TCHAR **argv)
  {
    DANCE_TRACE ("LocalityManager_Task::parse_args");

    DANCE_DEBUG (DANCE_LOG_TRACE,
                 (LM_TRACE, DLINFO
                  ACE_TEXT ("LocalityManager_Task::parse_args - ")
                  ACE_TEXT ("parsing arguments...\n")));

    ACE_Get_Opt opts (argc, argv, ACE_TEXT("hu:c:p:"), 1, 0,
                      ACE_Get_Opt::RETURN_IN_ORDER);
    opts.long_option (ACE_TEXT("uuid"), 'u', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT("callback-ior"), 'c', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT("help"), 'h');
    opts.long_option (ACE_TEXT("log-level"),'l', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT("trace"),'t', ACE_Get_Opt::NO_ARG);
    opts.long_option (ACE_TEXT("output-ior"),'o', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT("plugin-config"),'p', ACE_Get_Opt::ARG_REQUIRED);

    int c = 0;
    while ((c = opts ()) != -1)
      {
        DANCE_DEBUG (DANCE_LOG_DETAILED_TRACE,
                     (LM_TRACE, DLINFO
                      ACE_TEXT ("LocalityManager_Task::parse_args - ")
                      ACE_TEXT ("Found option: \"%s\" with argument \"%s\"\n"),
                      opts.last_option (), opts.opt_arg ()));

        switch (c)
          {
          case 'u':
            DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                         (LM_DEBUG, DLINFO
                          ACE_TEXT ("LocalityManager_Task::parse_args - ")
                          ACE_TEXT ("uuid is %s\n"),
                          opts.opt_arg ()));
            this->uuid_ = opts.opt_arg ();
            break;

          case 'c':
            DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                         (LM_DEBUG, DLINFO
                          ACE_TEXT ("LocalityManager_Task::parse_args - ")
                          ACE_TEXT ("callback ior is %s\n"),
                          opts.opt_arg ()));
            this->callback_ior_str_ = opts.opt_arg ();
            break;

          case 'l':
            {
              continue; // no-op, already taken care of
            }

          case 't':
            continue; // already taken care of

          case 'o':
            DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                         (LM_DEBUG, DLINFO
                          ACE_TEXT ("LocalityManager_Task::parse_args - ")
                          ACE_TEXT ("IOR Output file: %s\n"),
                          opts.opt_arg ()));
            this->output_file_ = opts.opt_arg ();
            break;

          case 'p':
            DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                         (LM_DEBUG, DLINFO
                          ACE_TEXT ("LocalityManager_Task::parse_args - ")
                          ACE_TEXT ("Adding <%s> to plugin config list\n"),
                          opts.opt_arg ()));
            this->plugin_config_.push_back (ACE_TEXT_ALWAYS_CHAR (opts.opt_arg ()));
            break;

          case 'h':
            this->usage ();
            throw Error ("Command line help requested, bailing out....");

          default:
            DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO
                                           ACE_TEXT (" Unknown option: %s\n"),
                                           opts.last_option ()));
            this->usage ();
            ACE_CString err ("Unknown option ");
            err += ACE_TEXT_ALWAYS_CHAR (opts.last_option ());
            throw Error (err);
          }
      }

    // check required options.
    if (this->uuid_ == ACE_TEXT (""))
      throw Error ("Option required: -u|--uuid");
    if (this->callback_ior_str_ == ACE_TEXT(""))
      {
        DANCE_ERROR (DANCE_LOG_WARNING,
                     (LM_WARNING, DLINFO
                      ACE_TEXT ("LocalityManager_Task::parse_args - ")
                      ACE_TEXT ("Starting ComponentServer without a callback IOR\n")));
      }

    if (this->plugin_config_.size () == 0)
      {
        DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                     (LM_DEBUG, DLINFO
                      ACE_TEXT ("LocalityManager_Task::parse_args - ")
                      ACE_TEXT ("No plugin config specified, adding default at ")
                      ACE_TEXT ("DANCE_ROOT/bin/ciao.localityconfig\n")));

        ACE_Env_Value<const ACE_TCHAR *> dance_env (ACE_TEXT ("DANCE_ROOT"),
                                                    ACE_TEXT (""));
        std::string filename (ACE_TEXT_ALWAYS_CHAR (dance_env));
        filename += "/bin/ciao.localityconfig";
        this->plugin_config_.push_back (filename.c_str ());
      }
  }
コード例 #27
0
int
run_main (int argc, ACE_TCHAR *argv[])
{
  ACE_START_TEST (ACE_TEXT ("Reactor_Performance_Test"));

  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("dswc:l:"), 1);
  for (int c; (c = getopt ()) != -1; )
  //FUZZ: enble check_for_lack_ACE_OS
    switch (c)
      {
      case 's':
        opt_select_reactor = 1;
        break;
      case 'w':
        opt_wfmo_reactor = 1;
        break;
      case 'c':
        opt_nconnections = ACE_OS::atoi (getopt.opt_arg ());
        break;
      case 'l':
        opt_nloops = ACE_OS::atoi (getopt.opt_arg ());
        break;
      case 'd':
        opt_debug = 1;
        break;
      }

  // Sets up the correct reactor (based on platform and options).
  create_reactor ();

  // Manage memory automagically.
  auto_ptr<ACE_Reactor> reactor (ACE_Reactor::instance ());
  auto_ptr<ACE_Reactor_Impl> impl;

  // If we are using other that the default implementation, we must
  // clean up.
  if (opt_select_reactor || opt_wfmo_reactor)
    {
      auto_ptr<ACE_Reactor_Impl> auto_impl (ACE_Reactor::instance ()->implementation ());
      impl = auto_impl;
    }

  Read_Handler::set_countdown (opt_nconnections);

  // Acceptor
  ACCEPTOR acceptor;
  ACE_INET_Addr server_addr;

  // Bind acceptor to any port and then find out what the port was.
  ACE_INET_Addr local_addr (ACE_sap_any_cast (const ACE_INET_Addr &));
  if (acceptor.open (local_addr) == -1
      || acceptor.acceptor ().get_local_addr (server_addr) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("(%t) %p\n"),
                       ACE_TEXT ("open")),
                      -1);

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) starting server at port %d\n"),
              server_addr.get_port_number ()));

  ACE_INET_Addr connection_addr (server_addr.get_port_number (),
                                 ACE_DEFAULT_SERVER_HOST);

  if (ACE_Thread_Manager::instance ()->spawn
      (ACE_THR_FUNC (client),
       (void *) &connection_addr,
       THR_NEW_LWP | THR_DETACHED) == -1)
    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("(%t) %p\n"),
                ACE_TEXT ("thread create failed")));

  ACE_Time_Value run_limit (opt_nloops / 10);

  ACE_Profile_Timer timer;
  timer.start ();
  const int status =
    ACE_Reactor::instance ()->run_reactor_event_loop (run_limit);
  timer.stop ();

  ACE_Profile_Timer::ACE_Elapsed_Time et;
  timer.elapsed_time (et);

  // Print results
  print_results (et);

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) waiting for the client thread...\n")));

  ACE_Thread_Manager::instance ()->wait ();

  ACE_END_TEST;
  return status;
}
コード例 #28
0
ファイル: app.cpp プロジェクト: HansonLu/lacf
int App::main_i(int argc, char ** argv)
{
    LOG_INFO_OS("app start ...");

    int c;
    
    ACE_Get_Opt getopt (argc, argv, ACE_TEXT("dp:c:"));
    while ((c = getopt ()) != -1)
        switch (c)
    {
        case 'p':
            this->port_ = getopt.opt_arg ();
            break;
        case 'c':
            config_ = getopt.opt_arg ();

            break;
        case 'd':
            daemon_ = true;
            break;
    }


    if (port_.empty()) 
    {
        cerr << " App's port is invalid" << endl;
        return -1;
    }

    if (daemon_)
    {
        daemonize();
    }

    do_init_sig();

    ACE::init();

    cmd_task_ = new CmdTask(); 
    if ( cmd_task_->open(port_.c_str() )!= 0) 
    {
        cerr << " open cmd port " << port_ << " failed!" << endl;
        return -1;
    }


    init();

    while (!shutdown_) 
    {
        ACE_OS::sleep(1);
    }

    fini();

    cmd_task_->shutdown();

    ACE_Thread_Manager::instance()->wait();
    ACE::fini();
    LOG_INFO_OS("app exit ...");

    delete cmd_task_;
    cmd_task_ =0;
    return 0;
}
コード例 #29
0
ファイル: Process_Test.cpp プロジェクト: INMarkus/ATCD
int
run_main (int argc, ACE_TCHAR *argv[])
{
  int c = 0;
  int handle_inherit = 0; /* Disable inheritance by default */
  bool ischild = false;
  ACE_TString temp_file_name;

  ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("ch:f:"));

  while ((c = getopt ()) != -1)
      switch ((char) c)
        {
        case 'c':
          ischild = true;
          break;
        case 'h':
          handle_inherit = ACE_OS::atoi (getopt.opt_arg ());
          break;
        case 'f':
          temp_file_name = getopt.opt_arg ();
          break;
        default:
          // Don't forgive bad options
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("Bad option\n")),
                            -1);
          break;
        }

  if (ischild)
    {
      ACE_TCHAR lognm[MAXPATHLEN];
      int const mypid (ACE_OS::getpid ());
      ACE_OS::snprintf (lognm, MAXPATHLEN,
                        ACE_TEXT ("Process_Test-child-%d"), mypid);
      ACE_START_TEST (lognm);

      int result = check_temp_file (temp_file_name);
      // Check descriptor inheritance
      if (result == -1)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("Could not retrieve open files\n")),
                          -1);
      else if (result == handle_inherit)
        result = 0;
      else
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT ("Handle inheritance test failed with ")
                    ACE_TEXT ("%d, expected %d\n"), result, handle_inherit));
      ACE_END_LOG;
      return result;
    }
  else
    {
      ACE_START_TEST (ACE_TEXT ("Process_Test"));

      int status = test_setenv ();

      // The rest of this test relies on the ability to get a list of open
      // files for a process and examine each file descriptor to see which
      // file is open, matching against an expected opened file name.
      // Although most systems provide some mechanism to do this, the code
      // in this test uses Linux-specific techniques. Thus, although it
      // is possible to add the code for the checks on, for example,
      // HP-UX (pstat_getproc, pstat_getpathname) and
      // AIX (/proc is available, but there's no self and the fds are not links
      // to the opened file names), the code isn't here at present.
#if defined (ACE_LACKS_FORK) || defined (ACE_LACKS_READLINK) || !defined(ACE_LINUX)
      ACE_ERROR ((LM_INFO,
                  ACE_TEXT ("The remainder of this test is not supported on this platform\n")));
#else
      // Test handle inheritance set to true
      if (!status)
        status = run_parent (true);

      // ... and set to false
      if (!status)
        run_parent (false);
#endif /* ! ACE_LACKS_FORK */

      ACE_END_TEST;
      return status;
    }
}
コード例 #30
0
int
run_main (int argc, ACE_TCHAR *argv[])
{
  ACE_START_TEST (ACE_TEXT ("Notify_Performance_Test"));

  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("pswdc:l:"));

  for (int c; (c = getopt ()) != -1; )
    switch (c)
      {
  //FUZZ: enable check_for_lack_ACE_OS
      case 'p':
        opt_dev_poll_reactor = 1;
        break;
      case 's':
        opt_select_reactor = 1;
        break;
      case 'w':
        opt_wfmo_reactor = 1;
        break;
      case 'c':
        opt_nthreads = ACE_OS::atoi (getopt.opt_arg ());
        break;
      case 'l':
        opt_nloops = ACE_OS::atoi (getopt.opt_arg ());
        break;
      case 'd':
        opt_pass_notify_data = 1;
        break;
      }

  // Sets up the correct reactor (based on platform and options)
  create_reactor ();

  // Manage memory automagically.
  auto_ptr<ACE_Reactor> reactor (ACE_Reactor::instance ());
  auto_ptr<ACE_Reactor_Impl> impl;

  // If we are using other that the default implementation, we must
  // clean up.
  if (opt_select_reactor || opt_wfmo_reactor || opt_dev_poll_reactor)
    {
      auto_ptr<ACE_Reactor_Impl> auto_impl (ACE_Reactor::instance ()->implementation ());
      impl = auto_impl;
    }

  // Callback object
  Handler handler;

  // Spawn worker threads
  if (ACE_Thread_Manager::instance ()->spawn_n
      (opt_nthreads,
       ACE_THR_FUNC (client),
       (void *) &handler,
       THR_NEW_LWP | THR_DETACHED) == -1)
    ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n%a"), ACE_TEXT ("thread create failed")));

  // Timer business
  ACE_Profile_Timer timer;
  timer.start ();

  // Run event loop
  ACE_Reactor::instance()->run_reactor_event_loop ();

  timer.stop ();

  ACE_Profile_Timer::ACE_Elapsed_Time et;
  timer.elapsed_time (et);

  // Print results
  print_results (et);

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%P|%t) waiting for the worker threads...\n")));

  // Wait for all worker to get done.
  ACE_Thread_Manager::instance ()->wait ();

  ACE_END_TEST;
  return 0;
}