From 688c743313118c681dc8a8fe8dda2e2eaf9bd8a9 Mon Sep 17 00:00:00 2001 From: schodet Date: Fri, 25 Mar 2005 18:54:13 +0000 Subject: Ajout du support du quote dans les paramètres. --- n/avr/proto/proto.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'n/avr/proto/proto.c') diff --git a/n/avr/proto/proto.c b/n/avr/proto/proto.c index ddba80b..900605a 100644 --- a/n/avr/proto/proto.c +++ b/n/avr/proto/proto.c @@ -31,6 +31,10 @@ static void proto_accept_digit (uint8_t c); +/** Accept a quoted char to be used for args. */ +static void +proto_accept_char (uint8_t c); + /* Send a hex digit. */ inline static void proto_hex (uint8_t h); @@ -45,7 +49,8 @@ static uint8_t args[AC_PROTO_ARGS_MAX_SIZE]; * - 0: nothing received. * - 1: bang received. * - 2: command received. - * - 3: command received, and processing a number. */ + * - 3: command received, and processing a number. + * - 4: quote received. */ static uint8_t step; /** Accept a new character. */ @@ -82,6 +87,10 @@ proto_accept (uint8_t c) AC_PROTO_CALLBACK (cmd, size, args); step = 0; } +#if AC_PROTO_QUOTE == 1 + else if (c == '\'') + step = 4; +#endif else { step = 3; @@ -92,6 +101,12 @@ proto_accept (uint8_t c) step--; proto_accept_digit (c); break; +#if AC_PROTO_QUOTE == 1 + case 4: + step = 2; + proto_accept_char (c); + break; +#endif } } } @@ -126,6 +141,24 @@ proto_accept_digit (uint8_t c) size++; } +#if AC_PROTO_QUOTE == 1 +/** Accept a quoted char to be used for args. */ +static void +proto_accept_char (uint8_t c) +{ + /* Test for argument list overflow. */ + if (size >= AC_PROTO_ARGS_MAX_SIZE) + { + AC_PROTO_CALLBACK ('?', 0, 0); + step = 0; + return; + } + /* Add char. */ + args[size] = c; + size++; +} +#endif + /* Send a hex digit. */ inline static void proto_hex (uint8_t h) -- cgit v1.2.3