Beispiel #1
0
void		allum(t_allum *s, int pvp)
{
  if (pvp == 0)
    {
      get_cmd(s);
      check_player(s);
      aff_allum(s);
      my_printf("Press 'Enter' to continue...");
      if (read(0, &s->buff, 1) == -1)
	error("Read");
      ia(s);
      aff_allum(s);
    }
  else
    {
      s->player = 1;
      my_printf("------------Player %d-------------\n\n", s->player);
      get_cmd(s);
      check_player_pvp(s);
      aff_allum(s);
      s->player = 2;
      my_printf("------------Player %d-------------\n\n", s->player);
      get_cmd(s);
      check_player_pvp(s);
      aff_allum(s);
    }
}
static void recv_uc(struct unicast_conn *c, const rimeaddr_t * from)
{
    sec_since_start = clock_seconds();
    printf("\n%d - MSG from %d.%d\n", sec_since_start, from->u8[0], from->u8[1]);
    
    msg = (struct unicast_message *)packetbuf_dataptr();  
    packetbuf_clear();  
    //printf("MSG TYPE: %d \tCMD: %s \tVALUE: %d\n", msg->type, get_cmd(msg->cmd), msg->value);
    switch (msg->cmd) {
    case CMD_FAN_ON:
	printf("PG:FAN ON\n");
	break;
    case CMD_FAN_OFF:
	printf("PG:FAN OFF\n");
	break;
    case CMD_HEATER_ON:
	printf("PG:HEAT ON\n");
	break;
    case CMD_HEATER_OFF:
	printf("PG:HEAT OFF\n");
	break;
    case CMD_LIGHT_ON:
	printf("PG:LIGHT ON\n");
	break;
    case CMD_LIGHT_OFF:
	printf("PG:LIGHT OFF\n");
	break;
    default:
	printf("\n%s\n", get_cmd(msg->cmd));
    }

}
static int get_cmd_rsp
(
    char *argv[]
)
{
    int err = -1;
    int n;

    err = get_cmd(buffer, argv);
    if(err != 0) {
       close(sockfds);
       return 1;
    }

    write(sockfds, buffer, strlen(buffer));
    memset(buffer, 0, MAX_BUFFER);
    n = read(sockfds, buffer, MAX_BUFFER);
    if(n > 0) {
       ALOGE("Client: got response: %s\n", buffer);
       err = atol(buffer);
       print_cmd_rslt(argv, err);
       if(!strcmp(argv[1], "seeknext")) {
          err = ((err > 0) ? 0 : 1);
       }
    }else {
    }

    return err;
}
Beispiel #4
0
void			ftp_list(t_client *client, char *str)
{
  FILE			*fd;
  int			client_fd;
  struct sockaddr_in	cliaddr;
  socklen_t		clilen;
  char			*arg;
  char			buff[4096];

  arg = get_cmd(str, 4);
  if (!is_passive(client))
    return;
  clilen = sizeof(cliaddr);
  if (!is_authorized_path(client, arg))
    return (bad_path(client));
  client_fd = accept(client->pasv_sck,
		     (struct sockaddr *)&cliaddr, &clilen);
  write(client->fd, "150 Accepted data connection\r\n",
	strlen("150 Accepted data connection\r\n"));
  sprintf(buff, "ls -la %s > /tmp/.result", arg);
  system(buff);
  if (!(fd = fopen("/tmp/.result", "r")))
    return (cond_is_ok(client, client_fd));
   end_list(client, fd, client_fd);
}
void chat_command_handler::do_room_query_noarg()
{
	config data;
	config& q = data.add_child("room_query");
	q.add_child(get_cmd());
	chat_handler_.send_to_server(data);
}
Beispiel #6
0
static void *create_bash_argv(char *wd)
{
	/* start is required because exec_program does not create a window */
	static const char *bash_argv[] = { NULL, "/c", "start",
		"sh", "-c", NULL, NULL };
	static const char *command = "cd %s && sh -l -i";
	void *argv = xmalloc(sizeof(bash_argv));
	struct strbuf shell_cmd = STRBUF_INIT;
	char *converted = convert_directory_format(wd);

	/* strbuf_addf allocates only 64 bytes, so we have to grow it manually */
	strbuf_grow(&shell_cmd, strlen(converted) + strlen(command) + 1);
	strbuf_addf(&shell_cmd, command, converted);
	free(converted);

	bash_argv[0] = get_cmd();
	bash_argv[5] = shell_cmd.buf;

	memcpy(argv, bash_argv, sizeof(bash_argv));

	/* start the cmd on a system drive, so it does not fail on UNC */
	strcpy(wd, getenv("SYSTEMDRIVE"));

	return argv;
}
Beispiel #7
0
static uint32_t REGPARAM2 uaeexe_server (TrapContext *context)
{
	int32_t len;
	TCHAR *cmd;
	char *dst, *s;

	if (ARG (0) && !running) {
		running = 1;
		write_log (_T("Remote CLI started.\n"));
	}

	cmd = get_cmd ();
	if (!cmd)
		return 0;
	if (!ARG (0)) {
		running = 0;
		return 0;
	}

	dst = (char*)get_real_address (ARG (0));
	len = ARG (1);
	s = ua (cmd);
	strncpy (dst, s, len);
	write_log (_T("Sending '%s' to remote cli\n"), cmd);
	xfree (s);
	xfree (cmd);
	return ARG (0);
}
Beispiel #8
0
static int	auth_process(int sock_fd, t_auth_state *state)
{
  char		buff[PACKET_BUFF_SIZE];
  t_cmd		cmd;
  char		**args;

  if ((packet_receive(sock_fd, buff) == 0) ||
      ((args = my_str_split(buff, WORD_SEPS)) == NULL ||
       my_wordtab_count((const char **)args) < 1))
    return (0);
  if ((get_cmd(args[0], &cmd) == 0) ||
      !is_auth_cmd_allowed(args[0]))
    send_msg_response(sock_fd, "530", NULL);
  else if (strcasecmp(cmd.command, "PASS") == 0 && *state == NONE)
    send_msg_response(sock_fd, "530", NULL);
  else if (cmd.execute(sock_fd, (const char **)args))
    {
      if (strcasecmp(cmd.command, "USER") == 0 && *state != NAME_STEP)
	*state = NAME_STEP;
      else if (strcasecmp(cmd.command, "PASS") == 0 && *state == NAME_STEP)
	*state = SUCCESS;
      return (my_free_wordtab(args), 1);
    }
  return (my_free_wordtab(args), 0);
}
Beispiel #9
0
static void handle_satn(ESPState *s)
{
    uint8_t buf[32];
    int len;

    len = get_cmd(s, buf);
    if (len)
        do_cmd(s, buf);
}
void chat_command_handler::do_room_query()
{
	if (get_data(1).empty()) return command_failed_need_arg(1);
	config data;
	config& q = data.add_child("room_query");
	q["room"] = get_arg(1);
	q.add_child(get_cmd());
	chat_handler_.send_to_server(data);
}
Beispiel #11
0
int anay_cmd(char *line, char *cmd, char argv[10][80])
{
	if (get_cmd(&line, cmd) == 0)
	{
		get_argv(line, argv);
		return 0;
	}

	return -1;
}
Beispiel #12
0
static void handle_s_without_atn(ESPState *s)
{
    uint8_t buf[32];
    int len;

    len = get_cmd(s, buf);
    if (len) {
        do_busid_cmd(s, buf, 0);
    }
}
Beispiel #13
0
static void handle_satn_stop(ESPState *s)
{
    s->cmdlen = get_cmd(s, s->cmdbuf);
    if (s->cmdlen) {
        DPRINTF("Set ATN & Stop: cmdlen %d\n", s->cmdlen);
        s->do_cmd = 1;
        s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD;
        s->rregs[ESP_RINTR] = INTR_BS | INTR_FC;
        s->rregs[ESP_RSEQ] = SEQ_CD;
        esp_raise_irq(s);
    }
}
Beispiel #14
0
int run_command(void)
//  returned:	-1  - command not found
//		0   - command found and ran
//		1   - no command
//		2   - other block command (do not run command)
//		3   - get new command
{
    term_def_t	*term;
    command_def_t	*c;
    ret_code_t	rv;

    if (debug_flag) printf("run_command:\n");
    term = get_next_term();
    if (term == NULL) return(1);
    if (term->term_type != CMD_TERM) return(1);
    c = get_cmd(term->term);
    if (c == (command_def_t *)NULL) {
        printf("Invalid command:\n%s\n", cmd_line);
        go_to_dialog();
        help(0);
        shell_error = HPI_SHELL_CMD_ERROR;
        return(-1);
    };
    if (c->fun) {
        if (debug_flag)
            printf("run_command: c->type = %d\n", c->type);
        term->term = c->cmd;
        if ((block_type != c->type) && (c->type != UNDEF_COM)) {
            block_type = c->type;
            if (debug_flag) printf("run_command: ret = 2\n");
            return(2);
        };
        rv = c->fun();
        if (rv == HPI_SHELL_PARM_ERROR) {
            printf("Invalid parameters:\n%s\n", cmd_line);
            printf("%s\n", c->help);
            go_to_dialog();
            shell_error = HPI_SHELL_PARM_ERROR;
            return(3);
        } else if (rv == HPI_SHELL_CMD_ERROR) {
            printf("Command failed:\n%s\n", cmd_line);
            go_to_dialog();
            return(3);
        };
        shell_error = rv;
    } else {
        printf("Unimplemented command:\n%s\n", cmd_line);
        go_to_dialog();
        shell_error = HPI_SHELL_CMD_ERROR;
        return(3);
    };
    return(0);
}
Beispiel #15
0
/** temp_dir *************************************************************
 * top level function of the directory, shouldn't need to change anything
 * in here when making a new module. The new function handler name 
 * should be added to test.h.
 ************************************************************************/
void trod_dir(void)
{
	char *cmd = dir_cmd;
	exit_dir = 0; /* reset exit condition */
	while(!exit_dir)
	{
		dbg_puts(cdir);
		get_cmd(cmd, CMD_LEN);
		dbg_puts("\n\r");
		process_cmd(cmd);
	}
}
Beispiel #16
0
static void handle_satn(ESPState *s)
{
    uint8_t buf[32];
    int len;

    if (s->dma && !s->dma_enabled) {
        s->dma_cb = handle_satn;
        return;
    }
    len = get_cmd(s, buf);
    if (len)
        do_cmd(s, buf);
}
Beispiel #17
0
static void handle_s_without_atn(ESPState *s)
{
    uint8_t buf[32];
    int len;

    if (s->dma && !s->dma_enabled) {
        s->dma_cb = handle_s_without_atn;
        return;
    }
    len = get_cmd(s, buf);
    if (len) {
        do_busid_cmd(s, buf, 0);
    }
}
Beispiel #18
0
int main(int argc, char *argv[]) {
    clock_init();

    uart_init();

    led_init();
    motor_controller_init();
    commander_init();

    interrupt_init();

    cmd_t cmd = 0;

    while (1) {
        cmd = get_cmd();
        if (cmd != CMD_NONE) {
            VERBOSE("motor_test", "Command recieved: [%i]", cmd);
        }
        switch (cmd) {
            case CMD_STOP:
                motor_set_movement(VERT_STOPPED, HORIZ_STOPPED);
                led_display(0);
                break;
            case CMD_FORWARD:
                motor_set_movement(VERT_FORWARD, HORIZ_STOPPED);
                led_display(1);
                break;
            case CMD_BACK:
                motor_set_movement(VERT_BACKWARD, HORIZ_STOPPED);
                led_display(2);
                break;
            case CMD_LEFT:
                motor_set_movement(VERT_STOPPED, HORIZ_LEFT);
                led_display(3);
                break;
            case CMD_RIGHT:
                motor_set_movement(VERT_STOPPED, HORIZ_RIGHT);
                led_display(4);
                break;
            case CMD_NONE:
                // Ignore it
                break;
            default:
                led_display(cmd);
                break;
        }
    }

    return 0;
}
Beispiel #19
0
int main(int argc, char argv[]){
	Cmd cmd;
	cmd.prefix = 0xFFFF;
	cmd.version = 1;
	cmd.timestamp = 2;
	cmd.cmd = 3;
	cmd.device = 4;
	cmd.msg_length = 11;
	cmd.msg = "Hello,baboy";
	p(cmd);
	void *d = create_cmd_data(cmd);
	printf("%X\n", d);
	Cmd cmd2 = get_cmd(d);
	p(cmd2);
}
Beispiel #20
0
/*
 * Confirm a retention period
 */
bool confirm_retention(UAContext *ua, utime_t *ret, const char *msg)
{
   bool retval;
   char ed1[100];
   int yes_in_arg;

   yes_in_arg = find_arg(ua, NT_("yes"));
   for ( ;; ) {
       ua->info_msg(_("The current %s retention period is: %s\n"),
                    msg, edit_utime(*ret, ed1, sizeof(ed1)));
       if (yes_in_arg != -1) {
          return true;
       }

       if (!get_cmd(ua, _("Continue? (yes/mod/no): "))) {
          return false;
       }

       if (bstrcasecmp(ua->cmd, _("mod"))) {
          if (!get_cmd(ua, _("Enter new retention period: "))) {
             return false;
          }
          if (!duration_to_utime(ua->cmd, ret)) {
             ua->error_msg(_("Invalid period.\n"));
             continue;
          }
          continue;
       }

       if (is_yesno(ua->cmd, &retval)) {
          return retval;
       }
    }

    return true;
}
Beispiel #21
0
static void handle_satn_stop(ESPState *s)
{
    if (s->dma && !s->dma_enabled) {
        s->dma_cb = handle_satn_stop;
        return;
    }
    s->cmdlen = get_cmd(s, s->cmdbuf);
    if (s->cmdlen) {
        trace_esp_handle_satn_stop(s->cmdlen);
        s->do_cmd = 1;
        s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD;
        s->rregs[ESP_RINTR] = INTR_BS | INTR_FC;
        s->rregs[ESP_RSEQ] = SEQ_CD;
        esp_raise_irq(s);
    }
}
Beispiel #22
0
/*
 * Get date from user
 */
static bool get_date(UAContext *ua, char *date, int date_len)
{
   ua->send_msg(_("The restored files will the most current backup\n"
                  "BEFORE the date you specify below.\n\n"));
   for ( ;; ) {
      if (!get_cmd(ua, _("Enter date as YYYY-MM-DD HH:MM:SS :"))) {
         return false;
      }
      if (str_to_utime(ua->cmd) != 0) {
         break;
      }
      ua->error_msg(_("Improper date format.\n"));
   }
   bstrncpy(date, ua->cmd, date_len);
   return true;
}
Beispiel #23
0
int	is_exec_found_for_multi(char **path, char *cmd, int *i)
{
  int	ok;

  ok = 0;
  while (path[*i] != NULL)
    {
      if (access(finall_path_maker(path[*i], get_cmd(cmd)), X_OK) != -1)
        {
	  ok = 1;
	  return (ok);
        }
      *i = *i + 1;
    }
  return (ok);
}
int main(){
	char com[MAX];
	pid_t pid;
	while(1){
		printf("$ ");
		gets(com);
		get_cmd(com);
		if(strcmp(cmd[0],"cd")==0){
			if(chdir(cmd[1])!=0)	puts("cd error\n");
		}else{
			if(strcmp(cmd[0],"exit")==0)	exit(0);
			else	exec_cmd();
		}
		set_cmd();
	}
	return 0;
}
Beispiel #25
0
int main(void)
{
	int pid;
	char *argv[MAX_ARG];
	char buf[100];

	printf("\n\n\rWelcome To FireKylin 0.1 !\n\n\r");
	printf("More info:http://firekylin.freekj.cn\n\n\r");

	while (1) {
		printf("%s", ps1);
		if (get_cmd(buf)) {
			parcmd(buf, argv);
			execcmd(argv);
		}
	}
}
Beispiel #26
0
void				sh_and_die(char **argv, char **env, int start)
{
	char	*cmd;
	int		shlvl;

	shlvl = 0;
	cmd = NULL;
	sgt_sh()->env = sh_cpyenv(env);
	if ((shlvl = ft_atoi(sh_getenv(sgt_sh()->env, "SHLVL"))) >= 0)
		sh_setenvsep(&sgt_sh()->env, "SHLVL", ft_itoa((shlvl - 1)));
	cmd = get_cmd(argv, start);
	if (cmd && cmd[0])
	{
		s_processor(cmd);
		ft_strdel(&cmd);
	}
}
Beispiel #27
0
void init(mcu_t* const state)
{
	uint8_t size_ok = 0;
	initscr();
	cbreak();
	noecho();
	keypad(stdscr, TRUE);
	curs_set(0);
	while(!size_ok)
	{
		getmaxyx(stdscr, message_y, message_x);
		if(message_y < 40 || message_x < 80)
		{
			clear();
			mvprintw(message_y - 1, 0, "Please increase your terminal window size to accommodate the UI.");
			refresh();
			getch();
		}
		else
			size_ok = 1;
	}
	sfr_x = 0;
	sfr_y = 0;
	gpram_x = 26;
	gpram_y = 15;
	misc_x = 0;
	misc_y = 15;
	message_x = 0;
	move(message_y, message_x);
	clrtoeol();
	refresh();
	message_y -= 1;
	sfr_draw();
	gpram_draw();
	misc_draw();
	mvprintw(message_y, message_x, "Welcome to MULE. Press ESC followed by r to run, or : to enter a command.");
	refresh();

	while(getch() != 27)
		;	

	get_cmd(state);
	
	return;
}	
Beispiel #28
0
int main(void)
{
	char *argv[MAX_ARG];
	int argc;
	char buf[100];

	printf("\n\rWelcome To FireKylin 0.1 !\n\r");
	printf("More info:http://bbs.firekylin.cc\n\r");

	while (1) {

		printf("%s", ps1);
		if (get_cmd(buf)) {
			argc = parcmd(buf, argv);
			execcmd(argc, argv);
		}
	}
}
Beispiel #29
0
int main()
{
	/*
	 * 1.读取命令
	 * 2.解析命令
	 * 3.执行命令,显示结果
	 *
	 * */
	init();
	while(1)
	{
		cleanup();
		if(get_cmd() == -1)
			continue;
		parse_cmd();
		exec_cmd();
	}
	return 0;
}
Beispiel #30
0
void
do_cmd(
	tffs_handle_t htffs)
{
	tsh_session_t * psession;
	char cmd[MAX_CMD_LEN];

	psession = (tsh_session_t *)malloc(sizeof(tsh_session_t));
	strcpy(psession->cur_dir, "/");
	psession->htffs = htffs;

	while (1) {
		int ci;

		printf("%s:>", psession->cur_dir);
		memset(cmd, 0, MAX_CMD_LEN);
		get_cmd(cmd);
		parse_cmd(cmd, psession);

		if (psession->argc == 0)
			continue;

		for (ci = 0; ci < chs_num; ci++) {
			if (!strcmp(chs[ci].cmd, psession->argv[0])) {
				if (chs[ci].handler == NULL) {
					goto _end;
				}
				else {
					chs[ci].handler(psession);
					break;
				}
			}
		}

		if (ci == chs_num) {
			printf("Unrecognized command %s\n", cmd);
			do_help(psession);
		}
	}

_end:
	free(psession);
}