changeset 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 f8a33603288f
children 05d01e810217
files sip-manual-out/Makefile sip-manual-out/disc_cmd.c sip-manual-out/user_cmd.c
diffstat 3 files changed, 35 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/sip-manual-out/Makefile	Fri Mar 17 13:45:31 2023 -0800
+++ b/sip-manual-out/Makefile	Fri Mar 17 14:31:54 2023 -0800
@@ -2,7 +2,7 @@
 CFLAGS=	-O2
 PROG=	sip-manual-out
 OBJS=	bye_in.o disc_cmd.o main.o readconf.o reinvite.o rtp_rx.o rtp_tx.o \
-	sdp_in.o sip_log.o sip_udp.o uac.o uas.o
+	sdp_in.o sip_log.o sip_udp.o uac.o uas.o user_cmd.o
 LIBS=	../libsip/libsip.a ../librtpalloc/librtpalloc.a ../libutil/libutil.a
 INSTBIN=/usr/local/bin
 
--- a/sip-manual-out/disc_cmd.c	Fri Mar 17 13:45:31 2023 -0800
+++ b/sip-manual-out/disc_cmd.c	Fri Mar 17 14:31:54 2023 -0800
@@ -53,27 +53,3 @@
 	sip_tx_packet(&msg, &sip_dest_sin);
 	return(0);
 }
-
-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");
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sip-manual-out/user_cmd.c	Fri Mar 17 14:31:54 2023 -0800
@@ -0,0 +1,34 @@
+/*
+ * 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");
+}