diff options
| author | Keith Packard <keithp@keithp.com> | 2016-11-02 14:14:23 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-02-20 11:16:49 -0800 | 
| commit | caba623cb013b73e1f0ca369edf98e0376bec41a (patch) | |
| tree | 54944406e26b10991c6a356aec26cbfb0d19baac /src/kernel/ao_cmd.c | |
| parent | d2408e72d1e0d3459918601712b09860ab17e200 (diff) | |
altos/kernel: Make ao_cmd_readline public. Return char from ao_cmd_lex.
With these two changes, the readline function can be used by other
code.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/kernel/ao_cmd.c')
| -rw-r--r-- | src/kernel/ao_cmd.c | 19 | 
1 files changed, 11 insertions, 8 deletions
| diff --git a/src/kernel/ao_cmd.c b/src/kernel/ao_cmd.c index 10716afd..077d7de1 100644 --- a/src/kernel/ao_cmd.c +++ b/src/kernel/ao_cmd.c @@ -24,13 +24,15 @@ __pdata uint32_t ao_cmd_lex_u32;  __pdata char	ao_cmd_lex_c;  __pdata enum ao_cmd_status ao_cmd_status; +#ifndef AO_CMD_LEN  #if AO_PYRO_NUM -#define CMD_LEN 128 +#define AO_CMD_LEN 128  #else -#define CMD_LEN	48 +#define AO_CMD_LEN	48 +#endif  #endif -static __xdata char	cmd_line[CMD_LEN]; +static __xdata char	cmd_line[AO_CMD_LEN];  static __pdata uint8_t	cmd_len;  static __pdata uint8_t	cmd_i; @@ -48,8 +50,8 @@ backspace(void)  	ao_put_string ("\010 \010");  } -static void -readline(void) +void +ao_cmd_readline(void)  {  	char c;  	if (ao_echo()) @@ -88,7 +90,7 @@ readline(void)  			break;  		} -		if (cmd_len >= CMD_LEN - 2) +		if (cmd_len >= AO_CMD_LEN - 2)  			continue;  		cmd_line[cmd_len++] = c;  		if (ao_echo()) @@ -99,12 +101,13 @@ readline(void)  	cmd_i = 0;  } -void +char  ao_cmd_lex(void)  {  	ao_cmd_lex_c = '\n';  	if (cmd_i < cmd_len)  		ao_cmd_lex_c = cmd_line[cmd_i++]; +	return ao_cmd_lex_c;  }  static void @@ -376,7 +379,7 @@ ao_cmd(void)  	void (*__xdata func)(void);  	for (;;) { -		readline(); +		ao_cmd_readline();  		ao_cmd_lex();  		ao_cmd_white();  		c = ao_cmd_lex_c; | 
