summaryrefslogtreecommitdiff
path: root/usr.bin/cu/command.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2012-07-10 12:47:24 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2012-07-10 12:47:24 +0000
commit602ccbf5d4f2fbfc7cb76196edf416ee39629434 (patch)
tree737f9823f3bb2930e8419cb4091ac5d24023cba3 /usr.bin/cu/command.c
parentba89989533bd55a701b857e20f5002ad0b3521f1 (diff)
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"