diff pcm/user_cmd.c @ 6:631f2db08538

pcm: implement print-rx and record commands
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 23 Jun 2024 18:53:01 +0000
parents 7233c10af3ad
children 70aa8cbdbde9
line wrap: on
line diff
--- a/pcm/user_cmd.c	Sun Jun 23 18:33:09 2024 +0000
+++ b/pcm/user_cmd.c	Sun Jun 23 18:53:01 2024 +0000
@@ -13,7 +13,27 @@
 
 #include "globals.h"
 
+static struct cmdtab {
+	char	*cmd;
+	void	(*func)(int argc, char **argv);
+} cmdtab[] = {
+	{"print-rx", cmd_print_rx},
+	{"record", cmd_record_start},
+	{"record-stop", cmd_record_stop},
+	/* table search terminator */
+	{NULL, NULL}
+};
+
 void handle_user_cmd(int argc, char **argv)
 {
-	/* to be filled */
+	struct cmdtab *tp;
+
+	for (tp = cmdtab; tp->cmd; tp++)
+		if (!strcmp(tp->cmd, argv[0]))
+			break;
+	if (!tp->func) {
+		printf("error: unknown or unimplemented command\n");
+		return;
+	}
+	tp->func(argc, argv);
 }