Article View: vmsnet.sources
Article #104XSCOPE/VMS 1.0, part 01/08
From: Patrick L. Mahan - TGV Window Wa...
Date: Fri, 04 Sep 1992 05:34
Date: Fri, 04 Sep 1992 05:34
1796 lines
50184 bytes
50184 bytes
Submitted-by: mahan@tgv.com (Patrick L. Mahan - TGV Window Washer)
Posting-number: Volume 3, Issue 153
Archive-name: xscope/part01
$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-007 22-FEB-1990
$! On 9-JUN-1992 23:28:42.94 By user MAHAN (Patrick L. Mahan)
$!
$! This VMS_SHARE Written by:
$! Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$! James Gray - Original VMS_SHARE
$! Michael Bednarek - Original Concept and implementation
$!
$!+ THIS PACKAGE DISTRIBUTED IN 8 PARTS, TO KEEP EACH PART
$! BELOW 100 BLOCKS
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE ( @name )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$! 1. COMMON.C;13
$! 2. DECODE11.C;4
$! 3. DNET_SOCKET_LIBRARY.C;81
$! 4. DNXSCOPE.OPT;2
$! 5. EMULATIONLIB.H;15
$! 6. FD.C;17
$! 7. FD.H;2
$! 8. FIX.INFO;1
$! 9. IMAKEFILE.;1
$! 10. IPXSCOPE.OPT;1
$! 11. MAKE.COM;20
$! 12. MAKEFILE.;1
$! 13. MAKEFILE.PROTO;1
$! 14. PORTOBJ.H;1
$! 15. PRINT11.C;2
$! 16. PRTYPE.C;10
$! 17. README.;1
$! 18. README.VMS;2
$! 19. SCOPE.C;19
$! 20. SCOPE.H;8
$! 21. SERVER.C;10
$! 22. TABLE11.C;3
$! 23. TARFILES.;1
$! 24. X11.H;6
$! 25. XSCOPE.1;1
$! 26. XSCOPE.TXT;1
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
X/* ************************************************************ *\
X *`09`09`09`09`09`09`09`09*
X * Common support routines for sockets`09`09`09*
X *`09`09`09`09`09`09`09`09*
X * James L. Peterson`09 `09`09`09`09*
X *`09(c) Copyright MCC, 1987 *
X * `09`09`09`09 `09`09`09`09*
X * `09`09`09`09 `09`09`09`09*
X \* *********************************************************** */
X#if defined(vax11c) && !defined(MULTINET)
X#include "emulationlib.h"
X#endif
X
X#include "scope.h"
X
X/* ********************************************** */
X/*`09`09`09`09`09`09 */
X/* Debugging support routines */
X/*`09`09`09`09`09`09 */
X/* ********************************************** */
X
Xenterprocedure(s)
X char *s;
X`7B
X debug(2,(stderr, "-> %s\n", s));
X`7D
X
Xwarn(s)
X char *s;
X`7B
X fprintf(stderr, "####### %s\n", s);
X`7D
X
Xpanic(s)
X char *s;
X`7B
X fprintf(stderr, "%s\n", s);
X exit(1);
X`7D
X
X/* ********************************************** */
X/*`09`09`09`09`09`09 */
X/* Debugging forms of memory management */
X/*`09`09`09`09`09`09 */
X/* ********************************************** */
X
Xextern char *malloc();
X
X#ifdef vax11c
Xchar *MyMalloc (n)
X#else
Xchar *Malloc (n)
X#endif /* vax11c */
X long n;
X`7B
X char *p;
X p = (char *)malloc((unsigned int)n);
X debug(64,(stderr, "%x = malloc(%d)\n", p, n));
X if (p == NULL)
X panic("no more malloc space");
X return(p);
X`7D
X
X#ifdef vax11c
XMyFree(p)
X#else
XFree(p)
X#endif /* vax11c */
X char *p;
X`7B
X debug(64,(stderr, "%x = free\n", p));
X free(p);
X`7D
X
X
X
X/* ************************************************************ */
X/*`09`09`09`09`09`09`09`09*/
X/* Signal Handling support`09`09`09`09`09*/
X/*`09`09`09`09`09`09`09`09*/
X/* ************************************************************ */
X
X#include <signal.h>
X
X#ifndef vax11c
XSignalURG()
X`7B
X debug(1,(stderr, "==> SIGURG received\n"));
X`7D
X#endif /* vax11c */
X
XSignalPIPE()
X`7B
X debug(1,(stderr, "==> SIGPIPE received\n"));
X`7D
X
XSignalINT()
X`7B
X debug(1,(stderr, "==> SIGINT received\n"));
X exit(1);
X`7D
X
XSignalQUIT()
X`7B
X debug(1,(stderr, "==> SIGQUIT received\n"));
X exit(1);
X`7D
X
XSignalTERM()
X`7B
X debug(1,(stderr, "==> SIGTERM received\n"));
X exit(1);
X`7D
X
X#ifndef vax11c
XSignalTSTP()
X`7B
X debug(1,(stderr, "==> SIGTSTP received\n"));
X`7D
X
XSignalCONT()
X`7B
X debug(1,(stderr, "==> SIGCONT received\n"));
X`7D
X#endif /* vax11c */
X
XSetSignalHandling()
X`7B
X enterprocedure("SetSignalHandling");
X#ifndef vax11c
X signal(SIGURG, SignalURG);
X#endif /* vax11c */
X signal(SIGPIPE, SignalPIPE);
X signal(SIGINT, SignalINT);
X signal(SIGQUIT, SignalQUIT);
X signal(SIGTERM, SignalTERM);
X#ifndef vax11c
X signal(SIGTSTP, SignalTSTP);
X signal(SIGCONT, SignalCONT);
X#endif /* vax11c */
X`7D
X
X
X
X/* ************************************************************ */
X/*`09`09`09`09`09`09`09`09*/
X/* Create a socket for a service to listen for clients */
X/*`09`09`09`09`09`09`09`09*/
X/* ************************************************************ */
X
X#ifdef vax11c
X#ifdef MULTINET
X#include <sys$common/multinet/include/sys/types.h>`09/* needed by sys/socket
V.h and netinet/in.h */
X#include <sys$common/multinet/include/sys/uio.h>`09/* for struct iovec, used
V by socket.h */
X#include <sys$common/multinet/include/sys/socket.h>`09/* for AF_INET, SOCK_S
VTREAM, ... */
X#include <sys$common/multinet/include/sys/ioctl.h>`09/* for FIONCLEX, FIONBI
VO, ... */
X#include <sys$common/multinet/include/netinet/in.h>`09/* struct sockaddr_in
V */
X#include <sys$common/multinet/include/netdb.h>`09`09/* struct servent * and
V struct hostent * */
X#endif /* MULTINET */
X#else
X#include <sys/types.h>`09 /* needed by sys/socket.h and netinet/in.h *
V/
X#include <sys/uio.h>`09 /* for struct iovec, used by socket.h */
X#include <sys/socket.h>`09 /* for AF_INET, SOCK_STREAM, ... */
X#include <sys/ioctl.h>`09 /* for FIONCLEX, FIONBIO, ... */
X#include <netinet/in.h>`09 /* struct sockaddr_in */
X#include <netdb.h>`09 /* struct servent * and struct hostent * */
X#endif /* vax11c */
X
Xstatic int ON = 1 /* used in ioctl */ ;
X#define`09BACKLOG`095
X
X/* for use in the UsingFD call -- defined later */
Xextern int NewConnection ();
X
X
XSetUpConnectionSocket(iport)
X int iport;
X`7B
X FD ConnectionSocket;
X struct sockaddr_in sin;
X short`09port;
X#ifdef vax11c
X unsigned long int On;
X#endif /* vax11c */
X
X enterprocedure("SetUpConnectionSocket");
X
X /* create the connection socket and set its parameters of use */
X ConnectionSocket = socket(AF_INET, SOCK_STREAM, 0);
X if (ConnectionSocket < 0)
X `7B
X perror("socket");
X exit(-1);
X `7D
X#ifdef vax11c
X On = 0;
X if (setsockopt(ConnectionSocket, SOL_SOCKET, SO_REUSEADDR, &On, sizeof(On)
V) < 0) `7B
X socket_perror("SOCKOPT: REUSADDR");
X exit(-1);
X `7D
X On = 0;
X if (setsockopt(ConnectionSocket, SOL_SOCKET, SO_USELOOPBACK, &On, sizeof(O
Vn)) < 0) `7B
X socket_perror("SOCKOPT: USELOOPBACK");
X exit(-1);
X `7D
X#ifdef SO_DONTLINGER
X if (setsockopt(ConnectionSocket, SOL_SOCKET, SO_DONTLINGER, (char *)NULL,
V 0) < 0) `7B
X socket_perror("SOCKOPT: DONTLINGER");
X exit(-1);
X `7D
X#endif
X#else
X (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_REUSEADDR, (char *)NUL
VL, 0);
X (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_USELOOPBACK, (char *)NUL
VL, 0);
X#ifdef SO_DONTLINGER
X (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_DONTLINGER, (char *)NUL
VL, 0);
X#endif
X#endif /* vax11c */
X
X /* define the name and port to be used with the connection socket */
X bzero((char *)&sin, sizeof(sin));
X sin.sin_family = AF_INET;
X
X /* the address of the socket is composed of two parts: the host machine an
Vd
X the port number. We need the host machine address for the current host
X */
X `7B
X /* define the host part of the address */
X char MyHostName`5B256`5D;
X struct hostent *hp;
X
X#ifdef vax11c
X if (gethostname(MyHostName, sizeof(MyHostName)) < 0) `7B
X`09fprintf(stderr, "Unable to retrieve hostname\n");
X`09exit (-1);
X `7D
X ScopeHost = (char *) MyMalloc((long)strlen(MyHostName));
X#else
X (void) gethostname(MyHostName, sizeof(MyHostName));
X ScopeHost = (char *) Malloc((long)strlen(MyHostName));
X#endif /* vax11c */
X strcpy(ScopeHost, MyHostName);
X hp = gethostbyname(MyHostName);
X if (hp == NULL)
X panic("No address for our host");
X bcopy((char *)hp->h_addr, (char*)&sin.sin_addr, hp->h_length);
X `7D
X /* new code -- INADDR_ANY should be better than using the name of the
X host machine. The host machine may have several different network
X addresses. INADDR_ANY should work with all of them at once. */
X sin.sin_addr.s_addr = INADDR_ANY;
X
X port = iport;
X sin.sin_port = htons (port);
X ScopePort = port;
X
X /* bind the name and port number to the connection socket */
X if (bind(ConnectionSocket, (struct sockaddr *)&sin, sizeof(sin)) < 0)
X `7B
X perror("bind");
X exit(-1);
X `7D
X
X debug(4,(stderr, "Socket is FD %d for %s,%d\n",
X`09 ConnectionSocket, ScopeHost, ScopePort));
X
X /* now activate the named connection socket to get messages */
X if (listen(ConnectionSocket, BACKLOG) < 0)
X `7B
X perror("listen");
X exit(-1);
X `7D;
X
X /* a few more parameter settings */
X#ifdef vax11c
X /* socket_ioctl(ConnectionSocket, FIOCLEX, 0); */
X socket_ioctl(ConnectionSocket, FIONBIO, &ON);
X#else
X ioctl(ConnectionSocket, FIOCLEX, 0);
X ioctl(ConnectionSocket, FIONBIO, &ON);
X#endif /* vax11c */
X
X debug(4,(stderr, "Listening on FD %d\n", ConnectionSocket));
X UsingFD(ConnectionSocket, NewConnection);
X`7D
X
X
$ CALL UNPACK COMMON.C;13 2031753986
$ create 'f'
X/* ************************************************************ *
X *`09`09`09`09`09`09 `09`09*
X * Decoding and switching routines for the X11 protocol`09*
X *`09`09`09`09`09`09 `09`09*
X *`09James Peterson, 1988`09`09`09 `09`09*
X *`09(c) Copyright MCC, 1988 `09`09 `09`09*
X *`09`09`09`09`09`09 `09`09*
X * ************************************************************ */
X#if defined(vax11c) && !defined(MULTINET)
X#include "emulationlib.h"
X#endif
X
X#include "scope.h"
X#include "x11.h"
X
X/*
X There are 4 types of things in X11: requests, replies, errors, and events.
X
X Each of them has a format defined by a small integer that defines
X the type of the thing.
X
X Requests have an opcode in the first byte.
X Events have a code in the first byte.
X Errors have a code in the second byte (the first byte is 0)
X Replies ...
X
X Replies have a sequence number in bytes 2 and 3. The sequence
X number should be used to identify the request that was sent, and
X from that request we can determine the type of the reply.
X*/
X
X
X/* ************************************************************ */
X/*`09`09`09`09`09`09`09`09*/
X/*`09`09`09`09`09`09`09`09*/
X/* ************************************************************ */
X
X
X/*
X We need to keep the sequence number for a request to match it with
X an expected reply. The sequence number is associated only with the
X particular connection that we have. We would expect these replies
X to be handled as a FIFO queue.
X*/
X
Xstruct QueueEntry
X`7B
X struct QueueEntry *Next;
X long SequenceNumber;
X short Request;
X`7D;
X
X/* free space list of Q entries */
X
Xstatic struct QueueEntry *FreeQEntries = NULL;
X
X/* ************************************************************ */
Xstruct QueueEntry *NewQEntry (SequenceNumber, Request)
X long SequenceNumber;
X short Request;
X`7B
X struct QueueEntry *p;
X
X /* Get a Queue Entry */
X if (FreeQEntries == NULL)
X `7B
X /* create new queue entry */
X#ifdef vax11c
X p = (struct QueueEntry *) MyMalloc ((long)(sizeof (*p)));
X#else
X p = (struct QueueEntry *) Malloc ((long)(sizeof (*p)));
X#endif /* vax11c */
X `7D
X else
X `7B
X /* reuse an old queue entry */
X p = FreeQEntries;
X FreeQEntries = FreeQEntries->Next;
X `7D
X
X /* fill in its values */
X p->Next = NULL;
X p->SequenceNumber = SequenceNumber;
X p->Request = Request;
X return(p);
X`7D
X/* ************************************************************ */
X
X/* define a queue of entries for each FD */
X
Xstruct QueueHeader
X`7B
X struct QueueEntry *Head;
X struct QueueEntry *Tail;
X`7D;
X
X#ifdef vax11c`09/* Another Hack, must remember to come back and fix this */
Xstruct QueueHeader *ReplyQ;
X#else
Xstruct QueueHeader ReplyQ`5BStaticMaxFD`5D;
X#endif /* vax11c */
X
X/* ************************************************************ */
X
XInitReplyQ()
X`7B
X short i;
X#ifdef vax11c
X /*
X *`09HACK ALERT! Again we are wasting TOO MUCH memory. But
X *`09in the interests of getting this done, we are going to
X *`09to waste it now. REMEMBER to come back and fix this.
X */
X ReplyQ = (struct QueueHeader *)
X MyMalloc((long)(MaxFD * sizeof (struct QueueHeader)));
X for (i = 0; i < MaxFD; i++) `7B
X ReplyQ`5Bi`5D.Head = NULL;
X ReplyQ`5Bi`5D.Tail = NULL;
X `7D
X#else
X for (i = 0; i < StaticMaxFD; i++)
X `7B
X ReplyQ`5Bi`5D.Head = NULL;
X ReplyQ`5Bi`5D.Tail = NULL;
X `7D
X#endif /* vax11c */
X`7D
X
XFlushReplyQ(fd)
XFD fd;
X`7B
X struct QueueEntry *p;
X struct QueueEntry *NextQEntry;
X
X /* go down the reply queue and free all entries */
X for (p = ReplyQ`5Bfd`5D.Head; p != NULL; p = NextQEntry)
X `7B
X NextQEntry = p->Next;
X `20
X /* put freed entry on list of free entries (for later reuse) */
X p->Next = FreeQEntries;
X FreeQEntries = p;
X `7D
X `20
X ReplyQ`5Bfd`5D.Head = NULL;
X ReplyQ`5Bfd`5D.Tail = NULL;
X`7D
X
X
XDumpReplyQ(fd)
X FD fd;
X`7B
X fprintf(stderr, "ReplyQ`5B%d`5D = `7B Head 0x%x; Tail 0x%x `7D\n",`20
X`09 fd, ReplyQ`5Bfd`5D.Head, ReplyQ`5Bfd`5D.Tail);
X `7B
X struct QueueEntry *p;
X for (p = ReplyQ`5Bfd`5D.Head; p != NULL; p = p->Next)
X fprintf(stderr, "0x%x = `7B Next 0x%x; SequenceNumber %d; Request %d `
V7D\n",
X`09 p, p->Next, p->SequenceNumber, p->Request);
X `7D
X`7D
X/* ************************************************************ */
X/*`09`09`09`09`09`09`09`09*/
X/*`09`09`09`09`09`09`09`09*/
X/* ************************************************************ */
X
X/* A reply is expected to the type of request given for the fd associated
X with this one */
X
XSequencedReplyExpected(fd, SequenceNumber, RequestType)
X FD fd;
X long SequenceNumber;
X short RequestType;
X`7B
X struct QueueEntry *p;
X
X debug(8,(stderr, "Reply expected: sequence %d and request type %d for fd %
Vd\n",
X`09 SequenceNumber, RequestType, fd));
X /* create a new queue entry */
X p = NewQEntry(SequenceNumber, RequestType);
X
X /* find the server associated with this client */
X fd = FDPair(fd);
X#ifdef vax11c
X if (fd < 0 `7C`7C fd >= MaxFD) return;
X#else
X if (fd < 0 `7C`7C fd >= StaticMaxFD) return;
X#endif /* vax11c */
X
X /* attach the new queue entry to the end of the queue for the Server */
X if (ReplyQ`5Bfd`5D.Tail != NULL)
X (ReplyQ`5Bfd`5D.Tail)->Next = p;
X else
X ReplyQ`5Bfd`5D.Head = p;
X ReplyQ`5Bfd`5D.Tail = p;
X
X debug(8,(stderr, "Save sequence %d and request type %d for fd %d\n",
X`09 p->SequenceNumber, p->Request, fd));
X`7D
X
X
Xstatic FD Lastfd;
Xstatic long LastSequenceNumber;
Xstatic short LastReplyType;
X
X/* search for the type of request that is associated with a reply
X to the given sequence number for this fd */
X
Xshort CheckReplyTable (fd, SequenceNumber)
X FD fd;
X short SequenceNumber;
X`7B
X struct QueueEntry *p;
X struct QueueEntry *trailer;
X
X if (debuglevel & 128) DumpReplyQ(fd);
X for (trailer = NULL, p = ReplyQ`5Bfd`5D.Head;
X p != NULL;
X trailer = p, p = p->Next)
X `7B
X /* look for matching sequence number in queue of this fd */
X if (SequenceNumber == ((short)(0xFFFF & p->SequenceNumber)))
X`09`7B
X`09 /* save the Request type */
X`09 Lastfd = fd;
X`09 LastSequenceNumber = p->SequenceNumber;
X`09 LastReplyType = p->Request;
X
X`09 /* pull the queue entry out of the queue for this fd */
X`09 if (trailer == NULL)
X`09 ReplyQ`5Bfd`5D.Head = p->Next;
X`09 else
X`09 trailer->Next = p->Next;
X`09 if (ReplyQ`5Bfd`5D.Tail == p) ReplyQ`5Bfd`5D.Tail = trailer;
X
X
X`09 /* put freed entry on list of free entries (for later reuse) */
X`09 p->Next = FreeQEntries;
X`09 FreeQEntries = p;
X
X`09 debug(8,(stderr, "Reply on fd %d for sequence %d is type %d\n",
X`09`09 fd, SequenceNumber, LastReplyType));
X`09 return(LastReplyType);
X`09`7D
X `7D
X
X /* not expecting a reply for that sequence number */
X debug(8,(stderr, "Reply on fd %d for sequence %d is not found\n",
X`09 fd, SequenceNumber));
X return(0);
X`7D
X
X
X/* ************************************************************ */
X/* A reply is expected to the type of request given for the
X sequence number associated with this fd */
X
XReplyExpected(fd, Request)
X FD fd;
X short Request;
X`7B
X SequencedReplyExpected(fd, CS`5Bfd`5D.SequenceNumber, Request);
X`7D
X
X/* ************************************************************ */
X/* another reply is expected for the same reply as we just had */
X/* This is only used with ListFontsWithInfo */
X
XKeepLastReplyExpected()
X`7B
X SequencedReplyExpected(Lastfd, LastSequenceNumber, LastReplyType);
X`7D
X
X/* ************************************************************ */
X/*`09`09`09`09`09`09`09`09*/
X/*`09`09`09`09`09`09`09`09*/
X/* ************************************************************ */
X
X
XDecodeRequest(fd, buf, n)
X FD fd;
X unsigned char *buf;
X long n;
X`7B
X short Request = IByte (&buf`5B0`5D);
X CS`5Bfd`5D.SequenceNumber += 1;
X bcopy ((char *)&(CS`5Bfd`5D.SequenceNumber), (char *)SBf, sizeof(long));
X SetIndentLevel(PRINTCLIENT);
X
X if (Verbose > 3)
X DumpItem("Request", fd, buf, n);
X if (Request <= 0 `7C`7C 127 < Request)
X warn("Extended request opcode");
X else switch (Request)
X `7B
X`09 case 1:
X`09`09 CreateWindow(buf);
X`09`09 break;
X`09 case 2:
X`09`09 ChangeWindowAttributes(buf);
X`09`09 break;
X`09 case 3:
X`09`09 GetWindowAttributes(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 4:
X`09`09 DestroyWindow(buf);
X`09`09 break;
X`09 case 5:
X`09`09 DestroySubwindows(buf);
X`09`09 break;
X`09 case 6:
X`09`09 ChangeSaveSet(buf);
X`09`09 break;
X`09 case 7:
X`09`09 ReparentWindow(buf);
X`09`09 break;
X`09 case 8:
X`09`09 MapWindow(buf);
X`09`09 break;
X`09 case 9:
X`09`09 MapSubwindows(buf);
X`09`09 break;
X`09 case 10:
X`09`09 UnmapWindow(buf);
X`09`09 break;
X`09 case 11:
X`09`09 UnmapSubwindows(buf);
X`09`09 break;
X`09 case 12:
X`09`09 ConfigureWindow(buf);
X`09`09 break;
X`09 case 13:
X`09`09 CirculateWindow(buf);
X`09`09 break;
X`09 case 14:
X`09`09 GetGeometry(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 15:
X`09`09 QueryTree(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 16:
X`09`09 InternAtom(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 17:
X`09`09 GetAtomName(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 18:
X`09`09 ChangeProperty(buf);
X`09`09 break;
X`09 case 19:
X`09`09 DeleteProperty(buf);
X`09`09 break;
X`09 case 20:
X`09`09 GetProperty(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 21:
X`09`09 ListProperties(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 22:
X`09`09 SetSelectionOwner(buf);
X`09`09 break;
X`09 case 23:
X`09`09 GetSelectionOwner(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 24:
X`09`09 ConvertSelection(buf);
X`09`09 break;
X`09 case 25:
X`09`09 SendEvent(buf);
X`09`09 break;
X`09 case 26:
X`09`09 GrabPointer(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 27:
X`09`09 UngrabPointer(buf);
X`09`09 break;
X`09 case 28:
X`09`09 GrabButton(buf);
X`09`09 break;
X`09 case 29:
X`09`09 UngrabButton(buf);
X`09`09 break;
X`09 case 30:
X`09`09 ChangeActivePointerGrab(buf);
X`09`09 break;
X`09 case 31:
X`09`09 GrabKeyboard(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 32:
X`09`09 UngrabKeyboard(buf);
X`09`09 break;
X`09 case 33:
X`09`09 GrabKey(buf);
X`09`09 break;
X`09 case 34:
X`09`09 UngrabKey(buf);
X`09`09 break;
X`09 case 35:
X`09`09 AllowEvents(buf);
X`09`09 break;
X`09 case 36:
X`09`09 GrabServer(buf);
X`09`09 break;
X`09 case 37:
X`09`09 UngrabServer(buf);
X`09`09 break;
X`09 case 38:
X`09`09 QueryPointer(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 39:
X`09`09 GetMotionEvents(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 40:
X`09`09 TranslateCoordinates(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 41:
X`09`09 WarpPointer(buf);
X`09`09 break;
X`09 case 42:
X`09`09 SetInputFocus(buf);
X`09`09 break;
X`09 case 43:
X`09`09 GetInputFocus(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 44:
X`09`09 QueryKeymap(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 45:
X`09`09 OpenFont(buf);
X`09`09 break;
X`09 case 46:
X`09`09 CloseFont(buf);
X`09`09 break;
X`09 case 47:
X`09`09 QueryFont(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 48:
X`09`09 QueryTextExtents(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 49:
X`09`09 ListFonts(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 50:
X`09`09 ListFontsWithInfo(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 51:
X`09`09 SetFontPath(buf);
X`09`09 break;
X`09 case 52:
X`09`09 GetFontPath(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 53:
X`09`09 CreatePixmap(buf);
X`09`09 break;
X`09 case 54:
X`09`09 FreePixmap(buf);
X`09`09 break;
X`09 case 55:
X`09`09 CreateGC(buf);
X`09`09 break;
X`09 case 56:
X`09`09 ChangeGC(buf);
X`09`09 break;
X`09 case 57:
X`09`09 CopyGC(buf);
X`09`09 break;
X`09 case 58:
X`09`09 SetDashes(buf);
X`09`09 break;
X`09 case 59:
X`09`09 SetClipRectangles(buf);
X`09`09 break;
X`09 case 60:
X`09`09 FreeGC(buf);
X`09`09 break;
X`09 case 61:
X`09`09 ClearArea(buf);
X`09`09 break;
X`09 case 62:
X`09`09 CopyArea(buf);
X`09`09 break;
X`09 case 63:
X`09`09 CopyPlane(buf);
X`09`09 break;
X`09 case 64:
X`09`09 PolyPoint(buf);
X`09`09 break;
X`09 case 65:
X`09`09 PolyLine(buf);
X`09`09 break;
X`09 case 66:
X`09`09 PolySegment(buf);
X`09`09 break;
X`09 case 67:
X`09`09 PolyRectangle(buf);
X`09`09 break;
X`09 case 68:
X`09`09 PolyArc(buf);
X`09`09 break;
X`09 case 69:
X`09`09 FillPoly(buf);
X`09`09 break;
X`09 case 70:
X`09`09 PolyFillRectangle(buf);
X`09`09 break;
X`09 case 71:
X`09`09 PolyFillArc(buf);
X`09`09 break;
X`09 case 72:
X`09`09 PutImage(buf);
X`09`09 break;
X`09 case 73:
X`09`09 GetImage(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 74:
X`09`09 PolyText8(buf);
X`09`09 break;
X`09 case 75:
X`09`09 PolyText16(buf);
X`09`09 break;
X`09 case 76:
X`09`09 ImageText8(buf);
X`09`09 break;
X`09 case 77:
X`09`09 ImageText16(buf);
X`09`09 break;
X`09 case 78:
X`09`09 CreateColormap(buf);
X`09`09 break;
X`09 case 79:
X`09`09 FreeColormap(buf);
X`09`09 break;
X`09 case 80:
X`09`09 CopyColormapAndFree(buf);
X`09`09 break;
X`09 case 81:
X`09`09 InstallColormap(buf);
X`09`09 break;
X`09 case 82:
X`09`09 UninstallColormap(buf);
X`09`09 break;
X`09 case 83:
X`09`09 ListInstalledColormaps(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 84:
X`09`09 AllocColor(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 85:
X`09`09 AllocNamedColor(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 86:
X`09`09 AllocColorCells(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 87:
X`09`09 AllocColorPlanes(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 88:
X`09`09 FreeColors(buf);
X`09`09 break;
X`09 case 89:
X`09`09 StoreColors(buf);
X`09`09 break;
X`09 case 90:
X`09`09 StoreNamedColor(buf);
X`09`09 break;
X`09 case 91:
X`09`09 QueryColors(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 92:
X`09`09 LookupColor(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 93:
X`09`09 CreateCursor(buf);
X`09`09 break;
X`09 case 94:
X`09`09 CreateGlyphCursor(buf);
X`09`09 break;
X`09 case 95:
X`09`09 FreeCursor(buf);
X`09`09 break;
X`09 case 96:
X`09`09 RecolorCursor(buf);
X`09`09 break;
X`09 case 97:
X`09`09 QueryBestSize(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 98:
X`09`09 QueryExtension(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 99:
X`09`09 ListExtensions(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 100:
X`09`09 ChangeKeyboardMapping(buf);
X`09`09 break;
X`09 case 101:
X`09`09 GetKeyboardMapping(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 102:
X`09`09 ChangeKeyboardControl(buf);
X`09`09 break;
X`09 case 103:
X`09`09 GetKeyboardControl(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 104:
X`09`09 Bell(buf);
X`09`09 break;
X`09 case 105:
X`09`09 ChangePointerControl(buf);
X`09`09 break;
X`09 case 106:
X`09`09 GetPointerControl(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 107:
X`09`09 SetScreenSaver(buf);
X`09`09 break;
X`09 case 108:
X`09`09 GetScreenSaver(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 109:
X`09`09 ChangeHosts(buf);
X`09`09 break;
X`09 case 110:
X`09`09 ListHosts(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 111:
X`09`09 SetAccessControl(buf);
X`09`09 break;
X`09 case 112:
X`09`09 SetCloseDownMode(buf);
X`09`09 break;
X`09 case 113:
X`09`09 KillClient(buf);
X`09`09 break;
X`09 case 114:
X`09`09 RotateProperties(buf);
X`09`09 break;
X`09 case 115:
X`09`09 ForceScreenSaver(buf);
X`09`09 break;
X`09 case 116:
X`09`09 SetPointerMapping(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 117:
X`09`09 GetPointerMapping(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 118:
X`09`09 SetModifierMapping(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 119:
X`09`09 GetModifierMapping(buf);
X`09`09 ReplyExpected(fd, Request);
X`09`09 break;
X`09 case 127:
X`09`09 NoOperation(buf);
X`09`09 break;
X`09 default:
X`09`09 warn("Unimplemented request opcode");
X`09`09 break;
X `7D
X`7D
X
X/* ************************************************************ */
X/*`09`09`09`09`09`09`09`09*/
X/*`09`09`09`09`09`09`09`09*/
X/* ************************************************************ */
X
XDecodeReply(fd, buf, n)
X FD fd;
X unsigned char *buf;
X long n;
X`7B
X short SequenceNumber = IShort (&buf`5B2`5D);
X short Request = CheckReplyTable (fd, SequenceNumber);
X if (Request == 0)
X `7B
X warn("Unexpected reply");
X return;
X `7D
X SetIndentLevel(PRINTSERVER);
X RBf`5B0`5D = Request /* for the PrintField in the Reply procedure */ ;
X if (Verbose > 3)
X DumpItem("Reply", fd, buf, n);
X if (Request <= 0 `7C`7C 127 < Request)
X warn("Extended reply opcode");
X else switch (Request)
X `7B
X`09 case 3:
X`09`09 GetWindowAttributesReply(buf);
X`09`09 break;
X`09 case 14:
X`09`09 GetGeometryReply(buf);
X`09`09 break;
X`09 case 15:
X`09`09 QueryTreeReply(buf);
X`09`09 break;
X`09 case 16:
X`09`09 InternAtomReply(buf);
X`09`09 break;
X`09 case 17:
X`09`09 GetAtomNameReply(buf);
X`09`09 break;
X`09 case 20:
X`09`09 GetPropertyReply(buf);
X`09`09 break;
X`09 case 21:
X`09`09 ListPropertiesReply(buf);
X`09`09 break;
X`09 case 23:
X`09`09 GetSelectionOwnerReply(buf);
X`09`09 break;
X`09 case 26:
X`09`09 GrabPointerReply(buf);
X`09`09 break;
X`09 case 31:
X`09`09 GrabKeyboardReply(buf);
X`09`09 break;
X`09 case 38:
X`09`09 QueryPointerReply(buf);
X`09`09 break;
X`09 case 39:
X`09`09 GetMotionEventsReply(buf);
X`09`09 break;
X`09 case 40:
X`09`09 TranslateCoordinatesReply(buf);
X`09`09 break;
X`09 case 43:
X`09`09 GetInputFocusReply(buf);
X`09`09 break;
X`09 case 44:
X`09`09 QueryKeymapReply(buf);
X`09`09 break;
X`09 case 47:
X`09`09 QueryFontReply(buf);
X`09`09 break;
X`09 case 48:
X`09`09 QueryTextExtentsReply(buf);
X`09`09 break;
X`09 case 49:
X`09`09 ListFontsReply(buf);
X`09`09 break;
X`09 case 50:
X`09`09 ListFontsWithInfoReply(buf);
X`09`09 break;
X`09 case 52:
X`09`09 GetFontPathReply(buf);
X`09`09 break;
X`09 case 73:
X`09`09 GetImageReply(buf);
X`09`09 break;
X`09 case 83:
X`09`09 ListInstalledColormapsReply(buf);
X`09`09 break;
X`09 case 84:
X`09`09 AllocColorReply(buf);
X`09`09 break;
X`09 case 85:
X`09`09 AllocNamedColorReply(buf);
X`09`09 break;
X`09 case 86:
X`09`09 AllocColorCellsReply(buf);
X`09`09 break;
X`09 case 87:
X`09`09 AllocColorPlanesReply(buf);
X`09`09 break;
X`09 case 91:
X`09`09 QueryColorsReply(buf);
X`09`09 break;
X`09 case 92:
X`09`09 LookupColorReply(buf);
X`09`09 break;
X`09 case 97:
X`09`09 QueryBestSizeReply(buf);
X`09`09 break;
X`09 case 98:
X`09`09 QueryExtensionReply(buf);
X`09`09 break;
X`09 case 99:
X`09`09 ListExtensionsReply(buf);
X`09`09 break;
X`09 case 101:
X`09`09 GetKeyboardMappingReply(buf);
X`09`09 break;
X`09 case 103:
X`09`09 GetKeyboardControlReply(buf);
X`09`09 break;
X`09 case 106:
X`09`09 GetPointerControlReply(buf);
X`09`09 break;
X`09 case 108:
X`09`09 GetScreenSaverReply(buf);
X`09`09 break;
X`09 case 110:
X`09`09 ListHostsReply(buf);
X`09`09 break;
X`09 case 116:
X`09`09 SetPointerMappingReply(buf);
X`09`09 break;
X`09 case 117:
X`09`09 GetPointerMappingReply(buf);
X`09`09 break;
X`09 case 118:
X`09`09 SetModifierMappingReply(buf);
X`09`09 break;
X`09 case 119:
X`09`09 GetModifierMappingReply(buf);
X`09`09 break;
X`09 default:
X`09`09 warn("Unimplemented reply opcode");
X`09`09 break;
X `7D
X`7D
X
X/* ************************************************************ */
X/*`09`09`09`09`09`09`09`09*/
X/*`09`09`09`09`09`09`09`09*/
X/* ************************************************************ */
X
XDecodeError(fd, buf, n)
X FD fd;
X unsigned char *buf;
X long n;
X`7B
X short Error = IByte (&buf`5B1`5D);
X SetIndentLevel(PRINTSERVER);
X if (Verbose > 3)
X DumpItem("Error", fd, buf, n);
X (void)CheckReplyTable (fd, (short)IShort(&buf`5B2`5D));
X if (Error < 1 `7C`7C Error > 17)
X warn("Extended Error code");
X else switch (Error)
X `7B
X`09 case 1:
X`09`09 RequestError(buf);
X`09`09 break;
X`09 case 2:
X`09`09 ValueError(buf);
X`09`09 break;
X`09 case 3:
X`09`09 WindowError(buf);
X`09`09 break;
X`09 case 4:
X`09`09 PixmapError(buf);
X`09`09 break;
X`09 case 5:
X`09`09 AtomError(buf);
X`09`09 break;
X`09 case 6:
X`09`09 CursorError(buf);
X`09`09 break;
X`09 case 7:
X`09`09 FontError(buf);
X`09`09 break;
X`09 case 8:
X`09`09 MatchError(buf);
X`09`09 break;
X`09 case 9:
X`09`09 DrawableError(buf);
X`09`09 break;
X`09 case 10:
X`09`09 AccessError(buf);
X`09`09 break;
X`09 case 11:
X`09`09 AllocError(buf);
X`09`09 break;
X`09 case 12:
X`09`09 ColormapError(buf);
X`09`09 break;
X`09 case 13:
X`09`09 GContextError(buf);
X`09`09 break;
X`09 case 14:
X`09`09 IDChoiceError(buf);
X`09`09 break;
X`09 case 15:
X`09`09 NameError(buf);
X`09`09 break;
X`09 case 16:
X`09`09 LengthError(buf);
X`09`09 break;
X`09 case 17:
X`09`09 ImplementationError(buf);
X`09`09 break;
X`09 default:
X`09`09 warn("Unimplemented error code");
X`09`09 break;
X `7D
X`7D
X
X/* ************************************************************ */
X/*`09`09`09`09`09`09`09`09*/
X/*`09`09`09`09`09`09`09`09*/
X/* ************************************************************ */
X
XDecodeEvent(fd, buf, n)
X FD fd;
X unsigned char *buf;
X long n;
X`7B
X short Event = IByte (&buf`5B0`5D);
X SetIndentLevel(PRINTSERVER);
X if (Verbose > 3)
X DumpItem("Event", fd, buf, n);
X if (Event < 2 `7C`7C Event > 34)
X warn("Extended Event code");
X else switch (Event)
X `7B
X`09 case 2:
X`09`09 KeyPressEvent(buf);
X`09`09 break;
X`09 case 3:
X`09`09 KeyReleaseEvent(buf);
X`09`09 break;
X`09 case 4:
X`09`09 ButtonPressEvent(buf);
X`09`09 break;
X`09 case 5:
X`09`09 ButtonReleaseEvent(buf);
X`09`09 break;
X`09 case 6:
X`09`09 MotionNotifyEvent(buf);
X`09`09 break;
X`09 case 7:
X`09`09 EnterNotifyEvent(buf);
X`09`09 break;
X`09 case 8:
X`09`09 LeaveNotifyEvent(buf);
X`09`09 break;
X`09 case 9:
X`09`09 FocusInEvent(buf);
X`09`09 break;
X`09 case 10:
X`09`09 FocusOutEvent(buf);
X`09`09 break;
X`09 case 11:
X`09`09 KeymapNotifyEvent(buf);
X`09`09 break;
X`09 case 12:
X`09`09 ExposeEvent(buf);
X`09`09 break;
X`09 case 13:
X`09`09 GraphicsExposureEvent(buf);
X`09`09 break;
X`09 case 14:
X`09`09 NoExposureEvent(buf);
X`09`09 break;
X`09 case 15:
X`09`09 VisibilityNotifyEvent(buf);
X`09`09 break;
X`09 case 16:
X`09`09 CreateNotifyEvent(buf);
X`09`09 break;
X`09 case 17:
X`09`09 DestroyNotifyEvent(buf);
X`09`09 break;
X`09 case 18:
X`09`09 UnmapNotifyEvent(buf);
X`09`09 break;
X`09 case 19:
X`09`09 MapNotifyEvent(buf);
X`09`09 break;
X`09 case 20:
X`09`09 MapRequestEvent(buf);
X`09`09 break;
X`09 case 21:
X`09`09 ReparentNotifyEvent(buf);
X`09`09 break;
X`09 case 22:
X`09`09 ConfigureNotifyEvent(buf);
X`09`09 break;
X`09 case 23:
X`09`09 ConfigureRequestEvent(buf);
X`09`09 break;
X`09 case 24:
X`09`09 GravityNotifyEvent(buf);
X`09`09 break;
X`09 case 25:
X`09`09 ResizeRequestEvent(buf);
X`09`09 break;
X`09 case 26:
X`09`09 CirculateNotifyEvent(buf);
X`09`09 break;
X`09 case 27:
X`09`09 CirculateRequestEvent(buf);
X`09`09 break;
X`09 case 28:
X`09`09 PropertyNotifyEvent(buf);
X`09`09 break;
X`09 case 29:
X`09`09 SelectionClearEvent(buf);
X`09`09 break;
X`09 case 30:
X`09`09 SelectionRequestEvent(buf);
X`09`09 break;
X`09 case 31:
X`09`09 SelectionNotifyEvent(buf);
X`09`09 break;
X`09 case 32:
X`09`09 ColormapNotifyEvent(buf);
X`09`09 break;
X`09 case 33:
X`09`09 ClientMessageEvent(buf);
X`09`09 break;
X`09 case 34:
X`09`09 MappingNotifyEvent(buf);
X`09`09 break;
X`09 default:
X`09`09 warn("Unimplemented event code");
X`09`09 break;
X `7D
X`7D
$ CALL UNPACK DECODE11.C;4 661840910
$ create 'f'
X/*
X * $NCDId: @(#)dnet_socket_library.c,v 4.9 1992/02/12 16:01:34 hardison Exp
V $
X *
X * Socket library emulation for DECnet.
X * This library was created primarily out of the need for a socket-type inte
Vrface
X * for DECnet on a VMS host (originally for the DECnet Font Server from NCD)
V. `20
X * Gradually, the various socket calls and lower level functions evolved int
Vo its`20
X * present form. The various assumptions and warnings for each routine are
V included`20
X * before its declaration.
X *
X * Another fine product from: Osborne Hardison - NCD - 11/21/91
X *
X * Modifications:
X *
X * - Added support for gethostbyxxxx by querying the NCP database for node n
Vames
X * and addresses; subsequent calls to NCPfind use a binary search to actu
Vally find
X * the given reference (inputs can be in the form of a name, a DECnet addr
Vess, or
X * a hybrid address composed of the last two bytes of the active ethernet
V address).
X * OBH - 1/5/92
X * - Made changes to accept, bind and nameFromPort for XSCOPE fixes.
X * OBH - 3/23/92
X *
X */
X#module DSL DNET_SOCKET_LIBRARY `09/* for easy DEBUG reference */
X
X#include stdio
X#include dvidef
X#include msgdef
X#include syidef
X#include ssdef
X#include stsdef
X#include descrip
X#include nfbdef
X#include iodef
X#include errno
X#include time
X#include ctype
X#include "emulationlib.h"`09`09/* emulation macros and definitions */
X#include "portobj.h"`09`09`09/* port/object translations */
X#pragma builtins`09`09`09/* for _FFS support */
X
Xextern volatile int noshare socket_errno;
Xextern volatile int noshare h_errno;
Xextern volatile int noshare errno;
X
Xstatic $DESCRIPTOR (netcmd_mbx, "NETCMD_MBX");
Xstatic $DESCRIPTOR (net_device, "_NET:");
Xstatic unsigned short lisChannel = 0;
Xstatic unsigned short mbxChannel = 0;
Xstatic unsigned short netChannel = 0;
Xstatic int stackIndex;
Xstatic int timerExpired;
Xstatic int zero = 0;
Xstatic int info_cnt;
Xstatic int NCPtot = 0;
Xstatic int mbx_created = 0;
Xstatic int initChanTable = 1;
Xstatic int mbxMsgLen = MAX_MSG;
Xstatic char *ncb = NULL;
Xstatic struct io_stat_blk netiosb;
Xstatic NCPstruct *pNCP = NULL;
Xstatic struct chantable *ChanTableInfo`5BFD_SETSIZE`5D;
Xstatic struct stackstruct stack`5BMAX_LINKS`5D;
X
Xfd_set channelfds;
Xfd_set *allChannels = &channelfds;
X
X#define Number(a) (sizeof(a)/sizeof(a`5B0`5D))
X
X`0C
X/*`20
X * SUPPORT ROUTINE DECLARATIONS
X * Routines to support socket library emulation routines
X */
Xvoid `09`09clearChanTable ();`09/* Sets up and clears Channel Table */
Xint `09`09connectNet ();`09`09/* Connects to NET: and network MBX */
Xchar `09`09*dnMalloc ();`09`09/* Special malloc */
Xint `09`09dnFree ();`09`09/* Special free */
Xchar `09`09*initNCB ();`09`09/* Net control block init routine */
Xint `09`09isEtherAddr ();`09`09/* funct to determine is passed str is enet a
Vddr */
Xint `09`09isDnetAddr ();`09`09/* funct to determine is passed str is dnet ad
Vdr */
Xint `09`09issueNetCmdRead ();`09/* funct to issue a network read w/AST */
Xint `09`09issueRead ();`09`09/* funct to issue a socket read w/AST */
Xvoid `09`09linkInit ();`09`09/* link initilization routine */
Xvoid `09`09linkTerm ();`09`09/* link termination routine */
Xstruct dsc$descriptor *nameFromPort ();`09/* funct to return an object from
V a port designation */
Xstatic int `09NCPpredicate ();`09/* funct to pass to qsort */
Xint `09`09NCPinit ();`09`09/* sets up the DECnet node data */
Xint `09`09NCPfind ();`09`09/* finds DECnet node info from name or addr */
Xvoid `09`09netCmdAst ();`09`09/* AST for network messages */
Xvoid `09`09notUsed ();`09`09/* funct for unrecognized network messages */
Xint `09`09processNetCmd ();`09/* processes network messages */
Xint`09`09readAst ();`09`09/* AST for all asynch select socket reads */
Xvoid `09`09timeoutAst ();`09`09/* funct for select timeouts */
Xvoid `09`09upper ();`09`09/* lower to upper conversion */
X
X`0C
X/*`20
X * EMULATION ROUTINE DECLARATIONS
X * Routines for the actual socket library emulation
X */
Xunsigned short `09accept ();
Xint `09`09bcmp ();
Xvoid `09`09*bcopy ();
Xint `09`09bind ();
Xint `09`09bzero ();
Xint `09`09connect ();
Xint `09`09ffs ();
Xint `09`09getdtablesize ();
Xstruct hostent `09*gethostbyaddr ();
Xstruct hostent `09*gethostbyname ();
Xint `09`09gethostname ();
Xint `09`09getpeername ();
Xint `09`09gettimeofday ();
Xunsigned short `09htons ();
Xint `09`09htonl ();
Xint `09`09inet_addr ();
Xint `09`09listen ();
Xint `09`09select ();
Xint `09`09setsockopt ();
Xunsigned short `09socket ();
Xint `09`09socket_close ();
Xint `09`09socket_ioctl ();
Xvoid `09`09socket_perror ();
Xint `09`09socket_read ();
Xint `09`09socket_write ();
Xint `09`09socket_writev ();
X
X`0C
X/*
X * SUPPORT ROUTINES
X */
X
X/*
X * clearChanTable():
X * Module to allocate a chantable-struct-sized chunk of VM (if the entry in
X * the channel table is NULL for the passed shifted channel) or to free the`
V20
X * current chunk of VM that is used to maps the passed channel's information
V (as
X * in the case of a link termination).
X */
Xvoid
XclearChanTable (shiftChan)
X`09unsigned short shiftChan;
X`7B
X`09int`09i;
X`09static int movlen = sizeof(struct chantable);
X
X`09if (initChanTable)
X`09`7B
X`09`09initChanTable = 0;
X`09`09for (i = 0; i < FD_SETSIZE; i++)
X`09`09`09ChanTableInfo`5Bi`5D = (struct chantable *) NULL;
X`09`7D
X/*`20
X * Allocate or free the channel table info area in VM depending on who calle
Vd`20
X * this procedure.
X */
X`09if (ChanTableInfo`5BshiftChan`5D)
X`09`7B
X`09`09if (ChanTableInfo`5BshiftChan`5D->nodename)
X`09`09`09DNETFREE (ChanTableInfo`5BshiftChan`5D->nodename);
X`09`09if (ChanTableInfo`5BshiftChan`5D->base)
X`09`09`09DNETFREE (ChanTableInfo`5BshiftChan`5D->base);
X`09`09if (ChanTableInfo`5BshiftChan`5D->backLogQueue)
X`09`09`09DNETFREE (ChanTableInfo`5BshiftChan`5D->backLogQueue);
X`09`09DNETFREE (ChanTableInfo`5BshiftChan`5D);
X`09`09ChanTableInfo`5BshiftChan`5D = (struct chantable *) NULL;
X`09`09FD_CLR((shiftChan<<4), allChannels);
X`09`09return;
X`09`7D
X`09ChanTableInfo`5BshiftChan`5D = (struct chantable *) DNETALLOC (movlen);
X`09LIB$MOVC5 (&zero, NULL, "\0", &movlen, (char *) ChanTableInfo`5BshiftChan
V`5D);
X `09ChanTableInfo`5BshiftChan`5D->base = DNETALLOC(MAX_QIO);
X `09ChanTableInfo`5BshiftChan`5D->delta = ChanTableInfo`5BshiftChan`5D->b
Vase;
X`7D
X
X`0C
X/*
X * connectNet
X * Creates a link to the _NET: device and, if no MBX link exists, creates o
Vne
X * to the network mailbox.
X */
Xint
XconnectNet ()
X`7B
X `09int`09status;
X
X `09if (!mbx_created)
X `09`7B
X `09`09status = SYS$CREMBX (TEMP_MBX, &mbxChannel, MAX_MSG, BUF_QUO, 0, 0
V, &netcmd_mbx);
X`09`09if (VMSFAIL(status)) LIB$SIGNAL(status);
X `09`09mbx_created++;
X `09`7D
X`09status = SYS$ASSIGN (&net_device, &netChannel, 0, &netcmd_mbx);
X`09if (VMSFAIL(status)) LIB$SIGNAL(status);
X#ifdef DNDEBUG
X `09fprintf(stderr, "connectNet: netChannel: %d\n", netChannel);
X#endif
X `09return status;
X`7D
X
X`0C
X/*
X * malloc and free routines:
X * These are specifically tied to LIB$GET_VM and LIB$FREE_VM to
X * 1) speed things up a notch, and
X * 2) get away from using buggy CRTL malloc.
X */
Xchar *
XdnMalloc(size)
X `09int size;
X`7B
X `09int status;
X `09int soql = sizeof(long) * 8;
X `09char *addr;
X
X `09size = (((((size + sizeof(int)) + (soql - 1))/soql) +1) * soql);
X `09status = LIB$GET_VM(&size, (unsigned long *) &addr);
X `09if (VMSFAIL(status)) LIB$SIGNAL(status);
X `09bcopy ((char *) &size, addr, sizeof(int));
X `09addr += sizeof(int);
X `09return addr;
X`7D
X
X`0C
Xint
XdnFree(addr)
X `09char *addr;
X`7B
X `09int status;
X `09unsigned int size;
X `09
X `09if (!addr) return 1;
X `09addr -= sizeof(int);
X `09bcopy (addr, (char *) &size, sizeof(int));
X `09status = LIB$FREE_VM(&size, (unsigned long *) &addr);
X `09if (VMSFAIL(status)) LIB$SIGNAL(status);
X `09return 1;
X`7D
X
X`0C
X/*`20
X * initNCB
X * Module to create Network Control Block as in,`20
X * `7B "MV3100::",'"',"TASK=FONT$FS/",0,'"' `7D from something that looks`20
X * like this: "decnet/mv3100::FONT$FS". Note that the object name is`20
X * assumed to be at the pointer located one word off of the "name" pointer`2
V0
X * (name+2), where name points to the sockaddr structure from the program`20
X * that called (connect()).
X */
Xchar *
XinitNCB (name, objlen, task, node)
X`09struct sockaddr *name;
X`09unsigned short`09*objlen;
X`09char *task;
X`09char *node;
X`7B
X`09char *pncb = (char *) DNETALLOC (NCBSIZE);
X`09char *op;
X`09char *onp;
X
X`09if (!node)
X`09`7B
X`09`09`7B
X`09`09`09char *oop = (char *) ((char *) name + sizeof(name->sa_family));
X`09`09`09char *t = &op;
X`09`09`09bcopy (oop, t, sizeof(&op));
X`09`09`7D
X `09`09if (!isalpha(*op)) return NULL;
X`09`09upper(op);
X`09`09if (!(memcmp(op, DNET_PREFIX, strlen(DNET_PREFIX))))`20
X`09`09`09op += strlen(DNET_PREFIX);
X`09`09else
X `09`09`09return NULL;
X`09`7D
X`09else
X`09`09op = node;
X`09bcopy(op, (char *) pncb, strlen(op));
X`09onp = strchr(pncb, ':') + 2;
X`09if (!node) op = strchr(op, ':') + 2;
X`09*onp++ = '"';
X`09strcpy(onp, task);
X`09onp += strlen(task);
X`09if (!node)
X`09`7B
X`09`09strcpy(onp, op);
X`09`09onp += strlen(op);
X`09`09*onp++ = '/';
X`09`7D
X`09*onp++ = '\0';
X`09*onp++ = '\0';
X`09*onp++ = '"';
X`09*objlen = onp - (char *) pncb;
X`09return pncb;
X`7D
X
X`0C
X/*
X * isEtherAddr
X * Boolean routine to determine if a passed client node name
X * is a valid DECnet name or a ethernet ad hoc name derived from the
X * last two bytes of the active ethernet address.
X */
Xint
XisEtherAddr (caddr)
X `09char *caddr;
X`7B
X `09char *a;
X
+-+-+-+-+-+-+-+- END OF PART 1 +-+-+-+-+-+-+-+-
--
Patrick L. Mahan
--- TGV Window Washer ------------------------------- Mahan@TGV.COM ---------
Waking a person unnecessarily should not be considered - Lazarus Long
a capital crime. For a first offense, that is From the Notebooks of
Lazarus Long
Technical Details
Message-ID:
<8045404@MVB.SAIC.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!news.service.uci.edu!unogate!mvb.saic.com!vmsnet-sourcesShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!news.service.uci.edu!unogate!mvb.saic.com!vmsnet-sources From: mahan@tgv.com (Patrick L. Mahan - TGV Window Washer) Newsgroups: vmsnet.sources Subject: XSCOPE/VMS 1.0, part 01/08 Message-ID: <8045404@MVB.SAIC.COM> Date: Fri, 04 Sep 1992 05:34:11 GMT Reply-To: mahan@tgv.com Organization: TGV Incorporated (Tech Support) in Santa Cruz, CA Lines: 1797 Approved: Mark.Berryman@Mvb.Saic.Com