nanogui: Making mterm work on Cygwin


Previous by date: 4 Jun 2005 22:14:13 +0100 Re: Making mterm work on Cygwin, Alain Volmat
Next by date: 4 Jun 2005 22:14:13 +0100 Re: Pending patches/bug/requests ... list available on the FTP, skoe.nexgo.de
Previous in thread: 4 Jun 2005 22:14:13 +0100 Re: Making mterm work on Cygwin, Alain Volmat
Next in thread:

Subject: Re: [nanogui] Making mterm work on Cygwin
From: David Cullen ####@####.####
Date: 4 Jun 2005 22:14:13 +0100
Message-Id: <42A2199C.1090501@intergate.com>

Dear Alan,

Sorry for the mixup. I have no good excuse.

Here's a correct patch.  Remember, this patch modifies config because I 
copied config.cygwin to config.  config.original should be copied back 
to config for the normal installation.

This patch is really meant as an opportunity to show how to make the 
terminal work on Cygwin.

--- Cut here ---

? microwin/src/config.original
? microwin/src/obj
? microwin/src/bin/digits.cl
? microwin/src/bin/ftdemo.txt
? microwin/src/bin/landmine.ppm
? microwin/src/bin/launcher.cnf
? microwin/src/bin/letters.cl
? microwin/src/bin/logo.ppm
? microwin/src/bin/mwlogo.ppm
? microwin/src/bin/nanocal.ppm
? microwin/src/bin/nbreaker.ppm
? microwin/src/bin/ntetris.ppm
? microwin/src/bin/nxclock.pgm
? microwin/src/bin/nxeyes.pgm
? microwin/src/bin/nxkbd.pgm
? microwin/src/bin/nxroach.pgm
? microwin/src/bin/nxscribble.ppm
? microwin/src/bin/nxterm.ppm
? microwin/src/bin/punc.cl
? microwin/src/bin/slidebmp.bmp
? microwin/src/bin/slider.ppm
? microwin/src/bin/test.cnf
? microwin/src/bin/tux.gif
? microwin/src/bin/tux.ppm
? microwin/src/bin/uponface.ppm
? microwin/src/bin/world.map
? microwin/src/bin/world.ppm
Index: microwin/src/config
===================================================================
RCS file: /usr/cvs/microwin/src/config,v
retrieving revision 1.32
diff -u -r1.32 config
--- microwin/src/config	16 Nov 2003 22:34:12 -0000	1.32
+++ microwin/src/config	4 Jun 2005 21:03:29 -0000
@@ -33,13 +33,13 @@
  # RTEMS
  # DJGPP
  # ELKS
+# CYGWIN
  #
  # note: ELKS can't build client/server nano-X, nor widget lib
  #
  ####################################################################
-ARCH                     = LINUX-NATIVE
+ARCH                     = CYGWIN
  BIGENDIAN                = N
-NATIVETOOLSPREFIX        =
  ARMTOOLSPREFIX           = arm-linux-
  MIPSTOOLSPREFIX          = mipsel-linux-
  POWERPCTOOLSPREFIX       = powerpc-linux-
@@ -52,9 +52,9 @@
  #
  ####################################################################
  OPTIMIZE                 = Y
-DEBUG                    = N
+DEBUG                    = Y
  VERBOSE                  = N
-THREADSAFE               = Y
+THREADSAFE               = N
  GPROF                    = N

  ####################################################################
@@ -64,7 +64,7 @@
  ####################################################################
  MICROWIN                 = Y
  NANOX                    = Y
-SHAREDLIBS               = Y
+SHAREDLIBS               = N
  OBJFRAMEWORK             = N


@@ -135,29 +135,22 @@
  # JPEG support through libjpeg, see README.txt in contrib/jpeg
  ####################################################################
  HAVE_JPEG_SUPPORT        = Y
-INCJPEG                  = .
-LIBJPEG                  = /usr/lib/libjpeg.so
+INCJPEG                  =
+LIBJPEG                  = /usr/lib/libjpeg.a

  ####################################################################
  # PNG support via libpng and libz
  ####################################################################
-HAVE_PNG_SUPPORT         = N
-INCPNG                   = .
+HAVE_PNG_SUPPORT         = Y
+INCPNG                   =
  LIBPNG                   = /usr/lib/libpng.a
  LIBZ                     = /usr/lib/libz.a

  ####################################################################
-# TIFF support through libtiff
-####################################################################
-HAVE_TIFF_SUPPORT        = N
-INCTIFF                  = .
-LIBTIFF                  = /usr/lib/libtiff.a
-
-####################################################################
  # native .fnt loadable font support
  ####################################################################
  HAVE_FNT_SUPPORT         = Y
-HAVE_FNTGZ_SUPPORT       = Y
+HAVE_FNTGZ_SUPPORT       = N
  FNT_FONT_DIR             = "fonts/bdf"

  ####################################################################
@@ -165,13 +158,13 @@
  ####################################################################
  HAVE_T1LIB_SUPPORT       = N
  INCT1LIB                 = /usr/include
-LIBT1LIB                 = /usr/local/lib/libt1.a
+LIBT1LIB                 = /usr/lib/libt1.a

  ####################################################################
  # TrueType font support thru FreeType 1.x
  ####################################################################
-HAVE_FREETYPE_SUPPORT    = Y
-INCFTLIB                 = /usr/include/freetype1
+HAVE_FREETYPE_SUPPORT    = N
+INCFTLIB                 = /usr/include
  LIBFTLIB                 = /usr/lib/libttf.so
  FREETYPE_FONT_DIR        = "fonts/truetype"

@@ -257,7 +250,7 @@
  ifneq ($(ARCH), ELKS)

  # X Window screen, mouse and kbd drivers
-X11                      = N
+X11                      = Y

  ifeq ($(X11), Y)
  # startup screen width, height, (depth for palette mode only)
@@ -303,7 +296,6 @@
  # ZAURUSMOUSE	Sharp Zaurus (/dev/sharp_ts)
  # TUXMOUSE	TuxScreen (/dev/ucb1x00-ts)
  # ADSMOUSE	Applied Data Systems GC+ (/dev/ts)
-# ADS7846MOUSE	        ADS7846 chip, PSI OMAP Innovator 
(/dev/innnovator_ts)
  # EPMOUSE	Embedded Planet (/dev/tpanel)
  # VHMOUSE	Vtech Helio (/dev/tpanel)
  # MTMOUSE	MicroTouch serial (/dev/ttyS1)
@@ -319,14 +311,12 @@
  ZAURUSMOUSE              = N
  TUXMOUSE                 = N
  ADSMOUSE                 = N
-ADS7846MOUSE             = N
  EPMOUSE                  = N
  VHMOUSE                  = N
  MTMOUSE                  = N
  PSIONMOUSE               = N
  YOPYMOUSE                = N
  HARRIERMOUSE             = N
-LIRCMOUSE                = N

  # keyboard or null kbd driver
  TTYKBD                   = N
@@ -338,11 +328,6 @@

  endif

-# Secondary keyboard drivers.
-# You may have a normal keyboard driver in addition to these
-# drivers, e.g. for both normal keyboard and IR input.
-LIRCKBD2                 = N
-
  ####################################################################
  # Screen driver specific configuration
  # SA1100_LCD_LTLEND 4bpp driver with arm SA1100 LCD controller
Index: microwin/src/demos/mwin/mterm.c
===================================================================
RCS file: /usr/cvs/microwin/src/demos/mwin/mterm.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mterm.c
--- microwin/src/demos/mwin/mterm.c	21 Jun 2001 06:32:39 -0000	1.1.1.1
+++ microwin/src/demos/mwin/mterm.c	4 Jun 2005 21:03:30 -0000
@@ -16,6 +16,9 @@
  #include "windows.h"
  #include "wintern.h"		/* for MwRegisterFdInput*/
  #include "wintools.h"		/* Draw3dInset*/
+#if __CYGWIN__
+#include <pty.h>
+#endif

  #define COLS		80
  #define ROWS		24
@@ -105,7 +108,7 @@
  	HDC		hdc;
  	RECT		rc;
  	PAINTSTRUCT	ps;
-
+
  	switch(msg) {
  	case WM_CREATE:
  		ttyfd = CreatePtyShell();
@@ -150,7 +153,7 @@
  	return 0;
  }

-int WINAPI
+int WINAPI
  WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
  	int nShowCmd)
  {
@@ -238,9 +241,13 @@
  #if DOS_DJGPP
  #define SHELL	"bash"
  #else
+#if __CYGWIN__
+#define SHELL  "/usr/bin/bash"
+#else
  #define SHELL	"/bin/sh"
  #endif
  #endif
+#endif

  static int pid;

@@ -268,11 +275,49 @@
  int
  CreatePtyShell(void)
  {
-	int	n = 0;
+#if __CYGWIN__
+   char  pty_name[32];
+   int master;
+   int slave;
+#else
  	int	tfd;
+	int	n = 0;
  	char	pty_name[12];
+#endif
  	char *	argv[2];

+#if __CYGWIN__
+	signal(SIGCHLD, ptysignaled);
+	signal(SIGINT, ptysignaled);
+	if ((pid = forkpty(&master, pty_name, NULL, NULL)) == -1) {
+		fprintf(stderr, "No processes\n");
+		return -1;
+	}
+   fprintf(stderr, "CYGWIN: Opened pty_name %s\n", pty_name);
+	if (!pid) {
+		close(STDIN_FILENO);
+		close(STDOUT_FILENO);
+		close(STDERR_FILENO);
+      close(master);
+
+      setsid();
+      grantpt(master);
+      unlockpt(master);
+		if ((slave = open(pty_name, O_RDWR)) < 0) {
+			fprintf(stderr, "Child: Can't open pty %s\n", pty_name);
+			exit(1);
+		}
+		dup2(slave, STDIN_FILENO);
+		dup2(slave, STDOUT_FILENO);
+		dup2(slave, STDERR_FILENO);
+		/*if(!(argv[0] = getenv("SHELL")))*/
+		argv[0] = SHELL;
+		argv[1] = NULL;
+		execv(argv[0], argv);
+		exit(1);
+	}
+	return master;
+#else
  again:
  	sprintf(pty_name, "/dev/ptyp%d", n);
  	if ((tfd = open(pty_name, O_RDWR | O_NONBLOCK)) < 0) {
@@ -280,8 +325,10 @@
  			++n;
  			goto again;
  		}
-		fprintf(stderr, "Can't create pty %s\n", pty_name);
-		return -1;
+      else {
+         fprintf(stderr, "Can't create pty %s\n", pty_name);
+         return -1;
+      }
  	}
  	signal(SIGCHLD, ptysignaled);
  	signal(SIGINT, ptysignaled);
@@ -311,6 +358,7 @@
  		exit(1);
  	}
  	return tfd;
+#endif
  }

  int


--- Cut here ---

Alain Volmat wrote:
> Hi David,
> 
> can you send again a proper patch so that I'll upload it into the
> ftp server (patch_092 directory) for public review.
> 
> Alain
> 
> * Alex Holden [Sat,  4 Jun 2005 at 14:14 +0100]
> <quote>
> 

Previous by date: 4 Jun 2005 22:14:13 +0100 Re: Making mterm work on Cygwin, Alain Volmat
Next by date: 4 Jun 2005 22:14:13 +0100 Re: Pending patches/bug/requests ... list available on the FTP, skoe.nexgo.de
Previous in thread: 4 Jun 2005 22:14:13 +0100 Re: Making mterm work on Cygwin, Alain Volmat
Next in thread:


Powered by ezmlm-browse 0.20.