diff abis/user_cmd.c @ 30:5dd30224b70a

abis: starting new program
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 13 Aug 2024 21:38:55 +0000
parents ater/user_cmd.c@1dda11905e85
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/abis/user_cmd.c	Tue Aug 13 21:38:55 2024 +0000
@@ -0,0 +1,39 @@
+/*
+ * In this module we handle user-issued stdin commands during
+ * itt-abis-16 running session.
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <osmocom/core/select.h>
+
+#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)
+{
+	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);
+}