FreeCalypso > hg > themwi-interim
view mtctest/user_cmd.c @ 13:c71801aa0039 default tip
themwi-test-mtc: increase maximum play length
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 29 Oct 2024 00:06:28 +0000 |
parents | aa2ba9b432af |
children |
line wrap: on
line source
/* * In this module we implement stdin command handling: 'disc' command * for caller-initiated disconnect; 'play' and 'play-stop' commands * for RTP output. */ #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> static void play_cmd(args) char *args; { char *cp, *filename; unsigned frame_len; int loop; for (cp = args; isspace(*cp); cp++) ; if (!*cp) { inv_syntax: fprintf(stderr, "error: play command invalid syntax\n"); return; } for (filename = cp; *cp && !isspace(*cp); cp++) ; if (!*cp) goto inv_syntax; *cp++ = '\0'; while (isspace(*cp)) cp++; if (!isdigit(*cp)) goto inv_syntax; frame_len = strtoul(cp, &cp, 0); if (*cp && !isspace(*cp)) goto inv_syntax; if (frame_len < 1 || frame_len > 160) { fprintf(stderr, "error: frame length argument out of range\n"); return; } while (isspace(*cp)) cp++; if (*cp) { if (strcmp(cp, "loop")) goto inv_syntax; loop = 1; } else loop = 0; play_file_cmdop(filename, frame_len, loop); } void select_stdin() { char buf[256], *cp; fgets(buf, sizeof buf, stdin); cp = index(buf, '\n'); if (cp) { while (cp > buf && isspace(cp[-1])) cp--; *cp = '\0'; } for (cp = buf; isspace(*cp); cp++) ; if (!*cp) return; if (!strcmp(cp, "disc")) disconnect_command(); else if (!strncmp(cp, "play", 4) && isspace(cp[4])) play_cmd(cp + 5); else if (!strcmp(cp, "play-stop")) play_file_stop(); else fprintf(stderr, "error: non-understood stdin command\n"); }