File: screen-4.0.1.patch

package info (click to toggle)
brltty 6.9-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 44,828 kB
  • sloc: ansic: 154,246; java: 13,514; sh: 9,934; xml: 5,672; tcl: 2,679; makefile: 2,346; awk: 713; lisp: 366; python: 321; ml: 301
file content (379 lines) | stat: -rw-r--r-- 9,265 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
--- 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