home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / vmsnet / sources / 348 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  47.2 KB

  1. Path: sparky!uunet!usc!news.service.uci.edu!unogate!mvb.saic.com!vmsnet-sources
  2. From: mahan@tgv.com (Patrick L. Mahan - TGV Window Washer)
  3. Newsgroups: vmsnet.sources
  4. Subject: XSCOPE/VMS 1.0, part 01/08
  5. Message-ID: <8045404@MVB.SAIC.COM>
  6. Date: Fri, 04 Sep 1992 05:34:11 GMT
  7. Reply-To: mahan@tgv.com
  8. Organization: TGV Incorporated (Tech Support) in Santa Cruz, CA
  9. Lines: 1797
  10. Approved: Mark.Berryman@Mvb.Saic.Com
  11.  
  12. Submitted-by: mahan@tgv.com (Patrick L. Mahan - TGV Window Washer)
  13. Posting-number: Volume 3, Issue 153
  14. Archive-name: xscope/part01
  15.  
  16.  
  17. $! ------------------ CUT HERE -----------------------
  18. $ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
  19. $!
  20. $! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
  21. $!   On  9-JUN-1992 23:28:42.94   By user MAHAN (Patrick L. Mahan)
  22. $!
  23. $! This VMS_SHARE Written by:
  24. $!    Andy Harper, Kings College London UK
  25. $!
  26. $! Acknowledgements to:
  27. $!    James Gray       - Original VMS_SHARE
  28. $!    Michael Bednarek - Original Concept and implementation
  29. $!
  30. $!+ THIS PACKAGE DISTRIBUTED IN 8 PARTS, TO KEEP EACH PART
  31. $!  BELOW 100 BLOCKS
  32. $!
  33. $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
  34. $! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
  35. $!
  36. $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
  37. $!       1. COMMON.C;13
  38. $!       2. DECODE11.C;4
  39. $!       3. DNET_SOCKET_LIBRARY.C;81
  40. $!       4. DNXSCOPE.OPT;2
  41. $!       5. EMULATIONLIB.H;15
  42. $!       6. FD.C;17
  43. $!       7. FD.H;2
  44. $!       8. FIX.INFO;1
  45. $!       9. IMAKEFILE.;1
  46. $!      10. IPXSCOPE.OPT;1
  47. $!      11. MAKE.COM;20
  48. $!      12. MAKEFILE.;1
  49. $!      13. MAKEFILE.PROTO;1
  50. $!      14. PORTOBJ.H;1
  51. $!      15. PRINT11.C;2
  52. $!      16. PRTYPE.C;10
  53. $!      17. README.;1
  54. $!      18. README.VMS;2
  55. $!      19. SCOPE.C;19
  56. $!      20. SCOPE.H;8
  57. $!      21. SERVER.C;10
  58. $!      22. TABLE11.C;3
  59. $!      23. TARFILES.;1
  60. $!      24. X11.H;6
  61. $!      25. XSCOPE.1;1
  62. $!      26. XSCOPE.TXT;1
  63. $!
  64. $set="set"
  65. $set symbol/scope=(nolocal,noglobal)
  66. $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
  67. $e="write sys$error  ""%UNPACK"", "
  68. $w="write sys$output ""%UNPACK"", "
  69. $ if f$trnlnm("SHARE_LOG") then $ w = "!"
  70. $ ve=f$getsyi("version")
  71. $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
  72. $ e "-E-OLDVER, Must run at least VMS 4.4"
  73. $ v=f$verify(v)
  74. $ exit 44
  75. $UNPACK: SUBROUTINE ! P1=filename, P2=checksum
  76. $ if f$search(P1) .eqs. "" then $ goto file_absent
  77. $ e "-W-EXISTS, File ''P1' exists. Skipped."
  78. $ delete 'f'*
  79. $ exit
  80. $file_absent:
  81. $ if f$parse(P1) .nes. "" then $ goto dirok
  82. $ dn=f$parse(P1,,,"DIRECTORY")
  83. $ w "-I-CREDIR, Creating directory ''dn'."
  84. $ create/dir 'dn'
  85. $ if $status then $ goto dirok
  86. $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
  87. $ delete 'f'*
  88. $ exit
  89. $dirok:
  90. $ w "-I-PROCESS, Processing file ''P1'."
  91. $ if .not. f$verify() then $ define/user sys$output nl:
  92. $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
  93. PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
  94. SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
  95. CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
  96. LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
  97. BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
  98. IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
  99. MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
  100. ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
  101. 1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
  102. POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
  103. ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
  104. COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
  105. "output_file"));ENDPROCEDURE;Unpacker;QUIT;
  106. $ delete/nolog 'f'*
  107. $ CHECKSUM 'P1'
  108. $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
  109. $ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
  110. $ ENDSUBROUTINE
  111. $START:
  112. $ create 'f'
  113. X/* ************************************************************ *\
  114. X *`09`09`09`09`09`09`09`09*
  115. X *    Common support routines for sockets`09`09`09*
  116. X *`09`09`09`09`09`09`09`09*
  117. X *       James L. Peterson`09 `09`09`09`09*
  118. X *`09(c) Copyright MCC, 1987                                 *
  119. X * `09`09`09`09  `09`09`09`09*
  120. X * `09`09`09`09  `09`09`09`09*
  121. X \* *********************************************************** */
  122. X#if defined(vax11c) && !defined(MULTINET)
  123. X#include "emulationlib.h"
  124. X#endif
  125. X
  126. X#include "scope.h"
  127. X
  128. X/* ********************************************** */
  129. X/*`09`09`09`09`09`09  */
  130. X/*       Debugging support routines               */
  131. X/*`09`09`09`09`09`09  */
  132. X/* ********************************************** */
  133. X
  134. Xenterprocedure(s)
  135. X     char   *s;
  136. X`7B
  137. X  debug(2,(stderr, "-> %s\n", s));
  138. X`7D
  139. X
  140. Xwarn(s)
  141. X     char   *s;
  142. X`7B
  143. X  fprintf(stderr, "####### %s\n", s);
  144. X`7D
  145. X
  146. Xpanic(s)
  147. X     char   *s;
  148. X`7B
  149. X  fprintf(stderr, "%s\n", s);
  150. X  exit(1);
  151. X`7D
  152. X
  153. X/* ********************************************** */
  154. X/*`09`09`09`09`09`09  */
  155. X/*  Debugging forms of memory management          */
  156. X/*`09`09`09`09`09`09  */
  157. X/* ********************************************** */
  158. X
  159. Xextern char *malloc();
  160. X
  161. X#ifdef vax11c
  162. Xchar   *MyMalloc (n)
  163. X#else
  164. Xchar   *Malloc (n)
  165. X#endif /* vax11c */
  166. X     long    n;
  167. X`7B
  168. X  char   *p;
  169. X  p = (char *)malloc((unsigned int)n);
  170. X  debug(64,(stderr, "%x = malloc(%d)\n", p, n));
  171. X  if (p == NULL)
  172. X    panic("no more malloc space");
  173. X  return(p);
  174. X`7D
  175. X
  176. X#ifdef vax11c
  177. XMyFree(p)
  178. X#else
  179. XFree(p)
  180. X#endif /* vax11c */
  181. X     char   *p;
  182. X`7B
  183. X  debug(64,(stderr, "%x = free\n", p));
  184. X  free(p);
  185. X`7D
  186. X
  187. X
  188. X
  189. X/* ************************************************************ */
  190. X/*`09`09`09`09`09`09`09`09*/
  191. X/*    Signal Handling support`09`09`09`09`09*/
  192. X/*`09`09`09`09`09`09`09`09*/
  193. X/* ************************************************************ */
  194. X
  195. X#include <signal.h>
  196. X
  197. X#ifndef vax11c
  198. XSignalURG()
  199. X`7B
  200. X  debug(1,(stderr, "==> SIGURG received\n"));
  201. X`7D
  202. X#endif /* vax11c */
  203. X
  204. XSignalPIPE()
  205. X`7B
  206. X  debug(1,(stderr, "==> SIGPIPE received\n"));
  207. X`7D
  208. X
  209. XSignalINT()
  210. X`7B
  211. X  debug(1,(stderr, "==> SIGINT received\n"));
  212. X  exit(1);
  213. X`7D
  214. X
  215. XSignalQUIT()
  216. X`7B
  217. X  debug(1,(stderr, "==> SIGQUIT received\n"));
  218. X  exit(1);
  219. X`7D
  220. X
  221. XSignalTERM()
  222. X`7B
  223. X  debug(1,(stderr, "==> SIGTERM received\n"));
  224. X  exit(1);
  225. X`7D
  226. X
  227. X#ifndef vax11c
  228. XSignalTSTP()
  229. X`7B
  230. X  debug(1,(stderr, "==> SIGTSTP received\n"));
  231. X`7D
  232. X
  233. XSignalCONT()
  234. X`7B
  235. X  debug(1,(stderr, "==> SIGCONT received\n"));
  236. X`7D
  237. X#endif /* vax11c */
  238. X
  239. XSetSignalHandling()
  240. X`7B
  241. X  enterprocedure("SetSignalHandling");
  242. X#ifndef vax11c
  243. X  signal(SIGURG, SignalURG);
  244. X#endif /* vax11c */
  245. X  signal(SIGPIPE, SignalPIPE);
  246. X  signal(SIGINT, SignalINT);
  247. X  signal(SIGQUIT, SignalQUIT);
  248. X  signal(SIGTERM, SignalTERM);
  249. X#ifndef vax11c
  250. X  signal(SIGTSTP, SignalTSTP);
  251. X  signal(SIGCONT, SignalCONT);
  252. X#endif /* vax11c */
  253. X`7D
  254. X
  255. X
  256. X
  257. X/* ************************************************************ */
  258. X/*`09`09`09`09`09`09`09`09*/
  259. X/*   Create a socket for a service to listen for clients        */
  260. X/*`09`09`09`09`09`09`09`09*/
  261. X/* ************************************************************ */
  262. X
  263. X#ifdef vax11c
  264. X#ifdef MULTINET
  265. X#include <sys$common/multinet/include/sys/types.h>`09/* needed by sys/socket
  266. V.h and netinet/in.h */
  267. X#include <sys$common/multinet/include/sys/uio.h>`09/* for struct iovec, used
  268. V by socket.h */
  269. X#include <sys$common/multinet/include/sys/socket.h>`09/* for AF_INET, SOCK_S
  270. VTREAM, ... */
  271. X#include <sys$common/multinet/include/sys/ioctl.h>`09/* for FIONCLEX, FIONBI
  272. VO, ... */
  273. X#include <sys$common/multinet/include/netinet/in.h>`09/* struct sockaddr_in
  274. V */
  275. X#include <sys$common/multinet/include/netdb.h>`09`09/* struct servent * and
  276. V struct hostent *  */
  277. X#endif /* MULTINET */
  278. X#else
  279. X#include <sys/types.h>`09       /* needed by sys/socket.h and netinet/in.h *
  280. V/
  281. X#include <sys/uio.h>`09       /* for struct iovec, used by socket.h */
  282. X#include <sys/socket.h>`09       /* for AF_INET, SOCK_STREAM, ... */
  283. X#include <sys/ioctl.h>`09       /* for FIONCLEX, FIONBIO, ... */
  284. X#include <netinet/in.h>`09       /* struct sockaddr_in */
  285. X#include <netdb.h>`09       /* struct servent * and struct hostent *  */
  286. X#endif /* vax11c */
  287. X
  288. Xstatic int  ON = 1 /* used in ioctl */ ;
  289. X#define`09BACKLOG`095
  290. X
  291. X/* for use in the UsingFD call -- defined later */
  292. Xextern int  NewConnection ();
  293. X
  294. X
  295. XSetUpConnectionSocket(iport)
  296. X     int     iport;
  297. X`7B
  298. X  FD ConnectionSocket;
  299. X  struct sockaddr_in  sin;
  300. X  short`09port;
  301. X#ifdef vax11c
  302. X  unsigned long int On;
  303. X#endif /* vax11c */
  304. X
  305. X  enterprocedure("SetUpConnectionSocket");
  306. X
  307. X  /* create the connection socket and set its parameters of use */
  308. X  ConnectionSocket = socket(AF_INET, SOCK_STREAM, 0);
  309. X  if (ConnectionSocket < 0)
  310. X    `7B
  311. X      perror("socket");
  312. X      exit(-1);
  313. X    `7D
  314. X#ifdef vax11c
  315. X  On = 0;
  316. X  if (setsockopt(ConnectionSocket, SOL_SOCKET, SO_REUSEADDR, &On, sizeof(On)
  317. V) < 0) `7B
  318. X      socket_perror("SOCKOPT: REUSADDR");
  319. X      exit(-1);
  320. X  `7D
  321. X  On = 0;
  322. X  if (setsockopt(ConnectionSocket, SOL_SOCKET, SO_USELOOPBACK, &On, sizeof(O
  323. Vn)) < 0) `7B
  324. X      socket_perror("SOCKOPT: USELOOPBACK");
  325. X      exit(-1);
  326. X  `7D
  327. X#ifdef SO_DONTLINGER
  328. X  if (setsockopt(ConnectionSocket, SOL_SOCKET, SO_DONTLINGER,  (char *)NULL,
  329. V 0) < 0) `7B
  330. X      socket_perror("SOCKOPT: DONTLINGER");
  331. X      exit(-1);
  332. X  `7D
  333. X#endif
  334. X#else
  335. X  (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_REUSEADDR,   (char *)NUL
  336. VL, 0);
  337. X  (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_USELOOPBACK, (char *)NUL
  338. VL, 0);
  339. X#ifdef SO_DONTLINGER
  340. X  (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_DONTLINGER,  (char *)NUL
  341. VL, 0);
  342. X#endif
  343. X#endif /* vax11c */
  344. X
  345. X  /* define the name and port to be used with the connection socket */
  346. X  bzero((char *)&sin, sizeof(sin));
  347. X  sin.sin_family = AF_INET;
  348. X
  349. X  /* the address of the socket is composed of two parts: the host machine an
  350. Vd
  351. X     the port number.  We need the host machine address for the current host
  352. X   */
  353. X  `7B
  354. X    /* define the host part of the address */
  355. X    char    MyHostName`5B256`5D;
  356. X    struct hostent *hp;
  357. X
  358. X#ifdef vax11c
  359. X    if (gethostname(MyHostName, sizeof(MyHostName)) < 0) `7B
  360. X`09fprintf(stderr, "Unable to retrieve hostname\n");
  361. X`09exit (-1);
  362. X    `7D
  363. X    ScopeHost = (char *) MyMalloc((long)strlen(MyHostName));
  364. X#else
  365. X    (void) gethostname(MyHostName, sizeof(MyHostName));
  366. X    ScopeHost = (char *) Malloc((long)strlen(MyHostName));
  367. X#endif /* vax11c */
  368. X    strcpy(ScopeHost, MyHostName);
  369. X    hp = gethostbyname(MyHostName);
  370. X    if (hp == NULL)
  371. X      panic("No address for our host");
  372. X    bcopy((char *)hp->h_addr, (char*)&sin.sin_addr, hp->h_length);
  373. X  `7D
  374. X    /* new code -- INADDR_ANY should be better than using the name of the
  375. X       host machine.  The host machine may have several different network
  376. X       addresses.  INADDR_ANY should work with all of them at once. */
  377. X  sin.sin_addr.s_addr = INADDR_ANY;
  378. X
  379. X  port = iport;
  380. X  sin.sin_port = htons (port);
  381. X  ScopePort = port;
  382. X
  383. X  /* bind the name and port number to the connection socket */
  384. X  if (bind(ConnectionSocket, (struct sockaddr *)&sin, sizeof(sin)) < 0)
  385. X    `7B
  386. X      perror("bind");
  387. X      exit(-1);
  388. X    `7D
  389. X
  390. X  debug(4,(stderr, "Socket is FD %d for %s,%d\n",
  391. X`09   ConnectionSocket, ScopeHost, ScopePort));
  392. X
  393. X  /* now activate the named connection socket to get messages */
  394. X  if (listen(ConnectionSocket, BACKLOG) < 0)
  395. X    `7B
  396. X      perror("listen");
  397. X      exit(-1);
  398. X    `7D;
  399. X
  400. X  /* a few more parameter settings */
  401. X#ifdef vax11c
  402. X  /* socket_ioctl(ConnectionSocket, FIOCLEX, 0); */
  403. X  socket_ioctl(ConnectionSocket, FIONBIO, &ON);
  404. X#else
  405. X  ioctl(ConnectionSocket, FIOCLEX, 0);
  406. X  ioctl(ConnectionSocket, FIONBIO, &ON);
  407. X#endif /* vax11c */
  408. X
  409. X  debug(4,(stderr, "Listening on FD %d\n", ConnectionSocket));
  410. X  UsingFD(ConnectionSocket, NewConnection);
  411. X`7D
  412. X
  413. X
  414. $ CALL UNPACK COMMON.C;13 2031753986
  415. $ create 'f'
  416. X/* ************************************************************ *
  417. X *`09`09`09`09`09`09     `09`09*
  418. X *  Decoding and switching routines for the X11 protocol`09*
  419. X *`09`09`09`09`09`09      `09`09*
  420. X *`09James Peterson, 1988`09`09`09      `09`09*
  421. X *`09(c) Copyright MCC, 1988 `09`09      `09`09*
  422. X *`09`09`09`09`09`09      `09`09*
  423. X * ************************************************************ */
  424. X#if defined(vax11c) && !defined(MULTINET)
  425. X#include "emulationlib.h"
  426. X#endif
  427. X
  428. X#include "scope.h"
  429. X#include "x11.h"
  430. X
  431. X/*
  432. X  There are 4 types of things in X11: requests, replies, errors, and events.
  433. X
  434. X  Each of them has a format defined by a small integer that defines
  435. X  the type of the thing.
  436. X
  437. X  Requests have an opcode in the first byte.
  438. X  Events have a code in the first byte.
  439. X  Errors have a code in the second byte (the first byte is 0)
  440. X  Replies ...
  441. X
  442. X  Replies have a sequence number in bytes 2 and 3.  The sequence
  443. X  number should be used to identify the request that was sent, and
  444. X  from that request we can determine the type of the reply.
  445. X*/
  446. X
  447. X
  448. X/* ************************************************************ */
  449. X/*`09`09`09`09`09`09`09`09*/
  450. X/*`09`09`09`09`09`09`09`09*/
  451. X/* ************************************************************ */
  452. X
  453. X
  454. X/*
  455. X  We need to keep the sequence number for a request to match it with
  456. X  an expected reply.  The sequence number is associated only with the
  457. X  particular connection that we have. We would expect these replies
  458. X  to be handled as a FIFO queue.
  459. X*/
  460. X
  461. Xstruct QueueEntry
  462. X`7B
  463. X  struct QueueEntry  *Next;
  464. X  long    SequenceNumber;
  465. X  short   Request;
  466. X`7D;
  467. X
  468. X/* free space list of Q entries */
  469. X
  470. Xstatic struct QueueEntry   *FreeQEntries = NULL;
  471. X
  472. X/* ************************************************************ */
  473. Xstruct QueueEntry  *NewQEntry (SequenceNumber, Request)
  474. X     long    SequenceNumber;
  475. X     short   Request;
  476. X`7B
  477. X  struct QueueEntry  *p;
  478. X
  479. X  /* Get a Queue Entry */
  480. X  if (FreeQEntries == NULL)
  481. X    `7B
  482. X      /* create new queue entry */
  483. X#ifdef vax11c
  484. X      p = (struct QueueEntry *) MyMalloc ((long)(sizeof (*p)));
  485. X#else
  486. X      p = (struct QueueEntry *) Malloc ((long)(sizeof (*p)));
  487. X#endif /* vax11c */
  488. X    `7D
  489. X  else
  490. X    `7B
  491. X      /* reuse an old queue entry */
  492. X      p = FreeQEntries;
  493. X      FreeQEntries = FreeQEntries->Next;
  494. X    `7D
  495. X
  496. X  /* fill in its values */
  497. X  p->Next = NULL;
  498. X  p->SequenceNumber = SequenceNumber;
  499. X  p->Request = Request;
  500. X  return(p);
  501. X`7D
  502. X/* ************************************************************ */
  503. X
  504. X/* define a queue of entries for each FD */
  505. X
  506. Xstruct QueueHeader
  507. X`7B
  508. X  struct QueueEntry  *Head;
  509. X  struct QueueEntry  *Tail;
  510. X`7D;
  511. X
  512. X#ifdef vax11c`09/* Another Hack, must remember to come back and fix this */
  513. Xstruct QueueHeader *ReplyQ;
  514. X#else
  515. Xstruct QueueHeader  ReplyQ`5BStaticMaxFD`5D;
  516. X#endif /* vax11c */
  517. X
  518. X/* ************************************************************ */
  519. X
  520. XInitReplyQ()
  521. X`7B
  522. X  short   i;
  523. X#ifdef vax11c
  524. X  /*
  525. X   *`09HACK ALERT!  Again we are wasting TOO MUCH memory.  But
  526. X   *`09in the interests of getting this done, we are going to
  527. X   *`09to waste it now.  REMEMBER to come back and fix this.
  528. X   */
  529. X  ReplyQ = (struct QueueHeader *)
  530. X           MyMalloc((long)(MaxFD * sizeof (struct QueueHeader)));
  531. X  for (i = 0; i < MaxFD; i++) `7B
  532. X      ReplyQ`5Bi`5D.Head = NULL;
  533. X      ReplyQ`5Bi`5D.Tail = NULL;
  534. X  `7D
  535. X#else
  536. X  for (i = 0; i < StaticMaxFD; i++)
  537. X    `7B
  538. X      ReplyQ`5Bi`5D.Head = NULL;
  539. X      ReplyQ`5Bi`5D.Tail = NULL;
  540. X    `7D
  541. X#endif /* vax11c */
  542. X`7D
  543. X
  544. XFlushReplyQ(fd)
  545. XFD fd;
  546. X`7B
  547. X  struct QueueEntry  *p;
  548. X  struct QueueEntry  *NextQEntry;
  549. X
  550. X  /* go down the reply queue and free all entries */
  551. X  for (p = ReplyQ`5Bfd`5D.Head; p != NULL; p = NextQEntry)
  552. X    `7B
  553. X      NextQEntry = p->Next;
  554. X     `20
  555. X      /* put freed entry on list of free entries (for later reuse)  */
  556. X      p->Next = FreeQEntries;
  557. X      FreeQEntries = p;
  558. X    `7D
  559. X `20
  560. X  ReplyQ`5Bfd`5D.Head = NULL;
  561. X  ReplyQ`5Bfd`5D.Tail = NULL;
  562. X`7D
  563. X
  564. X
  565. XDumpReplyQ(fd)
  566. X     FD fd;
  567. X`7B
  568. X  fprintf(stderr, "ReplyQ`5B%d`5D = `7B Head 0x%x; Tail 0x%x `7D\n",`20
  569. X`09  fd, ReplyQ`5Bfd`5D.Head, ReplyQ`5Bfd`5D.Tail);
  570. X  `7B
  571. X    struct QueueEntry  *p;
  572. X    for (p = ReplyQ`5Bfd`5D.Head; p != NULL; p = p->Next)
  573. X      fprintf(stderr, "0x%x = `7B Next 0x%x; SequenceNumber %d; Request %d `
  574. V7D\n",
  575. X`09      p, p->Next, p->SequenceNumber, p->Request);
  576. X  `7D
  577. X`7D
  578. X/* ************************************************************ */
  579. X/*`09`09`09`09`09`09`09`09*/
  580. X/*`09`09`09`09`09`09`09`09*/
  581. X/* ************************************************************ */
  582. X
  583. X/* A reply is expected to the type of request given for the fd associated
  584. X   with this one */
  585. X
  586. XSequencedReplyExpected(fd, SequenceNumber, RequestType)
  587. X     FD fd;
  588. X     long SequenceNumber;
  589. X     short   RequestType;
  590. X`7B
  591. X  struct QueueEntry  *p;
  592. X
  593. X  debug(8,(stderr, "Reply expected: sequence %d and request type %d for fd %
  594. Vd\n",
  595. X`09   SequenceNumber, RequestType, fd));
  596. X  /* create a new queue entry */
  597. X  p = NewQEntry(SequenceNumber, RequestType);
  598. X
  599. X  /* find the server associated with this client */
  600. X  fd = FDPair(fd);
  601. X#ifdef vax11c
  602. X  if (fd < 0 `7C`7C fd >= MaxFD) return;
  603. X#else
  604. X  if (fd < 0 `7C`7C fd >= StaticMaxFD) return;
  605. X#endif /* vax11c */
  606. X
  607. X  /* attach the new queue entry to the end of the queue for the Server */
  608. X  if (ReplyQ`5Bfd`5D.Tail != NULL)
  609. X    (ReplyQ`5Bfd`5D.Tail)->Next = p;
  610. X  else
  611. X    ReplyQ`5Bfd`5D.Head = p;
  612. X  ReplyQ`5Bfd`5D.Tail = p;
  613. X
  614. X  debug(8,(stderr, "Save sequence %d and request type %d for fd %d\n",
  615. X`09   p->SequenceNumber, p->Request, fd));
  616. X`7D
  617. X
  618. X
  619. Xstatic FD Lastfd;
  620. Xstatic long LastSequenceNumber;
  621. Xstatic short LastReplyType;
  622. X
  623. X/* search for the type of request that is associated with a reply
  624. X   to the given sequence number for this fd */
  625. X
  626. Xshort   CheckReplyTable (fd, SequenceNumber)
  627. X     FD fd;
  628. X     short   SequenceNumber;
  629. X`7B
  630. X  struct QueueEntry  *p;
  631. X  struct QueueEntry  *trailer;
  632. X
  633. X  if (debuglevel & 128) DumpReplyQ(fd);
  634. X  for (trailer = NULL, p = ReplyQ`5Bfd`5D.Head;
  635. X       p != NULL;
  636. X       trailer = p, p = p->Next)
  637. X    `7B
  638. X      /* look for matching sequence number in queue of this fd */
  639. X      if (SequenceNumber == ((short)(0xFFFF & p->SequenceNumber)))
  640. X`09`7B
  641. X`09  /* save the Request type */
  642. X`09  Lastfd = fd;
  643. X`09  LastSequenceNumber = p->SequenceNumber;
  644. X`09  LastReplyType = p->Request;
  645. X
  646. X`09  /* pull the queue entry out of the queue for this fd */
  647. X`09  if (trailer == NULL)
  648. X`09      ReplyQ`5Bfd`5D.Head = p->Next;
  649. X`09  else
  650. X`09    trailer->Next = p->Next;
  651. X`09  if (ReplyQ`5Bfd`5D.Tail == p) ReplyQ`5Bfd`5D.Tail = trailer;
  652. X
  653. X
  654. X`09  /* put freed entry on list of free entries (for later reuse)  */
  655. X`09  p->Next = FreeQEntries;
  656. X`09  FreeQEntries = p;
  657. X
  658. X`09  debug(8,(stderr, "Reply on fd %d for sequence %d is type %d\n",
  659. X`09`09   fd, SequenceNumber, LastReplyType));
  660. X`09  return(LastReplyType);
  661. X`09`7D
  662. X    `7D
  663. X
  664. X  /* not expecting a reply for that sequence number */
  665. X  debug(8,(stderr, "Reply on fd %d for sequence %d is not found\n",
  666. X`09   fd, SequenceNumber));
  667. X  return(0);
  668. X`7D
  669. X
  670. X
  671. X/* ************************************************************ */
  672. X/* A reply is expected to the type of request given for the
  673. X   sequence number associated with this fd */
  674. X
  675. XReplyExpected(fd, Request)
  676. X     FD fd;
  677. X     short   Request;
  678. X`7B
  679. X  SequencedReplyExpected(fd, CS`5Bfd`5D.SequenceNumber, Request);
  680. X`7D
  681. X
  682. X/* ************************************************************ */
  683. X/* another reply is expected for the same reply as we just had */
  684. X/* This is only used with ListFontsWithInfo */
  685. X
  686. XKeepLastReplyExpected()
  687. X`7B
  688. X  SequencedReplyExpected(Lastfd, LastSequenceNumber, LastReplyType);
  689. X`7D
  690. X
  691. X/* ************************************************************ */
  692. X/*`09`09`09`09`09`09`09`09*/
  693. X/*`09`09`09`09`09`09`09`09*/
  694. X/* ************************************************************ */
  695. X
  696. X
  697. XDecodeRequest(fd, buf, n)
  698. X     FD fd;
  699. X     unsigned char *buf;
  700. X     long    n;
  701. X`7B
  702. X  short   Request = IByte (&buf`5B0`5D);
  703. X  CS`5Bfd`5D.SequenceNumber += 1;
  704. X  bcopy ((char *)&(CS`5Bfd`5D.SequenceNumber), (char *)SBf, sizeof(long));
  705. X  SetIndentLevel(PRINTCLIENT);
  706. X
  707. X  if (Verbose > 3)
  708. X    DumpItem("Request", fd, buf, n);
  709. X  if (Request <= 0 `7C`7C 127 < Request)
  710. X    warn("Extended request opcode");
  711. X  else switch (Request)
  712. X    `7B
  713. X`09    case 1:
  714. X`09`09    CreateWindow(buf);
  715. X`09`09    break;
  716. X`09    case 2:
  717. X`09`09    ChangeWindowAttributes(buf);
  718. X`09`09    break;
  719. X`09    case 3:
  720. X`09`09    GetWindowAttributes(buf);
  721. X`09`09    ReplyExpected(fd, Request);
  722. X`09`09    break;
  723. X`09    case 4:
  724. X`09`09    DestroyWindow(buf);
  725. X`09`09    break;
  726. X`09    case 5:
  727. X`09`09    DestroySubwindows(buf);
  728. X`09`09    break;
  729. X`09    case 6:
  730. X`09`09    ChangeSaveSet(buf);
  731. X`09`09    break;
  732. X`09    case 7:
  733. X`09`09    ReparentWindow(buf);
  734. X`09`09    break;
  735. X`09    case 8:
  736. X`09`09    MapWindow(buf);
  737. X`09`09    break;
  738. X`09    case 9:
  739. X`09`09    MapSubwindows(buf);
  740. X`09`09    break;
  741. X`09    case 10:
  742. X`09`09    UnmapWindow(buf);
  743. X`09`09    break;
  744. X`09    case 11:
  745. X`09`09    UnmapSubwindows(buf);
  746. X`09`09    break;
  747. X`09    case 12:
  748. X`09`09    ConfigureWindow(buf);
  749. X`09`09    break;
  750. X`09    case 13:
  751. X`09`09    CirculateWindow(buf);
  752. X`09`09    break;
  753. X`09    case 14:
  754. X`09`09    GetGeometry(buf);
  755. X`09`09    ReplyExpected(fd, Request);
  756. X`09`09    break;
  757. X`09    case 15:
  758. X`09`09    QueryTree(buf);
  759. X`09`09    ReplyExpected(fd, Request);
  760. X`09`09    break;
  761. X`09    case 16:
  762. X`09`09    InternAtom(buf);
  763. X`09`09    ReplyExpected(fd, Request);
  764. X`09`09    break;
  765. X`09    case 17:
  766. X`09`09    GetAtomName(buf);
  767. X`09`09    ReplyExpected(fd, Request);
  768. X`09`09    break;
  769. X`09    case 18:
  770. X`09`09    ChangeProperty(buf);
  771. X`09`09    break;
  772. X`09    case 19:
  773. X`09`09    DeleteProperty(buf);
  774. X`09`09    break;
  775. X`09    case 20:
  776. X`09`09    GetProperty(buf);
  777. X`09`09    ReplyExpected(fd, Request);
  778. X`09`09    break;
  779. X`09    case 21:
  780. X`09`09    ListProperties(buf);
  781. X`09`09    ReplyExpected(fd, Request);
  782. X`09`09    break;
  783. X`09    case 22:
  784. X`09`09    SetSelectionOwner(buf);
  785. X`09`09    break;
  786. X`09    case 23:
  787. X`09`09    GetSelectionOwner(buf);
  788. X`09`09    ReplyExpected(fd, Request);
  789. X`09`09    break;
  790. X`09    case 24:
  791. X`09`09    ConvertSelection(buf);
  792. X`09`09    break;
  793. X`09    case 25:
  794. X`09`09    SendEvent(buf);
  795. X`09`09    break;
  796. X`09    case 26:
  797. X`09`09    GrabPointer(buf);
  798. X`09`09    ReplyExpected(fd, Request);
  799. X`09`09    break;
  800. X`09    case 27:
  801. X`09`09    UngrabPointer(buf);
  802. X`09`09    break;
  803. X`09    case 28:
  804. X`09`09    GrabButton(buf);
  805. X`09`09    break;
  806. X`09    case 29:
  807. X`09`09    UngrabButton(buf);
  808. X`09`09    break;
  809. X`09    case 30:
  810. X`09`09    ChangeActivePointerGrab(buf);
  811. X`09`09    break;
  812. X`09    case 31:
  813. X`09`09    GrabKeyboard(buf);
  814. X`09`09    ReplyExpected(fd, Request);
  815. X`09`09    break;
  816. X`09    case 32:
  817. X`09`09    UngrabKeyboard(buf);
  818. X`09`09    break;
  819. X`09    case 33:
  820. X`09`09    GrabKey(buf);
  821. X`09`09    break;
  822. X`09    case 34:
  823. X`09`09    UngrabKey(buf);
  824. X`09`09    break;
  825. X`09    case 35:
  826. X`09`09    AllowEvents(buf);
  827. X`09`09    break;
  828. X`09    case 36:
  829. X`09`09    GrabServer(buf);
  830. X`09`09    break;
  831. X`09    case 37:
  832. X`09`09    UngrabServer(buf);
  833. X`09`09    break;
  834. X`09    case 38:
  835. X`09`09    QueryPointer(buf);
  836. X`09`09    ReplyExpected(fd, Request);
  837. X`09`09    break;
  838. X`09    case 39:
  839. X`09`09    GetMotionEvents(buf);
  840. X`09`09    ReplyExpected(fd, Request);
  841. X`09`09    break;
  842. X`09    case 40:
  843. X`09`09    TranslateCoordinates(buf);
  844. X`09`09    ReplyExpected(fd, Request);
  845. X`09`09    break;
  846. X`09    case 41:
  847. X`09`09    WarpPointer(buf);
  848. X`09`09    break;
  849. X`09    case 42:
  850. X`09`09    SetInputFocus(buf);
  851. X`09`09    break;
  852. X`09    case 43:
  853. X`09`09    GetInputFocus(buf);
  854. X`09`09    ReplyExpected(fd, Request);
  855. X`09`09    break;
  856. X`09    case 44:
  857. X`09`09    QueryKeymap(buf);
  858. X`09`09    ReplyExpected(fd, Request);
  859. X`09`09    break;
  860. X`09    case 45:
  861. X`09`09    OpenFont(buf);
  862. X`09`09    break;
  863. X`09    case 46:
  864. X`09`09    CloseFont(buf);
  865. X`09`09    break;
  866. X`09    case 47:
  867. X`09`09    QueryFont(buf);
  868. X`09`09    ReplyExpected(fd, Request);
  869. X`09`09    break;
  870. X`09    case 48:
  871. X`09`09    QueryTextExtents(buf);
  872. X`09`09    ReplyExpected(fd, Request);
  873. X`09`09    break;
  874. X`09    case 49:
  875. X`09`09    ListFonts(buf);
  876. X`09`09    ReplyExpected(fd, Request);
  877. X`09`09    break;
  878. X`09    case 50:
  879. X`09`09    ListFontsWithInfo(buf);
  880. X`09`09    ReplyExpected(fd, Request);
  881. X`09`09    break;
  882. X`09    case 51:
  883. X`09`09    SetFontPath(buf);
  884. X`09`09    break;
  885. X`09    case 52:
  886. X`09`09    GetFontPath(buf);
  887. X`09`09    ReplyExpected(fd, Request);
  888. X`09`09    break;
  889. X`09    case 53:
  890. X`09`09    CreatePixmap(buf);
  891. X`09`09    break;
  892. X`09    case 54:
  893. X`09`09    FreePixmap(buf);
  894. X`09`09    break;
  895. X`09    case 55:
  896. X`09`09    CreateGC(buf);
  897. X`09`09    break;
  898. X`09    case 56:
  899. X`09`09    ChangeGC(buf);
  900. X`09`09    break;
  901. X`09    case 57:
  902. X`09`09    CopyGC(buf);
  903. X`09`09    break;
  904. X`09    case 58:
  905. X`09`09    SetDashes(buf);
  906. X`09`09    break;
  907. X`09    case 59:
  908. X`09`09    SetClipRectangles(buf);
  909. X`09`09    break;
  910. X`09    case 60:
  911. X`09`09    FreeGC(buf);
  912. X`09`09    break;
  913. X`09    case 61:
  914. X`09`09    ClearArea(buf);
  915. X`09`09    break;
  916. X`09    case 62:
  917. X`09`09    CopyArea(buf);
  918. X`09`09    break;
  919. X`09    case 63:
  920. X`09`09    CopyPlane(buf);
  921. X`09`09    break;
  922. X`09    case 64:
  923. X`09`09    PolyPoint(buf);
  924. X`09`09    break;
  925. X`09    case 65:
  926. X`09`09    PolyLine(buf);
  927. X`09`09    break;
  928. X`09    case 66:
  929. X`09`09    PolySegment(buf);
  930. X`09`09    break;
  931. X`09    case 67:
  932. X`09`09    PolyRectangle(buf);
  933. X`09`09    break;
  934. X`09    case 68:
  935. X`09`09    PolyArc(buf);
  936. X`09`09    break;
  937. X`09    case 69:
  938. X`09`09    FillPoly(buf);
  939. X`09`09    break;
  940. X`09    case 70:
  941. X`09`09    PolyFillRectangle(buf);
  942. X`09`09    break;
  943. X`09    case 71:
  944. X`09`09    PolyFillArc(buf);
  945. X`09`09    break;
  946. X`09    case 72:
  947. X`09`09    PutImage(buf);
  948. X`09`09    break;
  949. X`09    case 73:
  950. X`09`09    GetImage(buf);
  951. X`09`09    ReplyExpected(fd, Request);
  952. X`09`09    break;
  953. X`09    case 74:
  954. X`09`09    PolyText8(buf);
  955. X`09`09    break;
  956. X`09    case 75:
  957. X`09`09    PolyText16(buf);
  958. X`09`09    break;
  959. X`09    case 76:
  960. X`09`09    ImageText8(buf);
  961. X`09`09    break;
  962. X`09    case 77:
  963. X`09`09    ImageText16(buf);
  964. X`09`09    break;
  965. X`09    case 78:
  966. X`09`09    CreateColormap(buf);
  967. X`09`09    break;
  968. X`09    case 79:
  969. X`09`09    FreeColormap(buf);
  970. X`09`09    break;
  971. X`09    case 80:
  972. X`09`09    CopyColormapAndFree(buf);
  973. X`09`09    break;
  974. X`09    case 81:
  975. X`09`09    InstallColormap(buf);
  976. X`09`09    break;
  977. X`09    case 82:
  978. X`09`09    UninstallColormap(buf);
  979. X`09`09    break;
  980. X`09    case 83:
  981. X`09`09    ListInstalledColormaps(buf);
  982. X`09`09    ReplyExpected(fd, Request);
  983. X`09`09    break;
  984. X`09    case 84:
  985. X`09`09    AllocColor(buf);
  986. X`09`09    ReplyExpected(fd, Request);
  987. X`09`09    break;
  988. X`09    case 85:
  989. X`09`09    AllocNamedColor(buf);
  990. X`09`09    ReplyExpected(fd, Request);
  991. X`09`09    break;
  992. X`09    case 86:
  993. X`09`09    AllocColorCells(buf);
  994. X`09`09    ReplyExpected(fd, Request);
  995. X`09`09    break;
  996. X`09    case 87:
  997. X`09`09    AllocColorPlanes(buf);
  998. X`09`09    ReplyExpected(fd, Request);
  999. X`09`09    break;
  1000. X`09    case 88:
  1001. X`09`09    FreeColors(buf);
  1002. X`09`09    break;
  1003. X`09    case 89:
  1004. X`09`09    StoreColors(buf);
  1005. X`09`09    break;
  1006. X`09    case 90:
  1007. X`09`09    StoreNamedColor(buf);
  1008. X`09`09    break;
  1009. X`09    case 91:
  1010. X`09`09    QueryColors(buf);
  1011. X`09`09    ReplyExpected(fd, Request);
  1012. X`09`09    break;
  1013. X`09    case 92:
  1014. X`09`09    LookupColor(buf);
  1015. X`09`09    ReplyExpected(fd, Request);
  1016. X`09`09    break;
  1017. X`09    case 93:
  1018. X`09`09    CreateCursor(buf);
  1019. X`09`09    break;
  1020. X`09    case 94:
  1021. X`09`09    CreateGlyphCursor(buf);
  1022. X`09`09    break;
  1023. X`09    case 95:
  1024. X`09`09    FreeCursor(buf);
  1025. X`09`09    break;
  1026. X`09    case 96:
  1027. X`09`09    RecolorCursor(buf);
  1028. X`09`09    break;
  1029. X`09    case 97:
  1030. X`09`09    QueryBestSize(buf);
  1031. X`09`09    ReplyExpected(fd, Request);
  1032. X`09`09    break;
  1033. X`09    case 98:
  1034. X`09`09    QueryExtension(buf);
  1035. X`09`09    ReplyExpected(fd, Request);
  1036. X`09`09    break;
  1037. X`09    case 99:
  1038. X`09`09    ListExtensions(buf);
  1039. X`09`09    ReplyExpected(fd, Request);
  1040. X`09`09    break;
  1041. X`09    case 100:
  1042. X`09`09    ChangeKeyboardMapping(buf);
  1043. X`09`09    break;
  1044. X`09    case 101:
  1045. X`09`09    GetKeyboardMapping(buf);
  1046. X`09`09    ReplyExpected(fd, Request);
  1047. X`09`09    break;
  1048. X`09    case 102:
  1049. X`09`09    ChangeKeyboardControl(buf);
  1050. X`09`09    break;
  1051. X`09    case 103:
  1052. X`09`09    GetKeyboardControl(buf);
  1053. X`09`09    ReplyExpected(fd, Request);
  1054. X`09`09    break;
  1055. X`09    case 104:
  1056. X`09`09    Bell(buf);
  1057. X`09`09    break;
  1058. X`09    case 105:
  1059. X`09`09    ChangePointerControl(buf);
  1060. X`09`09    break;
  1061. X`09    case 106:
  1062. X`09`09    GetPointerControl(buf);
  1063. X`09`09    ReplyExpected(fd, Request);
  1064. X`09`09    break;
  1065. X`09    case 107:
  1066. X`09`09    SetScreenSaver(buf);
  1067. X`09`09    break;
  1068. X`09    case 108:
  1069. X`09`09    GetScreenSaver(buf);
  1070. X`09`09    ReplyExpected(fd, Request);
  1071. X`09`09    break;
  1072. X`09    case 109:
  1073. X`09`09    ChangeHosts(buf);
  1074. X`09`09    break;
  1075. X`09    case 110:
  1076. X`09`09    ListHosts(buf);
  1077. X`09`09    ReplyExpected(fd, Request);
  1078. X`09`09    break;
  1079. X`09    case 111:
  1080. X`09`09    SetAccessControl(buf);
  1081. X`09`09    break;
  1082. X`09    case 112:
  1083. X`09`09    SetCloseDownMode(buf);
  1084. X`09`09    break;
  1085. X`09    case 113:
  1086. X`09`09    KillClient(buf);
  1087. X`09`09    break;
  1088. X`09    case 114:
  1089. X`09`09    RotateProperties(buf);
  1090. X`09`09    break;
  1091. X`09    case 115:
  1092. X`09`09    ForceScreenSaver(buf);
  1093. X`09`09    break;
  1094. X`09    case 116:
  1095. X`09`09    SetPointerMapping(buf);
  1096. X`09`09    ReplyExpected(fd, Request);
  1097. X`09`09    break;
  1098. X`09    case 117:
  1099. X`09`09    GetPointerMapping(buf);
  1100. X`09`09    ReplyExpected(fd, Request);
  1101. X`09`09    break;
  1102. X`09    case 118:
  1103. X`09`09    SetModifierMapping(buf);
  1104. X`09`09    ReplyExpected(fd, Request);
  1105. X`09`09    break;
  1106. X`09    case 119:
  1107. X`09`09    GetModifierMapping(buf);
  1108. X`09`09    ReplyExpected(fd, Request);
  1109. X`09`09    break;
  1110. X`09    case 127:
  1111. X`09`09    NoOperation(buf);
  1112. X`09`09    break;
  1113. X`09    default:
  1114. X`09`09    warn("Unimplemented request opcode");
  1115. X`09`09    break;
  1116. X   `7D
  1117. X`7D
  1118. X
  1119. X/* ************************************************************ */
  1120. X/*`09`09`09`09`09`09`09`09*/
  1121. X/*`09`09`09`09`09`09`09`09*/
  1122. X/* ************************************************************ */
  1123. X
  1124. XDecodeReply(fd, buf, n)
  1125. X     FD fd;
  1126. X     unsigned char *buf;
  1127. X     long    n;
  1128. X`7B
  1129. X  short   SequenceNumber = IShort (&buf`5B2`5D);
  1130. X  short   Request = CheckReplyTable (fd, SequenceNumber);
  1131. X  if (Request == 0)
  1132. X    `7B
  1133. X      warn("Unexpected reply");
  1134. X      return;
  1135. X    `7D
  1136. X  SetIndentLevel(PRINTSERVER);
  1137. X  RBf`5B0`5D = Request /* for the PrintField in the Reply procedure */ ;
  1138. X  if (Verbose > 3)
  1139. X    DumpItem("Reply", fd, buf, n);
  1140. X  if (Request <= 0 `7C`7C 127 < Request)
  1141. X    warn("Extended reply opcode");
  1142. X  else switch (Request)
  1143. X    `7B
  1144. X`09    case 3:
  1145. X`09`09    GetWindowAttributesReply(buf);
  1146. X`09`09    break;
  1147. X`09    case 14:
  1148. X`09`09    GetGeometryReply(buf);
  1149. X`09`09    break;
  1150. X`09    case 15:
  1151. X`09`09    QueryTreeReply(buf);
  1152. X`09`09    break;
  1153. X`09    case 16:
  1154. X`09`09    InternAtomReply(buf);
  1155. X`09`09    break;
  1156. X`09    case 17:
  1157. X`09`09    GetAtomNameReply(buf);
  1158. X`09`09    break;
  1159. X`09    case 20:
  1160. X`09`09    GetPropertyReply(buf);
  1161. X`09`09    break;
  1162. X`09    case 21:
  1163. X`09`09    ListPropertiesReply(buf);
  1164. X`09`09    break;
  1165. X`09    case 23:
  1166. X`09`09    GetSelectionOwnerReply(buf);
  1167. X`09`09    break;
  1168. X`09    case 26:
  1169. X`09`09    GrabPointerReply(buf);
  1170. X`09`09    break;
  1171. X`09    case 31:
  1172. X`09`09    GrabKeyboardReply(buf);
  1173. X`09`09    break;
  1174. X`09    case 38:
  1175. X`09`09    QueryPointerReply(buf);
  1176. X`09`09    break;
  1177. X`09    case 39:
  1178. X`09`09    GetMotionEventsReply(buf);
  1179. X`09`09    break;
  1180. X`09    case 40:
  1181. X`09`09    TranslateCoordinatesReply(buf);
  1182. X`09`09    break;
  1183. X`09    case 43:
  1184. X`09`09    GetInputFocusReply(buf);
  1185. X`09`09    break;
  1186. X`09    case 44:
  1187. X`09`09    QueryKeymapReply(buf);
  1188. X`09`09    break;
  1189. X`09    case 47:
  1190. X`09`09    QueryFontReply(buf);
  1191. X`09`09    break;
  1192. X`09    case 48:
  1193. X`09`09    QueryTextExtentsReply(buf);
  1194. X`09`09    break;
  1195. X`09    case 49:
  1196. X`09`09    ListFontsReply(buf);
  1197. X`09`09    break;
  1198. X`09    case 50:
  1199. X`09`09    ListFontsWithInfoReply(buf);
  1200. X`09`09    break;
  1201. X`09    case 52:
  1202. X`09`09    GetFontPathReply(buf);
  1203. X`09`09    break;
  1204. X`09    case 73:
  1205. X`09`09    GetImageReply(buf);
  1206. X`09`09    break;
  1207. X`09    case 83:
  1208. X`09`09    ListInstalledColormapsReply(buf);
  1209. X`09`09    break;
  1210. X`09    case 84:
  1211. X`09`09    AllocColorReply(buf);
  1212. X`09`09    break;
  1213. X`09    case 85:
  1214. X`09`09    AllocNamedColorReply(buf);
  1215. X`09`09    break;
  1216. X`09    case 86:
  1217. X`09`09    AllocColorCellsReply(buf);
  1218. X`09`09    break;
  1219. X`09    case 87:
  1220. X`09`09    AllocColorPlanesReply(buf);
  1221. X`09`09    break;
  1222. X`09    case 91:
  1223. X`09`09    QueryColorsReply(buf);
  1224. X`09`09    break;
  1225. X`09    case 92:
  1226. X`09`09    LookupColorReply(buf);
  1227. X`09`09    break;
  1228. X`09    case 97:
  1229. X`09`09    QueryBestSizeReply(buf);
  1230. X`09`09    break;
  1231. X`09    case 98:
  1232. X`09`09    QueryExtensionReply(buf);
  1233. X`09`09    break;
  1234. X`09    case 99:
  1235. X`09`09    ListExtensionsReply(buf);
  1236. X`09`09    break;
  1237. X`09    case 101:
  1238. X`09`09    GetKeyboardMappingReply(buf);
  1239. X`09`09    break;
  1240. X`09    case 103:
  1241. X`09`09    GetKeyboardControlReply(buf);
  1242. X`09`09    break;
  1243. X`09    case 106:
  1244. X`09`09    GetPointerControlReply(buf);
  1245. X`09`09    break;
  1246. X`09    case 108:
  1247. X`09`09    GetScreenSaverReply(buf);
  1248. X`09`09    break;
  1249. X`09    case 110:
  1250. X`09`09    ListHostsReply(buf);
  1251. X`09`09    break;
  1252. X`09    case 116:
  1253. X`09`09    SetPointerMappingReply(buf);
  1254. X`09`09    break;
  1255. X`09    case 117:
  1256. X`09`09    GetPointerMappingReply(buf);
  1257. X`09`09    break;
  1258. X`09    case 118:
  1259. X`09`09    SetModifierMappingReply(buf);
  1260. X`09`09    break;
  1261. X`09    case 119:
  1262. X`09`09    GetModifierMappingReply(buf);
  1263. X`09`09    break;
  1264. X`09    default:
  1265. X`09`09    warn("Unimplemented reply opcode");
  1266. X`09`09    break;
  1267. X    `7D
  1268. X`7D
  1269. X
  1270. X/* ************************************************************ */
  1271. X/*`09`09`09`09`09`09`09`09*/
  1272. X/*`09`09`09`09`09`09`09`09*/
  1273. X/* ************************************************************ */
  1274. X
  1275. XDecodeError(fd, buf, n)
  1276. X     FD fd;
  1277. X     unsigned char *buf;
  1278. X     long    n;
  1279. X`7B
  1280. X  short   Error = IByte (&buf`5B1`5D);
  1281. X  SetIndentLevel(PRINTSERVER);
  1282. X  if (Verbose > 3)
  1283. X    DumpItem("Error", fd, buf, n);
  1284. X  (void)CheckReplyTable (fd, (short)IShort(&buf`5B2`5D));
  1285. X  if (Error < 1 `7C`7C Error > 17)
  1286. X    warn("Extended Error code");
  1287. X  else switch (Error)
  1288. X    `7B
  1289. X`09    case 1:
  1290. X`09`09    RequestError(buf);
  1291. X`09`09    break;
  1292. X`09    case 2:
  1293. X`09`09    ValueError(buf);
  1294. X`09`09    break;
  1295. X`09    case 3:
  1296. X`09`09    WindowError(buf);
  1297. X`09`09    break;
  1298. X`09    case 4:
  1299. X`09`09    PixmapError(buf);
  1300. X`09`09    break;
  1301. X`09    case 5:
  1302. X`09`09    AtomError(buf);
  1303. X`09`09    break;
  1304. X`09    case 6:
  1305. X`09`09    CursorError(buf);
  1306. X`09`09    break;
  1307. X`09    case 7:
  1308. X`09`09    FontError(buf);
  1309. X`09`09    break;
  1310. X`09    case 8:
  1311. X`09`09    MatchError(buf);
  1312. X`09`09    break;
  1313. X`09    case 9:
  1314. X`09`09    DrawableError(buf);
  1315. X`09`09    break;
  1316. X`09    case 10:
  1317. X`09`09    AccessError(buf);
  1318. X`09`09    break;
  1319. X`09    case 11:
  1320. X`09`09    AllocError(buf);
  1321. X`09`09    break;
  1322. X`09    case 12:
  1323. X`09`09    ColormapError(buf);
  1324. X`09`09    break;
  1325. X`09    case 13:
  1326. X`09`09    GContextError(buf);
  1327. X`09`09    break;
  1328. X`09    case 14:
  1329. X`09`09    IDChoiceError(buf);
  1330. X`09`09    break;
  1331. X`09    case 15:
  1332. X`09`09    NameError(buf);
  1333. X`09`09    break;
  1334. X`09    case 16:
  1335. X`09`09    LengthError(buf);
  1336. X`09`09    break;
  1337. X`09    case 17:
  1338. X`09`09    ImplementationError(buf);
  1339. X`09`09    break;
  1340. X`09    default:
  1341. X`09`09    warn("Unimplemented error code");
  1342. X`09`09    break;
  1343. X    `7D
  1344. X`7D
  1345. X
  1346. X/* ************************************************************ */
  1347. X/*`09`09`09`09`09`09`09`09*/
  1348. X/*`09`09`09`09`09`09`09`09*/
  1349. X/* ************************************************************ */
  1350. X
  1351. XDecodeEvent(fd, buf, n)
  1352. X     FD fd;
  1353. X     unsigned char *buf;
  1354. X     long    n;
  1355. X`7B
  1356. X  short   Event = IByte (&buf`5B0`5D);
  1357. X  SetIndentLevel(PRINTSERVER);
  1358. X  if (Verbose > 3)
  1359. X    DumpItem("Event", fd, buf, n);
  1360. X  if (Event < 2 `7C`7C Event > 34)
  1361. X    warn("Extended Event code");
  1362. X  else switch (Event)
  1363. X    `7B
  1364. X`09    case 2:
  1365. X`09`09    KeyPressEvent(buf);
  1366. X`09`09    break;
  1367. X`09    case 3:
  1368. X`09`09    KeyReleaseEvent(buf);
  1369. X`09`09    break;
  1370. X`09    case 4:
  1371. X`09`09    ButtonPressEvent(buf);
  1372. X`09`09    break;
  1373. X`09    case 5:
  1374. X`09`09    ButtonReleaseEvent(buf);
  1375. X`09`09    break;
  1376. X`09    case 6:
  1377. X`09`09    MotionNotifyEvent(buf);
  1378. X`09`09    break;
  1379. X`09    case 7:
  1380. X`09`09    EnterNotifyEvent(buf);
  1381. X`09`09    break;
  1382. X`09    case 8:
  1383. X`09`09    LeaveNotifyEvent(buf);
  1384. X`09`09    break;
  1385. X`09    case 9:
  1386. X`09`09    FocusInEvent(buf);
  1387. X`09`09    break;
  1388. X`09    case 10:
  1389. X`09`09    FocusOutEvent(buf);
  1390. X`09`09    break;
  1391. X`09    case 11:
  1392. X`09`09    KeymapNotifyEvent(buf);
  1393. X`09`09    break;
  1394. X`09    case 12:
  1395. X`09`09    ExposeEvent(buf);
  1396. X`09`09    break;
  1397. X`09    case 13:
  1398. X`09`09    GraphicsExposureEvent(buf);
  1399. X`09`09    break;
  1400. X`09    case 14:
  1401. X`09`09    NoExposureEvent(buf);
  1402. X`09`09    break;
  1403. X`09    case 15:
  1404. X`09`09    VisibilityNotifyEvent(buf);
  1405. X`09`09    break;
  1406. X`09    case 16:
  1407. X`09`09    CreateNotifyEvent(buf);
  1408. X`09`09    break;
  1409. X`09    case 17:
  1410. X`09`09    DestroyNotifyEvent(buf);
  1411. X`09`09    break;
  1412. X`09    case 18:
  1413. X`09`09    UnmapNotifyEvent(buf);
  1414. X`09`09    break;
  1415. X`09    case 19:
  1416. X`09`09    MapNotifyEvent(buf);
  1417. X`09`09    break;
  1418. X`09    case 20:
  1419. X`09`09    MapRequestEvent(buf);
  1420. X`09`09    break;
  1421. X`09    case 21:
  1422. X`09`09    ReparentNotifyEvent(buf);
  1423. X`09`09    break;
  1424. X`09    case 22:
  1425. X`09`09    ConfigureNotifyEvent(buf);
  1426. X`09`09    break;
  1427. X`09    case 23:
  1428. X`09`09    ConfigureRequestEvent(buf);
  1429. X`09`09    break;
  1430. X`09    case 24:
  1431. X`09`09    GravityNotifyEvent(buf);
  1432. X`09`09    break;
  1433. X`09    case 25:
  1434. X`09`09    ResizeRequestEvent(buf);
  1435. X`09`09    break;
  1436. X`09    case 26:
  1437. X`09`09    CirculateNotifyEvent(buf);
  1438. X`09`09    break;
  1439. X`09    case 27:
  1440. X`09`09    CirculateRequestEvent(buf);
  1441. X`09`09    break;
  1442. X`09    case 28:
  1443. X`09`09    PropertyNotifyEvent(buf);
  1444. X`09`09    break;
  1445. X`09    case 29:
  1446. X`09`09    SelectionClearEvent(buf);
  1447. X`09`09    break;
  1448. X`09    case 30:
  1449. X`09`09    SelectionRequestEvent(buf);
  1450. X`09`09    break;
  1451. X`09    case 31:
  1452. X`09`09    SelectionNotifyEvent(buf);
  1453. X`09`09    break;
  1454. X`09    case 32:
  1455. X`09`09    ColormapNotifyEvent(buf);
  1456. X`09`09    break;
  1457. X`09    case 33:
  1458. X`09`09    ClientMessageEvent(buf);
  1459. X`09`09    break;
  1460. X`09    case 34:
  1461. X`09`09    MappingNotifyEvent(buf);
  1462. X`09`09    break;
  1463. X`09    default:
  1464. X`09`09    warn("Unimplemented event code");
  1465. X`09`09    break;
  1466. X    `7D
  1467. X`7D
  1468. $ CALL UNPACK DECODE11.C;4 661840910
  1469. $ create 'f'
  1470. X/*
  1471. X * $NCDId: @(#)dnet_socket_library.c,v 4.9 1992/02/12 16:01:34 hardison Exp
  1472. V $
  1473. X *
  1474. X * Socket library emulation for DECnet.
  1475. X * This library was created primarily out of the need for a socket-type inte
  1476. Vrface
  1477. X * for DECnet on a VMS host (originally for the DECnet Font Server from NCD)
  1478. V. `20
  1479. X * Gradually, the various socket calls and lower level functions evolved int
  1480. Vo its`20
  1481. X * present form.  The various assumptions and warnings for each routine are
  1482. V included`20
  1483. X * before its declaration.
  1484. X *
  1485. X * Another fine product from: Osborne Hardison - NCD - 11/21/91
  1486. X *
  1487. X * Modifications:
  1488. X *
  1489. X * - Added support for gethostbyxxxx by querying the NCP database for node n
  1490. Vames
  1491. X *   and addresses;  subsequent calls to NCPfind use a binary search to actu
  1492. Vally find
  1493. X *   the given reference (inputs can be in the form of a name, a DECnet addr
  1494. Vess, or
  1495. X *   a hybrid address composed of the last two bytes of the active ethernet
  1496. V address).
  1497. X *   OBH - 1/5/92
  1498. X * - Made changes to accept, bind and nameFromPort for XSCOPE fixes.
  1499. X *   OBH - 3/23/92
  1500. X *
  1501. X */
  1502. X#module DSL DNET_SOCKET_LIBRARY `09/* for easy DEBUG reference */
  1503. X
  1504. X#include stdio
  1505. X#include dvidef
  1506. X#include msgdef
  1507. X#include syidef
  1508. X#include ssdef
  1509. X#include stsdef
  1510. X#include descrip
  1511. X#include nfbdef
  1512. X#include iodef
  1513. X#include errno
  1514. X#include time
  1515. X#include ctype
  1516. X#include "emulationlib.h"`09`09/* emulation macros and definitions */
  1517. X#include "portobj.h"`09`09`09/* port/object translations */
  1518. X#pragma builtins`09`09`09/* for _FFS support */
  1519. X
  1520. Xextern volatile int noshare socket_errno;
  1521. Xextern volatile int noshare h_errno;
  1522. Xextern volatile int noshare errno;
  1523. X
  1524. Xstatic $DESCRIPTOR (netcmd_mbx, "NETCMD_MBX");
  1525. Xstatic $DESCRIPTOR (net_device, "_NET:");
  1526. Xstatic unsigned short lisChannel = 0;
  1527. Xstatic unsigned short mbxChannel = 0;
  1528. Xstatic unsigned short netChannel = 0;
  1529. Xstatic int stackIndex;
  1530. Xstatic int timerExpired;
  1531. Xstatic int zero = 0;
  1532. Xstatic int info_cnt;
  1533. Xstatic int NCPtot = 0;
  1534. Xstatic int mbx_created = 0;
  1535. Xstatic int initChanTable = 1;
  1536. Xstatic int mbxMsgLen = MAX_MSG;
  1537. Xstatic char *ncb = NULL;
  1538. Xstatic struct io_stat_blk netiosb;
  1539. Xstatic NCPstruct *pNCP = NULL;
  1540. Xstatic struct chantable *ChanTableInfo`5BFD_SETSIZE`5D;
  1541. Xstatic struct stackstruct stack`5BMAX_LINKS`5D;
  1542. X
  1543. Xfd_set channelfds;
  1544. Xfd_set *allChannels = &channelfds;
  1545. X
  1546. X#define Number(a)       (sizeof(a)/sizeof(a`5B0`5D))
  1547. X
  1548. X`0C
  1549. X/*`20
  1550. X * SUPPORT ROUTINE DECLARATIONS
  1551. X * Routines to support socket library emulation routines
  1552. X */
  1553. Xvoid `09`09clearChanTable ();`09/* Sets up and clears Channel Table */
  1554. Xint `09`09connectNet ();`09`09/* Connects to NET: and network MBX */
  1555. Xchar `09`09*dnMalloc ();`09`09/* Special malloc */
  1556. Xint `09`09dnFree ();`09`09/* Special free   */
  1557. Xchar `09`09*initNCB ();`09`09/* Net control block init routine */
  1558. Xint `09`09isEtherAddr ();`09`09/* funct to determine is passed str is enet a
  1559. Vddr */
  1560. Xint `09`09isDnetAddr ();`09`09/* funct to determine is passed str is dnet ad
  1561. Vdr */
  1562. Xint `09`09issueNetCmdRead ();`09/* funct to issue a network read w/AST */
  1563. Xint `09`09issueRead ();`09`09/* funct to issue a socket read w/AST */
  1564. Xvoid `09`09linkInit ();`09`09/* link initilization routine */
  1565. Xvoid `09`09linkTerm ();`09`09/* link termination routine */
  1566. Xstruct dsc$descriptor *nameFromPort ();`09/* funct to return an object from
  1567. V a port designation */
  1568. Xstatic int `09NCPpredicate ();`09/* funct to pass to qsort */
  1569. Xint `09`09NCPinit ();`09`09/* sets up the DECnet node data */
  1570. Xint `09`09NCPfind ();`09`09/* finds DECnet node info from name or addr */
  1571. Xvoid `09`09netCmdAst ();`09`09/* AST for network messages */
  1572. Xvoid `09`09notUsed ();`09`09/* funct for unrecognized network messages */
  1573. Xint `09`09processNetCmd ();`09/* processes network messages */
  1574. Xint`09`09readAst ();`09`09/* AST for all asynch select socket reads */
  1575. Xvoid `09`09timeoutAst ();`09`09/* funct for select timeouts */
  1576. Xvoid `09`09upper ();`09`09/* lower to upper conversion */
  1577. X
  1578. X`0C
  1579. X/*`20
  1580. X * EMULATION ROUTINE DECLARATIONS
  1581. X * Routines for the actual socket library emulation
  1582. X */
  1583. Xunsigned short `09accept ();
  1584. Xint `09`09bcmp ();
  1585. Xvoid `09`09*bcopy ();
  1586. Xint `09`09bind ();
  1587. Xint `09`09bzero ();
  1588. Xint `09`09connect ();
  1589. Xint `09`09ffs ();
  1590. Xint `09`09getdtablesize ();
  1591. Xstruct hostent `09*gethostbyaddr ();
  1592. Xstruct hostent `09*gethostbyname ();
  1593. Xint `09`09gethostname ();
  1594. Xint `09`09getpeername ();
  1595. Xint `09`09gettimeofday ();
  1596. Xunsigned short `09htons ();
  1597. Xint `09`09htonl ();
  1598. Xint `09`09inet_addr ();
  1599. Xint `09`09listen ();
  1600. Xint `09`09select ();
  1601. Xint `09`09setsockopt ();
  1602. Xunsigned short `09socket ();
  1603. Xint `09`09socket_close ();
  1604. Xint `09`09socket_ioctl ();
  1605. Xvoid `09`09socket_perror ();
  1606. Xint `09`09socket_read ();
  1607. Xint `09`09socket_write ();
  1608. Xint `09`09socket_writev ();
  1609. X
  1610. X`0C
  1611. X/*
  1612. X * SUPPORT ROUTINES
  1613. X */
  1614. X
  1615. X/*
  1616. X * clearChanTable():
  1617. X * Module to allocate a chantable-struct-sized chunk of VM (if the entry in
  1618. X * the channel table is NULL for the passed shifted channel) or to free the`
  1619. V20
  1620. X * current chunk of VM that is used to maps the passed channel's information
  1621. V (as
  1622. X * in the case of a link termination).
  1623. X */
  1624. Xvoid
  1625. XclearChanTable (shiftChan)
  1626. X`09unsigned short shiftChan;
  1627. X`7B
  1628. X`09int`09i;
  1629. X`09static int movlen = sizeof(struct chantable);
  1630. X
  1631. X`09if (initChanTable)
  1632. X`09`7B
  1633. X`09`09initChanTable = 0;
  1634. X`09`09for (i = 0; i < FD_SETSIZE; i++)
  1635. X`09`09`09ChanTableInfo`5Bi`5D = (struct chantable *) NULL;
  1636. X`09`7D
  1637. X/*`20
  1638. X * Allocate or free the channel table info area in VM depending on who calle
  1639. Vd`20
  1640. X * this procedure.
  1641. X */
  1642. X`09if (ChanTableInfo`5BshiftChan`5D)
  1643. X`09`7B
  1644. X`09`09if (ChanTableInfo`5BshiftChan`5D->nodename)
  1645. X`09`09`09DNETFREE (ChanTableInfo`5BshiftChan`5D->nodename);
  1646. X`09`09if (ChanTableInfo`5BshiftChan`5D->base)
  1647. X`09`09`09DNETFREE (ChanTableInfo`5BshiftChan`5D->base);
  1648. X`09`09if (ChanTableInfo`5BshiftChan`5D->backLogQueue)
  1649. X`09`09`09DNETFREE (ChanTableInfo`5BshiftChan`5D->backLogQueue);
  1650. X`09`09DNETFREE (ChanTableInfo`5BshiftChan`5D);
  1651. X`09`09ChanTableInfo`5BshiftChan`5D = (struct chantable *) NULL;
  1652. X`09`09FD_CLR((shiftChan<<4), allChannels);
  1653. X`09`09return;
  1654. X`09`7D
  1655. X`09ChanTableInfo`5BshiftChan`5D = (struct chantable *) DNETALLOC (movlen);
  1656. X`09LIB$MOVC5 (&zero, NULL, "\0", &movlen, (char *) ChanTableInfo`5BshiftChan
  1657. V`5D);
  1658. X    `09ChanTableInfo`5BshiftChan`5D->base = DNETALLOC(MAX_QIO);
  1659. X    `09ChanTableInfo`5BshiftChan`5D->delta = ChanTableInfo`5BshiftChan`5D->b
  1660. Vase;
  1661. X`7D
  1662. X
  1663. X`0C
  1664. X/*
  1665. X * connectNet
  1666. X * Creates a link to the _NET: device and, if no MBX link  exists, creates o
  1667. Vne
  1668. X * to the network mailbox.
  1669. X */
  1670. Xint
  1671. XconnectNet ()
  1672. X`7B
  1673. X    `09int`09status;
  1674. X
  1675. X    `09if (!mbx_created)
  1676. X    `09`7B
  1677. X    `09`09status = SYS$CREMBX (TEMP_MBX, &mbxChannel, MAX_MSG, BUF_QUO, 0, 0
  1678. V, &netcmd_mbx);
  1679. X`09`09if (VMSFAIL(status)) LIB$SIGNAL(status);
  1680. X    `09`09mbx_created++;
  1681. X    `09`7D
  1682. X`09status = SYS$ASSIGN (&net_device, &netChannel, 0, &netcmd_mbx);
  1683. X`09if (VMSFAIL(status)) LIB$SIGNAL(status);
  1684. X#ifdef DNDEBUG
  1685. X    `09fprintf(stderr, "connectNet: netChannel: %d\n", netChannel);
  1686. X#endif
  1687. X    `09return status;
  1688. X`7D
  1689. X
  1690. X`0C
  1691. X/*
  1692. X * malloc and free routines:
  1693. X * These are specifically tied to LIB$GET_VM and LIB$FREE_VM to
  1694. X * 1) speed things up a notch, and
  1695. X * 2) get away from using buggy CRTL malloc.
  1696. X */
  1697. Xchar *
  1698. XdnMalloc(size)
  1699. X    `09int size;
  1700. X`7B
  1701. X    `09int status;
  1702. X    `09int soql = sizeof(long) * 8;
  1703. X    `09char *addr;
  1704. X
  1705. X    `09size = (((((size + sizeof(int)) + (soql - 1))/soql) +1) * soql);
  1706. X    `09status = LIB$GET_VM(&size, (unsigned long *) &addr);
  1707. X    `09if (VMSFAIL(status)) LIB$SIGNAL(status);
  1708. X    `09bcopy ((char *) &size, addr, sizeof(int));
  1709. X    `09addr += sizeof(int);
  1710. X    `09return addr;
  1711. X`7D
  1712. X
  1713. X`0C
  1714. Xint
  1715. XdnFree(addr)
  1716. X    `09char *addr;
  1717. X`7B
  1718. X    `09int status;
  1719. X    `09unsigned int size;
  1720. X        `09
  1721. X    `09if (!addr) return 1;
  1722. X    `09addr -= sizeof(int);
  1723. X    `09bcopy (addr, (char *) &size, sizeof(int));
  1724. X    `09status = LIB$FREE_VM(&size, (unsigned long *) &addr);
  1725. X    `09if (VMSFAIL(status)) LIB$SIGNAL(status);
  1726. X    `09return 1;
  1727. X`7D
  1728. X
  1729. X`0C
  1730. X/*`20
  1731. X * initNCB
  1732. X * Module to create Network Control Block as in,`20
  1733. X * `7B "MV3100::",'"',"TASK=FONT$FS/",0,'"' `7D from something that looks`20
  1734. X * like this: "decnet/mv3100::FONT$FS".  Note that the object name is`20
  1735. X * assumed to be at the pointer located one word off of the "name" pointer`2
  1736. V0
  1737. X * (name+2), where name points to the sockaddr structure from the program`20
  1738. X * that called (connect()).
  1739. X */
  1740. Xchar *
  1741. XinitNCB (name, objlen, task, node)
  1742. X`09struct sockaddr *name;
  1743. X`09unsigned short`09*objlen;
  1744. X`09char *task;
  1745. X`09char *node;
  1746. X`7B
  1747. X`09char *pncb = (char *) DNETALLOC (NCBSIZE);
  1748. X`09char *op;
  1749. X`09char *onp;
  1750. X
  1751. X`09if (!node)
  1752. X`09`7B
  1753. X`09`09`7B
  1754. X`09`09`09char *oop = (char *) ((char *) name + sizeof(name->sa_family));
  1755. X`09`09`09char *t = &op;
  1756. X`09`09`09bcopy (oop, t, sizeof(&op));
  1757. X`09`09`7D
  1758. X    `09`09if (!isalpha(*op)) return NULL;
  1759. X`09`09upper(op);
  1760. X`09`09if (!(memcmp(op, DNET_PREFIX, strlen(DNET_PREFIX))))`20
  1761. X`09`09`09op += strlen(DNET_PREFIX);
  1762. X`09`09else
  1763. X    `09`09`09return NULL;
  1764. X`09`7D
  1765. X`09else
  1766. X`09`09op = node;
  1767. X`09bcopy(op, (char *) pncb, strlen(op));
  1768. X`09onp = strchr(pncb, ':') + 2;
  1769. X`09if (!node) op = strchr(op, ':') + 2;
  1770. X`09*onp++ = '"';
  1771. X`09strcpy(onp, task);
  1772. X`09onp += strlen(task);
  1773. X`09if (!node)
  1774. X`09`7B
  1775. X`09`09strcpy(onp, op);
  1776. X`09`09onp += strlen(op);
  1777. X`09`09*onp++ = '/';
  1778. X`09`7D
  1779. X`09*onp++ = '\0';
  1780. X`09*onp++ = '\0';
  1781. X`09*onp++ = '"';
  1782. X`09*objlen = onp - (char *) pncb;
  1783. X`09return pncb;
  1784. X`7D
  1785. X
  1786. X`0C
  1787. X/*
  1788. X * isEtherAddr
  1789. X * Boolean routine to determine if a passed client node name
  1790. X * is a valid DECnet name or a ethernet ad hoc name derived from the
  1791. X * last two bytes of the active ethernet address.
  1792. X */
  1793. Xint
  1794. XisEtherAddr (caddr)
  1795. X    `09char *caddr;
  1796. X`7B
  1797. X    `09char *a;
  1798. X
  1799. +-+-+-+-+-+-+-+-  END  OF PART 1 +-+-+-+-+-+-+-+-
  1800. --
  1801. Patrick L. Mahan
  1802.  
  1803. --- TGV Window Washer ------------------------------- Mahan@TGV.COM ---------
  1804.  
  1805. Waking a person unnecessarily should not be considered  - Lazarus Long
  1806. a capital crime.  For a first offense, that is            From the Notebooks of
  1807.                               Lazarus Long
  1808.  
  1809.