view sip-manual-out/user_cmd.c @ 193:1f9a6cede2c5

sip-manual-out: split user_cmd.c from disc_cmd.c
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 17 Mar 2023 14:31:54 -0800
parents sip-manual-out/disc_cmd.c@f8a33603288f
children a3d71489672f
line wrap: on
line source

/*
 * In this module we implement stdin command handling, supporting
 * user-initiated CANCEL and BYE as well as TFO testing commands.
 */

#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, "b") || !strcasecmp(cp, "bye"))
		send_bye_req();
	else if (!strcmp(cp, "c") || !strcasecmp(cp, "cancel"))
		send_cancel_req();
	else
		fprintf(stderr, "error: non-understood stdin command\n");
}