--- configure.in.orig	2003-06-03 07:58:24.000000000 -0400
+++ configure.in	2006-07-24 01:21:24.000000000 -0400
@@ -1193,17 +1193,17 @@
   exit(0); /* libc version works properly.  */
 }], AC_DEFINE(USEMEMCPY))
 
-AC_MSG_CHECKING(long file names)
-(echo 1 > /tmp/conftest9012345) 2>/dev/null
-(echo 2 > /tmp/conftest9012346) 2>/dev/null
-val=`cat /tmp/conftest9012345 2>/dev/null`
-if test -f /tmp/conftest9012345 && test "$val" = 1; then
-AC_MSG_RESULT(yes)
-else
-AC_MSG_RESULT(no)
-AC_DEFINE(NAME_MAX, 14)
-fi
-rm -f /tmp/conftest*
+#AC_MSG_CHECKING(long file names)
+#(echo 1 > /tmp/conftest9012345) 2>/dev/null
+#(echo 2 > /tmp/conftest9012346) 2>/dev/null
+#val=`cat /tmp/conftest9012345 2>/dev/null`
+#if test -f /tmp/conftest9012345 && test "$val" = 1; then
+#AC_MSG_RESULT(yes)
+#else
+#AC_MSG_RESULT(no)
+#AC_DEFINE(NAME_MAX, 14)
+#fi
+#rm -f /tmp/conftest*
 
 AC_MSG_CHECKING(for vsprintf)
 AC_TRY_LINK(,[vsprintf(0,0,0);], AC_MSG_RESULT(yes);AC_DEFINE(USEVARARGS), AC_MSG_RESULT(no))
--- Makefile.in.orig	2003-12-05 08:59:39.000000000 -0500
+++ Makefile.in	2006-07-24 01:22:51.000000000 -0400
@@ -46,7 +46,12 @@
 # -DDUMPSHADOW
 #	With shadow-pw screen would never dump core. Use this option if
 #	you still want to have a core. Use only for debugging.
-OPTIONS=
+# -DIPC_EXPORT_IMAGE
+#	Allows an other program to get the screen content through shared mem 
+#	 and ipc. This is used e.g. for braille and speech software.
+
+OPTIONS=-DIPC_EXPORT_IMAGE
+#OPTIONS=
 #OPTIONS= -DDEBUG
 
 SHELL=/bin/sh
--- extern.h.orig	2003-08-22 08:27:57.000000000 -0400
+++ extern.h	2006-08-09 11:35:42.000000000 -0400
@@ -139,6 +139,15 @@
 extern void  FreePseudowin __P((struct win *));
 #endif
 extern void  nwin_compose __P((struct NewWindow *, struct NewWindow *, struct NewWindow *));
+
+#ifdef IPC_EXPORT_IMAGE
+extern void SetWinImage __P((const char *, unsigned char *));
+extern void CopyWinImage __P((struct win *, unsigned char *));
+extern int IsInputLayer __P((struct layer *));
+extern int GetInputPosition __P((struct layer *));
+extern void CopyInputLine __P((struct layer *, char *, int));
+#endif /* IPC_EXPORT_IMAGE */
+
 extern int   DoStartLog __P((struct win *, char *, int));
 extern int   ReleaseAutoWritelock __P((struct display *, struct win *));
 extern int   ObtainAutoWritelock __P((struct display *, struct win *));
--- screen.h.orig	2003-08-22 08:28:43.000000000 -0400
+++ screen.h	2006-07-24 02:04:06.000000000 -0400
@@ -288,6 +288,10 @@
   int sym;	/* symbol defined in ttydev.h */
 };
 
+#ifdef IPC_EXPORT_IMAGE
+extern unsigned char *shm;		  /* pointer to shared memory segment */
+#endif
+
 /*
  * windowlist orders
  */
--- screen.c.orig	2003-09-08 10:26:41.000000000 -0400
+++ screen.c	2006-07-25 10:55:24.000000000 -0400
@@ -71,6 +71,14 @@
 #if (defined(AUX) || defined(_AUX_SOURCE)) && defined(POSIX)
 # include <compat.h>
 #endif
+
+#ifdef IPC_EXPORT_IMAGE
+# include <sys/ipc.h>
+# include <sys/shm.h>
+#endif
+
+
+
 #if defined(USE_LOCALE) || defined(ENCODINGS)
 # include <locale.h>
 #endif
@@ -78,6 +86,11 @@
 # include <langinfo.h>
 #endif
 
+#ifdef IPC_EXPORT_IMAGE
+# include <sys/ipc.h>
+# include <sys/shm.h>
+#endif
+
 #include "screen.h"
 #ifdef HAVE_BRAILLE
 # include "braille.h"
@@ -234,6 +247,12 @@
 
 
 
+
+#ifdef IPC_EXPORT_IMAGE
+unsigned char *shm;              /* pointer to shared memory segment */
+#endif
+
+
 /*
  * Do this last
  */
@@ -461,6 +480,40 @@
   zmodem_recvcmd = SaveStr("!!! rz -vv -b -E");
 #endif
 
+#ifdef IPC_EXPORT_IMAGE
+  {
+    const char *path;
+    key_t key;
+    int shmid;
+
+    /* allow for the header, text, attributes, and auxiliary data
+     * (assuming no screen will be bigger than 132x66)
+     */
+    size_t size = 18000; /*  */
+
+    path = getenv("HOME");
+    if (!path || !*path) path = "/";
+    if ((key = ftok(path, 'b')) == -1) key = 0XBACD072F;
+
+    shmid = shmget( key, size, IPC_CREAT | S_IRWXU );
+    if( shmid < 0 )
+      {
+        Panic( errno, "shmget" );
+        /* NOTREACHED */
+      }
+
+    shm = shmat( shmid, 0, 0);
+    if ( shm == (void*)-1 )
+      {
+        Panic( errno, "shmat" );
+        /* NOTREACHED */
+      }
+
+    /* put valid data into the image */
+    SetWinImage( "screen is initializing...", shm );
+  }
+#endif
+
 #ifdef COPY_PASTE
   CompileKeys((char *)0, 0, mark_key_tab);
 #endif
--- sched.c.orig	2003-09-08 10:26:36.000000000 -0400
+++ sched.c	2006-07-24 01:33:39.000000000 -0400
@@ -110,6 +110,10 @@
   return min;
 }
 
+#ifdef IPC_EXPORT_IMAGE
+ extern struct win *windows;
+#endif
+
 void
 sched()
 {
@@ -121,6 +125,11 @@
 
   for (;;)
     {
+#ifdef IPC_EXPORT_IMAGE
+      /* export image from last used window which is on top of the list */
+      CopyWinImage( windows, shm );
+#endif
+
       if (calctimeout)
 	timeoutev = calctimo();
       if (timeoutev)
--- input.c.orig	2006-08-09 10:40:10.000000000 -0400
+++ input.c	2006-08-09 11:42:39.000000000 -0400
@@ -400,3 +400,49 @@
   return 0;
 }
 
+#ifdef IPC_EXPORT_IMAGE
+int
+IsInputLayer(l)
+struct layer *l;
+{
+  return l->l_layfn == &InpLf;
+}
+
+int
+GetInputPosition(l)
+struct layer *l;
+{
+  struct inpdata *inpdata = (struct inpdata *)l->l_data;
+  return inpdata->inpstringlen + inpdata->inp.pos;
+}
+
+void
+CopyInputLine(l, dest, width)
+struct layer *l;
+char *dest;
+int width;
+{
+  struct inpdata *inpdata = (struct inpdata *)l->l_data;
+  char *src;
+  int len;
+
+  for
+  ( 
+    src = inpdata->inpstring, len = inpdata->inpstringlen;
+    width && len;
+    *dest++ = *src++, len--, width--
+  );
+
+  if( !(inpdata->inpmode & INP_NOECHO) )
+    {
+      for
+      ( 
+        src = inpdata->inp.buf, len = inpdata->inp.len;
+        width && len;
+        *dest++ = *src++, len--, width--
+      );
+    }
+
+  while( width ) *dest++ = ' ', width--;
+}
+#endif	/* IPC_EXPORT_IMAGE */
--- window.c.orig	2003-12-05 08:45:41.000000000 -0500
+++ window.c	2006-08-09 11:34:20.000000000 -0400
@@ -1993,6 +1993,138 @@
     }
 }
 
+
+#ifdef IPC_EXPORT_IMAGE
+
+void
+SetWinImage( msg, dest )
+const char *msg;
+unsigned char *dest;
+{
+  unsigned char *d = dest;
+
+  *d++ = 80;   /* screen width */
+  *d++ = 1;    /* screen height */
+  *d++ = 0;    /* cursor column */
+  *d++ = 0;    /* cursor row */
+
+  {
+    size_t count = dest[0] * dest[1];
+
+    memset( d, ' ', count );
+    strcpy( d, msg );
+    d[strlen(d)] = ' ';
+    d += count;
+
+    memset( d, 0X07, count );
+    d += count;
+  }
+
+  *d++ = 0;    /* window number */
+  *d++ = 0;    /* flags */
+}
+
+
+void
+CopyWinImage( p, dest )
+struct win *p;
+unsigned char *dest;
+{
+  register unsigned char *s, *d = dest, *m;
+  register int x, y;
+  struct display *display = p->w_lastdisp;
+  int st = (display && D_status) ? 1 : 0;
+  int in = IsInputLayer(p->w_savelayer) ? 1 : 0;
+
+  if( p && p->w_mlines )
+    {
+      *d++ = p->w_width;                        /* screen width */
+      *d++ = p->w_height + (st | in);                  /* screen height */
+      *d++ = st? D_status_len:                  /* cursor column */
+             in? GetInputPosition(p->w_savelayer):
+                 p->w_x;
+      *d++ = (st || in)? p->w_height: p->w_y;       /* cursor row */
+
+      /* copy window image to buffer */
+      for( y = 0; y < p->w_height; y++ )
+        {
+          s = p->w_mlines[y].image;
+          x = p->w_width;
+          for( ; x; *d++ = *s++, x-- );
+        }
+
+      /* copy status line to buffer */
+      if( st )
+        {
+          s = D_status_lastmsg;
+          x = p->w_width;
+          for( ; *s && x; *d++ = *s++, x-- );
+          for( ; x; *d++ = ' ', x-- );
+        }
+      else if (in)
+        {
+          CopyInputLine(p->w_savelayer, d, p->w_width);
+          d += p->w_width;
+        }
+
+      /* copy attributes from window image to buffer */
+#ifdef COLOR
+      for( y = 0; y < p->w_height; y++ )
+        {
+          struct mline *ml = &p->w_mlines[y];
+          x = 0;
+          for( ; x<p->w_width; x++ )
+            {
+              static const unsigned char tr[] =
+                {
+                  0X0, 0X4, 0X2, 0X6, 0X1, 0X5, 0X3, 0X7,
+                  0X8, 0XC, 0XA, 0XE, 0X9, 0XD, 0XB, 0XF
+                };
+
+              struct mchar mc;
+              int fg;
+              int bg;
+
+              copy_mline2mchar( &mc, ml, x );
+              fg = rend_getfg(&mc);
+              bg = rend_getbg(&mc);
+
+              fg = fg? tr[coli2e(fg) & 0XF]: 0X7;
+              bg = bg? tr[coli2e(bg) & 0XF]: 0X0;
+              *d++ = fg | (bg << 4);
+            }
+        }
+
+      if( st || in )
+        {
+          memset(d, (st ? 0X70 : 0X07), p->w_width);
+          d += p->w_width;
+        }
+#else /* COLOR */
+      {
+        int count = dest[0] * dest[1];
+        memset(d, 0X07, count);
+        d += count;
+      }
+#endif /* COLOR */
+
+      *d++ = p->w_number;  /* window number */
+
+      *d = 0;  /* flags */
+      if (p->w_cursorkeys) *d |= 0X01; /* cursor keys are in application mode */
+      if (p->w_keypad) *d |= 0X02; /* keypad is in application mode */
+      d++;
+    }
+  else
+    {
+      /* no window pointer */
+      SetWinImage( "no active scren", dest );
+    }
+}
+
+#endif	/* IPC_EXPORT_IMAGE */
+ 
+
 #ifdef ZMODEM
 
 static int
