comparison ater/user_cmd.c @ 15:98ae717734d6

ater: starting skeleton
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 24 Jun 2024 04:01:38 +0000
parents pcm/user_cmd.c@27ca01bb5b11
children f49e57b0d1a2
comparison
equal deleted inserted replaced
14:99426da5603d 15:98ae717734d6
1 /*
2 * In this module we handle user-issued stdin commands during
3 * itt-ater-16 running session.
4 */
5
6 #include <stdint.h>
7 #include <stdbool.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11
12 #include <osmocom/core/select.h>
13
14 #include "globals.h"
15
16 static struct cmdtab {
17 char *cmd;
18 void (*func)(int argc, char **argv);
19 } cmdtab[] = {
20 {"print-rx", cmd_print_rx},
21 {"record", cmd_record_start},
22 {"record-stop", cmd_record_stop},
23 /* table search terminator */
24 {NULL, NULL}
25 };
26
27 void handle_user_cmd(int argc, char **argv)
28 {
29 struct cmdtab *tp;
30
31 for (tp = cmdtab; tp->cmd; tp++)
32 if (!strcmp(tp->cmd, argv[0]))
33 break;
34 if (!tp->func) {
35 printf("error: unknown or unimplemented command\n");
36 return;
37 }
38 tp->func(argc, argv);
39 }