home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sources / misc / 4122 < prev    next >
Encoding:
Text File  |  1992-11-21  |  35.1 KB  |  1,396 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
  4. Subject:  v33i117:  u386mon - SVR3 performance/status monitor v2.60, Part08/09
  5. Message-ID: <1992Nov22.020321.24475@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: 044d0d8b31c22ea69482612d167df009
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. References: <csm-v33i110=u386mon.195754@sparky.IMD.Sterling.COM>
  11. Date: Sun, 22 Nov 1992 02:03:21 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 1381
  14.  
  15. Submitted-by: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
  16. Posting-number: Volume 33, Issue 117
  17. Archive-name: u386mon/part08
  18. Environment: SYSVR3
  19. Supersedes: u386mon: Volume 22, Issue 3-9
  20.  
  21. #!/bin/sh
  22. # This is part 08 of u386mon.2.60
  23. # ============= siotools/README ==============
  24. if test ! -d 'siotools'; then
  25.     echo 'x - creating directory siotools'
  26.     mkdir 'siotools'
  27. fi
  28. if test -f 'siotools/README' -a X"$1" != X"-c"; then
  29.     echo 'x - skipping siotools/README (File already exists)'
  30. else
  31. echo 'x - extracting siotools/README (Text)'
  32. sed 's/^X//' << 'SHAR_EOF' > 'siotools/README' &&
  33. XSIOTOOLS IS TWO PROGRAMS
  34. X------------------------
  35. XSIOMON displays kernel tty structures in a dynamic fashion.
  36. XDetailed status may be displayed on a single tty.
  37. X
  38. XUUSNAP displays HDB UUCP connection status.  Detailed status may be
  39. Xdisplayed on a single connection if you have configured the code
  40. Xproperly.
  41. X
  42. XThese display hacks are self-documenting.  Just read the following
  43. Xand have fun.
  44. X
  45. XCONFIGURATION
  46. X-------------
  47. X
  48. XA great number of people worked with u386mon to arrive at its
  49. Xconfigurability.  This work has not been done with siotools.  As
  50. Xdelivered, u386mon and siotools support the SCO standard sio tty
  51. Xdriver.  Porting to other SVR3 systems and tty drivers may be as
  52. Xsimple as modifying one header file in the u386mon base directory
  53. X(ttynm.h).  Refer to the discussion in the u386mon README.
  54. X
  55. XThe code was once supported under XENIX.  With this revision's
  56. Xuse of nlsym, XENIX support is dropped.  The earlier comp.sources.misc
  57. Xversion works fine for XENIX:
  58. X
  59. Xv09i044   siotools/part01   siotools part 1/2
  60. Xv09i045   siotools/part02   siotools part 2/2
  61. Xv09i056   siotools/patch01  siotools v09i044 patch 1
  62. Xv09i058   siotools/patch02  siotools patch 2
  63. Xv09i086   siotools/patch03  siotools patch 3
  64. Xv10i049   siotools/patch04  siotools v09i044,045 patch 4
  65. Xv10i070   siotools/patch05  siotools v09i044/045 patch 5
  66. Xv10i076   siotools/patch06  siotools v09i044/45 patch 6
  67. Xv11i028   siotools.p7       siotools v09i044/045 patch 7
  68. X
  69. XMAKING & INSTALLING
  70. X-------------------
  71. XTo make: edit the Makefile to select the CFLAGS options
  72. Xappropriate for you.  Then 'make' or 'make all'.  As mentioned
  73. Xabove, this will not be adequate to get the programs working on
  74. Xyour non-SCO/non-sio UNIX system.
  75. X
  76. XTo install, edit LBIN in the Makefile to have your favorite local
  77. Xbin directory path, 'su root' and 'make install'.
  78. X
  79. XPorts (ttynm.h definitions), bug reports and suggestions are appreciated.
  80. X
  81. X--------------------------------------------------------------------
  82. XWarren Tucker, TuckerWare emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
  83. XHacker Extraordinaire  d' async PADs,  pods,  proteins and protocols
  84. SHAR_EOF
  85. chmod 0644 siotools/README ||
  86. echo 'restore of siotools/README failed'
  87. Wc_c="`wc -c < 'siotools/README'`"
  88. test 2084 -eq "$Wc_c" ||
  89.     echo 'siotools/README: original size 2084, current size' "$Wc_c"
  90. fi
  91. # ============= siotools/kmemsio.c ==============
  92. if test -f 'siotools/kmemsio.c' -a X"$1" != X"-c"; then
  93.     echo 'x - skipping siotools/kmemsio.c (File already exists)'
  94. else
  95. echo 'x - extracting siotools/kmemsio.c (Text)'
  96. sed 's/^X//' << 'SHAR_EOF' > 'siotools/kmemsio.c' &&
  97. X/* CHK=0xE646 */
  98. X/*+-------------------------------------------------------------------------
  99. X    kmemsio.c
  100. X    ...!gatech!emory!tridom!wht
  101. X
  102. X  Defined functions:
  103. X    kmem_init_tty()
  104. X    kmem_read_tty(ttfirst,ttcount)
  105. X
  106. X--------------------------------------------------------------------------*/
  107. X/*+:EDITS:*/
  108. X/*:07-15-1992-14:33-wht@n4hgf-2.60 release - u386mon+siotools merge */
  109. X/*:06-24-1992-20:19-wht@n4hgf-use nlsym in cahorts with u386mon */
  110. X/*:12-04-1989-16:05-wht-creation */
  111. X
  112. X#include <sys/types.h>
  113. X#include <sys/stat.h>
  114. X#define TERMIO_HACK /* for XENIX termio.h multiple inclusion problem */
  115. X#include <sys/tty.h>
  116. X
  117. X#include "kmemsio.h"
  118. X
  119. X#ifdef M_UNIX
  120. Xchar *kernel_file = "/unix";
  121. X
  122. X#include <nlist.h>
  123. X#define XLIST nlist
  124. X#define XL_name n_name
  125. X#define XL_value n_value
  126. X#define XL_type n_type
  127. X#else
  128. Xchar *kernel_file = "/xenix";
  129. X
  130. X#include <sys/a.out.h>
  131. X#define XLIST xlist
  132. X#define XL_name xl_name
  133. X#define XL_value xl_value
  134. X#define XL_type xl_type
  135. X#endif
  136. X
  137. X#ifdef STANDALONE_NLIST
  138. X#if defined(M_UNIX)
  139. Xstruct XLIST kernel_symbols[] = {
  140. X#define KS_SIO_TTY    0
  141. X    { "sio_tty" },
  142. X    { (char *)0 }
  143. X};
  144. X#else /* !M_UNIX */
  145. X
  146. Xstruct XLIST kernel_symbols[] = {
  147. X#define KS_SIO_TTY    0
  148. X    {0,0,0, "_sio_tty" },
  149. X    {0,0,0, (char *)0 }
  150. X};
  151. X#endif /* M_UNIX */
  152. X
  153. X#define    sio_ttyaddr kernel_symbols[KS_SIO_TTY].XL_value
  154. X
  155. X#else  /* !STANDALONE_NLIST */
  156. X#undef M_TERMINFO
  157. X#include "../config.h"
  158. X#ifndef M_TERMINFO
  159. Xa.kludge.did.not.work;
  160. X#endif
  161. X#include "../nlsym.h"
  162. X#include "../libnlsym.h"
  163. X#endif /* STANDALONE_NLIST */
  164. X
  165. Xchar *kmem_file = "/dev/kmem";
  166. X
  167. Xint kmemfd;
  168. X
  169. Xstruct tty sio[SIO_NTTY];
  170. X
  171. Xstatic char errmsg[80];
  172. X
  173. Xextern int errno;
  174. Xextern char *sys_errlist[];
  175. X
  176. X/*+-------------------------------------------------------------------------
  177. X    kmem_read_tty(ttfirst,ttcount)
  178. X--------------------------------------------------------------------------*/
  179. Xchar *
  180. Xkmem_read_tty(ttfirst,ttcount)
  181. Xint ttfirst;
  182. Xint ttcount;
  183. X{
  184. Xint len = ttcount * sizeof(struct tty);
  185. X
  186. X    if(((unsigned)ttfirst >= SIO_NTTY) ||
  187. X        (((unsigned)ttfirst + (unsigned)ttcount) > SIO_NTTY))
  188. X        return(" illegal tty ");
  189. X
  190. X    if(lseek(kmemfd,sio_ttyaddr + (ttfirst * sizeof(struct tty)),0) == -1)
  191. X    {
  192. X        sprintf(errmsg,
  193. X            " kmem lseek failure: %s ",sys_errlist[errno]);
  194. X        return(errmsg);
  195. X    }
  196. X    errno = 0;
  197. X    if(read(kmemfd,(char *)sio,len) != len)
  198. X    {
  199. X        sprintf(errmsg,
  200. X            " kmem read failure: %s ",sys_errlist[errno]);
  201. X        return(errmsg);
  202. X    }
  203. X
  204. X    return((char *)0);
  205. X
  206. X}    /* end of kmem_read_tty */
  207. X
  208. X/*+-------------------------------------------------------------------------
  209. X    kmem_init_tty()
  210. X--------------------------------------------------------------------------*/
  211. Xchar *
  212. Xkmem_init_tty()
  213. X{
  214. X    char sio_ttyname[64];
  215. X
  216. X    strncpy(sio_ttyname,nlsym[Nindex_SIO_TTY].XL_name,
  217. X        sizeof(sio_ttyname));
  218. X    sio_ttyname[sizeof(sio_ttyname) - 1] = 0;
  219. X
  220. X
  221. X    if((kmemfd = open(kmem_file,0)) < 0)
  222. X    {
  223. X        sprintf(errmsg," %s: %s ",kmem_file,sys_errlist[errno]);
  224. X        return(errmsg);
  225. X    }
  226. X
  227. X#ifdef STANDALONE_NLIST
  228. X    if(XLIST(kernel_file,kernel_symbols))
  229. X    {
  230. X        sprintf(errmsg," xlist/nlist failure: %s ",kernel_file);
  231. X        return(errmsg);
  232. X    }
  233. X
  234. X#else
  235. X    nlsym_read();
  236. X    if(!sio_ttyaddr)
  237. X    {
  238. X        sprintf(errmsg," %s not found in this kernel", sio_ttyname);
  239. X        return(errmsg);
  240. X    }
  241. X#endif
  242. X
  243. X    return((char *)0);
  244. X
  245. X}    /* end of kmem_init_tty */
  246. X
  247. X/*+-------------------------------------------------------------------------
  248. X    leave_text(text,code)
  249. X--------------------------------------------------------------------------*/
  250. X#ifndef STANDALONE_NLIST
  251. Xvoid
  252. Xleave_text(text,code)
  253. Xchar *text;
  254. Xint code;
  255. X{
  256. X    disp_cmd_legend(text);
  257. X    bye(1);
  258. X}    /* end of leave_text */
  259. X
  260. X#endif
  261. X
  262. X/* vi: set tabstop=4 shiftwidth=4: */
  263. X/* end of kmemsio.c */
  264. SHAR_EOF
  265. chmod 0644 siotools/kmemsio.c ||
  266. echo 'restore of siotools/kmemsio.c failed'
  267. Wc_c="`wc -c < 'siotools/kmemsio.c'`"
  268. test 3580 -eq "$Wc_c" ||
  269.     echo 'siotools/kmemsio.c: original size 3580, current size' "$Wc_c"
  270. fi
  271. # ============= siotools/kmemsio.h ==============
  272. if test -f 'siotools/kmemsio.h' -a X"$1" != X"-c"; then
  273.     echo 'x - skipping siotools/kmemsio.h (File already exists)'
  274. else
  275. echo 'x - extracting siotools/kmemsio.h (Text)'
  276. sed 's/^X//' << 'SHAR_EOF' > 'siotools/kmemsio.h' &&
  277. X/* CHK=0x83D5 */
  278. X/*+-----------------------------------------------------------------------
  279. X    kmemsio.h
  280. X------------------------------------------------------------------------*/
  281. X/*+:EDITS:*/
  282. X/*:07-15-1992-14:33-wht@n4hgf-2.60 release - u386mon+siotools merge */
  283. X/*:12-04-1989-16:49-afterlint-creation */
  284. X
  285. X#ifndef _kmemsio_h
  286. X#define _kmemsio_h
  287. X
  288. X#include "../ttynm.h"
  289. X
  290. Xextern struct tty sio[SIO_NTTY];
  291. X
  292. X#ifndef BUILDING_LINT_ARGS
  293. X#ifdef LINT_ARGS
  294. X
  295. X/* kmemsio.c */
  296. Xchar *kmem_init_tty(void );
  297. Xchar *kmem_read_tty(int ,int );
  298. X
  299. X#else        /* compiler doesn't know about prototyping */
  300. X
  301. X/* kmemsio.c */
  302. Xchar *kmem_init_tty();
  303. Xchar *kmem_read_tty();
  304. X
  305. X#endif /* LINT_ARGS */
  306. X#endif /* BUILDING_LINT_ARGS */
  307. X
  308. X#endif /* _kmemsio_h */
  309. X
  310. X/* vi: set tabstop=4 shiftwidth=4: */
  311. X/* end of kmemsio.h */
  312. SHAR_EOF
  313. chmod 0644 siotools/kmemsio.h ||
  314. echo 'restore of siotools/kmemsio.h failed'
  315. Wc_c="`wc -c < 'siotools/kmemsio.h'`"
  316. test 782 -eq "$Wc_c" ||
  317.     echo 'siotools/kmemsio.h: original size 782, current size' "$Wc_c"
  318. fi
  319. # ============= siotools/pend.sh ==============
  320. if test -f 'siotools/pend.sh' -a X"$1" != X"-c"; then
  321.     echo 'x - skipping siotools/pend.sh (File already exists)'
  322. else
  323. echo 'x - extracting siotools/pend.sh (Text)'
  324. sed 's/^X//' << 'SHAR_EOF' > 'siotools/pend.sh' &&
  325. XFrom n4hgf!kd4nc!emory!wuarchive!zaphod.mps.ohio-state.edu!rpi!crdgw1!crdos1!local Tue Oct 30 15:33:14 EST 1990
  326. XArticle 822 of alt.sources:
  327. XPath: n4hgf!kd4nc!emory!wuarchive!zaphod.mps.ohio-state.edu!rpi!crdgw1!crdos1!local
  328. X>From: local@crdos1.crd.ge.COM (local software)
  329. XNewsgroups: alt.sources
  330. XSubject: Show pending jobs in HDB uucp
  331. XMessage-ID: <2801@crdos1.crd.ge.COM>
  332. XDate: 29 Oct 90 21:58:30 GMT
  333. XReply-To: davidsen@crdos1.crd.ge.com (bill davidsen)
  334. XDistribution: alt
  335. XOrganization: GE Corp R&D Center
  336. XLines: 211
  337. X
  338. X
  339. X  After a job comes in via uucp, and before it is run via uuxqt, it is
  340. Xin a state I call "pending." When debugging a system, or just looking
  341. Xaround, I like to see what's there. Here's my program to do that. Also
  342. Xuseful when tuning the system to determine how often to run uuxqt from
  343. Xcron.
  344. X
  345. X#!/bin/sh
  346. X# shar:    Shell Archiver  (v1.29)
  347. X#
  348. X#    Run the following text with /bin/sh to create:
  349. X#      pending.1
  350. X#      Makefile
  351. X#      pending.c
  352. X#
  353. Xsed 's/^X//' << 'SHAR_EOF' > pending.1 &&
  354. XX.TH pending 1 Local
  355. XX.SH NAME
  356. XXpending \- list jobs pending from a remote site
  357. XX.SH SYNOPSIS
  358. XXpending remotesite
  359. XX.SH DESCRIPTION
  360. XXThe \fBpending\fP command shows jobs received from a remote site which
  361. XXhave not yet been processed by uuxqt. There are jobs which will be
  362. XXexecuted locally at some future time.
  363. XX.SS INSTALLATION
  364. XXThis program will only run from the uucp user (unless you security is
  365. XX\fIvery\fP lax), but may be installed setuid to uucp.
  366. XX.SH EXAMPLES
  367. XX  $ pending maxxwell
  368. XX
  369. XX     Job             User            Input File      Task
  370. XX    crdgw1X0T9Q     root crdgw1     D.crdgw1b0T9S   rmail stugr02!bob
  371. XX.SH FILES
  372. XX/usr/spool/uucp/site/*
  373. XX.SH SEE ALSO
  374. XXuustat
  375. XX.SH DIAGNOSTICS
  376. XXCan't get working dir - invalid site name of no directory for this site.
  377. XXCan't start ls - too many processes or /bin/ls missing.
  378. XXCan't open info file - sync error, uuxqt running, or access denied.
  379. XX.SH LIMITATIONS
  380. XXOnly works for HDB uucp.
  381. XX.SH AUTHOR
  382. XXBill Davidsen, davidsen@crdos1.crd.ge.com
  383. XX.SH Copyright
  384. XXCopyright (c) 1988,1990 by Bill Davidsen, All rights reserved. This
  385. XXprogram and documentation may be freely distributed and used providing
  386. XXthe copyright notices are kept intact.
  387. XSHAR_EOF
  388. Xchmod 0666 pending.1 || echo "restore of pending.1 fails"
  389. Xsed 's/^X//' << 'SHAR_EOF' > Makefile &&
  390. XX# makefile for pending command
  391. XX
  392. XX# ================> check everything below this line
  393. XX
  394. XXCFLAGS        = -O
  395. XXLFLAGS        = -S
  396. XX# remember to use /usr/man/man.LOCAL for SCO
  397. XXMANDIR        = /usr/man/man1
  398. XX# This is where you install it, like /usr/lbin, /usr/local/bin, 
  399. XX# /local, /u/local/bin or /usr/bin as last resort.
  400. XXBINDIR        = /u/local/bin
  401. XX# your local shar program
  402. XXSHAR        = shar
  403. XX
  404. XX# ================> stop, you've checked enough
  405. XX
  406. XXBASEFILES    = pending.1 Makefile
  407. XXSHARLIST    = $(BASEFILES) pending.c
  408. XXSHAROUT        = pending.shar
  409. XX
  410. XX# magic makerule for SCCS
  411. XX.c~.c:
  412. XX    get $<
  413. XX
  414. XX# default
  415. XXdefault:
  416. XX    @echo "After you have checked the first few lines of the Makefile"
  417. XX    @echo "you can type \"make pending\" or \"make install\"."
  418. XX    @echo "You can \"make clean\" after the install is done."
  419. XX
  420. XXpending: pending.o
  421. XX    $(CC) -o pending $(LFLAGS) pending.o
  422. XX
  423. XXinstall: pending pending.1
  424. XX    cp pending $(BINDIR)/pending
  425. XX    chusr uucp $(BINDIR)/pending
  426. XX    chmod 4711 $(BINDIR)/pending
  427. XX
  428. XXshar: $(SHAROUT)
  429. XX$(SHAROUT): $(SHARLIST)
  430. XX    $(SHAR) $(SHARLIST) > $(SHAROUT)
  431. XX
  432. XXclean:
  433. XX    rm -f pending $(SHAROUT)
  434. XX    test -f p.pending.c || rm -f pending.c
  435. XX
  436. XX# this is for the author!
  437. XXzoo: pending.zoo
  438. XXZOOLIST        = $(BASEFILES) s.pending.c
  439. XXpending.zoo: $(ZOOLIST)
  440. XX    zoo aunM pending.zoo $?
  441. XSHAR_EOF
  442. Xchmod 0644 Makefile || echo "restore of Makefile fails"
  443. Xsed 's/^X//' << 'SHAR_EOF' > pending.c &&
  444. XX/* list pending HDB requests from a site */
  445. XX
  446. XX#include <stdio.h>
  447. XX
  448. XX#define HDBdir    "/usr/spool/uucp"
  449. XX#define EOS        '\0'
  450. XX
  451. XXstatic char *IDent[] = {
  452. XX    "@(#)pending.c v1.2, 10/29/90"
  453. XX    "Copyright 1988 by Bill Davidsen, all rights reserved",
  454. XX    "May be freely distributed and used providing copyright",
  455. XX    "notices are kept intact."
  456. XX};
  457. XX
  458. XXmain(argc,argv)
  459. XXint argc;
  460. XXchar *argv[];
  461. XX{
  462. XX    char dirname[1024], filename[32], dataline[132];
  463. XX    char xfilename[32], wkfilename[132], *DummY = IDent[0];
  464. XX    int slen;                    /* string length */
  465. XX    int first1 = 1;                /* flag for 1st time thru */
  466. XX    FILE *lsout, *popen(), *xfile, *fopen();
  467. XX
  468. XX    /* test input */
  469. XX    if (argc != 2) {
  470. XX        fprintf(stderr, "Format:\n  pending SYSname\n\n");
  471. XX        exit(1);
  472. XX    }
  473. XX
  474. XX    sprintf(dirname, "%s/%s", HDBdir, argv[1]);
  475. XX    if (chdir(dirname)) {
  476. XX        perror("Can't get working dir");
  477. XX        exit(1);
  478. XX    }
  479. XX    
  480. XX    lsout = popen("ls X.* 2>&1", "r");
  481. XX    if (lsout == NULL) {
  482. XX        perror("Can't start ls");
  483. XX        exit(1);
  484. XX    }
  485. XX
  486. XX    filename[31] = EOS;
  487. XX    /* loop checking files */
  488. XX    while (fgets(filename, 31, lsout)) {
  489. XX        if (strlen(filename) > 30) {
  490. XX            fprintf(stderr, "filename too long\n");
  491. XX            exit(1);
  492. XX        }
  493. XX
  494. XX        /* see if there's a file found */
  495. XX        sscanf(filename, "%s", xfilename);
  496. XX        if (strncmp(xfilename, "X.*", 3) == 0) {
  497. XX            fprintf(stderr, "No jobs pending\n");
  498. XX            exit(0);
  499. XX        }
  500. XX
  501. XX        /* open the file for reading */
  502. XX        xfile = fopen(xfilename, "r");
  503. XX        if (xfile == NULL) {
  504. XX            perror("Can't open info file");
  505. XX            exit(1);
  506. XX        }
  507. XX
  508. XX        /* check for header needed */
  509. XX        if (first1) {
  510. XX            first1 = 0;
  511. XX            printf("\n %-15s %-15s %-15s %s\n",
  512. XX                "Job", "User", "Input File", "Task");
  513. XX        }
  514. XX
  515. XX        /* scan the file for various things */
  516. XX        printf("%-15s ", xfilename+2);
  517. XX        dataline[131] = EOS;
  518. XX        while (fgets(dataline, 131, xfile)) {
  519. XX            if ((slen = strlen(dataline)) > 130) {
  520. XX                /* line too long */
  521. XX                while (getc(xfile) != '\n');
  522. XX            }
  523. XX            dataline[slen-1] = EOS;
  524. XX
  525. XX            switch (dataline[0]) {
  526. XX            case 'U': /* originating user */
  527. XX                printf("%-15s ", dataline+2);
  528. XX                break;
  529. XX            case 'C': /* command */
  530. XX                printf("%s\n", dataline+2);
  531. XX                break;
  532. XX            case 'I': /* input file */
  533. XX                printf("%-15s ", dataline+2);
  534. XX                break;
  535. XX            }
  536. XX        }
  537. XX
  538. XX        /* clean up */
  539. XX        fclose(xfile);
  540. XX    }
  541. XX
  542. XX    pclose(lsout);
  543. XX    exit(0);
  544. XX}
  545. XX/* tabs=4 */
  546. XSHAR_EOF
  547. Xchmod 0444 pending.c || echo "restore of pending.c fails"
  548. Xexit 0
  549. X
  550. X
  551. SHAR_EOF
  552. chmod 0644 siotools/pend.sh ||
  553. echo 'restore of siotools/pend.sh failed'
  554. Wc_c="`wc -c < 'siotools/pend.sh'`"
  555. test 5996 -eq "$Wc_c" ||
  556.     echo 'siotools/pend.sh: original size 5996, current size' "$Wc_c"
  557. fi
  558. # ============= siotools/siomon.c ==============
  559. if test -f 'siotools/siomon.c' -a X"$1" != X"-c"; then
  560.     echo 'x - skipping siotools/siomon.c (File already exists)'
  561. else
  562. echo 'x - extracting siotools/siomon.c (Text)'
  563. sed 's/^X//' << 'SHAR_EOF' > 'siotools/siomon.c' &&
  564. X/* CHK=0xBED5 */
  565. Xchar *revision = "2.01";
  566. X/*+-------------------------------------------------------------------------
  567. X    siomon.c -- watch XENIX/UNIX serial I/O
  568. X    ...!gatech!kd4nc!n4hgf!wht
  569. X    XENIX debugging help by Jim Stratton (stratton@hpda.da.com)
  570. X
  571. X    Sample output:
  572. X   000000000011111111112222222222333333333344444444445555555555666666666677777
  573. X   012345678901234567890123456789012345678901234567890123456789012345678901234
  574. X00  siomon 1.34 (UNIX V.3.2/i386) n4hgf           interval:  1        21:54:54
  575. X01 
  576. X02  tty  raw  can   out   speed  state iflag  oflag  cflag  lflag  pgrp
  577. X03  ---  ---  ---  -----  -----  ----- ------ ------ ------ ------ -----
  578. X04  1a     0    0      0   9600  OC     10045      0   6655      0     0
  579. X05  1b
  580. X06  1c
  581. X07  1d
  582. X08  1e
  583. X09  1f
  584. X10  1g
  585. X11  1h
  586. X12  2a
  587. X13  2b
  588. X14  2c
  589. X15  2d     0    0      0   9600  W          0      0   2275      0     0
  590. X16  2e
  591. X17  2f     0    0      0   4800  OC     10040      0   2374      0     0
  592. X18  2g     0    0      0   4800  OC     10005      0   6374      0     0
  593. X19  2h
  594. X20 
  595. X21 State: W waiting for open to complete  O open  C carrier on
  596. X22        S stopped by XOFF  D interval timeout in progress
  597. X23 Commands: + inc interval  - dec interval  ^L refresh  q quit  d detail
  598. X
  599. XUnder XENIX, termio.h is included twice (once by curses.h/tcap.h and
  600. Xagain by sys/tty.h.  You need to bracket the termio.h under XENIX with
  601. X  #if !defined(TERMIO_HACK) || (defined(TERMIO_HACK) && !defined(IOCTYPE))
  602. X  ...
  603. X  #endif
  604. X
  605. X  Defined functions:
  606. X    bye(sig)
  607. X    detail()
  608. X    disp_cmd_legend(text)
  609. X    disp_interval()
  610. X    disp_state_legend()
  611. X    disp_tod()
  612. X    disp_tty(y,sionum,tty)
  613. X    main(argc,argv,envp)
  614. X    main_template()
  615. X    my_resetty()
  616. X    my_savetty()
  617. X    strcmpi(s1,s2)
  618. X    to_lower(ch)
  619. X    to_upper(ch)
  620. X
  621. X  Kudos to pyrnj.pyramid.com!romain (Romain Kang) for many suggestions
  622. X  regarding screen and CPU efficiency in the original itpmon.c for Pyramid
  623. X  Thanks to mpxenix!news (Randy Bush) for tireless help with a curses
  624. X  bug hopefully now retired, even if it crockish.
  625. X--------------------------------------------------------------------------*/
  626. X/*+:EDITS:*/
  627. X/*:08-10-1992-07:32-wht@n4hgf-put state legend on detail screen too */
  628. X/*:07-15-1992-14:33-wht@n4hgf-2.60 release - u386mon+siotools merge */
  629. X/*:06-25-1992-02:37-root@n4hgf-integrate with u386mon's nlsym */
  630. X/*:06-22-1992-13:28-wht@n4hgf-revisit for 3.2v4 */
  631. X/*:02-23-1990-17:10-wht-more keyboard problems with UNIX: try typeahead(-1) */
  632. X/*:02-18-1990-03:29-wht-bug in curses tty mode handling - force a fix */
  633. X/*:12-28-1989-13:35-wht-change rev - B600 added to wintty */
  634. X/*:12-21-1989-15:20-wht-version number chg - CTSFLOW/RTSFLOW */
  635. X/*:12-04-1989-16:45-wht-add more to detail */
  636. X/*:11-28-1989-19:49-wht-no more sprintf and allow nap/rdchk in lieu of select */
  637. X/*:11-22-1989-12:33-wht-rehost my Pyramid itpmon.c */
  638. X
  639. X/* -------- select(S) availability --------- */
  640. X/* define HAVE_SELECT */ /* uncomment for XENIX/386 2.3.2 and later */
  641. X#if (defined(M_UNIX) && (!defined(HAVE_SELECT))) /* automatic for UNIX */
  642. X#define HAVE_SELECT
  643. X#endif
  644. X
  645. X#ifndef SYSV
  646. X#define SYSV
  647. X#endif
  648. X
  649. X#include <curses.h>
  650. X#include <signal.h>
  651. X#include <sys/types.h>
  652. X#include <sys/utsname.h>
  653. X#include <time.h>
  654. X
  655. X#if defined(HAVE_SELECT)
  656. X#include <sys/select.h>
  657. X#endif
  658. X
  659. X#include <sys/tty.h>
  660. X
  661. X#include "wintty.h"
  662. X#define DEFINE_TTYNM
  663. X#include "kmemsio.h"
  664. X#include "utoa.h"
  665. X
  666. X#define HY 2    /* header line */
  667. X#define TX 1
  668. X#define RX 6
  669. X#define CX 11
  670. X#define OX 16
  671. X#define SX 23
  672. X#define FX 30
  673. X
  674. Xextern char _sobuf[];
  675. Xextern int errno;
  676. Xextern char *sys_errlist[];
  677. X
  678. Xint no_tod = 0;
  679. Xint interval_secs = 1;
  680. Xstruct utsname me;
  681. Xchar bell = 7;
  682. X
  683. X/*+-------------------------------------------------------------------------
  684. X    workaround curses tty handling difficulties among different revs
  685. X--------------------------------------------------------------------------*/
  686. Xstruct termio my_termio_crock;
  687. Xvoid my_savetty()    /* used in lieu of savetty() */
  688. X{
  689. X    ioctl(0,TCGETA,&my_termio_crock);
  690. X}
  691. Xvoid my_resetty()    /* used in lieu of resetty() and endwin() */
  692. X{
  693. X    ioctl(0,TCSETA,&my_termio_crock);
  694. X}
  695. X
  696. X/*+-------------------------------------------------------------------------
  697. X    bye() - terminate curses, reset terminal and exit
  698. X--------------------------------------------------------------------------*/
  699. Xvoid
  700. Xbye(sig)
  701. Xint sig;
  702. X{
  703. X    if(stdscr)
  704. X    {
  705. X        standend();
  706. X        move(LINES - 1,0);
  707. X        refresh();
  708. X        my_resetty();
  709. X    }
  710. X    exit(0);
  711. X}    /* end of bye */
  712. X
  713. X/*+-------------------------------------------------------------------------
  714. X    disp_tty(y,sionum,tty) - display info for 1 tty
  715. X--------------------------------------------------------------------------*/
  716. Xvoid
  717. Xdisp_tty(y,sionum,tty)
  718. Xint y;
  719. Xint sionum;
  720. Xregister struct tty *tty;
  721. X{
  722. X    register unsigned int itmp;
  723. X    register opened = tty->t_state & (ISOPEN | WOPEN);
  724. X    char s8[8];
  725. X
  726. X    move(y,TX + 0);
  727. X    addstr(ttynm[sionum]);
  728. X
  729. X    if(!opened)
  730. X    {
  731. X        clrtoeol();
  732. X        return;
  733. X    }
  734. X
  735. X    if((itmp = (unsigned)tty->t_rawq.c_cc) > 999)
  736. X        itmp = 999;
  737. X    utoda(s8,3,itmp);
  738. X    move(y,RX + 0);
  739. X    if(itmp > 10)
  740. X        standout();
  741. X    addstr(s8);
  742. X    if(itmp > 10)
  743. X        standend();
  744. X
  745. X    if((itmp = (unsigned)tty->t_canq.c_cc) > 999)
  746. X        itmp = 999;
  747. X    utoda(s8,3,itmp);
  748. X    move(y,CX + 0);
  749. X    addstr(s8);
  750. X
  751. X    if((itmp = (unsigned)tty->t_outq.c_cc + tty->t_tbuf.c_count) > 99999)
  752. X        itmp = 99999;
  753. X    utoda(s8,5,itmp);
  754. X    move(y,OX + 0);
  755. X    addstr(s8);
  756. X
  757. X    move(y,SX + 0);
  758. X    addstr(B_to_baud_rate(tty->t_cflag & CBAUD));
  759. X
  760. X    strcpy(s8,"     ");
  761. X    if(tty->t_state & WOPEN)
  762. X        s8[0] = 'W';
  763. X    else if(tty->t_state & ISOPEN)
  764. X        s8[0] = 'O';
  765. X    if(tty->t_state & CARR_ON)
  766. X        s8[1] = 'C';
  767. X    if(tty->t_state & BUSY)
  768. X        s8[2] = 'B';
  769. X    if(tty->t_state & TTSTOP)
  770. X        s8[3] = 'S';
  771. X    if(tty->t_state & TIMEOUT)
  772. X        s8[4] = 'D';
  773. X    move(y,FX);
  774. X    addstr(s8);
  775. X
  776. X    utooa(s8,7,tty->t_iflag);
  777. X    addstr(s8);
  778. X
  779. X    utooa(s8,7,tty->t_oflag);
  780. X    addstr(s8);
  781. X
  782. X    utooa(s8,7,tty->t_cflag);
  783. X    addstr(s8);
  784. X
  785. X    utooa(s8,7,tty->t_lflag);
  786. X    addstr(s8);
  787. X
  788. X    utoda(s8,6,tty->t_pgrp);
  789. X    addstr(s8);
  790. X
  791. X}    /* end of disp_tty */
  792. X
  793. X/*+-------------------------------------------------------------------------
  794. X    disp_interval() - display current display interval
  795. X--------------------------------------------------------------------------*/
  796. Xvoid
  797. Xdisp_interval()
  798. X{
  799. X    char dmsg[12];
  800. X
  801. X    move(0,47);
  802. X    addstr("interval: ");
  803. X    utoda(dmsg,2,interval_secs);
  804. X    addstr(dmsg);
  805. X}    /* end of disp_interval */
  806. X
  807. X/*+-------------------------------------------------------------------------
  808. X    disp_state_legend() - display "State: W ......"
  809. X--------------------------------------------------------------------------*/
  810. Xvoid
  811. Xdisp_state_legend()
  812. X{
  813. X
  814. X    move(LINES - 4,0);
  815. X    addstr(
  816. X"State: W waiting for open to complete  O open  C carrier on");
  817. X    move(LINES - 3,0);
  818. X    addstr(
  819. X"       S stopped by XOFF  D interval timeout in progress  B transmitter busy");
  820. X}    /* end of disp_state_legend */
  821. X
  822. X/*+-------------------------------------------------------------------------
  823. X    disp_tod() - display time of day
  824. X--------------------------------------------------------------------------*/
  825. Xvoid
  826. Xdisp_tod()
  827. X{
  828. X    register struct tm *lt;        /* local time */
  829. X    struct tm *localtime();
  830. X    long now;
  831. X    char buf[10];
  832. X
  833. X    if(no_tod)
  834. X        return;
  835. X
  836. X    time(&now);
  837. X    lt = localtime(&now);
  838. X    utoda_lz(buf,2,lt->tm_hour);
  839. X    buf[2] = ':';
  840. X    utoda_lz(buf + 3,2,lt->tm_min);
  841. X    buf[5] = ':';
  842. X    utoda_lz(buf + 6,2,lt->tm_sec);
  843. X    move(0,COLS - 13);
  844. X    addstr(buf);
  845. X}    /* end of disp_tod */
  846. X
  847. X/*+-------------------------------------------------------------------------
  848. X    disp_cmd_legend(text) - display command legend
  849. X--------------------------------------------------------------------------*/
  850. Xvoid
  851. Xdisp_cmd_legend(text)
  852. Xchar *text;
  853. X{
  854. X    move(LINES - 2,0);
  855. X    clrtoeol();
  856. X
  857. X    if(!text)
  858. X    {
  859. X        move(LINES - 2,0);
  860. X        addstr("Commands: ");
  861. X        standout();
  862. X        addstr("ESC");
  863. X        standend();
  864. X        addstr("/");
  865. X        standout();
  866. X        addstr("q");
  867. X        standend();
  868. X        addstr(" quit   ");
  869. X        standout();
  870. X        addstr("d");
  871. X        standend();
  872. X        addstr(" detail on tty   ");
  873. X        standout();
  874. X        addstr("+");
  875. X        standend();
  876. X        addstr("/");
  877. X        standout();
  878. X        addstr("-");
  879. X        standend();
  880. X        addstr(" change interval   ");
  881. X        standout();
  882. X        addstr("^L");
  883. X        standend();
  884. X        addstr(" refresh");
  885. X    }
  886. X    else
  887. X        addstr(text);
  888. X
  889. X}    /* end of disp_cmd_legend */
  890. X
  891. X/*+-------------------------------------------------------------------------
  892. X    main_template() - draw main screen template
  893. X--------------------------------------------------------------------------*/
  894. Xvoid
  895. Xmain_template()
  896. X{
  897. X    static char *header  = 
  898. X        " tty  raw  can   out   speed  state iflag  oflag  cflag  lflag  pgrp";
  899. X    static char *hyphens =
  900. X        " ---  ---  ---  -----  -----  ----- ------ ------ ------ ------ -----";
  901. X    FILE *fp = fopen("/etc/systemid","r");
  902. X    char sysid[64];
  903. X
  904. X    wclear(stdscr);
  905. X    move(0,0);
  906. X    standout();
  907. X    printw(" siomon %s (%s V.%s/%s)",
  908. X        revision,
  909. X#if defined(M_UNIX)
  910. X        "UNIX",
  911. X#else
  912. X        "XENIX",
  913. X#endif
  914. X        me.release,me.machine);
  915. X    if(fp)
  916. X    {
  917. X        sysid[0] = 0;
  918. X        fgets(sysid,sizeof(sysid),fp);
  919. X        if(sysid[0])
  920. X        {
  921. X            sysid[strlen(sysid) - 1] = 0;
  922. X            printw(" %s ",sysid);
  923. X        }
  924. X        fclose(fp);
  925. X    }
  926. X    standend();
  927. X    move(HY,0);
  928. X    addstr(header);
  929. X    move(HY + 1,0);
  930. X    addstr(hyphens);
  931. X    disp_state_legend();
  932. X    disp_cmd_legend((char *)0);
  933. X    move(LINES - 1,0);
  934. X    disp_interval();
  935. X    refresh();
  936. X}    /* end of main_template */
  937. X
  938. X#ifdef SIO_IS_FAS
  939. X#define  STRCMP strcmp
  940. X#else
  941. X#define  STRCMP strcmpi
  942. X/*+-------------------------------------------------------------------------
  943. X    to_upper() / to_lower()
  944. X
  945. XOne would think that these were relatively standard types of
  946. Xthing, but System V specifies toupper() to convert to upper case
  947. Xif not already and BSD says to adjust without testing, so, two
  948. Xstupid little routines here.  ASCII only -- no EBCDIC gradoo here please.
  949. X--------------------------------------------------------------------------*/
  950. Xchar to_upper(ch)
  951. Xregister char ch;
  952. X{ return( ((ch >= 'a') && (ch <= 'z')) ? ch - 0x20 : ch);
  953. X}   /* end of to_upper() */
  954. X
  955. Xchar to_lower(ch)
  956. Xregister char ch;
  957. X{ return( ((ch >= 'A') && (ch <= 'Z')) ? ch + 0x20 : ch);
  958. X}   /* end of to_lower() */
  959. X
  960. X/*+-------------------------------------------------------------------------
  961. X    strcmpi(s1,s2) - case-insensitive strcmp
  962. X
  963. XThis version of strcmp() is case-insensitive and works like a sane one
  964. Xshould, per strcmp(3), not per  the K&R1 example or POSIX/ANSI.
  965. X
  966. XIn here rather than ecuutil.c since other executables besides ecu
  967. Xuses this module and strcmpi needed there too 
  968. X--------------------------------------------------------------------------*/
  969. Xint
  970. Xstrcmpi(s1,s2)
  971. Xregister char *s1;
  972. Xregister char *s2;
  973. X{
  974. X
  975. X    while(*s1)
  976. X    {
  977. X        if(to_upper(*s1++) != to_upper(*s2++))
  978. X        {
  979. X            s1--;
  980. X            s2--;
  981. X            break;
  982. X        }
  983. X    }
  984. X    return(to_upper(*s1) - to_upper(*s2));
  985. X
  986. X}    /* end of strcmpi */
  987. X#endif /* SIO_IS_FAS */
  988. X
  989. X/*+-------------------------------------------------------------------------
  990. X    detail() - detail screen handler
  991. X--------------------------------------------------------------------------*/
  992. Xvoid
  993. Xdetail()
  994. X{
  995. X    int y,x;
  996. X    int sionum;
  997. X    char tty_name[32];
  998. X    char cmd;
  999. X    char **cpptr;
  1000. X    char delim;
  1001. X    int cmd_available;
  1002. X#if defined(HAVE_SELECT)
  1003. X    struct timeval timeout;
  1004. X    int readfds;
  1005. X#else
  1006. X    long ltimeout;
  1007. X    long nap();
  1008. X#endif
  1009. X
  1010. X    for(y = 0; y < (LINES - 4); y++)
  1011. X    {
  1012. X        move(HY + 2 + y,0);
  1013. X        clrtoeol();
  1014. X    }
  1015. X    disp_cmd_legend("display detail on /dev/tty");
  1016. X    getyx(stdscr,y,x);
  1017. X
  1018. X    if(wingets(stdscr,y,x,tty_name,3,&delim,0,(int *)0) < 0)
  1019. X        return;
  1020. X    for(sionum = 0,cpptr = ttynm; sionum < SIO_NTTY; sionum++,cpptr++)
  1021. X    {
  1022. X        if(!STRCMP(*cpptr,tty_name))
  1023. X            break;
  1024. X    }
  1025. X    if(sionum == SIO_NTTY)
  1026. X    {
  1027. X        write(2,&bell,1);
  1028. X        return;
  1029. X    }
  1030. X
  1031. X    disp_state_legend();
  1032. X    disp_cmd_legend("");
  1033. X    move(LINES - 2,0);
  1034. X    addstr("Commands: ");
  1035. X    standout();
  1036. X    addstr("ESC");
  1037. X    standend();
  1038. X    addstr("/");
  1039. X    standout();
  1040. X    addstr("q");
  1041. X    standend();
  1042. X    addstr(" main display   ");
  1043. X    standout();
  1044. X    addstr("+");
  1045. X    standend();
  1046. X    addstr("/");
  1047. X    standout();
  1048. X    addstr("-");
  1049. X    standend();
  1050. X    addstr(" change interval");
  1051. X
  1052. X    move(HY + 2,0);
  1053. X    clrtoeol();
  1054. X    wintty_template(stdscr,HY + 2 + 2,0,1);
  1055. X    while(1)
  1056. X    {
  1057. X        disp_tod();
  1058. X        kmem_read_tty(sionum,1);
  1059. X        disp_tty(HY + 2,sionum,&sio[0]);
  1060. X        wintty(stdscr,HY + 2 + 2,0,&sio[0]);
  1061. X        move(HY + 2 + 11,0);
  1062. X        refresh();
  1063. X#if defined(HAVE_SELECT)
  1064. X        readfds = 1;            /* for standard input */
  1065. X        timeout.tv_sec  = interval_secs;
  1066. X        timeout.tv_usec = (interval_secs)
  1067. X                                ? 0
  1068. X                                : ((sio[0].t_state & ISOPEN)
  1069. X                                    ? 20*1000L
  1070. X                                    : 200*1000L);
  1071. X        cmd_available = (select(32,&readfds,0,0,&timeout) > 0);
  1072. X#else
  1073. X        ltimeout = (interval_secs)
  1074. X                        ? (interval_secs * 1000L)
  1075. X                        : ((sio[0].t_state & ISOPEN) ? 20L : 100L);
  1076. X        while(ltimeout > 0)
  1077. X        {
  1078. X            ltimeout -= nap((interval_secs) ? 20L : 100L);
  1079. X            if(cmd_available = rdchk(0))
  1080. X                break;
  1081. X        }
  1082. X#endif
  1083. X        if(rdchk(0))
  1084. X        {
  1085. X            cmd = getch();
  1086. X            if((cmd == 0x1B) || (cmd == 'q'))
  1087. X                break;
  1088. X            switch(cmd)
  1089. X            {
  1090. X                case '+':
  1091. X                    interval_secs++;
  1092. X                    disp_interval();
  1093. X                    break;
  1094. X
  1095. X                case '-':
  1096. X                    if(!interval_secs)
  1097. X                        break;
  1098. X                    interval_secs--;
  1099. X                    disp_interval();
  1100. X                    break;
  1101. X            }
  1102. X        }
  1103. X    }
  1104. X}    /* end of detail */
  1105. X
  1106. X/*+-------------------------------------------------------------------------
  1107. X    main(argc,argv,envp)
  1108. X--------------------------------------------------------------------------*/
  1109. Xmain(argc,argv,envp)
  1110. Xint argc;
  1111. Xchar **argv;
  1112. Xchar **envp;
  1113. X{
  1114. X    register sionum;
  1115. X    char *cptr;
  1116. X    int cmd_available;
  1117. X#if defined(HAVE_SELECT)
  1118. X    struct timeval timeout;
  1119. X    int readfds;
  1120. X#else
  1121. X    long ltimeout;
  1122. X    long nap();
  1123. X#endif
  1124. X
  1125. X    if((argc > 1) && !strcmp(argv[1],"-n"))
  1126. X        no_tod = 1;
  1127. X
  1128. X    signal(SIGINT,bye);
  1129. X    signal(SIGTERM,bye);
  1130. X    uname(&me);
  1131. X
  1132. X    setbuf(stdout,_sobuf);
  1133. X    my_savetty();
  1134. X    if(!initscr())
  1135. X    {
  1136. X        fputs("curses init failed ... check terminal type\n",stderr);
  1137. X        exit(1);
  1138. X    }
  1139. X#if defined(M_TERMINFO)
  1140. X    typeahead(-1);
  1141. X#endif
  1142. X    crmode();
  1143. X    noecho();
  1144. X    main_template();
  1145. X
  1146. X    move(4,0);
  1147. X    standout();
  1148. X    addstr(" Reading kernel symbol table ");
  1149. X    standend();
  1150. X    refresh();
  1151. X
  1152. X    if(cptr = kmem_init_tty())
  1153. X    {
  1154. X        move(5,0);
  1155. X        standout();
  1156. X        addstr(cptr);
  1157. X        standend();
  1158. X        bye(0);
  1159. X    }
  1160. X
  1161. X    move(4,0);
  1162. X    clrtoeol();
  1163. X    refresh();
  1164. X
  1165. X    while(1)
  1166. X    {
  1167. X        kmem_read_tty(0,SIO_NTTY);
  1168. X        for(sionum = 0; sionum < SIO_NTTY; sionum++)
  1169. X        {
  1170. X            int yy = HY + 2 + sionum;
  1171. X            if(yy == (LINES - 5))
  1172. X            {
  1173. X                move(yy,0);
  1174. X                clrtoeol();
  1175. X                addstr("not enough room for all ttys");
  1176. X                break;
  1177. X            }
  1178. X            disp_tty(yy,sionum,&sio[sionum]);
  1179. X        }
  1180. X        disp_tod();
  1181. X        move(LINES - 1,0);
  1182. X        refresh();
  1183. X
  1184. X#if defined(HAVE_SELECT)
  1185. X        readfds = 1;            /* for standard input */
  1186. X        timeout.tv_sec  = interval_secs;
  1187. X        timeout.tv_usec = (interval_secs) ? 0 : 100*1000L;
  1188. X        cmd_available = (select(32,&readfds,0,0,&timeout) > 0);
  1189. X#else
  1190. X        ltimeout = (interval_secs) ? (interval_secs * 1000L) : 100L;
  1191. X        while(ltimeout > 0)
  1192. X        {
  1193. X            ltimeout -= nap(100L);
  1194. X            if(cmd_available = rdchk(0))
  1195. X                break;
  1196. X        }
  1197. X#endif
  1198. X
  1199. X        if(cmd_available)
  1200. X        {
  1201. X        char ch;
  1202. X            ch = getch();
  1203. X            switch(ch & 0x7F)
  1204. X            {
  1205. X            case 'L' & 0x1F:        /* redraw screen */
  1206. X            case 'R' & 0x1F:        /* redraw screen */
  1207. X                main_template();
  1208. X                break;
  1209. X
  1210. X            case '+':
  1211. X                interval_secs++;
  1212. X                disp_interval();
  1213. X                break;
  1214. X
  1215. X            case '-':
  1216. X                if(!interval_secs)
  1217. X                    break;
  1218. X                interval_secs--;
  1219. X                disp_interval();
  1220. X                break;
  1221. X
  1222. X            case 'q':        /* quit */
  1223. X            case 0x1B:
  1224. X                bye(0);
  1225. X                break;
  1226. X
  1227. X            case 'd':        /* detail */
  1228. X                detail();
  1229. X                main_template();
  1230. X                refresh();
  1231. X                break;
  1232. X
  1233. X            }
  1234. X        }
  1235. X    }
  1236. X}    /* end of main */
  1237. X
  1238. X/* vi: set tabstop=4 shiftwidth=4: */
  1239. X/* end of siomon.c */
  1240. SHAR_EOF
  1241. chmod 0644 siotools/siomon.c ||
  1242. echo 'restore of siotools/siomon.c failed'
  1243. Wc_c="`wc -c < 'siotools/siomon.c'`"
  1244. test 14992 -eq "$Wc_c" ||
  1245.     echo 'siotools/siomon.c: original size 14992, current size' "$Wc_c"
  1246. fi
  1247. # ============= siotools/utoa.c ==============
  1248. if test -f 'siotools/utoa.c' -a X"$1" != X"-c"; then
  1249.     echo 'x - skipping siotools/utoa.c (File already exists)'
  1250. else
  1251. echo 'x - extracting siotools/utoa.c (Text)'
  1252. sed 's/^X//' << 'SHAR_EOF' > 'siotools/utoa.c' &&
  1253. X/* CHK=0xAD27 */
  1254. X/*+-------------------------------------------------------------------------
  1255. X    utoa.c - fast substitutes for most sprintf needs
  1256. X    ...!gatech!emory!tridom!wht
  1257. X
  1258. X  Defined functions:
  1259. X    utoda_common(buf,width,n,leading)
  1260. X    utooa_common(buf,width,n,leading)
  1261. X
  1262. X--------------------------------------------------------------------------*/
  1263. X/*+:EDITS:*/
  1264. X/*:07-15-1992-14:33-wht@n4hgf-2.60 release - u386mon+siotools merge */
  1265. X/*:11-29-1989-03:32-wht-creation */
  1266. X
  1267. X#include "utoa.h"
  1268. X
  1269. X/*+-------------------------------------------------------------------------
  1270. X    utoda_common(buf,width,n,leading) unsigned to decimal ascii
  1271. X--------------------------------------------------------------------------*/
  1272. Xvoid
  1273. Xutoda_common(buf,width,n,leading)
  1274. Xchar *buf;
  1275. Xint width;
  1276. Xunsigned n;
  1277. Xchar leading;
  1278. X{
  1279. X    register unsigned div;
  1280. X    register char *ep = &buf[width];
  1281. X
  1282. X    *ep = '\0';
  1283. X    if(n == 0)
  1284. X        *--ep = '0';
  1285. X    while(ep-- > buf)
  1286. X    {
  1287. X        if(n <= 0)
  1288. X            *ep = leading;
  1289. X        else
  1290. X        {
  1291. X            div = n / 10;
  1292. X            *ep = n - 10*div + '0';
  1293. X            n = div;
  1294. X        }
  1295. X    }
  1296. X}    /* end of utoda_common */
  1297. X
  1298. X/*+-------------------------------------------------------------------------
  1299. X    utooa_common(buf,width,n,leading) unsigned to octal ascii
  1300. X--------------------------------------------------------------------------*/
  1301. Xvoid
  1302. Xutooa_common(buf,width,n,leading)
  1303. Xchar *buf;
  1304. Xint width;
  1305. Xunsigned n;
  1306. Xchar leading;
  1307. X{
  1308. Xregister unsigned div;
  1309. Xregister char *ep = &buf[width];
  1310. X
  1311. X    *ep = '\0';
  1312. X    if(n == 0)
  1313. X        *--ep = '0';
  1314. X    while(ep-- > buf)
  1315. X    {
  1316. X        if(n <= 0)
  1317. X            *ep = leading;
  1318. X        else
  1319. X        {
  1320. X            div = n >> 3;
  1321. X            *ep = n - (div << 3) + '0';
  1322. X            n = div;
  1323. X        }
  1324. X    }
  1325. X}    /* end of utooa_common */
  1326. X
  1327. X/* vi: set tabstop=4 shiftwidth=4: */
  1328. X/* end of utoa.c */
  1329. SHAR_EOF
  1330. chmod 0644 siotools/utoa.c ||
  1331. echo 'restore of siotools/utoa.c failed'
  1332. Wc_c="`wc -c < 'siotools/utoa.c'`"
  1333. test 1659 -eq "$Wc_c" ||
  1334.     echo 'siotools/utoa.c: original size 1659, current size' "$Wc_c"
  1335. fi
  1336. # ============= siotools/utoa.h ==============
  1337. if test -f 'siotools/utoa.h' -a X"$1" != X"-c"; then
  1338.     echo 'x - skipping siotools/utoa.h (File already exists)'
  1339. else
  1340. echo 'x - extracting siotools/utoa.h (Text)'
  1341. sed 's/^X//' << 'SHAR_EOF' > 'siotools/utoa.h' &&
  1342. X/* CHK=0x01CD */
  1343. X/*+-----------------------------------------------------------------------
  1344. X    utoa.h
  1345. X------------------------------------------------------------------------*/
  1346. X/*+:EDITS:*/
  1347. X/*:07-15-1992-14:33-wht@n4hgf-2.60 release - u386mon+siotools merge */
  1348. X/*:12-04-1989-16:50-afterlint-creation */
  1349. X
  1350. X#ifndef _utoa_h
  1351. X#define _utoa_h
  1352. X/* unsigned to decimal ascii w/o leading spaces */
  1353. X#define utoda(buf,width,n)  utoda_common(buf,width,n,' ')
  1354. X
  1355. X/* unsigned to decimal ascii w/leading zeroes */
  1356. X#define utoda_lz(buf,width,n)  utoda_common(buf,width,n,'0')
  1357. X
  1358. X/* unsigned to octal ascii w/o leading spaces */
  1359. X#define utooa(buf,width,n)  utooa_common(buf,width,n,' ')
  1360. X
  1361. X/* unsigned to octal ascii w/leading zeroes */
  1362. X#define utooa_lz(buf,width,n)  utooa_common(buf,width,n,'0')
  1363. X
  1364. X#ifndef BUILDING_LINT_ARGS
  1365. X#ifdef LINT_ARGS
  1366. X
  1367. X/* utoa.c */
  1368. Xvoid utoda_common(char *,int ,unsigned int ,char );
  1369. Xvoid utooa_common(char *,int ,unsigned int ,char );
  1370. X
  1371. X#else        /* compiler doesn't know about prototyping */
  1372. X
  1373. X/* utoa.c */
  1374. Xvoid utoda_common();
  1375. Xvoid utooa_common();
  1376. X
  1377. X#endif /* LINT_ARGS */
  1378. X#endif /* BUILDING_LINT_ARGS */
  1379. X
  1380. X#endif /* _utoa_h */
  1381. X
  1382. X/* vi: set tabstop=4 shiftwidth=4: */
  1383. X/* end of utoa.h */
  1384. SHAR_EOF
  1385. chmod 0644 siotools/utoa.h ||
  1386. echo 'restore of siotools/utoa.h failed'
  1387. Wc_c="`wc -c < 'siotools/utoa.h'`"
  1388. test 1181 -eq "$Wc_c" ||
  1389.     echo 'siotools/utoa.h: original size 1181, current size' "$Wc_c"
  1390. fi
  1391. true || echo 'restore of siotools/uusnap.c failed'
  1392. echo End of part 8, continue with part 9
  1393. exit 0
  1394.  
  1395. exit 0 # Just in case...
  1396.