shmpatch-screen_c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. $OpenBSD: shmpatch-screen_c,v 1.1 2003/11/22 00:56:58 espie Exp $
  2. --- screen.c.orig 2003-09-08 16:26:41.000000000 +0200
  3. +++ screen.c 2003-11-17 23:37:54.000000000 +0100
  4. @@ -71,6 +71,14 @@
  5. #if (defined(AUX) || defined(_AUX_SOURCE)) && defined(POSIX)
  6. # include <compat.h>
  7. #endif
  8. +
  9. +#ifdef IPC_EXPORT_IMAGE
  10. +# include <sys/ipc.h>
  11. +# include <sys/shm.h>
  12. +#endif
  13. +
  14. +
  15. +
  16. #if defined(USE_LOCALE) || defined(ENCODINGS)
  17. # include <locale.h>
  18. #endif
  19. @@ -78,6 +86,11 @@
  20. # include <langinfo.h>
  21. #endif
  22. +#ifdef IPC_EXPORT_IMAGE
  23. +# include <sys/ipc.h>
  24. +# include <sys/shm.h>
  25. +#endif
  26. +
  27. #include "screen.h"
  28. #ifdef HAVE_BRAILLE
  29. # include "braille.h"
  30. @@ -234,6 +247,12 @@ struct win *console_window;
  31. +
  32. +#ifdef IPC_EXPORT_IMAGE
  33. +char *shm; /* pointer to shared memory segment */
  34. +#endif
  35. +
  36. +
  37. /*
  38. * Do this last
  39. */
  40. @@ -461,6 +480,37 @@ char **av;
  41. zmodem_recvcmd = SaveStr("!!! rz -vv -b -E");
  42. #endif
  43. +#ifdef IPC_EXPORT_IMAGE
  44. + {
  45. + key_t key = 0xBACD072F; /* random static IPC key */
  46. + int shmid;
  47. +
  48. + /* Allocation of shared mem for 18000 bytes (screen text and attributes
  49. + * + few coord.). We supose no screen will be wider than 132x66.
  50. + * 0x1C0 = [rwx------].
  51. + */
  52. + shmid = shmget( key, 18000, IPC_CREAT | 0x1C0 );
  53. + if( shmid < 0 )
  54. + {
  55. + Panic( errno, "shmget" );
  56. + /* NOTRECHED */
  57. + }
  58. + shm = shmat( shmid, 0, 0);
  59. + if ( shm == (void*)-1 )
  60. + {
  61. + Panic( errno, "shmat" );
  62. + /* NOTRECHED */
  63. + }
  64. + /* minimal initialisation just to have valid data */
  65. + shm[0] = 80; /* scrdim x */
  66. + shm[1] = 1; /* scrdim y */
  67. + shm[2] = 0; /* csrpos x */
  68. + shm[3] = 0; /* csrpos y */
  69. + strcpy( shm+4, "screen is initializing..." );
  70. + memset( shm+4+strlen(shm+4), ' ', 80);
  71. + }
  72. +#endif
  73. +
  74. #ifdef COPY_PASTE
  75. CompileKeys((char *)0, 0, mark_key_tab);
  76. #endif