summaryrefslogtreecommitdiff
path: root/n/avr/proto/proto.c
diff options
context:
space:
mode:
authorschodet2005-03-25 18:54:13 +0000
committerschodet2005-03-25 18:54:13 +0000
commit688c743313118c681dc8a8fe8dda2e2eaf9bd8a9 (patch)
tree16301df037da3b8856bbb9c8f4bb9699b59723d7 /n/avr/proto/proto.c
parent54e09378739ace8a751ca452c654d452146571fd (diff)
Ajout du support du quote dans les paramètres.
Diffstat (limited to 'n/avr/proto/proto.c')
-rw-r--r--n/avr/proto/proto.c35
1 files changed, 34 insertions, 1 deletions
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)