void input(char *b, uint16_t l) { char *s = b; char *e = b + l; while(s < e && read(0, s, 1) == 1) { if (*s == 13 || *s == 10) { *s = 0; return; } if (*s < 32) continue; s++; } waitcr(); *s = 0; }
int main(int argc, char *argv[]) { struct swcli_context ctx; char hostname[HOST_NAME_MAX]; if (switch_init() < 0) { perror("switch_init"); return -1; } gethostname(hostname, sizeof(hostname)); hostname[sizeof(hostname) - 1] = '\0'; printf( "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" "\r\n\r\n%s con0 is now available\r\n\r\n\r\n\r\n\r\n\r\n" "Press RETURN to get started." "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", hostname); waitcr(); /* FIXME: enable should behave differently when the cli is invoked from * console, i.e. it should not warn the user that no password is set. * In the old cli this was done by setting a global flag: * console_session = 1; */ CLI_CTX(&ctx)->node_filter = PRIV_FILTER(1); CLI_CTX(&ctx)->root = &menu_main; CLI_CTX(&ctx)->out_open = cli_out_open; RLSHELL_CTX(&ctx)->prompt = swcli_prompt; RLSHELL_CTX(&ctx)->exit = 0; RLSHELL_CTX(&ctx)->enable_ctrl_z = 0; ctx.sock_fd = -1; ctx.cdp = NULL; rlshell_main(RLSHELL_CTX(&ctx)); return 0; }