altos: Provide for a pre-filter on commands
authorKeith Packard <keithp@keithp.com>
Fri, 1 Apr 2011 21:07:23 +0000 (14:07 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 1 Apr 2011 21:07:23 +0000 (14:07 -0700)
This allows for external code to see each command line before it is
processed and potentially skip it.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao.h
src/ao_cmd.c

index 2d2bbf82ac247459cbf68f1e5e5101a28ba4886d..77f3259ee5ca5e22186c2662773314ce14cd2122 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -403,6 +403,14 @@ ao_cmd_register(__code struct ao_cmds *cmds);
 void
 ao_cmd_init(void);
 
 void
 ao_cmd_init(void);
 
+#if HAS_CMD_FILTER
+/*
+ * Provided by an external module to filter raw command lines
+ */
+uint8_t
+ao_cmd_filter(void);
+#endif
+
 /*
  * ao_dma.c
  */
 /*
  * ao_dma.c
  */
index 6007773c96cdaba0a8eb6ca63ea4c83580bc7b9f..50d5b96fd9afe4a9355377ebd764a753efe244d4 100644 (file)
@@ -275,6 +275,11 @@ ao_cmd(void)
        lex_echo = 1;
        for (;;) {
                readline();
        lex_echo = 1;
        for (;;) {
                readline();
+#if HAS_CMD_FILTER
+               if (ao_cmd_filter())
+                       continue;
+               cmd_i = 0;
+#endif
                ao_cmd_lex();
                ao_cmd_white();
                c = ao_cmd_lex_c;
                ao_cmd_lex();
                ao_cmd_white();
                c = ao_cmd_lex_c;