Esempio n. 1
0
t_getopt	ft_getopt(int ac, char **av, const char *opt_str)
{
	static t_getopt	opt = {0, 1, 0, 0, NULL};
	static char		*opt_ptr = NULL;
	static int		*elem_ind = NULL;

	if (elem_ind == NULL)
	{
		if ((elem_ind = (int *)malloc(ac * sizeof(int))) == NULL)
			exit(1);
		ft_memset(elem_ind, 0, ac * sizeof(int));
	}
	opt.arg = NULL;
	opt.is_arg = 0;
	while (opt.ind < ac && !is_options(&opt, &opt_ptr, av, opt_str))
	{
		elem_ind[opt.ind++] = 1;
		opt_ptr = NULL;
	}
	if (opt.ind >= ac)
	{
		opt.ret = -1;
		sort_opt(ac, av, elem_ind, &opt);
		return (opt);
	}
	get_opt(&opt, &opt_ptr, ac, av);
	return (opt);
}
Esempio n. 2
0
static mrb_value
mrb_random_init(mrb_state *mrb, mrb_value self)
{
  mrb_value seed;
  mt_state *t;

  /* avoid memory leaks */
  t = (mt_state*)DATA_PTR(self);
  if (t) {
    mrb_free(mrb, t);
  }

  DATA_TYPE(self) = &mt_state_type;
  DATA_PTR(self) = NULL;

  t = (mt_state *)mrb_malloc(mrb, sizeof(mt_state));
  t->mti = N + 1;

  seed = get_opt(mrb);
  seed = mrb_random_mt_srand(mrb, t, seed);
  if (mrb_nil_p(seed)) {
    t->has_seed = FALSE;
  }
  else {
    mrb_assert(mrb_fixnum_p(seed));
    t->has_seed = TRUE;
    t->seed = mrb_fixnum(seed);
  }

  DATA_PTR(self) = t;

  return self;
}
void
parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("p:"));

  for (int c; (c = get_opt ()) != -1; )
    switch (c)
      {
      case 'p':
        broadcast_port_number = ACE_OS::atoi (get_opt.opt_arg ());
        break;
      default:
        print_usage_and_die ();
        break;
      }
}
Esempio n. 4
0
File: pj_init.c Progetto: aleaf/swb
static paralist *
get_defaults(projCtx ctx, paralist **start, paralist *next, char *name) {
    FILE *fid;

    if ( (fid = pj_open_lib(ctx,"proj_def.dat", "rt")) != NULL) {
        next = get_opt(ctx, start, fid, "general", next);
        rewind(fid);
        next = get_opt(ctx, start, fid, name, next);
        (void)fclose(fid);
    }
    if (errno)
        errno = 0; /* don't care if can't open file */
    ctx->last_errno = 0;

    return next;
}
Esempio n. 5
0
int
Event_Logging_Service::parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("n:o:p:t:x"));
  int opt;

  while ((opt = get_opt ()) != EOF)
    {
      switch (opt)
        {
        case 'n':
          this->service_name_ = ACE_TEXT_ALWAYS_CHAR(get_opt.opt_arg ());
          break;

        case 'o':
          this->ior_file_name_ = get_opt.opt_arg ();
          break;

        case 'p':
          this->pid_file_name_ = get_opt.opt_arg ();
          break;

        case 't':
          this->nthreads_ = ACE_OS::atoi (get_opt.opt_arg ());
          break;

        case 'x':
          this->bind_to_naming_service_ = false;
          break;

        case '?':
        default:
          ORBSVCS_DEBUG ((LM_DEBUG,
                      "Usage: %s "
                      "-n service_name "
                      "-o ior_file_name "
                      "-p pid_file_name "
                      "-t threads "
                      "-x [disable naming service bind] "
                      "\n",
                      argv[0]));
          return -1;
        }
    }

  return 0;
}
int
ACE_TS_Clerk_Processor::parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_TRACE ("ACE_TS_Clerk_Processor::parse_args");
  ACE_INET_Addr server_addr;
  ACE_TS_Clerk_Handler *handler;

  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("h:t:p:b"), 0);

  for (int c; (c = get_opt ()) != -1; )
    {
      switch (c)
        {
        case 'h':
          // Get the hostname:port and create an ADDR
          server_addr.set (get_opt.opt_arg ());

          // Create a new handler
          ACE_NEW_RETURN (handler,
                          ACE_TS_Clerk_Handler (this, server_addr),
                          -1);

          // Cache the handler
          this->handler_set_.insert (handler);
          break;
        case 't':
          // Get the timeout value
          this->timeout_ = ACE_OS::atoi (get_opt.opt_arg ());
          break;
        case 'p':
          // Get the poolname
          ACE_OS::strncpy (this->poolname_,
                           get_opt.opt_arg (),
                           sizeof this->poolname_ / sizeof (ACE_TCHAR));
          break;
        case 'b':
          // Blocking semantics
          this->blocking_semantics_ = 1;
          break;
        default:
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("%n:\n[-h hostname:port] [-t timeout] [-p poolname]\n")),
                            -1);
        }
    }
  return 0;
}
//
// parse_args
//
int System_Probe_Daemon::parse_args (int argc, char * argv [])
{
  const char * optstr = "c:h";

  ACE_Get_Opt get_opt (argc, argv, optstr);

  get_opt.long_option ("config", 'c', ACE_Get_Opt::ARG_REQUIRED);
  get_opt.long_option ("help", 'h', ACE_Get_Opt::NO_ARG);
  get_opt.long_option ("debug", ACE_Get_Opt::NO_ARG);
  get_opt.long_option ("hertz", ACE_Get_Opt::ARG_REQUIRED);
  get_opt.long_option ("disable", ACE_Get_Opt::ARG_REQUIRED);
  get_opt.long_option ("dump", ACE_Get_Opt::ARG_REQUIRED);

  // Parse the remaining command-line arguments
  int opt = 0;

  while ((opt = get_opt ()) != EOF)
  {
    switch (opt)
    {
    case 0:
      if (0 == ACE_OS::strcmp ("help", get_opt.long_option ()))
        this->print_help ();
      else if (0 == ACE_OS::strcmp ("debug", get_opt.long_option ()))
        this->enable_log_level (LM_DEBUG);
      else if (0 == ACE_OS::strcmp ("hertz", get_opt.long_option ()))
        this->hertz_ = ACE_CString ("--hertz=") + get_opt.opt_arg ();
      else if (0 == ACE_OS::strcmp ("disable", get_opt.long_option ()))
        this->disabled_ = get_opt.opt_arg ();
      else if (0 == ACE_OS::strcmp ("config", get_opt.long_option ()))
        this->config_file_ = get_opt.opt_arg ();
      else if (0 == ACE_OS::strcmp ("dump", get_opt.long_option ()))
        this->dump_ = get_opt.opt_arg ();
      break;

    case 'h':
      this->print_help ();
      break;

    case 'c':
      this->config_file_ = get_opt.opt_arg ();
      break;
    }
  }

  return 0;
}
Esempio n. 8
0
static int cmd_link_set_prop(struct nlmsghdr *nlh, const struct cmd *cmd,
			     struct cmdl *cmdl, void *data)
{
	int val;
	int prop;
	char buf[MNL_SOCKET_BUFFER_SIZE];
	struct nlattr *props;
	struct nlattr *attrs;
	struct opt *opt;
	struct opt opts[] = {
		{ "link",		OPT_KEYVAL,	NULL },
		{ NULL }
	};

	if (strcmp(cmd->cmd, PRIORITY_STR) == 0)
		prop = TIPC_NLA_PROP_PRIO;
	else if ((strcmp(cmd->cmd, TOLERANCE_STR) == 0))
		prop = TIPC_NLA_PROP_TOL;
	else if ((strcmp(cmd->cmd, WINDOW_STR) == 0))
		prop = TIPC_NLA_PROP_WIN;
	else
		return -EINVAL;

	if (help_flag) {
		(cmd->help)(cmdl);
		return -EINVAL;
	}

	if (cmdl->optind >= cmdl->argc) {
		fprintf(stderr, "error, missing value\n");
		return -EINVAL;
	}
	val = atoi(shift_cmdl(cmdl));

	if (parse_opts(opts, cmdl) < 0)
		return -EINVAL;

	nlh = msg_init(buf, TIPC_NL_LINK_SET);
	if (!nlh) {
		fprintf(stderr, "error, message initialisation failed\n");
		return -1;
	}
	attrs = mnl_attr_nest_start(nlh, TIPC_NLA_LINK);

	opt = get_opt(opts, "link");
	if (!opt) {
		fprintf(stderr, "error, missing link\n");
		return -EINVAL;
	}
	mnl_attr_put_strz(nlh, TIPC_NLA_LINK_NAME, opt->val);

	props = mnl_attr_nest_start(nlh, TIPC_NLA_LINK_PROP);
	mnl_attr_put_u32(nlh, prop, val);
	mnl_attr_nest_end(nlh, props);

	mnl_attr_nest_end(nlh, attrs);

	return msg_doit(nlh, link_get_cb, &prop);
}
Esempio n. 9
0
void
Options::parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("i:rskt:d"));
  int c;

  while ((c = get_opt ()) != -1)
    switch (c)
      {
      case 'i':
        opt_install = 1;
        opt_startup = ACE_OS::atoi (get_opt.optarg);
        if (opt_startup <= 0)
          print_usage_and_die ();
        break;
      case 'r':
        opt_remove = 1;
        break;
      case 's':
        opt_start = 1;
        break;
      case 'k':
        opt_kill = 1;
        break;
      case 't':
        opt_type = 1;
        opt_startup = ACE_OS::atoi (get_opt.optarg);
        if (opt_startup <= 0)
          print_usage_and_die ();
        break;
      case 'd':
        //opt_debug = 1;
        break;
      default:
        // -i can also be given without a value - if so, it defaults
        // to defined value.
        if (ACE_OS::strcmp (get_opt.argv_[get_opt.optind-1], ACE_TEXT ("-i")) == 0)
          {
            opt_install = 1;
            opt_startup = DEFAULT_SERVICE_INIT_STARTUP;
          }
        else
          this->print_usage_and_die ();
        break;
      }
}
Esempio n. 10
0
void		ipv_init(t_ipv *ipv, int ac, char **av)
{
    bzero(ipv, sizeof(t_ipv));
    get_opt(ipv, ac, av);
    init_bc(&ipv->fd.buf_read);
    init_bc(&ipv->fd.buf_write);
    ipv->state = _connect;
}
//
// parse_args
//
int Tao_Data_Channel_Service::parse_args (int argc, ACE_TCHAR * argv [])
{
  // Initialize the ORB.
  this->orb_ = ::CORBA::ORB_init (argc, argv);

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

  bool run_orb = false;

  // Parse the remaining command-line arguments.
  const char * optargs = "r";
  ACE_Get_Opt get_opt (argc, argv, optargs, 0);
  int opt = 0;

  get_opt.long_option ("run-orb", 'r', ACE_Get_Opt::NO_ARG);

  while (EOF != (opt = get_opt ()))
  {
    switch (opt)
    {
    case 0:
      if (0 != ACE_OS::strcmp ("run-orb", get_opt.long_option ()))
        run_orb = true;

      break;

    case 'r':
      run_orb = true;
      break;
    }
  }

  if (run_orb)
  {
    // Since we are running our own ORB, we need to allocate a task for
    // processing requests.
    ORB_Server_Task * task = 0;
    ACE_NEW_RETURN (task, ORB_Server_Task (this->orb_.in ()), -1);
    this->task_.reset (task);
  }

  return 0;
}
Esempio n. 12
0
void
Options::parse_args (int argc, ACE_TCHAR *argv[])
{
  this->port_ = ACE_DEFAULT_SERVER_PORT;

  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:"));

  for (int c; (c = get_opt ()) != -1; )
    switch (c)
      {
      case 'p':
        this->port_ = ACE_OS::atoi (get_opt.opt_arg ());
        break;
      default:
        break;
      }
}
Esempio n. 13
0
char* core_extention(char *impl) {
  if(strncmp("ccl",impl,3)==0) {
    char* binname=get_opt("ccl.bit",0);
    binname = ccl_binname(binname?binname:"");
    return binname;
  }
  return q("core");
}
Esempio n. 14
0
void parse_cmdline(int argc, char *argv[])
{
  int arg;

  for(arg = 1; arg < argc; arg++) {
    int sw;
    char *argp, *start_argp;
    argp = argv[arg];
    while(*argp) {
      start_argp = argp;
      sw = get_opt(&argp, switches, sizeof(switches) / sizeof(switches[0]));
      switch(sw) {
        case GETOPT_PARAM:
          if (isdigit(*argp) && *(argp+1) != ':') {
            long n;
            n = parse_kilobyte(argp, &argp);
            if (n > 0x3FFFFFL)
              syntax("Invalid disk size");
            newf.size = n;
            defined_format |= DISK_SIZE;
            forced_format |= DISK_SIZE;
          }
          else {
            if (drive)
              goto bad_char;
            drive = toupper(*argp);
            if ( !(   (drive >= 'A' && drive <= 'Z')
                   || (drive >= '1' && drive <= '9')) )
             bad_char:
              syntax("Unrecognised character '%c' on command line", *argp);
            if (*++argp == ':') argp++;
          }
          break;
        case GETOPT_NOMATCH:
          /* !!!! Should I try to cut any extra parameters off? */
          syntax("Unknown switch %s", argp);
          break;
        case GETOPT_AMBIGUOUS:
          /* !!!! Should list the ambiguities */
          syntax("Ambiguous switch %s", argp);
          break;
        default:
          argp = parse_arg(argp, sw);
          break;
      }
      assert(argp != start_argp);
    }
  }

  { int c = 0;
    if (defined_format & DISK_SIZE) c++;
    if (defined_format & SPACE_AVAILABLE) c++;
    if (defined_format & FILE_SPACE) c++;
    if (defined_format & FREE_MEMORY) c++;
    if (c > 1)
      syntax("You specified many sizes for the disk");
  }
}
Esempio n. 15
0
int
parse_args (int argc, ACE_TCHAR *argv[])
{
    ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("t:m:s:l:"));

    int c;

    while ((c = get_opt ()) != -1)
        switch (c)
        {
        case 't':
            number_of_event_loop_threads =
                ACE_OS::atoi (get_opt.opt_arg ());
            break;
        case 'm':
            number_of_messages =
                ACE_OS::atoi (get_opt.opt_arg ());
            break;
        case 's':
            sleep_time_in_msec =
                ACE_OS::atoi (get_opt.opt_arg ());
            break;
        case 'l':
            lock_upcall =
                ACE_OS::atoi (get_opt.opt_arg ());
            break;
        default:
            ACE_ERROR_RETURN
            ((LM_ERROR,
              ACE_TEXT ("usage:  %s\n")
              ACE_TEXT ("\t-m <number of messages> (defaults to %d)\n")
              ACE_TEXT ("\t-t <number of event loop threads> (defaults to %d)\n")
              ACE_TEXT ("\t-s <sleep time in msec> (defaults to %d)\n")
              ACE_TEXT ("\t-l <lock upcall> (defaults to %d)\n")
              ACE_TEXT ("\n"),
              argv [0],
              number_of_messages,
              number_of_event_loop_threads,
              sleep_time_in_msec,
              lock_upcall),
             -1);
        }

    return 0;
}
Esempio n. 16
0
//
// parse_args
//
int Tron_Deployment_Handler::parse_args (char * args[])
{
  // Convert the command string into a vector of commands.
  ACE_ARGV_T <char> argv (args);
  const char * optargs = "";

  // Parse the command-line options.
  ACE_Get_Opt get_opt (argv.argc (), argv.argv (), optargs, 0);
  get_opt.long_option ("TimeUnit", ACE_Get_Opt::ARG_REQUIRED);
  get_opt.long_option ("Timeout", ACE_Get_Opt::ARG_REQUIRED);

  int opt = 0;

  while (EOF != (opt = get_opt ()))
  {
    switch (opt)
    {
    case 0:
      if (0 == ACE_OS::strcmp ("TimeUnit", get_opt.long_option ()))
      {
        size_t timeunit;
        std::istringstream istr (get_opt.opt_arg ());
        istr >> timeunit;

        if (istr.fail ())
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("%T (%t) - %M - failed to parse TimeUnit value\n")),
                             -1);
        this->timeunit_ = timeunit;
      }

      if (0 == ACE_OS::strcmp ("Timeout", get_opt.long_option ()))
      {
        size_t timeout;
        std::istringstream istr (get_opt.opt_arg ());
        istr >> timeout;

        if (istr.fail ())
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("%T (%t) - %M - failed to parse Timeout value\n")),
                             -1);
        this->timeout_ = timeout;
      }
      break;
    }
Esempio n. 17
0
static void
parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("w:"));

  int c;

  while ((c = get_opt ()) != -1)
    switch (c)
      {
      case 'w':
        n_workers = ACE_OS::atoi (get_opt.opt_arg ());
        break;
      default:
        print_usage_and_die ();
        break;
      }
}
Esempio n. 18
0
static mrb_value 
mrb_random_g_rand(mrb_state *mrb, mrb_value self)
{
  mrb_value max;

  max = get_opt(mrb);
  mrb_random_g_rand_seed(mrb);
  return mrb_random_mt_g_rand(mrb, max);
}
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("ab:cd:ef:gh:"));
  int c;

  while ((c = get_opt ()) != EOF)
    switch (c)
      {
      case 'a':
	ACE_DEBUG ((LM_DEBUG, "got a\n"));
	break;
      case 'b':
	ACE_DEBUG ((LM_DEBUG, "got b with arg %s\n", get_opt.opt_arg ()));
	break;
      case 'c':
	ACE_DEBUG ((LM_DEBUG, "got c\n"));
	break;
      case 'd':
	ACE_DEBUG ((LM_DEBUG, "got d with arg %s\n", get_opt.opt_arg ()));
	break;
      case 'e':
	ACE_DEBUG ((LM_DEBUG, "got e\n"));
	break;
      case 'f':
	ACE_DEBUG ((LM_DEBUG, "got f with arg %s\n", get_opt.opt_arg ()));
	break;
      case 'g':
	ACE_DEBUG ((LM_DEBUG, "got g\n"));
	break;
      case 'h':
	ACE_DEBUG ((LM_DEBUG, "got h with arg %s\n", get_opt.opt_arg ()));
	break;
      default:
	ACE_DEBUG ((LM_DEBUG, "got %c, which is unrecognized!\n", c));
	break;
      }

  for (int i = get_opt.opt_ind (); i < argc; i++)
    ACE_DEBUG ((LM_DEBUG, "optind = %d, argv[optind] = %s\n",
		i, argv[i]));

  return 0;
}
Esempio n. 20
0
static int
parse_args (int argc, ACE_TCHAR *argv[])
{
    ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("m:s:w:b:t:d:"));
    int c;

    while ((c = get_opt ()) != -1)
    {
        switch (c)
        {
        case 'm':
            number_of_messages = ACE_OS::atoi (get_opt.opt_arg ());
            break;
        case 's':
            message_size = ACE_OS::atoi (get_opt.opt_arg ());
            break;
        case 'w':
            number_of_workers = ACE_OS::atoi (get_opt.opt_arg ());
            break;
        case 'b':
            burst_size = ACE_OS::atoi (get_opt.opt_arg ());
            break;
        case 't':
            timeout_between_bursts = ACE_OS::atoi (get_opt.opt_arg ());
            break;
        case 'd':
            debug = static_cast<DEBUGGING_RANGE> (ACE_OS::atoi (get_opt.opt_arg ()));
            break;
        default:
            ACE_ERROR_RETURN ((LM_ERROR,
                               "usage: %s\n"
                               "\t[-m number of messages]\n"
                               "\t[-s message size]\n"
                               "\t[-w number of workers]\n"
                               "\t[-b burst size]\n"
                               "\t[-t timeout between bursts]\n"
                               "\t[-d debug]\n",
                               argv[0]),
                              -1);
        }
    }

    return 0;
}
Esempio n. 21
0
int	main(int ac, char **av)
{
	t_env	e;

	init_env(&e);
	get_opt(&e, ac, av);
	srv_create(&e, e.port);
	main_loop(&e);
	return (0);
}
Esempio n. 22
0
File: random.c Progetto: ASnow/mruby
static mrb_value
mrb_random_rand(mrb_state *mrb, mrb_value self)
{
  mrb_value max;
  mt_state *t = DATA_GET_PTR(mrb, self, &mt_state_type, mt_state);

  max = get_opt(mrb);
  mrb_random_rand_seed(mrb, t);
  return mrb_random_mt_rand(mrb, t, max);
}
Esempio n. 23
0
QString XSettingsModel::getx(QString option, bool return_default)
{
	//=PETE - I dont think this is being used...
	Q_UNUSED(return_default);
	XOpt opt = get_opt(option);
	if(opt.value.length() == 0){
		return opt.default_value;
	}
	return opt.value;
}
Esempio n. 24
0
int
Baseline_Test_Base::parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("i:ylrw"), 0);
  int c;

  while ((c = get_opt ()) != -1)
    switch (c)
      {
      case 'i':                 // Total iterations
        {
          int tmp = ACE_OS::atoi (get_opt.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;
}
Esempio n. 25
0
char* determin_impl(char* impl) {
  char* version=NULL;
  int pos;
  cond_printf(1,"determin_impl:%s\n",impl);
  if(impl && (pos=position_char("/",impl))!=-1) {
    version=subseq(impl,pos+1,0);
    impl=subseq(impl,0,pos);
  }else {
    if(!impl)
      impl=get_opt("default.lisp",1);
    if(impl) {
      char* opt=s_cat(q(impl),q("."),q("version"),NULL);
      version=get_opt(opt,1);
      s(opt);
    }
    if(!impl)
      impl=DEFAULT_IMPL;
    impl=q(impl);
    if(version)
      version=q(version);
  }
  if(!version&&strcmp(impl,DEFAULT_IMPL)!=0) {
    cond_printf(1,"once!%s,%s\n",impl,version);
    if(!version)
      s(version);
    version=q("system");
  }

  if(!(impl && version)) {
    char* cmd=cat(which(argv_orig[0]),verbose>0?(verbose>1?" -v -v":" -v"):""," setup",NULL);
    char* ret;
    if(impl) s(impl);
    impl=q(DEFAULT_IMPL);
    cond_printf(1,"cmd:%s\n",cmd);
    ret=system_(cmd);
    cond_printf(1,"ret:%s\n",ret);
    s(ret);
    char* path=s_cat(configdir(),q("config"),NULL);
    global_opt=load_opts(path),s(path);;
    version=get_opt(DEFAULT_IMPL".version",0);
  }
  return s_cat(impl,q("/"),version,NULL);
}
Esempio n. 26
0
// show all options on stdout
void show_options() {
  int i;
  for(i = 0; i < noptions; i++) {
    printf("# option[%d] = %s %s\n", i, get_opt(i), 
	   bs_nl(get_val(i)));
  }
  for(i = 0; i < nfiles; i++) {
    printf("# file[%d] = %s\n", i, files[i]);
  }
}
Esempio n. 27
0
int
STDIN_Token::parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR);

  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("h:p:diu"), 1);

  for (int c; (c = get_opt ()) != -1; )
    {
      switch (c)
      {
      case 'h':  // specify the host machine on which the server is running
        server_host_ = get_opt.opt_arg ();
        remote_ = 1;
        break;
      case 'p':  // specify the port on which the server is running
        server_port_ = ACE_OS::atoi (get_opt.opt_arg ());
        remote_ = 1;
        break;
      case 'd':
        debug_ = 1;
        break;
      case 'i':
        ignore_deadlock_ = 1;
        break;
      case 'u':
        // usage: fallthrough
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
        "%n:\n"
        "[-h <remote host>]\n"
        "[-p <remote port>]\n"
        "[-i ignore deadlock]\n"
        "[-d debug]\n", 1), -1);
      }
    }

  if (remote_)
    ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port_,
                                                         server_host_));

  return 0;
}
Esempio n. 28
0
static mrb_value 
mrb_random_rand(mrb_state *mrb, mrb_value self)
{
  mrb_value max;
  mt_state *t = DATA_PTR(self);

  max = get_opt(mrb);
  mrb_random_rand_seed(mrb, self);
  return mrb_random_mt_rand(mrb, t, max);
}
bool
parse_args (int argc, ACE_TCHAR *argv [])
{
  DANCE_TRACE ("parse_args");

  DANCE_DEBUG (DANCE_LOG_TRACE,
    (LM_TRACE, DLINFO ACE_TEXT ("dance_artifact_installation options: ")));

  for (int i = 0; i < argc; ++i)
    {
      DANCE_DEBUG (DANCE_LOG_EVENT_TRACE, (LM_TRACE, ACE_TEXT("\t%s\n"), argv[i]));
    }

  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("c:x:h"), 0);

  int c;
  ACE_CString s;
  while ((c = get_opt ()) != EOF)
    {
      switch (c)
        {
        case 'c':
          cdr_encoded_ = true;
          input_filename = get_opt.opt_arg ();
          break;

        case 'x':
          cdr_encoded_ = false;
          input_filename = get_opt.opt_arg ();
          break;

        case 'h':
          usage ();
          return false;
        default:
          usage ();
          return false;
        }
    }

  return true;
}
Esempio n. 30
0
void
parse_args (int argc, ACE_TCHAR *argv[])
{
  program_name = argv[0];
  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("f:r:"));

  for (int c; (c = get_opt ()) != -1; )
    switch (c)
      {
      case 'f':
        file_name = get_opt.opt_arg ();
        break;
      case 'r':
        rendezvous = get_opt.opt_arg ();
        break;
      default:
        print_usage_and_die ();
        break;
      }
}