nanogui: Making mterm work on Cygwin


Previous by date: 4 Jun 2005 12:45:30 +0100 Nano-X version 0.91 released, Greg Haerr
Next by date: 4 Jun 2005 12:45:30 +0100 Re: Making mterm work on Cygwin, Alex Holden
Previous in thread:
Next in thread: 4 Jun 2005 12:45:30 +0100 Re: Making mterm work on Cygwin, Alex Holden

Subject: Making mterm work on Cygwin
From: David Cullen ####@####.####
Date: 4 Jun 2005 12:45:30 +0100
Message-Id: <42A19453.4080504@intergate.com>

Dear Greg Haerr,

I got the mterm working on Cygwin.  Colors come through mangled, but 
that is something to work on later, I suppose.  Here is the patch:

--- 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 11:28:11 -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 11:28:12 -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
@@ -101,11 +104,12 @@
 LRESULT CALLBACK
 WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
 {
+   stati
     unsigned char    ch;
     HDC        hdc;
     RECT        rc;
     PAINTSTRUCT    ps;
-  
+
     switch(msg) {
     case WM_CREATE:
         ttyfd = CreatePtyShell();
@@ -150,7 +154,7 @@
     return 0;
 }
 
-int WINAPI
+int WINAPI
 WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
     int nShowCmd)
 {
@@ -238,9 +242,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 +276,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 +326,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 +359,7 @@
         exit(1);
     }
     return tfd;
+#endif
 }
 
 int

--- Cut here ---

Thank you,
David Cullen

Previous by date: 4 Jun 2005 12:45:30 +0100 Nano-X version 0.91 released, Greg Haerr
Next by date: 4 Jun 2005 12:45:30 +0100 Re: Making mterm work on Cygwin, Alex Holden
Previous in thread:
Next in thread: 4 Jun 2005 12:45:30 +0100 Re: Making mterm work on Cygwin, Alex Holden


Powered by ezmlm-browse 0.20.