X-Git-Url: https://git.cryptolib.org/?p=arm-crypto-lib.git;a=blobdiff_plain;f=test_src%2Fcli.c;h=c609d9f588d7a09f4a612c85301ad65ceb99725c;hp=3ecdf6cd9e7b8c4d5151f18305082f03d5ef1886;hb=5e75eafde9b0269aa78395bbeb3e79ff36a1f082;hpb=f4853b26a54089e6796fcf115f739f1e9ea7ceb7 diff --git a/test_src/cli.c b/test_src/cli.c index 3ecdf6c..c609d9f 100644 --- a/test_src/cli.c +++ b/test_src/cli.c @@ -90,13 +90,12 @@ void cli_putstr(const char* s){ cli_tx(*s++); } - /** * \brief reads a line or max n characters from the console * Writes characters from the console into the supplied buffer until a '\r' * character is received or until n character a read (whatever happens first). * The string will always be terminated by a '\0' character, so the buffer - * should have at least a size of n+1. + * should have at least a size of n+1. */ uint8_t cli_getsn(char* s, uint32_t n){ char c; @@ -109,6 +108,22 @@ uint8_t cli_getsn(char* s, uint32_t n){ return (c=='\r')?0:1; } +/** + * \brief reads a line or max n characters from the console and echos the characters back + * Writes characters from the console into the supplied buffer until a '\r' + * character is received or until n character a read (whatever happens first). + * The string will always be terminated by a '\0' character, so the buffer + * should have at least a size of n+1. + */ +uint8_t cli_getsn_cecho(char* s, uint32_t n){ + uint8_t echo_backup,r ; + echo_backup = cli_echo; + cli_echo = 1; + r = cli_getsn(s, n); + cli_echo = echo_backup; + return r; +} + void cli_hexdump_byte(uint8_t byte){ cli_tx(hexdigit_tab[byte>>4]); cli_tx(hexdigit_tab[byte & 0xf]); @@ -309,7 +324,7 @@ uint8_t cli_completion(char* buffer, uint16_t maxcmdlength, const cmdlist_entry_ ref[0]='\0'; /* check if we are behind the first word */ while(buffer[i]){ - if(!isgraph(buffer[i++])) + if(!isgraph((uint8_t)(buffer[i++]))) return 0; } for(;;){