home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume10 / xmon / patch3 next >
Encoding:
Internet Message Format  |  1990-12-07  |  31.2 KB

  1. Path: uunet!zaphod.mps.ohio-state.edu!usc!apple!sun-barr!newstop!exodus!appserv!otc.otca.oz.au
  2. From: gregm@otc.otca.oz.au (Greg McFarlane)
  3. Newsgroups: comp.sources.x
  4. Subject: v10i070: Xmon - X protocol monitor, Patch3, Part01/01
  5. Message-ID: <308@appserv.Eng.Sun.COM>
  6. Date: 16 Nov 90 05:28:11 GMT
  7. References: <csx-10i070:xmon@uunet.UU.NET>
  8. Sender: news@exodus.Eng.Sun.COM
  9. Lines: 1071
  10. Approved: argv@sun.com
  11.  
  12. Submitted-by: Greg McFarlane <gregm@otc.otca.oz.au>
  13. Posting-number: Volume 10, Issue 70
  14. Archive-name: xmon/patch3
  15. Patch-To: xmon: Volume 9, Issue 15-19, 30, 75
  16.  
  17. This patch brings xmon to patchlevel 3 and makes the following changes:
  18.  
  19. 1. The number of bytes in each network protocol packet can be displayed.
  20. 2. Can initialize xmond from a setup file. (Useful for testing clients.)
  21. 3. Synthetic events are monitored correctly.
  22. 4. The default server is taken from the DISPLAY environment variable.
  23. 5. Don't need to use -Bstatic compiler flag on Suns.
  24. 6. Xmond doesn't need to link to Xt or Xaw libraries.
  25. 7. Will now compile on Sony's RISC based 3710 system under SVR4.
  26. 8. Manual page updated to reflect above changes.
  27.  
  28. First unshar this posting, then run it through patch.
  29. You must be up to patchlevel 2.
  30.  
  31. ---- Cut Here and unpack ----
  32. #!/bin/sh
  33. # This is xmon.patch3, a shell archive (shar 3.32)
  34. # made 11/13/1990 02:39 UTC by gregm@otc.otca.oz.au
  35. # Source directory /u/projects/multi/xmux/xmon/patches
  36. #
  37. # existing files will NOT be overwritten
  38. #
  39. # This shar contains:
  40. # length  mode       name
  41. # ------ ---------- ------------------------------------------
  42. #  28460 -rw-rw-r-- xmon.patch3
  43. #
  44. if touch 2>&1 | fgrep 'amc' > /dev/null
  45.  then TOUCH=touch
  46.  else TOUCH=true
  47. fi
  48. # ============= xmon.patch3 ==============
  49. if test X"$1" != X"-c" -a -f 'xmon.patch3'; then
  50.     echo "File already exists: skipping 'xmon.patch3'"
  51. else
  52. echo "x - extracting xmon.patch3 (Text)"
  53. sed 's/^X//' << 'SHAR_EOF' > xmon.patch3 &&
  54. Xdiff -c version2/CHANGES version3/CHANGES
  55. X*** version2/CHANGES    Tue Nov 13 13:32:01 1990
  56. X--- version3/CHANGES    Tue Nov 13 13:32:50 1990
  57. X***************
  58. X*** 0 ****
  59. X--- 1,13 ----
  60. X+ xmon patch 3
  61. X+ 
  62. X+ This patch brings xmon to patchlevel 3 and makes the following changes:
  63. X+ 
  64. X+ 1. The number of bytes in each network protocol packet can be displayed.
  65. X+ 2. Can initialize xmond from a setup file. (Useful for testing clients.)
  66. X+ 3. Synthetic events are monitored correctly.
  67. X+ 4. The default server is taken from the DISPLAY environment variable.
  68. X+ 5. Don't need to use -Bstatic compiler flag on Suns.
  69. X+ 6. Xmond doesn't need to link to Xt or Xaw libraries.
  70. X+ 7. Will now compile on Sony's RISC based 3710 system under SVR4.
  71. X+ 8. Manual page updated to reflect above changes.
  72. X+ 
  73. Xdiff -c version2/patchlevel.h version3/patchlevel.h
  74. X*** version2/patchlevel.h    Thu Sep 27 17:03:30 1990
  75. X--- version3/patchlevel.h    Fri Nov  2 15:21:18 1990
  76. X***************
  77. X*** 1 ****
  78. X! #define PATCHLEVEL 2
  79. X--- 1 ----
  80. X! #define PATCHLEVEL 3
  81. Xdiff -c version2/Imakefile version3/Imakefile
  82. X*** version2/Imakefile    Thu Sep 27 16:44:45 1990
  83. X--- version3/Imakefile    Fri Oct 12 19:35:05 1990
  84. X***************
  85. X*** 1,4 ****
  86. X! LOCAL_LIBRARIES = -Bstatic -lXaw -lXmu -lXt -lXext -lX11
  87. X  CDEBUGFLAGS = -g
  88. X  
  89. X  SRCS1 = decode11.c linkl.c print11.c server.c fd.c main.c prtype.c table11.c
  90. X--- 1,6 ----
  91. X! LOCAL_LIBRARIES1 = -lXmu -lXext -lX11
  92. X! LOCAL_LIBRARIES2 = -lXaw -lXmu -lXt -lXext -lX11
  93. X! 
  94. X  CDEBUGFLAGS = -g
  95. X  
  96. X  SRCS1 = decode11.c linkl.c print11.c server.c fd.c main.c prtype.c table11.c
  97. X***************
  98. X*** 12,19 ****
  99. X  
  100. X  PROGRAMS = xmond xmonui
  101. X  
  102. X! ComplexProgramTarget_1(xmond, $(LOCAL_LIBRARIES), )
  103. X! ComplexProgramTarget_2(xmonui, $(LOCAL_LIBRARIES), )
  104. X  
  105. X  SHARFILES = README xmon.man Imakefile Makefile $(SRCS1) $(SRCS2) \
  106. X  $(INCLUDE_FILES)
  107. X--- 14,21 ----
  108. X  
  109. X  PROGRAMS = xmond xmonui
  110. X  
  111. X! ComplexProgramTarget_1(xmond, $(LOCAL_LIBRARIES1), )
  112. X! ComplexProgramTarget_2(xmonui, $(LOCAL_LIBRARIES2), )
  113. X  
  114. X  SHARFILES = README xmon.man Imakefile Makefile $(SRCS1) $(SRCS2) \
  115. X  $(INCLUDE_FILES)
  116. Xdiff -c version2/README version3/README
  117. X*** version2/README    Thu Sep 27 16:44:46 1990
  118. X--- version3/README    Fri Nov  2 15:37:47 1990
  119. X***************
  120. X*** 8,17 ****
  121. X      make Makefile
  122. X  If you don't have imake, then good luck with modifing the Makefile.
  123. X  
  124. X! You may want to delete the -Bstatic flag from the Imakefile (or Makefile
  125. X! if you are not using imake). I need it to get around the infamous
  126. X!     ld.so: Undefined symbol: __XtInherit
  127. X! error with shared libraries on Suns.
  128. X  
  129. X  When you have finished the Makefile, type
  130. X      make
  131. X--- 8,15 ----
  132. X      make Makefile
  133. X  If you don't have imake, then good luck with modifing the Makefile.
  134. X  
  135. X! If you have system five unices, define the appropriate ones of these:
  136. X!     -DSYSV -DSVR4
  137. X  
  138. X  When you have finished the Makefile, type
  139. X      make
  140. X***************
  141. X*** 19,24 ****
  142. X--- 17,26 ----
  143. X  
  144. X  Run xmon with the command
  145. X      xmonui | xmond
  146. X+ 
  147. X+ PS: The source files have tab stops set to 4 characters. If you are using
  148. X+ vi to look at the code use this to set the tab stops:
  149. X+     : set tabstop=4
  150. X  
  151. X  Please send any reports to
  152. X      gregm@otc.otca.oz.au
  153. Xdiff -c version2/decode11.c version3/decode11.c
  154. X*** version2/decode11.c    Fri Oct 12 18:49:03 1990
  155. X--- version3/decode11.c    Fri Oct 12 19:28:32 1990
  156. X***************
  157. X*** 996,1043 ****
  158. X  }
  159. X  
  160. X  Global void
  161. X! DecodeEvent(server, buf, n)
  162. X      Server                    *server;
  163. X      unsigned char            *buf;
  164. X      long                    n;
  165. X  {
  166. X-     int                        fd = server->fdd->fd;
  167. X      short                    Event = IByte (&buf[0]) & 0x7f;
  168. X  
  169. X!     if (CountEvents)
  170. X      {
  171. X!         if (Event < 0 || Event >= MAX_EVENT)
  172. X!             fprintf(stdout, "####### Illegal event opcode %d\n", Event);
  173. X!         else
  174. X!             EventCount[Event]++;
  175. X!     }
  176. X  
  177. X!     if 
  178. X!     (
  179. X!         BlockingEvents
  180. X!         &&
  181. X!         2 <= Event && Event <= 34
  182. X!         &&
  183. X!         BlockEvent[Event]
  184. X!     )
  185. X!         ignore_bytes = True;
  186. X  
  187. X!     if 
  188. X!     (
  189. X!         MonitoringEvents
  190. X!         &&
  191. X!         2 <= Event && Event <= 34
  192. X!         &&
  193. X!         VerboseEvent[Event]
  194. X!     )
  195. X!         CurrentVerbose = SelectedEventVerbose;
  196. X!     else
  197. X!         CurrentVerbose = EventVerbose;
  198. X!     if (CurrentVerbose <= 0)
  199. X!         return;
  200. X!     SetIndentLevel(PRINTSERVER);
  201. X!     if (CurrentVerbose > 3)
  202. X!         DumpItem("Event", fd, buf, n);
  203. X      if (Event < 2 || Event > 34)
  204. X          fprintf(stdout, "####### Extended Event opcode %d\n", Event);
  205. X      else
  206. X--- 996,1046 ----
  207. X  }
  208. X  
  209. X  Global void
  210. X! DecodeEvent(server, buf, n, real_event)
  211. X      Server                    *server;
  212. X      unsigned char            *buf;
  213. X      long                    n;
  214. X+     Bool                    real_event;
  215. X  {
  216. X      short                    Event = IByte (&buf[0]) & 0x7f;
  217. X  
  218. X!     if (real_event)
  219. X      {
  220. X!         if (CountEvents)
  221. X!         {
  222. X!             if (Event < 0 || Event >= MAX_EVENT)
  223. X!                 fprintf(stdout, "####### Illegal event opcode %d\n", Event);
  224. X!             else
  225. X!                 EventCount[Event]++;
  226. X!         }
  227. X  
  228. X!         if 
  229. X!         (
  230. X!             BlockingEvents
  231. X!             &&
  232. X!             2 <= Event && Event <= 34
  233. X!             &&
  234. X!             BlockEvent[Event]
  235. X!         )
  236. X!             ignore_bytes = True;
  237. X  
  238. X!         if 
  239. X!         (
  240. X!             MonitoringEvents
  241. X!             &&
  242. X!             2 <= Event && Event <= 34
  243. X!             &&
  244. X!             VerboseEvent[Event]
  245. X!         )
  246. X!             CurrentVerbose = SelectedEventVerbose;
  247. X!         else
  248. X!             CurrentVerbose = EventVerbose;
  249. X!         if (CurrentVerbose <= 0)
  250. X!             return;
  251. X!         SetIndentLevel(PRINTSERVER);
  252. X!         if (CurrentVerbose > 3)
  253. X!             DumpItem("Event", server->fdd->fd, buf, n);
  254. X!     }
  255. X      if (Event < 2 || Event > 34)
  256. X          fprintf(stdout, "####### Extended Event opcode %d\n", Event);
  257. X      else
  258. Xdiff -c version2/fd.c version3/fd.c
  259. X*** version2/fd.c    Thu Sep 27 16:44:46 1990
  260. X--- version3/fd.c    Thu Nov  1 18:53:52 1990
  261. X***************
  262. X*** 15,20 ****
  263. X--- 15,25 ----
  264. X  
  265. X  #include <errno.h>             /* for EINTR, EADDRINUSE, ... */
  266. X  
  267. X+ #ifdef SVR4
  268. X+ #include <sys/time.h>
  269. X+ #include <sys/resource.h>
  270. X+ #endif
  271. X+ 
  272. X  #include "common.h"
  273. X  
  274. X  #include "xmond.h"
  275. X***************
  276. X*** 35,44 ****
  277. X--- 40,61 ----
  278. X  {
  279. X      register short  i;
  280. X      short   MaxFD /* maximum number of FD's possible */ ;
  281. X+ #ifdef SVR4
  282. X+     struct rlimit rlp;
  283. X+ #endif
  284. X  
  285. X      enterprocedure("InitializeFD");
  286. X      /* get the number of file descriptors the system will let us use */
  287. X+ #ifdef SVR4
  288. X+     if (getrlimit(RLIMIT_NOFILE, &rlp) < 0)
  289. X+     {
  290. X+         perror("getrlimit(RLIMIT_NOFILE)");
  291. X+         exit(1);
  292. X+     }
  293. X+     MaxFD = rlp.rlim_cur;
  294. X+ #else
  295. X      MaxFD = getdtablesize();
  296. X+ #endif
  297. X  
  298. X      /* allocate space for a File Descriptor Table */
  299. X      FDD = (FDDescriptor *)malloc((long)(MaxFD * sizeof(FDDescriptor)));
  300. Xdiff -c version2/main.c version3/main.c
  301. X*** version2/main.c    Thu Sep 27 17:00:51 1990
  302. X--- version3/main.c    Wed Nov  7 11:02:33 1990
  303. X***************
  304. X*** 13,19 ****
  305. X--- 13,22 ----
  306. X  #include <sys/ioctl.h>         /* for FIONCLEX, FIONBIO, ... */
  307. X  #ifdef SYSV
  308. X  #include <sys/fcntl.h>
  309. X+ #ifndef FD_CLOEXEC
  310. X+ #define FD_CLOEXEC 1
  311. X  #endif
  312. X+ #endif
  313. X  #include <netinet/in.h>        /* struct sockaddr_in */
  314. X  #include <netdb.h>             /* struct servent * and struct hostent * */
  315. X  #include <errno.h>             /* for EINTR, EADDRINUSE, ... */
  316. X***************
  317. X*** 41,51 ****
  318. X  static short GetScopePort P((void ));
  319. X  static void Usage P((void ));
  320. X  static void ReadStdin P((Pointer private_data ));
  321. X  static void NewConnection P((Pointer private_data ));
  322. X  static void DataFromClient P((Pointer private_data ));
  323. X  static void DataFromServer P((Pointer private_data ));
  324. X  static Bool ReadAndProcessData P((Pointer private_data , FDDescriptor
  325. X! *read_fdd , FDDescriptor *write_fdd ));
  326. X  static void SaveBytes P((Buffer *buffer , char *buf , long n ));
  327. X  static void RemoveSavedBytes P((Buffer *buffer , int n ));
  328. X  static int ConnectToClient P((int ConnectionSocket ));
  329. X--- 44,55 ----
  330. X  static short GetScopePort P((void ));
  331. X  static void Usage P((void ));
  332. X  static void ReadStdin P((Pointer private_data ));
  333. X+ static void do_command P((char *ptr ));
  334. X  static void NewConnection P((Pointer private_data ));
  335. X  static void DataFromClient P((Pointer private_data ));
  336. X  static void DataFromServer P((Pointer private_data ));
  337. X  static Bool ReadAndProcessData P((Pointer private_data , FDDescriptor
  338. X! *read_fdd , FDDescriptor *write_fdd , Bool is_server ));
  339. X  static void SaveBytes P((Buffer *buffer , char *buf , long n ));
  340. X  static void RemoveSavedBytes P((Buffer *buffer , int n ));
  341. X  static int ConnectToClient P((int ConnectionSocket ));
  342. X***************
  343. X*** 63,68 ****
  344. X--- 67,74 ----
  345. X  static Bool ANYSET P((long *src));
  346. X  #endif
  347. X  
  348. X+ extern char *getenv();
  349. X+ 
  350. X  /* end function prototypes */
  351. X  
  352. X  Global Bool    ignore_bytes;
  353. X***************
  354. X*** 95,100 ****
  355. X--- 101,107 ----
  356. X  static long            ClientNumber = 0;
  357. X  static int                ServerPort = 0;
  358. X  static int                ListenForClientsPort = 1;
  359. X+ static Bool     ShowPacketSize = False;     /* show size of net packets? */
  360. X  
  361. X  Global void
  362. X  main(argc, argv)
  363. X***************
  364. X*** 159,164 ****
  365. X--- 166,172 ----
  366. X  {
  367. X      int i;
  368. X  
  369. X+     ServerHostName[0] = '\0';
  370. X      /* Scan argument list */
  371. X      for (i = 1; i < argc; i++)
  372. X          {
  373. X***************
  374. X*** 235,241 ****
  375. X      LocalHostName = (char *)malloc(255);
  376. X      (void) gethostname(LocalHostName, 255);
  377. X      if (ServerHostName[0] == '\0')
  378. X!         (void) gethostname(ServerHostName, sizeof (ServerHostName));
  379. X      if (Streq(ServerHostName,LocalHostName) && ListenForClientsPort ==
  380. X  ServerPort)
  381. X          {
  382. X--- 243,270 ----
  383. X      LocalHostName = (char *)malloc(255);
  384. X      (void) gethostname(LocalHostName, 255);
  385. X      if (ServerHostName[0] == '\0')
  386. X!     {
  387. X!         char *display_env_name;
  388. X! 
  389. X!         if ((display_env_name = getenv("DISPLAY")) == NULL)
  390. X!             (void) gethostname(ServerHostName, sizeof (ServerHostName));
  391. X!         else
  392. X!         {
  393. X!             char *index;
  394. X! 
  395. X!             strcpy(ServerHostName, display_env_name);
  396. X!             index = strchr(ServerHostName, ':');
  397. X!             if (index != NULL)
  398. X!             {
  399. X!                 *index = '\0';
  400. X!                 ServerPort = atoi(index + 1);
  401. X!                 if (ServerPort < 0)
  402. X!                     ServerPort = 0;
  403. X!             }
  404. X!             if (index == ServerHostName)
  405. X!                 (void) gethostname(ServerHostName, sizeof (ServerHostName));
  406. X!         }
  407. X!     }
  408. X      if (Streq(ServerHostName,LocalHostName) && ListenForClientsPort ==
  409. X  ServerPort)
  410. X          {
  411. X***************
  412. X*** 325,331 ****
  413. X--- 354,362 ----
  414. X  #else
  415. X      ioctl(ConnectionSocket, FIOCLEX, 0);
  416. X  #endif
  417. X+ #ifndef SVR4
  418. X      ioctl(ConnectionSocket, FIONBIO, &ON);
  419. X+ #endif
  420. X  
  421. X      debug(4,(stderr, "Listening on FD %d\n", ConnectionSocket));
  422. X      (void)UsingFD(ConnectionSocket, NewConnection, (Pointer)ConnectionSocket);
  423. X***************
  424. X*** 372,379 ****
  425. X          (
  426. X              HighestFD + 1, (fd_set *)rfds, (fd_set *)wfds, (fd_set *)xfds, NULL
  427. X          );
  428. X-         if (ANYSET(xfds))
  429. X-             panic("MainLoop: error in select");
  430. X          if (nfds <= 0)
  431. X          {
  432. X              if (errno != EINTR)
  433. X--- 403,408 ----
  434. X***************
  435. X*** 401,406 ****
  436. X--- 430,446 ----
  437. X                          panic("help: which connection do we shut down (TODO?");
  438. X                  }
  439. X              }
  440. X+             for (fd = 0; ANYSET(xfds) && fd <= HighestFD; fd++)
  441. X+             {
  442. X+                 if (GETBIT(xfds, fd))
  443. X+                 {
  444. X+                     BITCLEAR(xfds, fd);
  445. X+                     if (fd == fileno(stdin))
  446. X+                         NotUsingFD(fd);
  447. X+                     else
  448. X+                         fprintf(stderr, "error in select: fd is %d\n", fd);
  449. X+                 }
  450. X+             }
  451. X          }
  452. X          client_list.current = client_list.top;
  453. X          while (client_list.current != (LinkLeaf *)(&client_list))
  454. X***************
  455. X*** 538,576 ****
  456. X  #define REQUEST_BLOCKING_OFF_STR            "request_blocking_off"
  457. X  #define EVENT_BLOCKING_ON_STR                "event_blocking_on"
  458. X  #define EVENT_BLOCKING_OFF_STR                "event_blocking_off"
  459. X  #define QUIT_STR                            "quit"
  460. X  #define HELP_STR                            "help"
  461. X  
  462. X  #define Strleneq(a,b) Strneq(a, b, strlen(b))
  463. X  
  464. X  static void
  465. X  ReadStdin(private_data)
  466. X      Pointer                private_data;
  467. X  {
  468. X      int                    fd = (int)private_data;
  469. X!     char                buf[2048];
  470. X      char                *ptr;
  471. X      int                    n;
  472. X  
  473. X      enterprocedure("ReadStdin");
  474. X      n = read(fd, buf, 2048);
  475. X-     if (n == 0)
  476. X-     {
  477. X-         fprintf(stdout, "EOF on stdin\n");
  478. X-         exit(0);
  479. X-     }
  480. X      if (n < 0)
  481. X      {
  482. X          fprintf(stdout, "Error reading stdin\n");
  483. X!         exit(0);
  484. X      }
  485. X! 
  486. X!     buf[n] = '\0';
  487. X      ptr = buf;
  488. X!     while (*ptr == ' ' || *ptr == '\t')
  489. X!         ptr++;
  490. X!     if (*ptr != '\0')
  491. X      {
  492. X          if (Strleneq(ptr, REQUEST_VERBOSE_STR))
  493. X              RequestVerbose = atoi(ptr + strlen(REQUEST_VERBOSE_STR));
  494. X          else if (Strleneq(ptr, EVENT_VERBOSE_STR))
  495. X--- 578,654 ----
  496. X  #define REQUEST_BLOCKING_OFF_STR            "request_blocking_off"
  497. X  #define EVENT_BLOCKING_ON_STR                "event_blocking_on"
  498. X  #define EVENT_BLOCKING_OFF_STR                "event_blocking_off"
  499. X+ #define SHOW_PACKET_SIZE_ON_STR                "show_packet_size_on"
  500. X+ #define SHOW_PACKET_SIZE_OFF_STR            "show_packet_size_off"
  501. X  #define QUIT_STR                            "quit"
  502. X  #define HELP_STR                            "help"
  503. X  
  504. X  #define Strleneq(a,b) Strneq(a, b, strlen(b))
  505. X  
  506. X+ char                save_buf[2048];
  507. X+ int                    saved_bytes = 0;
  508. X+ 
  509. X  static void
  510. X  ReadStdin(private_data)
  511. X      Pointer                private_data;
  512. X  {
  513. X      int                    fd = (int)private_data;
  514. X!     char                buf[4096];
  515. X      char                *ptr;
  516. X+     char                *end_ptr;
  517. X      int                    n;
  518. X+     int                    endn;
  519. X  
  520. X      enterprocedure("ReadStdin");
  521. X      n = read(fd, buf, 2048);
  522. X      if (n < 0)
  523. X      {
  524. X          fprintf(stdout, "Error reading stdin\n");
  525. X!         return;
  526. X      }
  527. X!     if (n + saved_bytes == 0)
  528. X!         return;
  529. X!     if (saved_bytes > 0)
  530. X!     {
  531. X!         bcopy(buf, buf + saved_bytes, n);
  532. X!         bcopy(save_buf, buf, saved_bytes);
  533. X!         n += saved_bytes;
  534. X!         saved_bytes = 0;
  535. X!     }
  536. X      ptr = buf;
  537. X!     while(n > 0)
  538. X      {
  539. X+         while (n > 0 && (*ptr == ' ' || *ptr == '\t'))
  540. X+         {
  541. X+             ptr++;
  542. X+             n--;
  543. X+         }
  544. X+         if (n <= 0)
  545. X+             break;
  546. X+         end_ptr = ptr;
  547. X+         endn = n;
  548. X+         while(endn > 0 && *end_ptr != '\n')
  549. X+         {
  550. X+             end_ptr++;
  551. X+             endn--;
  552. X+         }
  553. X+         if (endn <= 0)
  554. X+         {
  555. X+             bcopy(ptr, save_buf, n);
  556. X+             saved_bytes = n;
  557. X+             break;
  558. X+         }
  559. X+         *end_ptr = '\0';
  560. X+         do_command(ptr);
  561. X+         ptr = end_ptr + 1;
  562. X+         n = endn - 1;
  563. X+     }
  564. X+ }
  565. X+ 
  566. X+ static void
  567. X+ do_command(ptr)
  568. X+     char                *ptr;
  569. X+ {
  570. X          if (Strleneq(ptr, REQUEST_VERBOSE_STR))
  571. X              RequestVerbose = atoi(ptr + strlen(REQUEST_VERBOSE_STR));
  572. X          else if (Strleneq(ptr, EVENT_VERBOSE_STR))
  573. X***************
  574. X*** 603,608 ****
  575. X--- 681,690 ----
  576. X              BlockingEvents = True;
  577. X          else if (Strleneq(ptr, EVENT_BLOCKING_OFF_STR))
  578. X              BlockingEvents = False;
  579. X+         else if (Strleneq(ptr, SHOW_PACKET_SIZE_ON_STR))
  580. X+             ShowPacketSize = True;
  581. X+         else if (Strleneq(ptr, SHOW_PACKET_SIZE_OFF_STR))
  582. X+             ShowPacketSize = False;
  583. X          else if (Strleneq(ptr, SELECTED_REQUEST_VERBOSE_STR))
  584. X              SelectedRequestVerbose =
  585. X                  atoi(ptr +strlen(SELECTED_REQUEST_VERBOSE_STR));
  586. X***************
  587. X*** 695,701 ****
  588. X              (
  589. X                  stdout, "illegal command: %s\n\"help\" to get help\n", ptr
  590. X              );
  591. X-     }
  592. X  }
  593. X  
  594. X  /*
  595. X--- 777,782 ----
  596. X***************
  597. X*** 740,746 ****
  598. X      Server                    *server;
  599. X  
  600. X      server = (Server *)(TopOfList(&client->server_list));
  601. X!     if (!ReadAndProcessData(private_data, client->fdd, server->fdd))
  602. X          CloseConnection(client);
  603. X  }
  604. X  
  605. X--- 821,827 ----
  606. X      Server                    *server;
  607. X  
  608. X      server = (Server *)(TopOfList(&client->server_list));
  609. X!     if (!ReadAndProcessData(private_data, client->fdd, server->fdd, False))
  610. X          CloseConnection(client);
  611. X  }
  612. X  
  613. X***************
  614. X*** 751,757 ****
  615. X      Server                    *server = (Server *)private_data;
  616. X      Client                    *client = server->client;
  617. X  
  618. X!     if (!ReadAndProcessData(private_data, server->fdd, client->fdd))
  619. X          CloseConnection(client);
  620. X  }
  621. X  
  622. X--- 832,838 ----
  623. X      Server                    *server = (Server *)private_data;
  624. X      Client                    *client = server->client;
  625. X  
  626. X!     if (!ReadAndProcessData(private_data, server->fdd, client->fdd, True))
  627. X          CloseConnection(client);
  628. X  }
  629. X  
  630. X***************
  631. X*** 801,815 ****
  632. X   */
  633. X  
  634. X  static Bool
  635. X! ReadAndProcessData(private_data, read_fdd, write_fdd)
  636. X      Pointer                    private_data;
  637. X      FDDescriptor            *read_fdd;
  638. X      FDDescriptor            *write_fdd;
  639. X  {
  640. X      Buffer                    *inbuffer = &read_fdd->inBuffer;
  641. X      Buffer                    *outbuffer = &write_fdd->outBuffer;
  642. X      int                        fd = read_fdd->fd;
  643. X!     char                    read_buf_block[2048];
  644. X      char                    *read_buf = read_buf_block;
  645. X      int                        num_read;
  646. X      char                    *process_buf;
  647. X--- 882,897 ----
  648. X   */
  649. X  
  650. X  static Bool
  651. X! ReadAndProcessData(private_data, read_fdd, write_fdd, is_server)
  652. X      Pointer                    private_data;
  653. X      FDDescriptor            *read_fdd;
  654. X      FDDescriptor            *write_fdd;
  655. X+     Bool                    is_server;
  656. X  {
  657. X      Buffer                    *inbuffer = &read_fdd->inBuffer;
  658. X      Buffer                    *outbuffer = &write_fdd->outBuffer;
  659. X      int                        fd = read_fdd->fd;
  660. X!     char                    read_buf_block[16384];
  661. X      char                    *read_buf = read_buf_block;
  662. X      int                        num_read;
  663. X      char                    *process_buf;
  664. X***************
  665. X*** 816,822 ****
  666. X      int                        NumberofUsedBytes;
  667. X      int                        BytesToSave;
  668. X  
  669. X!     num_read = read(fd, read_buf, 2048);
  670. X      if (num_read < 0)
  671. X      {
  672. X          perror("read error");
  673. X--- 898,916 ----
  674. X      int                        NumberofUsedBytes;
  675. X      int                        BytesToSave;
  676. X  
  677. X!     num_read = read(fd, read_buf, 16384);
  678. X!     if (ShowPacketSize)
  679. X!     {
  680. X!         if (is_server)
  681. X!             fprintf(stdout, "\t\t\t\t\t");
  682. X!         else
  683. X!             fprintf(stdout, "Client %d --> ", read_fdd->fd);
  684. X!         fprintf(stdout, "%4d byte%s", num_read, (num_read == 1) ? "" : "s");
  685. X!         if (is_server)
  686. X!             fprintf(stdout, "<-- Server %d\n", read_fdd->fd);
  687. X!         else
  688. X!             fprintf(stdout, "\n");
  689. X!     }
  690. X      if (num_read < 0)
  691. X      {
  692. X          perror("read error");
  693. X***************
  694. X*** 950,956 ****
  695. X--- 1044,1052 ----
  696. X  #else
  697. X      ioctl(ClientFD, FIOCLEX, 0);
  698. X  #endif
  699. X+ #ifndef SVR4
  700. X      ioctl(ClientFD, FIONBIO, &ON);
  701. X+ #endif
  702. X      return(ClientFD);
  703. X  }
  704. X  
  705. Xdiff -c version2/prtype.c version3/prtype.c
  706. X*** version2/prtype.c    Thu Sep 27 16:44:52 1990
  707. X--- version3/prtype.c    Fri Oct 12 19:28:48 1990
  708. X***************
  709. X*** 581,588 ****
  710. X          unsigned char *buf;
  711. X  {
  712. X      /* print an EVENT_FORM -- event format */
  713. X!     fprintf(stdout, "PrintEVENTFORM: calling DecodeEvent with NULL server!\n");
  714. X!     DecodeEvent((Server *)NULL, buf, (long)-1);
  715. X  }
  716. X  
  717. X  Global void
  718. X--- 581,587 ----
  719. X          unsigned char *buf;
  720. X  {
  721. X      /* print an EVENT_FORM -- event format */
  722. X!     DecodeEvent((Server *)NULL, buf, (long)-1, False);
  723. X  }
  724. X  
  725. X  Global void
  726. Xdiff -c version2/server.c version3/server.c
  727. X*** version2/server.c    Thu Sep 27 17:36:46 1990
  728. X--- version3/server.c    Fri Oct 12 19:28:57 1990
  729. X***************
  730. X*** 312,318 ****
  731. X      unsigned char            *buf;
  732. X      long                    n;
  733. X  {
  734. X!     DecodeEvent(server, buf, n);
  735. X      server->fdd->ByteProcessing = ServerPacket;
  736. X      server->fdd->inBuffer.num_Needed = 32;
  737. X      return(n);
  738. X--- 312,318 ----
  739. X      unsigned char            *buf;
  740. X      long                    n;
  741. X  {
  742. X!     DecodeEvent(server, buf, n, True);
  743. X      server->fdd->ByteProcessing = ServerPacket;
  744. X      server->fdd->inBuffer.num_Needed = 32;
  745. X      return(n);
  746. Xdiff -c version2/widgeti.c version3/widgeti.c
  747. X*** version2/widgeti.c    Thu Sep 27 16:44:53 1990
  748. X--- version3/widgeti.c    Thu Nov  1 18:57:22 1990
  749. X***************
  750. X*** 4,10 ****
  751. X--- 4,14 ----
  752. X   *  Description: Routines to build various widget combinations
  753. X   */
  754. X  #include    <stdio.h>
  755. X+ #ifdef SVR4
  756. X+ #include    <string.h>
  757. X+ #else
  758. X  #include    <strings.h>
  759. X+ #endif
  760. X  #include    <X11/cursorfont.h>
  761. X  #include    <X11/Intrinsic.h>
  762. X  #include    <X11/StringDefs.h>
  763. Xdiff -c version2/xmon.man version3/xmon.man
  764. X*** version2/xmon.man    Thu Sep 27 16:44:53 1990
  765. X--- version3/xmon.man    Fri Nov  2 15:13:49 1990
  766. X***************
  767. X*** 1,4 ****
  768. X! .TH xmon 1 "September, 1990" "X Version 11"
  769. X  .SH NAME
  770. X  xmon \- interactive X protocol monitor
  771. X  .SH SYNOPSIS
  772. X--- 1,4 ----
  773. X! .TH xmon 1 "November, 1990" "X Version 11"
  774. X  .SH NAME
  775. X  xmon \- interactive X protocol monitor
  776. X  .SH SYNOPSIS
  777. X***************
  778. X*** 54,60 ****
  779. X  
  780. X  .PP
  781. X  In the diagram the vertical connections are pipes and the horizontal
  782. X! connections are normal X connections.
  783. X  .PP
  784. X  Xmond sits transparently between the X clients and an X server.
  785. X  To the clients it behaves just like an X server and to the server
  786. X--- 54,60 ----
  787. X  
  788. X  .PP
  789. X  In the diagram the vertical connections are pipes and the horizontal
  790. X! connections are normal X socket connections.
  791. X  .PP
  792. X  Xmond sits transparently between the X clients and an X server.
  793. X  To the clients it behaves just like an X server and to the server
  794. X***************
  795. X*** 63,70 ****
  796. X  .TP
  797. X  .B "-server \fIdisplay_name\fP:\fIdisplay_number\fP"
  798. X  This option sets the X display which xmond connects to.
  799. X! Default for \fIdisplay_name\fP is the local host.
  800. X! Default for \fIdisplay_number\fP is 0.
  801. X  .TP
  802. X  .B "-port \fIdisplay_number\fP"
  803. X  This option sets the 
  804. X--- 63,72 ----
  805. X  .TP
  806. X  .B "-server \fIdisplay_name\fP:\fIdisplay_number\fP"
  807. X  This option sets the X display which xmond connects to.
  808. X! The default for both values is the value of the DISPLAY environment
  809. X! variable. If this is not set, then the
  810. X! default for \fIdisplay_name\fP is the local host and the
  811. X! default for \fIdisplay_number\fP is 0.
  812. X  .TP
  813. X  .B "-port \fIdisplay_number\fP"
  814. X  This option sets the 
  815. X***************
  816. X*** 88,93 ****
  817. X--- 90,123 ----
  818. X  The xmonui user interface will
  819. X  appear on the display \fIlocalhost:0\fP.
  820. X  .PP
  821. X+ When starting up the application that you want to monitor, be sure to set
  822. X+ it's display correctly.
  823. X+ When you normally start up an X application, and if
  824. X+ you have not done anything special, it
  825. X+ will by default start up on display 0 of your local host.
  826. X+ But xmon by default
  827. X+ is listening as if it is display 1 of your local host. Assuming your X
  828. X+ application
  829. X+ is called "myclient" and your local host name is "dolphin" then type the
  830. X+ following to start up your application:
  831. X+ 
  832. X+ myclient -display dolphin:1
  833. X+ 
  834. X+ Another way to do the same thing is to change the DISPLAY environment
  835. X+ variable. If you are using a C shell you can do this:
  836. X+ 
  837. X+ setenv DISPLAY dolphin:1
  838. X+ .br
  839. X+ myclient
  840. X+ 
  841. X+ If you are not using a C shell, you may have to do something
  842. X+ different to change the DISPLAY environment variable.
  843. X+ Also, most clients understand the -display option, but there are those
  844. X+ that do not.
  845. X+ To determine the name of your local host try
  846. X+ the \fIhostname\fP command (although it may not be available
  847. X+ on all machines).
  848. X+ .PP
  849. X  2) If you are on the host \fIsquiggle\fP which has two X servers using
  850. X  the displays \fIsquiggle:0\fP and \fIsquiggle:1\fP, and want to monitor
  851. X  connections made to the server running on the display
  852. X***************
  853. X*** 127,132 ****
  854. X--- 157,174 ----
  855. X  .I hex
  856. X  All fields of the message are output, as well as a hexadecimal dump.
  857. X  .PP
  858. X+ Note that synthetic events (events sent by XSendEvent) are 
  859. X+ monitored in the same way as normal events but are identified as
  860. X+ being "SYNTHETIC".
  861. X+ .PP
  862. X+ Also in this section is the \fIshow packet size\fP toggle. If this is
  863. X+ turned \fIon\fP, xmon will display the size of each packet received from
  864. X+ both clients and servers. The file descriptor of the client or server
  865. X+ which sent the packet is also displayed. The first client file
  866. X+ descriptor is 4. File descriptors 0, 1 and 2 are used by standard
  867. X+ input, standard output and standard error and file descriptor 3 is where
  868. X+ xmon listens for new connections.
  869. X+ .PP
  870. X  In the \fIstatistics\fP section, the counting of requests, events and
  871. X  errors can be controlled as follows.
  872. X  .TP
  873. X***************
  874. X*** 166,176 ****
  875. X  .PP
  876. X  The \fIselected events\fP section is similar to the above section but
  877. X  deals with events received from the server.
  878. X! .SH BUGS
  879. X! Tested only on Sun3 machines. Byte swapping may produce problems on other
  880. X! machines.
  881. X  .PP
  882. X  No provision is included for extensions to the base protocol.
  883. X  .SH SEE ALSO
  884. X  X(1)
  885. X  .PP
  886. X--- 208,278 ----
  887. X  .PP
  888. X  The \fIselected events\fP section is similar to the above section but
  889. X  deals with events received from the server.
  890. X! .SH USING XMOND WITHOUT XMONUI
  891. X! Normally xmonui is used as an interactive interface to xmond. However,
  892. X! for some testing procedures it may be better to run xmond by itself
  893. X! initialising it with some standard setup.
  894. X! The interface between xmonui and xmond is made up of simple ascii
  895. X! strings.
  896. X! Pressing buttons on xmonui causes it to write these strings to
  897. X! standard output which are then usually read by xmond.
  898. X! You can just run xmond by itself
  899. X! and type in the strings, or, even better, use a file as input to xmond.
  900. X! There are too many strings to list here, but
  901. X! if you run xmonui by itself, you will see the strings being printed to
  902. X! standard output.
  903. X! Run
  904. X! 
  905. X! xmonui > command.file
  906. X! 
  907. X! to create a file of strings that can be used as input to xmond.
  908. X! For example, a file which will cause xmond to monitor the Bell request
  909. X! and also print the names of all events would contain the lines:
  910. X! 
  911. X! monitor_request_on 104
  912. X! .br
  913. X! event_verbose 1
  914. X! 
  915. X! Running
  916. X! 
  917. X! xmond < command.file
  918. X! 
  919. X! will then set up xmond in the same way each time. Note that when
  920. X! running xmond by itself, it does not
  921. X! exit on reading end-of-file and so it must be killed. (I use
  922. X! CONTROL-C to kill.
  923. X! Your kill character may be different.)
  924. X  .PP
  925. X+ It is also possible to initialise xmond with a file, and then
  926. X+ take further commands from xmonui by running
  927. X+ 
  928. X+ xmonui | cat command.file - | xmond
  929. X+ 
  930. X+ The cat command first sends the command.file to xmond and then passes the
  931. X+ output of xmonui to xmond. Please note that in this case xmonui will not
  932. X+ show the new state of xmond correctly.
  933. X+ For example, xmonui starts up assuming that
  934. X+ no requests have been selected, even if the command.file has initialised
  935. X+ xmond by selecting some requests.
  936. X+ This inconsistency does not effect the usability of xmon
  937. X+ but may be confusing.
  938. X+ .PP
  939. X+ The string
  940. X+ 
  941. X+ quit
  942. X+ 
  943. X+ will cause xmond to exit, so make sure that this does not occur in
  944. X+ any input file. Also it is meaningless to use the statistics commands
  945. X+ from within an input file because these will be read before any X clients
  946. X+ have connected.
  947. X+ .SH BUGS
  948. X  No provision is included for extensions to the base protocol.
  949. X+ .PP
  950. X+ Xmon only handles TCP socket connections.
  951. X+ UNIX domain sockets and DECnet are not supported.
  952. X+ .PP
  953. X+ There should be a better way of initialising the state of xmond and having
  954. X+ this new state reflected in xmonui.
  955. X  .SH SEE ALSO
  956. X  X(1)
  957. X  .PP
  958. Xdiff -c version2/xmond.h version3/xmond.h
  959. X*** version2/xmond.h    Thu Sep 27 16:44:54 1990
  960. X--- version3/xmond.h    Mon Nov  5 13:13:41 1990
  961. X***************
  962. X*** 98,103 ****
  963. X  Global void DecodeReply P((Server *server , unsigned char *buf , long n ));
  964. X  Global void DecodeError P((Server *server , unsigned char *buf , long n ));
  965. X! Global void DecodeEvent P((Server *server , unsigned char *buf , long n ));
  966. X  Global void KeepLastReplyExpected P((void ));
  967. X  /* print11.c: */
  968. X  Global void PrintSetUpMessage P((unsigned char *buf ));
  969. X--- 98,104 ----
  970. X  Global void DecodeReply P((Server *server , unsigned char *buf , long n ));
  971. X  Global void DecodeError P((Server *server , unsigned char *buf , long n ));
  972. X! Global void DecodeEvent P((Server *server , unsigned char *buf , long n ,
  973. X! Bool real_event ));
  974. X  Global void KeepLastReplyExpected P((void ));
  975. X  /* print11.c: */
  976. X  Global void PrintSetUpMessage P((unsigned char *buf ));
  977. Xdiff -c version2/xmonui.c version3/xmonui.c
  978. X*** version2/xmonui.c    Thu Sep 27 16:44:54 1990
  979. X--- version3/xmonui.c    Fri Nov  2 14:09:18 1990
  980. X***************
  981. X*** 125,130 ****
  982. X--- 125,134 ----
  983. X          /*"0\n1\n2\n3\n4", "reply_verbose %s\n", "0"*/
  984. X      },
  985. X      {
  986. X+         "show packet size       ",
  987. X+         "off\non", "show_packet_size_%s\n", "off"
  988. X+     },
  989. X+     {
  990. X          "detail ",
  991. X          DETAIL_STR, "selected_request_verbose", "full"
  992. X          /*"0\n1\n2\n3\n4", "selected_request_verbose %s\n", "3"*/
  993. X***************
  994. X*** 136,153 ****
  995. X      },
  996. X      {
  997. X          " blocking ",
  998. X!         "on\noff", "request_blocking_%s\n", "on"
  999. X      },
  1000. X      {
  1001. X          " blocking ",
  1002. X!         "on\noff", "event_blocking_%s\n", "on"
  1003. X      },
  1004. X  };
  1005. X- #define REQUEST_VERBOSE            4
  1006. X- #define EVENT_VERBOSE            5
  1007. X- #define REQUEST_BLOCKING        6
  1008. X- #define EVENT_BLOCKING            7
  1009. X  
  1010. X  #define NUM_TOGGLES (sizeof(toggledata) / sizeof(ToggleData))
  1011. X  
  1012. X  typedef struct
  1013. X--- 140,159 ----
  1014. X      },
  1015. X      {
  1016. X          " blocking ",
  1017. X!         "off\non", "request_blocking_%s\n", "on"
  1018. X      },
  1019. X      {
  1020. X          " blocking ",
  1021. X!         "off\non", "event_blocking_%s\n", "on"
  1022. X      },
  1023. X  };
  1024. X  
  1025. X+ #define NUM_FIRST_TOGGLES        5
  1026. X+ #define REQUEST_VERBOSE            5
  1027. X+ #define EVENT_VERBOSE            6
  1028. X+ #define REQUEST_BLOCKING        7
  1029. X+ #define EVENT_BLOCKING            8
  1030. X+ 
  1031. X  #define NUM_TOGGLES (sizeof(toggledata) / sizeof(ToggleData))
  1032. X  
  1033. X  typedef struct
  1034. X***************
  1035. X*** 213,219 ****
  1036. X      for (toggle_count = 0; toggle_count < NUM_TOGGLES; toggle_count++)
  1037. X          if (toggledata[toggle_count].widget == XtParent(widget))
  1038. X          {
  1039. X!             if (toggle_count < 6)
  1040. X              {
  1041. X                  printf(toggledata[toggle_count].output_string);
  1042. X                  if (Streq((char*) client_data, "off"))
  1043. X--- 219,225 ----
  1044. X      for (toggle_count = 0; toggle_count < NUM_TOGGLES; toggle_count++)
  1045. X          if (toggledata[toggle_count].widget == XtParent(widget))
  1046. X          {
  1047. X!             if (toggle_count < 4 || toggle_count == 5 || toggle_count == 6)
  1048. X              {
  1049. X                  printf(toggledata[toggle_count].output_string);
  1050. X                  if (Streq((char*) client_data, "off"))
  1051. X***************
  1052. X*** 415,421 ****
  1053. X  
  1054. X  
  1055. X  /* verbose level toggles */
  1056. X!     for (toggle_count = 0; toggle_count < 4; toggle_count++)
  1057. X          widget = build_toggle(form, toggle_count, widget);
  1058. X  
  1059. X  /* counting buttons */
  1060. X--- 421,427 ----
  1061. X  
  1062. X  
  1063. X  /* verbose level toggles */
  1064. X!     for (toggle_count = 0; toggle_count < NUM_FIRST_TOGGLES; toggle_count++)
  1065. X          widget = build_toggle(form, toggle_count, widget);
  1066. X  
  1067. X  /* counting buttons */
  1068. SHAR_EOF
  1069. $TOUCH -am 1113133890 xmon.patch3 &&
  1070. chmod 0664 xmon.patch3 ||
  1071. echo "restore of xmon.patch3 failed"
  1072. set `wc -c xmon.patch3`;Wc_c=$1
  1073. if test "$Wc_c" != "28460"; then
  1074.     echo original size 28460, current size $Wc_c
  1075. fi
  1076. fi
  1077. exit 0
  1078.  
  1079. dan
  1080. ----------------------------------------------------
  1081. O'Reilly && Associates   argv@sun.com / argv@ora.com
  1082. Opinions expressed reflect those of the author only.
  1083. --
  1084. dan
  1085. ----------------------------------------------------
  1086. O'Reilly && Associates   argv@sun.com / argv@ora.com
  1087. Opinions expressed reflect those of the author only.
  1088.