# HG changeset patch # User Mychaela Falconia # Date 1679092314 28800 # Node ID 1f9a6cede2c54dabf5b5e869cc51cca7cd69ebd6 # Parent f8a33603288f3f9308407aed55b0795336eb27d9 sip-manual-out: split user_cmd.c from disc_cmd.c diff -r f8a33603288f -r 1f9a6cede2c5 sip-manual-out/Makefile --- 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 diff -r f8a33603288f -r 1f9a6cede2c5 sip-manual-out/disc_cmd.c --- 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"); -} diff -r f8a33603288f -r 1f9a6cede2c5 sip-manual-out/user_cmd.c --- /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 +#include +#include +#include +#include + +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"); +}