Exemple #1
0
int
parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("sk:o:n"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 's' :
        result = true;
        break;
      case 'n':
        server_orb.set ("server_orb");
        client_orb.set ("client_orb");
        break;
      case '?':
      default:
        // This is a hack but that is okay!
        return 0;
      }
  // Indicates successful parsing of the command line
  return 0;
}
int
Consumer_Client::parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
        case 'k':
          ior = get_opts.optarg;
          break;

        default:
          ACE_ERROR_RETURN ((LM_ERROR,
            "usage:  %s "
            "-k <ior> "
            "\n",
            argv [0]),
            -1);
      }
  // Indicates successful parsing of the command line
  return 0;
}
Exemple #3
0
int
Cubit_Server::parse_args (void)
{
  ACE_Get_Opt get_opts (argc_, argv_, ACE_TEXT("df:"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'd':  // debug flag.
        TAO_debug_level++;
        break;

      case 'f': // output the IOR to a file.
        this->ior_output_file_ = ACE_OS::fopen (get_opts.opt_arg (), "w");
        if (this->ior_output_file_ == 0)
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Unable to open <%s> for writing: %p\n",
                             get_opts.opt_arg (),
                             ""),
                            -1);
        break;
      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s"
                           " [-d]"
                           " [-f] <ior_output_file>"
                           "\n",
                           argv_ [0]),
                          -1);
      }

  // Indicates successful parsing of command line.
  return 0;
}
Exemple #4
0
int
parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("xk:i:"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'x':
        shutdown_server = 1;
        break;

      case 'k':
        ior = get_opts.opt_arg ();
        break;

      case 'i':
        iterations = ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s "
                           "-k <ior> "
                           "-i <iterations> "
                           "-x [shutdown server] "
                           "\n",
                           argv [0]),
                          -1);
      }

  // Indicates successful parsing of the command line
  return 0;
}
Exemple #5
0
void
Client::parse_args (int argc,
                    ACE_TCHAR *argv[])
{
  const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");

  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'k':
        ior = get_opts.opt_arg ();
        break;
      case '?':
      default:
        ACE_ERROR ((LM_ERROR,
                    "usage:  %s "
                    "-k <ior> "
                    "\n",
                    argv [0]));
      }

  CORBA::Object_var object =
    this->orb_->string_to_object (ior);

  this->server_ =
    Stopwatch::_narrow (object.in ());

  if (CORBA::is_nil(this->server_.in ()))
    {
      ACE_DEBUG ((LM_DEBUG,
                  "\n The server value is nil "));
    }
}
Exemple #6
0
int
parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("v"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'v':
        verbose = 1;
        break;
      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s "
                           "-v "
                           "\n",
                           argv [0]),
                          -1);
      }
  // Indicates successful parsing of the command line
  return 0;
}
int
Concurrency_Service::parse_args (int argc, ACE_TCHAR** argv)
{
  ORBSVCS_DEBUG ((LM_DEBUG,
              ACE_TEXT("Concurrency_Service::parse_args\n")));

  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("do:p:s"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'd': // debug flag
        ++TAO_debug_level;
        break;
      case 'o': // output the IOR to a file
        this->ior_file_name_ = get_opts.opt_arg();
        break;
      case 'p':
        this->pid_file_name_ = get_opts.opt_arg();
        break;
      case 's':
        this->use_naming_service_ = 0;
        break;
      default:
        ORBSVCS_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT("usage:  %s")
                           ACE_TEXT(" [-d]")
                           ACE_TEXT(" [-o] <ior_output_file>")
                           ACE_TEXT("\n"),
                           argv[0]),
                           1);
      }
  // Indicates successful persing of command line.
  return 0;
}
int
parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'o':
        ior_output_file = get_opts.opt_arg ();
        break;
      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s "
                           "-o <iorfile>"
                           "\n",
                           argv [0]),
                          -1);
      }
  // Indicates successful parsing of the command line
  return 0;
}
Exemple #9
0
int
parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("dk:n:i:"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'd':
        debug = 1;
        break;
      case 'k':
        ior = get_opts.opt_arg ();
        break;
      case 'n':
        nthreads = ACE_OS::atoi (get_opts.opt_arg ());
        break;
      case 'i':
        niterations = ACE_OS::atoi (get_opts.opt_arg ());
        break;
      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s "
                           "-d "
                           "-k <ior> "
                           "-n <nthreads> "
                           "-i <niterations> "
                           "\n",
                           argv [0]),
                          -1);
      }
  // Indicates successful parsing of the command line
  return 0;
}
Exemple #10
0
int
Supplier_Client::parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:e:d:"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
  {
    case 'd':
      {
        const ACE_TCHAR *order = get_opts.optarg;
        if (ACE_OS::strcasecmp (order, ACE_TEXT ("fifo")) == 0)
        {
          order_policy = CosNotification::FifoOrder;
        }
        else if (ACE_OS::strcasecmp (order, ACE_TEXT ("priority")) == 0)
        {
          order_policy = CosNotification::PriorityOrder;
        }
        else if (ACE_OS::strcasecmp (order, ACE_TEXT ("deadline")) == 0)
        {
          order_policy = CosNotification::DeadlineOrder;
#if !defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
          ACE_ERROR_RETURN ((LM_ERROR,
            "This order policy requires timed message "
            "blocks.\nPlease #define "
            "ACE_HAS_TIMED_MESSAGE_BLOCKS in your "
            "config.h\n"), -1);
#endif
        }
        else
        {
          ACE_ERROR_RETURN ((LM_ERROR,
            "Unknown order policy: %s\n",
            order_policy),
            -1);
        }
        break;
      }

    case 'e':
      num_events = ACE_OS::atoi (get_opts.optarg);
      break;

    case 'o':
      ior_output_file = get_opts.optarg;
      break;

    default:
      ACE_ERROR_RETURN ((LM_ERROR,
        "usage:  %s "
        "-o <iorfile> -e <# of events> -d"
        "\n",
        argv [0]),
        -1);
  }

  // Indicates successful parsing of the command line
  return 0;
}
Exemple #11
0
int main(int ac, char** av)
{
    stlink_t* sl = NULL;
    struct opts o;
    char serial_buffer[13] = {0};
    o.serial = serial_buffer;
    int err = -1;

    o.size = 0;
    if (get_opts(&o, ac - 1, av + 1) == -1)
    {
        printf("invalid command line\n");
        usage();
        goto on_error;
    }

    if (o.devname != NULL) /* stlinkv1 */
    {
        sl = stlink_v1_open(o.log_level, 1);
        if (sl == NULL) goto on_error;
        sl->verbose = o.log_level;
    }
    else /* stlinkv2 */
    {
        sl = stlink_open_usb(o.log_level, 1, o.serial);
        if (sl == NULL) goto on_error;
        sl->verbose = o.log_level;
    }

    if (stlink_current_mode(sl) == STLINK_DEV_DFU_MODE)
        stlink_exit_dfu_mode(sl);

    if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE)
        stlink_enter_swd_mode(sl);

    if (o.reset) {
        stlink_jtag_reset(sl,2);
        stlink_reset(sl);
    }

    // Disable DMA - Set All DMA CCR Registers to zero. - AKS 1/7/2013
    if (sl->chip_id == STM32_CHIPID_F4)
    {
        memset(sl->q_buf,0,4);
        for (int i=0; i<8; i++) {
            stlink_write_mem32(sl,0x40026000+0x10+0x18*i,4);
            stlink_write_mem32(sl,0x40026400+0x10+0x18*i,4);
            stlink_write_mem32(sl,0x40026000+0x24+0x18*i,4);
            stlink_write_mem32(sl,0x40026400+0x24+0x18*i,4);
        }
    }

    // Core must be halted to use RAM based flashloaders
    stlink_force_debug(sl);
    stlink_status(sl);

    if (o.cmd == DO_WRITE) /* write */
    {
        if ((o.addr >= sl->flash_base) &&
                (o.addr < sl->flash_base + sl->flash_size)) {
            err = stlink_fwrite_flash(sl, o.filename, o.addr);
            if (err == -1)
            {
                printf("stlink_fwrite_flash() == -1\n");
                goto on_error;
            }
        }
        else if ((o.addr >= sl->sram_base) &&
                 (o.addr < sl->sram_base + sl->sram_size)) {
            err = stlink_fwrite_sram(sl, o.filename, o.addr);
            if (err == -1)
            {
                printf("stlink_sram_flash() == -1\n");
                goto on_error;
            }
        }
    } else if (o.cmd == DO_ERASE)
    {
        err = stlink_erase_flash_mass(sl);
        if (err == -1)
        {
            printf("stlink_fwrite_flash() == -1\n");
            goto on_error;
        }
    }
    else /* read */
    {
        if ((o.addr >= sl->flash_base) && (o.size == 0) &&
                (o.addr < sl->flash_base + sl->flash_size))
            o.size = sl->flash_size;
        else if ((o.addr >= sl->sram_base) && (o.size == 0) &&
                 (o.addr < sl->sram_base + sl->sram_size))
            o.size = sl->sram_size;
        err = stlink_fread(sl, o.filename, o.addr, o.size);
        if (err == -1)
        {
            printf("stlink_fread() == -1\n");
            goto on_error;
        }
    }

    if (o.reset) {
        stlink_jtag_reset(sl,2);
        stlink_reset(sl);
    }

    /* success */
    err = 0;

on_error:
    if (sl != NULL)
    {
        stlink_exit_debug_mode(sl);
        stlink_close(sl);
    }

    return err;
}
Exemple #12
0
int
main(int argc, char **argv)
{
	struct options *my_opts;
	PGconn	   *pgconn;

	my_opts = (struct options *) myalloc(sizeof(struct options));

	my_opts->oids = (eary *) myalloc(sizeof(eary));
	my_opts->tables = (eary *) myalloc(sizeof(eary));
	my_opts->filenodes = (eary *) myalloc(sizeof(eary));

	my_opts->oids->num = my_opts->oids->alloc = 0;
	my_opts->tables->num = my_opts->tables->alloc = 0;
	my_opts->filenodes->num = my_opts->filenodes->alloc = 0;

	/* parse the opts */
	get_opts(argc, argv, my_opts);

	if (my_opts->dbname == NULL)
	{
		my_opts->dbname = "postgres";
		my_opts->nodb = true;
	}
	pgconn = sql_conn(my_opts);

	/* display only tablespaces */
	if (my_opts->tablespaces)
	{
		if (!my_opts->quiet)
			printf("All tablespaces:\n");
		sql_exec_dumpalltbspc(pgconn, my_opts);

		PQfinish(pgconn);
		exit(0);
	}

	/* display the given elements in the database */
	if (my_opts->oids->num > 0 ||
		my_opts->tables->num > 0 ||
		my_opts->filenodes->num > 0)
	{
		if (!my_opts->quiet)
			printf("From database \"%s\":\n", my_opts->dbname);
		sql_exec_searchtables(pgconn, my_opts);

		PQfinish(pgconn);
		exit(0);
	}

	/* no elements given; dump the given database */
	if (my_opts->dbname && !my_opts->nodb)
	{
		if (!my_opts->quiet)
			printf("From database \"%s\":\n", my_opts->dbname);
		sql_exec_dumpalltables(pgconn, my_opts);

		PQfinish(pgconn);
		exit(0);
	}

	/* no database either; dump all databases */
	if (!my_opts->quiet)
		printf("All databases:\n");
	sql_exec_dumpalldbs(pgconn, my_opts);

	PQfinish(pgconn);
	return 0;
}
Exemple #13
0
int main(int ac, char** av)
{
  sl = NULL;
  struct opts o;
  int err = -1;

  signal(SIGINT, catcher);

  o.size = 0;
  if (get_opts(&o, ac - 1, av + 1) == -1)
  {
    printf("invalid command line\n");
    usage();
    goto on_error;
  }

  if (o.devname != NULL) /* stlinkv1 */
  {
    sl = stlink_v1_open(50);
    sl->verbose = 50;
    if (sl == NULL) goto on_error;
  }
  else /* stlinkv2 */
  {
    sl = stlink_open_usb(50);
    sl->verbose = 50;
    if (sl == NULL) goto on_error;
  }

  if (stlink_current_mode(sl) == STLINK_DEV_DFU_MODE)
    stlink_exit_dfu_mode(sl);

  if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE)
    stlink_enter_swd_mode(sl);

  stlink_reset(sl);

  printf("Erasing chip entirely...");
  stlink_erase_flash_mass(sl);
  printf(" Done\n");

  stlink_force_debug(sl);
  stlink_reset(sl);

  if (o.do_read == 0) /* write */
  {
    err = stlink_fwrite_flash(sl, o.filename, o.addr);
    if (err == -1)
    {
      printf("stlink_fwrite_flash() == -1\n");
      goto on_error;
    }
  }
  else /* read */
  {
    err = stlink_fread(sl, o.filename, o.addr, o.size);
    if (err == -1)
    {
      printf("stlink_fread() == -1\n");
      goto on_error;
    }
  }

  /* success */
  err = 0;

 on_error:
  if (sl != NULL)
  {
    stlink_reset(sl);
    stlink_run(sl);
    stlink_close(sl);
  }

  return err;
}
Exemple #14
0
int
TAO_Naming_Server::parse_args (int argc,
                               ACE_TCHAR *argv[])
{
#if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("b:do:p:s:f:m:u:r:z:"));
#else
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("b:do:p:s:f:m:z:"));
#endif /* TAO_HAS_MINIMUM_POA */

  int c;
  int size;
#if !defined (CORBA_E_MICRO)
  int result;

  // This is declared this way to avoid warnings from
  // some compilers that complain about mismatching types
  // in the sscanf.
#if ACE_SIZEOF_VOID_P == ACE_SIZEOF_LONG_LONG
  ptrdiff_t address;
#else
  long int address;
#endif /* ACE_SIZEOF_VOID_P */
#endif /* CORBA_E_MICRO */

  // Make sure only one persistence option is specified
  int f_opt_used = 0;
  int u_opt_used = 0;
  int r_opt_used = 0;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'd':  // debug flag.
        ++TAO_debug_level;
        break;
      case 'o': // outputs the naming service ior to a file.
        this->ior_file_name_ = get_opts.opt_arg ();
        break;
      case 'p':
        this->pid_file_name_ = get_opts.opt_arg ();
        break;
      case 's':
        size = ACE_OS::atoi (get_opts.opt_arg ());
        if (size >= 0)
          this->context_size_ = size;
        break;
      case 'm':
        this->multicast_ = ACE_OS::atoi(get_opts.opt_arg ());
        break;
#if !defined (CORBA_E_MICRO)
      case 'b':
        result = ::sscanf (ACE_TEXT_ALWAYS_CHAR (get_opts.opt_arg ()),
#if ACE_SIZEOF_VOID_P == ACE_SIZEOF_LONG_LONG
                           ACE_INT64_FORMAT_SPECIFIER_ASCII,
#else
                           "%ld",
#endif /* ACE_SIZEOF_VOID_P */
                           &address);
        if (result == 0 || result == EOF)
          ORBSVCS_ERROR_RETURN ((LM_ERROR,
                             "Unable to process <-b> option"),
                            -1);
        this->base_address_ = (void *) address;
        break;
      case 'f':
        this->persistence_file_name_ = get_opts.opt_arg ();
        f_opt_used = 1;
        break;
#if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
      case 'r':
        this->use_redundancy_ = 1;
        this->use_storable_context_ = 1;
        this->persistence_file_name_ = get_opts.opt_arg ();
        r_opt_used = 1;
        break;
      case 'u':
        this->use_storable_context_ = 1;
        this->persistence_file_name_ = get_opts.opt_arg ();
        u_opt_used = 1;
        break;
#endif /* TAO_HAS_MINIMUM_POA == 0 */
#endif /* !CORBA_E_MICRO */
      case 'z':
        this->use_round_trip_timeout_ = 1;
        this->round_trip_timeout_ = (int)1.0e7 * ACE_OS::atoi (get_opts.opt_arg ());
        break;
      case '?':
      default:
#if !defined (ACE_NLOGGING)
        const ACE_TCHAR *reqNonMinCorba=
#if !defined (CORBA_E_MICRO)
          ACE_TEXT ("-f <persistence_file_name> ")
#endif /* CORBA_E_MICRO */
#if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_MICRO)
          ACE_TEXT ("-u <storable_persistence_directory (not used with -f)> ")
          ACE_TEXT ("-r <redundant_persistence_directory> ");
#else
          ACE_TEXT ("");
#endif /* TAO_HAS_MINIMUM_POA && !CORBA_E_MICRO */
#endif /* !ACE_NLOGGING */
        ORBSVCS_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("usage:  %s ")
                           ACE_TEXT ("-d ")
                           ACE_TEXT ("-o <ior_output_file> ")
                           ACE_TEXT ("-p <pid_file_name> ")
                           ACE_TEXT ("-s <context_size> ")
                           ACE_TEXT ("-b <base_address> ")
                           ACE_TEXT ("-u <persistence dir name> ")
                           ACE_TEXT ("-m <1=enable multicast, 0=disable multicast(default) ")
                           ACE_TEXT ("%s")
                           ACE_TEXT ("-z <relative round trip timeout> ")
                           ACE_TEXT ("\n"),
                           argv [0], reqNonMinCorba),
                          -1);
      }

  if (f_opt_used + u_opt_used + r_opt_used > 1)
    ORBSVCS_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Only one persistence option can be passed")
                       ACE_TEXT ("\n")),
                      -1);

  return 0;
}
Exemple #15
0
int
parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:a:b:e:f:n:"));
  int c, result;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'n':
        iterations = ACE_OS::atoi (get_opts.opt_arg ());
        break;
      case 'o':
        ior = get_opts.opt_arg ();
        break;
      case 'a':
        result = ::sscanf (ACE_TEXT_ALWAYS_CHAR (get_opts.opt_arg ()),
                           "%hd",
                           &priority1);
        if (result == 0 || result == EOF)
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Unable to process <-a> option"),
                            -1);
        break;
      case 'b':
        result = ::sscanf (ACE_TEXT_ALWAYS_CHAR (get_opts.opt_arg ()),
                           "%hd",
                           &priority2);
        if (result == 0 || result == EOF)
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Unable to process <-b> option"),
                            -1);
        break;
      case 'e':
        result = ::sscanf (ACE_TEXT_ALWAYS_CHAR (get_opts.opt_arg ()),
                           "%u",
                           &protocol1);
        if (result == 0 || result == EOF)
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Unable to process <-e> option"),
                            -1);
        break;
      case 'f':
        result = ::sscanf (ACE_TEXT_ALWAYS_CHAR (get_opts.opt_arg ()),
                           "%u",
                           &protocol2);
        if (result == 0 || result == EOF)
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Unable to process <-f> option"),
                            -1);
        break;
      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s "
                           "-o <ior> "
                           "-a <priority1> "
                           "-b <priority2> "
                           "-e <protocol_type1> "
                           "-f <protocol_type2> "
                           "-n <number_of_iterations> "
                           "\n",
                           argv [0]),
                          -1);
      }

  if (priority1 < 0
      || priority2 < 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "Valid thread priorities must be specified.\n"
                       "See README for command-line options.\n"),
                      -1);
  return 0;
}
Exemple #16
0
int FT_ReplicaFactory_i::parse_args (int argc, ACE_TCHAR * argv[])
{
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:n:f:i:l:t:p:qu"));
  int c;

  while ((c = get_opts ()) != -1)
  {
    switch (c)
    {
      case 'o':
      {
        this->ior_output_file_ = get_opts.opt_arg ();
        break;
      }
      case 'n':
      {
        this->ns_name_ = ACE_TEXT_ALWAYS_CHAR(get_opts.opt_arg ());
        break;
      }
      case 'f':
      {
        this->factory_registry_ior_ = get_opts.opt_arg ();
        break;
      }
      case 'i':
      {
        this->roles_.push_back(ACE_TEXT_ALWAYS_CHAR(get_opts.opt_arg ()));
        break;
      }
      case 'l':
      {
        this->location_ = ACE_TEXT_ALWAYS_CHAR(get_opts.opt_arg ());
        break;
      }
      case 'q':
      {
        this->quit_on_idle_ = 1;
        break;
      }
      case 'u':
      {
        this->unregister_by_location_ = 1;
        break;
      }

      case 't':
      {
        this->test_output_file_ = get_opts.opt_arg ();
        break;
      }
      case 'p':
      {
       this->name_persistent_file_ = get_opts.opt_arg ();
       break;
      }

      case '?':
        // fall thru
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s\n"
                           " -o <factory ior file>\n"
                           " -n <naming service registration name>\n"
                           " -f <factory registry ior file>\n"
                           " -i <registration: role>\n"
                           " -l <registration: location>\n"
                           " -t <test replica ior file>\n"
                           " -p <name presistent file>\n"
                           " -u{nregister by location}\n"
                           " -q{uit on idle}\n",
                           argv [0]),
                          -1);
      break;
    }
  }
  // Indicates successful parsing of the command line
  return 0;
}
bool
DAnCE_TargetManager_Module::parse_args (int argc, ACE_TCHAR * argv[])
{
  DANCE_TRACE ("DAnCE_TargetManager_Module::parse_args");

  ACE_Get_Opt get_opts (argc - 1,
                        argv + 1,
                        ACE_TEXT(":hd:f:i:"),
                        0,
                        0,
                        ACE_Get_Opt::RETURN_IN_ORDER,
                        1);

  get_opts.long_option (ACE_TEXT("help"), 'h', ACE_Get_Opt::NO_ARG);
  get_opts.long_option (ACE_TEXT("domain-nc"), 'd', ACE_Get_Opt::ARG_REQUIRED);
  get_opts.long_option (ACE_TEXT("file"), 'f', ACE_Get_Opt::ARG_REQUIRED);
  get_opts.long_option (ACE_TEXT("init"), 'i', ACE_Get_Opt::ARG_REQUIRED);

  int c;
  while ( (c = get_opts ()) != -1)
    {
      switch (c)
        {
        case 'd':
          DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                       (LM_DEBUG, DLINFO
                        ACE_TEXT ("Target_Manager_Module::parse_args - ")
                        ACE_TEXT ("Binding to provided Domain Naming Context: '%s'\n"),
                        get_opts.opt_arg ()));
          this->options_.domain_nc_ = get_opts.opt_arg ();
          break;

        case 'f':
          DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                       (LM_DEBUG, DLINFO
                        ACE_TEXT ("Target_Manager_Module::parse_args - ")
                        ACE_TEXT ("Output filename for IOR is %s\n"),
                        get_opts.opt_arg ()));
          this->options_.ior_file_ = get_opts.opt_arg ();
          break;

        case 'i':
          DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                       (LM_DEBUG, DLINFO
                        ACE_TEXT ("Target_Manager_Module::parse_args - ")
                        ACE_TEXT ("Initial domain file %s\n"),
                        get_opts.opt_arg ()));
          this->options_.domain_descr_ = get_opts.opt_arg ();
          break;

        case 'h':
        case '?': // Display help for use of the server.
          ACE_ERROR_RETURN ((LM_ERROR,
                             this->usage (),
                             argv [0], c),
                             false);
          break;

        case 0:
            {
              DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("Target_Manager_Module::parse_args - ")
                            ACE_TEXT ("ERROR: unknown long option %s\n"),
                            get_opts.long_option ()));
            }

          break;

        default:
          DANCE_ERROR (DANCE_LOG_WARNING, (LM_TRACE, DLINFO ACE_TEXT ("Target_Manager_Module::parse_args - ignoring unknown option %c:%C\n"),
                        c, get_opts.opt_arg ()));
        }

    }

   return true;
}
Exemple #18
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try {
    CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

    int init_delay_secs = 0;
    int num_requests_expected = 0;

    ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("d:n:?"));
    int c;

    while ((c = get_opts ()) != -1)
      switch (c)
        {
        case 'd':
          init_delay_secs = ACE_OS::atoi (get_opts.opt_arg ());
          break;
        case 'n':
          num_requests_expected = ACE_OS::atoi (get_opts.opt_arg ());
          break;
        case '?':
          ACE_DEBUG ((LM_DEBUG,
                      "usage: %s "
                      "-d <seconds to delay before initializing POA> ",
                      "-n <number of expected requests> \n",
                      argv[0]));
          return 1;
          break;
        }

    ACE_DEBUG ((LM_DEBUG,
                "Delaying in initialization for %d seconds\n",
                init_delay_secs));
    ACE_OS::sleep (init_delay_secs);
    ACE_DEBUG ((LM_DEBUG,
                "Done with delay\n"));

    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in());

    PortableServer::POAManager_var mgr = root_poa->the_POAManager();

    ACE_CString poa_name("TestObject");

    PortableServer::POA_var test_poa = createPOA(root_poa.in(),
                                                 poa_name.c_str ());

    PortableServer::Servant_var<Test_i> test_servant =
      new Test_i(num_requests_expected);

    PortableServer::ObjectId_var object_id =
      PortableServer::string_to_ObjectId("test_object");

    //
    // Activate the servant with the test POA,
    // obtain its object reference, and get a
    // stringified IOR.
    //
    test_poa->activate_object_with_id(object_id.in(), test_servant.in());

    //
    // Create binding between "TestService" and
    // the test object reference in the IOR Table.
    // Use a TAO extension to get the non imrified poa
    // to avoid forwarding requests back to the ImR.

    TAO_Root_POA* tpoa = dynamic_cast<TAO_Root_POA*>(test_poa.in());
    if (!tpoa)
      {
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT ("Could not cast POA to root POA")
                    ));
        return -1;
      }

    obj = tpoa->id_to_reference_i(object_id.in(), false);
    CORBA::String_var test_ior = orb->object_to_string(obj.in());
    obj = orb->resolve_initial_references("IORTable");
    IORTable::Table_var table = IORTable::Table::_narrow(obj.in());
    table->bind(poa_name.c_str (), test_ior.in());

    //
    // This server is now ready to run.
    // This version does not create an IOR
    // file as demonstrated in the
    // Developer's Guide.  It assumes that
    // users create IORs for the client using
    // the tao_imr utility.
    //
    //
    // Stop discarding requests.
    //
    mgr->activate();

    ACE_DEBUG ((LM_DEBUG,
      "\n  Started Server %s \n",
      poa_name.c_str()));

    {
      ACE_CString status_file = poa_name + ACE_CString(".status");
      ofstream out(status_file.c_str ());
      out << "started" << endl;
    }

    orb->run();

    root_poa->destroy(1,1);
    orb->destroy();

  }
  catch(const CORBA::Exception& ex) {
    ex._tao_print_exception ("Server main()");
    return 1;
  }

  bool expected_requests_made = Test_i::expected_requests_made ();
  if (!expected_requests_made)
    {
      ACE_ERROR ((LM_ERROR,
                  "ERROR: Expected number of requests were not made\n"));
    }

  int status = expected_requests_made ? 0 : -1;

  return status;
}
Exemple #19
0
/** ***************************************************************
 * MAIN
 */
int main(int argc, char **argv)
{
	unsigned int threads=THREADS;
	unsigned int chunk = CHUNK;
	unsigned int test_length = SECONDS;  /* how many seconds before stopping generation
	                                      * negative to infinite (until ESC) */
	unsigned int cycles = CYCLES; // how many times to run generators to get average throughput
	unsigned int cycle;

	double throughputs [cycles][METHODS_COUNT];
	double averages [METHODS_COUNT];
	double sum, max_throughput;
	int max_throughput_method, method;
	int tested_methods_count = compute_tests_amount(TESTED_METHODS);

	FILE *stream;

	max_throughput = 0;
	max_throughput_method = 0;

	if(rdrand_testSupport() == RDRAND_UNSUPPORTED)
	{
		fprintf(stderr,"FATAL ERROR: RdRand is not supported on this CPU!\n");
		exit (EXIT_FAILURE);
	}

	get_opts(argc,
		 argv,
		 &threads,
		 &chunk,
		 &test_length,
		 &cycles,
		 &stream,
		 &tested_methods_count);

	if(verbose_flag)
	{
		fprintf(stderr,"This test will run %d methods for %d times in %d threads.\n", tested_methods_count, cycles, threads);
		fprintf(stderr,"Each method will run for %d seconds, the overall time of this test is %d seconds.\n",
			test_length, test_length*cycles*tested_methods_count );
		fprintf(stderr,"The random values are generated in chunks of size %u 64 bit values (per thread).\n",chunk);
		if(print_numbers_flag == 0)
			fprintf(stderr,"Generated values will be print raw.\n");
		else
			fprintf(stderr,"Generated values will be print as readable numbers.\n");

		if(no_print_flag)
			fprintf(stderr,"Will not print generates values.\n");
		fprintf(stderr,"-------------------------------------------------------------------\n");
	}

	/************** DO THE TESTING ******************************************/
	/* run all methods in required count */
	for ( cycle = 0; cycle < cycles; cycle++)
	{
		if(verbose_flag)
			fprintf(stderr,"\nDoing %d. run:\n",cycle+1);
		/* run all methods */
		for( method = 0; method < tested_methods_count; method++)
		{
			if(verbose_flag)
				fprintf(stderr,"%s:\n",METHOD_NAMES[TESTED_METHODS[method]]);

			throughputs[cycle][method] = test_throughput(threads, chunk, test_length, stream, TESTED_METHODS[method]);
		}
	}

	/************** PRINT OVERALL RESULTS **********************************/
	if(print_numbers_flag == 1)
		fprintf(stderr,"\n"); // to break line after numbers

	if(verbose_flag)
		fprintf(stderr,"\n-------------------------------------------------------------------\n");

	for( method = 0; method< tested_methods_count; method++)
	{
		sum = 0;
		for( cycle = 0; cycle < cycles; cycle++)
		{
			sum += throughputs[cycle][method];
		}
		averages[method] = sum/cycles;
		// find the maximum throughput
		if(max_throughput < averages[method])
		{
			max_throughput = averages[method];
			max_throughput_method = TESTED_METHODS[method];
		}
	}

	if(verbose_flag)
	{
		fprintf(stderr,"The fastest method (%g MiB/s) was: %s\n",max_throughput, METHOD_NAMES[max_throughput_method]);
		fprintf(stderr,"Average throughputs in %d runs:\n", cycles);
	}

	for( method = 0; method< tested_methods_count; method++)
	{
		if(verbose_flag)
		{
			fprintf(stderr,"  (%.2f %%) Method %s: %.3f MiB/s\n",

				(averages[method]/max_throughput)*100, // percents of max throughput
				METHOD_NAMES[TESTED_METHODS[method]],
				averages[method]
				);
		}
		else
		{

			fprintf(stderr,"%s %.3f MiB/s %.2f %%\n",
				METHOD_NAMES[TESTED_METHODS[method]],
				averages[method],
				(averages[method]/max_throughput)*100 // percents of max throughput
				);
		}
	}



	fclose(stream);
	return 1;
}
Exemple #20
0
int
ServerApp::parse_args(int argc, ACE_TCHAR* argv[])
{
  this->exe_name_ = argv[0];

  ACE_Get_Opt get_opts(argc, argv, ACE_TEXT("p:s:n:t:r:c:k:"));

  int c;

  while ((c = get_opts()) != -1)
    {
      int result = 0;
      switch (c)
      {
        case 'p':
          this->ior_filename_prefix_ = get_opts.opt_arg();
          break;

        case 's':
          result = this->set_arg(this->num_servants_,
                  get_opts.opt_arg(),
                  c,
                  "num_servants",
                  1);
          break;

        case 'n':
          result = this->set_arg(this->num_csd_threads_,
                  get_opts.opt_arg(),
                  c,
                  "num_servants",
                  1);
          break;

        case 't':
          result = this->set_arg(this->num_orb_threads_,
                  get_opts.opt_arg(),
                  c,
                  "num_orb_threads",
                  1);
          break;

        case 'r':
          result = this->set_arg(this->num_remote_clients_,
                  get_opts.opt_arg(),
                  c,
                  "num_remote_clients");
          break;

        case 'c':
          result = this->set_arg(this->num_collocated_clients_,
                  get_opts.opt_arg(),
                  c,
                  "num_collocated_clients");
          break;

        case 'k':
          result = this->set_arg(this->collocated_client_kind_,
                  get_opts.opt_arg(),
                  c,
                  "collocated_client_kind");
          break;

        case '?':
          this->usage_statement();
          return 1;

        default:
          this->usage_statement();
          return -1;
      }

      if (result != 0)
        {
          return result;
        }
    }

  return this->arg_dependency_checks();
}
int ReplicationManagerFaultConsumerAdapter::parse_args (int argc, ACE_TCHAR * argv[])
{
  int optionError = 0;
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:r:d:n:"));
  int c;
  while ((c = get_opts ()) != -1)
  {
    switch (c)
    {
      case 'r':
      {
        this->replica_iors_.push_back (ACE_TEXT_ALWAYS_CHAR(get_opts.opt_arg ()));
        break;
      }
      case 'd':
      {
        this->detector_ior_ = get_opts.opt_arg ();
        break;
      }
      case 'n':
      {
        this->notifier_ior_ = get_opts.opt_arg ();
        break;
      }
      case 'o':
      {
        this->readyFile_ = get_opts.opt_arg ();
        break;
      }

      default:
        // fall thru
      case '?':
      {
        break;
      }
    }
  }

  if(! optionError)
  {
    if (0 == this->replica_iors_.size())
    {
      ACE_ERROR ((LM_ERROR,
        "-r option is required.\n"
        ));
      optionError = -1;
    }
    if (0 == this->detector_ior_)
    {
      ACE_ERROR ((LM_ERROR,
        "-d option is required.\n"
        ));
      optionError = -1;
    }
  }

  if(optionError)
  {
    ACE_ERROR ((LM_ERROR,
      "usage:  %s"
      " -r <replica.ior[ -r replica.ior]>"
      " -d <detector.ior>"
      " -o <this.ior>"
      " -n <nameService name>"
      "\n",
      argv [0]
      ));
  }
  return optionError;
}
Exemple #22
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try {
    CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

    const ACE_TCHAR *iorfile = ACE_TEXT ("");

    ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("o:?"));
    int c;

    while ((c = get_opts ()) != -1)
      switch (c)
        {
        case 'o':
          iorfile = get_opts.opt_arg ();
          break;
        case '?':
          ACE_DEBUG ((LM_DEBUG,
                      "usage: %s "
                      "-d <seconds to delay before initializing POA> "
                      "-n Number of the server\n",
                      argv[0]));
          return 1;
          break;
        }

    CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
    root_poa = PortableServer::POA::_narrow (obj.in ());
    //    TAO_Root_POA::imr_client_adapter_name ("Test_Imr_Adapter");

    ACE_CString base = ACE_CString ("TestObject");
    createPOAs (base);

    PortableServer::Servant_var<Test_i> test_servant = new Test_i ();

    PortableServer::ObjectId_var object_id =
      PortableServer::string_to_ObjectId (base.c_str());

    poa_a->activate_object_with_id (object_id.in(), test_servant.in ());
    obj = poa_a->id_to_reference (object_id.in());

    Test_var tva = Test::_narrow (obj.in());

    if (ACE_OS::strlen (iorfile) > 0)
      {
        CORBA::String_var ior = orb->object_to_string (obj.in());
        FILE *output_file= ACE_OS::fopen (iorfile, "w");
        if (output_file == 0)
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Cannot open output file for writing IOR: %s\n",
                             iorfile),
                            1);
        ACE_OS::fprintf (output_file, "%s", ior.in ());
        ACE_OS::fclose (output_file);
      }

    poa_b->activate_object_with_id (object_id.in(), test_servant.in ());
    obj = poa_b->id_to_reference (object_id.in());

    Test_var tvb = Test::_narrow (obj.in());

    //    object_id = root_poa->activate_object (test_servant.in());

    //
    // This server is now ready to run.
    // This version does not create an IOR
    // file as demonstrated in the
    // Developer's Guide.  It assumes that
    // users create IORs for the client using
    // the tao_imr utility.
    //
    //
    // Stop discarding requests.
    //
    activatePOAs ();

    //
    // Create binding between "TestService" and
    // the test object reference in the IOR Table.
    // Use a TAO extension to get the non imrified poa
    // to avoid forwarding requests back to the ImR.

    TAO_Root_POA* tpoa = dynamic_cast<TAO_Root_POA*> (poa_a.in ());
    ACE_ASSERT (tpoa != 0);

    obj = tpoa->id_to_reference_i (object_id.in (), false);
    CORBA::String_var test_ior = orb->object_to_string (obj.in ());
    obj = orb->resolve_initial_references("IORTable");
    IORTable::Table_var table = IORTable::Table::_narrow (obj.in ());
    table->bind(base.c_str (), test_ior.in ());

    {
      ACE_CString status_file = base + ACE_CString(".status");
      ofstream out(status_file.c_str ());
      out << "started" << endl;
    }

    test_ior = orb->object_to_string (tva.in());
    base += "_a";
    ACE_DEBUG ((LM_DEBUG, "%s:\n%s\n", base.c_str(), test_ior.in()));
    table->bind (base.c_str (), test_ior.in ());
    base[base.length()-1] = 'b';
    test_ior = orb->object_to_string (tvb.in());
    ACE_DEBUG ((LM_DEBUG, "%s:\n%s\n", base.c_str(), test_ior.in()));
    table->bind (base.c_str (), test_ior.in ());

    ACE_DEBUG ((LM_DEBUG,
      "Started Server %s \n",
      base.c_str()));

    orb->run();
    root_poa->destroy(1,1);
    orb->destroy();

  }
  catch(const CORBA::Exception& ex) {
    ex._tao_print_exception ("Server main()");
    return 1;
  }

  return 0;
}
Exemple #23
0
NSGROUP::NSGROUP_COMMAND
NSGROUP::parse_command_line (void)
{
  #if 0
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("parse_command_line::argc(%u)\n"),
              this->argc_));
  for( int i = 0; i < this->argc_; ++i){
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("parse_command_line::argv(%u:%s)\n"),
                i,
                this->argv_[i]));
  }
  #endif

  static const ACE_TCHAR options[] = ACE_TEXT("g:p:t:l:i:n:h");
  static const int skip_args     = 1;
  static const int report_errors = 0;
  static const int ordering      = ACE_Get_Opt::PERMUTE_ARGS;
  static const int long_only     = 1;

  ACE_Get_Opt get_opts (
    this->argc_,
    this->argv_,
    options,
    skip_args,
    report_errors,
    ordering,
    long_only
  );

  this->group_arg_ = 0;
  if (get_opts.long_option (ACE_TEXT ("group"),
                           'g',
                           ACE_Get_Opt::ARG_REQUIRED) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Unable to add long option 'g'\n")),
                      NSGROUP_NONE);

  this->policy_arg_ = 0;
  if (get_opts.long_option (ACE_TEXT ("policy"),
                           'p',
                           ACE_Get_Opt::ARG_REQUIRED) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Unable to add long option 'p'\n")),
                      NSGROUP_NONE);

  this->location_arg_ = 0;
  if (get_opts.long_option (ACE_TEXT ("location"),
                           'l',
                           ACE_Get_Opt::ARG_REQUIRED) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Unable to add long option 'l'\n")),
                      NSGROUP_NONE);

  this->ior_arg_ = 0;
  if (get_opts.long_option (ACE_TEXT ("ior"),
                           'i',
                           ACE_Get_Opt::ARG_REQUIRED) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Unable to add long option 'i'\n")),
                      NSGROUP_NONE);

  this->namepath_arg_ = 0;
  if (get_opts.long_option (ACE_TEXT ("name"),
                           'n',
                           ACE_Get_Opt::ARG_REQUIRED) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Unable to add long option 'n'\n")),
                      NSGROUP_NONE);

  if (get_opts.long_option (ACE_TEXT ("help"), 'h') != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Unable to add long option 'h'\n")),
                      NSGROUP_NONE);

  int c;
  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'g':  // group
        this->group_arg_ =  get_opts.opt_arg ();
        break;
      case 'p':  // policy
        this->policy_arg_ = get_opts.opt_arg ();
        break;
      case 'l':  // location
        this->location_arg_ = get_opts.opt_arg ();
        break;
      case 'i': // ior
        this->ior_arg_ = get_opts.opt_arg ();
        break;
      case 'n': // name
        this->namepath_arg_ = get_opts.opt_arg ();
        break;
      case 'h':
        return NSGROUP_HELP;
      }

  // handle non-option arguments
  int non_option_arg_count = 0;
  for( int i = get_opts.opt_ind (); i < this->argc_; ++i)
  {

    non_option_arg_count++;


    if( ACE_OS::strncmp (this->argv_[i],ACE_TEXT("group_create"),
                         ACE_OS::strlen (ACE_TEXT("group_create"))) == 0 )
      {
        nsgroup_cmd_ =  NSGROUP_GROUP_CREATE;
      }
    else if(ACE_OS::strncmp (this->argv_[i], ACE_TEXT("group_bind"),
                             ACE_OS::strlen (ACE_TEXT("group_bind"))) == 0 )
      {
        nsgroup_cmd_ =  NSGROUP_GROUP_BIND;
      }
    else if(ACE_OS::strncmp (this->argv_[i], ACE_TEXT("group_unbind"),
                             ACE_OS::strlen (ACE_TEXT("group_unbind")))
            == 0 )
      {
        nsgroup_cmd_ =  NSGROUP_GROUP_UNBIND;
      }
    else if(ACE_OS::strncmp (this->argv_[i], ACE_TEXT("group_modify"),
                             ACE_OS::strlen (ACE_TEXT("group_modify"))) == 0 )
      {
        /// reserve cmd NSGROUP_GROUP_MODIFY for future use
        nsgroup_cmd_ =  NSGROUP_NONE;//
      }
    else if(ACE_OS::strncmp (this->argv_[i], ACE_TEXT("group_list"),
                               ACE_OS::strlen (ACE_TEXT("group_list"))) == 0 )
      {
        nsgroup_cmd_ =  NSGROUP_GROUP_LIST;
      }
    else if(ACE_OS::strncmp (this->argv_[i], ACE_TEXT("group_remove"),
                             ACE_OS::strlen (ACE_TEXT("group_remove"))) == 0 )
      {
        nsgroup_cmd_ =  NSGROUP_GROUP_REMOVE;
      }
    else if(ACE_OS::strncmp (this->argv_[i], ACE_TEXT("member_list"),
                               ACE_OS::strlen (ACE_TEXT("member_list"))) == 0 )
      {
        nsgroup_cmd_ =  NSGROUP_MEMBER_LIST;
      }
    else if(ACE_OS::strncmp (this->argv_[i], ACE_TEXT("member_add"),
                             ACE_OS::strlen (ACE_TEXT("member_add"))) == 0 )
      {
        nsgroup_cmd_ =  NSGROUP_MEMBER_ADD;
      }
    else if(ACE_OS::strncmp (this->argv_[i], ACE_TEXT("member_remove"),
                             ACE_OS::strlen (ACE_TEXT("member_remove"))) == 0 )
      {
        nsgroup_cmd_ =  NSGROUP_MEMBER_REMOVE;

      }
    else if(ACE_OS::strncmp (this->argv_[i], ACE_TEXT("member_show"),
                               ACE_OS::strlen (ACE_TEXT("member_show"))) == 0 )
      {
        nsgroup_cmd_ =  NSGROUP_MEMBER_SHOW;
      }
    else
      {
        nsgroup_cmd_ =  NSGROUP_NONE;
      }
  }

  // The command should be the only non option argument
  if ( non_option_arg_count > 1 ) {
      nsgroup_cmd_ =  NSGROUP_NONE;
  }

  return nsgroup_cmd_;
}
Exemple #24
0
// parse command line arguments (if any).
int
Demux_Test_Server::parse_args (void)
{

  ACE_Get_Opt get_opts (this->argc_, this->argv_, ACE_TEXT("df:o:p:ut"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'd':  // debug flag
        TAO_debug_level++;
        break;
      case 'f':
        this->ior_fp_ = ACE_OS::fopen (get_opts.opt_arg (), "w");
        if (this->ior_fp_ == 0)
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Unable to open %s for writing: %p\n",
                             get_opts.opt_arg ()), -1);
        break;
      case 'o':
        this->num_objs_ = ACE_OS::atoi (get_opts.opt_arg ());
        if (this->num_objs_ > TAO_DEMUX_TEST_MAX_OBJS)
          {
            ACE_ERROR_RETURN ((LM_ERROR,
                               "%d exceeds the maximum of "
                               "%d objects per POA\n",
                               this->num_objs_,
                               TAO_DEMUX_TEST_MAX_OBJS),
                              -1);
          }
        break;
      case 'p':
        this->num_POAs_ = ACE_OS::atoi (get_opts.opt_arg ());
        if (this->num_POAs_ > TAO_DEMUX_TEST_MAX_POAS)
          {
            ACE_ERROR_RETURN ((LM_ERROR,
                               "%d exceeds the maximum of "
                               "%d POAs\n",
                               this->num_objs_,
                               TAO_DEMUX_TEST_MAX_POAS),
                              -1);
          }
        break;
      case 'u':
        this->use_user_id_ = 1;
        break;
      case 't':
        this->use_transient_poas_ = 1;
        break;
      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s"
                           " [-d]"
                           " [-o <num objects>]"
                           " [-p <num POAs>]"
                           " [-f <IOR file>]"
                           "\n", this->argv_ [0]),
                          -1);
      }

  if (!this->ior_fp_)
    {
      // open default IOR file
      this->ior_fp_ = ACE_OS::fopen ("ior.dat", "w");
      if (this->ior_fp_ == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Unable to open file ior.dat for writing\n"), -1);
    }
  return 0;
}
Exemple #25
0
int
MT_Client::parse_args (void)
{
  ACE_Get_Opt get_opts (argc_, argv_, ACE_TEXT("df:g:h:i:n:s:"));
  int c;
  int result;

  while ((c = get_opts ()) != -1)
    switch (c)
    {
      case 'd':  // debug flag
        TAO_debug_level++;
        break;
        // Depending on the thread ID we pick the IOR
      case 'f': // read the IOR from the file.
        if ((this->client_number_ % 2) == 0)
        {
          result = this->read_ior (get_opts.opt_arg ());
          // read IOR for MT Object
          if (result < 0)
            ACE_ERROR_RETURN ((LM_ERROR,
                               "Unable to read ior from %s\n",
                               get_opts.opt_arg ()),
                              -1);
        }
        break;
      case 'g': // read the IOR from the file.
        if ((this->client_number_ % 2) == 1)
        {
          result = this->read_ior (get_opts.opt_arg ());
          // read IOR for Object A
          if (result < 0)
            ACE_ERROR_RETURN ((LM_ERROR,
                               "Unable to read ior from %s\n",
                               get_opts.opt_arg ()),
                              -1);
        }
        break;
      case 'i': this->iterations_ = ACE_OS::atoi (get_opts.opt_arg ());
        break;
      case 'h':
      case 'n':
      case 's':
        break;
      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                          "usage:  %s\n"
                           " [-f] first server ior file\n"
                           " [-g] second server ior file\n"
                           " [-h] third server ior file\n"
                           " [-i] client iterations\n"
                           " [-n] number of client threads\n"
                           " [-s] number of server iterations\n",
                          this->argv_ [0]),
                          -1);
    }

  // Indicates successful parsing of command line.
  return 0;
}
Exemple #26
0
static int
parse_args (int argc, ACE_TCHAR **argv)
{
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("a:b:k:m:i:t:x"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'k':
        IOR = get_opts.opt_arg ();
        break;

      case 'm':
        message_count = ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'a':
        invoke_ami_style = ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'b':
        setup_buffering = ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'i':
        iterations = ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 't':
        interval = ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'x':
        shutdown_server = 1;
        break;

      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s "
                           "-k IOR "
                           "-m message count "
                           "-a invoke AMI style [0/1] "
                           "-b setup buffering [0/1] "
                           "-i iterations "
                           "-t interval between calls "
                           "-x shutdown server "
                           "\n",
                           argv [0]),
                          -1);
      }

  if (IOR == 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "Please specify the IOR for the servant\n"), -1);

  // Without AMI, replies are immediate.
  if (!invoke_ami_style)
    received_all_replies = 1;

  // Message count must be a multiple of iterations; otherwise we'll
  // have some unsent messages left in the buffered queue.  Even
  // though we can explicitly flush the queue, I am being lazy and
  // forcing the user to give the right numbers.
  if ((iterations % message_count) != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "<message_count> must be a multiple <iterations> "
                         "or the program should be changed to flush explicitly\n"),
                        -1);
    }

  // Indicates successful parsing of command line.
  return 0;
}
Exemple #27
0
int main(int argc, const char * argv[]) {
#ifdef ICMP
    // get the ping socket
    int ping = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP);
    {
        // Drop privelege immediately
        errno_t ping_errno = errno;
        setuid(getuid());
    
        if (0 > ping) {
            errno = ping_errno;
            DIE(EX_OSERR, "open ping socket");
        }
        
        LOG(2, "ping socket: %d", ping);
    }
#endif // ICMP
    
    
#ifdef DNS
    // get the dns socket
    int dns = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
    {
        if (0 > dns) {
            DIE(EX_OSERR, "open dns socket");
        }
        LOG(2, "dns socket: %d", dns);
    }
#endif // DNS
    
    struct pollfd fds[2] = {
#ifdef ICMP
        { ping, POLLIN, 0 }
#endif // ICMP
#ifdef BOTH
        ,
#endif // BOTH
#ifdef DNS
        { dns,  POLLIN, 0 }
#endif // DNS
    };

    int fd_count = 0;
#ifdef ICMP
    int ping_index = fd_count++;
#endif // ICMP
#ifdef DNS
    int dns_index = fd_count++;
#endif // DNS

    // process arguments
    struct opts_t opts;
    get_opts(argc, argv, &opts);
    const struct addrinfo * addr = get_one_host(opts.target);
    
#ifdef ICMP
    int sequence = -1;
    struct icmp icmp_template;
    construct_icmp_template(&icmp_template);
#endif // ICMP
    
#ifdef DNS
    void * dns_template;
    size_t template_size = construct_dns_template(&dns_template, opts.query);
    LOG(3, "template: ");
    if (verbose() >= 3) { fputbuf(stderr, dns_template, template_size);fputc('\n', stderr); }
#endif // DNS
    
    // initialize the prng
    srandomdev();
    
    int count = -1;
    while (1) {
        ++count;
        
#ifdef ICMP
        struct icmp icmp_message;
        size_t icmp_message_size;
        icmp_message_size = construct_icmp(&icmp_template, &icmp_message, ++sequence);
        
        ssize_t icmp_sent = sendto(ping, (const void *)&icmp_message, icmp_message_size, 0, addr->ai_addr, addr->ai_addrlen);
        if (0 > icmp_sent) DIE(EX_OSERR, "sendto ping");
        LOG(1, "ping sent %d bytes", icmp_sent);
        long icmp_send_time = now_us();
        long icmp_recv_time = -1;
#endif // ICMP
      
#ifdef DNS
        void * dns_message;
        size_t dns_message_size;
        short dns_id = (short)random();
        dns_message_size = construct_dns(dns_template, template_size, &dns_message, dns_id);
        
        ssize_t dns_sent = sendto(dns, (const void *)dns_message, dns_message_size, 0, addr->ai_addr, addr->ai_addrlen);
        LOG(1, "dns sent %d bytes", dns_sent);
        if (verbose() >= 3) { fputbuf(stderr, dns_message, dns_message_size);fputc('\n', stderr); }
        if (0 > dns_sent) DIE(EX_OSERR, "sendto dns");
        long dns_send_time = now_us();
        long dns_recv_time = -1;
#endif // DNS
        
        long ttd_ms = now_ms() + opts.period_ms;
        int poll_time = (int)opts.period_ms;
        int ret;
        while ((ret = poll(fds, fd_count, poll_time))) {
            if (0 > ret) DIE(EX_OSERR, "poll");
            
#ifdef ICMP
            if (fds[ping_index].revents & POLLERR) {
                int error = 0;
                socklen_t errlen = sizeof(error);
                if (0 < getsockopt(fds[0].fd, SOL_SOCKET, SO_ERROR, (void *)&error, &errlen))
                    DIE(EX_OSERR, "getsockopt on ping while handling POLLERR");
                errno = error;
                DIE(EX_OSERR, "POLLERR on ping");
            }
            
            if (fds[ping_index].revents & POLLIN) {
                icmp_recv_time = process_ping(fds[ping_index].fd, sequence);
            }
#endif // ICMP
            
#ifdef DNS
            if (fds[dns_index].revents & POLLERR) {
                int error = 0;
                socklen_t errlen = sizeof(error);
                if (0 < getsockopt(fds[1].fd, SOL_SOCKET, SO_ERROR, (void *)&error, &errlen))
                    DIE(EX_OSERR, "getsockopt on dns while handling POLLERR");
                errno = error;
                DIE(EX_OSERR, "POLLERR on dns");
            }
            
            if (fds[dns_index].revents & POLLIN) {
                dns_recv_time = process_dns(fds[dns_index].fd, dns_id);
            }
#endif // DNS
            
            poll_time = (int)(ttd_ms - now_ms());
            if (poll_time < 0) break;
        }
        
        LOG(1, "poll period %d ended", count);
        
#ifdef ICMP
        REPORT("icmp", icmp_send_time, icmp_recv_time, sequence);
#endif // ICMP
        
#ifdef DNS
        REPORT("dns", dns_send_time, dns_recv_time, dns_id);
#endif // DNS
    }
    
    return 0;
}
Exemple #28
0
struct config *parse_opts (int argc, char **argv, struct config *conf)
{
	int optval, index = 1;
	//char *optstr;
	char *optarg = NULL;
	int err = 0, policy_set = 0;

	conf->opt_check_policy          = 1;
	conf->shuffle_passes            = 1;
	conf->policy.pwdlen             = DEFAULT_PASSWD_LEN;
	conf->opt_passwd_count          = DEFAULT_PASSWD_COUNT;
	conf->opt_ascii_digit.val       = ASCII_DIGIT_CHARS;
	conf->opt_ascii_digit.len       = ASCII_DIGIT_CHARS_LEN;
	conf->opt_ascii_alpha_lower.val = ASCII_ALPHA_LOWER_CHARS;
	conf->opt_ascii_alpha_lower.len = ASCII_ALPHA_LOWER_CHARS_LEN;
	conf->opt_ascii_alpha_upper.val = ASCII_ALPHA_UPPER_CHARS;
	conf->opt_ascii_alpha_upper.len = ASCII_ALPHA_UPPER_CHARS_LEN;
	conf->opt_ascii_special.val     = ASCII_SPECIAL_CHARS;
	conf->opt_ascii_special.len     = ASCII_SPECIAL_CHARS_LEN;
	conf->opt_utf8_alpha_lower.val  = UTF8_ALPHA_LOWER_CHARS;
	conf->opt_utf8_alpha_lower.len  = UTF8_ALPHA_LOWER_CHARS_LEN;
	conf->opt_utf8_alpha_upper.val  = UTF8_ALPHA_UPPER_CHARS;
	conf->opt_utf8_alpha_upper.len  = UTF8_ALPHA_UPPER_CHARS_LEN;

	while (1) {

		//optstr = argv[index];
		optval = get_opts(argc, argv, options, options_length, &index, &optarg);
		//printf("DEBUG:  ARGC=%02d INDEX=%d ARGV[%d] = '%s' OPTARG = '%s'\n", argc, index, index, optstr, optarg);
		if (optval == OPT_END)
			break;

		switch (optval) {

			case OPT_HELP:
				usage(conf, argv[0]);
				break;

			case OPT_ASCII_DIGIT:
				err = parse_range(conf, optarg, &conf->policy.ascii_digit, PARSE_INTEGER);
				policy_set = 1;
				break;

			case OPT_ASCII_ALPHA_LOWER:
				err = parse_range(conf, optarg, &conf->policy.ascii_alpha_lower, PARSE_INTEGER);
				policy_set = 1;
				break;

			case OPT_ASCII_ALPHA_UPPER:
				err = parse_range(conf, optarg, &conf->policy.ascii_alpha_upper, PARSE_INTEGER);
				policy_set = 1;
				break;

			case OPT_ASCII_SPECIAL:
				err = parse_range(conf, optarg, &conf->policy.ascii_special, PARSE_INTEGER);
				policy_set = 1;
				break;

			case OPT_UTF8_ALPHA_LOWER:
				err = parse_range(conf, optarg, &conf->policy.utf8_alpha_lower, PARSE_INTEGER);
				policy_set = 1;
				break;

			case OPT_UTF8_ALPHA_UPPER:
				err = parse_range(conf, optarg, &conf->policy.utf8_alpha_upper, PARSE_INTEGER);
				policy_set = 1;
				break;

			case OPT_SET_ASCII_DIGIT:
				parse_alphabet(optarg, &conf->opt_ascii_digit);
				break;

			case OPT_SET_ASCII_ALPHA_LOWER:
				parse_alphabet(optarg, &conf->opt_ascii_alpha_lower);
				break;

			case OPT_SET_ASCII_ALPHA_UPPER:
				parse_alphabet(optarg, &conf->opt_ascii_alpha_upper);
				break;

			case OPT_SET_ASCII_SPECIAL:
				parse_alphabet(optarg, &conf->opt_ascii_special);
				break;

			case OPT_SET_UTF8_ALPHA_LOWER:
				parse_alphabet(optarg, &conf->opt_utf8_alpha_lower);
				break;

			case OPT_SET_UTF8_ALPHA_UPPER:
				parse_alphabet(optarg, &conf->opt_utf8_alpha_lower);
				break;

			case OPT_CHECK_ENTROPY:
				conf->opt_check_entropy = 1;
				break;

			case OPT_COUNT:
				conf->opt_passwd_count = strtoul(optarg, NULL, 10);
				break;

			case OPT_ENTROPY:
				conf->opt_entropy = 1;
				if (!strcasecmp(optarg, "max")) {
					conf->policy.entropy.min = (size_t)-1.0;
					conf->policy.entropy.max = (size_t)-1.0;
				}
				else {
					err = parse_range(conf, optarg, &conf->policy.entropy, PARSE_ENTROPY);
				}
				break;

			case OPT_LENGTH:
				conf->policy.pwdlen = strtoul(optarg, NULL, 10);
				break;

			case OPT_NO_POLICY:
				conf->opt_check_policy = 0;
				break;

			case OPT_SHOW_STATS:
				conf->opt_show_stats = 1;
				break;

			case OPT_TABLE:
				conf->opt_show_stats = 1;
				conf->opt_table = 1;
				break;

			case OPT_VERBOSE:
				conf->opt_verbose = 1;
				break;

			case OPT_INCOMPLETE:
				fprintf(stderr, "FATAL: Missing parameter for option: `%s'", argv[index]);
				exit(EXIT_FAILURE);
				break;

			case OPT_UNDEFINED:
				fprintf(stderr, "FATAL: Invalid parameter: `%s'", argv[index]);
				exit(EXIT_FAILURE);
				break;

			default:
				exit(EXIT_FAILURE);
				break;
		}

		if (err)
			usage(conf, argv[0]);
	}

	if (!policy_set) {
		conf->policy.ascii_digit.max = conf->policy.ascii_alpha_lower.max = conf->policy.ascii_alpha_upper.max = conf->policy.ascii_special.max = conf->policy.pwdlen;
		switch (conf->policy.pwdlen) {
			default: conf->policy.ascii_digit.min = 1;
			case 3:  conf->policy.ascii_special.min = 1;
			case 2:  conf->policy.ascii_alpha_upper.min = 1;
			case 1:  conf->policy.ascii_alpha_lower.min = 1;
		}
	}

	return conf;
}
Exemple #29
0
int
Cubit_Client::parse_args (void)
{
  ACE_Get_Opt get_opts (argc_, argv_, ACE_TEXT("b:t:z:ovdn:f:k:xsq"));
  int c = 0;
  int result = 0;
  u_int test_mask = 0;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'b':
        // bytes in octet sequence
        result = ACE_OS::atoi (get_opts.opt_arg ());

        if (result <= 0)
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Invalid number of bytes entered: <%s>\n",
                             get_opts.opt_arg ()),
                            -1);
        else
          this->bytes_in_octet_sequence_ = (u_int) result;
        break;
      case 't':
        test_mask = this->opt_to_mask (get_opts.opt_arg ());
        if (test_mask == 0)
          return -1;
        this->enable_test (test_mask);
        break;
      case 'z':
        test_mask = this->opt_to_mask (get_opts.opt_arg ());
        if (test_mask == 0)
          return -1;
        this->disable_test (test_mask);
        break;
      case 'v':
        // For backward compatibility
        test_mask = this->opt_to_mask (ACE_TEXT("void"));
        if (test_mask == 0)
          return -1;
        this->enable_test (test_mask);
        break;
      case 'o':
        // For backward compatibility
        test_mask = this->opt_to_mask (ACE_TEXT("one_way"));
        if (test_mask == 0)
          return -1;
        this->enable_test (test_mask);
        break;
      case 'd':  // debug flag
        TAO_debug_level++;
        break;
      case 'n':                 // loop count
        result = ACE_OS::atoi (get_opts.opt_arg ());

        if (result <= 0)
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Invalid number of iterations entered: <%s>\n",
                             get_opts.opt_arg ()),
                            -1);
        else
          this->loop_count_ = (u_int) result;
        break;
      case 'f': // read the IOR from the file.
        result = this->read_ior (get_opts.opt_arg ());
        if (result < 0)
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Unable to read ior from <%s> : %p\n",
                             get_opts.opt_arg (),
                             ""),
                            -1);
        break;
      case 'k': // read the cubit IOR from the command-line.
        this->cubit_factory_key_ =
          ACE_OS::strdup (get_opts.opt_arg ());
        break;
      case 'x':
        ACE_DEBUG ((LM_DEBUG, "We will shutdown the server\n"));
        this->shutdown_ = 1;
        break;
      case 'q':
        this->quiet_ = 1;
        break;
      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s"
                           " [-b bytes-in-sequence]"
                           " [-d]"
                           " [-n loopcount]"
                           " [-f cubit_factory-obj-ref-key-file]"
                           " [-k cubit-obj-ref-key]"
                           " [-x]"
                           " [-s]"
                           " [-t test-to-enable]"
                           " [-z test-to-disable]"
                           "\n",
                           this->argv_ [0]),
                          -1);
      }

  // Indicates successful parsing of command line.
  return 0;
}
Exemple #30
0
int
parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opts (argc, argv,
                        "c:e:g:hi:k:m:p:q:r:t:u:v:w:x:y:z:" //client options
                        "b:f:hl:n:o:s:" // server options
                        );
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'c':
        continuous_workers =
          ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'e':
        count_missed_end_deadlines =
          ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'g':
        do_dump_history =
          ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'i':
        individual_continuous_worker_stats =
          ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'k':
        ior =
          get_opts.opt_arg ();
        break;

      case 'm':
        print_missed_invocations =
          ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'p':
        invocation_priorities_file =
          get_opts.opt_arg ();
        break;

      case 'q':
        prime_number =
          ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'r':
        rates_file =
          get_opts.opt_arg ();
        break;

      case 't':
        time_for_test =
          ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'u':
        continuous_worker_priority =
          ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'v':
        priority_setting =
          Priority_Setting (ACE_OS::atoi (get_opts.opt_arg ()));
        break;

      case 'w':
        work =
          ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'x':
        shutdown_server =
          ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'y':
        set_priority =
          ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'z':
        max_throughput_timeout =
          ACE_OS::atoi (get_opts.opt_arg ());
        break;

      case 'b':
      case 'f':
      case 'l':
      case 'n':
      case 'o':
      case 's':
        // server options: ignored.
        break;

      case 'h':
      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s\n"
                           "\t-c <number of continuous workers> (defaults to %d)\n"
                           "\t-e <count missed end deadlines> (defaults to %d)\n"
                           "\t-g <show history> (defaults to %d)\n"
                           "\t-h <help: shows options menu>\n"
                           "\t-i <print stats of individual continuous workers> (defaults to %d)\n"
                           "\t-k <ior> (defaults to %s)\n"
                           "\t-m <print missed invocations for paced workers> (defaults to %d)\n"
                           "\t-p <invocation priorities file> (defaults to %s)\n"
                           "\t-q <prime number> (defaults to %d)\n"
                           "\t-r <rates file> (defaults to %s)\n"
                           "\t-t <time for test> (defaults to %d)\n"
                           "\t-u <continuous worker priority> (defaults to %d)\n"
                           "\t-v <priority setting: AT_THREAD_CREATION = 0, AFTER_THREAD_CREATION = 1> (defaults to %s)\n"
                           "\t-w <work> (defaults to %d)\n"
                           "\t-x <shutdown server> (defaults to %d)\n"
                           "\t-y <set invocation priorities> (defaults to %d)\n"
                           "\t-z <timeout for max throughput measurement> (defaults to %d)\n"
                           "\n",
                           argv [0],
                           continuous_workers,
                           count_missed_end_deadlines,
                           do_dump_history,
                           individual_continuous_worker_stats,
                           ior,
                           print_missed_invocations,
                           invocation_priorities_file,
                           prime_number,
                           rates_file,
                           time_for_test,
                           continuous_worker_priority,
                           priority_setting == 0 ? "AT_THREAD_CREATION" : "AFTER_THREAD_CREATION",
                           work,
                           shutdown_server,
                           set_priority,
                           max_throughput_timeout),
                          -1);
      }

  return 0;
}