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

  1. Path: sparky!uunet!stanford.edu!agate!usenet.ins.cwru.edu!news.ysu.edu!malgudi.oar.net!caen!sol.ctr.columbia.edu!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 08/08
  5. Message-ID: <8045411@MVB.SAIC.COM>
  6. Date: Fri, 04 Sep 1992 05:34:40 GMT
  7. Reply-To: mahan@tgv.com
  8. Organization: TGV Incorporated (Tech Support) in Santa Cruz, CA
  9. Lines: 863
  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 160
  14. Archive-name: xscope/part08
  15.  
  16.  
  17. -+-+-+-+-+-+-+-+ START OF PART 8 -+-+-+-+-+-+-+-+
  18. X  PrintField(buf, 12, 4, CARD32, "black-pixel");
  19. X  PrintField(buf, 16, 4, SETofEVENT, "current-input-masks");
  20. X  PrintField(buf, 20, 2, CARD16, "width-in-pixels");
  21. X  PrintField(buf, 22, 2, CARD16, "height-in-pixels");
  22. X  PrintField(buf, 24, 2, CARD16, "width-in-millimeters");
  23. X  PrintField(buf, 26, 2, CARD16, "height-in-millimeters");
  24. X  PrintField(buf, 28, 2, CARD16, "min-installed-maps");
  25. X  PrintField(buf, 30, 2, CARD16, "max-installed-maps");
  26. X  PrintField(buf, 32, 4, VISUALID, "root-visual");
  27. X  PrintField(buf, 36, 1, BACKSTORE, "backing-stores");
  28. X  PrintField(buf, 37, 1, BOOL, "save-unders");
  29. X  PrintField(buf, 38, 1, CARD8, "root-depth");
  30. X  PrintField(buf, 39, 1, CARD8, "number of allowed-depths");
  31. X  n = IByte(&buf`5B39`5D);
  32. X  m = PrintList(&buf`5B40`5D, (long)n, DEPTH, "allowed-depths");
  33. X  return(40 + m);
  34. X`7D
  35. X
  36. XPrintDEPTH(buf)
  37. X     unsigned char *buf;
  38. X`7B
  39. X  short   n /* number of elements in List of VISUALTYPE */ ;
  40. X  short   m /* length (in bytes) of List of VISUALTYPE */ ;
  41. X
  42. X  PrintField(buf, 0, 1, CARD8, "depth");
  43. X  PrintField(buf, 2, 2, DVALUE2(n), "number of visuals");
  44. X  n = IShort(&buf`5B2`5D);
  45. X  m = PrintList(&buf`5B8`5D, (long)n, VISUALTYPE, "visuals");
  46. X  return(8 + m);
  47. X`7D
  48. X
  49. XPrintVISUALTYPE(buf)
  50. X     unsigned char *buf;
  51. X`7B
  52. X  PrintField(buf, 0, 4, VISUALID, "visual-id");
  53. X  PrintField(buf, 4, 1, COLORCLASS, "class");
  54. X  PrintField(buf, 5, 1, CARD8, "bits-per-rgb-value");
  55. X  PrintField(buf, 6, 2, CARD16, "colormap-entries");
  56. X  PrintField(buf, 8, 4, CARD32, "red-mask");
  57. X  PrintField(buf, 12, 4, CARD32, "green-mask");
  58. X  PrintField(buf, 16, 4, CARD32, "blue-mask");
  59. X  return(24);
  60. X`7D
  61. X
  62. X/* ************************************************************ */
  63. X
  64. XInitRecordTypes()
  65. X`7B
  66. X  (void) DefineType(CHAR2B, RECORD, "CHAR2B", PrintCHAR2B);
  67. X  (void) DefineType(POINT, RECORD, "POINT", PrintPOINT);
  68. X  (void) DefineType(RECTANGLE, RECORD, "RECTANGLE", PrintRECTANGLE);
  69. X  (void) DefineType(ARC, RECORD, "ARC", PrintARC);
  70. X  (void) DefineType(HOST, RECORD, "HOST", PrintHOST);
  71. X  (void) DefineType(TIMECOORD, RECORD, "TIMECOORD", PrintTIMECOORD);
  72. X  (void) DefineType(FONTPROP, RECORD, "FONTPROP", PrintFONTPROP);
  73. X  (void) DefineType(CHARINFO, RECORD, "CHARINFO", PrintCHARINFO);
  74. X  (void) DefineType(SEGMENT, RECORD, "SEGMENT", PrintSEGMENT);
  75. X  (void) DefineType(COLORITEM, RECORD, "COLORITEM", PrintCOLORITEM);
  76. X  (void) DefineType(RGB, RECORD, "RGB", PrintRGB);
  77. X  (void) DefineType(FORMAT, RECORD, "FORMAT", PrintFORMAT);
  78. X  (void) DefineType(SCREEN, RECORD, "SCREEN", PrintSCREEN);
  79. X  (void) DefineType(DEPTH, RECORD, "DEPTH", PrintDEPTH);
  80. X  (void) DefineType(VISUALTYPE, RECORD, "VISUALTYPE", PrintVISUALTYPE);
  81. X`7D
  82. X
  83. X
  84. X
  85. X/* ************************************************************ */
  86. X/*`09`09`09`09`09`09`09`09*/
  87. X/*`09`09`09`09`09`09`09`09*/
  88. X/* ************************************************************ */
  89. X
  90. XInitValuesTypes()
  91. X`7B
  92. X  TYPE p;
  93. X
  94. X  p = DefineType(WINDOW_BITMASK, SET, "WINDOW_BITMASK", PrintSET);
  95. X
  96. X  DefineValues(p, 0x00000001L, 4, PIXMAPNPR, "background-pixmap");
  97. X  DefineValues(p, 0x00000002L, 4, CARD32, "background-pixel");
  98. X  DefineValues(p, 0x00000004L, 4, PIXMAPC, "border-pixmap");
  99. X  DefineValues(p, 0x00000008L, 4, CARD32, "border-pixel");
  100. X  DefineValues(p, 0x00000010L, 1, BITGRAVITY, "bit-gravity");
  101. X  DefineValues(p, 0x00000020L, 1, WINGRAVITY, "win-gravity");
  102. X  DefineValues(p, 0x00000040L, 1, BACKSTORE, "backing-store");
  103. X  DefineValues(p, 0x00000080L, 4, CARD32, "backing-planes");
  104. X  DefineValues(p, 0x00000100L, 4, CARD32, "backing-pixel");
  105. X  DefineValues(p, 0x00000200L, 1, BOOL, "override-redirect");
  106. X  DefineValues(p, 0x00000400L, 1, BOOL, "save-under");
  107. X  DefineValues(p, 0x00000800L, 4, SETofEVENT, "event-mask");
  108. X  DefineValues(p, 0x00001000L, 4, SETofDEVICEEVENT, "do-not-propagate-mask")
  109. V;
  110. X  DefineValues(p, 0x00002000L, 4, COLORMAPC, "colormap");
  111. X  DefineValues(p, 0x00004000L, 4, CURSOR, "cursor");
  112. X
  113. X  p = DefineType(CONFIGURE_BITMASK, SET, "CONFIGURE_BITMASK", PrintSET);
  114. X  DefineValues(p, 0x0001L, 2, INT16, "x");
  115. X  DefineValues(p, 0x0002L, 2, INT16, "y");
  116. X  DefineValues(p, 0x0004L, 2, CARD16, "width");
  117. X  DefineValues(p, 0x0008L, 2, CARD16, "height");
  118. X  DefineValues(p, 0x0010L, 2, CARD16, "border-width");
  119. X  DefineValues(p, 0x0020L, 4, WINDOW, "sibling");
  120. X  DefineValues(p, 0x0040L, 1, STACKMODE, "stack-mode");
  121. X
  122. X  p = DefineType(GC_BITMASK, SET, "GC_BITMASK", PrintSET);
  123. X  DefineValues(p, 0x00000001L, 1, GCFUNC, "function");
  124. X  DefineValues(p, 0x00000002L, 4, CARD32, "plane-mask");
  125. X  DefineValues(p, 0x00000004L, 4, CARD32, "foreground");
  126. X  DefineValues(p, 0x00000008L, 4, CARD32, "background");
  127. X  DefineValues(p, 0x00000010L, 2, CARD16, "line-width");
  128. X  DefineValues(p, 0x00000020L, 1, LINESTYLE, "line-style");
  129. X  DefineValues(p, 0x00000040L, 1, CAPSTYLE, "cap-style");
  130. X  DefineValues(p, 0x00000080L, 1, JOINSTYLE, "join-style");
  131. X  DefineValues(p, 0x00000100L, 1, FILLSTYLE, "fill-style");
  132. X  DefineValues(p, 0x00000200L, 1, FILLRULE, "fill-rule");
  133. X  DefineValues(p, 0x00000400L, 4, PIXMAP, "tile");
  134. X  DefineValues(p, 0x00000800L, 4, PIXMAP, "stipple");
  135. X  DefineValues(p, 0x00001000L, 2, INT16, "tile-stipple-x-origin");
  136. X  DefineValues(p, 0x00002000L, 2, INT16, "tile-stipple-y-origin");
  137. X  DefineValues(p, 0x00004000L, 4, FONT, "font");
  138. X  DefineValues(p, 0x00008000L, 1, SUBWINMODE, "subwindow-mode");
  139. X  DefineValues(p, 0x00010000L, 1, BOOL, "graphics-exposures");
  140. X  DefineValues(p, 0x00020000L, 2, INT16, "clip-x-origin");
  141. X  DefineValues(p, 0x00040000L, 2, INT16, "clip-y-origin");
  142. X  DefineValues(p, 0x00080000L, 4, PIXMAP, "clip-mask");
  143. X  DefineValues(p, 0x00100000L, 2, CARD16, "dash-offset");
  144. X  DefineValues(p, 0x00200000L, 1, CARD8, "dashes");
  145. X  DefineValues(p, 0x00400000L, 1, ARCMODE, "arc-mode");
  146. X
  147. X  p = DefineType(KEYBOARD_BITMASK, SET, "KEYBOARD_BITMASK", PrintSET);
  148. X  DefineValues(p, 0x0001L, 1, INT8, "key-click-percent");
  149. X  DefineValues(p, 0x0002L, 1, INT8, "bell-percent");
  150. X  DefineValues(p, 0x0004L, 2, INT16, "bell-pitch");
  151. X  DefineValues(p, 0x0008L, 2, INT16, "bell-duration");
  152. X  DefineValues(p, 0x0010L, 1, CARD8, "led");
  153. X  DefineValues(p, 0x0020L, 1, OFF_ON, "led-mode");
  154. X  DefineValues(p, 0x0040L, 1, KEYCODE, "key");
  155. X  DefineValues(p, 0x0080L, 1, OFF_ON, "auto-repeat-mode");
  156. X`7D
  157. $ CALL UNPACK TABLE11.C;3 1260789462
  158. $ create 'f'
  159. X./Imakefile,v
  160. X./common.c,v
  161. X./fd.c,v
  162. X./decode11.c,v
  163. X./fd.h,v
  164. X./print11.c,v
  165. X./patchlevel.h,v
  166. X./prtype.c,v
  167. X./scope.c,v
  168. X./scope.h,v
  169. X./server.c,v
  170. X./table11.c,v
  171. X./x11.h,v
  172. X./xscope.man,v
  173. X./tarfiles
  174. $ CALL UNPACK TARFILES.;1 1601260302
  175. $ create 'f'
  176. X/* ************************************************************ *
  177. X *`09`09`09`09`09`09     `09`09*
  178. X *  Type definitions and Connection State for the  X11 protocol *
  179. X *`09`09`09`09`09`09      `09`09*
  180. X *`09James Peterson, 1988`09`09`09      `09`09*
  181. X *`09(c) Copyright MCC, 1988 `09`09      `09`09*
  182. X *`09`09`09`09`09`09      `09`09*
  183. X * ************************************************************ */
  184. X
  185. X
  186. X/* Some field contents are constants, not just types */
  187. X
  188. X#define CONST1(n)  CARD8
  189. X#define CONST2(n)  CARD16
  190. X#define CONST4(n)  CARD32
  191. X
  192. X/* Some field contents define the components of an expression */
  193. X
  194. X#define DVALUE1(expression)  CARD8
  195. X#define DVALUE2(expression)  CARD16
  196. X#define DVALUE4(expression)  CARD32
  197. X
  198. X
  199. X/* ************************************************************ */
  200. X/*`09`09`09`09`09`09`09`09*/
  201. X/*`09`09`09`09`09`09`09`09*/
  202. X/* ************************************************************ */
  203. X
  204. X/* Built-in Types */
  205. X
  206. X#define BYTE 1`09`09       /* 8-bit value */
  207. X#define INT8 2`09`09       /* 8-bit signed integer */
  208. X#define INT16 3`09`09       /* 16-bit signed integer */
  209. X#define INT32 4`09`09       /* 32-bit signed integer */
  210. X#define CARD8 5`09`09       /* 8-bit unsigned integer */
  211. X#define CARD16 6`09       /* 16-bit unsigned integer */
  212. X#define CARD32 7`09       /* 32-bit unsigned integer */
  213. X#define STRING8 8`09       /* List of CARD8 */
  214. X#define STRING16 9`09       /* List of CHAR2B */
  215. X#define TEXTITEM8 10`09       /* STRING8 or Font shift */
  216. X#define TEXTITEM16 11`09       /* STRING16 or Font shift */
  217. X
  218. X#define WINDOW 12`09       /* CARD32  plus 0 = None */
  219. X#define WINDOWD 13`09       /* CARD32  plus 0 = PointerWindow, 1 =
  220. X`09`09`09          InputFocus */
  221. X#define WINDOWNR 14`09       /* CARD32  plus 0 = None, 1 = PointerRoot */
  222. X
  223. X#define PIXMAP 15`09       /* CARD32  plus 0 = None */
  224. X#define PIXMAPNPR 16`09       /* CARD32  plus 0 = None, 1 = ParentRelative`2
  225. V0
  226. X`09`09`09       */
  227. X#define PIXMAPC 17`09       /* CARD32  plus 0 = CopyFromParent */
  228. X
  229. X#define CURSOR 18`09       /* CARD32  plus 0 = None */
  230. X
  231. X#define FONT 19`09`09       /* CARD32  plus 0 = None */
  232. X
  233. X#define GCONTEXT 20`09       /* CARD32 */
  234. X
  235. X#define COLORMAP 21`09       /* CARD32 plus 0 = None */
  236. X#define COLORMAPC 22`09       /* CARD32 plus 0 = CopyFromParent */
  237. X
  238. X#define DRAWABLE 23`09       /* CARD32 */
  239. X#define FONTABLE 24`09       /* CARD32 */
  240. X
  241. X#define ATOM 25`09`09       /* CARD32 plus 0 = None */
  242. X#define ATOMT 26`09       /* CARD32 plus 0 = AnyPropertyType */
  243. X
  244. X#define VISUALID 27`09       /* CARD32 plus 0 = None */
  245. X#define VISUALIDC 28`09       /* CARD32 plus 0 = CopyFromParent */
  246. X
  247. X#define TIMESTAMP 29`09       /* CARD32 plus 0 as the current time */
  248. X
  249. X#define RESOURCEID 30`09       /* CARD32 plus 0 = AllTemporary */
  250. X
  251. X#define KEYSYM 31`09       /* CARD32 */
  252. X#define KEYCODE 32`09       /* CARD8 */
  253. X#define KEYCODEA 33`09       /* CARD8 plus 0 = AnyKey */
  254. X
  255. X#define BUTTON 34`09       /* CARD8 */
  256. X#define BUTTONA 35`09       /* CARD8 plus 0 = AnyButton */
  257. X
  258. X#define EVENTFORM 34`09       /* event format */
  259. X#define CHAR8 35`09       /* CARD8 interpreted as a character */
  260. X#define STR 36`09`09       /* String of CHAR8 with preceding length */
  261. X
  262. X/* ************************************************************ */
  263. X/*`09`09`09`09`09`09`09`09*/
  264. X/*`09`09`09`09`09`09`09`09*/
  265. X/* ************************************************************ */
  266. X
  267. X/* Defined types */
  268. X
  269. X#define BITGRAVITY`09 40`20
  270. X#define WINGRAVITY`09 41`20
  271. X#define BOOL`09`09 42`20
  272. X#define HOSTFAMILY`09 43`20
  273. X#define PK_MODE`09`09 44`20
  274. X#define NO_YES`09`09 45`20
  275. X#define WINDOWCLASS`09 46`20
  276. X#define BACKSTORE`09 47`20
  277. X#define MAPSTATE`09 48`20
  278. X#define STACKMODE`09 49`20
  279. X#define CIRMODE`09 `09 50`20
  280. X#define CHANGEMODE`09 51`20
  281. X#define GRABSTAT`09 52`20
  282. X#define EVENTMODE`09 53`20
  283. X#define FOCUSAGENT`09 54`20
  284. X#define DIRECT`09`09 55`20
  285. X#define GCFUNC`09`09 56`20
  286. X#define LINESTYLE`09 57`20
  287. X#define CAPSTYLE`09 58`20
  288. X#define JOINSTYLE`09 59`20
  289. X#define FILLSTYLE`09 60`20
  290. X#define FILLRULE`09 61`20
  291. X#define SUBWINMODE`09 62`20
  292. X#define ARCMODE`09 `09 63`20
  293. X#define RECTORDER`09 64`20
  294. X#define COORMODE`09 65`20
  295. X#define POLYSHAPE`09 66`20
  296. X#define IMAGEMODE`09 67`20
  297. X#define ALLORNONE`09 68`20
  298. X#define OBJECTCLASS`09 69`20
  299. X#define OFF_ON`09`09 70`20
  300. X#define INS_DEL`09 `09 71`20
  301. X#define DIS_EN`09`09 72`20
  302. X#define CLOSEMODE`09 73`20
  303. X#define SAVEMODE`09 74`20
  304. X#define RSTATUS`09 `09 75`20
  305. X#define MOTIONDETAIL`09 76`20
  306. X#define ENTERDETAIL`09 77`20
  307. X#define BUTTONMODE`09 78`20
  308. X#define SCREENFOCUS`09 79`20
  309. X#define VISIBLE`09 `09 80`20
  310. X#define CIRSTAT`09 `09 81`20
  311. X#define PROPCHANGE`09 82`20
  312. X#define CMAPCHANGE`09 83`20
  313. X#define MAPOBJECT`09 84`20
  314. X#define SETofEVENT`09 85`20
  315. X#define SETofPOINTEREVENT`09 86`20
  316. X#define SETofDEVICEEVENT`09 87`20
  317. X#define SETofKEYBUTMASK`09 `09 88`20
  318. X#define SETofKEYMASK`09`09 89`20
  319. X#define WINDOW_BITMASK`09`09 90`20
  320. X#define CONFIGURE_BITMASK`09 91`20
  321. X#define GC_BITMASK`09`09 92`20
  322. X#define KEYBOARD_BITMASK`09 93`20
  323. X#define COLORMASK`09`09 94`20
  324. X#define CHAR2B`09`09 95`20
  325. X#define POINT`09`09 96`20
  326. X#define RECTANGLE`09 97`20
  327. X#define ARC`09`09 98`20
  328. X#define HOST`09`09 99`20
  329. X#define TIMECOORD`09100`20
  330. X#define FONTPROP`09101`20
  331. X#define CHARINFO`09102`20
  332. X#define SEGMENT`09`09103`20
  333. X#define COLORITEM`09104`20
  334. X#define RGB`09`09105`20
  335. X#define BYTEMODE`09110
  336. X#define BYTEORDER`09111
  337. X#define COLORCLASS`09112
  338. X#define FORMAT`09`09113
  339. X#define SCREEN`09`09114
  340. X#define DEPTH`09`09115
  341. X#define VISUALTYPE`09116
  342. X
  343. X#define REQUEST`09`09117
  344. X#define REPLY`09`09118
  345. X#define ERROR`09`09119
  346. X#define EVENT`09`09120
  347. X
  348. X#define MaxTypes 128
  349. X
  350. X/* ************************************************************ */
  351. X/*`09`09`09`09`09`09`09`09*/
  352. X/*`09`09`09`09`09`09`09`09*/
  353. X/* ************************************************************ */
  354. X
  355. X/* declaration of the existance of print routines for the basic types */
  356. X
  357. XPrintINT8();
  358. XPrintINT16();
  359. XPrintINT32();
  360. XPrintCARD8();
  361. XPrintCARD16();
  362. XPrintCARD32();
  363. XPrintBYTE();
  364. XPrintCHAR8();
  365. X#ifdef vax11c
  366. XMYPrintSTRING16();
  367. X#define PrintSTRING16 MYPrintSTRING16
  368. X#else
  369. XPrintSTRING16();
  370. X#endif /* vax11c */
  371. XPrintTEXTITEM8();
  372. XPrintTEXTITEM16();
  373. XPrintSTR();
  374. XPrintWINDOW();
  375. XPrintWINDOWD();
  376. XPrintWINDOWNR();
  377. XPrintPIXMAP();
  378. XPrintPIXMAPNPR();
  379. XPrintPIXMAPC();
  380. XPrintCURSOR();
  381. XPrintFONT();
  382. XPrintGCONTEXT();
  383. XPrintCOLORMAP();
  384. XPrintCOLORMAPC();
  385. XPrintDRAWABLE();
  386. XPrintFONTABLE();
  387. XPrintATOM();
  388. XPrintATOMT();
  389. XPrintVISUALID();
  390. XPrintVISUALIDC();
  391. XPrintTIMESTAMP();
  392. XPrintRESOURCEID();
  393. XPrintKEYSYM();
  394. XPrintKEYCODE();
  395. XPrintKEYCODEA();
  396. XPrintBUTTON();
  397. XPrintBUTTONA();
  398. XPrintEVENTFORM();
  399. XPrintENUMERATED();
  400. XPrintSET();
  401. X
  402. X/* ************************************************************ */
  403. X/*`09`09`09`09`09`09`09`09*/
  404. X/*`09`09`09`09`09`09`09`09*/
  405. X/* ************************************************************ */
  406. X
  407. X/*  Type Definition Table
  408. X
  409. X    Each item in the X11 Protocol has a type.  There are about 120
  410. X    different types.  We need to be able to print each item in a`20
  411. X    format and interpretation which is appropriate for the type of
  412. X    that item.  To do so, we build a table describing each type.
  413. X    Each type has a name, possibly a list of named values and a
  414. X    procedure which knows how to print that type.
  415. X*/
  416. X
  417. X/* Types of Types */
  418. X
  419. X#define BUILTIN    1
  420. X#define ENUMERATED 2
  421. X#define SET        3
  422. X#define RECORD     5
  423. X
  424. X
  425. X/* Enumerated and Set types need a list of Named Values */
  426. X
  427. Xstruct ValueListEntry
  428. X`7B
  429. X    struct ValueListEntry  *Next;
  430. X    char   *Name;
  431. X    short   Type;
  432. X    short   Length;
  433. X    long    Value;
  434. X`7D;
  435. X
  436. Xstruct TypeDef
  437. X`7B
  438. X    char   *Name;
  439. X    short   Type /* BUILTIN, ENUMERATED, SET, or RECORD */ ;
  440. X    struct ValueListEntry  *ValueList;
  441. X    int     (*PrintProc)();
  442. X`7D;
  443. X
  444. Xtypedef struct TypeDef *TYPE;
  445. X
  446. Xstruct TypeDef  TD`5BMaxTypes`5D;
  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/* Reply Buffer: Pseudo-buffer used to provide the opcode for the
  454. X                 request to which this is a reply: Set by DecodeReply
  455. X`09`09 and used in the PrintField of the Reply procedure */
  456. Xunsigned char    RBf`5B2`5D;
  457. X
  458. X
  459. X/* Sequence Buffer: Pseudo-buffer used to provide the sequence number for a
  460. X                 request: Set by DecodeReply and used in a PrintField of`20
  461. X`09`09 the Request procedure */
  462. Xunsigned char    SBf`5B4`5D;
  463. X
  464. X
  465. X#define PRINTSERVER 5`09       /* indent output as if it comes from server *
  466. V/
  467. X#define PRINTCLIENT 1`09       /* indent output as if it comes from client *
  468. V/
  469. X
  470. X/* ************************************************************ */
  471. X/*`09`09`09`09`09`09`09`09*/
  472. X/*`09`09`09`09`09`09`09`09*/
  473. X/* ************************************************************ */
  474. X
  475. X/*`20
  476. X  In general, we are called with a buffer of bytes and are supposed to
  477. X  try to make sense of these bytes according to the X11 protocol.  There
  478. X  are two different types of communication: requests from the client to
  479. X  the server and replies/errors/events from the server to the client.
  480. X  We must interpret these two differently.
  481. X
  482. X  Also, we must consider that the bytes on the communication socket may
  483. X  be sent asynchronously in any amount.  This means that we must be prepared
  484. X  to read in and save some bytes until we get enough to do something with
  485. X  them.  For example, suppose that we get a buffer from a client.  We would
  486. X  expect it to be a request.  The request may be 24 bytes long.  We may find
  487. V,
  488. X  however, that only 16 bytes have actually arrived -- the other 8 are stuck
  489. X  in a buffer somewhere.  We must be prepared to simply hold the 16 bytes we
  490. X  have until more bytes arrive.
  491. X
  492. X  In general, we do two things: we wait for some number of bytes, and
  493. X  then we interpret this set of bytes.  To interpret this data we use`20
  494. X  a modified state machine.  We keep two pieces of information:
  495. X
  496. X  (1) the number of bytes that we need
  497. X  (2) what to do with those bytes.
  498. X
  499. X  This last piece of information is the "state" of the interpretation.
  500. X  We keep the state as a pointer to the procedure that is to be executed.
  501. X
  502. X
  503. X  CLIENTS:
  504. X
  505. X  The data going from the client to the x11 server consists of a
  506. X  set-up message followed by an infinite stream of variable length
  507. X  requests. `20
  508. X
  509. X  Our overall flow is then:
  510. X
  511. X  (a) Wait for 12 bytes.
  512. X  (b) Interpret these first 12 bytes of the set-up message to get the
  513. X      length of the rest of the message.
  514. X  (c) Wait for the rest of the set-up message.
  515. X  (d) Interpret and print the set-up message.
  516. X `20
  517. X  *** end of set-up phase -- start normal request loop ***
  518. X
  519. X  (e) Wait for 4 bytes.
  520. X  (f) Interpret these 4 bytes to get the length of the rest of the command.
  521. X  (g) Wait for the rest of the command.
  522. X  (h) Interpret and print the command.
  523. X  (i) Go back to step (e).
  524. X
  525. X  SERVERS:
  526. X
  527. X  Again, we have a set-up reply followed by an infinite stream of variable
  528. X  length replies/errors/events.
  529. X
  530. X  Our overall flow is then:
  531. X
  532. X  (a) Wait for 8 bytes.
  533. X  (b) Interpret the 8 bytes to get the length of the rest of the set-up repl
  534. Vy.
  535. X  (c) Wait for the rest of the set-up reply.
  536. X  (d) Interpret and print the set-up reply.
  537. X
  538. X  *** end of set-up phase -- start normal reply/error/event loop ***
  539. X
  540. X  We have the following properties of X11 replies, errors, and events:
  541. X
  542. X  Replies:  32 bytes plus a variable amount.  Byte 0 is 1.
  543. X            Bytes 2-3 are a sequence number; bytes 4-7 are length (n).  The
  544. X`09    complete length of the reply is 32 + 4 * n.
  545. X
  546. X  Errors:   32 bytes.  Byte 0 is 0.
  547. X            Byte 1 is an error code; bytes 2-3 are a sequence number.
  548. X`09    Bytes 8-9 are a major opcode; byte 10 is a minor opcode.
  549. X
  550. X  Events:   32 bytes.  Byte 0 is 2, 3, 4, ....
  551. X
  552. X  Looking at this we have two choices:  wait for one byte and then separatel
  553. Vy
  554. X  wait for replies, errors, and events, or wait for 32 bytes, then separatel
  555. Vy
  556. X  process each type.  We may have to wait for more, in the event of a reply.
  557. X  This latter seems more effective.  It appears reply/error/event formats
  558. X  were selected to allow waiting for 32 bytes, and it will allow short packe
  559. Vts
  560. X  which are only 32 bytes long, to be processed completely in one step.
  561. X `20
  562. X  Thus, For normal reply/error/event processing we have`20
  563. X
  564. X  (e) Wait for 32 bytes.
  565. X  (f) Interpret these 32 bytes.  If possible, go back to step (e).
  566. X  (g) If the packet is a reply with bytes 4-7 non-zero, wait for the
  567. X      remainder of the the reply.
  568. X  (h) Interpret and print the longer reply.  Go back to step (e).
  569. X `20
  570. X
  571. X  The similarity in approach to how both the client and server are handled
  572. X  suggests we can use the same control structure to drive the interpretation
  573. X  of both types of communication client->server and server->client. `20
  574. X  Accordingly, we package up the relevant variables in a ConnState
  575. X  record.  The ConnState record contains the buffer of saved bytes (if any),
  576. X  the size and length of this buffer, the number of bytes we are waiting for
  577. X  and what to do when we get them.  A separate ConnState record is kept
  578. X  for the client and server.
  579. X
  580. X  In addition, we may have several different client or server connections.
  581. X  Thus we need an array of all the necessary state for each client or server
  582. V.
  583. X  A client/server is identified with a file descriptor (fd), so we use the
  584. X  fd to identify the client/server and use it as an index into an array of
  585. X  state variables.
  586. X*/
  587. X
  588. Xstruct ConnState
  589. X`7B
  590. X    unsigned char   *SavedBytes;
  591. X    int`09    littleEndian;
  592. X    long    SizeofSavedBytes;
  593. X    long    NumberofSavedBytes;
  594. X
  595. X    long    NumberofBytesNeeded;
  596. X    long    (*ByteProcessing)();
  597. X
  598. X    long    SequenceNumber;
  599. X`7D;
  600. X
  601. X#ifdef vax11c
  602. Xstruct ConnState    *CS = NULL;
  603. X#else
  604. Xstruct ConnState    CS`5BStaticMaxFD`5D;
  605. X#endif /* vax11c */
  606. X
  607. X
  608. X
  609. X
  610. X/* ************************************************************ */
  611. X/*`09`09`09`09`09`09`09`09*/
  612. X/*`09`09`09`09`09`09`09`09*/
  613. X/* ************************************************************ */
  614. X
  615. X/* declaraction of the types of some common functions */
  616. X
  617. Xextern unsigned long    ILong();
  618. Xextern unsigned short   IShort();
  619. Xextern unsigned short   IByte();
  620. Xextern Boolean          IBool();
  621. X
  622. Xextern long    PrintList();
  623. Xextern long    PrintListSTR();
  624. Xextern long    pad();
  625. $ CALL UNPACK X11.H;6 117966406
  626. $ create 'f'
  627. X.TH XSCOPE 1 "8 Sept 1988" "X Version 11"
  628. X.SH NAME
  629. Xxscope - X Window Protocol Viewer
  630. X.SH SYNOPSIS
  631. X.B xscope
  632. X`5B option `5D ...
  633. X.SH DESCRIPTION
  634. X.I Xscope
  635. Xsits in-between an X11 client and an X11 server and prints the contents
  636. Xof each request, reply, error, or event that is communicated between them.
  637. XThis information can be useful in debugging and performance
  638. Xtuning of X11 servers and clients.
  639. X.PP
  640. XTo operate, \fIxscope\fP must know the host, port, and display to use
  641. Xto connect to the X11 server.  In addition, it must know the port on
  642. Xwhich it should listen for X11 clients.  Two cases are common:
  643. X.PP
  644. X.TP 5
  645. X(1) The X11 server is on the same host as \fIxscope\fP.
  646. XIn this case, the input port for \fIxscope\fP should be selected as an
  647. XX11 server on a different display, and the client DISPLAY argument
  648. Xadjusted to select \fIxscope\fP .  For example, if the X11 server is
  649. Xon port 6000, display 1, then \fIxscope\fP can use port 6002 as its
  650. Xinput port.  The client can use display 1 for direct access to X11 or
  651. Xdisplay 2 for access to \fIxscope\fP.
  652. X.PP
  653. X.TP 5
  654. X(2) The X11 server is on a different host than \fIxscope\fP.
  655. XIn this case the same input and output ports can be used, and the host
  656. Xcomponent of the DISPLAY is used to select \fIxscope\fP or X11.
  657. X.SH ARGUMENTS
  658. X.PP
  659. X.TP 10
  660. X.B \-i<input-port>
  661. XSpecify the port that \fIxscope\fP will use to take requests from clients
  662. X(defaults to 1).
  663. XFor X11, this port is automatically biased by 6000.
  664. X.PP
  665. X.TP 10
  666. X.B \-o<output-port>
  667. XDetermines the port that`20
  668. X\fIxscope\fP will use to connect to X11 (defaults to 0).`20
  669. XFor X11, this port is automatically biased by 6000.
  670. X.PP
  671. X.TP 10
  672. X.B \-h<host>
  673. XDetermines the host that  \fIxscope\fP will use to find its X11 server.
  674. X.PP
  675. X.TP 10
  676. X.B \-d<display>
  677. XDefines the display number.  The display number is added to the input
  678. Xand output port to give the actual ports which are used by  \fIxscope\fP.
  679. X.PP
  680. X.TP 10
  681. X.B \-q
  682. XQuiet output mode.  Gives only the names of requests, replies, errors, and`2
  683. V0
  684. Xevents, but does not indicate contents.
  685. X.PP
  686. X.TP 10
  687. X.B \-v<print-level>
  688. XDetermines the level of printing which \fIxscope\fP will provide.  The
  689. Xprint-level can be 0 (same as quiet mode), 1, 2, 3, 4.  The larger
  690. Xnumbers give more and more output.  For example, a successful setup
  691. Xreturns a string which is the name of the vendor of the X11 server.
  692. XAt level 1, the explicit field giving the length of the string is
  693. Xsuppressed since it can be inferred from the string.  At level 2 and
  694. Xabove the length is explicitly printed.
  695. X.SH EXAMPLES
  696. X.LP
  697. Xxscope -v4 -hcleo -d0 -o0 -i1
  698. X.PP
  699. XThis command would have xscope communicate with an X11 server on host
  700. X`60`60cleo'', display 0;  xscope itself would be available on the current
  701. Xhost as display 1 (display of 0 plus the 1 of -i1). Verbose level 4.
  702. X.LP
  703. Xxscope -q -d1 -o1 -o3
  704. X.PP
  705. XThe X11 server for the current host, display 2 (1 for -d1 plus 1 for -o1)
  706. Xwould be used by xscope which would run as display 4 (1 for -d1 plus 3 for
  707. X-o3). Quite mode (verbose level 0).
  708. X.SH SEE ALSO
  709. XX(1), X11 Protocol document (doc/Protocol/X11.protocol)
  710. X.SH AUTHOR
  711. X.PP
  712. XJames L. Peterson (MCC)
  713. X.PP
  714. XCopyright 1988, MCC
  715. X.SH BUGS
  716. XCode has only been tested on Sun3's.
  717. $ CALL UNPACK XSCOPE.1;1 1534005916
  718. $ create 'f'
  719. X
  720. X
  721. X
  722. XXSCOPE(1)                USER COMMANDS                  XSCOPE(1)
  723. X
  724. X
  725. X
  726. XNAME
  727. X     xscope - X Window Protocol Viewer
  728. X
  729. XSYNOPSIS
  730. X     xscope `5B option `5D ...
  731. X
  732. XDESCRIPTION
  733. X     _`08X_`08s_`08c_`08o_`08p_`08e sits in-between an X11 client and an X11
  734. V  server  and
  735. X     prints  the contents of each request, reply, error, or event
  736. X     that is communicated between them.  This information can  be
  737. X     useful  in  debugging  and performance tuning of X11 servers
  738. X     and clients.
  739. X
  740. X     To operate, _`08x_`08s_`08c_`08o_`08p_`08e must know the host, port, an
  741. Vd display  to
  742. X     use to connect to the X11 server.  In addition, it must know
  743. X     the port on which it should listen  for  X11  clients.   Two
  744. X     cases are common:
  745. X
  746. X     (1) The X11 server is on the same host as _`08x_`08s_`08c_`08o_`08p_`08
  747. Ve.
  748. X          In this case, the  input  port  for  _`08x_`08s_`08c_`08o_`08p_`08
  749. Ve  should  be
  750. X          selected  as  an X11 server on a different display, and
  751. X          the client DISPLAY argument adjusted to select _`08x_`08s_`08c_`08
  752. Vo_`08p_`08e .
  753. X          For example, if the X11 server is on port 6000, display
  754. X          1, then _`08x_`08s_`08c_`08o_`08p_`08e can use port 6002  as  its
  755. V  input  port.
  756. X          The  client  can use display 1 for direct access to X11
  757. X          or display 2 for access to _`08x_`08s_`08c_`08o_`08p_`08e.
  758. X
  759. X     (2) The X11 server is on a different host than _`08x_`08s_`08c_`08o_`08
  760. Vp_`08e.
  761. X          In this case the same input and  output  ports  can  be
  762. X          used,  and the host component of the DISPLAY is used to
  763. X          select _`08x_`08s_`08c_`08o_`08p_`08e or X11.
  764. X
  765. XARGUMENTS
  766. X     -i<input-port>
  767. X               Specify the port that  _`08x_`08s_`08c_`08o_`08p_`08e  will
  768. V  use  to  take
  769. X               requests  from  clients (defaults to 1).  For X11,
  770. X               this port is automatically biased by 6000.
  771. X
  772. X     -o<output-port>
  773. X               Determines the port that _`08x_`08s_`08c_`08o_`08p_`08e will
  774. V use  to  con-
  775. X               nect to X11 (defaults to 0). For X11, this port is
  776. X               automatically biased by 6000.
  777. X
  778. X     -h<host>  Determines the host that  _`08x_`08s_`08c_`08o_`08p_`08e will
  779. V use to  find
  780. X               its X11 server.
  781. X
  782. X     -d<display>
  783. X               Defines the display number.  The display number is
  784. X               added  to  the  input  and output port to give the
  785. X               actual ports which are used by  _`08x_`08s_`08c_`08o_`08p_`08
  786. Ve.
  787. X
  788. X
  789. X
  790. X
  791. X
  792. XX Version 11        Last change: 8 Sept 1988                    1
  793. X
  794. X
  795. X
  796. X
  797. X
  798. X
  799. XXSCOPE(1)                USER COMMANDS                  XSCOPE(1)
  800. X
  801. X
  802. X
  803. X     -q        Quiet  output  mode.   Gives  only  the  names  of
  804. X               requests,  replies,  errors,  and events, but does
  805. X               not indicate contents.
  806. X
  807. X     -v<print-level>
  808. X               Determines the level of printing which _`08x_`08s_`08c_`08o_`
  809. V08p_`08e will
  810. X               provide.   The print-level can be 0 (same as quiet
  811. X               mode), 1, 2, 3, 4.  The larger numbers  give  more
  812. X               and  more output.  For example, a successful setup
  813. X               returns a string which is the name of  the  vendor
  814. X               of the X11 server.  At level 1, the explicit field
  815. X               giving the length  of  the  string  is  suppressed
  816. X               since  it  can  be  inferred  from the string.  At
  817. X               level  2  and  above  the  length  is   explicitly
  818. X               printed.
  819. X
  820. XEXAMPLES
  821. X     xscope -v4 -hcleo -d0 -o0 -i1
  822. X
  823. X     This command would  have  xscope  communicate  with  an  X11
  824. X     server  on host `60`60cleo'', display 0;  xscope itself would be
  825. X     available on the current host as display  1  (display  of  0
  826. X     plus the 1 of -i1). Verbose level 4.
  827. X
  828. X     xscope -q -d1 -o1 -o3
  829. X
  830. X     The X11 server for the current host, display 2  (1  for  -d1
  831. X     plus  1  for -o1) would be used by xscope which would run as
  832. X     display 4 (1 for -d1 plus 3 for -o3).  Quite  mode  (verbose
  833. X     level 0).
  834. X
  835. XSEE ALSO
  836. X     X(1), X11 Protocol document (doc/Protocol/X11.protocol)
  837. X
  838. XAUTHOR
  839. X     James L. Peterson (MCC)
  840. X
  841. X     Copyright 1988, MCC
  842. X
  843. XBUGS
  844. X     Code has only been tested on Sun3's.
  845. X
  846. X
  847. X
  848. X
  849. X
  850. X
  851. X
  852. X
  853. X
  854. X
  855. X
  856. X
  857. X
  858. X
  859. XX Version 11        Last change: 8 Sept 1988                    2
  860. X
  861. X
  862. X
  863. $ CALL UNPACK XSCOPE.TXT;1 2016376814
  864. $ v=f$verify(v)
  865. $ EXIT
  866. --
  867. Patrick L. Mahan
  868.  
  869. --- TGV Window Washer ------------------------------- Mahan@TGV.COM ---------
  870.  
  871. Waking a person unnecessarily should not be considered  - Lazarus Long
  872. a capital crime.  For a first offense, that is            From the Notebooks of
  873.                               Lazarus Long
  874.  
  875.