comparison test-v22/user_cmd.c @ 10:3c5734b88c20

sipout-test-v22 put together
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 07 Mar 2024 02:33:49 -0800
parents test-fsk/user_cmd.c@030d52b96a23
children
comparison
equal deleted inserted replaced
9:ff535725e01f 10:3c5734b88c20
1 /*
2 * In this module we implement stdin command handling, supporting
3 * user-initiated CANCEL and BYE.
4 */
5
6 #include <ctype.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <strings.h>
11
12 static void
13 pcm_fill_cmd(arg)
14 char *arg;
15 {
16 char *cp;
17 unsigned octet;
18
19 for (cp = arg; isspace(*cp); cp++)
20 ;
21 if (!isxdigit(*cp)) {
22 inv_syntax: fprintf(stderr, "error: pcm-fill command invalid syntax\n");
23 return;
24 }
25 octet = strtoul(cp, &cp, 16);
26 if (*cp)
27 goto inv_syntax;
28 if (octet > 0xFF) {
29 fprintf(stderr,
30 "error: pcm-fill octet argument out of range\n");
31 return;
32 }
33 set_pcm_fill_octet(octet);
34 }
35
36 void
37 select_stdin()
38 {
39 char buf[256], *cp;
40
41 fgets(buf, sizeof buf, stdin);
42 cp = index(buf, '\n');
43 if (cp) {
44 while (cp > buf && isspace(cp[-1]))
45 cp--;
46 *cp = '\0';
47 }
48 for (cp = buf; isspace(*cp); cp++)
49 ;
50 if (!*cp)
51 return;
52 if (!strcmp(cp, "b") || !strcasecmp(cp, "bye"))
53 send_bye_req();
54 else if (!strcmp(cp, "c") || !strcasecmp(cp, "cancel"))
55 send_cancel_req();
56 else
57 fprintf(stderr, "error: non-understood stdin command\n");
58 }