• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

ttyrecのfork. Original: http://0xcc.net/ttyrec/


Commit MetaInfo

Revisão096ae3f3ac526c2e914897d551d26d520ff8d6ee (tree)
Hora2019-12-09 16:23:30
AutorIWAMOTO Kouichi <sue@iwmt...>
CommiterIWAMOTO Kouichi

Mensagem de Log

update to ttyrec-1.0.7

Mudança Sumário

Diff

--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
11 CC = gcc
22 CFLAGS = -O2
3-VERSION = 1.0.6
3+VERSION = 1.0.7
44
55 TARGET = ttyrec ttyplay ttytime
66
--- a/README
+++ b/README
@@ -8,6 +8,13 @@ or if your system is SVR4 system (Solaris etc.),
88
99 % make CFLAGS=-DSVR4
1010
11+or if your system supports getpt(3),
12+
13+ % make CFLAGS=-DHAVE_getpt
14+
15+HAVE_getpt is required if your linux system uses devfs.
16+
17+
1118 Usage:
1219
1320 % ttyrec
--- a/io.c
+++ b/io.c
@@ -31,11 +31,12 @@
3131 * SUCH DAMAGE.
3232 */
3333
34+#include <assert.h>
35+#include <errno.h>
3436 #include <stdio.h>
3537 #include <stdlib.h>
36-#include <assert.h>
3738 #include <string.h>
38-#include <errno.h>
39+#include <unistd.h>
3940
4041 #include "ttyrec.h"
4142
@@ -127,3 +128,34 @@ efopen (const char *path, const char *mode)
127128 return fp;
128129 }
129130
131+int
132+edup (int oldfd)
133+{
134+ int fd = dup(oldfd);
135+ if (fd == -1) {
136+ fprintf(stderr, "%s: dup failed: %s\n", progname, strerror(errno));
137+ exit(EXIT_FAILURE);
138+ }
139+ return fd;
140+}
141+
142+int
143+edup2 (int oldfd, int newfd)
144+{
145+ int fd = dup2(oldfd, newfd);
146+ if (fd == -1) {
147+ fprintf(stderr, "%s: dup2 failed: %s\n", progname, strerror(errno));
148+ exit(EXIT_FAILURE);
149+ }
150+ return fd;
151+}
152+
153+FILE *
154+efdopen (int fd, const char *mode)
155+{
156+ FILE *fp = fdopen(fd, mode);
157+ if (fp == NULL) {
158+ fprintf(stderr, "%s: fdopen failed: %s\n", progname, strerror(errno));
159+ exit(EXIT_FAILURE);
160+ }
161+}
--- a/io.h
+++ b/io.h
@@ -3,8 +3,11 @@
33
44 #include "ttyrec.h"
55
6-int read_header (FILE *fp, Header *h);
7-int write_header (FILE *fp, Header *h);
8-FILE* efopen (const char *path, const char *mode);
6+int read_header (FILE *fp, Header *h);
7+int write_header (FILE *fp, Header *h);
8+FILE* efopen (const char *path, const char *mode);
9+int edup (int oldfd);
10+int edup2 (int oldfd, int newfd);
11+FILE* efdopen (int fd, const char *mode);
912
1013 #endif
--- a/ttyplay.c
+++ b/ttyplay.c
@@ -221,6 +221,19 @@ usage (void)
221221 exit(EXIT_FAILURE);
222222 }
223223
224+/*
225+ * We do some tricks so that select(2) properly works on
226+ * STDIN_FILENO in ttywait().
227+ */
228+FILE *
229+input_from_stdin (void)
230+{
231+ FILE *fp;
232+ int fd = edup(STDIN_FILENO);
233+ edup2(STDOUT_FILENO, STDIN_FILENO);
234+ return efdopen(fd, "r");
235+}
236+
224237 int
225238 main (int argc, char **argv)
226239 {
@@ -228,7 +241,7 @@ main (int argc, char **argv)
228241 ReadFunc read_func = ttyread;
229242 WaitFunc wait_func = ttywait;
230243 ProcessFunc process = ttyplayback;
231- FILE *input = stdin;
244+ FILE *input = NULL;
232245 struct termios old, new;
233246
234247 set_progname(argv[0]);
@@ -258,7 +271,10 @@ main (int argc, char **argv)
258271
259272 if (optind < argc) {
260273 input = efopen(argv[optind], "r");
274+ } else {
275+ input = input_from_stdin();
261276 }
277+ assert(input != NULL);
262278
263279 tcgetattr(0, &old); /* Get current terminal state */
264280 new = old; /* Make a copy */
--- a/ttyrec.c
+++ b/ttyrec.c
@@ -400,6 +400,12 @@ getmaster()
400400 fail();
401401 }
402402 #else
403+#ifdef HAVE_getpt
404+ if ((master = getpt()) < 0) {
405+ perror("getpt()");
406+ fail();
407+ }
408+#else
403409 char *pty, *bank, *cp;
404410 struct stat stb;
405411
@@ -432,6 +438,7 @@ getmaster()
432438 }
433439 fprintf(stderr, _("Out of pty's\n"));
434440 fail();
441+#endif /* not HAVE_getpt */
435442 #endif /* not HAVE_openpty */
436443 #endif /* !SVR4 */
437444 }