comparison sip-manual-out/user_cmd.c @ 195:a3d71489672f

sip-manual-out: implement tfo-req command
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 17 Mar 2023 17:22:42 -0800
parents 1f9a6cede2c5
children f3164f732b84
comparison
equal deleted inserted replaced
194:05d01e810217 195:a3d71489672f
6 #include <ctype.h> 6 #include <ctype.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 #include <strings.h> 10 #include <strings.h>
11
12 static void
13 tfo_req_cmd(args)
14 char *args;
15 {
16 char *cp;
17 unsigned sig, codec;
18
19 for (cp = args; isspace(*cp); cp++)
20 ;
21 if (!isdigit(*cp)) {
22 inv_syntax: fprintf(stderr, "error: tfo-req command invalid syntax\n");
23 return;
24 }
25 sig = strtoul(cp, &cp, 0);
26 if (!isspace(*cp))
27 goto inv_syntax;
28 if (sig > 0xFF) {
29 fprintf(stderr, "error: Sig argument out of range\n");
30 return;
31 }
32 while (isspace(*cp))
33 cp++;
34 if (!isdigit(*cp))
35 goto inv_syntax;
36 codec = strtoul(cp, &cp, 0);
37 if (*cp && !isspace(*cp))
38 goto inv_syntax;
39 if (codec > 14) {
40 fprintf(stderr, "error: Codec_Type argument out of range\n");
41 return;
42 }
43 while (isspace(*cp))
44 cp++;
45 if (*cp)
46 goto inv_syntax;
47 send_tfo_req(sig, codec);
48 }
11 49
12 void 50 void
13 select_stdin() 51 select_stdin()
14 { 52 {
15 char buf[256], *cp; 53 char buf[256], *cp;
27 return; 65 return;
28 if (!strcmp(cp, "b") || !strcasecmp(cp, "bye")) 66 if (!strcmp(cp, "b") || !strcasecmp(cp, "bye"))
29 send_bye_req(); 67 send_bye_req();
30 else if (!strcmp(cp, "c") || !strcasecmp(cp, "cancel")) 68 else if (!strcmp(cp, "c") || !strcasecmp(cp, "cancel"))
31 send_cancel_req(); 69 send_cancel_req();
70 else if (!strncmp(cp, "tfo-req", 7) && isspace(cp[7]))
71 tfo_req_cmd(cp + 8);
32 else 72 else
33 fprintf(stderr, "error: non-understood stdin command\n"); 73 fprintf(stderr, "error: non-understood stdin command\n");
34 } 74 }