comparison 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
comparison
equal deleted inserted replaced
192:f8a33603288f 193:1f9a6cede2c5
1 /*
2 * In this module we implement stdin command handling, supporting
3 * user-initiated CANCEL and BYE as well as TFO testing commands.
4 */
5
6 #include <ctype.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <strings.h>
11
12 void
13 select_stdin()
14 {
15 char buf[256], *cp;
16
17 fgets(buf, sizeof buf, stdin);
18 cp = index(buf, '\n');
19 if (cp) {
20 while (cp > buf && isspace(cp[-1]))
21 cp--;
22 *cp = '\0';
23 }
24 for (cp = buf; isspace(*cp); cp++)
25 ;
26 if (!*cp)
27 return;
28 if (!strcmp(cp, "b") || !strcasecmp(cp, "bye"))
29 send_bye_req();
30 else if (!strcmp(cp, "c") || !strcasecmp(cp, "cancel"))
31 send_cancel_req();
32 else
33 fprintf(stderr, "error: non-understood stdin command\n");
34 }