#! /bin/sh #------------------------------------------------ # This is an AIPS self-unpacking shell archive # created on Thu Aug 17 11:30:02 EDT 1995. #------------------------------------------------ # AIPS XAS TV Server for X11 #----------------------------------------------- cat > Makefile << --XYZZY-- # Makefile for xas #----------------------------------------------------------------------- #; Copyright (C) 1995, 1996 #; Associated Universities, Inc. Washington DC, USA. #; #; This program is free software; you can redistribute it and/or #; modify it under the terms of the GNU General Public License as #; published by the Free Software Foundation; either version 2 of #; the License, or (at your option) any later version. #; #; This program is distributed in the hope that it will be useful, #; but WITHOUT ANY WARRANTY; without even the implied warranty of #; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #; GNU General Public License for more details. #; #; You should have received a copy of the GNU General Public #; License along with this program; if not, write to the Free #; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, #; MA 02139, USA. #; #; Correspondence concerning AIPS should be addressed as follows: #; Internet email: aipsmail@nrao.edu. #; Postal address: AIPS Project Office #; National Radio Astronomy Observatory #; 520 Edgemont Road #; Charlottesville, VA 22903-2475 USA #----------------------------------------------------------------------- # # This makefile has been tested on the following: # baboon - Sun SparcStation 2, SunOS 4.1.2, SC2.0.1 compilers # orangutan - Sun SparcStation IPX, SunOS 5.4, SC3.0.1 compilers # rhesus - IBM RS/6000 model 580 (AIX 3.2.5) # bonobo - Decstation 3100, Ultrix 4.3 # pongo - Dec Alpha AXP 3000/300, OSF-1/1.2 # siamang - Dec Alpha 266, OSF-1 T3.2 # langer - HP 9000/755, HP-UX A.09.01 (X11R5) # jansky - SGI, SG-Irix 5.x # tarsier - Gateway 2000 Pentium/90 PC, Linux-Elf 1.3.3 # exogyra - Gateway 2000 486DX2/66 PC, Linux 1.2.8 # # (old note for VMS, xas.h must be modified to define VMS as 1) # Destination for executable. If you are building XAS on a system # that has AIPS installed this should be the same as the AIPS LOAD # area. MAKE SURE "LOAD" IS DEFINED FIRST!!!!! INSTEP1 should take # care of this, but otherwise it is done with "source LOGIN.CSH" # (c-shell) or ". LOGIN.SH" (bash, korn, bourne shells). # Most implementations of make allow the use of an environmental # variable as shown here: check your system documentation. DESTDIR = $(LOAD) # Additional include files. Some X Window System implementations do # not place their include in the standard Unix directory /usr/include. # The include directories should be listed here, each preceded by -I. # For Sun, make sure OPENWINHOME is set! (/usr/openwin usually) INCDIRS_ALPHA = INCDIRS_DEC = INCDIRS_IBM = INCDIRS_LINUX = INCDIRS_HP = -I/usr/include/X11R5 INCDIRS_SGI = INCDIRS_SOL = -I$(OPENWINHOME)/include INCDIRS_SUN4 = -I$(OPENWINHOME)/include INCDIRS = $(INCDIRS_$(ARCH)) # Library search path. Standard Unix libraries are usually found in # /usr/lib; some X Window System implementations place their libraries # elsewhere. These should be listed here, each preceded by -L. # IBM-SHR is for IBM systems shared memory. LIBDIRS_ALPHA = -L/usr/lib/X11 LIBDIRS_DEC = -L/usr/lib/X11 LIBDIRS_HP = -L/usr/lib/X11R5 LIBDIRS_IBM = # For AIX 3.2.2 or earlier, use LIBDIRS_IBM = -L/usr/lpp/X11/Xamples/lib # if you have set up the X server to use MIT SHM shared memory. LIBDIRS_LINUX = -L/usr/X386/lib LIBDIRS_SGI = # If you change LIBDIRS_SOL, make sure to change LOCALOPTS_SOL (-R argument) LIBDIRS_SOL = -L$(OPENWINHOME)/lib LIBDIRS_SUN4 = -L$(OPENWINHOME)/lib LIBDIRS = $(LIBDIRS_$(ARCH)) # In addition, there are apparently different requirements for # standard low-level libraries on the various systems and different # intolerance/requirement to include a library twice. STDLIBS_ALPHA = STDLIBS_DEC = STDLIBS_HP = STDLIBS_IBM = # for AIX 3.2.2 or earlier, set STDLIBS_IBM =-lXextSam # if you have set up the X server to use MIT SHM shared memory. STDLIBS_LINUX = STDLIBS_SGI = STDLIBS_SOL = -lsocket STDLIBS_SUN4 = -lXext STDLIBS = $(STDLIBS_$(ARCH)) # The X Shared Memory Extension can significantly improve the # performance of XAS. Depending on whether your X server supports # these (xdpyinfo should show it as MIT_SHM under the extensions # section), you may want to preserve the OSOPTS_(architecture) value # below, or remove the -DUSE_SHM if it doesn't seem to work. IBM X11 # servers do not have it enabled by default but the X server can be # rebuilt to include it for AIX 3.2.2 or earlier versions OSOPTS_ALPHA = -D_BSD -DUSE_SHM OSOPTS_DEC = -D_BSD -DUSE_SHM OSOPTS_HP = -D_BSD -DUSE_SHM OSOPTS_IBM = -D_AIX -D_BSD OSOPTS_LINUX = -D_BSD -DUSE_SHM OSOPTS_SGI = -D_BSD -DUSE_SHM OSOPTS_SOL = -D_BSD -DUSE_SHM OSOPTS_SUN4 = -D_BSD -DUSE_SHM # XAS still works on some VMS platforms... OSOPTS_VMS = -D_VMS OSOPTS = $(OSOPTS_$(ARCH)) # Add local compiler/linker options here. The -R under Solaris makes sure # the library area used in LIBDIRS_SOL gets burned into the resulting # binary. LOCALOPTS_ALPHA = LOCALOPTS_DEC = LOCALOPTS_HP = LOCALOPTS_IBM = LOCALOPTS_LINUX = LOCALOPTS_SGI = # if you change the -R argument, it should match LIBDIRS_SOL above. LOCALOPTS_SOL = -O -v -K PIC -Xa -R $(OPENWINHOME)/lib LOCALOPTS_SUN4 = LOCALOPTS = $(LOCALOPTS_$(ARCH)) # The C compiler, whatever works for you. # CC_SOL = /opt/SUNWspro/bin/cc # this is the non-standard CV location for Sun SC3.x compilers. CC_SOL = /opt/TESTspro/SUNWspro/bin/cc CC_SUN4 = /usr/lang/cc CC_ALPHA = cc CC_IBM = cc CC_LINUX = gcc CC_HP = cc CC_DEC = cc CC_SGI = cc CC = $(CC_$(ARCH)) # Do not alter anything below this line #-------------------------------------------------------------------- CCOPTS = $(INCDIRS) $(OSOPTS) $(LOCALOPTS) -c OBJECTS = xas.o image.o comm.o cursor.o screen.o init.o colors.o .c.o : $(CC) $(CCOPTS) $< install : xas mv xas $(DESTDIR)/XAS all: @ echo 'First make xas, then make install, then make clean' xas : $(OBJECTS) $(CC) $(LIBDIRS) $(LOCALOPTS) $(OSOPTS) $(OBJECTS) -lXext -lX11 -lm $(STDLIBS) -o xas xas.o : xas.c xas.h image.o : image.c xas.h comm.o : comm.c xas.h cursor.o: cursor.c xas.h screen.o: screen.c xas.h init.o : init.c xas.h Xas.icon colors.o: colors.c xas.h clean: rm -f *.o xas XAS --XYZZY-- cat > Makefile.DEC << --XYZZY-- # Makefile for xas # This makefile is a stripped down version of the generic Makefile for # XAS specifically for Ultrix. It has been tested under Ultrix 4.3. # # Destination for executable. If you are building XAS on a # system that has AIPS installed this should be the same as # the AIPS LOAD area. MAKE SURE "LOAD" IS DEFINED FIRST!!!!! # Usually this is done with "source LOGIN.CSH" or ". LOGIN.SH". # Some implementations of make allow the use of an environmental # variable as shown here: check your system documentation. DESTDIR = $(LOAD) # Additional include files. Some X Window System # implementations do not place their include in the standard # Unix directory /usr/include. The include directories should # be listed here, each preceded by -I. INCDIRS = -I/usr/include/X11 # Library search path. Standard Unix libraries are usually found in # /usr/lib; some X Window System implementations place their libraries # elsewhere. These should be listed here, each preceded by -L. LIBDIRS = -L/usr/lib/X11 # The X Shared Memory Extension can significantly improve the # performance of XAS. If you have the X Shared Memory # extension and your version of Unix supports shared memory # segments leave the following definition as it is, otherwise # set the value to blank. SHMOPT = -DUSE_SHM # Add OS-dependent options used inside XAS # On IBM : OSOPTS = -D_AIX -D_BSD # On VMS : OSOPTS = -D_VMS # On Unix : OSOPTS = -D_BSD OSOPTS = -D_BSD # Add local compiler/linker options here. LOCALOPTS = -O # Your favourite C compiler # for Gnu C : CC=gcc CC=cc # Do not alter anything below this line #-------------------------------------------------------------------- .c.o : $(CC) $(CCOPTS) $< CCOPTS = $(INCDIRS) $(SHMOPT) $(OSOPTS) $(LOCALOPTS) -c OBJECTS = xas.o image.o comm.o cursor.o screen.o init.o colors.o install : xas mv xas $(DESTDIR)/XAS all : @ echo 'First make xas, then make install, then make clean' xas : $(OBJECTS) $(CC) $(LIBDIRS) $(LOCALOPTS) $(OSOPTS) $(OBJECTS) -lXext -lX11 -lm $(STDLIBS) -o xas xas.o : xas.c xas.h image.o : image.c xas.h comm.o : comm.c xas.h cursor.o: cursor.c xas.h screen.o: screen.c xas.h init.o : init.c xas.h Xas.icon colors.o: colors.c xas.h clean: rm -f *.o xas XAS --XYZZY-- cat > Makefile.old << --XYZZY-- # Makefile for xas # This makefile has been tested on the following systems: # baboon - Sun SparcStation 2, SunOS 4.1.2 # rhesus - IBM RS/6000 model 560 (AIX 3.2.2, MIT-SHM added) # bonobo - Decstation 3100, Ultrix 4.0 # pongo - Dec Alpha AXP 3000/300, OSF-1/1.2 # hpdemo - HP 9000/755, HP-UX A.09.01 (X11R5) # tamarin - Sun SparcStation LX, SunOS 5.2 # tarsier - Gateway 2000 486DX2/66 PC, Linux 0.99.12 # # The different settings for each architecture is indicated # in the comments. # Note for VMS, xas.h must be modified to define VMS as 1 # # Destination for executable. If you are building XAS on a # system that has AIPS installed this should be the same as # the AIPS LOAD area. MAKE SURE "LOAD" IS DEFINED FIRST!!!!! # Usually this is done with "source LOGIN.CSH" or ". LOGIN.SH". # Some implementations of make allow the use of an environmental # variable as shown here: check your system documentation. DESTDIR = $(LOAD) # Additional include files. Some X Window System # implementations do not place their include in the standard # Unix directory /usr/include. The include directories should # be listed here, each preceded by -I. # On SUN4 : INCDIRS = -I$(OPENWINHOME)/include # On SOL : INCDIRS = -I$(OPENWINHOME)/include # (cv sun's): INCDIRS = -I/usr/local/include # On IBM : INCDIRS = -I/usr/include/X11 # On HP : INCDIRS = -I/usr/include/X11R5 # On DEC : INCDIRS = -I/usr/include/X11 # On ALPHA : INCDIRS = -I/usr/include/X11 # On LINUX : INCDIRS = -I/usr/include/X11 INCDIRS = -I$(OPENWINHOME)/include # Library search path. Standard Unix libraries are usually found in # /usr/lib; some X Window System implementations place their libraries # elsewhere. These should be listed here, each preceded by -L. # IBM-SHR is for IBM systems shared memory. # On SUN4 : LIBDIRS = -L$(OPENWINHOME)/lib # On SOL : LIBDIRS = -L$(OPENWINHOME)/lib # On IBM : LIBDIRS = # On IBM-SHR: LIBDIRS = -L/usr/lpp/X11/Xamples/lib # On DEC : LIBDIRS = -L/usr/lib/X11 # On ALPHA : LIBDIRS = -L/usr/lib/X11 # On HP : LIBDIRS = -L/usr/lib/X11R5 # On LINUX : LIBDIRS = -L/usr/X386/lib LIBDIRS = -L$(OPENWINHOME)/lib # In addition, there are apparently different requirements for # standard low-level libraries on the various systems and different # intolerance/requirement to include a library twice. # On SunOS 4.2 : STDLIBS = -lXext # On Solaris : STDLIBS = -lsocket # On IBM (SHM) : STDLIBS = -lXextSam STDLIBS = -lXext # The X Shared Memory Extension can significantly improve the # performance of XAS. If you have the X Shared Memory # extension and your version of Unix supports shared memory # segments leave the following definition as it is, otherwise # set the value to blank. IBM X11 servers do not have it enabled # by default but the X server can be rebuilt to include it. # SHMOPT = -DUSE_SHM # SHMOPT = SHMOPT = -DUSE_SHM # Add OS-dependent options used inside XAS # On IBM : OSOPTS = -D_AIX -D_BSD # On VMS : OSOPTS = -D_VMS # On Unix : OSOPTS = -D_BSD OSOPTS = -D_BSD # Add local compiler/linker options here. For example Sun 3s # will require a -f option to specify the floating point # hardware option. # On Debug : LOCALOPTS = -g # Default : LOCALOPTS = -O # On SOL : LOCALOPTS = -O -v -K PIC -Xa LOCALOPTS = -O # Your favourite C compiler # On SOL : CC=/opt/SUNWspro/bin/cc # On SUN4 : CC=/usr/lang/cc # for Gnu C : CC=gcc CC=cc # Do not alter anything below this line #-------------------------------------------------------------------- .c.o : $(CC) $(CCOPTS) $< CCOPTS = $(INCDIRS) $(SHMOPT) $(OSOPTS) $(LOCALOPTS) -c OBJECTS = xas.o image.o comm.o cursor.o screen.o init.o colors.o install : $(DESTDIR)/XAS $(DESTDIR)/XAS : xas mv xas $(DESTDIR)/XAS all : xas xas : $(OBJECTS) $(CC) $(LIBDIRS) $(LOCALOPTS) $(OBJECTS) -lXext -lX11 -lm $(STDLIBS) -o xas xas.o : xas.c xas.h image.o : image.c xas.h comm.o : comm.c xas.h cursor.o: cursor.c xas.h screen.o: screen.c xas.h init.o : init.c xas.h Xas.icon colors.o: colors.c xas.h --XYZZY-- cat > Xas.icon << --XYZZY-- /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=8 This cannot be read by iconedit which uses 16-bit words only and which puts the bits in the reverse order! Files below, Xas.iconedit and TEST.FOR, are for iconedit'ing and conversion to this format. */ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00, 0xBD,0xFF,0xFF,0x77,0xFF,0xFF,0x07,0x00, 0xB9,0x73,0xDF,0x77,0xE7,0xF9,0x01,0x00, 0xB5,0x6D,0xDB,0xAF,0xDF,0xFE,0x00,0x03, 0xAD,0x61,0xDB,0xDF,0xC7,0x7C,0xC0,0x01, 0xAD,0x7D,0xD5,0xAF,0xDB,0x39,0x60,0x00, 0x9D,0xFD,0xEE,0x77,0xDB,0x1B,0x70,0x00, 0xBD,0xE3,0xEE,0x77,0xA7,0x1C,0x3C,0x00, 0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x3E,0x10, 0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x1F,0x18, 0xFF,0xFF,0xF7,0xFF,0xFF,0x9F,0x1F,0x3C, 0xFF,0xFF,0x03,0xFF,0xFF,0x9F,0x1F,0x3F, 0xFF,0xFF,0x01,0xFC,0xFF,0x9F,0x9F,0x3F, 0xFF,0xFF,0x0D,0xF8,0xFF,0xFF,0x9F,0x3F, 0xFF,0x7F,0x4C,0xF0,0xFF,0xFF,0x9F,0x3F, 0xFF,0x3F,0x80,0xE0,0xFF,0xFF,0x9F,0x3F, 0xFF,0x1F,0x80,0xE0,0xFF,0xFF,0x9F,0x3F, 0xFF,0x1F,0xC0,0x00,0xFF,0xFF,0xDF,0x3F, 0xFF,0x1F,0x02,0x00,0xFC,0xFF,0xFF,0x3F, 0xFF,0xFF,0x01,0x00,0xFC,0xFF,0xFF,0x3F, 0xFF,0x3F,0x00,0x00,0xF0,0xFF,0xFF,0x3F, 0xFF,0x7F,0x20,0x00,0xE0,0xFF,0xFF,0x3F, 0xFF,0xFF,0x11,0x00,0xE0,0xFF,0xFF,0x3F, 0xFF,0xFF,0x0F,0x00,0xC0,0xFF,0xFF,0x3F, 0xFF,0xFF,0x1F,0x00,0x00,0xFF,0xFF,0x3F, 0xFF,0xFF,0x1F,0x00,0x00,0xFE,0xFF,0x3F, 0xFF,0xFF,0x1F,0x00,0x00,0xC0,0xFF,0x3F, 0xFF,0xFF,0x1F,0x00,0x00,0x00,0xFF,0x3F, 0xFF,0xFF,0x0F,0x00,0x00,0x00,0xFF,0x3F, 0xFF,0xFF,0x0F,0x00,0x00,0x00,0xFE,0x3F, 0xFF,0xFF,0x07,0x00,0x00,0x00,0xFE,0x3F, 0xFF,0xFF,0x07,0x00,0x00,0x00,0xFE,0x3F, 0xFF,0xFF,0x03,0x00,0x00,0x00,0xFF,0x3F, 0xFF,0xFF,0x03,0x00,0x00,0x00,0xFF,0x3F, 0xFF,0xFF,0x01,0x06,0x00,0x00,0xFF,0x3F, 0xFF,0xFF,0x80,0x09,0x00,0x00,0xFF,0x3F, 0xFF,0xFF,0xC0,0x31,0x01,0x00,0xFF,0x3F, 0xFF,0x7F,0xC0,0xF0,0x5F,0x04,0xFE,0x3F, 0xFF,0x3F,0xF0,0xF0,0xBF,0x0F,0xFE,0x3F, 0xFF,0x1F,0xFC,0xF8,0x3F,0x10,0xFC,0x3F, 0xFF,0x0F,0x7C,0xF8,0x3F,0x10,0xF8,0x3F, 0xFF,0x0F,0x7C,0xF0,0x7F,0x20,0xF8,0x3F, 0xFF,0x0F,0x78,0xF0,0xFF,0x20,0xF8,0xBF, 0xFF,0x0F,0x78,0xF0,0x7F,0x60,0xF0,0xFF, 0xFF,0x0F,0x7C,0xF8,0x1F,0x60,0xF0,0xFF, 0xFF,0x0F,0xFE,0xFF,0x1F,0x10,0xF8,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0xFE,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF --XYZZY-- cat > Xas.iconedit << --XYZZY-- /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16 */ 0xFFFF,0xFFFF,0xFFFF,0xF000, 0xBDFF,0xFFEE,0xFFFF,0xE000, 0x9DCE,0xFBEE,0xE79F,0x8000, 0xADB6,0xDBF5,0xFB7F,0x00C0, 0xB586,0xDBFB,0xE33E,0x0380, 0xB5BE,0xABF5,0xDB9C,0x0600, 0xB9BF,0x77EE,0xDBD8,0x0E00, 0xBDC7,0x77EE,0xE538,0x3C00, 0xFFFF,0xFFFF,0xFFF8,0x7C08, 0xFFFF,0xFFFF,0xFFF8,0xF818, 0xFFFF,0xEFFF,0xFFF9,0xF83C, 0xFFFF,0xC0FF,0xFFF9,0xF8FC, 0xFFFF,0x803F,0xFFF9,0xF9FC, 0xFFFF,0xB01F,0xFFFF,0xF9FC, 0xFFFE,0x320F,0xFFFF,0xF9FC, 0xFFFC,0x0107,0xFFFF,0xF9FC, 0xFFF8,0x0107,0xFFFF,0xF9FC, 0xFFF8,0x0300,0xFFFF,0xFBFC, 0xFFF8,0x4000,0x3FFF,0xFFFC, 0xFFFF,0x8000,0x3FFF,0xFFFC, 0xFFFC,0x0000,0x0FFF,0xFFFC, 0xFFFE,0x0400,0x07FF,0xFFFC, 0xFFFF,0x8800,0x07FF,0xFFFC, 0xFFFF,0xF000,0x03FF,0xFFFC, 0xFFFF,0xF800,0x00FF,0xFFFC, 0xFFFF,0xF800,0x007F,0xFFFC, 0xFFFF,0xF800,0x0003,0xFFFC, 0xFFFF,0xF800,0x0000,0xFFFC, 0xFFFF,0xF000,0x0000,0xFFFC, 0xFFFF,0xF000,0x0000,0x7FFC, 0xFFFF,0xE000,0x0000,0x7FFC, 0xFFFF,0xE000,0x0000,0x7FFC, 0xFFFF,0xC000,0x0000,0xFFFC, 0xFFFF,0xC000,0x0000,0xFFFC, 0xFFFF,0x8060,0x0000,0xFFFC, 0xFFFF,0x0190,0x0000,0xFFFC, 0xFFFF,0x038C,0x8000,0xFFFC, 0xFFFE,0x030F,0xFA20,0x7FFC, 0xFFFC,0x0F0F,0xFDF0,0x7FFC, 0xFFF8,0x3F1F,0xFC08,0x3FFC, 0xFFF0,0x3E1F,0xFC08,0x1FFC, 0xFFF0,0x3E0F,0xFE04,0x1FFC, 0xFFF0,0x1E0F,0xFF04,0x1FFD, 0xFFF0,0x1E0F,0xFE06,0x0FFF, 0xFFF0,0x3E1F,0xF806,0x0FFF, 0xFFF0,0x7FFF,0xF808,0x1FFF, 0xFFFF,0xFFFF,0xFFF8,0x7FFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0x0000,0x0000,0x0000,0x0000, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF --XYZZY-- cat > colors.c << --XYZZY-- #include "xas.h" int cmap_wlut() /*--------------------------------------------------------------------*/ /*! set look-up tables (colormaps) --- XAS version */ /*# TV-IO */ /*--------------------------------------------------------------------*/ /*; Copyright (C) 1995, 1996 */ /*; Associated Universities, Inc. Washington DC, USA. */ /*; */ /*; This program is free software; you can redistribute it and/or */ /*; modify it under the terms of the GNU General Public License as */ /*; published by the Free Software Foundation; either version 2 of */ /*; the License, or (at your option) any later version. */ /*; */ /*; This program is distributed in the hope that it will be useful, */ /*; but WITHOUT ANY WARRANTY; without even the implied warranty of */ /*; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /*; GNU General Public License for more details. */ /*; */ /*; You should have received a copy of the GNU General Public */ /*; License along with this program; if not, write to the Free */ /*; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, */ /*; MA 02139, USA. */ /*; */ /*; Correspondence concerning AIPS should be addressed as follows: */ /*; Internet email: aipsmail@nrao.edu. */ /*; Postal address: AIPS Project Office */ /*; National Radio Astronomy Observatory */ /*; 520 Edgemont Road */ /*; Charlottesville, VA 22903-2475 USA */ /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/ /* Write the NColour LookUpTable into memory and to colormap */ /*--------------------------------------------------------------------*/ { register int i, j; /*--------------------------------------------------------------------*/ j = xbuf.parms[3] - 1; if ((xbuf.parms[3] < 1) || (xbuf.parms[3] > NGREY)) { fprintf (stderr, "XAS: Illegal grey channel %d\n", xbuf.parms[3]); return (-1); } else { if (xbuf.parms[0] != 0) for (i = 0; i < NColour; ++i) rlut[j][i] = xbuf.data[i]; if (xbuf.parms[1] != 0) for (i = 0; i < NColour; ++i) glut[j][i] = xbuf.data[i]; if (xbuf.parms[2] != 0) for (i = 0; i < NColour; ++i) blut[j][i] = xbuf.data[i]; return (xbuf.parms[3] == cur_chan ? cmap_change() : 0); } } int cmap_rlut() /*--------------------------------------------------------------------*/ /* Read the NColour LookUpTable from memory */ /*--------------------------------------------------------------------*/ { register int i, j; /*--------------------------------------------------------------------*/ j = xbuf.parms[3] - 1; if ((j < 0) || (j > NGREY-1)) { fprintf (stderr, "XAS: Illegal grey channel %d\n", j+1); return (-1); } else { if (xbuf.parms[0] != 0) for (i = 0; i < NColour; ++i) ybuf.data[i] = rlut[j][i]; if (xbuf.parms[1] != 0) for (i = 0; i < NColour; ++i) ybuf.data[i] = glut[j][i]; if (xbuf.parms[2] != 0) for (i = 0; i < NColour; ++i) ybuf.data[i] = blut[j][i]; return (0); } } int cmap_wofm() /*--------------------------------------------------------------------*/ /* Write the NINTENS OutputFunction into memory and to colormap */ /*--------------------------------------------------------------------*/ { register int i; /*--------------------------------------------------------------------*/ if (xbuf.parms[0] != 0) for (i = 0; i < NINTENS; ++i) rofm[i] = xbuf.data[i]; if (xbuf.parms[1] != 0) for (i = 0; i < NINTENS; ++i) gofm[i] = xbuf.data[i]; if (xbuf.parms[2] != 0) for (i = 0; i < NINTENS; ++i) bofm[i] = xbuf.data[i]; return (cmap_change()); } int cmap_rofm() /*--------------------------------------------------------------------*/ /* Read the NINTENS OutputFunction from memory */ /*--------------------------------------------------------------------*/ { register int i; /*--------------------------------------------------------------------*/ if (xbuf.parms[0] != 0) for (i = 0; i < NINTENS; ++i) ybuf.data[i] = rofm[i]; if (xbuf.parms[1] != 0) for (i = 0; i < NINTENS; ++i) ybuf.data[i] = gofm[i]; if (xbuf.parms[2] != 0) for (i = 0; i < NINTENS; ++i) ybuf.data[i] = bofm[i]; return (0); } int cmap_change() /*--------------------------------------------------------------------*/ /* Changes the colormap based on the stored LUTs and OFMs in core. */ /* Adapted from a routine used in SSS. */ /*--------------------------------------------------------------------*/ { register int i, ns, j; /*--------------------------------------------------------------------*/ j = cur_chan - 1; /* do the NColor of image 1st */ if (cur_chan > 0) { for (i = 0; i < NColour; ++i) { colour_table[i+OColour].red = rofm[rlut[j][i]] << COLORSHIFT; colour_table[i+OColour].green = gofm[glut[j][i]] << COLORSHIFT; colour_table[i+OColour].blue = bofm[blut[j][i]] << COLORSHIFT; } colour_table[OColour].red = colour_table[OColour].blue = colour_table[OColour].green = 0; } /* image is off */ else { for (i = 0; i < NColour; ++i) { colour_table[i+OColour].red = colour_table[i+OColour].blue = colour_table[i+OColour].green = 0; } } /* add in graphics */ ns = NColour; for (i = NColour; i < NValue; ++i) { colour_table[i+OColour].red = rgcol[i-ns] << COLORSHIFT; colour_table[i+OColour].green = ggcol[i-ns] << COLORSHIFT; colour_table[i+OColour].blue = bgcol[i-ns] << COLORSHIFT ; } XStoreColors (display, TV_colour, colour_table, NValue+OColour); return (0); } int cmap_graph() /*--------------------------------------------------------------------*/ /* Switch graphics plane(s) on or off. */ /*--------------------------------------------------------------------*/ { int prevgraph; /*--------------------------------------------------------------------*/ if ((xbuf.parms[0] < 1) || (xbuf.parms[0] > NGRAPH)) { fprintf (stderr, "XAS: Illegal graphics channel %d\n", xbuf.parms[0]); return (-1); } else { prevgraph = rwgraph; gph_mask = 1; if (xbuf.parms[0] == 2) gph_mask = 2; if (xbuf.parms[0] == 3) gph_mask = 4; if (xbuf.parms[0] == 4) gph_mask = 8; if (xbuf.parms[0] == 5) gph_mask = 16; if (xbuf.parms[0] == 6) gph_mask = 32; if (xbuf.parms[0] == 7) gph_mask = 64; if (xbuf.parms[0] == 8) gph_mask = 128; if (xbuf.parms[1] > 0) rwgraph = rwgraph | gph_mask; else rwgraph = rwgraph & (~ gph_mask); if (prevgraph != rwgraph) { scrwrt (0, 0, Screen_Width - 1, Screen_Height - 1); return (cmap_change()); } else return (0); } } int cmap_split() /*--------------------------------------------------------------------*/ /* Switch grey channel on or off. */ /*--------------------------------------------------------------------*/ { int prevchan; /*--------------------------------------------------------------------*/ if ((xbuf.parms[0] < 0) || (xbuf.parms[0] > NGREY)) { fprintf (stderr, "XAS: Illegal grey channel %d\n", xbuf.parms[0]); return (-1); } else if ((xbuf.parms[1] != xbuf.parms[0]) || (xbuf.parms[2] != xbuf.parms[0]) || (xbuf.parms[3] != xbuf.parms[0])) { fprintf (stderr, "XAS: Split not implemented %d %d %d %d\n", xbuf.parms[0], xbuf.parms[1], xbuf.parms[2], xbuf.parms[3]); return (-1); } else { prevchan = cur_chan; cur_chan = xbuf.parms[0]; if (prevchan != cur_chan) { scrwrt (0, 0, Screen_Width - 1, Screen_Height - 1); return (cmap_change()); } else return (0); } } int cmap_wgrfx() /*--------------------------------------------------------------------*/ /* Writes the cursor and graphics colour assignment. */ /* */ /* MRC 90/Feb/15: */ /*--------------------------------------------------------------------*/ { int i; if ((xbuf.parms[0] < 0) || (xbuf.parms[0] > NGRAPH)) { fprintf (stderr, "XAS: Illegal grafix channel %d\n", xbuf.parms[0]); return (-1); } rgrfx[xbuf.parms[0]] = xbuf.parms[1]; ggrfx[xbuf.parms[0]] = xbuf.parms[2]; bgrfx[xbuf.parms[0]] = xbuf.parms[3]; /* make cross colors */ crscol (rgrfx, rgcol); crscol (ggrfx, ggcol); crscol (bgrfx, bgcol); /* make cursor colors */ if (xbuf.parms[0] == 0) { if (fg_curs.pixel >= 0) { bg_curs.red = 0; bg_curs.green = 0; bg_curs.blue = 0; fg_curs.red = rgcol[19] << COLORSHIFT; fg_curs.green = ggcol[19] << COLORSHIFT; fg_curs.blue = bgcol[19] << COLORSHIFT; XRecolorCursor (display, cursor, &fg_curs, &bg_curs); } return (0); } /* change the screen colors */ else return (cmap_change()); } void crscol (grfx, gcol) /*--------------------------------------------------------------------*/ /* converts grfx[9] to full set of colors gcol[16] where */ /* Input: grfx i[9] cursor, 8 graphics values for a color */ /* Output: gcol i[20] graphics values 1-19, cursor for the color */ /*--------------------------------------------------------------------*/ int *grfx, *gcol; /*--------------------------------------------------------------------*/ { *(gcol+0) = *(grfx+1); /* grph 1-4 w cross colors */ *(gcol+1) = *(grfx+2); *(gcol+2) = *(grfx+1) ^ *(grfx+2); *(gcol+3) = *(grfx+3); *(gcol+4) = *(grfx+1) ^ *(grfx+3); *(gcol+5) = *(grfx+2) ^ *(grfx+3); *(gcol+6) = *(grfx+1) ^ *(gcol+5); *(gcol+7) = *(grfx+4); *(gcol+8) = *(grfx+4) ^ *(gcol+0); *(gcol+9) = *(grfx+4) ^ *(gcol+1); *(gcol+10) = *(grfx+4) ^ *(gcol+2); *(gcol+11) = *(grfx+4) ^ *(gcol+3); *(gcol+12) = *(grfx+4) ^ *(gcol+4); *(gcol+13) = *(grfx+4) ^ *(gcol+5); *(gcol+14) = *(grfx+4) ^ *(gcol+6); *(gcol+15) = *(grfx+5); /* grph 5-8 simple */ *(gcol+16) = *(grfx+6); *(gcol+17) = *(grfx+7); *(gcol+18) = *(grfx+8); *(gcol+19) = *(grfx+0); /* cursor */ return; } int cmap_rgrfx() /*--------------------------------------------------------------------*/ /* Reads the cursor and graphics colour assignment. */ /* */ /* MRC 90/Feb/15: */ /*--------------------------------------------------------------------*/ { if ((xbuf.parms[0] < 0) || (xbuf.parms[0] > NGRAPH)) { fprintf (stderr, "XAS: Illegal grafix channel %d\n", xbuf.parms[0]); return (-1); } ybuf.data[0] = rgrfx[xbuf.parms[0]]; ybuf.data[1] = ggrfx[xbuf.parms[0]]; ybuf.data[2] = bgrfx[xbuf.parms[0]]; return (0); } --XYZZY-- cat > comm.c << --XYZZY-- /*--------------------------------------------------------------------*/ /*! XAS communications package */ /*# TV-IO */ /*--------------------------------------------------------------------*/ /*; Copyright (C) 1995, 1996 */ /*; Associated Universities, Inc. Washington DC, USA. */ /*; */ /*; This program is free software; you can redistribute it and/or */ /*; modify it under the terms of the GNU General Public License as */ /*; published by the Free Software Foundation; either version 2 of */ /*; the License, or (at your option) any later version. */ /*; */ /*; This program is distributed in the hope that it will be useful, */ /*; but WITHOUT ANY WARRANTY; without even the implied warranty of */ /*; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /*; GNU General Public License for more details. */ /*; */ /*; You should have received a copy of the GNU General Public */ /*; License along with this program; if not, write to the Free */ /*; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, */ /*; MA 02139, USA. */ /*; */ /*; Correspondence concerning AIPS should be addressed as follows: */ /*; Internet email: aipsmail@nrao.edu. */ /*; Postal address: AIPS Project Office */ /*; National Radio Astronomy Observatory */ /*; 520 Edgemont Road */ /*; Charlottesville, VA 22903-2475 USA */ /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/ #include "xas.h" #if __STDC__ short int swapbytes ( short int a ) #else short int swapbytes( a ) short int a; #endif { union { short int shortint; struct { unsigned char lo, hi; }byte; }x; x.shortint = a; return x.byte.lo << 8 | x.byte.hi; } #if BSD int MakeLink() /*--------------------------------------------------------------------*/ /* Get a socket and bind it appropriately, if possible. The */ /* environmental variable TVDEV is expanded to find the AIPS TV */ /* assignment which is in turn expanded to a device name. If the */ /* device name contains a colon then the portion of the name before */ /* the colon is taken to be a service name and an INET socket is */ /* created. If the character before the colon is a 'b' then it is */ /* omitted from the service name and certain opcodes may be buffered. */ /* If no colon is present the device name is taken to be the name of */ /* a Unix domain socket. */ /*--------------------------------------------------------------------*/ { char device[80]; /* socket device name */ char service[16]; /* INET service name */ char *colon_ptr, *tptr1, *tptr2; register int i; /*--------------------------------------------------------------------*/ /* Check that TVDEV is */ /* defined and that it */ /* contains the name of an */ /* environmental variable. */ if (getenv("TVDEV") == NULL) { fprintf (stderr, "XAS: MakeLink translate TVDEV once fails\n"); perror ("MakeLink getenv(\"TVDEV\")"); return (-1); } sprintf (device, "%s", getenv(getenv("TVDEV"))); /* TVDEVn is undefined */ if (strcmp(device, "(NULL)") == 0) { perror ("get_socket getenv"); fprintf (stderr, "XAS: MakeLink translate TVDEV twice fails %s\n", device); return (-1); } /* INET domain */ if ((colon_ptr = strchr(device, ':')) != NULL) { domain_type = INET_DOMAIN; tptr1 = device; tptr2 = service; while (*tptr1 != ':') *(tptr2++) = *(tptr1++); *tptr2 = '\0'; if (*(--tptr2) == 'b') { buffered = True; *tptr2 = '\0'; } else buffered = False; if ((sp_in = getservbyname (service, "tcp")) == NULL) { fprintf (stderr, "XAS: %s is not a service\n", service); fprintf (stderr, "XAS: Check /etc/services or YP/NIS services map\n"); return (-1); } server_in.sin_port = sp_in->s_port; if ((AipsSocket = socket (AF_INET, SOCK_STREAM, 0)) < 0) { perror ("MakeLink: socket (INET)"); return (-1); } if (bind(AipsSocket, (struct sockaddr *)&server_in, sizeof(server_in)) < 0){ perror ("MakeLink: bind error (INET)"); return (-1); } } /* UNIX domain */ else { domain_type = UNIX_DOMAIN; buffered = False; server_un.sun_family = AF_UNIX; if ((AipsSocket = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) { perror ("MakeLink: socket (UNIX)"); return (-1); } /* Otherwise, open socket */ unlink (device); /* first unlink if it exists */ strcpy (server_un.sun_path, device); if (bind (AipsSocket, (struct sockaddr *)&server_un, strlen(server_un.sun_path) + 2) < 0) { perror ("MakeLink: bind error (UNIX)"); return (-1); } } listen (AipsSocket, 5); /* Queue up to 5 requests */ /* Set up the opcodes we want */ /* to buffer. Basically all */ /* the writes. */ for (i = 0; i < (NUMOP+1); i++) bufferop[i] = False; if (buffered) { bufferop[CLEAR]=True; bufferop[VIEW]=True; bufferop[IMWRT]=True; bufferop[WLUT]=True; bufferop[WOFM]=True; bufferop[WCURS]=True; bufferop[GRAPH]=True; bufferop[SPLIT]=True; bufferop[WGRFX]=True; bufferop[WZOOM]=True; bufferop[WSCROL]=True; bufferop[WZSCR]=True; } return (0); } /* end MakeLink */ #endif #if VMS int MakeLink() { (aipsname, AIPS_SOCKET); (xasname, XAS_SOCKET); int status,chan; /* create mailbox with logical name "AipsSocket" */ status = sys (0, &chan, maxmsg, bufquo, 0, 0, &aipsname); if (!(status & SS)) lib(status); AipsLink = chan; /* create mailbox with logical name "XasSocket" */ status = sys (0, &chan, maxmsg, bufquo, 0, 0, &xasname); if (!(status & SS)) lib(status); XasLink = chan; return (0); } /* end MakeLink */ #endif #if BSD int ReadLink (link, in, out) int link; XASinput *in; XASoutput *out; { register int i; int bytes_togo, bytes_trans, ldata, lbytes, nbytes, optlen; short int lbuf[6]; unsigned char *buffer; /* read header */ buffer = (unsigned char *) lbuf; bytes_togo = 6*size_i2; ldata = bytes_togo; while (bytes_togo > 0) { bytes_trans = read (link, buffer+(ldata-bytes_togo), bytes_togo); if (bytes_trans <= 0) { out->status = -1; /* error -> shutdown */ return (-1); } bytes_togo -= bytes_trans; } out->status = OK; in->opcode = ntohs (lbuf[0]); in->data_length = ntohs (lbuf[5]); for (i = 0; i < NPARMS; i++ ) in->parms[i] = ntohs (lbuf[i+1]); /* Note: in->data[] is unsigned char and isn't swapped */ /* "Variable length" data is */ /* in bytes, not words. */ /* Always read an even number */ /* of bytes. */ bytes_togo = in->data_length + (in->data_length)%2; ldata = bytes_togo; buffer = in->data; /* increase buffer size */ nbytes = bytes_togo; if ((Z_rcvbuf == Z_rcvini) && (nbytes > Z_rcvini)) { optlen = sizeof (Z_rcvbuf); Z_rcvbuf = 8192; if (setsockopt (link, SOL_SOCKET, SO_RCVBUF, (char *) &Z_rcvbuf, optlen) < 0) { perror ("XAS ReadLink increase rcvbuf size"); Z_rcvbuf = Z_rcvini+1; } else if (Z_rcvini > 0) fprintf (stderr, "XAS ReadLink increased send buffer size\n"); } while (bytes_togo > 0) { lbytes = bytes_togo; bytes_trans = read (link, (buffer+(ldata - bytes_togo)), lbytes); if (bytes_trans <= 0) { fprintf (stderr, "XAS: ReadLink read data error - shutdown?\n"); out->status = -1; return (-1); } bytes_togo -= bytes_trans; } return (0); } /* end ReadLink */ int WriteLink (link, in, out) int link; XASoutput *out; XASinput *in; { register int i, j; int buflen, lbytes, nbytes, optlen, mbytes; static short int packet[4096+2]; unsigned char *pp; pp = (unsigned char *) packet; buflen = out->return_data_length; if (!bufferop[in->opcode]) { packet[0] = htons (out->status); packet[1] = htons (out->return_data_length); i = 2; j = 0; while (j < buflen) packet[i++] = htons (out->data[j++]); buflen = (buflen + 2) * size_i2; /* increase buffer size */ nbytes = buflen; if ((Z_sndbuf == Z_sndini) && (nbytes > Z_sndini)) { optlen = sizeof (Z_sndbuf); Z_sndbuf = 16384; if (setsockopt (link, SOL_SOCKET, SO_SNDBUF, (char *) &Z_sndbuf, optlen) < 0) { perror ("XAS WriteLink increase sndbuf size"); Z_sndbuf = Z_sndini+1; } else if (Z_sndini > 0) fprintf (stderr, "XAS WriteLink increased send buffer size\n"); } for (nbytes = buflen; nbytes > 0; nbytes -= mbytes) { lbytes = nbytes; mbytes = write (link, pp+(buflen-nbytes), lbytes); if (mbytes <= 0) { perror ("xas:WriteLink - "); out->status = -1; return (-1); } } } else { if (out->status != 0) fprintf (stderr, "XAS: Buffered op %d, istat=%d\n", in->opcode, out ->status); } out->status = OK; return (0); } /* end WriteLink */ #endif #if VMS void XasAipsReadAST() { if (!(read_status.ioresult & SS)) fprintf (stderr, "XAS: ReadLink - "); if (ybuf.status == OK) ProcessAipsRequest(); read_in_progress = 0; WriteLink(); } int ReadLink() { int s; if (read_in_progress) return (0); read_in_progress = 1; s = sys (0, XasLink, IO, &read_status, &XasAipsReadAST, 0, xbuf.buf, sizeof(xbuf.buf), 0, 0, 0, 0); if (!(s & SS)) { fprintf (stderr, "XAS: ReadLink - "); ybuf.status = -1; return (-1); } ybuf.status = OK; if (ByteSwapped) { xbuf.opcode = swapbytes (xbuf.opcode); xbuf.data_length = swapbytes (xbuf.data_length); for (i = 0; i < NPARMS; i++) xbuf.parms[i] = swapbytes (xbuf.parms[i]); /* Note: xbuf.data[] is unsigned char and isn't swapped */ } return (0); } /* end ReadLink */ /* This could be real strange if more than one process tries to */ /* send commands to this process. This assumes that the "master" */ /* process is doing IO synchronusly(since it must wait for status)*/ /* Question: should all error checking be done by the AIPS process*/ /* thus eliminating the need for synchronous IO??? */ void XasAipsWriteAST() { if(!(write_status.ioresult & SS)) fprintf(stderr,"XAS: WriteLink - "); write_in_progress = 0; /* Ready to do the next read */ ReadLink(); return; } int WriteLink() { int s, i, buflen; if (write_in_progress) return; if (!bufferop[xbuf.opcode]) { write_in_progress = 1; buflen = ybuf.return_data_length; if (ByteSwapped) { ybuf.status = swapbytes (ybuf.status); ybuf.return_data_length = swapbytes (ybuf.return_data_length); /* the returned data is of type short int */ for (i = 0; i < buflen; i++) ybuf.data[i] = swapbytes (ybuf.data[i]); } s = sys (0, AipsLink, IO, &write_status, &XasAipsWriteAST, 0, ybuf.status, 4+2*buflen, 0, 0, 0, 0); if (!(s & SS)) fprintf (stderr, "XAS: WriteLink - "); } return (0); } /* end WriteLink */ #endif void closedown() { int status, i; #ifdef USE_SHM if (using_shm) { /* clean up SHM */ for (i = 0; i < NGREY; i++) { XShmDetach (display, &plane_info[i]); XDestroyImage (plane[i]); shmdt (plane_info[i].shmaddr); shmctl (plane_info[i].shmid, IPC_RMID, 0); } XShmDetach (display, &graph_info); XDestroyImage (graph); shmdt (graph_info.shmaddr); shmctl (graph_info.shmid, IPC_RMID, 0); XShmDetach (display, &line_info); XDestroyImage (line); shmdt (line_info.shmaddr); shmctl (line_info.shmid, IPC_RMID, 0); } #endif XFreeGC (display, ImageGC); #ifndef USE_SHM for (i = 0; i < NGREY; i++ ) XDestroyImage (plane[i]); XDestroyImage (graph); XDestroyImage (line); #endif XCloseDisplay (display); #if BSD if (domain_type == UNIX_DOMAIN) if( unlink(server_un.sun_path) < 0) { perror ("closedown: unlink"); } #endif #if VMS status = sys(AipsLink); if (!(status & SS)) lib(status); status = sys(XasLink); if (!(status & SS)) lib(status); #endif fprintf(stderr, "XAS: Quitting NOW.\n"); exit(1); return; } void printbufin() { int i, j, limit; fprintf (stderr,"parms[]= %4d %4d %4d %4d\n", xbuf.parms[0], xbuf.parms[1], xbuf.parms[2], xbuf.parms[3]); fprintf (stderr, "data_length= %d\n", xbuf.data_length); limit = 16; /* xbuf.data_length; */ for (i = 0; i < limit; i += 16) { for (j = i; (j < i+16) && (j < limit); j++) fprintf (stderr, " %4d", xbuf.data[j]); fprintf (stderr, "\n"); } return; } /* end printfbuf */ void printbufout() { int i, j, limit; fprintf (stderr, "status = %4d\n", ybuf.status); fprintf (stderr, "parms[]= %4d %4d %4d %4d\n", xbuf.parms[0], xbuf.parms[1], xbuf.parms[2], xbuf.parms[3]); fprintf (stderr, "return_data_length= %d\n", ybuf.return_data_length); limit = ybuf.return_data_length; for (i = 0; i < limit; i += 16) { for (j = i; (j < i+16) && (j < limit); j++) fprintf (stderr," %4d", ybuf.data[j]); fprintf (stderr,"\n"); } return; } /* end printfbuf */ /*--------------------------------------------------------------------*/ --XYZZY-- cat > cursor.c << --XYZZY-- /*--------------------------------------------------------------------*/ /*! XAS cursor handling routines */ /*# TV-IO */ /*--------------------------------------------------------------------*/ /*; Copyright (C) 1995, 1996 */ /*; Associated Universities, Inc. Washington DC, USA. */ /*; */ /*; This program is free software; you can redistribute it and/or */ /*; modify it under the terms of the GNU General Public License as */ /*; published by the Free Software Foundation; either version 2 of */ /*; the License, or (at your option) any later version. */ /*; */ /*; This program is distributed in the hope that it will be useful, */ /*; but WITHOUT ANY WARRANTY; without even the implied warranty of */ /*; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /*; GNU General Public License for more details. */ /*; */ /*; You should have received a copy of the GNU General Public */ /*; License along with this program; if not, write to the Free */ /*; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, */ /*; MA 02139, USA. */ /*; */ /*; Correspondence concerning AIPS should be addressed as follows: */ /*; Internet email: aipsmail@nrao.edu. */ /*; Postal address: AIPS Project Office */ /*; National Radio Astronomy Observatory */ /*; 520 Edgemont Road */ /*; Charlottesville, VA 22903-2475 USA */ /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/ /* Description of keys enabled by this module */ /* */ /* Key Alternate(s) Action */ /* ----------------------------------------------------------------- */ /* F3 Keypad F1, A, a AIPS button "A" */ /* F4 Keypad F2, B, b AIPS button "B" */ /* F5 Keypad F3, C, c AIPS button "C" */ /* F6 Keypad F4, D, d AIPS button "D" */ /* F7 F2, Keypad '+' Toggle screen size (small <-> large) */ /* F8 Toggle XAS debug flag */ /* F9 Toggle Xwindow debug flag */ /* F20 ESC, Control C Quit via call to closedown(AipsLink) */ /* -- not recommended! */ /*--------------------------------------------------------------------*/ #include "xas.h" void RecordCursor (x, y) int x, y; { /* -> wrt to window */ cursor_x = x + sc_centre_x - sc_width2 + 1; cursor_y = y + sc_centre_y - sc_height2 + 1; /* guard against border crossings with a button pressed */ if (cursor_x < 0) cursor_x = 0; if (cursor_y < 0) cursor_y = 0; if (cursor_x > Screen_Width - 1) cursor_x = Screen_Width - 1; if (cursor_y > Screen_Height - 1) cursor_y = Screen_Height - 1; return; } void CheckKey (key, AipsLink) KeySym key; int AipsLink; { /* The keys F3, F4, F5 and F6 are the AIPS buttons A, B, C, D */ switch (key) { case XK_F8: /* Toggle XAS debug flag */ XasDebug = !XasDebug; fprintf (stderr,"XAS: Debugging Toggled with button F8\n"); break; case XK_F9: /* Toggle Xwin debug flag */ XDebug = !XDebug; break; case XK_KP_F1: /* AIPS A button */ case XK_F3: case XK_A: case XK_a: button_a += 1; break; case XK_KP_F2: /* AIPS B button */ case XK_F4: case XK_B: case XK_b: button_b += 1; break; case XK_KP_F3: /* AIPS C button */ case XK_F5: case XK_C: case XK_c: button_c += 1; break; case XK_KP_F4: /* AIPS D button */ case XK_F6: case XK_D: case XK_d: button_d += 1; break; case XK_KP_Add: case XK_F7: case XK_F2: (void) resize_pressed(); break; case XK_F20: case XK_Escape: closedown (); break; default: break; } return; } int GetCursor() { ybuf.data[0] = Aips_x (cursor_x); ybuf.data[1] = Aips_y (cursor_y); return (0); } int movecursor() { int xc, yc; cursor_x = Memory_x (xbuf.parms[0]); cursor_y = Memory_y (xbuf.parms[1]); /* -> wrt to window */ xc = cursor_x - sc_centre_x + sc_width2 - 1; yc = cursor_y - sc_centre_y + sc_height2 - 1; /* move cursor only if it would be in window */ if ((xc < sc_width) && (yc < sc_height) && (xc >= 0) && (yc >= 0)) XWarpPointer (display, win, win, 0, 0, sc_width, sc_height, xc, yc); return (0); } int readbuttons() { ybuf.data[0] = button_a; ybuf.data[1] = button_b; ybuf.data[2] = button_c; ybuf.data[3] = button_d; button_a = button_b = button_c = button_d = 0; return (0); } int cursor_button() { ybuf.data[0] = Aips_x (cursor_x); ybuf.data[1] = Aips_y (cursor_y); ybuf.data[2] = button_a; ybuf.data[3] = button_b; ybuf.data[4] = button_c; ybuf.data[5] = button_d; button_a = button_b = button_c = button_d = 0; return (0); } --XYZZY-- cat > image.c << --XYZZY-- /*--------------------------------------------------------------------*/ /*! XAS image handling routines */ /*# TV-IO */ /*--------------------------------------------------------------------*/ /*; Copyright (C) 1995, 1996 */ /*; Associated Universities, Inc. Washington DC, USA. */ /*; */ /*; This program is free software; you can redistribute it and/or */ /*; modify it under the terms of the GNU General Public License as */ /*; published by the Free Software Foundation; either version 2 of */ /*; the License, or (at your option) any later version. */ /*; */ /*; This program is distributed in the hope that it will be useful, */ /*; but WITHOUT ANY WARRANTY; without even the implied warranty of */ /*; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /*; GNU General Public License for more details. */ /*; */ /*; You should have received a copy of the GNU General Public */ /*; License along with this program; if not, write to the Free */ /*; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, */ /*; MA 02139, USA. */ /*; */ /*; Correspondence concerning AIPS should be addressed as follows: */ /*; Internet email: aipsmail@nrao.edu. */ /*; Postal address: AIPS Project Office */ /*; National Radio Astronomy Observatory */ /*; 520 Edgemont Road */ /*; Charlottesville, VA 22903-2475 USA */ /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/ #include "xas.h" int imwrt() /* IMWRT Writes an image plane or a graphics plane to the internal xas*/ /* arrays, then displays the array on the screen. */ /* used by the aips VERBS TVLOD TVMOVIE */ /* Modified to record when data is displayed */ { register int i, npix; int xs, ys, iangl, channel, j, k, vv; unsigned char goffset,ioffset; /*--------------------------------------------------------------------*/ channel = xbuf.parms[2]; if ((channel < 1) || (channel > NGRTOT)) { fprintf (stderr, "XAS: Bad imwrt channel = %d\n", channel); return (-1); } else { /* Else channel OK */ TvStatus[channel-1] = 1; /* record Data put on TV */ } /* End if channel number bad */ npix = xbuf.data_length; iangl = xbuf.parms[3]; xs = Memory_x (xbuf.parms[0]); ys = Memory_y (xbuf.parms[1]); goffset = graphics_offset; ioffset = image_offset; gph_mask = 0; if (channel == NGREY+1) gph_mask = 1; if (channel == NGREY+2) gph_mask = 2; if (channel == NGREY+3) gph_mask = 4; if (channel == NGREY+4) gph_mask = 8; if (channel == NGREY+5) gph_mask = 16; if (channel == NGREY+6) gph_mask = 32; if (channel == NGREY+7) gph_mask = 64; if (channel == NGREY+8) gph_mask = 128; j = channel - 1; if (iangl == 0) { if (channel <= NGREY) /* If writing Image */ for (i = 0; i < npix; i++) { XPutPixel (plane[j], xs+i, ys, int2pix[xbuf.data[i]]); } else { /* Else writing graph */ for (i = 0; i < npix; i++) { /* For all pixels in line */ vv = XGetPixel(graph, xs+i, ys); chg_s (vv, xbuf.data[i], gph_mask); XPutPixel (graph, xs+i, ys, vv); } } /* update if visible */ if ((channel == cur_chan) || (rwgraph & gph_mask)) scrwrt (xs, ys, xs + npix, ys); } else if (iangl == 1) { if (channel <= NGREY) for (i = 0; i < npix; i++) { XPutPixel (plane[j], xs, ys-i, int2pix[xbuf.data[i]]); } else { for (i = 0; i < npix; i++) { vv = XGetPixel(graph, xs, ys-i); chg_s (vv, xbuf.data[i], gph_mask); XPutPixel (graph, xs, ys-i, vv); } } if ((channel == cur_chan) || (rwgraph & gph_mask)) scrwrt (xs, ys - npix, xs, ys); } else if (iangl == 2) { if (channel <= NGREY) for (i = 0; i < npix; i++) { XPutPixel (plane[j], xs-i, ys, int2pix[xbuf.data[i]]); } else { for (i = 0; i < npix; i++) { vv = XGetPixel(graph, xs-i, ys); chg_s (vv, xbuf.data[i], gph_mask); XPutPixel (graph, xs-i, ys, vv); } } if ((channel == cur_chan) || (rwgraph & gph_mask)) scrwrt (xs - npix, ys, xs, ys); } else if (iangl == 3) { if (channel <= NGREY) for (i = 0; i < npix; i++) { XPutPixel (plane[j], xs, ys+i, int2pix[xbuf.data[i]]); } else { for (i = 0; i < npix; i++) { vv = XGetPixel(graph, xs, ys+i); chg_s (vv, xbuf.data[i], gph_mask); XPutPixel (graph, xs, ys+i, vv); } } if ((channel == cur_chan) || (rwgraph & gph_mask)) scrwrt (xs, ys, xs, ys + npix); } return (0); } /* end imwrt */ int imrd (nwpix) /*--------------------------------------------------------------------*/ /* This subroutine returns an image line to the client. */ /*--------------------------------------------------------------------*/ short int *nwpix; /*--------------------------------------------------------------------*/ { int xs, ys, iangl, channel, j, vv; short int jj; register int i, npix; /*--------------------------------------------------------------------*/ xs = Memory_x (xbuf.parms[0]); ys = Memory_y (xbuf.parms[1]); channel = xbuf.parms[2]; iangl = xbuf.parms[3]; /* special I*2 word in buffer */ jj = *((short int *)xbuf.data); npix = ntohs (jj); *nwpix = npix; if ((channel < 1) || (channel > NGRTOT)) { fprintf (stderr, "XAS: Bad imrd channel = %d\n", channel); return (-1); } gph_mask = 0; if (channel == NGREY+1) gph_mask = 1; if (channel == NGREY+2) gph_mask = 2; if (channel == NGREY+3) gph_mask = 4; if (channel == NGREY+4) gph_mask = 8; if (channel == NGREY+5) gph_mask = 16; if (channel == NGREY+6) gph_mask = 32; if (channel == NGREY+7) gph_mask = 64; if (channel == NGREY+8) gph_mask = 128; j = channel - 1; if (iangl == 0) { if (channel <= NGREY) for (i = 0; i < npix; i++) { ybuf.data[i] = pix2int[XGetPixel (plane[j], xs+i, ys)]; } else for (i = 0; i < npix; i++) { ybuf.data[i] = chg_g (XGetPixel (graph, xs+i, ys), gph_mask); } } else if (iangl == 1) { if (channel <= NGREY) for (i = 0; i < npix; i++) { ybuf.data[i] = pix2int[XGetPixel (plane[j], xs, ys-i)]; } else for (i = 0; i < npix; i++) { ybuf.data[i] = chg_g (XGetPixel (graph, xs, ys-i), gph_mask); } } if (iangl == 2) { if (channel <= NGREY) for (i = 0; i < npix; i++) { ybuf.data[i] = pix2int[XGetPixel (plane[j], xs-i, ys)]; } else for (i = 0; i < npix; i++) { ybuf.data[i] = chg_g (XGetPixel (graph, xs-i, ys), gph_mask); } } else if (iangl == 3) { if (channel <= NGREY) for (i = 0; i < npix; i++) { ybuf.data[i] = pix2int[XGetPixel (plane[j], xs, ys+i)]; } else for (i = 0; i < npix; i++) { ybuf.data[i] = chg_g (XGetPixel (graph, xs, ys+i), gph_mask); } } return (0); } void resize_canvas (width, height, ix0, iy0) /*--------------------------------------------------------------------*/ /* checks canvas size and position */ /*--------------------------------------------------------------------*/ int width, height, ix0, iy0; /*--------------------------------------------------------------------*/ { int icx, icy, itx, ity; icx = ix0; icy = iy0; itx = width; ity = height; /* set widths */ sc_width = min (itx, Screen_Width); sc_height = min (ity, Screen_Height); sc_width2 = sc_width / 2; sc_height2 = sc_height / 2; /* set center coords */ sc_centre_x = max (sc_centre_x, sc_width2 - 1); sc_centre_y = max (sc_centre_y, sc_height2 - 1); sc_centre_x = min (sc_centre_x, Screen_Width - sc_width2 - 1); sc_centre_y = min (sc_centre_y, Screen_Height - sc_height2 - 1); /* check frame coords */ itx = sc_width; ity = sc_height; icx += bwid; icy += bwid; icx = max (icx, SCREEN_LEFT); icy = max (icy, SCREEN_TOP); icx = min (icx, twidth - SCREEN_RIGHT - itx) - bwid; icy = min (icy, theight - SCREEN_BOTTOM - ity) - bwid; /* resize, bring into view */ if (/*(ix0 != icx) || (iy0 != icy) ||*/ (width != itx) || (height != ity)) { Cur_Xsize = itx; Cur_Ysize = ity; XResizeWindow (display, win, itx, ity); if (XasDebug) fprintf (stderr, "force resize_canvas: W H %d %d\n", itx, ity); /* Cur_Xzero = icx; Cur_Yzero = icy; */ } return; } /* end resize_canvas */ void resize_pressed() /*--------------------------------------------------------------------*/ /* Toggle between full screen and smaller window set by the window */ /* manager. */ /*--------------------------------------------------------------------*/ { int itx, ity, icx, icy; big_screen = !big_screen; if (big_screen) { cur_xcorn = Cur_Xzero + bwid; cur_ycorn = Cur_Yzero + bwid; cur_xsize = Cur_Xsize; cur_ysize = Cur_Ysize; itx = Screen_Width; ity = Screen_Height; icx = 0; icy = 0; } else { itx = cur_xsize; ity = cur_ysize; icx = cur_xcorn; icy = cur_ycorn; } icx = max (icx, SCREEN_LEFT); icy = max (icy, SCREEN_TOP); icx = min (icx, twidth - SCREEN_RIGHT - itx) - bwid; icy = min (icy, theight - SCREEN_BOTTOM - ity) - bwid; Cur_Xzero = icx; Cur_Yzero = icy; Cur_Xsize = itx; Cur_Ysize = ity; /* XResizeWindow (display, win, itx, ity); if (XasDebug) fprintf (stderr, "resize_pressed: W H, %d %d\n", itx, ity); */ XMoveResizeWindow (display, win, icx, icy, itx, ity); if (XasDebug) fprintf (stderr, "resize_pressed: W H, X Y %d %d, %d %d\n", itx, ity, icx, icy); return; } int windo_status() /*--------------------------------------------------------------------*/ /* Returns current window corners */ /*--------------------------------------------------------------------*/ { int itx, ity, icx, icy; /*--------------------------------------------------------------------*/ /* force screen size */ if (xbuf.parms[0] > 0 && xbuf.parms[1] > 0 && xbuf.parms[2] > 0 && xbuf.parms[3] > 0) { xbuf.parms[2] = min (xbuf.parms[2], Screen_Width); xbuf.parms[3] = min (xbuf.parms[3], Screen_Height); icx = Memory_x (xbuf.parms[0]); itx = Memory_x (xbuf.parms[2]); icy = Memory_y (xbuf.parms[3]); ity = Memory_y (xbuf.parms[1]); sc_width = itx - icx + 1; sc_height = ity - icy + 1; sc_centre_x = (icx + itx - 1) / 2; sc_centre_y = (icy + ity - 1) / 2; sc_width2 = sc_width / 2; sc_height2 = sc_height / 2; itx = sc_width; ity = sc_height; icx = Cur_Xzero + bwid; icy = Cur_Yzero + bwid; icx = max (icx, SCREEN_LEFT); icy = max (icy, SCREEN_TOP); icx = min (icx, twidth - SCREEN_RIGHT - itx) - bwid; icy = min (icy, theight - SCREEN_BOTTOM - ity) - bwid; Cur_Xzero = icx; Cur_Yzero = icy; Cur_Xsize = itx; Cur_Ysize = ity; /* XResizeWindow (display, win, itx, ity); if (XasDebug) fprintf (stderr, "windo_status: W H %d %d\n", itx, ity); */ XMoveResizeWindow (display, win, icx, icy, itx, ity); if (XasDebug) fprintf (stderr, "windo_status: W H, X Y %d %d, %d %d\n", itx, ity, icx, icy); } ybuf.data[0] = Aips_x (sc_centre_x - sc_width2 + 1); ybuf.data[3] = Aips_y (sc_centre_y - sc_height2 + 1); ybuf.data[2] = Aips_x (sc_centre_x + sc_width2); ybuf.data[1] = Aips_y (sc_centre_y + sc_height2); return (0); } int Interogate (nparms) /*--------------------------------------------------------------------*/ /* This subroutine returns the critical parameters of the TV to the */ /* client in the order of DTVC.INC */ /*--------------------------------------------------------------------*/ short int *nparms; /*--------------------------------------------------------------------*/ { *nparms = 29; ybuf.data[0] = NGREY; ybuf.data[1] = NGRAPH; ybuf.data[2] = -1; ybuf.data[3] = Screen_Width; ybuf.data[4] = Screen_Height; ybuf.data[5] = NColour - 1; ybuf.data[6] = (NINTENS) - 1; ybuf.data[7] = (NINTENS) - 1; ybuf.data[8] = (NINTENS) - 1; ybuf.data[9] = 1; ybuf.data[10] = 1; ybuf.data[11] = 1 - (MAXZOOM); ybuf.data[12] = -1; ybuf.data[13] = -1; ybuf.data[14] = 0; ybuf.data[15] = 0; ybuf.data[16] = 3; ybuf.data[17] = 3; ybuf.data[18] = -1; ybuf.data[19] = -1; ybuf.data[20] = -1; ybuf.data[21] = -1; ybuf.data[22] = -1; ybuf.data[23] = -1; ybuf.data[24] = -1; ybuf.data[25] = -1; ybuf.data[26] = -1; ybuf.data[27] = -1; ybuf.data[28] = -1; return (0); } int ClearChan() /*--------------------------------------------------------------------*/ /* ClearChan clears both graphics and image planes, if requested */ /* Performs AIPS VERBS TVINIT, GRCLEAR */ /* Inputs */ /* channel I If Channel is 0, all images and graphics cleared */ /* If Channel <= NGREY then one images is cleared */ /* If Channel > NGREY then one graph is cleared */ /* If Channel = NGRTOT+1 then clear all graphs only */ /* Modified to clear more rapidly if only one graph plane is on */ { Bool OnlyWritten; int channel, imax, izero; register int i, j, k; char *t1, *t2; channel = xbuf.parms[0]; /* If channel invalid, exit */ if ((channel < 0) || (channel > NGRTOT+1)) return (-1); /* If only one graph and already cleared */ /* If clearing channel=0, clear all for safty sake (no return) */ if (channel > 0 && channel <= NGRTOT && TvStatus[channel-1] == 0) { return (0); /* already done, return okay */ } if (channel == 0) { /* if clearing all channels */ OnlyWritten = True; for (j=0; j < NGRTOT; j++) TvStatus[j] = 0; /* tell all are un-written */ } else { /* else clearing only some */ if (channel == NGRTOT+1) { /* if clearing all graphs */ OnlyWritten = True; for (j=NGREY; j < NGRTOT; j++) TvStatus[j] = 0; /* tell graphs is clear */ } else { /* clearing one graph */ TvStatus[channel-1] = 0; /* record Data put on TV */ OnlyWritten = True; /* Assume only this 1 written */ for (j=NGREY; j < NGRAPH+NGREY; j++) { /* If data in other graphics */ if ((j != channel-1) && (TvStatus[j] != 0)) OnlyWritten = False; } } /* End if all graphs off */ } /* End if all channels off */ imax = Screen_Width * Screen_Height * ((depth+1)/8); izero = int2pix[0]; for (j = 0; j < NGREY; j++) { /* Clear Image */ if ((channel == 0) || (channel == j+1)) { if (depth == 8) { /* special depth, quick clear */ t1 = plane_data[j]; for (i = 0; i < imax; i++) *t1++ = izero; /* set pixel to zero */ } else { /* Else slow clear */ for (i = 0; i < Screen_Width; i++) { for (k = 0; k < Screen_Height; k++) XPutPixel (plane[j], i, k, izero); } } } } if (channel == 0 || OnlyWritten) { /* If clearing all graphs */ t2 = graph_data; /* Clear graphics data */ for (i = 0; i < imax; i++) *t2++ = 0; } else { /* Else clearing only 1 graph */ if (channel > NGREY) { gph_mask = 255; /* set mask to all but channel*/ if (channel == NGREY + 1) gph_mask = 254; if (channel == NGREY + 2) gph_mask = 253; if (channel == NGREY + 3) gph_mask = 251; if (channel == NGREY + 4) gph_mask = 247; if (channel == NGREY + 5) gph_mask = 239; if (channel == NGREY + 6) gph_mask = 223; if (channel == NGREY + 7) gph_mask = 191; if (channel == NGREY + 8) gph_mask = 127; t2 = graph_data; /* point to begin graph plane */ for (i = 0; i < imax; i++) /* for all pixels in graph pl */ *t2++ = *t2 & gph_mask; /* zero this graph */ } /* End if clear only one graph*/ } /* End if clering all */ scrwrt (0, 0, Screen_Width - 1, Screen_Height - 1); return (0); } int ViewData() /*--------------------------------------------------------------------*/ /* turns on/off command buffering by scrwrt() */ /*--------------------------------------------------------------------*/ { if ((scrhold) && (xbuf.parms[0] == 0)) { scrhold = 0; if (numhold > 0) scrwrt (uxs, uys, uxe, uye); numhold = 0; uxe = uye = 0; uxs = Screen_Width; uys = Screen_Height; } scrhold = xbuf.parms[0] ; if (Maxhold <= 1) scrhold = 0; return (0); } int zoom() /*--------------------------------------------------------------------*/ /* Sets the zoom registers */ /*--------------------------------------------------------------------*/ { int i; /*--------------------------------------------------------------------*/ if ((xbuf.parms[0] < 0) || (xbuf.parms[0] > NGRTOT)) { fprintf (stderr, "XAS: Illegal zoom channel %d\n", xbuf.parms[0]); return (-1); } else if (xbuf.parms[0] > NGREY) { if (cur_chan < 1) scrwrt (0, 0, Screen_Width - 1, Screen_Height - 1); } else if (xbuf.parms[0] == 0) { upleft_mag = xbuf.parms[1]; for (i = 0; i < NGREY; i++) { upleft_x[i] = xbuf.parms[2]; upleft_y[i] = xbuf.parms[3]; } scrwrt (0, 0, Screen_Width - 1, Screen_Height - 1); } else { upleft_mag = xbuf.parms[1]; upleft_x[xbuf.parms[0]-1] = xbuf.parms[2]; upleft_y[xbuf.parms[0]-1] = xbuf.parms[3]; if (xbuf.parms[0] == cur_chan) scrwrt (0, 0, Screen_Width - 1, Screen_Height - 1); } return (0); } --XYZZY-- cat > init.c << --XYZZY-- /*--------------------------------------------------------------------*/ /*! XAS initialization routines */ /*# TV-IO */ /*--------------------------------------------------------------------*/ /*; Copyright (C) 1995, 1996 */ /*; Associated Universities, Inc. Washington DC, USA. */ /*; */ /*; This program is free software; you can redistribute it and/or */ /*; modify it under the terms of the GNU General Public License as */ /*; published by the Free Software Foundation; either version 2 of */ /*; the License, or (at your option) any later version. */ /*; */ /*; This program is distributed in the hope that it will be useful, */ /*; but WITHOUT ANY WARRANTY; without even the implied warranty of */ /*; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /*; GNU General Public License for more details. */ /*; */ /*; You should have received a copy of the GNU General Public */ /*; License along with this program; if not, write to the Free */ /*; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, */ /*; MA 02139, USA. */ /*; */ /*; Correspondence concerning AIPS should be addressed as follows: */ /*; Internet email: aipsmail@nrao.edu. */ /*; Postal address: AIPS Project Office */ /*; National Radio Astronomy Observatory */ /*; 520 Edgemont Road */ /*; Charlottesville, VA 22903-2475 USA */ /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/ #include "xas.h" #include extern XLink; /*--------------------------------------------------------------------*/ /* Icon position request flag - set to 1 if the user has requested an */ /* initial icon position. */ static int ic_pos_request; /* Error Handler for I/O */ #define ERRMSGLEN 80 /* Max. length of an error message */ int XAS_IOHandler (display, XAS_Error_Event) Display *display; XErrorEvent *XAS_Error_Event; { char msg[ERRMSGLEN+1]; /*--------------------------------------------------------------------*/ /* If there are events pending the server connection was probably */ /* broken by the server. In this case XAS_Error_Event will be garbage*/ /* and will cause a core dump if used in the call to get error text. */ /* If there are no pending events this is assumed to be a normal */ /* shutdown and no message will be displayed. */ if (XPending(display) != 0) { XGetErrorText (display, XAS_Error_Event->error_code, msg, ERRMSGLEN); fprintf (stderr, "XAS: Received error code %d, %s\n", XAS_Error_Event->error_code, msg); } closedown(); exit(42); return (42); } void init() { int i; union { short int shortint; struct { unsigned char lo, hi; }byte; }x; XasDebug = False; XDebug = False; connected = False; /* check for byte swapped */ x.shortint = 17; /* any small number will do */ if (x.shortint == x.byte.lo) ByteSwapped = True; else ByteSwapped = False; button_a = button_b = button_c = button_d = 0; cur_chan = 1; /* channel 1 on, graphics off */ rwgraph = 0; for (i = 0; i < NGREY; i++) upleft_x[i] = upleft_y[i] = 0; for (i = 0; i < NGREY; i++) /* TV channels are off */ TvStatus[i] = 0; for (i = 0; i < NGRAPH; i++) /* Graphics channels are off */ TvStatus[i+NGREY] = 0; upleft_mag = 1; /* Default, buffer none */ for (i = 0; i < (NUMOP+1); i++) bufferop[i] = False; size_i2 = sizeof(short int); return; } void SetupWindow (argc, argv) int argc; char *argv[]; { int offset = 0; int x = 0, y = 0; /* window position */ unsigned int border_width = 2; /* border 2 pixels wide */ unsigned long GCmask = 0; /* ignore XGCValues, use defaults */ char *window_name = "X-AIPS TV-Screen-Server"; /* char *icon_name = "xaips"; */ char *icon_name = "AIPS TV"; char *display_name = NULL; unsigned long event_mask, value_mask; Pixmap icon_pixmap; static unsigned char icon_image[512] = /* icon data */ { #include "Xas.icon" }; unsigned long icon_xsize = 64; unsigned long icon_ysize = 48; XWMHints wm_hints; XSizeHints size_hints; XClassHint class_hints; XGCValues values; XSetWindowAttributes WinAtt; double xx, yy, zz; Visual *defauvis; /* type of visual root window */ XVisualInfo template; /* type of visual XAS uses */ XVisualInfo *vislist; /* list of visuals matching */ /* the template */ int nvis; /* number of visuals in list */ XGCValues gc_values; /* X11 graphics context */ /* template */ unsigned long plane_masks[15]; /* plane masks from XAlloc- */ /* Colorcells. */ int mjr, mnr, pixmaps; /* Dummy variables for SHM */ register int i, j, k; int icx, icy, imax, izero, notdefault, vok; char *t1, *t2; unsigned long curs_pixel[2]; XIOErrorHandler old_handler; /* Pointer to old I/O error */ /* handler */ /*--------------------------------------------------------------------*/ /* connect to X server */ if ((display = XOpenDisplay (display_name)) == NULL) { fprintf (stderr, "XAS: cannot connect to X server %s\n", XDisplayName(display_name)); exit (-1); } /* get root screen number */ screen_num = DefaultScreen (display); /* set up I/O error handler */ #ifndef X11R3 old_handler = #endif XSetIOErrorHandler (XAS_IOHandler); /* get root (full) screen size*/ theight = DisplayHeight (display, screen_num); twidth = DisplayWidth (display, screen_num); /* Check that the server has sufficient depth for our needs */ if ((depth = DisplayPlanes (display, screen_num)) < 6) { (void) fprintf (stderr, "XAS: X server color table too small\n"); (void) fprintf (stderr, "XAS: Image display not possible\n"); (void) fprintf (stderr, "XAS: Exiting...\n"); exit (-1); } if (depth > 8) { fprintf (stderr, "XAS: **************************************\n"); fprintf (stderr, "XAS: ** depth = %d > 8!", depth); fprintf (stderr, "XAS: ** Sorry, must limit to 8\n"); fprintf (stderr, "XAS: ** due to 1-character limit of ZSSSX2.\n"); fprintf (stderr, "XAS: **************************************\n"); depth = 8; } defauvis = DefaultVisual (display, screen_num); template.screen = DefaultScreen(display); template.depth = depth; template.class = PseudoColor; vislist = XGetVisualInfo (display, VisualScreenMask|VisualDepthMask| VisualClassMask, &template, &nvis); if (nvis == 0) { fprintf (stderr, "XAS: No pseudocolor visual"); template.class = GrayScale; vislist = XGetVisualInfo (display, VisualScreenMask | VisualDepthMask | VisualClassMask, &template, &nvis); if (nvis == 0) { perror (" - No suitable visual"); exit (1); } fprintf (stderr, "XAS: - using GrayScale visual instead\n"); } if (nvis > 1) { for (i = 0; i < nvis; i++) { if (vislist[i].visualid == defauvis->visualid) visnum = i; } } else visnum = 0; /* Attempt to allocate colours */ /* from default colourmap */ TV_colour = DefaultColormap (display, DefaultScreen(display)); notdefault = 0; /* create color map if nec. */ if (defauvis->class != vislist[visnum].class) { fprintf (stderr, "XAS: Visual not = default, create colormap\n"); TV_colour = XCreateColormap (display, RootWindow (display, screen_num), vislist[visnum].visual, AllocAll); notdefault = 1; } /* screen size details */ Screen_Width = twidth - SCREEN_LEFT - SCREEN_RIGHT; Screen_Height = theight - SCREEN_TOP - SCREEN_BOTTOM; Screen_Width = (Screen_Width / 2) * 2; Screen_Height = (Screen_Height / 2) * 2; NValue = 1 << depth; NValue = NValue - 40; /* be considerate, leave some */ NValue = min (NValue, 256); /* ZSSSX2 uses 8-bit chars */ NColour = NValue - NGRPHCOL; /* Get cursor graphics colours*/ ic_height = max (icon_xsize, icon_ysize); ic_width = ic_height; user_options (argc, argv); i = NColour - 1; fprintf (stderr,"XAS: Using screen width height %d %d,", Screen_Width, Screen_Height); fprintf (stderr," max grey level %d\n", i); /* init gph table */ for (i = 0; i < 256; i +=16) { for (j = 0; j < 16; j++) grfvc[i+j] = j; if (i != 0) grfvc[i] = 16; } grfvc[32] = grfvc[96] = grfvc[160] = grfvc[224] = 17; grfvc[64] = grfvc[192] = 18; grfvc[128] = 19; scrhold = numhold = uxe = uye = 0; uxs = Screen_Width; uys = Screen_Height; /* create opaque window */ value_mask = CWBorderPixel | CWBackPixel | CWBitGravity; WinAtt.border_pixel = curs_pixel[0] = WhitePixel (display, screen_num); WinAtt.background_pixel = curs_pixel[1] = BlackPixel (display, screen_num); WinAtt.bit_gravity = CenterGravity; if (defauvis->class != vislist[visnum].class) { WinAtt.colormap = TV_colour; value_mask |= CWColormap ; } win = XCreateWindow (display, RootWindow(display,screen_num), x, y, Screen_Width, Screen_Height, border_width, depth, InputOutput, vislist[visnum].visual, value_mask, &WinAtt); if (defauvis->class != vislist[visnum].class) XSetWindowColormap (display, win, TV_colour); #ifdef AIX bwid = 0; #else bwid = border_width; #endif /* create pixmap of depth 1 */ /* (bitmap) for icon */ #if __STDC__ icon_pixmap = XCreateBitmapFromData (display, win, (const char *)icon_image, icon_xsize, icon_ysize); #else icon_pixmap = XCreateBitmapFromData (display, win, (char *)icon_image, icon_xsize, icon_ysize); #endif /* set size, class, other */ /* hints for Window Manager */ size_hints.min_width = 16; size_hints.min_height = 16; size_hints.max_width = Screen_Width; size_hints.max_height = Screen_Height; size_hints.flags = PMinSize | PMaxSize; /* Assure keyboard input */ wm_hints.input = True; wm_hints.initial_state = IconicState ; wm_hints.flags = InputHint | StateHint | IconPixmapHint; if (ic_pos_request) wm_hints.flags |= IconPositionHint; wm_hints.icon_pixmap = icon_pixmap; wm_hints.icon_x = ic_xcorn; wm_hints.icon_y = ic_ycorn; class_hints.res_name = ProgName; class_hints.res_class = "AIPSServer" ; #ifdef X11R3 /* X11 Release 3 or earlier */ size_hints.x = cur_xcorn + SCREEN_LEFT - bwid; size_hints.y = cur_ycorn + SCREEN_TOP - bwid; size_hints.width = sc_width; size_hints.height = sc_height; size_hints.flags |= (PPosition | PSize); /* set properties for window */ /* manager (before mapping) */ XSetStandardProperties (display, win, window_name, icon_name, icon_pixmap, argv, argc, &size_hints); XSetWMHints (display, win, &wm_hints); XSetClassHint (display, win, &class_hints); #else /* X11 Release 4 or later */ { XTextProperty windowName, iconName; if (XStringListToTextProperty (&window_name, 1, &windowName) == 0) { fprintf (stderr, "XAS: structure allocation for windowName fails\n"); exit (-1); } if (XStringListToTextProperty (&icon_name, 1, &iconName) == 0) { fprintf (stderr, "XAS: structure allocation for iconName fails\n"); exit (-1); } XSetWMProperties (display, win, &windowName, &iconName, argv, argc, &size_hints, &wm_hints, &class_hints); } #endif /* select event types wanted */ event_mask = ExposureMask | KeyPressMask | StructureNotifyMask | ButtonPressMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask; XSelectInput (display, win, event_mask); /* create all the images */ #ifdef USE_SHM if (using_shm) { for (i = 0; i < NGREY; i++) { plane[i] = XShmCreateImage (display, vislist[visnum].visual, depth, ZPixmap, NULL, &plane_info[i], Screen_Width, Screen_Height); if ((plane_info[i].shmid = shmget (IPC_PRIVATE, (plane[i]->bytes_per_line * plane[i]->height), IPC_CREAT|0777)) == -1 ) { perror ("Shared memory id failure"); exit (1); } plane_info[i].shmaddr = plane[i]->data = plane_data[i] = shmat (plane_info[i].shmid, NULL, 0); plane_info[i].readOnly = False; if (XShmAttach (display, &plane_info[i]) == False) { perror ("Shared memory attach failed"); exit (1); } } graph = XShmCreateImage (display, vislist[visnum].visual, depth, ZPixmap, NULL, &graph_info, Screen_Width, Screen_Height); if ((graph_info.shmid = shmget (IPC_PRIVATE, (graph->bytes_per_line * graph->height), IPC_CREAT|0777)) == -1) { perror ("Shared memory id failure"); exit (1); } graph_info.shmaddr = graph->data = graph_data = shmat (graph_info.shmid, NULL, 0); graph_info.readOnly = False; if (XShmAttach (display, &graph_info) == False ) { perror ("Shared memory attach failed"); exit (1); } line = XShmCreateImage (display, vislist[visnum].visual, depth, ZPixmap, NULL, &line_info, Screen_Width, Screen_Height); if ((line_info.shmid = shmget (IPC_PRIVATE, (line->bytes_per_line * line->height), IPC_CREAT|0777)) ==-1) { perror ("Shared memory id failure"); exit (1); } line_info.shmaddr = line->data = line_data = shmat (line_info.shmid, NULL, 0); line_info.readOnly = False; if ( XShmAttach (display, &line_info) == False ) { perror ("Shared memory attach failed"); exit (1); } } else { #endif /* USE_SHM */ for (i = 0; i < NGREY; i++) { plane_data[i] = (char*) malloc (Screen_Width * Screen_Height * ((depth+1) / 8)); plane[i] = XCreateImage (display, vislist[visnum].visual, depth, ZPixmap, offset, plane_data[i], Screen_Width, Screen_Height, 8, 0); } graph_data = (char*) malloc (Screen_Width * Screen_Height * ((depth+1)/8)); graph = XCreateImage (display, vislist[visnum].visual, depth, ZPixmap, offset, graph_data, Screen_Width, Screen_Height, 8, 0) ; line_data = (char*) malloc (Screen_Width * Screen_Height * ((depth+1)/8)); line = XCreateImage (display, vislist[visnum].visual, depth, ZPixmap, offset, line_data, Screen_Width, Screen_Height, 8, 0); #ifdef USE_SHM } #endif /* Allocate space for lookups */ for (i = 0; i < NGREY; i++) { rlut[i] = (int *) malloc (NColour * (sizeof (int))); glut[i] = (int *) malloc (NColour * (sizeof (int))); blut[i] = (int *) malloc (NColour * (sizeof (int))); } int2pix = (unsigned long int *) malloc (NValue*(sizeof (long int))); pix2int = (int *) malloc ((1 << depth) * (sizeof (int))); /* Allocate space for the */ /* colour table: */ if ((colour_table = (XColor *) malloc (vislist[visnum].colormap_size * sizeof(XColor))) == NULL) { perror ("Cannot allocate space for colour table"); exit (-1); } /* Attempt to allocate colors */ /* from default colormap */ if (!notdefault) { if (XAllocColorCells (display, TV_colour, True, plane_masks, 0, int2pix, NValue) == 0) { /* Attempt failed --- create a */ /* new (virtual) color map and */ /* install it as the color map */ /* for the AIPS TV: */ fprintf (stderr, "XAS: Warning -- creating virtual colormap\n"); TV_colour = XCreateColormap (display, win, vislist[visnum].visual, AllocAll); notdefault = 1; } } /* Copy colours from default */ /* colourmap to virtual */ /* colourmap (retains as much */ /* of the rest of the screen */ /* as possible): */ if (notdefault) { for (i = 0; i < vislist[visnum].colormap_size; i++) { colour_table[i].pixel = i; colour_table[i].flags = DoRed | DoGreen | DoBlue; } XQueryColors (display, DefaultColormap(display, DefaultScreen(display)), colour_table, vislist[visnum].colormap_size); XStoreColors (display, TV_colour, colour_table, vislist[visnum].colormap_size); /* Avoid the basic colors */ OColour = vislist[visnum].colormap_size - NValue; j = 0; i = 0 ; for (j = 0; j < NValue+OColour; j++) { vok = 0; for (k = 0; k < OColour; k++) if (j == colour_table[k].pixel) vok++; if (vok == 0) int2pix[i++] = j; } /* Install the colourmap and */ /* let the window manager */ /* know that we want our own */ /* colour map on the canvas */ /* and the default colour map */ /* on the button panel: */ XSetWindowColormap (display, win, TV_colour); } /* reverse translation */ for (i = 0; i < NValue; i++) pix2int[int2pix[i]] = i; /* Set graphics contexts: */ gc_values.function = GXcopy; gc_values.plane_mask = AllPlanes; ImageGC = XCreateGC (display, win, GCFunction | GCPlaneMask, &gc_values); /* create cursor for window */ cursor = XCreateFontCursor (display, cursor_shape); XDefineCursor (display, win, cursor); /* color the cursor */ fg_curs.red = rgcol[19] << COLORSHIFT; fg_curs.green = ggcol[19] << COLORSHIFT; fg_curs.blue = bgcol[19] << COLORSHIFT; bg_curs.red = 0; bg_curs.green = 0; bg_curs.blue = 0; fg_curs.flags = DoRed | DoGreen | DoBlue; bg_curs.flags = DoRed | DoGreen | DoBlue; fg_curs.pixel = int2pix[NColour + 19]; bg_curs.pixel = int2pix[0]; XRecolorCursor (display, cursor, &fg_curs, &bg_curs); /* specify foreground since */ /* else may be white on white */ XSetForeground (display, ImageGC, BlackPixel(display, screen_num)); /* set initial sizes */ Cur_Xzero = cur_xcorn - bwid; Cur_Yzero = cur_ycorn - bwid; Cur_Xsize = cur_xsize = sc_width; Cur_Ysize = cur_ysize = sc_height; sc_width2 = sc_width/2; sc_height2 = sc_height/2; sc_centre_x = Screen_Width/2 - 1; sc_centre_y = Screen_Height/2 - 1; big_screen = False; XMoveResizeWindow (display, win, Cur_Xzero, Cur_Yzero, Cur_Xsize, Cur_Ysize); /* set OFM, Gamma = 2.2 */ yy = NINTENS - 1; zz = 1.0 / 2.2; for (i = 0; i < NINTENS; i++) { xx = i / yy; rofm[i] = gofm[i] = bofm[i] = yy * pow (xx, zz); } /* "zero" fill memories */ imax = Screen_Width * Screen_Height * ((depth+1)/8); izero = int2pix[0]; for (j = 0; j < NGREY; j++) { if (depth == 8) { t1 = plane_data[j]; for (i = 0; i < imax; i++) *t1++ = izero; } else { for (i = 0; i < Screen_Width; i++) { for (k = 0; k < Screen_Height; k++) XPutPixel (plane[j], i, k, izero); } } } t2 = graph_data; for (i = 0; i < imax; i++) *t2++ = 0; /* Start up the window with a */ /* linear transfer function: */ zz = NColour - 1; zz = yy / zz; for (i = 0; i < NValue; i++) { colour_table[i+OColour].pixel = int2pix[i]; colour_table[i+OColour].flags = DoRed | DoGreen | DoBlue; if (i < NColour) { rlut[0][i] = glut[0][i] = blut[0][i] = i * zz; if (NGREY > 1) { for (j = 1; j < NGREY; j++) rlut[j][i] = glut[j][i] = blut[j][i] = rlut[0][i]; } colour_table[i+OColour].red = colour_table[i+OColour].green = colour_table[i+OColour].blue = rofm[rlut[0][i]] << COLORSHIFT; } else { colour_table[i+OColour].red = rgcol[i-NColour] << COLORSHIFT; colour_table[i+OColour].blue = bgcol[i-NColour] << COLORSHIFT; colour_table[i+OColour].green = ggcol[i-NColour] << COLORSHIFT; } } XStoreColors (display, TV_colour, colour_table, NValue+OColour); XRecolorCursor (display, cursor, &fg_curs, &bg_curs); return; } /* end SetupWindow */ void user_options (argc, argv) int argc; char *argv[]; /*--------------------------------------------------------------------*/ /* Set cursor, graphics colors reading user's .Xdefaults file */ /* Also get the icon and window geometries from the command line or */ /* from the .Xdefaults file. */ /*--------------------------------------------------------------------*/ { char *option, *arg; char *IG, *ig, *WG, *wg, *uwg, *uig, g; char *BasicTV = "AIPStv"; int mjr, mnr, pixmaps; /* Dummy variables for SHM */ int i, j, xx, yy, wasi, wasw, jj; unsigned int ww, hh; long flags; char *xas_hostname, *xas_display; char xas_uc_disp[80]; /*--------------------------------------------------------------------*/ ProgName = argv[0]; cur_xcorn = cur_ycorn = ic_xcorn = ic_ycorn = -99999; sc_width = sc_height = 0; wasi = wasw = 0; /* Geometries */ /* from Command line */ for (i = 1; i < argc; i++) { arg = argv[i]; if (arg[0] == '-') { switch (arg[1]) { case 'I': /* Ig, IconGeometry */ if ((++i < argc) && ((arg[2] == 'g') || (arg[2] == 'c'))) { IG = argv[i]; wasi = wasi + 1; ic_pos_request = 1; } continue; case 'i': /* ig, iconGeometry */ if ((++i < argc) && ((arg[2] == 'g') || (arg[2] == 'c'))) { ig = argv[i]; wasi = wasi + 4; ic_pos_request = 1; } continue; case 'G': /* G, Geometry */ if (++i < argc) { WG = argv[i]; wasw = wasw + 1; } continue; case 'g': /* g, geometry */ if (++i < argc) { wg = argv[i]; wasw = wasw + 4; } continue; default: continue; } } } /* and/or from .Xdefaults */ option = XGetDefault (display, BasicTV, "geometry"); if (option) { wasw = wasw + 2; uwg = option; } option = XGetDefault (display, BasicTV, "iconGeometry"); if (option) { wasi = wasi + 2; uig = option; ic_pos_request = 1; } /* parse the window geometry */ if (wasw & 4) { flags = XParseGeometry (wg, &xx, &yy, &ww, &hh); if ((XValue & flags) && (cur_xcorn < 0)) { if (XNegative & flags) xx = -xx; if ((xx >= 0) && (xx < Screen_Width)) { if (XNegative & flags) cur_xcorn = Screen_Width + xx; else cur_xcorn = xx; } } if ((YValue & flags) && (cur_ycorn < 0)) { if (YNegative & flags) yy = -yy; if ((yy >= 0) && (yy < Screen_Height)) { if (YNegative & flags) cur_ycorn = Screen_Height + yy; else cur_ycorn = yy; } } if ((WidthValue & flags) && (sc_width <= 0)) { if ((ww > 0) && (ww <= Screen_Width)) sc_width = ww; } if ((HeightValue & flags) && (sc_height <= 0)) { if ((hh > 0) && (hh <= Screen_Height)) sc_height = hh; } } if (wasw & 2) { flags = XParseGeometry (uwg, &xx, &yy, &ww, &hh); if ((XValue & flags) && (cur_xcorn < 0)) { if (XNegative & flags) xx = -xx; if ((xx >= 0) && (xx < Screen_Width)) { if (XNegative & flags) cur_xcorn = Screen_Width + xx; else cur_xcorn = xx; } } if ((YValue & flags) && (cur_ycorn < 0)) { if (YNegative & flags) yy = -yy; if ((yy >= 0) && (yy < Screen_Height)) { if (YNegative & flags) cur_ycorn = Screen_Height + yy; else cur_ycorn = yy; } } if ((WidthValue & flags) && (sc_width <= 0)) { if ((ww > 0) && (ww <= Screen_Width)) sc_width = ww; } if ((HeightValue & flags) && (sc_height <= 0)) { if ((hh > 0) && (hh <= Screen_Height)) sc_height = hh; } } if (wasw & 1) { flags = XParseGeometry (WG, &xx, &yy, &ww, &hh); if ((XValue & flags) && (cur_xcorn < 0)) { if (XNegative & flags) xx = -xx; if ((xx >= 0) && (xx < Screen_Width)) { if (XNegative & flags) cur_xcorn = Screen_Width + xx; else cur_xcorn = xx; } } if ((YValue & flags) && (cur_ycorn < 0)) { if (YNegative & flags) yy = -yy; if ((yy >= 0) && (yy < Screen_Height)) { if (YNegative & flags) cur_ycorn = Screen_Height + yy; else cur_ycorn = yy; } } if ((WidthValue & flags) && (sc_width <= 0)) { if ((ww > 0) && (ww <= Screen_Width)) sc_width = ww; } if ((HeightValue & flags) && (sc_height <= 0)) { if ((hh > 0) && (hh <= Screen_Height)) sc_height = hh; } } if (sc_width <= 0) sc_width = 518; if (sc_height <= 0) sc_height = 518; cur_xcorn = max (0, cur_xcorn); cur_ycorn = max (0, cur_ycorn); if (cur_xcorn >= Screen_Width) cur_xcorn = twidth - SCREEN_RIGHT + Screen_Width - cur_xcorn - sc_width; if (cur_ycorn >= Screen_Height) cur_ycorn = theight - SCREEN_BOTTOM + Screen_Height - cur_ycorn - sc_height; cur_xcorn = cur_xcorn + SCREEN_LEFT; cur_ycorn = cur_ycorn + SCREEN_TOP; cur_xcorn = min (cur_xcorn, twidth - SCREEN_RIGHT - sc_width); cur_ycorn = min (cur_ycorn, theight - SCREEN_BOTTOM - sc_height); if (XasDebug) fprintf (stderr,"Initial window w,h,x,y %d %d %d %d\n", sc_width, sc_height, cur_xcorn, cur_ycorn); /* parse the icon geometry */ if (wasi & 4) { flags = XParseGeometry (ig, &xx, &yy, &ww, &hh); if ((XValue & flags) && (ic_xcorn < 0)) { if (XNegative & flags) xx = -xx; if ((xx >= 0) && (xx < twidth)) { if (XNegative & flags) ic_xcorn = twidth + xx; else ic_xcorn = xx; } } if ((YValue & flags) && (ic_ycorn < 0)) { if (YNegative & flags) yy = -yy; if ((yy >= 0) && (yy < theight)) { if (YNegative & flags) ic_ycorn = theight + yy; else ic_ycorn = yy; } } } if (wasi & 2) { flags = XParseGeometry (uig, &xx, &yy, &ww, &hh); if ((XValue & flags) && (ic_xcorn < 0)) { if (XNegative & flags) xx = -xx; if ((xx >= 0) && (xx < twidth)) { if (XNegative & flags) ic_xcorn = twidth + xx; else ic_xcorn = xx; } } if ((YValue & flags) && (ic_ycorn < 0)) { if (YNegative & flags) yy = -yy; if ((yy >= 0) && (yy < theight)) { if (YNegative & flags) ic_ycorn = theight + yy; else ic_ycorn = yy; } } } if (wasi & 1) { flags = XParseGeometry (IG, &xx, &yy, &ww, &hh); if ((XValue & flags) && (ic_xcorn < 0)) { if (XNegative & flags) xx = -xx; if ((xx >= 0) && (xx < twidth)) { if (XNegative & flags) ic_xcorn = twidth + xx; else ic_xcorn = xx; } } if ((YValue & flags) && (ic_ycorn < 0)) { if (YNegative & flags) yy = -yy; if ((yy >= 0) && (yy < theight)) { if (YNegative & flags) ic_ycorn = theight + yy; else ic_ycorn = yy; } } } if (ic_xcorn < 0) ic_xcorn = twidth; ic_ycorn = max (0, ic_ycorn); if (ic_xcorn >= twidth) ic_xcorn = 2 * twidth - ic_xcorn - ic_width; if (ic_ycorn >= theight) ic_ycorn = 2 * theight - ic_ycorn - ic_height; ic_xcorn = min (ic_xcorn, twidth - ic_width); ic_ycorn = min (ic_ycorn, theight - ic_height); if (XasDebug) fprintf (stderr, "Initial icon w,h,x,y %d %d %d %d\n", ic_width, ic_height, ic_xcorn, ic_ycorn); /* ONLY from .Xdefaults */ /* cursor shape */ /* 34 => XC_crosshair */ option = XGetDefault (display, BasicTV, "cursorShape"); i = option ? atoi (option) : -1; cursor_shape = ((i >= 0) && (i <= 154)) ? i : 34; cursor_shape = (cursor_shape / 2) * 2; /* cursor colours */ option = XGetDefault (display, BasicTV, "cursorR"); i = option ? atoi (option) : -1; rgrfx[0] = ((i >= 0) && (i <= 255)) ? i : 255; option = XGetDefault (display, BasicTV, "cursorG"); i = option ? atoi (option) : -1; ggrfx[0] = ((i >= 0) && (i <= 255)) ? i : 0; option = XGetDefault (display, BasicTV, "cursorB"); i = option ? atoi (option) : -1; bgrfx[0] = ((i >= 0) && (i <= 255)) ? i : 255; /* graphics colours */ option = XGetDefault (display, BasicTV, "graphics1R"); i = option ? atoi (option) : -1; rgrfx[1] = ((i >= 0) && (i <= 255)) ? i : 255; option = XGetDefault (display, BasicTV, "graphics1G"); i = option ? atoi (option) : -1; ggrfx[1] = ((i >= 0) && (i <= 255)) ? i : 255; option = XGetDefault (display, BasicTV, "graphics1B"); i = option ? atoi (option) : -1; bgrfx[1] = ((i >= 0) && (i <= 255)) ? i : 0; option = XGetDefault (display, BasicTV, "graphics2R"); i = option ? atoi (option) : -1; rgrfx[2] = ((i >= 0) && (i <= 255)) ? i : 16; option = XGetDefault (display, BasicTV, "graphics2G"); i = option ? atoi (option) : -1; ggrfx[2] = ((i >= 0) && (i <= 255)) ? i : 255; option = XGetDefault (display, BasicTV, "graphics2B"); i = option ? atoi (option) : -1; bgrfx[2] = ((i >= 0) && (i <= 255)) ? i : 0; option = XGetDefault (display, BasicTV, "graphics3R"); i = option ? atoi (option) : -1; rgrfx[3] = ((i >= 0) && (i <= 255)) ? i : 255; option = XGetDefault (display, BasicTV, "graphics3G"); i = option ? atoi (option) : -1; ggrfx[3] = ((i >= 0) && (i <= 255)) ? i : 171; option = XGetDefault (display, BasicTV, "graphics3B"); i = option ? atoi (option) : -1; bgrfx[3] = ((i >= 0) && (i <= 255)) ? i : 255; option = XGetDefault (display, BasicTV, "graphics4R"); i = option ? atoi (option) : -1; rgrfx[4] = ((i >= 0) && (i <= 255)) ? i : 0; option = XGetDefault (display, BasicTV, "graphics4G"); i = option ? atoi (option) : -1; ggrfx[4] = ((i >= 0) && (i <= 255)) ? i : 255; option = XGetDefault (display, BasicTV, "graphics4B"); i = option ? atoi (option) : -1; bgrfx[4] = ((i >= 0) && (i <= 255)) ? i : 255; option = XGetDefault (display, BasicTV, "graphics5R"); i = option ? atoi (option) : -1; rgrfx[5] = ((i >= 0) && (i <= 255)) ? i : 255; option = XGetDefault (display, BasicTV, "graphics5G"); i = option ? atoi (option) : -1; ggrfx[5] = ((i >= 0) && (i <= 255)) ? i : 45; option = XGetDefault (display, BasicTV, "graphics5B"); i = option ? atoi (option) : -1; bgrfx[5] = ((i >= 0) && (i <= 255)) ? i : 45; option = XGetDefault (display, BasicTV, "graphics6R"); i = option ? atoi (option) : -1; rgrfx[6] = ((i >= 0) && (i <= 255)) ? i : 153; option = XGetDefault (display, BasicTV, "graphics6G"); i = option ? atoi (option) : -1; ggrfx[6] = ((i >= 0) && (i <= 255)) ? i : 153; option = XGetDefault (display, BasicTV, "graphics6B"); i = option ? atoi (option) : -1; bgrfx[6] = ((i >= 0) && (i <= 255)) ? i : 255; option = XGetDefault (display, BasicTV, "graphics7R"); i = option ? atoi (option) : -1; rgrfx[7] = ((i >= 0) && (i <= 255)) ? i : 255; option = XGetDefault (display, BasicTV, "graphics7G"); i = option ? atoi (option) : -1; ggrfx[7] = ((i >= 0) && (i <= 255)) ? i : 204; option = XGetDefault (display, BasicTV, "graphics7B"); i = option ? atoi (option) : -1; bgrfx[7] = ((i >= 0) && (i <= 255)) ? i : 102; option = XGetDefault (display, BasicTV, "graphics8R"); i = option ? atoi (option) : -1; rgrfx[8] = ((i >= 0) && (i <= 63)) ? i : 0; option = XGetDefault (display, BasicTV, "graphics8G"); i = option ? atoi (option) : -1; ggrfx[8] = ((i >= 0) && (i <= 63)) ? i : 0; option = XGetDefault (display, BasicTV, "graphics8B"); i = option ? atoi (option) : -1; bgrfx[8] = ((i >= 0) && (i <= 63)) ? i : 0; /* make cross colors */ crscol (rgrfx, rgcol); crscol (ggrfx, ggcol); crscol (bgrfx, bgcol); using_shm = 0; #ifdef USE_SHM /* Find out whether the user */ /* Wants to use shared memory */ option = XGetDefault (display, BasicTV, "useSharedMemory"); using_shm = option ? atoi (option) : 1; /* Before asking, see if the */ /* connection is local/remote */ xas_hostname = getenv("HOST"); xas_display = getenv("DISPLAY"); /* convert display host to uc */ jj = strlen (xas_display); for (i = 0; (i < jj) && (xas_display[i] != ':'); i++) xas_uc_disp[i] = toupper (xas_display[i]); xas_uc_disp[i] = '\0'; /* now for non-blank display, */ /* compare hostname */ if (xas_uc_disp[0] != '\0') { if (strcmp(xas_hostname, xas_uc_disp) != 0) { fprintf (stderr, "XAS: Cannot use shared memory on remote XAS link\n"); using_shm=0; } } /* Find out whether the shared */ /* memory extension is */ /* available: */ if (using_shm) { using_shm = XShmQueryVersion (display, &mjr, &mnr, &pixmaps); if (!using_shm) fprintf (stderr, "XAS: @@@ Shared memory not available @@@\n"); else fprintf (stderr, "XAS: *** Using shared memory option for speed ***\n"); } else fprintf (stderr, "XAS: !!! Shared memory not selected !!!\n"); #endif /* limit intensities ? */ option = XGetDefault (display, BasicTV, "maxGreyLevel"); xx = 1 << depth; xx = min (xx, 256) - 1; xx = xx - NGRPHCOL - 2; i = NColour - 1; j = option ? atoi (option) : i; j = min (xx, j); if (j != i) { NColour = j + 1; NValue = NColour + NGRPHCOL; } /* limit scrwrt's delay */ option = XGetDefault (display, BasicTV, "maxCommDelay"); Maxhold = option ? atoi (option) : 16384; if (Maxhold != 16384) fprintf (stderr, "XAS: Max commands delayed = %d\n", Maxhold); return; } /* end user_options */ --XYZZY-- cat > screen.c << --XYZZY-- /*--------------------------------------------------------------------*/ /*! XAS screen drawing package */ /*# TV-IO */ /*--------------------------------------------------------------------*/ /*; Copyright (C) 1995, 1996 */ /*; Associated Universities, Inc. Washington DC, USA. */ /*; */ /*; This program is free software; you can redistribute it and/or */ /*; modify it under the terms of the GNU General Public License as */ /*; published by the Free Software Foundation; either version 2 of */ /*; the License, or (at your option) any later version. */ /*; */ /*; This program is distributed in the hope that it will be useful, */ /*; but WITHOUT ANY WARRANTY; without even the implied warranty of */ /*; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /*; GNU General Public License for more details. */ /*; */ /*; You should have received a copy of the GNU General Public */ /*; License along with this program; if not, write to the Free */ /*; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, */ /*; MA 02139, USA. */ /*; */ /*; Correspondence concerning AIPS should be addressed as follows: */ /*; Internet email: aipsmail@nrao.edu. */ /*; Postal address: AIPS Project Office */ /*; National Radio Astronomy Observatory */ /*; 520 Edgemont Road */ /*; Charlottesville, VA 22903-2475 USA */ /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/ #include "xas.h" int scrwrt (xs, ys, xe, ye) /*--------------------------------------------------------------------*/ /* Draws from memory image to the screen taking account of zoom, */ /* scroll and window offsets etc. Updates that rectangle enclosed by */ /* xs, ys, xe, ye. Dimensions are screen units. */ /*--------------------------------------------------------------------*/ int xs, ys, xe, ye; /*--------------------------------------------------------------------*/ { int xmin, xmax, ymin, ymax, xext, yext, amin, amax, xoff, yoff; int choff; /*--------------------------------------------------------------------*/ if (scrhold) { uxs = min (xs, uxs); uys = min (ys, uys); uxe = max (xe, uxe); uye = max (ye, uye); numhold = numhold + 1; if (numhold <= Maxhold) return (0); xs = uxs; ys = uys; xe = uxe; ye = uye; uxs = Screen_Width; uxe = 0; uys = Screen_Height; uye = 0; } numhold = 0; choff = max (0, cur_chan - 1); /* Upper left quadrant */ xmin = upleft_x[choff] * upleft_mag + sc_centre_x - sc_width2 + 1; xmax = upleft_x[choff] * upleft_mag + sc_centre_x + sc_width2; if (xmin >= Screen_Width * upleft_mag) { xmin -= Screen_Width * upleft_mag; xmax -= Screen_Width * upleft_mag; } xext = xmax - (Screen_Width - 1) * upleft_mag; if (xext > 0) xmax = (Screen_Width - 1) * upleft_mag; ymin = upleft_y[choff] * upleft_mag + sc_centre_y - sc_height2 + 1; ymax = upleft_y[choff] * upleft_mag + sc_centre_y + sc_height2; if (ymin >= Screen_Height * upleft_mag) { ymin -= Screen_Height * upleft_mag; ymax -= Screen_Height * upleft_mag; } yext = ymax - (Screen_Height - 1) * upleft_mag; if (yext > 0) ymax = (Screen_Height - 1) * upleft_mag; xoff = yoff = 0; scrdoit (xs, ys, xe, ye, xmin, ymin, xmax, ymax, xoff, yoff); /* Upper right quadrant */ if (xext > 0) { amin = 0; amax = xext - upleft_mag; xoff = (xmax + upleft_mag - xmin); yoff = 0; scrdoit (xs, ys, xe, ye, amin, ymin, amax, ymax, xoff, yoff); } /* Lower left quadrant */ if (yext > 0) { amin = 0; amax = yext - upleft_mag; xoff = 0; yoff = (ymax + upleft_mag - ymin); scrdoit (xs, ys, xe, ye, xmin, amin, xmax, amax, xoff, yoff); } /* Lower right quadrant */ if ((xext > 0) && (yext > 0)) { xoff = (xmax + upleft_mag - xmin); yoff = (ymax + upleft_mag - ymin); amin = 0; amax = yext - upleft_mag; xmin = 0; xmax = xext - upleft_mag; scrdoit (xs, ys, xe, ye, xmin, amin, xmax, amax, xoff, yoff); } return (0); } void scrdoit (xs, ys, xe, ye, xmin, ymin, xmax, ymax, xoff, yoff) /*--------------------------------------------------------------------*/ /* Draws from memory image to the screen taking account of zoom, */ /* scroll and window offsets etc. Updates that rectangle enclosed */ /* by xs, ys, xe, ye. Dimensions are screen units before zoom for xs,*/ /* ys, xe, ye and AFTER zoom for the others. This means that the left*/ /* column and upper row and right column and lower row may not be */ /* replicated upleft_mag times in zoom. */ /*--------------------------------------------------------------------*/ int xs, ys, xe, ye, xmin, ymin, xmax, ymax, xoff, yoff; /*--------------------------------------------------------------------*/ { int i, x, y, offset, k, choff, yoffs, ytemp; register char *pi, *pl, *gi, *gl, *mp; int gphv, imv, mem_full[4096], xx, yy, nx, ny, bytes_row; unsigned long pv; register int j, jj; #ifdef USE_SHM XEvent event; #endif /*--------------------------------------------------------------------*/ upleft_mag = max (1, upleft_mag); if (XasDebug) { fprintf (stderr, "xs,ys,xe,ye,mag %d %d %d %d %d\n", xs, ys, xe, ye, upleft_mag); fprintf (stderr, "xmin,xmax,ymin,ymax %d %d %d %d\n", xmin, xmax, ymin, ymax); fprintf (stderr, "xoff, yoff %d %d\n", xoff, yoff); } xs = max (xs, xmin/upleft_mag); ys = max (ys, ymin/upleft_mag); xe = min (xe, xmax/upleft_mag); ye = min (ye, ymax/upleft_mag); choff = max (cur_chan - 1, 0); if ((xe >= xs) && (ye >= ys)) { /* find number x points */ nx = upleft_mag * (xe - xs + 1); offset = upleft_mag * xs - xmin + xoff; if (offset < 0) { nx += offset; offset = 0; } nx = min (nx, xmax - xmin - offset + xoff + 1); #ifdef USE_SHM if (using_shm) bytes_row = line->bytes_per_line; else #endif /* USE_SHM */ bytes_row = Screen_Width; /* no graphics is faster */ if (rwgraph <= 0) { /* no zoom is easy */ if (upleft_mag <= 1) { yy = upleft_mag * ys - ymin + yoff; ny = upleft_mag * (ye - ys + 1) ; if (yy < 0) { ny += yy; yy = 0; } ny = min (ymax - ymin - yy + yoff + 1, ny); #ifdef USE_SHM if (using_shm) { (void) XShmPutImage (display, win, ImageGC, plane[choff], xs, ys, offset, yy, nx, ny, True); XIfEvent (display, &event, is_complete, NULL); } else #endif /* USE_SHM */ XPutImage (display, win, ImageGC, plane[choff], xs, ys, offset, yy, nx, ny); } /* zoomed by replication */ else { /* fast when 8-bit chars */ if (depth == 8) { for (i = ys; i <= ye; i++) { yy = upleft_mag * i - ymin + yoff; ny = upleft_mag; if (yy < 0) { ny += yy; yy = 0; } ny = min (ymax - ymin + yoff + 1 - yy, ny); /* zoom a row */ for (x=0; x < upleft_mag; x++) { offset = upleft_mag * xs - xmin + x + xoff; pl = line_data + offset + yy * bytes_row; pi = plane_data[choff] + bytes_row * i + xs; j = (xe - xs) + 1; if (offset < 0) { pl += upleft_mag; pi += 1; j--; } while (j--) { *pl = *pi++; pl += upleft_mag; } } /* replicate the row */ offset = max (upleft_mag * xs - xmin + xoff, 0); yoffs = bytes_row * yy + offset; for (y = 1; y < ny; y++) memcpy (line_data + (bytes_row * y + yoffs), line_data + (yoffs), nx); /* move to the display */ } /* for i = ys:ye */ yy = upleft_mag * ys - ymin + yoff; ny = upleft_mag * (ye - ys + 1) ; if (yy < 0) { ny += yy; yy = 0; } ny = min (ymax - ymin - yy + yoff + 1, ny); if (XasDebug) { fprintf (stderr, "Blit xs,ys,xe,ye,mag %d %d %d %d %d\n", xs, ys, xe, ye, upleft_mag); fprintf (stderr, "Blit offset nx yy ny %d %d %d %d\n", offset, nx, yy, ny); } #ifdef USE_SHM if (using_shm) { (void) XShmPutImage (display, win, ImageGC, line, offset, yy, offset, yy, nx, ny, True); XIfEvent (display, &event, is_complete, NULL); } else #endif XPutImage (display, win, ImageGC, line, offset, yy, offset, yy, nx, ny); } /* depth = 8 */ /* Displays that are not */ /* 8-bit deep are handled */ /* with generic Xlib calls. */ else { for (i = ys; i <= ye; i++) { /* zoom a row */ offset = upleft_mag * xs - xmin + xoff; for (j = xs; j <= xe; j++) { pv = XGetPixel (plane[choff], j, i); for (jj = 0; jj < upleft_mag; jj++) { if (offset > 0) XPutPixel (line, offset, 0, pv); offset++; } /* jj */ } /* j = xs-xe */ /* replicate the row */ offset = upleft_mag * xs - xmin + xoff; yy = upleft_mag * i - ymin + yoff; ny = upleft_mag; if (yy < 0) { ny += yy; yy = 0; } ny = min (ymax - ymin + yoff + 1 - yy, ny); #ifdef USE_SHM if (using_shm) { for (y = 1; y < ny; y++) { (void) XShmPutImage (display, win, ImageGC, line, offset, 0, offset, yy + y, nx, 1, True); XIfEvent (display, &event, is_complete, NULL); } } else #endif for (y = 1; y < ny; y++) XPutImage (display, win, ImageGC, line, offset, 0, offset, yy + y, nx, 1); } /* for i = ys:ye */ } /* depth != 8 */ } /* else upleft_mag > 1 */ } /* rwgraph <= 0 */ /* graphics are on */ else { /* zoomed by replication */ /* fast when 8-bit chars */ if (depth == 8) { for (i = ys; i <= ye; i++) { /* get graphics + image line */ pi = plane_data[choff] + bytes_row * i + xs; gi = graph_data + bytes_row * i + xs; jj = NColour - 1; for (j = xs; j <= xe; j++) { gphv = rwgraph & *gi++; imv = *pi++; if (gphv > 0) mem_full[j] = int2pix[jj + grfvc[gphv]]; else mem_full[j] = imv; } yy = upleft_mag * i - ymin + yoff; ny = upleft_mag; if (yy < 0) { ny += yy; yy = 0; } ny = min (ymax - ymin + yoff + 1 - yy, ny); /* zoom a row */ for (x = 0; x < upleft_mag; x++) { offset = upleft_mag * xs - xmin + x + xoff; pl = line_data + offset + yy * bytes_row; ytemp = xs; if (offset < 0) { pl += upleft_mag; ytemp++; } for (j = ytemp; j <= xe; j++) { *pl = mem_full[j]; pl += upleft_mag; } } /* replicate the row */ offset = max (upleft_mag * xs - xmin + xoff, 0); yoffs = bytes_row * yy + offset; for (y = 1; y < ny; y++) memcpy (line_data + (bytes_row * y + yoffs), line_data + (yoffs), nx); /* move to the display */ } /* for i = ys:ye */ yy = upleft_mag * ys - ymin + yoff; ny = upleft_mag * (ye - ys + 1) ; if (yy < 0) { ny += yy; yy = 0; } ny = min (ymax - ymin + yoff + 1 - yy, ny); if (XasDebug) { fprintf (stderr, "Blit xs,ys,xe,ye,mag %d %d %d %d %d\n", xs, ys, xe, ye, upleft_mag); fprintf (stderr, "Blit offset nx yy ny %d %d %d %d\n", offset, nx, yy, ny); } #ifdef USE_SHM if (using_shm) { (void) XShmPutImage (display, win, ImageGC, line, offset, yy, offset, yy, nx, ny, True); XIfEvent (display, &event, is_complete, NULL); } else #endif XPutImage (display, win, ImageGC, line, offset, yy, offset, yy, nx, ny); } /* depth = 8 */ /* Displays that are not */ /* 8-bit deep are handled */ /* with generic Xlib calls. */ else { for (i = ys; i <= ye; i++) { /* get graphics + image line */ offset = upleft_mag * xs - xmin + xoff; for (j = xs; j <= xe; j++) { gphv = rwgraph & XGetPixel (graph, j, i); if (gphv > 0) pv = int2pix[jj + grfvc[gphv]]; else pv = XGetPixel (plane[choff], j, i); /* zoom the pixel */ for (jj = 0; jj < upleft_mag; jj++) { if (offset > 0) XPutPixel (line, offset, 0, pv); offset++; } /* jj */ } /* j = xs-xe */ /* replicate the row */ offset = upleft_mag * xs - xmin + xoff; yy = upleft_mag * i - ymin + yoff; ny = upleft_mag; if (yy < 0) { ny += yy; yy = 0; } ny = min (ymax - ymin + yoff + 1 - yy, ny); #ifdef USE_SHM if (using_shm) { for (y = 1; y < ny; y++) { (void) XShmPutImage (display, win, ImageGC, line, offset, 0, offset, yy + y, nx, ny, True); XIfEvent (display, &event, is_complete, NULL); } } else #endif for (y = 1; y < ny; y++) XPutImage (display, win, ImageGC, line, offset, 0, offset, yy + y, nx, 1); } /* for i = ys:ye */ } /* depth != 8 */ } /* rwgraph > 0 */ } /* xe>=xs, ye>=ys */ return; } #ifdef USE_SHM /* Predicate procedure for XIfEvent: */ Bool is_complete (display, event, arg) Display *display; XEvent *event; char *arg; { #if __STDC__ int XShmGetEventBase ( Display * ); #else int XShmGetEventBase (/* Display * */); #endif if (event->type == (XShmGetEventBase (display) + ShmCompletion)) return True; else return False; } #endif --XYZZY-- cat > xas.c << --XYZZY-- /*--------------------------------------------------------------------*/ /*! X-AIPS server */ /*# TV-IO */ /*--------------------------------------------------------------------*/ /*; Copyright (C) 1995, 1996 */ /*; Associated Universities, Inc. Washington DC, USA. */ /*; */ /*; This program is free software; you can redistribute it and/or */ /*; modify it under the terms of the GNU General Public License as */ /*; published by the Free Software Foundation; either version 2 of */ /*; the License, or (at your option) any later version. */ /*; */ /*; This program is distributed in the hope that it will be useful, */ /*; but WITHOUT ANY WARRANTY; without even the implied warranty of */ /*; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /*; GNU General Public License for more details. */ /*; */ /*; You should have received a copy of the GNU General Public */ /*; License along with this program; if not, write to the Free */ /*; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, */ /*; MA 02139, USA. */ /*; */ /*; Correspondence concerning AIPS should be addressed as follows: */ /*; Internet email: aipsmail@nrao.edu. */ /*; Postal address: AIPS Project Office */ /*; National Radio Astronomy Observatory */ /*; 520 Edgemont Road */ /*; Charlottesville, VA 22903-2475 USA */ /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/ #include "xas.h" #include #ifdef AIX #include #endif #if BSD #include #endif int main (argc, argv) int argc; char *argv[]; { XEvent report; KeySym key; char CharBuf[4]; XComposeStatus compose; int sx, sy, w, h, exposed, i; #if BSD int select_size; int XLink, len, optlen; struct sockaddr_un from_un; struct sockaddr_in from_in; fd_set fdmask; #endif #if VMS int status; #endif /* Init global variables */ exposed = False; init(); /* Connect to X server, get window ID and generate gray scale */ SetupWindow (argc, argv); #if BSD /* Create communications link with AIPS. */ if (MakeLink() < 0) { (void) shutdown (AipsSocket, 0); (void) close (AipsSocket); closedown(); exit(-1); } /* Get file descriptor of X */ /* server socket */ XLink = ConnectionNumber (display); /* on hpux, use posix form */ #if defined(__hpux) || defined(__STDC__) select_size = sysconf (_SC_OPEN_MAX); #else select_size = getdtablesize(); #endif #if VMS /* Create communications link with AIPS. */ Makelink(); write_in_progress = 0; read_in_progress = 0; /* wake up about once every 1/4 second */ status = sys(&dtime,&delta); if (!(status & SS)) lib(status); status = sys(0,0,&delta,&delta); if (!(status & SS)) lib(status); /* Start the IO */ ReadLink (AipsLink); #endif /* display window */ XMapWindow (display, win); /* * Event loop, first Expose displays blank window; * Press ESC or control-c or F20 to exit. */ while (1) { #if VMS sys(0); while (XCheckWindowEvent (display, win, emask, &report)) { #endif #if BSD if (XPending (display)) { XNextEvent (display, &report); } else { if (connected) { FD_ZERO (&fdmask); FD_SET (AipsLink, &fdmask); FD_SET (XLink, &fdmask); /* select for an X event or I/O from AIPS */ if (select (select_size, &fdmask, (fd_set *)NULL, (fd_set *)NULL, (struct timeval *)0) < 0) { perror ("select error - AipsLink"); continue; } if (FD_ISSET (XLink, &fdmask)) { XNextEvent (display, &report); } else { ReadLink (AipsLink, &xbuf, &ybuf); if (ybuf.status != OK) xbuf.opcode = CLOSE; ProcessAipsRequest(); if (connected) WriteLink (AipsLink, &xbuf, &ybuf); continue; } } else { /* not connected */ FD_ZERO (&fdmask); FD_SET (AipsSocket, &fdmask); FD_SET (XLink, &fdmask); /* select for an X event or connect request from AIPS */ if (select (select_size, &fdmask, (fd_set *)NULL, (fd_set *)NULL, (struct timeval *)0) < 0) { perror ("select error - AipsSocket"); continue; } if (FD_ISSET (XLink, &fdmask)) { XNextEvent(display, &report); } else { /* Connect to an AIPS task */ if (domain_type == INET_DOMAIN ) { len = sizeof(from_in); if ((AipsLink = accept (AipsSocket, (struct sockaddr *) &from_in, &len)) < 0) { perror ("Accept"); connected = False; } else { connected = True; } } else { /* UNIX_DOMAIN */ len = sizeof(from_un); if ((AipsLink = accept (AipsSocket, (struct sockaddr *) &from_un, &len)) < 0) { perror ("Accept"); connected = False; } else { connected = True; } } if (connected) { optlen = sizeof (Z_sndbuf); if (getsockopt (AipsLink, SOL_SOCKET, SO_SNDBUF, (char *) &Z_sndbuf, &optlen) < 0) { perror("XAS connect SO_SNDBUF get"); Z_sndbuf = 4096; } optlen = sizeof (Z_rcvbuf); if (getsockopt (AipsLink, SOL_SOCKET, SO_RCVBUF, (char *) &Z_rcvbuf, &optlen) < 0) { perror("XAS connect SO_RCVBUF get"); Z_rcvbuf = 4096; } Z_sndini = Z_sndbuf; Z_rcvini = Z_rcvbuf; } continue; } } } #endif if (XDebug) fprintf (stderr," %s\n",event_names[report.type]); switch (report.type) { case Expose: while (XCheckTypedEvent (display, Expose, &report)); if (XasDebug) fprintf (stderr, "expose event w,h,x,y %d %d %d %d\n", Cur_Xsize, Cur_Ysize, Cur_Xzero, Cur_Yzero); /* first time force it */ if (!exposed) XResizeWindow (display, win, Cur_Xsize, Cur_Ysize); exposed = True; /* repaint the picture */ scrwrt (0, 0, Screen_Width - 1, Screen_Height - 1); break; case ButtonPress: RecordCursor (report.xbutton.x, report.xbutton.y); break; case MotionNotify: RecordCursor (report.xmotion.x, report.xmotion.y); break; case KeyPress: (void) XLookupString ((XKeyEvent *)&report, CharBuf, sizeof(CharBuf), &key, &compose ); CheckKey (key, AipsLink); break; case ConfigureNotify: if (exposed) { Cur_Xsize = report.xconfigure.width; Cur_Ysize = report.xconfigure.height; if ((report.xconfigure.x != 0) || (report.xconfigure.y != 0)) { Cur_Xzero = report.xconfigure.x; Cur_Yzero = report.xconfigure.y; } } if (XasDebug) fprintf (stderr, "configure event w,h,x,y %d %d %d %d\n", Cur_Xsize, Cur_Ysize, Cur_Xzero, Cur_Yzero); (void) resize_canvas (Cur_Xsize, Cur_Ysize, Cur_Xzero, Cur_Yzero); break; default: /* all events selected by StructureNotifyMask * except ConfigureNotify are thrown away here, * since nothing is done with them */ break; } /* end switch */ #if VMS } /* end while */ sys(1); /* enable AST's while hibernating */ sys(); /* go to sleep, wait for wakeup */ #endif } /* end while */ /* close down by destroying */ /* anything created in init */ /* More needed here? Maybe */ /* shutdown (AipsSocket, 0) */ /* and close (AipsSocket) */ /* first??? */ closedown(); #endif return (0); } /* end main */ /*-------------------------------------------------------------------*/ void ProcessAipsRequest() { ybuf.status = 0; ybuf.return_data_length = 0; if ((XDebug) && (xbuf.opcode != IMWRT) && (xbuf.opcode != RCURS) && (xbuf.opcode != RCURB)) { fprintf (stderr, "%s\n",opcodes[xbuf.opcode]); printbufin (); } switch (xbuf.opcode) { case OPEN: if (XasDebug) fprintf (stderr, "XAS Open \n"); ybuf.status = 0; ybuf.return_data_length = 0; break; case CLOSE: if (XasDebug) fprintf (stderr, "XAS Close now \n"); #if BSD shutdown (AipsLink, 0); close (AipsLink); #endif connected = False; break; case INTGT: if (XasDebug) fprintf (stderr, "XAS parameters requested"); ybuf.status = Interogate (&ybuf.return_data_length); if (XasDebug) fprintf (stderr, " done\n"); break; case CLEAR: /* AIPS TVINIT */ if (XasDebug) fprintf (stderr, "CLEAR %d", xbuf.parms[0]); ybuf.status = ClearChan(); ybuf.return_data_length = 0; if (XasDebug) fprintf (stderr, " done\n"); break; case VIEW: if (XasDebug) fprintf (stderr, "VIEW %d", xbuf.parms[0]); ybuf.status = ViewData(); ybuf.return_data_length = 0; if (XasDebug) fprintf (stderr, " done\n"); break; case IMWRT: ybuf.status = imwrt(); ybuf.return_data_length = 0; break; case IMRD: ybuf.status = imrd (&ybuf.return_data_length); break; case WLUT: if (XasDebug) fprintf (stderr, "WLUT %d", xbuf.parms[0]); ybuf.status = cmap_wlut(); ybuf.return_data_length = 0; if (XasDebug) fprintf (stderr, " done\n"); break; case RLUT: if (XasDebug) fprintf (stderr, "RLUT %d", xbuf.parms[0]); ybuf.status = cmap_rlut(); ybuf.return_data_length = NColour; if (XasDebug) fprintf (stderr, " done\n"); break; case WOFM: if (XasDebug) fprintf (stderr, "WOFM %d", xbuf.parms[0]); ybuf.status = cmap_wofm(); ybuf.return_data_length = 0; if (XasDebug) fprintf (stderr, " done\n"); break; case ROFM: if (XasDebug) fprintf (stderr, "ROFM %d", xbuf.parms[0]); ybuf.status = cmap_rofm(); ybuf.return_data_length = NINTENS; if (XasDebug) fprintf (stderr, " done\n"); break; case GRAPH: if (XasDebug) fprintf (stderr, "GRAPH %d %d\n", xbuf.parms[0],xbuf.parms[1]); ybuf.status = cmap_graph(); ybuf.return_data_length = 0; if (XasDebug) fprintf (stderr, " GRAPH done\n"); break; case SPLIT: if (XasDebug) fprintf (stderr, "SPLIT %d", xbuf.parms[0]); ybuf.status = cmap_split(); ybuf.return_data_length = 0; if (XasDebug) fprintf (stderr, " done\n"); break; case WGRFX: if (XasDebug) fprintf (stderr, "WGRFX %d", xbuf.parms[0]); ybuf.status = cmap_wgrfx(); ybuf.return_data_length = 0; if (XasDebug) fprintf (stderr, " done\n"); break; case RGRFX: if (XasDebug) fprintf (stderr, "RGRFX %d", xbuf.parms[0]); ybuf.status = cmap_rgrfx(); ybuf.return_data_length = 3; if (XasDebug) fprintf (stderr, " done\n"); break; case RCURS: ybuf.status = GetCursor(); ybuf.return_data_length = 2; break; case RBUTT: ybuf.status = readbuttons(); ybuf.return_data_length = 4; break; case WCURS: if (XasDebug) fprintf (stderr, "WCURS %d %d", xbuf.parms[0], xbuf.parms[1]); ybuf.status = movecursor(); ybuf.return_data_length = 0; if (XasDebug) fprintf (stderr, " done\n"); break; case RCURB: ybuf.status = cursor_button(); ybuf.return_data_length = 6; if ((XasDebug) && ((ybuf.data[2] > 0) || (ybuf.data[3] > 0) || (ybuf.data[4] > 0) || (ybuf.data[5] > 0))) fprintf (stderr, "RCURB returns %d %d %d %d %d %d\n", ybuf.data[0], ybuf.data[1], ybuf.data[2], ybuf.data[3], ybuf.data[4], ybuf.data[5]); break; case WZSCR: if (XasDebug) fprintf (stderr, "ZOOM %d %d %d %d", xbuf.parms[0], xbuf.parms[1], xbuf.parms[2], xbuf.parms[3]); ybuf.status = zoom(); ybuf.return_data_length = 0; if (XasDebug) fprintf (stderr, " done\n"); break; case WINDO: if (XasDebug) fprintf (stderr, "WINDO %d %d %d %d\n", xbuf.parms[0], xbuf.parms[1], xbuf.parms[2], xbuf.parms[3]); ybuf.status = windo_status(); ybuf.return_data_length = 4; if (XasDebug) fprintf (stderr, " done\n"); break; default: fprintf (stderr, "XAS: opcode %d not yet implemented.\n", xbuf.opcode); ybuf.status = -1; ybuf.return_data_length = 0; break; } /* end switch */ return ; } /* end ProcessAipsRequest */ --XYZZY-- cat > xas.h << --XYZZY-- /*--------------------------------------------------------------------*/ /*! XAS header file */ /*# TV-IO */ /*--------------------------------------------------------------------*/ /*; Copyright (C) 1995, 1996 */ /*; Associated Universities, Inc. Washington DC, USA. */ /*; */ /*; This program is free software; you can redistribute it and/or */ /*; modify it under the terms of the GNU General Public License as */ /*; published by the Free Software Foundation; either version 2 of */ /*; the License, or (at your option) any later version. */ /*; */ /*; This program is distributed in the hope that it will be useful, */ /*; but WITHOUT ANY WARRANTY; without even the implied warranty of */ /*; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /*; GNU General Public License for more details. */ /*; */ /*; You should have received a copy of the GNU General Public */ /*; License along with this program; if not, write to the Free */ /*; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, */ /*; MA 02139, USA. */ /*; */ /*; Correspondence concerning AIPS should be addressed as follows: */ /*; Internet email: aipsmail@nrao.edu. */ /*; Postal address: AIPS Project Office */ /*; National Radio Astronomy Observatory */ /*; 520 Edgemont Road */ /*; Charlottesville, VA 22903-2475 USA */ /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/ /* #define BSD 1 */ /* Select operating system */ /* #define VMS 0 */ /* set desired system to 1 */ #ifdef _BSD /* Unix needs BSD = 1 */ #define BSD 1 #undef VMS /* Do not us VMS specific code*/ #endif #ifdef _VMS /* DEC VMS */ #define VMS 1 #undef BSD /* No Unix-specific code */ #endif #ifdef _AIX /* IBM AIX needs BSD = 1 also */ #define AIX 1 /* use AIX specific code */ #undef VMS /* Do not us VMS specific code*/ #endif #include /* We must override MIT error */ /* in prototype */ #if __STDC__ #define XIOErrorHandler XFuckedUp1 #define XSetIOErrorHandler XFuckedUp2 #endif #include #include #include #if __STDC__ #undef XIOErrorHandler #undef XSetIOErrorHandler #endif #if BSD /* #include */ /* Header info needed for socket routines (including i/o) */ #include #include #include #include #include #include #include #include #include /* Header for shared memory extension */ #ifdef USE_SHM #include #include #include #endif struct sockaddr_un server_un; struct sockaddr_in server_in; struct servent *sp_in; Bool connected; int AipsSocket, AipsLink; int domain_type; #define UNIX_DOMAIN 0 #define INET_DOMAIN 1 #endif /* BSD */ #if VMS /* ##include "xlogo64." */ #include #include #include #define XAS_SOCKET "XasSocket" /* mailbox name AIPS --> XAS */ #define AIPS_SOCKET "AipsSocket" /* mailbox name XAS --> AIPS */ #define emask ExposureMask|KeyPressMask|StructureNotifyMask|PointerMotionMask #define maxmsg 2064 #define bufquo 2064 typedef struct { short int ioresult; short int iolength; int unused; } IOSB; int XasLink, AipsLink; IOSB read_status, write_status; int read_in_progress, write_in_progress; static (dtime, "0 00:00:00.25"); int delta[2]; #endif /* VMS */ /* Screen parameters */ #define NGREY 2 #define NGRAPH 8 #define NGRPHCOL 19 /* total number of planes */ /* (grey-scale + graphics) */ #define NGRTOT (NGREY+NGRAPH) #define MAXZOOM 16 /* Border allocations */ /* #define TEXT_SPACE 0 */ /* empty space @ bottom screen*/ #define TEXT_SPACE 69 /* preferred at NRAO? */ /* I can find no way to ask */ /* the window manager the size*/ /* of its top banner. */ /* They need to be visible to */ /* allow window resize, move..*/ #ifdef AIX /* Numbers for IBM Motif */ #define SCREEN_LEFT 11 #define SCREEN_RIGHT 11 #define SCREEN_TOP 34 #define SCREEN_BOTTOM (11 + TEXT_SPACE) #else /* Numbers for SUN OpenLook */ #define SCREEN_LEFT 5 #define SCREEN_RIGHT 5 #define SCREEN_TOP 26 #define SCREEN_BOTTOM (5 + TEXT_SPACE) #endif /* total screen size */ /* used in positioning */ int twidth, theight, bwid; /* size of logical screen */ /* must be EVEN numbers ! */ int Screen_Height, Screen_Width, visnum; int Cur_Xsize, Cur_Ysize, Cur_Xzero, Cur_Yzero; /* number grey levels in: */ /* total levels: NColour+1-19 */ int NColour, NValue, OColour; /* for graphics, and cursor */ /* number of grey-scale (OFM) */ /* intensities */ #define NINTENS 256 #define COLORSHIFT 8 /* 255 max from ofm then shift*/ /* 8 bits left for col table */ /* cursor [0], graphics [1-8] */ int rgrfx[9], ggrfx[9], bgrfx[9], rgcol[20], ggcol[20], bgcol[20]; int grfvc[256]; #define OK 0 #define NPARMS 4 typedef struct { short int opcode, parms[NPARMS], data_length; unsigned char data[2048]; } XASinput; typedef struct { short int return_data_length, status; short int data[2048]; } XASoutput; /* unsigned char buf[2064]; */ /* Global variables */ XASinput xbuf; /* I/O buffer for AIPS */ XASoutput ybuf; /* I/O buffer for AIPS */ int Z_sndbuf, Z_rcvbuf, Z_sndini, Z_rcvini; /* I/O buffer sizes */ Bool XasDebug; /* Toggle with F8 */ Bool XDebug; /* Toggle with F9 */ Bool ByteSwapped; /* Flag byte swapped machine */ Display *display; int screen_num; Cursor cursor; Window win; GC ImageGC; /* X11 graphics contexts for */ /* drawing images & graphics */ /* Image data structures: */ XImage *plane[NGREY]; /* grey-scale planes */ XImage *line; /* buffer for zoomed img line */ XImage *gline; /* buffer for zoomed graphics */ /* line */ /* All graphs are kept in one plane via a binary trick */ /* a pixel value of 1 means only graph 1 on, 2 means only graph 2 on */ /* a pixel value of 4 means only graph 3 on, 8 means only graph 4 on */ /* a pixel value of 3 means both graph 1 and 2 on, 15 means all 4 on, */ /* etc. */ XImage *graph; /* graphics overlay */ char *plane_data[NGREY]; /* data storage */ char *line_data; char *graph_data; /* Shared memory */ int using_shm; /* set True if using SHM */ #ifdef USE_SHM XShmSegmentInfo plane_info[NGREY]; /* shm info for image planes */ XShmSegmentInfo graph_info; /* shm info for graphics plane*/ XShmSegmentInfo line_info; /* shm info for zoom buffers */ #endif int rwgraph, depth; unsigned char gph_mask; int rofm[NINTENS], gofm[NINTENS], /* red, green and blue OFM */ bofm[NINTENS]; /* registers */ /* red, green and blue LUT */ int *rlut[NGREY], *glut[NGREY], *blut[NGREY]; int *pix2int; /* input int <- assigned pixv */ unsigned long *int2pix; /* input int -> assigned pixv */ int TvStatus[NGREY+NGRAPH]; /* TV Image + Graphics status */ int cur_chan; int cursor_x, cursor_y; int size_i2; int big_screen; /* True if screen is at max. */ /* size, FALSE otherwise */ int cur_xcorn, cur_ycorn; /* current location of top- */ /* left corner of smaller */ /* window */ int cur_xsize, cur_ysize; /* current size of smaller */ /* window */ Colormap TV_colour; XColor *colour_table; XColor fg_curs, bg_curs; int cursor_shape; /* standard cursor shape number*/ unsigned char image_offset; unsigned char graphics_offset; int button_a, button_b, button_c, button_d; int upleft_x[NGREY], upleft_y[NGREY], upleft_mag; int sc_centre_x, sc_centre_y, sc_zoom_mag; int sc_width, sc_height, sc_width2, sc_height2; int ic_width, ic_height, ic_xcorn, ic_ycorn; int scrhold, numhold, Maxhold, uxs, uxe, uys, uye; char *ProgName; /* Useful macros */ #ifndef min #define min(a,b) ((a)<(b)?(a):(b)) #endif #ifndef max #define max(a,b) ((a)>(b)?(a):(b)) #endif #define intswap(a,b) { int tmp; tmp=a; a=b; b=tmp; } #define Memory_x(aips_x) ((aips_x) - 1) #define Memory_y(aips_y) (Screen_Height - (aips_y)) #define Aips_x(memory_x) ((memory_x) + 1) #define Aips_y(memory_y) (Screen_Height - (memory_y)) #define chg_s(var,val,msk) ((var) = ((var)&(~(msk)))|((val) ? (msk) : 0)) #define chg_g(var,msk) (((var)&(msk)) ? 1 : 0) int buffered; /* True if socket is */ /* buffered */ /* Defined opcodes */ #define NUMOP 83 /* Largest opcode */ int bufferop[NUMOP+1]; /* bufferop[OP] is True if */ /* there is no status return */ /* in buffered mode */ #define OPEN 11 /* Opens the XAS connection */ #define CLOSE 12 /* Close the XAS, allows new connections */ #define INTGT 13 /* Interrogate: get XAS major parameters */ #define WINDO 14 /* Read, write the X window size */ #define CLEAR 15 /* Clear some or all channels */ #define VIEW 16 /* Do/hold screen updates */ #define IMWRT 21 /* Write image line to some channel */ #define IMRD 22 /* Read image line from some channel, */ #define WLUT 41 /* Write LUT to a channel. */ #define RLUT 42 /* Read LUT to a channel. */ #define WOFM 43 /* Write OFM. */ #define ROFM 44 /* Read OFM. */ #define GRAPH 45 /* On/off graphics channel(s) */ #define SPLIT 46 /* On/off image channels(s) */ #define WGRFX 51 /* Write graphics/cursor colours */ #define RGRFX 52 /* Read graphics/cursor colours */ #define RCURS 61 /* Read the cursor position. */ #define RBUTT 62 /* Read the status of the buttons */ #define WCURS 63 /* Write the cursor position. */ #define RCURB 64 /* Read the cursor position and buttons */ #define WZOOM 81 /* Write zoom info to the XAS */ #define WSCROL 82 /* Write scroll registers */ #define WZSCR 83 /* Write zoom/scroll to XAS using ULC */ static char *opcodes[NUMOP+1] = { "CODE0 ","CODE1 ","CODE2 ","CODE3 ","CODE4 ", "CODE5 ","CODE6 ","CODE7 ","CORD8 ","CODE9 ", "CODE10","OPEN ","CLOSE ","INTGT ","WINDO ", "CLEAR ","VIEW ","CODE17","CODE18","CODE19", "CODE20","IMWRT ","IMRD ","CODE23","CODE24", "CODE25","CODE26","CODE27","CODE28","CODE29", "CODE30","CODE31","CODE32","CODE33","CODE34", "CODE35","CODE36","CODE37","CODE38","CODE39", "CODE40","WLUT ","RLUT ","WOFM ","ROFM ", "GRAPH ","SPLIT ","CODE47","CODE48","CODE49", "CODE50","WGRFX ","RGRFX ","CODE53","CODE54", "CODE55","CODE56","CODE57","CODE58","CODE59", "CODE60","RCURS ","RBUTT ","WCURS ","RCURB ", "CODE65","CODE66","CODE67","CODE68","CODE69", "CODE70","CODE71","CODE72","CODE73","CODE74", "CODE75","CODE76","CODE77","CODE78","CODE79", "CODE80","WZOOM ","WSCROL","WZSCR " }; static char *event_names[] = { "", "", "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease", "MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", "FocusOut", "KeymapNotify", "Expose", "GraphicsExpose", "NoExpose", "VisibilityNotify", "CreateNotify", "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest", "ReparentNotify", "ConfigureNotify", "ConfigureRequest", "GravityNotify", "ResizeRequest", "CirculateNotify", "CirculateRequest", "PropertyNotify", "SelectionClear", "SelectionRequest", "SelectionNotify", "ColormapNotify", "ClientMessage", "MappingNotify" }; /* Prototyp section */ /* Override the MIT Standard prototype declarations which are wrong */ /* on all machines */ #if __STDC__ typedef int (*XIOErrorHandler) ( Display*, XErrorEvent * ); extern XIOErrorHandler XSetIOErrorHandler ( XIOErrorHandler ); #endif #if __STDC__ void ProcessAipsRequest ( void ); int scrwrt ( int, int, int, int ); void scrdoit ( int, int, int, int, int, int, int, int, int, int ); #ifdef USE_SHM Bool is_complete ( Display *, XEvent *, char * ); #endif int XAS_IOHandler ( Display *, XErrorEvent * ); void init ( void ); void SetupWindow ( int, char ** ); void user_options ( int, char ** ); int imwrt ( void ); int imrd ( short int * ); void resize_canvas ( int, int, int, int ); void resize_pressed ( void ); int windo_status ( void ); int Interogate ( short int * ); int ClearChan ( void ); int ViewData ( void ); int zoom ( void ); void RecordCursor ( int, int ); void CheckKey ( KeySym, int ); int GetCursor ( void ) ; int movecursor ( void ); int readbuttons ( void ); int cursor_button ( void ); short int swapbytes ( short int ); int MakeLink ( void ); #if BSD int ReadLink ( int, XASinput *, XASoutput * ); int WriteLink ( int, XASinput *, XASoutput * ); #endif #if VMS void XasAipsReadAST ( void ); int ReadLink ( void ); void XasAipsWriteAST ( void ); int WriteLink ( void ); #endif void closedown ( void ); void printbufin ( void ); void printbufout ( void ); int cmap_wlut ( void ); int cmap_rlut ( void ); int cmap_wofm ( void ); int cmap_rofm ( void ); int cmap_change ( void ); int cmap_graph ( void ); int cmap_split ( void ); int cmap_wgrfx ( void ); int cmap_rgrfx ( void ); void crscol ( int *, int * ); #else void ProcessAipsRequest (/* void */); int scrwrt (/* int, int, int, int */); void scrdoit (/* int, int, int, int, int, int, int, int, int, int */); #ifdef USE_SHM Bool is_complete (/* Display *, XEvent *, char * */); #endif int XAS_IOHandler (/* Display *, XErrorEvent * */); void init (/* void */); void SetupWindow (/* int, char ** */); void user_options (/* int, char ** */); int imwrt (/* void */); int imrd (/* short int * */); void resize_canvas (/* int, int, int, int */); void resize_pressed (/* void */); int windo_status (/* void */); int Interogate (/* short int * */); int ClearChan (/* void */); int ViewData (/* void */); int zoom (/* void */); void RecordCursor (/* int, int */); void CheckKey (/* KeySym, int */); int GetCursor (/* void */) ; int movecursor (/* void */); int readbuttons (/* void */); int cursor_button (/* void */); short int swapbytes (/* short int */); int MakeLink (/* void */); #if BSD int ReadLink (/* int, XASinput *, XASoutput * */); int WriteLink (/* int, XASinput *, XASoutput * */); #endif #if VMS void XasAipsReadAST (/* void */); int ReadLink (/* void */); void XasAipsWriteAST (/* void */); int WriteLink (/* void */); #endif void closedown (/* void */); void printbufin (/* void */); void printbufout (/* void */); int cmap_wlut (/* void */); int cmap_rlut (/* void */); int cmap_wofm (/* void */); int cmap_rofm (/* void */); int cmap_change (/* void */); int cmap_graph (/* void */); int cmap_split (/* void */); int cmap_wgrfx (/* void */); int cmap_rgrfx (/* void */); void crscol (/* int *, int * */); #endif --XYZZY--