FreeCalypso > hg > themwi-interim
comparison mtctest/user_cmd.c @ 8:a902ccbf6bbc
mtctest: introduce general user command structure
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sun, 09 Jun 2024 02:48:55 +0000 |
| parents | |
| children | aa2ba9b432af |
comparison
equal
deleted
inserted
replaced
| 7:d0b86b144577 | 8:a902ccbf6bbc |
|---|---|
| 1 /* | |
| 2 * In this module we implement stdin command handling: we start with | |
| 3 * 'disc' command for caller-initiated disconnect, and then we'll add | |
| 4 * play commands for RTP output. | |
| 5 */ | |
| 6 | |
| 7 #include <ctype.h> | |
| 8 #include <stdio.h> | |
| 9 #include <stdlib.h> | |
| 10 #include <string.h> | |
| 11 #include <strings.h> | |
| 12 | |
| 13 void | |
| 14 select_stdin() | |
| 15 { | |
| 16 char buf[256], *cp; | |
| 17 | |
| 18 fgets(buf, sizeof buf, stdin); | |
| 19 cp = index(buf, '\n'); | |
| 20 if (cp) { | |
| 21 while (cp > buf && isspace(cp[-1])) | |
| 22 cp--; | |
| 23 *cp = '\0'; | |
| 24 } | |
| 25 for (cp = buf; isspace(*cp); cp++) | |
| 26 ; | |
| 27 if (!*cp) | |
| 28 return; | |
| 29 if (!strcmp(cp, "disc")) | |
| 30 disconnect_command(); | |
| 31 else | |
| 32 fprintf(stderr, "error: non-understood stdin command\n"); | |
| 33 } |
