aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-05-24 13:18:03 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-05-28 10:43:39 -0400
commit528f9f76042a7d82a2108f4ea582c61481368ecf (patch)
tree82ae8a6000e29481cea6382985478b2763def7da /src/command.c
parentc8af3feee6b35e33ab989ca8af0b48d738d4aedf (diff)
downloadkutter-528f9f76042a7d82a2108f4ea582c61481368ecf.tar.gz
kutter-528f9f76042a7d82a2108f4ea582c61481368ecf.tar.xz
kutter-528f9f76042a7d82a2108f4ea582c61481368ecf.zip
command: Add command_find_and_dispatch() helper
Add a helper function that calls command_find_block() followed by command_dispatch(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c
index 965f91ed..2df70d85 100644
--- a/src/command.c
+++ b/src/command.c
@@ -307,3 +307,14 @@ command_dispatch(uint8_t *buf, uint_fast8_t msglen)
func(args);
}
}
+
+// Find a message block and then dispatch all the commands in it
+int_fast8_t
+command_find_and_dispatch(uint8_t *buf, uint_fast8_t buf_len
+ , uint_fast8_t *pop_count)
+{
+ int_fast8_t ret = command_find_block(buf, buf_len, pop_count);
+ if (ret > 0)
+ command_dispatch(buf, *pop_count);
+ return ret;
+}