Exemple #1
0
// I need this to work yesterday... I'm sorry!
void shell_input(char * js)
{
    char * cmd = strchr(js, '"') + 1;
    if (strncmp(cmd,"getvalues", 4) == 0) {
        JSONCMD_CONF_GETCALLBACK(values);
        shell_prompt("{\"response\":\"OK\",\"values\":[");
        for (int i=0; i < 8; i++) {
            char buf[10];
            inttostr(buf, values[i]);
            shell_prompt(buf);
            if ( i < 7 ) {
                shell_prompt(",");
            }
        }
        shell_output("]}", "");
    }
    else if (strncmp(cmd, "setvalues", 4) == 0) {
        cmd = strchr(cmd, '[')+1;
        for( int i=0; i < 8; i++) {
            sscanf(cmd, "%d", &values[i]);
            cmd = strchr(cmd, ',') + 1;
        }
        JSONCMD_CONF_SETCALLBACK(values);
        shell_output("{\"response\":\"OK\"}","");

    }
    else {
        shell_output("{\"response\":\"error\"}","");
    }
}
Exemple #2
0
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
  shell_output_str(NULL, shell_banner_text, "");
  shell_output_str(NULL, "Type '?' and return for help", "");
  shell_prompt(shell_prompt_text);
}
Exemple #3
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_process, ev, data)
{
  static struct process *started_process;
  struct shell_input *input;
  int ret;
  PROCESS_BEGIN();

  /* Let the system start up before showing the prompt. */
  PROCESS_PAUSE();
 
  shell_start();
 
  while(1) {
    
    PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
    {
      input = data;
      ret = shell_start_command(input->data1, input->len1, NULL,
				&started_process);

      if(started_process != NULL &&
	 ret == SHELL_FOREGROUND &&
	 process_is_running(started_process)) {
	front_process = started_process;
	PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_EXITED &&
				 data == started_process);
      }
      front_process = &shell_process;
    }
    shell_prompt(shell_prompt_text);
  }
  
  PROCESS_END();
}
Exemple #4
0
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
  shell_output("Welcome to FP server(based on uIP1.0)", "");
  shell_output("Type '?' for help", "");
  shell_prompt(SHELL_PROMPT);
}
Exemple #5
0
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
  shell_output("uIP command shell", "");
  shell_output("Type '?' and return for help", "");
  shell_prompt(SHELL_PROMPT);
}
Exemple #6
0
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
    shell_output_str(NULL, SHELL_CONF_BANNER, "");
    shell_output_str(NULL, "Type '?' and return for help", "");
    shell_prompt(SHELL_CONF_PROMPT);
}
Exemple #7
0
void Rsh::receive()
{
        std::string temp = "";
        while(true)
        {
                int len = 0;
                char* msg = shareinfo->get_message(len);
                if(msg != NULL)
                {
                        temp.append(msg, len);
                        int pos = temp.rfind('\n');
                        if(pos != std::string::npos)
                        {
                                std::string substr = temp.substr(0, pos+1);
                                write_to_output(substr.c_str(), substr.size());
				shell_prompt();
                                temp.erase(0, pos+1);
                        }
                        delete msg;
                }
                
                int* requests = shareinfo->get_requests(len);
                if(requests != NULL)
                {
                        for(int i = 0; i < len; i++)
                        {
                                int fd = open(get_fifo_id(partners[requests[i]], shareinfo->get_id()), O_RDONLY, 0666);
                                if(fd != -1)
                                        fifomgt->insert(std::pair<int, int>(requests[i], fd));
                        }
                        delete requests;
                }
                usleep(100000);
        }
}
Exemple #8
0
/*-----------------------------------------------------------------------------------*/
void
shell_start(void)
{
  showingdir = 0;
  shell_output("Contiki command shell", "");
  shell_output("Type '?' and return for help", "");  
  shell_prompt("contiki-c64> "); 
}
Exemple #9
0
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
	str_t *tp;
	do_init(tp);
	shell_output(tp->resp,"");
  shell_output("uIP command shell", "");
  shell_output("command 'quit' to return.\n","");
  shell_prompt(CLI_PROMPT);
}
Exemple #10
0
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
	mode = COMMAND_MODE;
	shell_output("Greetings and salutations, sir or madam.", "");
	shell_output("I bid you welcome to the IGOR command shell!", "");
	shell_output("How may I serve you today?", "");
	shell_output("Please, type '?' and return for help.", "");
	shell_prompt(SHELL_PROMPT);
}
Exemple #11
0
void shell(void) {
    const size_t BUFFER_LEN = 50;
    int sc;
    size_t len = 0;
    char buf[BUFFER_LEN + 1];
    buf[0] = '\0';
    shell_prompt();
    while (1) {
        asm volatile("hlt");
        sc = kbd_get_keycode();
        if (sc != -1) {
            char c = (kbd_get_shift() ? kbd_ascii_map_shift : kbd_ascii_map)[sc];
            if (c == 8) {
                if (len > 0) {
                    len--;
                    buf[len] = '\0';
                    putc(8);
                }
            } else if (c == 27) {
                while (len > 0) {
                    putc(8);
                    len--;
                }
                buf[0] = '\0';
            } else if (c == '\n') {
                putc('\n');
                shell_cmd(buf);
                len = 0;
                buf[0] = '\0';
                shell_prompt();
            } else if (kbd_get_ctrl() && c == 'c') {
                printf("^C\n");
                len = 0;
                buf[0] = '\0';
                shell_prompt();
            } else if (c && len < BUFFER_LEN) {
                buf[len++] = c;
                buf[len] = '\0';
                putc(c);
            }
        }
    }
}
Exemple #12
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(bbs_setboard_process, ev, data)
{

    struct shell_input *input;
    char szBuff[BBS_LINE_WIDTH];
    unsigned short num;
    ST_FILE file;
    BBS_BOARD_REC board;

    PROCESS_BEGIN();

    /* read board data */
    strcpy(file.szFileName, BBS_BOARDCFG_FILE);
    file.ucDeviceNo=8;
    ssReadRELFile(&file, &board, sizeof(BBS_BOARD_REC), bbs_status.bbs_board_id);

    memset(szBuff, 0, sizeof(szBuff));
    sprintf(szBuff, "(%s (%d, acl: %d) Choose board # (1-%d, 0=quit)? ", board.board_name, board.board_no, board.access_req, board.max_boards);
    shell_prompt(szBuff);

    PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
    input = data;
    num = atoi(input->data1);

    /* read new board data */
    strcpy(file.szFileName, BBS_BOARDCFG_FILE);
    file.ucDeviceNo=8;
    ssReadRELFile(&file, &board, sizeof(BBS_BOARD_REC), num);

    if (atoi(input->data1) < 0 || atoi(input->data1) > board.max_boards) {
        shell_prompt("invalid board id.\n");
    } else {
        if (bbs_user.access_req >= board.access_req) {
            bbs_status.bbs_board_id = num;
            shell_prompt("ok\n");
        } else {
            shell_prompt("insufficient access rights.\n");
        }
    }
    PROCESS_EXIT();

    PROCESS_END();
}
Exemple #13
0
/*---------------------------------------------------------------------------*/
void
shell_input(char *cmd)
{
	char *buff;
  //parse(cmd, parsetab);
	if(!strcmp(cmd,"quit")) shell_quit(cmd);
	else {
	  CLI_Builder(cmd, buff);
	  shell_output(buff,"\n");
	  shell_prompt(CLI_PROMPT);
	}
}
Exemple #14
0
void Rsh::run()
{
    PipeMgt mgt = PipeMgt();
    
    welcome_screen();
    shell_prompt();
    
    do{
	TOKEN token = scanner.lex();
	Action action = actionTable[token];
	(this->*action)();
    }while(true);
}
Exemple #15
0
/*-----------------------------------------------------------------------------------*/
void
shell_input(char *cmd)
{
  if(showingdir != 0) {
    showingdir = 0;
    shell_output("Directory stopped", "");
    cfs_closedir(&dir);
  }
  parse(cmd, configparsetab);
  if(showingdir == 0) {
    shell_prompt("contiki-c64> ");
  }
}
Exemple #16
0
char *git_terminal_prompt(const char *prompt, int echo)
{
	static struct strbuf buf = STRBUF_INIT;
	int r;
	FILE *input_fh, *output_fh;

#ifdef GIT_WINDOWS_NATIVE

	/* try shell_prompt first, fall back to CONIN/OUT if bash is missing */
	char *result = shell_prompt(prompt, echo);
	if (result)
		return result;

	if (echo && set_echo(1))
		return NULL;
#endif

	input_fh = fopen(INPUT_PATH, "r" FORCE_TEXT);
	if (!input_fh)
		return NULL;

	output_fh = fopen(OUTPUT_PATH, "w" FORCE_TEXT);
	if (!output_fh) {
		fclose(input_fh);
		return NULL;
	}

	if (!echo && disable_echo()) {
		fclose(input_fh);
		fclose(output_fh);
		return NULL;
	}

	fputs(prompt, output_fh);
	fflush(output_fh);

	r = strbuf_getline_lf(&buf, input_fh);
	if (!echo) {
		putc('\n', output_fh);
		fflush(output_fh);
	}

	restore_term();
	fclose(input_fh);
	fclose(output_fh);

	if (r == EOF)
		return NULL;
	return buf.buf;
}
Exemple #17
0
void Rsh::run()
{
        if(!finish)
        {
                pthread_t* thread;
                pthread_create(thread, NULL, prun, (void*)this);
                
                welcome_screen();
                shell_prompt();
                
                char buf[64];
                sprintf(buf, "Userid:%d --- Username:%s from:%s entered\n", shareinfo->get_id(), shareinfo->get_name(), shareinfo->get_ip());
                std::string message = buf;
                //broadcast(message.c_str(), message.size());
        
                do{
                        TOKEN token = scanner->lex();
                        switch(token)
                        {
                                case NEWLINE:
                                        onNewline();
                                        break;
                                case SLASH:
                                        onSlash();
                                        break;
                                case TRANIN:
                                        onTranIn();
                                        break;
                                case TRANOUT:
                                        onTranOut();
                                        break;
                                case WORD:
                                        onWord();
                                        break;
                                case PIPI:
                                        onPipe();
                                        break;
                                case ERROR:
                                        finish = true;
                                        break;
                        }
                }while(!finish);
                sprintf(buf, "*** Userid:%d --- Username:%s leaved ***\n", shareinfo->get_id(), shareinfo->get_name());
                message = buf;
                //sem_wait(sem_exit);
//                 broadcast(message.c_str(), message.size());
                //sem_post(sem_exit);
        }
}
Exemple #18
0
/*---------------------------------------------------------------------------*/
void
shell_input(char *cmd)
{
	if (mode == COMMAND_MODE) {
		parse(cmd, parsetab);
	}
	if (mode == COMMAND_MODE) {
		shell_prompt(SHELL_PROMPT);
	} else {
		//Lisp mode does not work yet
/*		struct buf *buf;
		buf = &telnet_data.readbuf;
		buf_write(buf, (uint8_t *)cmd, strlen(cmd));
*/	}
}
Exemple #19
0
void Rsh::onNewline()
{
        if(command.size() > 0)
        {
                PipeMgt::iterator it = mgt->find(commandno);
                
                if(it != mgt->end())
                {
                        if(sin == FIL)
                                close(it->second.in);
                        else
                        {
                                curin = it->second.in;
                                sin = PIP;
                        }
                        close(it->second.out);
                }
                execCommand(curin, curout);
        }
        shell_prompt();
}
Exemple #20
0
/*-----------------------------------------------------------------------------------*/
void
shell_eventhandler(ek_event_t ev, ek_data_t data)
{
  static struct cfs_dirent dirent;
  static char size[10];

  if(ev == EK_EVENT_CONTINUE) {
    if(showingdir != 0) {
      if(cfs_readdir(&dir, &dirent) != 0) {
	cfs_closedir(&dir);
	showingdir = 0;
	inttostr(size, totsize);
	shell_output("Total number of blocks: ", size);
	shell_prompt("contiki-c64> ");
      } else {
	totsize += dirent.size;
	inttostr(size, dirent.size);
	shell_output(size, dirent.name);
	ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
      }
    }
  }
}
Exemple #21
0
/*---------------------------------------------------------------------------*/
void shell_start(void)
{
  shell_output_P(PSTR("uIP command shell"), PSTR(""));
  shell_output_P(PSTR("Type '?' and return for help"), PSTR(""));
  shell_prompt(SHELL_PROMPT);
}
Exemple #22
0
/*---------------------------------------------------------------------------*/
void
shell_input(char *cmd)
{
  parse(cmd, parsetab);
  shell_prompt(SHELL_PROMPT);
}