Exemplo n.º 1
0
static int
handle_input_file(char *fname, struct handle_param *hparam)
{
    FILE *f = NULL;
    char buf[1024*1024] = {0};
    char *p = NULL;

    blog(LOG_DEBUG, "handling file:%s", fname);
    if(!(f = fopen(fname, "r"))){
        blog(LOG_ERR, "open file failed:%s", buf);
        return -1;
    }
    while(!feof(f)){
        if(!(p = fgets(buf, sizeof(buf) - 1, f))){
            if(!feof(f)){
                blog(LOG_ERR, "read file error");
                break;
            }
            break;
        }
        blog(LOG_DEBUG, "get line from file : %s", p);
        handle_input_line(buf, hparam);
    }
    fclose(f);
    return 0;
}
Exemplo n.º 2
0
void shell_run(shell_t *shell) {
    char line_buf[255];

    while(1) {
        int res = readline(shell, line_buf, sizeof(line_buf));
        shell->put_char('>');
        if (! res ) {
            char* line_copy = strdup(line_buf);
            handle_input_line(shell, line_copy);
            free(line_copy);
        }
    }
}
Exemplo n.º 3
0
Arquivo: shell.c Projeto: JMR-b/RIOT
void shell_run(const shell_command_t *shell_commands, char *line_buf, int len)
{
    print_prompt();

    while (1) {
        int res = readline(line_buf, len);

        if (!res) {
            handle_input_line(shell_commands, line_buf);
        }

        print_prompt();
    }
}
Exemplo n.º 4
0
void shell_run(shell_t *shell)
{
    char line_buf[shell->shell_buffer_size];

    print_prompt(shell);

    while (1) {
        int res = readline(shell, line_buf, sizeof(line_buf));

        if (!res) {
            handle_input_line(shell, line_buf);
        }

        print_prompt(shell);
    }
}