home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume33 / u386mon / part08 < prev    next >
Encoding:
Text File  |  1992-11-20  |  34.9 KB  |  1,390 lines

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