/****************************************/ /* iisio valdes 7 27 88 */ /* */ /* Basic IIS subroutines */ /****************************************/ #include "misc.h" #include "iisfv.h" /*Open display*/ iisopen (device) int device; { char *env, t[40], devstring[80], *getenv(); iisdev = device; switch (iisdev) { case 0: if ((fdiis = d_open ("/dev/null", 2)) < 0) { focaserr (1, "iisopen: Can't open ", "/dev/null"); return (0); } fbconf = 0; iisxsize = iisysize = 512; break; case 3: if ((env = getenv ("FOCASPIPE")) != NULL) strcpy (t, env); else strcpy (t, "/dev/imt1"); /* Use ZFIOGD, rather than open physical device. */ sprintf (devstring, "imtool,%s,512,512:tc=iism70", t); if ((fdiis = d_open(devstring, 2)) < 0) { focaserr (4, "iisopen: Can't open ", "imtool"); return (0); } else fdiisi = fdiis; fbconf = 2; iisxsize = iisysize = 800; if ((env = getenv ("FOCASDISPLAY")) != NULL) sscanf (env, "%d%d%d", &fbconf, &iisxsize, &iisysize); break; default: focaserr (1, "Can't open display device", ""); fdiis = 0; } return (fdiis); } /*Form check sum, write hdr and write addr to iis*/ iiswrite (hdr, addr, count) short *hdr; char *addr; int count; { int status, nleft, n, dummy; register short i, sum; char *ptr; if (hdr[THINGCT] > 0) hdr[THINGCT] = -hdr[THINGCT]; hdr[CHECKSUM] = 1; for (i = 0, sum = 0; i <= 7; i++) sum += hdr[i]; hdr[CHECKSUM] = -sum; switch (iisdev) { case 0: status = count; break; case 3: while ((status = d_write (fdiis, hdr, 16)) < 1); if (status != 16) { focaserr (10, "iiswrite: Error writing header to ", "iis"); return (0); } if (count > 0) { ptr = addr; for (nleft = count; nleft > 0; nleft -= n) { n = (nleft < IIS_MAXBYTES) ? nleft : IIS_MAXBYTES; while ((status = d_write (fdiis, ptr, n)) < 1); if (status != n) { focaserr (status, "iiswrite: Error writing to ", "iis"); return (0); } ptr += n; } } status = count; break; } return (status); } iisread (addr, count) char *addr; int count; { int status, nleft, n; char *ptr; switch (iisdev) { case 0: status = count; break; case 3: ptr = addr; for (nleft = count; nleft > 0; nleft -= n) { n = (nleft < IIS_MAXBYTES) ? nleft : IIS_MAXBYTES; while ((status = d_read (fdiisi, addr, n)) < 1); if (status != n) { focaserr (status, "iisread: Error reading ", "iis"); return (0); } ptr += n; } status = count; break; } return (status); } /* Modifications to support network access to a remote display server. * -------------------------------------------------------------------- */ #define READ_ONLY 1 /* file access modes */ #define READ_WRITE 2 #define WRITE_ONLY 3 /* D_OPEN -- Open the display device. To access a device on a remote server * node, the user must define the environment variable NODE on the client * (local) node, before running FOCAS. The value of NODE is the network name * of the workstation to be accessed. The following are required on the * client node to establish the network connection: * * setenv 'node' defines server node * setenv 'iraf' defines iraf root * $iraf/dev/hosts describes local network * * The latter two are automatically provided if iraf is installed on the client * node, but they are not difficult to set up if iraf is not available locally. * The directory pointed to by 'iraf' may be any directory containing the file * ./dev/hosts. */ d_open (device, mode) char *device; int mode; { int status; int xmode; char netpath[64]; char *node, *getenv(); if ((node = getenv ("node"))) { if (strchr (node, '!') == 0) sprintf (netpath, "%s!%s", node, device); else sprintf (netpath, "%s%s", node, device); } else strcpy (netpath, device); switch (mode) { case 0: xmode = READ_ONLY; break; case 1: xmode = WRITE_ONLY; break; default: xmode = READ_WRITE; break; } kopngd (netpath, &xmode, &status); return (status); } /* D_READ -- Read from the display device. */ d_read (chan, buf, nbytes) int chan; char *buf; int nbytes; { int offset = 0; int status; kardgd (&chan, buf, &nbytes, &offset); kawtgd (&chan, &status); return (status); } /* D_WRITE -- Write to the display device. */ d_write (chan, buf, nbytes) int chan; char *buf; int nbytes; { int offset = 0; int status; kawrgd (&chan, buf, &nbytes, &offset); kawtgd (&chan, &status); return (status); }