FreeCalypso > hg > e1-fake-trau
annotate ft16/user_cmd.c @ 5:3604828b2f54
add top Makefile
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 29 Aug 2024 13:21:38 +0000 |
parents | adcdbb2e30fe |
children |
rev | line source |
---|---|
2
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we handle user-issued stdin commands during |
4
adcdbb2e30fe
faketrau-16k: update code comments to new name
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
3 * faketrau-16k running session. |
2
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdint.h> |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdbool.h> |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <string.h> |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <osmocom/core/select.h> |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "globals.h" |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 static struct cmdtab { |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 char *cmd; |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 void (*func)(int argc, char **argv); |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 } cmdtab[] = { |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 {"print-rx", cmd_print_rx}, |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 {"record", cmd_record_start}, |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 {"record-stop", cmd_record_stop}, |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 /* table search terminator */ |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 {NULL, NULL} |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 }; |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 void handle_user_cmd(int argc, char **argv) |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 { |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 struct cmdtab *tp; |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 for (tp = cmdtab; tp->cmd; tp++) |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 if (!strcmp(tp->cmd, argv[0])) |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 break; |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (!tp->func) { |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 printf("error: unknown or unimplemented command\n"); |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 return; |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 } |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 tp->func(argc, argv); |
5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 } |