Exemplo n.º 1
0
static void init_controller(int port, int nrouters, int nworkers) {
    if (!new_server(port, &listen_fd, NULL))
	err(true, "Cannot set up server on port %u", port);
#if RPT >= 2
    report(2, "Listening socket has descriptor %d", listen_fd);
#endif
    router_addr_set = word_set_new();
    new_conn_map = word_keyvalue_new();
    router_fd_set = word_set_new();
    worker_fd_set = word_set_new();
    client_fd_set = word_set_new();
    init_cmd();
    add_cmd("status", do_controller_status_cmd,
	    "              | Determine status of connected nodes");
    add_cmd("flush", do_controller_flush_cmd,
	    "              | Flush state of all agents");
    add_cmd("collect", do_controller_collect_cmd,
	    "              | Initiate garbage collection");
    add_quit_helper(quit_controller);
    need_routers = nrouters;
    need_workers = nworkers;
    worker_cnt = nworkers;
    stat_message_cnt = 0;
    flush_requestor_fd = -1;
    stat_messages = calloc_or_fail(worker_cnt, sizeof(chunk_ptr),
				   "init_controller");
    gc_state = GC_READY;
    need_worker_cnt = 0;
    need_client_fd_set = NULL;
    defer_client_fd_set = NULL;
    gc_generation = 0;
}
Exemplo n.º 2
0
/* FIXME: needs comment: */
void
add_dump_command(const char *name,
		 void (*func)(const char *args, const char *mode),
		 const char *descr)
{
  struct cmd_list_element *c;
  struct dump_context *d;

  c = add_cmd(name, all_commands, NULL, descr, &dump_cmdlist);
  c->completer = filename_completer;
  d = XMALLOC(struct dump_context);
  d->func = func;
  d->mode = FOPEN_WB;
  set_cmd_context(c, d);
  c->func = call_dump_func;

  c = add_cmd(name, all_commands, NULL, descr, &append_cmdlist);
  c->completer = filename_completer;
  d = XMALLOC(struct dump_context);
  d->func = func;
  d->mode = FOPEN_AB;
  set_cmd_context(c, d);
  c->func = call_dump_func;

  /* Replace "Dump " at start of docstring with "Append " (borrowed
     from [deleted] deprecated_add_show_from_set).  */
  if ((c->doc[0] == 'W') && (c->doc[1] == 'r') && (c->doc[2] == 'i')
      && (c->doc[3] == 't') && (c->doc[4] == 'e') && (c->doc[5] == ' '))
    c->doc = concat("Append ", c->doc + 6, (char *)NULL);
}
Exemplo n.º 3
0
void plotstuff_stack_text(plot_args_t* pargs, cairo_t* cairo,
						  const char* txt, double px, double py) {
	cairocmd_t cmd;
	cairocmd_init(&cmd);
	set_cmd_args(pargs, &cmd);
	get_text_position(pargs, cairo, txt, &px, &py);
	cmd.type = TEXT;

	if (pargs->bg_rgba[3] > 0) {
		int dx, dy;
		logverb("Background text RGB [%g, %g, %g] alpha %g\n",
				pargs->bg_rgba[0], pargs->bg_rgba[1], 
				pargs->bg_rgba[2], pargs->bg_rgba[3]);
		cmd.layer = pargs->text_bg_layer;
		memcpy(cmd.rgba, pargs->bg_rgba, sizeof(cmd.rgba));
		for (dy=-1; dy<=1; dy++) {
			for (dx=-1; dx<=1; dx++) {
				cmd.text = strdup(txt);
				cmd.x = px + dx;
				cmd.y = py + dy;
				add_cmd(pargs, &cmd);
			}
		}
	} else
		logverb("No background behind text\n");

	cmd.layer = pargs->text_fg_layer;
	memcpy(cmd.rgba, pargs->rgba, sizeof(cmd.rgba));
	cmd.text = strdup(txt);
    cmd.x = px;
	cmd.y = py;
	add_cmd(pargs, &cmd);
}
Exemplo n.º 4
0
t_cmd		*parsing_pipe(char *str)
{
  t_cmd		*cmd;
  t_cmd		*tmp;
  int		i;
  int		i_save;

  if (str == NULL || str[0] == '|')
    return (NULL);
  i = 0;
  i_save = 0;
  cmd = NULL;
  while (str[i] != '\0')
    {
      if (str[i] == '|')
	{
	  if ((tmp = add_cmd(calc_new_str(str, i, i_save), &cmd, &tmp)) == NULL)
	    return (NULL);
	  next_cmd(str, &i, &i_save);
	}
      i++;
    }
  if (i > 0 && str[i - 1] == '|')
    return (NULL);
  if ((tmp = add_cmd(calc_new_str(str, i, i_save), &cmd, &tmp)) == NULL)
    return (NULL);
  return (cmd);
}
Exemplo n.º 5
0
void
_initialize_thread_db (void)
{

  init_fbsd_thread_ops ();

  if (thread_db_load ())
    {
      add_target (&fbsd_thread_ops);

      /* "thread tsd" command */
      add_cmd ("tsd", class_run, fbsd_thread_tsd_cmd,
            "Show the thread-specific data keys and destructors "
            "for the process.\n",
           &thread_cmd_list);

      add_cmd ("signal", class_run, fbsd_thread_signal_cmd,
            "Show the thread signal info.\n",
           &thread_cmd_list);

      /* Hook into new_objfile notification.  */
      observer_attach_new_objfile (fbsd_thread_new_objfile);
    }
  else
    {
      fprintf_unfiltered (gdb_stderr,
        "[GDB will not be able to debug user-mode threads: %s]\n", dlerror());
    }
}
Exemplo n.º 6
0
void CTipDlg::OnInputChange()
{
	wchar_t input[256];
	size_t input_len = ::GetWindowTextW(m_pair, input, elem_of(input));

	m_list.DeleteAllItems();
	cfg::config * c = cfg::config::instance();
	int ind1 = 0;

	// 1. 图标应用程序
	for (int i = 0; i < c->group_mgr.cs_count(); i++)
	{
		for (int j = 0; j < c->group_mgr.cmd_count(i); j++)
		{
			command * cmd = c->get_prog(i, j);
			if (wcsnicmp(cmd->path.c_str(), input, input_len) == 0)
			{
				add_cmd(cmd, 0, ind1++);
			}
			else if (hlp::wcsistr(cmd->path.c_str(), input))
			{
				add_cmd(cmd, 0);
			}
		}
	}

	// 2. 只索引的应用程序
	for (int i = 0; i < c->index_mgr.cs_count(); i++)
	{
		for (int j = 0; j < c->index_mgr.cmd_count(i); j++)
		{
			command *cmd = c->get_index_cmd(i, j);
			if (wcsnicmp(cmd->path.c_str(), input, input_len) == 0)
			{
				add_cmd(cmd, i+1, ind1++);
			}
			else if (hlp::wcsistr(cmd->path.c_str(), input))
			{
				add_cmd(cmd, i+1);
			}
		}
	}

	if (m_list.GetItemCount() > 0)
	{
		if (!IsWindowVisible())
		{
			CRect rc;
			::GetWindowRect(m_pair, &rc);
			SetWindowPos(0, rc.left, rc.bottom + 5, rc.Width(), rc.Height(), SWP_NOACTIVATE | SWP_SHOWWINDOW);
		}
		Resize();
		m_list.SelectItem(0);
	}
	else
	{
		ShowWindow(SW_HIDE);
	}
}
Exemplo n.º 7
0
int main(int argc, char *argv[]) {
    init_cmd();
    add_cmd("times", do_times, "Multiply");
    add_cmd("plus", do_plus, "Add");
    add_param("value", &value, "Value", NULL);
    add_quit_helper(app_quit);
    run_console(NULL);
    finish_cmd();
    return 0;
}
Exemplo n.º 8
0
void
_initialize_cp_abi (void)
{
  register_cp_abi (&auto_cp_abi);
  switch_to_cp_abi ("auto");

  add_cmd ("cp-abi", class_obscure, set_cp_abi_cmd,
	   "Set the ABI used for inspecting C++ objects.\n"
	   "\"set cp-abi\" with no arguments will list the available ABIs.",
	   &setlist);

  add_cmd ("cp-abi", class_obscure, show_cp_abi_cmd,
	   "Show the ABI used for inspecting C++ objects.", &showlist);
}
Exemplo n.º 9
0
void
add_dbg_cmds( dbg_cmd_t *table, int tablesize )
{
	int i;
	for( i=0; i<tablesize/sizeof(table[0]); i++ )
		add_cmd( table[i].name, table[i].help, -1, table[i].func );
}
Exemplo n.º 10
0
static int opts(int argc, char **argv)
{
    int i;
//    for(i=0;i<argc;i++)
//        printf("%d : %s\n",i,argv[i]);
    /* insert your own arguments here */
    while((i=getopt(argc,argv,"T:P:"))!=-1)
    {
        switch(i)
        {
#ifndef _WIN32
            case 'T':
                proxycommand=optarg;
                break;
#endif
            default:
                fprintf(stderr,"unknown option %c\n",optopt);
                usage();
        }
    }
    if(optind < argc)
        host=argv[optind++];
    while(optind < argc)
        add_cmd(argv[optind++]);
    if(host==NULL)
        usage();
    return 0;
}
Exemplo n.º 11
0
void init_socials() {
  // create the social table
  social_table = newHashtable();

  // open up the storage set
  STORAGE_SET       *set = storage_read(SOCIALS_FILE);
  STORAGE_SET_LIST *list = read_list(set, "socials");
  STORAGE_SET    *social = NULL;

  // parse all of the socials
  while( (social = storage_list_next(list)) != NULL)
    add_social(socialRead(social));
  
  // close the storage set
  storage_close(set);

  // add all of the socials to the command table
  HASH_ITERATOR *hash_i = newHashIterator(social_table);
  const char       *cmd = NULL;
  SOCIAL_DATA     *data = NULL;

  ITERATE_HASH(cmd, data, hash_i) {
    add_cmd(cmd, NULL, cmd_social, "player", FALSE);
    if(data->min_pos == POS_SITTING)
      add_cmd_check(cmd, chk_conscious);
    else if(data->min_pos == POS_STANDING)
      add_cmd_check(cmd, chk_can_move);
    else if(data->max_pos == POS_STANDING)
      add_cmd_check(cmd, chk_grounded);
  } deleteHashIterator(hash_i);
Exemplo n.º 12
0
void
initialize_remote_fileio (struct cmd_list_element *remote_set_cmdlist,
			  struct cmd_list_element *remote_show_cmdlist)
{
  sigint_fileio_token =
    create_async_signal_handler (async_remote_fileio_interrupt, NULL);

  add_cmd ("system-call-allowed", no_class,
	   set_system_call_allowed,
	   _("Set if the host system(3) call is allowed for the target."),
	   &remote_set_cmdlist);
  add_cmd ("system-call-allowed", no_class,
	   show_system_call_allowed,
	   _("Show if the host system(3) call is allowed for the target."),
	   &remote_show_cmdlist);
}
Exemplo n.º 13
0
int vss_parse( char *string, VSS_INFO *vss_info )
{
  int  err = 0 ;
  int  cmd_reconnue = 0 ;
  int  num_cmd = 0 ;
  char *s, *c ;
  char cmd[50] ;
  char params[200] ;

  s = strlwr( string ) ;

  c = strchr( s, '\r' ) ;
  if ( c != NULL ) *c = 0 ;
  c = strchr( s, '\n' ) ;
  if ( c != NULL ) *c = 0 ;

  vss_tronque( s, cmd, params ) ;
  if ( cmd[0] != ID_REMARK )
  {
    while ( !cmd_reconnue && ( cmds[num_cmd].cmd_id != CMD_NULL ) )
    {
      if ( strcmp( cmds[num_cmd].cmd_txt, cmd ) == 0 )
      {
        cmd_reconnue = 1 ;
        err = add_cmd( vss_info, cmds[num_cmd].cmd_id, params ) ;
        if ( !err && ( cmds[num_cmd].cmd_id == CMD_DISPLAY ) ) num_total++ ;
      }
      else
        num_cmd++ ;
    }
    if ( !cmd_reconnue ) err = VSSERR_CMDUNKNOWN ;
  }

  return( err ) ;
}
Exemplo n.º 14
0
static void add_cmd_block(char *cmdstr)
{
	char *sv, *eol;

	cmdstr = sv = xstrdup(cmdstr);
	do {
		eol = strchr(cmdstr, '\n');
 next:
		if (eol) {
			/* Count preceding slashes */
			int slashes = 0;
			char *sl = eol;

			while (sl != cmdstr && *--sl == '\\')
				slashes++;
			/* Odd number of preceding slashes - newline is escaped */
			if (slashes & 1) {
				overlapping_strcpy(eol - 1, eol);
				eol = strchr(eol, '\n');
				goto next;
			}
			*eol = '\0';
		}
		add_cmd(cmdstr);
		cmdstr = eol + 1;
	} while (eol);
	free(sv);
}
Exemplo n.º 15
0
void serial_task(void *pvParameters)	//term-task
{
    char crrnt_cmd[TERM_CMD_LENGTH];
    int crrnt_cmd_i = 0;

    tprintf("FreeRTOS RC-CAR ---- [email protected]\n");

    add_cmd("help", cmd_help);
    add_cmd("status", cmd_status);
    add_cmd("servo_cal", cmd_servo_cal);
    add_cmd("servo", cmd_servo);

    char ch;

    tprintf("\n$");
    for (;;) {
        xQueueReceive(uart_receive_queue, &ch, portMAX_DELAY); //blocking
        switch (ch) {
        case '\b':
            if (crrnt_cmd_i > 0) {
                tprintf("%c %c", ch, ch);
                crrnt_cmd_i--;
            }
            break;
        case '\n':
        case '\r':
            tprintf("\n");
            if (crrnt_cmd_i > 0) {
                crrnt_cmd[crrnt_cmd_i] = 0x00;
                if (parse_cmd(crrnt_cmd))
                    tprintf("unknown cmd\n");
            }
            tprintf("$");
            crrnt_cmd_i = 0;
            break;
        default:
            tprintf("%c", ch);
            crrnt_cmd[crrnt_cmd_i] = ch;
            if (crrnt_cmd_i < TERM_CMD_LENGTH - 1)
                crrnt_cmd_i++;
        }
    }
}
Exemplo n.º 16
0
void
_initialize_thread_db (void)
{

  if (fbsdcoreops_suppress_target)
    return;
  init_fbsd_thread_ops ();
  init_fbsd_core_ops ();

  if (thread_db_load ())
    {
      add_target (&fbsd_thread_ops);

      /* "thread tsd" command */
      add_cmd ("tsd", class_run, fbsd_thread_tsd_cmd,
            "Show the thread-specific data keys and destructors "
            "for the process.\n",
           &thread_cmd_list);

      add_cmd ("signal", class_run, fbsd_thread_signal_cmd,
            "Show the thread signal info.\n",
           &thread_cmd_list);

      memcpy (&orig_core_ops, &core_ops, sizeof (struct target_ops));
      memcpy (&core_ops, &fbsd_core_ops, sizeof (struct target_ops));
      add_target (&core_ops);

      /* Add ourselves to objfile event chain. */
      target_new_objfile_chain = target_new_objfile_hook;
      target_new_objfile_hook = fbsd_thread_new_objfile;

      child_suppress_run = 1;
    }
  else
    {
      fprintf_unfiltered (gdb_stderr,
        "[GDB will not be able to debug user-mode threads: %s]\n", dlerror());
     
      /* allow the user to debug non-threaded core files */
      add_target (&core_ops);
    }
}
Exemplo n.º 17
0
void
_initialize_record_btrace (void)
{
  add_cmd ("btrace", class_obscure, cmd_record_btrace_start,
	   _("Start branch trace recording."),
	   &record_cmdlist);
  add_alias_cmd ("b", "btrace", class_obscure, 1, &record_cmdlist);

  init_record_btrace_ops ();
  add_target (&record_btrace_ops);
}
Exemplo n.º 18
0
static int on_config_header_unset(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
    h2o_iovec_t *name;

    if (extract_name(node->data.scalar, strlen(node->data.scalar), &name) != 0) {
        h2o_configurator_errprintf(cmd, node, "invalid header name");
        return -1;
    }
    if (add_cmd(cmd, node, H2O_HEADERS_CMD_UNSET, name, (h2o_iovec_t){}) != 0)
        return -1;
    return 0;
}
Exemplo n.º 19
0
static int on_config_header_2arg(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, int cmd_id, yoml_t *node)
{
    h2o_iovec_t *name, value;

    if (extract_name_value(node->data.scalar, &name, &value) != 0) {
        h2o_configurator_errprintf(cmd, node, "failed to parse the value; should be in form of `name: value`");
        return -1;
    }
    if (add_cmd(cmd, node, cmd_id, name, value) != 0)
        return -1;
    return 0;
}
Exemplo n.º 20
0
void 
promif_init( void ) 
{
	obstack_init( &oftree.stack );
	oftree.next_phandle = 1;
	oftree.initialized = 1;

	/* load em_tree (emulation tree from file) */
	if( is_oldworld_boot() )
		printm("OF device tree: %s\n", gPE.oftree_filename);
	if( import_oftree(gPE.oftree_filename) )
		fatal("---> Import of OF device tree failed\n");

	check_irq_tree(0);

	os_interface_add_proc( OSI_PROM_IFACE, osip_prom_iface );
	os_interface_add_proc( OSI_PROM_PATH_IFACE, osip_prom_path_iface );

	add_cmd("ofexport", "ofexport filename\nDump OF device tree to file\n",-1, cmd_ofexport );
	add_cmd("showirqs", "show_irqs\nShow OF interrupts\n",-1, cmd_showirqs );
}
Exemplo n.º 21
0
void plotstuff_stack_marker(plot_args_t* pargs, double x, double y) {
	cairocmd_t cmd;
	cairocmd_init(&cmd);
	set_cmd_args(pargs, &cmd);
	// BG marker?
	cmd.layer = pargs->marker_fg_layer;
	cmd.type = MARKER;
	// FIXME -- handle cairo half-pixel issues here?
	cmd.x = x + 0.5;
	cmd.y = y + 0.5;
	add_cmd(pargs, &cmd);
}
Exemplo n.º 22
0
void
_initialize_cli_logging (void)
{
  static struct cmd_list_element *set_logging_cmdlist, *show_logging_cmdlist;

  
  add_prefix_cmd ("logging", class_support, set_logging_command,
		  "Set logging options", &set_logging_cmdlist,
		  "set logging ", 0, &setlist);
  add_prefix_cmd ("logging", class_support, show_logging_command,
		  "Show logging options", &show_logging_cmdlist,
		  "show logging ", 0, &showlist);
  add_setshow_boolean_cmd ("overwrite", class_support, &logging_overwrite,
			   "Set whether logging overwrites or appends "
			   "to the log file.\n",
			   "Show whether logging overwrites or appends "
			   "to the log file.\n",
			   NULL, NULL, &set_logging_cmdlist, &show_logging_cmdlist);
  add_setshow_boolean_cmd ("redirect", class_support, &logging_redirect,
			   "Set the logging output mode.\n"
			   "If redirect is off, output will go to both the "
			   "screen and the log file.\n"
			   "If redirect is on, output will go only to the log "
			   "file.",
			   "Show the logging output mode.\n"
			   "If redirect is off, output will go to both the "
			   "screen and the log file.\n"
			   "If redirect is on, output will go only to the log "
			   "file.",
			   NULL, NULL, &set_logging_cmdlist, &show_logging_cmdlist);
  add_setshow_cmd ("file", class_support, var_filename, &logging_filename,
		   "Set the current logfile.", "Show the current logfile.",
		   NULL, NULL, &set_logging_cmdlist, &show_logging_cmdlist);
  add_cmd ("on", class_support, set_logging_on,
	   "Enable logging.", &set_logging_cmdlist);
  add_cmd ("off", class_support, set_logging_off,
	   "Disable logging.", &set_logging_cmdlist);

  logging_filename = xstrdup ("gdb.txt");
}
Exemplo n.º 23
0
void
_initialize_tui_regs (void)
{
    struct cmd_list_element **tuicmd;

    tuicmd = tui_get_cmd_list ();

    add_prefix_cmd ("reg", class_tui, tui_reg_command,
                    _("TUI commands to control the register window."),
                    &tuireglist, "tui reg ", 0,
                    tuicmd);

    add_cmd ("float", class_tui, tui_reg_float_command,
             _("Display only floating point registers."),
             &tuireglist);
    add_cmd ("general", class_tui, tui_reg_general_command,
             _("Display only general registers."),
             &tuireglist);
    add_cmd ("system", class_tui, tui_reg_system_command,
             _("Display only system registers."),
             &tuireglist);
    add_cmd ("next", class_tui, tui_reg_next_command,
             _("Display next register group."),
             &tuireglist);

    if (xdb_commands)
    {
        add_com ("fr", class_tui, tui_reg_float_command,
                 _("Display only floating point registers\n"));
        add_com ("gr", class_tui, tui_reg_general_command,
                 _("Display only general registers\n"));
        add_com ("sr", class_tui, tui_reg_system_command,
                 _("Display only special registers\n"));
        add_com ("+r", class_tui, tui_scroll_regs_forward_command,
                 _("Scroll the registers window forward\n"));
        add_com ("-r", class_tui, tui_scroll_regs_backward_command,
                 _("Scroll the register window backward\n"));
    }
}
Exemplo n.º 24
0
static void add_cmd_block(char *cmdstr)
{
	int go=1;
	char *temp=bb_xstrdup(cmdstr),*temp2=temp;

	while(go) {
		int len=strcspn(temp2,"\n");
		if(!temp2[len]) go=0;
		else temp2[len]=0;
		add_cmd(temp2);
		temp2+=len+1;
	}
	free(temp);
}
Exemplo n.º 25
0
void plotstuff_stack_arrow(plot_args_t* pargs, double x, double y,
						   double x2, double y2) {
	cairocmd_t cmd;
	cairocmd_init(&cmd);
	// BG?
	set_cmd_args(pargs, &cmd);
	cmd.layer = pargs->marker_fg_layer;
	cmd.type = ARROW;
	cmd.x = x;
	cmd.y = y;
	cmd.x2 = x2;
	cmd.y2 = y2;
	add_cmd(pargs, &cmd);
}
Exemplo n.º 26
0
void
_initialize_gdbarch_utils (void)
{
  struct cmd_list_element *c;
  c = add_set_enum_cmd ("endian", class_support,
			endian_enum, &set_endian_string,
			"Set endianness of target.",
			&setlist);
  set_cmd_sfunc (c, set_endian);
  /* Don't use set_from_show - need to print both auto/manual and
     current setting. */
  add_cmd ("endian", class_support, show_endian,
	   "Show the current byte-order", &showlist);
}
Exemplo n.º 27
0
void
_initialize_record_btrace (void)
{
  add_cmd ("btrace", class_obscure, cmd_record_btrace_start,
	   _("Start branch trace recording."),
	   &record_cmdlist);
  add_alias_cmd ("b", "btrace", class_obscure, 1, &record_cmdlist);

  init_record_btrace_ops ();
  add_target (&record_btrace_ops);

  bfcache = htab_create_alloc (50, bfcache_hash, bfcache_eq, NULL,
			       xcalloc, xfree);
}
Exemplo n.º 28
0
static void add_cmd_block(char *cmdstr)
{
	char *sv, *eol;

	cmdstr = sv = xstrdup(cmdstr);
	do {
		eol = strchr(cmdstr, '\n');
		if (eol)
			*eol = '\0';
		add_cmd(cmdstr);
		cmdstr = eol + 1;
	} while (eol);
	free(sv);
}
Exemplo n.º 29
0
void
_initialize_symfile_mem (void)
{
  add_cmd ("add-symbol-file-from-memory", class_files,
           add_symbol_file_from_memory_command,
	   _("Load the symbols out of memory from a "
	     "dynamically loaded object file.\n"
	     "Give an expression for the address "
	     "of the file's shared object file header."),
           &cmdlist);

  /* Want to know of each new inferior so that its vsyscall info can
     be extracted.  */
  observer_attach_inferior_created (add_vsyscall_page);
}
Exemplo n.º 30
0
void	multiple_cmd(t_cmd **my_list, char *cmd)
{
    int	i;
    int	j;

    i = 0;
    while (cmd[i])
    {
        j = i;
        while (cmd[i] && cmd[i] != ';')
            i++;
        add_cmd(my_list, my_strndup(cmd, j, i));
        i++;
    }
}