summaryrefslogtreecommitdiffstats
path: root/usr.bin/cu/command.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2012-07-10 12:47:23 +0000
committernicm <nicm@openbsd.org>2012-07-10 12:47:23 +0000
commit66d5e211bb45be6afb8297927d50bafdfbc1617c (patch)
tree63f3ec652e8d4c560991fbc4df4d3a42767fa350 /usr.bin/cu/command.c
parentKill trailing whitespaces. (diff)
downloadwireguard-openbsd-66d5e211bb45be6afb8297927d50bafdfbc1617c.tar.xz
wireguard-openbsd-66d5e211bb45be6afb8297927d50bafdfbc1617c.zip
Add ~R command to start recording output to a file.
Diffstat (limited to 'usr.bin/cu/command.c')
-rw-r--r--usr.bin/cu/command.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/usr.bin/cu/command.c b/usr.bin/cu/command.c
index d902748efdb..7a8980584ec 100644
--- a/usr.bin/cu/command.c
+++ b/usr.bin/cu/command.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: command.c,v 1.9 2012/07/10 12:20:23 nicm Exp $ */
+/* $OpenBSD: command.c,v 1.10 2012/07/10 12:47:23 nicm Exp $ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org>
@@ -195,6 +195,25 @@ set_speed(void)
}
void
+start_record(void)
+{
+ const char *file;
+
+ if (record_file != NULL) {
+ fclose(record_file);
+ record_file = NULL;
+ }
+
+ file = get_input("Record file?");
+ if (file == NULL || *file == '\0')
+ return;
+
+ record_file = fopen(file, "a");
+ if (record_file == NULL)
+ cu_warnx("%s", file);
+}
+
+void
do_command(char c)
{
switch (c) {
@@ -210,6 +229,9 @@ do_command(char c)
case 'C':
connect_command();
break;
+ case 'R':
+ start_record();
+ break;
case 'S':
set_speed();
break;
@@ -233,6 +255,7 @@ do_command(char c)
"~$ pipe local command to remote host\r\n"
"~> send file to remote host\r\n"
"~C connect program to remote host\r\n"
+ "~R start recording to file\r\n"
"~S set speed\r\n"
"~X send file with XMODEM\r\n"
"~? get this summary\r\n"