view mtctest/user_cmd.c @ 9:0ec938ed530b

mtctest: capture MSC RTP info for play command
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 09 Jun 2024 03:37:44 +0000
parents a902ccbf6bbc
children aa2ba9b432af
line wrap: on
line source

/*
 * In this module we implement stdin command handling: we start with
 * 'disc' command for caller-initiated disconnect, and then we'll add
 * play commands for RTP output.
 */

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>

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
		fprintf(stderr, "error: non-understood stdin command\n");
}