From e724bd1f8221c9f9e1bb80807cbabc9ba1cced2f Mon Sep 17 00:00:00 2001 From: espie Date: Sat, 22 Nov 2003 00:56:58 +0000 Subject: [PATCH] Add shm flavor, to use with brltty ok brad@ --- misc/screen/Makefile | 7 +- misc/screen/patches/shmpatch-Makefile_in | 17 +++++ misc/screen/patches/shmpatch-configure_in | 32 +++++++++ misc/screen/patches/shmpatch-extern_h | 15 +++++ misc/screen/patches/shmpatch-sched_c | 26 ++++++++ misc/screen/patches/shmpatch-screen_c | 81 +++++++++++++++++++++++ misc/screen/patches/shmpatch-screen_h | 14 ++++ misc/screen/patches/shmpatch-window_c | 63 ++++++++++++++++++ misc/screen/pkg/DESCR | 1 + 9 files changed, 254 insertions(+), 2 deletions(-) create mode 100644 misc/screen/patches/shmpatch-Makefile_in create mode 100644 misc/screen/patches/shmpatch-configure_in create mode 100644 misc/screen/patches/shmpatch-extern_h create mode 100644 misc/screen/patches/shmpatch-sched_c create mode 100644 misc/screen/patches/shmpatch-screen_c create mode 100644 misc/screen/patches/shmpatch-screen_h create mode 100644 misc/screen/patches/shmpatch-window_c diff --git a/misc/screen/Makefile b/misc/screen/Makefile index d08ec6bdf87..b554c5c44aa 100644 --- a/misc/screen/Makefile +++ b/misc/screen/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.49 2003/10/19 03:59:27 brad Exp $ +# $OpenBSD: Makefile,v 1.50 2003/11/22 00:56:58 espie Exp $ COMMENT= "multi-screen window manager" @@ -23,12 +23,15 @@ SUBST_VARS= VERSION CONFIGURE_STYLE= gnu CONFIGURE_ARGS= --with-sys-screenrc="${SYSCONFDIR}/screenrc" -FLAVORS= static +FLAVORS= static shm FLAVOR?= .if ${FLAVOR:L} == "static" CONFIGURE_ENV= LDFLAGS="-static" .endif +.if ${FLAVOR:L} == "shm" +PATCH_LIST= patch-* shmpatch-* +.endif ALL_TARGET= screen screen.info diff --git a/misc/screen/patches/shmpatch-Makefile_in b/misc/screen/patches/shmpatch-Makefile_in new file mode 100644 index 00000000000..577893cfd4b --- /dev/null +++ b/misc/screen/patches/shmpatch-Makefile_in @@ -0,0 +1,17 @@ +$OpenBSD: shmpatch-Makefile_in,v 1.1 2003/11/22 00:56:58 espie Exp $ +--- Makefile.in.orig 2003-09-18 18:13:02.000000000 +0200 ++++ Makefile.in 2003-11-17 23:37:54.000000000 +0100 +@@ -46,7 +46,12 @@ AWK = @AWK@ + # -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 contetn 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 diff --git a/misc/screen/patches/shmpatch-configure_in b/misc/screen/patches/shmpatch-configure_in new file mode 100644 index 00000000000..1a7acd77630 --- /dev/null +++ b/misc/screen/patches/shmpatch-configure_in @@ -0,0 +1,32 @@ +$OpenBSD: shmpatch-configure_in,v 1.1 2003/11/22 00:56:58 espie Exp $ +--- configure.in.orig 2003-06-03 13:58:24.000000000 +0200 ++++ configure.in 2003-11-17 23:37:54.000000000 +0100 +@@ -1193,17 +1193,17 @@ main() { + 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)) diff --git a/misc/screen/patches/shmpatch-extern_h b/misc/screen/patches/shmpatch-extern_h new file mode 100644 index 00000000000..6119c88b077 --- /dev/null +++ b/misc/screen/patches/shmpatch-extern_h @@ -0,0 +1,15 @@ +$OpenBSD: shmpatch-extern_h,v 1.1 2003/11/22 00:56:58 espie Exp $ +--- extern.h.orig 2003-08-22 14:27:57.000000000 +0200 ++++ extern.h 2003-11-17 23:37:54.000000000 +0100 +@@ -139,6 +139,11 @@ extern int winexec __P((char **)); + extern void FreePseudowin __P((struct win *)); + #endif + extern void nwin_compose __P((struct NewWindow *, struct NewWindow *, struct NewWindow *)); ++ ++#ifdef IPC_EXPORT_IMAGE ++extern void CopyWinImage __P((struct win *, char *)); ++#endif ++ + extern int DoStartLog __P((struct win *, char *, int)); + extern int ReleaseAutoWritelock __P((struct display *, struct win *)); + extern int ObtainAutoWritelock __P((struct display *, struct win *)); diff --git a/misc/screen/patches/shmpatch-sched_c b/misc/screen/patches/shmpatch-sched_c new file mode 100644 index 00000000000..b6178240d00 --- /dev/null +++ b/misc/screen/patches/shmpatch-sched_c @@ -0,0 +1,26 @@ +$OpenBSD: shmpatch-sched_c,v 1.1 2003/11/22 00:56:58 espie Exp $ +--- sched.c.orig 2003-09-08 16:26:36.000000000 +0200 ++++ sched.c 2003-11-17 23:37:54.000000000 +0100 +@@ -110,6 +110,10 @@ calctimo() + return min; + } + ++#ifdef IPC_EXPORT_IMAGE ++ extern struct window *windows; ++#endif ++ + void + sched() + { +@@ -121,6 +125,11 @@ sched() + + 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) diff --git a/misc/screen/patches/shmpatch-screen_c b/misc/screen/patches/shmpatch-screen_c new file mode 100644 index 00000000000..d32e8231305 --- /dev/null +++ b/misc/screen/patches/shmpatch-screen_c @@ -0,0 +1,81 @@ +$OpenBSD: shmpatch-screen_c,v 1.1 2003/11/22 00:56:58 espie Exp $ +--- screen.c.orig 2003-09-08 16:26:41.000000000 +0200 ++++ screen.c 2003-11-17 23:37:54.000000000 +0100 +@@ -71,6 +71,14 @@ + #if (defined(AUX) || defined(_AUX_SOURCE)) && defined(POSIX) + # include + #endif ++ ++#ifdef IPC_EXPORT_IMAGE ++# include ++# include ++#endif ++ ++ ++ + #if defined(USE_LOCALE) || defined(ENCODINGS) + # include + #endif +@@ -78,6 +86,11 @@ + # include + #endif + ++#ifdef IPC_EXPORT_IMAGE ++# include ++# include ++#endif ++ + #include "screen.h" + #ifdef HAVE_BRAILLE + # include "braille.h" +@@ -234,6 +247,12 @@ struct win *console_window; + + + ++ ++#ifdef IPC_EXPORT_IMAGE ++char *shm; /* pointer to shared memory segment */ ++#endif ++ ++ + /* + * Do this last + */ +@@ -461,6 +480,37 @@ char **av; + zmodem_recvcmd = SaveStr("!!! rz -vv -b -E"); + #endif + ++#ifdef IPC_EXPORT_IMAGE ++ { ++ key_t key = 0xBACD072F; /* random static IPC key */ ++ int shmid; ++ ++ /* Allocation of shared mem for 18000 bytes (screen text and attributes ++ * + few coord.). We supose no screen will be wider than 132x66. ++ * 0x1C0 = [rwx------]. ++ */ ++ shmid = shmget( key, 18000, IPC_CREAT | 0x1C0 ); ++ if( shmid < 0 ) ++ { ++ Panic( errno, "shmget" ); ++ /* NOTRECHED */ ++ } ++ shm = shmat( shmid, 0, 0); ++ if ( shm == (void*)-1 ) ++ { ++ Panic( errno, "shmat" ); ++ /* NOTRECHED */ ++ } ++ /* minimal initialisation just to have valid data */ ++ shm[0] = 80; /* scrdim x */ ++ shm[1] = 1; /* scrdim y */ ++ shm[2] = 0; /* csrpos x */ ++ shm[3] = 0; /* csrpos y */ ++ strcpy( shm+4, "screen is initializing..." ); ++ memset( shm+4+strlen(shm+4), ' ', 80); ++ } ++#endif ++ + #ifdef COPY_PASTE + CompileKeys((char *)0, 0, mark_key_tab); + #endif diff --git a/misc/screen/patches/shmpatch-screen_h b/misc/screen/patches/shmpatch-screen_h new file mode 100644 index 00000000000..00dfaca0080 --- /dev/null +++ b/misc/screen/patches/shmpatch-screen_h @@ -0,0 +1,14 @@ +$OpenBSD: shmpatch-screen_h,v 1.1 2003/11/22 00:56:58 espie Exp $ +--- screen.h.orig 2003-08-22 14:28:43.000000000 +0200 ++++ screen.h 2003-11-17 23:37:54.000000000 +0100 +@@ -288,6 +288,10 @@ struct baud_values + int sym; /* symbol defined in ttydev.h */ + }; + ++#ifdef IPC_EXPORT_IMAGE ++char *shm; /* pointer to shared memory segment */ ++#endif ++ + /* + * windowlist orders + */ diff --git a/misc/screen/patches/shmpatch-window_c b/misc/screen/patches/shmpatch-window_c new file mode 100644 index 00000000000..8db8b2cb231 --- /dev/null +++ b/misc/screen/patches/shmpatch-window_c @@ -0,0 +1,63 @@ +$OpenBSD: shmpatch-window_c,v 1.1 2003/11/22 00:56:58 espie Exp $ +--- window.c.orig 2003-09-08 16:27:21.000000000 +0200 ++++ window.c 2003-11-17 23:37:54.000000000 +0100 +@@ -1993,6 +1993,59 @@ char *data; + } + } + ++ ++#ifdef IPC_EXPORT_IMAGE ++ ++void ++CopyWinImage( p, dest ) ++struct win *p; ++char *dest; ++{ ++ register char *s, *d = dest, *m; ++ register int x, y; ++ struct display *display = p->w_pdisplay; ++ int st = (display) ? D_status : 0; ++ ++ if( p && p->w_mlines ) ++ { ++ *d++ = p->w_width; /* scrdim x */ ++ *d++ = p->w_height; /* scrdim y */ ++ *d++ = (st) ? D_status_len : p->w_x; /* csrpos x */ ++ *d++ = (st) ? STATLINE : p->w_y; /* csrpos y */ ++ /* copy window image to buffer */ ++ for( y = 0; y < p->w_height; y++ ) ++ { ++ s = p->w_mlines[y].image; ++ x = p->w_width; ++ if( st && y == STATLINE ) ++ for( m = D_status_lastmsg; *m && x; *d++ = *m++, s++, x-- ); ++ for( ; x; *d++ = *s++, x-- ); ++ } ++ /* copy attributes from window image to buffer */ ++ for( y = 0; y < p->w_height; y++ ) ++ { ++ s = p->w_mlines[y].attr; ++ x = p->w_width; ++ if( st && y == STATLINE ) ++ for( ; x; *d++ = 0, s++, x-- ); ++ for( ; x; *d++ = *s++, x-- ); ++ } ++ } ++ else ++ { ++ /* no window pointer */ ++ *d++ = 80; /* scrdim x */ ++ *d++ = 1; /* scrdim y */ ++ *d++ = 0; /* csrpos x */ ++ *d++ = 0; /* csrpos y */ ++ strcpy( d, "*** screen: no window pointer ***" ); ++ memset( d+strlen(d), ' ', 80); ++ } ++} ++ ++#endif /* IPC_EXPORT_IMAGE */ ++ ++ + #ifdef ZMODEM + + static int diff --git a/misc/screen/pkg/DESCR b/misc/screen/pkg/DESCR index a3b6db15c1b..7ac713493a2 100644 --- a/misc/screen/pkg/DESCR +++ b/misc/screen/pkg/DESCR @@ -9,3 +9,4 @@ regions between windows. Flavors: static - Build with statically linked binaries. + shm - export screen as shared memory, useful for brltty.