Group commit for recovery after disk crash.
See Changelog for changes WRT release 990110.
diff --git a/misc/port.c b/misc/port.c
index 657450e..aba2d0a 100644
--- a/misc/port.c
+++ b/misc/port.c
@@ -7,6 +7,12 @@
#include "config.h"
#include <sys/types.h>
#include <sys/time.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <termios.h>
+#include <libio.h>
#ifndef HAVE_USLEEP
#ifdef __EMX__
@@ -90,3 +96,49 @@
#endif /* __i386__ */
}
#endif /* !HAVE_CLONE && __linux__ */
+
+
+/**
+ * It looks like the openpty that comes with glibc in RedHat 5.0
+ * is buggy (second call returns what looks like a dup of 0 and 1
+ * instead of a new pty), this is a generic replacement.
+ */
+/** We will have an autoconf check for this soon... */
+
+int wine_openpty(int *master, int *slave, char *name,
+ struct termios *term, struct winsize *winsize)
+{
+ char *ptr1, *ptr2;
+ char pts_name[512];
+
+ strcpy (pts_name, "/dev/ptyXY");
+
+ for (ptr1 = "pqrstuvwxyzPQRST"; *ptr1 != 0; ptr1++) {
+ pts_name[8] = *ptr1;
+ for (ptr2 = "0123456789abcdef"; *ptr2 != 0; ptr2++) {
+ pts_name[9] = *ptr2;
+
+ if ((*master = open(pts_name, O_RDWR)) < 0) {
+ if (errno == ENOENT)
+ return -1;
+ else
+ continue;
+ }
+ pts_name[5] = 't';
+ if ((*slave = open(pts_name, O_RDWR)) < 0) {
+ pts_name[5] = 'p';
+ continue;
+ }
+
+ if (term != NULL)
+ tcsetattr(*slave, TCSANOW, term);
+ if (winsize != NULL)
+ ioctl(*slave, TIOCSWINSZ, winsize);
+ if (name != NULL)
+ strcpy(name, pts_name);
+ return *slave;
+ }
+ }
+ return -1;
+}
+