]> git.cryptolib.org Git - arm-crypto-lib.git/blobdiff - test_src/cli.c
starting to make bigint more portable/32-bit efficient
[arm-crypto-lib.git] / test_src / cli.c
index 3ecdf6cd9e7b8c4d5151f18305082f03d5ef1886..c609d9f588d7a09f4a612c85301ad65ceb99725c 100644 (file)
@@ -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(;;){