# HG changeset patch # User LluĂ­s Batlle # Date 1395329607 -3600 # Node ID eea77d5a624c7029c76b0f58c725230a57e9867b # Parent 7d9b7a6da50773d6cebb00d2ce9c7334f439e234# Parent d090ddac513166001ca221ea80d97fbca6f8b190 Merging the savefile branch. I hope it works; I even don't remember it. diff -r 7d9b7a6da507 -r eea77d5a624c Makefile --- a/Makefile Thu Aug 21 23:21:22 2008 +0200 +++ b/Makefile Thu Mar 20 16:33:27 2014 +0100 @@ -32,7 +32,7 @@ $(INSTALL) tm $(PREFIX)/bin tm: $(OBJECTS) - $(CC) -o $@ $(LINUX_LIBS) $^ + $(CC) -o $@ $^ $(LINUX_LIBS) test_filter: test_filter.o filter.o simple_math.o filter_string.o error.o diff -r 7d9b7a6da507 -r eea77d5a624c app_control.c --- a/app_control.c Thu Aug 21 23:21:22 2008 +0200 +++ b/app_control.c Thu Mar 20 16:33:27 2014 +0100 @@ -19,6 +19,8 @@ static struct FilterRules *fr; +int savefile = -1; + void write_newline_cb(struct FilterRules *myfr, const struct FFilter *ff, char *obuf, int *olen, const char *ibuf, int pos) @@ -107,6 +109,8 @@ if (command_line.s_param.serve_eth) s_eth_send_to_connected(stream_buffer, res); #endif /* linux */ + if (savefile != -1) + write(savefile, stream_buffer, res); } } if (app_stderr != -1 && app_stdout != app_stderr && @@ -155,6 +159,8 @@ { hex_dump("from local to app", buffer, size); write(app_stdin, buffer, size); + if (savefile != -1) + write(savefile, buffer, size); } } @@ -167,6 +173,8 @@ command_line.s_param.echo_in_local_terminal) write(1, buffer, size); write(app_stdin, buffer, size); + if (savefile != -1) + write(savefile, buffer, size); } } diff -r 7d9b7a6da507 -r eea77d5a624c main.c --- a/main.c Thu Aug 21 23:21:22 2008 +0200 +++ b/main.c Thu Mar 20 16:33:27 2014 +0100 @@ -55,6 +55,7 @@ #ifdef linux printf(" -e dev[:port] Also serve/connect using raw ethernet, device 'dev'.\n"); printf(" -c adr Connect to address (MAC if eth).\n"); + printf(" -s fil Save the child stdin/stdout to the filename 'fil'.\n"); #endif /* linux */ printf(" -x Send xterm's resize control string to clients.\n"); return 0; @@ -112,6 +113,7 @@ command_line.s_param.echo_in_local_terminal = 0; command_line.s_param.send_xterm_resize = 0; command_line.s_param.serve_eth = 0; + command_line.s_param.savefile = 0; command_line.tcp_port = 40000; /* Arbitrary */ command_line.eth_port = 100; /* Arbitrary */ @@ -132,7 +134,7 @@ extern int optind, opterr, optopt; while(1) { - c = my_getopt(argc, argv, "tp:nBxdPN:hwCED" + c = my_getopt(argc, argv, "s:tp:nBxdPN:hwCED" #ifdef linux "c:e:" #endif /* linux */ @@ -192,6 +194,9 @@ parse_eth_device(optarg); command_line.c_param.transport = ETHERNET; break; + case 's': + command_line.s_param.savefile = strdup(optarg); + break; case '?': error("Wrong option %c.\n", optopt); } diff -r 7d9b7a6da507 -r eea77d5a624c main.h --- a/main.h Thu Aug 21 23:21:22 2008 +0200 +++ b/main.h Thu Mar 20 16:33:27 2014 +0100 @@ -23,6 +23,7 @@ char client_may_close_app_stdin; char client_can_write; char nohup; /* detach from terminal as nohup */ + char *savefile; char **command; /* ordono por exec */ } s_param; struct { diff -r 7d9b7a6da507 -r eea77d5a624c server.c --- a/server.c Thu Aug 21 23:21:22 2008 +0200 +++ b/server.c Thu Mar 20 16:33:27 2014 +0100 @@ -12,6 +12,7 @@ #include #include #include +#include #include "main.h" #include "handlers.h" @@ -19,6 +20,9 @@ /* signals.c */ extern int child_died; +/* app_control.c */ +extern int savefile; + /*extern*/ void fdset_dump(fd_set *set, int maxfd); @@ -143,6 +147,12 @@ s_eth_init(); #endif /* linux */ + if (command_line.s_param.savefile) + { + savefile = open(command_line.s_param.savefile, + O_CREAT | O_TRUNC | O_RDWR, 0666); + } + child = fork_app(command_line.s_param.command); if (command_line.s_param.nohup)