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

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
  4. Subject:  v33i118:  u386mon - SVR3 performance/status monitor v2.60, Part09/09
  5. Message-ID: <1992Nov22.020357.24553@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: 3b97d1e1707ed07b4ff7f7eaccf95a82
  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:57 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 2113
  14.  
  15. Submitted-by: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
  16. Posting-number: Volume 33, Issue 118
  17. Archive-name: u386mon/part09
  18. Environment: SYSVR3
  19. Supersedes: u386mon: Volume 22, Issue 3-9
  20.  
  21. #!/bin/sh
  22. # This is part 09 of u386mon.2.60
  23. # ============= siotools/uusnap.c ==============
  24. if test ! -d 'siotools'; then
  25.     echo 'x - creating directory siotools'
  26.     mkdir 'siotools'
  27. fi
  28. if test -f 'siotools/uusnap.c' -a X"$1" != X"-c"; then
  29.     echo 'x - skipping siotools/uusnap.c (File already exists)'
  30. else
  31. echo 'x - extracting siotools/uusnap.c (Text)'
  32. sed 's/^X//' << 'SHAR_EOF' > 'siotools/uusnap.c' &&
  33. X/* CHK=0x2504 */
  34. Xchar *revision = "2.01";
  35. X/*+-------------------------------------------------------------------------
  36. X    uusnap.c - display UUCP communications status for HDB systems
  37. X    ...gatech!kd4nc!n4hgf!wht
  38. X
  39. X  Many ideas in this program came from uustatus.c by Ed Carp
  40. X
  41. X  Defined functions:
  42. X    basename(fullname)
  43. X    bye(sig)
  44. X    datetime5(secs)
  45. X    detail()
  46. X    disp_cmd_legend(text)
  47. X    display_status(sysnum,system_name,y,status_info)
  48. X    display_tod()
  49. X    display_tty(sionum,tty)
  50. X    get_status_info(system_name,buf,bufsize)
  51. X    lockpid_to_tty(lockpid)
  52. X    main(argc,argv)
  53. X    my_resetty()
  54. X    my_savetty()
  55. X    spooldirname(fname)
  56. X    statdirname(fname)
  57. X    strcmpi(s1,s2)
  58. X    to_lower(ch)
  59. X    to_upper(ch)
  60. X
  61. XUnder XENIX, termio.h is included twice (once by curses.h/tcap.h and
  62. Xagain by sys/tty.h.  You need to bracket the termio.h under XENIX with
  63. X  #if !defined(TERMIO_HACK) || (defined(TERMIO_HACK) && !defined(IOCTYPE))
  64. X  ...
  65. X  #endif
  66. X
  67. XSample output:
  68. X
  69. Xuusnap 1.70 (UNIX V.3.2/i386) n4hgf                          19:28:26
  70. X
  71. X # SYSTEM    CALLS OUTQ INPQ LAST  NEXT  PID   STATUS
  72. X-- ------    ----- ---- ---- ----- ----- ----- ------------------------
  73. X 1 kd4nc        2    3       15:22 15:22       successful
  74. X 2 n4vu                      19:07 19:07       successful
  75. X 3 tridom                 1  19:17 19:17       TALKING (tty2e)
  76. X 4 ki4xo                     01/25 01/25       successful
  77. X
  78. X
  79. X Thanks to mpxenix!news (Randy Bush) for tireless help with a curses
  80. X bug hopefully now retired, even if it crockish.
  81. X--------------------------------------------------------------------------*/
  82. X/*+:EDITS:*/
  83. X/*:07-15-1992-14:33-wht@n4hgf-2.60 release - u386mon+siotools merge */
  84. X/*:06-25-1992-02:38-root@n4hgf-integrate with u386mon's nlsym */
  85. X/*:06-22-1992-13:28-wht@n4hgf-revisit for 3.2v4 */
  86. X/*:02-23-1990-17:10-wht-more keyboard problems with UNIX: try typeahead(-1) */
  87. X/*:02-18-1990-03:29-wht-bug in curses tty mode handling - force a fix */
  88. X/*:02-07-1990-16:34-wht-use crmode and nocrmode rather than raw and noraw */
  89. X/*:01-27-1990-19:11-wht-show input and output queues + cosmetics */
  90. X/*:12-28-1989-13:35-wht-change rev - B600 added to wintty */
  91. X/*:12-26-1989-14:53-wht-datetime5 month off by 1 */
  92. X/*:12-07-1989-03:10-wht-make changes per email suggestions */
  93. X/*:12-04-1989-16:45-wht-add detail in full */
  94. X/*:12-01-1989-16:53-wht-XENIX 286 work: no beep()! */
  95. X/*:11-30-1989-17:48-wht-complete rewrite to add detail status */
  96. X
  97. X#ifndef SYSV
  98. X#define SYSV
  99. X#endif
  100. X
  101. X#include <curses.h>
  102. X#include <ctype.h>
  103. X#include <memory.h>
  104. X#include <signal.h>
  105. X#include <time.h>
  106. X#include <sys/types.h>
  107. X#include <dirent.h>
  108. X#include <sys/stat.h>
  109. X#include <sys/tty.h>
  110. X#include <sys/utsname.h>
  111. X#if defined(M_SYSV)
  112. X#include <sys/select.h>
  113. X#else
  114. X#include <sys/time.h>
  115. X#endif
  116. X
  117. X#include "wintty.h"
  118. X#define DEFINE_TTYNM
  119. X#include "kmemsio.h"
  120. X#include "utoa.h"
  121. X
  122. X#define FIRSTSYS_Y    4
  123. X#define NAME_X        4
  124. X#define CALLS_X        14
  125. X#define OUTQ_X        19
  126. X#define INPQ_X        24
  127. X#define DTAQ_X        29
  128. X#define LAST_X        34
  129. X#define NEXT_X        40
  130. X#define PID_X        46
  131. X#define STATUS_X    52
  132. X
  133. X/* display_tty x offsets */
  134. X#define TX 0
  135. X#define RX 5
  136. X#define CX 10
  137. X#define OX 15
  138. X#define SX 22
  139. X#define FX 29
  140. X
  141. Xextern char _sobuf[];
  142. Xextern int errno;
  143. Xextern char *sys_errlist[];
  144. X
  145. XDIR *stat_dp;
  146. XDIR *work_dp;
  147. XDIR *uspool_dp;
  148. X
  149. Xlong secs_now;
  150. Xint systems;
  151. Xint no_tod = 0;
  152. Xchar sysnames[64 * 32];    /* sorta hack, but ka-plenty name space */
  153. Xchar locked_tty[16];
  154. Xchar bell = 7;
  155. X
  156. Xchar *STATUSDIR = "/usr/spool/uucp/.Status";
  157. Xchar *LOCKDIR = "/usr/spool/uucp/LCK..";
  158. Xchar *WORKDIR = "/usr/spool/uucp/";
  159. Xchar *SPOOLDIR = "/usr/spool/uucp";
  160. X
  161. X#define MAX_SYSTEMS (LINES - FIRSTSYS_Y - 4)
  162. X#define WAITSECS_ACTIVE 1 /* sleep secs between samples when talking */
  163. X#define WAITSECS_IDLE   7 /* sleep secs between samples when not talking */
  164. X
  165. X#define SS_OK                    0     /* successful */
  166. X#define SS_NO_DEVICE             1     /* no device */
  167. X#define SS_TIME_WRONG            2     /* wrong time to call */
  168. X#define SS_TALKING               3     /* TALKING */
  169. X#define SS_CONVERSATION          4     /* conversation failed */
  170. X#define SS_SEQBAD                5     /* bad sequence check */
  171. X#define SS_LOGIN_FAILED          6     /* login failed */
  172. X#define SS_DIAL_FAILED           7     /* dial failed */
  173. X#define SS_BAD_LOG_MCH           8     /* bad login/machine */
  174. X#define SS_LOCKED_DEVICE         9     /* DEVICE LOCKED */
  175. X#define SS_ASSERT_ERROR          10    /* assert error */
  176. X#define SS_BADSYSTEM             11    /* system not in Systems */
  177. X#define SS_CANT_ACCESS_DEVICE    12    /* can't access device */
  178. X#define SS_DEVICE_FAILED         13    /* device failed */
  179. X#define SS_WRONG_MCH             14    /* wrong machine name */
  180. X#define SS_CALLBACK              15    /* callback required */
  181. X#define SS_RLOCKED               16    /* remote has lock for me */
  182. X#define SS_RUNKNOWN              17    /* remote does not know me */
  183. X#define SS_RLOGIN                18    /* remote reject after login */
  184. X#define SS_UNKNOWN_RESPONSE      19    /* remote reject, unknown msg */
  185. X#define SS_STARTUP               20    /* startup failed */
  186. X#define SS_CHAT_FAILED           21    /* caller script failed */
  187. X#if defined(M_SYSV)
  188. X#define SS_CALL_IN_PROGRESS         22    /* CALL IN PROGRESS */
  189. X#define SS_CALL_FAILED           23    /* call failed (busy?) */
  190. X#else
  191. X#define SS_CALL_IN_PROGRESS         22    /* CALL IN PROGRESS */
  192. X#endif
  193. X
  194. Xstruct utsname me;
  195. Xint uucico_active;
  196. X
  197. Xchar *errortext[] = {
  198. X    /*       00000000001111111111222222 */
  199. X    /*       01234567890123456789012346 */
  200. X    /* 0 */ "successful",
  201. X    /* 1 */ "no device",
  202. X    /* 2 */ "wrong time to call",
  203. X    /* 3 */ "TALKING",
  204. X    /* 4 */ "conversation failed",
  205. X    /* 5 */ "bad sequence check",
  206. X    /* 6 */ "login failed",
  207. X    /* 7 */ "dial failed",
  208. X    /* 8 */ "bad login/machine",
  209. X    /* 9 */ "DEVICE LOCKED",
  210. X    /* 10*/ "assert error",
  211. X    /* 11*/ "system not in Systems",
  212. X    /* 12*/ "can't access device",
  213. X    /* 13*/ "device failed",
  214. X    /* 14*/ "wrong machine name",
  215. X    /* 15*/ "callback required",
  216. X    /* 16*/ "remote has lock for me",
  217. X    /* 17*/ "remote does not know me",
  218. X    /* 18*/ "remote reject after login",
  219. X    /* 19*/ "remote reject, unknown msg",
  220. X    /* 20*/ "startup failed",
  221. X    /* 21*/ "caller script failed",
  222. X#if defined(SYSV)
  223. X    /* 22*/ "CALL IN PROGRESS",
  224. X    /* 23*/ "call failed (busy?)",
  225. X#else
  226. X    /* 22*/ "CALL IN PROGRESS",
  227. X#endif
  228. X};
  229. X
  230. X#if defined(SYSV)
  231. X#define SS_MSG_MAX 23
  232. X#else
  233. X#define SS_MSG_MAX 22
  234. X#endif
  235. X
  236. X/*+-------------------------------------------------------------------------
  237. X    workaround curses tty handling difficulties among different revs
  238. X--------------------------------------------------------------------------*/
  239. Xstruct termio my_termio_crock;
  240. Xvoid my_savetty()    /* used in lieu of savetty() */
  241. X{
  242. X    ioctl(0,TCGETA,&my_termio_crock);
  243. X}
  244. Xvoid my_resetty()    /* used in lieu of resetty() and endwin() */
  245. X{
  246. X    ioctl(0,TCSETA,&my_termio_crock);
  247. X}
  248. X
  249. X/*+-------------------------------------------------------------------------
  250. X    datetime5(secs) - return 5 char date or time string
  251. X
  252. Xneeds global 'secs_now' to reflect current time in "seconds since epoch"
  253. X(done by display_tod()); returns 5 character 'mm/dd' if time now is more
  254. Xthan 12 hours before now or 12 hours from now
  255. X--------------------------------------------------------------------------*/
  256. Xchar *
  257. Xdatetime5(secs)
  258. Xlong secs;
  259. X{
  260. X    register long delta = secs_now - secs;
  261. X    struct tm *lt = localtime(&secs);
  262. X    static char dt5[8];
  263. X
  264. X    if(delta < 0)
  265. X        delta = -delta;
  266. X
  267. X    if(delta > (12L * 3600))
  268. X    {
  269. X        utoda_lz(dt5,2,lt->tm_mon + 1);
  270. X        dt5[2] = '/';
  271. X        utoda_lz(dt5 + 3,2,lt->tm_mday);
  272. X    }
  273. X    else
  274. X    {
  275. X        utoda_lz(dt5,2,lt->tm_hour);
  276. X        dt5[2] = ':';
  277. X        utoda_lz(dt5 + 3,2,lt->tm_min);
  278. X    }
  279. X
  280. X    return(dt5);
  281. X
  282. X}    /* end of datetime5 */
  283. X
  284. X/*+-------------------------------------------------------------------------
  285. X    basename(fullname) - strip directory name from filename
  286. X
  287. Xreturns address of static string
  288. X--------------------------------------------------------------------------*/
  289. Xchar *
  290. Xbasename(fullname)
  291. Xchar *fullname;
  292. X{
  293. X    register char *start;
  294. X    static char outstr[256];
  295. X    char *strrchr();
  296. X
  297. X    start = strrchr(fullname,'/'); /* find last slash */
  298. X    if(!start)
  299. X        return(fullname);
  300. X    start++;
  301. X    strcpy(outstr,start);
  302. X    return(outstr);
  303. X}    /* end of basename */
  304. X
  305. X/*+-------------------------------------------------------------------------
  306. X    statdirname(fname) - return base name prepended with status dir
  307. X
  308. Xreturns address of static string
  309. X--------------------------------------------------------------------------*/
  310. Xchar *
  311. Xstatdirname(fname)
  312. Xchar *fname;
  313. X{
  314. X    static char fullname[128];
  315. X    static int fullname_cat_point = 0;
  316. X
  317. X    if(!fullname_cat_point)
  318. X    {
  319. X        strcpy(fullname,STATUSDIR);
  320. X        strcat(fullname,"/");
  321. X        fullname_cat_point = strlen(fullname);
  322. X    }
  323. X
  324. X    strcpy(fullname + fullname_cat_point,fname);
  325. X    return(fullname);
  326. X
  327. X}    /* end of statdirname */
  328. X
  329. X/*+-------------------------------------------------------------------------
  330. X    spooldirname(fname) - return base name prepended with spool dir
  331. X
  332. Xreturns address of static string
  333. X--------------------------------------------------------------------------*/
  334. Xchar *
  335. Xspooldirname(fname)
  336. Xchar *fname;
  337. X{
  338. X    static char fullname[128];
  339. X    static int fullname_cat_point = 0;
  340. X
  341. X    if(!fullname_cat_point)
  342. X    {
  343. X        strcpy(fullname,SPOOLDIR);
  344. X        strcat(fullname,"/");
  345. X        fullname_cat_point = strlen(fullname);
  346. X    }
  347. X
  348. X    strcpy(fullname + fullname_cat_point,fname);
  349. X    return(fullname);
  350. X
  351. X}    /* end of statdirname */
  352. X
  353. X/*+-------------------------------------------------------------------------
  354. X    display_tod()
  355. X--------------------------------------------------------------------------*/
  356. Xvoid
  357. Xdisplay_tod()
  358. X{
  359. X    register struct tm *lt;        /* local time */
  360. X    struct tm *localtime();
  361. X    char buf[10];
  362. X
  363. X    (void)time(&secs_now);
  364. X
  365. X    if(no_tod)
  366. X        return;
  367. X
  368. X    lt = localtime(&secs_now);
  369. X    utoda_lz(buf,2,lt->tm_hour);
  370. X    buf[2] = ':';
  371. X    utoda_lz(buf + 3,2,lt->tm_min);
  372. X    buf[5] = ':';
  373. X    utoda_lz(buf + 6,2,lt->tm_sec);
  374. X    move(0,COLS - 18);
  375. X    addstr(buf);
  376. X
  377. X}    /* end of display_tod */
  378. X
  379. X/*+-------------------------------------------------------------------------
  380. X    bye(sig) - exit cleanly
  381. X--------------------------------------------------------------------------*/
  382. Xvoid
  383. Xbye(sig)
  384. Xint sig;
  385. X{
  386. X    if(stdscr)
  387. X    {
  388. X        standend();
  389. X        move(LINES - 1,0);
  390. X        clrtobot();
  391. X        refresh();
  392. X        echo();
  393. X        nocrmode();
  394. X        move(LINES - 1,0);
  395. X        refresh();
  396. X        my_resetty();
  397. X    }
  398. X    exit(0);
  399. X}    /* end of bye */
  400. X
  401. X/*+-------------------------------------------------------------------------
  402. X    lockpid_to_tty(lockpid) - given pid, find first ttyname it has locked
  403. X--------------------------------------------------------------------------*/
  404. Xchar *
  405. Xlockpid_to_tty(lockpid)
  406. Xint lockpid;
  407. X{
  408. X    struct dirent *dp;
  409. X    FILE *fp;
  410. X    int testpid;
  411. X    static char rtnname[32];
  412. X
  413. X    seekdir(uspool_dp,0);
  414. X    while(dp = readdir(uspool_dp))
  415. X    {
  416. X        if(strncmp(dp->d_name,"LCK..tty",8))
  417. X            continue;
  418. X        if(fp = fopen(spooldirname(dp->d_name),"r"))
  419. X        {
  420. X            fscanf(fp,"%d",&testpid);
  421. X            fclose(fp);
  422. X            if(testpid == lockpid)
  423. X            {
  424. X                strcpy(rtnname,dp->d_name + 5);
  425. X                return(rtnname);
  426. X            }
  427. X        }
  428. X    }
  429. X    return((char *)0);
  430. X
  431. X}    /* end of lockpid_to_tty */
  432. X
  433. X/*+-------------------------------------------------------------------------
  434. X    disp_cmd_legend(text)
  435. X--------------------------------------------------------------------------*/
  436. Xdisp_cmd_legend(text)
  437. Xchar *text;
  438. X{
  439. X    move(LINES - 2,0);
  440. X    clrtoeol();
  441. X
  442. X    if(!text)
  443. X    {
  444. X        addstr("Commands: ");
  445. X        standout();
  446. X        addstr("ESC");
  447. X        standend();
  448. X        addstr("/");
  449. X        standout();
  450. X        addstr("q");
  451. X        standend();
  452. X        addstr(" quit   ");
  453. X        standout();
  454. X        addstr("d");
  455. X        standend();
  456. X        addstr(" detail    ");
  457. X        standout();
  458. X        addstr("SPACE");
  459. X        standend();
  460. X        addstr(" immediate update");
  461. X    }
  462. X    else
  463. X        addstr(text);
  464. X
  465. X}    /* end of disp_cmd_legend */
  466. X
  467. X/*+-------------------------------------------------------------------------
  468. X    get_status_info(system_name,buf,bufsize)
  469. X--------------------------------------------------------------------------*/
  470. Xint
  471. Xget_status_info(system_name,buf,bufsize)
  472. Xchar *system_name;
  473. Xchar *buf;
  474. Xint bufsize;
  475. X{
  476. X    FILE *fp;
  477. X
  478. X    if(!(fp = fopen(statdirname(system_name),"r")))
  479. X        return(-1);
  480. X    buf[0] = 0;
  481. X    fgets(buf,bufsize,fp);
  482. X    fclose(fp);
  483. X    if(!buf[0])
  484. X        return(-1);
  485. X    buf[strlen(buf) - 1] = 0;
  486. X    return(0);
  487. X
  488. X}    /* end of get_status_info */
  489. X
  490. X/*+-------------------------------------------------------------------------
  491. X    display_status(sysnum,system_name,y,status_info)
  492. X
  493. Xcalled with status_info either .Status/<system_name> line or null
  494. Xif a tty is locked on the line, global locked_tty has "ttyxx"
  495. Xreturns -1 if status_info null and can't get it, else 0
  496. X--------------------------------------------------------------------------*/
  497. Xdisplay_status(sysnum,system_name,y,status_info)
  498. Xint sysnum;
  499. Xchar *system_name;
  500. Xint y;
  501. Xchar *status_info;
  502. X{
  503. X    int itmp;
  504. X    int retry_count;
  505. X    int status;
  506. X    int input_queue_count;
  507. X    int output_queue_count;
  508. X    int data_queue_count;
  509. X    char *stattxt;
  510. X    int locking_pid;
  511. X    char *ttyname;
  512. X    char lock_name[64];
  513. X    char s32[32];
  514. X    char work_dir[64];
  515. X    char linebuf[512];
  516. X    long secs_last_try;
  517. X    long secs_next_try;
  518. X    struct dirent *dp;
  519. X    FILE *fp;
  520. X
  521. X    if(!status_info)
  522. X    {
  523. X        status_info = linebuf;
  524. X        if(get_status_info(system_name,status_info,sizeof(linebuf)))
  525. X            return(-1);
  526. X    }
  527. X
  528. X    sscanf(status_info,"%d %d %ld %ld",
  529. X        &status,&retry_count,&secs_last_try,&secs_next_try);
  530. X    secs_next_try += secs_last_try;    /* files has secs til next retry */
  531. X
  532. X    strcpy(work_dir,WORKDIR);
  533. X    strcat(work_dir,system_name);
  534. X
  535. X    input_queue_count = 0;
  536. X    output_queue_count = 0;
  537. X    data_queue_count = 0;
  538. X
  539. X    if(work_dp = opendir(work_dir))
  540. X    {
  541. X        /* count the work files */
  542. X        while(dp = readdir(work_dp))
  543. X        {
  544. X            if(!strncmp(dp->d_name,"X.",2) && (input_queue_count <= 99))
  545. X                input_queue_count++;
  546. X            if(!strncmp(dp->d_name,"C.",2) && (output_queue_count <= 99))
  547. X                output_queue_count++;
  548. X            if(!strncmp(dp->d_name,"D.",2) && (data_queue_count <= 99))
  549. X                data_queue_count++;
  550. X            if((input_queue_count > 99) && (output_queue_count > 99))
  551. X                break;
  552. X        }
  553. X        closedir(work_dp);
  554. X    }
  555. X
  556. X    /* "kludges for screwy status stuff with HDB" thanks to Ed Carp */
  557. X    strcpy(lock_name,LOCKDIR);
  558. X    strcat(lock_name,system_name);
  559. X    if(!access(lock_name,0) && (status != SS_TALKING))
  560. X        status = SS_CALL_IN_PROGRESS;
  561. X#if 0/* not so sure about this one any more */
  562. X    if(status == SS_BADSYSTEM)
  563. X        status = SS_DEVICE_FAILED;
  564. X#endif
  565. X
  566. X    move(y,0);
  567. X    clrtoeol();
  568. X    utoda(s32,2,sysnum);
  569. X    addstr(s32);
  570. X    addch(' ');
  571. X
  572. X    strcpy(s32,system_name);
  573. X    if(strlen(s32) > 10)
  574. X        s32[10] = 0;
  575. X    addstr(s32);
  576. X
  577. X    move(y,CALLS_X);
  578. X    if(retry_count)
  579. X    {
  580. X        if(retry_count > 999)
  581. X            retry_count = 999;
  582. X        utoda(s32,3,retry_count);
  583. X        addstr(s32);
  584. X    }
  585. X    else
  586. X        addstr("   ");
  587. X
  588. X    move(y,INPQ_X);
  589. X    if(input_queue_count)
  590. X    {
  591. X        if(input_queue_count > 99)
  592. X            addstr(">99");
  593. X        else
  594. X        {
  595. X            utoda(s32,3,input_queue_count);
  596. X            addstr(s32);
  597. X        }
  598. X    }
  599. X    else
  600. X        addstr("   ");
  601. X
  602. X    move(y,OUTQ_X);
  603. X    if(output_queue_count)
  604. X    {
  605. X        if(output_queue_count > 99)
  606. X            addstr(">99");
  607. X        else
  608. X        {
  609. X            utoda(s32,3,output_queue_count);
  610. X            addstr(s32);
  611. X        }
  612. X    }
  613. X    else
  614. X        addstr("   ");
  615. X
  616. X    move(y,DTAQ_X);
  617. X    if(data_queue_count)
  618. X    {
  619. X        if(data_queue_count > 99)
  620. X            addstr(">99");
  621. X        else
  622. X        {
  623. X            utoda(s32,3,data_queue_count);
  624. X            addstr(s32);
  625. X        }
  626. X    }
  627. X    else
  628. X        addstr("   ");
  629. X
  630. X    move(y,LAST_X);
  631. X    addstr(datetime5(secs_last_try));
  632. X
  633. X    move(y,NEXT_X);
  634. X    addstr(datetime5(secs_next_try));
  635. X
  636. X    locking_pid = 0;
  637. X    memset(locked_tty,0,sizeof(locked_tty));
  638. X    move(y,PID_X);
  639. X    addstr("     ");
  640. X    ttyname = (char *)0;
  641. X    if( (status == SS_TALKING) ||
  642. X        (status == SS_LOCKED_DEVICE ) ||
  643. X        (status == SS_CALL_IN_PROGRESS))
  644. X    {
  645. X        uucico_active = 1;
  646. X        if(fp = fopen(lock_name,"r"))
  647. X        {
  648. X            fscanf(fp,"%d",&locking_pid);
  649. X            fclose(fp);
  650. X        }
  651. X        if(locking_pid)
  652. X        {
  653. X            strcpy(locked_tty,ttyname = lockpid_to_tty(locking_pid));
  654. X            move(y,PID_X);
  655. X            utoda(s32,5,locking_pid);
  656. X            addstr(s32);
  657. X        }
  658. X        standout();
  659. X    }
  660. X
  661. X    move(y,STATUS_X);
  662. X    if(status > SS_MSG_MAX)
  663. X    {
  664. X        stattxt = s32;
  665. X        strcpy(stattxt,"status ");
  666. X        utoda_lz(stattxt + 7,3,status);
  667. X    }
  668. X    else
  669. X        stattxt = errortext[status];
  670. X    addstr(stattxt);
  671. X    if(ttyname)
  672. X    {
  673. X        addstr(" (");
  674. X        addstr(ttyname);
  675. X        addch(')');
  676. X    }
  677. X    standend();
  678. X    itmp = 27 - strlen(stattxt);
  679. X    while(itmp--)
  680. X        addch(' ');
  681. X    return(0);
  682. X}    /* end of display_status */
  683. X
  684. X/*+-------------------------------------------------------------------------
  685. X    display_tty(sionum,tty)
  686. X--------------------------------------------------------------------------*/
  687. Xvoid
  688. Xdisplay_tty(sionum,tty)
  689. Xint sionum;
  690. Xregister struct tty *tty;
  691. X{
  692. X    register int x;
  693. X    register int y;
  694. X    register unsigned itmp;
  695. X    char s8[8];
  696. X
  697. X    clrtoeol();
  698. X    getyx(stdscr,y,x);
  699. X    move(y,TX + x);
  700. X    addstr(ttynm[sionum]);
  701. X    if((itmp = (unsigned)tty->t_rawq.c_cc) > 999)
  702. X        itmp = 999;
  703. X    utoda(s8,3,itmp);
  704. X    move(y,RX + x);
  705. X    if(itmp > 10)
  706. X        standout();
  707. X    addstr(s8);
  708. X    if(itmp > 10)
  709. X        standend();
  710. X
  711. X    if((itmp = (unsigned)tty->t_canq.c_cc) > 999)
  712. X        itmp = 999;
  713. X    utoda(s8,3,itmp);
  714. X    move(y,CX + x);
  715. X    addstr(s8);
  716. X
  717. X    if((itmp = (unsigned)tty->t_outq.c_cc + tty->t_tbuf.c_count) > 99999)
  718. X        itmp = 99999;
  719. X    utoda(s8,5,itmp);
  720. X    move(y,OX + x);
  721. X    addstr(s8);
  722. X
  723. X    move(y,SX + x);
  724. X    addstr(B_to_baud_rate(tty->t_cflag & CBAUD));
  725. X
  726. X    strcpy(s8,"     ");
  727. X    if(tty->t_state & WOPEN)
  728. X        s8[0] = 'W';
  729. X    else if(tty->t_state & ISOPEN)
  730. X        s8[0] = 'O';
  731. X    if(tty->t_state & CARR_ON)
  732. X        s8[1] = 'C';
  733. X    if(tty->t_state & BUSY)
  734. X        s8[2] = 'B';
  735. X    if(tty->t_state & TTSTOP)
  736. X        s8[3] = 'S';
  737. X    if(tty->t_state & TIMEOUT)
  738. X        s8[3] = 'D';
  739. X    move(y,FX + x);
  740. X    addstr(s8);
  741. X
  742. X    utooa(s8,7,tty->t_iflag);
  743. X    addstr(s8);
  744. X
  745. X    utooa(s8,7,tty->t_oflag);
  746. X    addstr(s8);
  747. X
  748. X    utooa(s8,7,tty->t_cflag);
  749. X    addstr(s8);
  750. X
  751. X    utooa(s8,7,tty->t_lflag);
  752. X    addstr(s8);
  753. X
  754. X    utoda(s8,6,tty->t_pgrp);
  755. X    addstr(s8);
  756. X
  757. X}    /* end of display_tty */
  758. X
  759. X#ifdef SIO_IS_FAS
  760. X#define  STRCMP strcmp
  761. X#else
  762. X#define  STRCMP strcmpi
  763. X/*+-------------------------------------------------------------------------
  764. X    to_upper() / to_lower()
  765. X
  766. XOne would think that these were relatively standard types of
  767. Xthing, but System V specifies toupper() to convert to upper case
  768. Xif not already and BSD says to adjust without testing, so, two
  769. Xstupid little routines here.  ASCII only -- no EBCDIC gradoo here please.
  770. X--------------------------------------------------------------------------*/
  771. Xchar to_upper(ch)
  772. Xregister char ch;
  773. X{ return( ((ch >= 'a') && (ch <= 'z')) ? ch - 0x20 : ch);
  774. X}   /* end of to_upper() */
  775. X
  776. Xchar to_lower(ch)
  777. Xregister char ch;
  778. X{ return( ((ch >= 'A') && (ch <= 'Z')) ? ch + 0x20 : ch);
  779. X}   /* end of to_lower() */
  780. X
  781. X/*+-------------------------------------------------------------------------
  782. X    strcmpi(s1,s2) - case-insensitive strcmp
  783. X
  784. XThis version of strcmp() is case-insensitive and works like a sane one
  785. Xshould, per strcmp(3), not per  the K&R1 example or POSIX/ANSI.
  786. X
  787. XIn here rather than ecuutil.c since other executables besides ecu
  788. Xuses this module and strcmpi needed there too 
  789. X--------------------------------------------------------------------------*/
  790. Xint
  791. Xstrcmpi(s1,s2)
  792. Xregister char *s1;
  793. Xregister char *s2;
  794. X{
  795. X
  796. X    while(*s1)
  797. X    {
  798. X        if(to_upper(*s1++) != to_upper(*s2++))
  799. X        {
  800. X            s1--;
  801. X            s2--;
  802. X            break;
  803. X        }
  804. X    }
  805. X    return(to_upper(*s1) - to_upper(*s2));
  806. X
  807. X}    /* end of strcmpi */
  808. X#endif /* SIO_IS_FAS */
  809. X
  810. X/*+-------------------------------------------------------------------------
  811. X    detail()
  812. X--------------------------------------------------------------------------*/
  813. Xvoid
  814. Xdetail()
  815. X{
  816. X    int y,x;
  817. X    int sysdetail = 0;
  818. X    int ttnum;
  819. X    int have_tty = 0;
  820. X    char *sysname;
  821. X    char *cptr;
  822. X    char **cpptr;
  823. X    char delim;
  824. X    char s8[8];
  825. X
  826. X    static char *header  =
  827. X    "tty  raw  can   out   speed  state iflag  oflag  cflag  lflag  pgrp";
  828. X    static char *hyphens =
  829. X    "---  ---  ---  -----  -----  ----- ------ ------ ------ ------ -----";
  830. X    static char *press_any_key =
  831. X    "press any key to return to main display  ";
  832. X    static char *state1 =
  833. X    "State: W waiting for open to complete  O open  C carrier on";
  834. X    static char *state2 =
  835. X    "       S stopped by XOFF  D delay timeout in progress  B transmitter busy";
  836. X    static kmem_initialized = 0;
  837. X
  838. X    disp_cmd_legend("display detail on system # (ESC to cancel): ");
  839. X    getyx(stdscr,y,x);
  840. X    if(wingets(stdscr,y,x,s8,3,&delim,0,(int *)0)< 0)
  841. X        goto SKIP_OUT;
  842. X    sysdetail = atoi(s8);
  843. X    sysdetail--;
  844. X    if(!x || ((unsigned)sysdetail > (unsigned)systems))
  845. X    {
  846. X        write(2,&bell,1);
  847. XSKIP_OUT:
  848. X        disp_cmd_legend((char *)0);
  849. X        refresh();
  850. X        return;
  851. X    }
  852. X
  853. X    if(!kmem_initialized)
  854. X    {
  855. X        standout();
  856. X        disp_cmd_legend(" Reading kernel symbol table ");
  857. X        standend();
  858. X        refresh();
  859. X        if(cptr = kmem_init_tty())
  860. X        {
  861. X            move(3,0);
  862. X            clrtoeol();
  863. X            standout();
  864. X            disp_cmd_legend(cptr);
  865. X            standend();
  866. X            bye(255);
  867. X        }
  868. X        kmem_initialized = 1;
  869. X    }
  870. X
  871. X    sysname = sysnames + (sysdetail << 4);
  872. X    y = FIRSTSYS_Y;
  873. X    move(y,0);
  874. X    clrtobot();
  875. X    disp_cmd_legend(press_any_key);
  876. X
  877. X    while(1)
  878. X    {
  879. X        display_tod();    /* display time and get 'secs_now' */
  880. X        if(display_status(sysdetail + 1,sysname,FIRSTSYS_Y,(char *)0))
  881. X        {
  882. X            move(y,0);
  883. X            standout();
  884. X            printw("cannot get status for %s",sysname);
  885. X            standend();
  886. X            clrtobot();
  887. X            disp_cmd_legend(press_any_key);
  888. X            goto DETAIL_SLEEP;
  889. X        }
  890. X
  891. X                            /* 00000 */
  892. X                            /* 01234 */
  893. X                            /* ttyxx */
  894. X        move(y+5,0);
  895. X
  896. X        if(locked_tty[0])
  897. X        {
  898. X            for(ttnum = 0,cpptr = ttynm; ttnum < SIO_NTTY; ttnum++,cpptr++)
  899. X            {
  900. X                if(!STRCMP(*cpptr,locked_tty + 3))
  901. X                    break;
  902. X            }
  903. X            if(ttnum == SIO_NTTY)
  904. X                goto NO_TTY;
  905. X        
  906. X            if(cptr = kmem_read_tty(ttnum,1))
  907. X            {
  908. X#ifdef SIO_IS_FAS
  909. XBAD_NEWS:
  910. X#endif
  911. X                standout();
  912. X                addstr(cptr);
  913. X                addstr(": ");
  914. X                addstr(locked_tty);
  915. X                standend();
  916. X                refresh();
  917. X                getch();
  918. X                goto DETAIL_EXIT;
  919. X            }
  920. X#ifdef SIO_IS_FAS
  921. X            if(!(sio[0].t_state & (WOPEN | ISOPEN)))
  922. X            {
  923. X                char other_tty[64];
  924. X                strcpy(other_tty,locked_tty);
  925. X                cptr = other_tty + strlen(other_tty) - 1;
  926. X                if(isupper(*cptr))
  927. X                    *cptr = tolower(*cptr);
  928. X                else if(islower(*cptr))
  929. X                    *cptr = toupper(*cptr);
  930. X                else
  931. X                    goto NO_TTY;
  932. X                for(ttnum = 0,cpptr = ttynm; ttnum < SIO_NTTY; ttnum++,cpptr++)
  933. X                {
  934. X                    if(!strcmp(*cpptr,other_tty + 3))
  935. X                        break;
  936. X                }
  937. X                if(ttnum == SIO_NTTY)
  938. X                    goto NO_TTY;
  939. X            
  940. X                if(cptr = kmem_read_tty(ttnum,1))
  941. X                    goto BAD_NEWS;
  942. X            }
  943. X#endif /* SIO_IS_FAS */
  944. X            if(!have_tty)
  945. X            {
  946. X                move(y+3,0);
  947. X                addstr(header);
  948. X                move(y+4,0);
  949. X                addstr(hyphens);
  950. X                move(y+7,0);
  951. X                addstr(state1);
  952. X                move(y+8,0);
  953. X                addstr(state2);
  954. X            }
  955. X            have_tty = 1;
  956. X            move(y+5,0);
  957. X            display_tty(ttnum,&sio[0]);
  958. X            wintty_template(stdscr,y+10,0,1);
  959. X            wintty(stdscr,y+10,0,&sio[0]);
  960. X            move(y+10,0);
  961. X        }
  962. X        else
  963. X        {
  964. XNO_TTY:
  965. X            move(y+3,0);
  966. X            clrtobot();
  967. X            move(y+5,0);
  968. X            printw(" no tty or non-async connection");
  969. X            disp_cmd_legend(press_any_key);
  970. X            have_tty = 0;
  971. X            wintty_template(stdscr,y+10,0,0);
  972. X            move(LINES - 1,0);
  973. X        }
  974. X
  975. XDETAIL_SLEEP:
  976. X        refresh();
  977. X        if(rdchk(0))
  978. X        {
  979. X            getch();
  980. X            break;
  981. X        }
  982. X        nap((have_tty) ? 20L : 500L);
  983. X    }
  984. X
  985. XDETAIL_EXIT:
  986. X    move(y = FIRSTSYS_Y,0);
  987. X    clrtobot();
  988. X    disp_cmd_legend((char *)0);
  989. X    refresh();
  990. X
  991. X}    /* end of detail */
  992. X
  993. X/*+-------------------------------------------------------------------------
  994. X    main(argc,argv)
  995. X--------------------------------------------------------------------------*/
  996. Xmain(argc,argv)
  997. Xint argc;
  998. Xchar **argv;
  999. X{
  1000. X    int display_delta_y;
  1001. X    char s32[32];
  1002. X    char linebuf[512];
  1003. X    char *sysname = "";
  1004. X    char *dirname = "";
  1005. X    char cmd;
  1006. X    FILE *fp;
  1007. X    struct dirent *dp;
  1008. X    int initializing = 1;
  1009. X#if defined(HAVE_SELECT)
  1010. X    struct timeval timeout;
  1011. X    int fdmask;
  1012. X#else
  1013. X    long timeout;
  1014. X#endif
  1015. X
  1016. X    if((argc > 1) && !strcmp(argv[1],"-n"))
  1017. X        no_tod = 1;
  1018. X
  1019. X    setbuf(stdout,_sobuf);
  1020. X
  1021. X    my_savetty();
  1022. X    if(!initscr())
  1023. X    {
  1024. X        fprintf(stderr,"curses init failed... check terminal type\n");
  1025. X        exit(0);
  1026. X    }
  1027. X#if defined(M_TERMINFO)
  1028. X    typeahead(-1);
  1029. X#endif
  1030. X    noecho();
  1031. X    crmode();
  1032. X
  1033. X    signal(SIGTERM,bye);
  1034. X    signal(SIGINT,bye);
  1035. X    signal(SIGHUP,bye);
  1036. X
  1037. X    uname(&me);
  1038. X    disp_cmd_legend((char *)0);
  1039. X
  1040. X    move(0,0);
  1041. X    standout();
  1042. X    printw(" uusnap %s (%s V.%s/%s)",
  1043. X        revision,
  1044. X#if defined(M_UNIX)
  1045. X        "UNIX",
  1046. X#else
  1047. X        "XENIX",
  1048. X#endif
  1049. X        me.release,me.machine);
  1050. X    if(fp = fopen("/etc/systemid","r"))
  1051. X    {
  1052. X        s32[0] = 0;
  1053. X        fgets(s32,sizeof(s32),fp);
  1054. X        if(s32[0])
  1055. X        {
  1056. X            s32[strlen(s32) - 1] = 0;
  1057. X            printw(" %s ",s32);
  1058. X        }
  1059. X        fclose(fp);
  1060. X    }
  1061. X    standend();
  1062. X
  1063. X
  1064. X    move(2,0);
  1065. X    addstr(
  1066. X" # SYSTEM    CALLS OUTQ INPQ DATA LAST  NEXT  PID   STATUS");
  1067. X    move(3,0);
  1068. X    addstr(
  1069. X"-- ------    ----- ---- ---- ---- ----- ----- ----- ------------------------");
  1070. X    move(4,0);
  1071. X    standout();
  1072. X    addstr(" initializing ");
  1073. X    standend();
  1074. X    refresh();
  1075. X
  1076. X    dirname = SPOOLDIR;
  1077. X    if(!(uspool_dp = opendir(dirname)))
  1078. X        goto BOO_HISS;
  1079. X
  1080. X    dirname = statdirname(".");
  1081. X    if(!(stat_dp = opendir(dirname)))
  1082. X    {
  1083. XBOO_HISS:
  1084. X        move(6,0);
  1085. X        printw("%s: %s",dirname,sys_errlist[errno]);
  1086. X        move(7,0);
  1087. X        addstr("I don't think HoneyDanBer UUCP is installed.");
  1088. X        bye(255);
  1089. X    }
  1090. X
  1091. X    while(1)
  1092. X    {
  1093. X        uucico_active = 0;        /* assume no uucico_active connections */
  1094. X        display_tod();    /* display time and get 'secs_now' */
  1095. X
  1096. X        seekdir(stat_dp,0);
  1097. X        display_delta_y = systems = 0;
  1098. X        move(FIRSTSYS_Y,0);
  1099. X        while(dp = readdir(stat_dp))
  1100. X        {
  1101. X            if(display_delta_y > MAX_SYSTEMS)
  1102. X                break;
  1103. X            if(*dp->d_name == '.')
  1104. X                continue;
  1105. X            if(get_status_info(dp->d_name,linebuf,sizeof(linebuf)))
  1106. X                continue;
  1107. X
  1108. X            sysname = sysnames + (systems++ << 4);
  1109. X            strcpy(sysname,dp->d_name);
  1110. X
  1111. X            if(initializing)
  1112. X            {
  1113. X                move(4,0);
  1114. X                addstr("              ");
  1115. X                initializing = 0;
  1116. X            }
  1117. X            display_status(systems,sysname,display_delta_y + FIRSTSYS_Y,
  1118. X                linebuf);
  1119. X            display_delta_y++;
  1120. X        }
  1121. X        while(display_delta_y < MAX_SYSTEMS)
  1122. X        {
  1123. X            move(display_delta_y++ + FIRSTSYS_Y,0);
  1124. X            clrtoeol();
  1125. X        }
  1126. X
  1127. X        if(initializing)
  1128. X        {
  1129. X            move(3,0);
  1130. X            addstr("              ");
  1131. X            initializing = 0;
  1132. X        }
  1133. X        move(LINES - 1,0);
  1134. X        refresh();
  1135. X
  1136. X#if defined(HAVE_SELECT)
  1137. X        timeout.tv_sec = (uucico_active) ? WAITSECS_ACTIVE : WAITSECS_IDLE;
  1138. X        timeout.tv_usec = 0;
  1139. X        fdmask = 1 << 0;
  1140. X        select(32,&fdmask,(int *)0,(int *)0,&timeout);
  1141. X#else
  1142. X        timeout = ((uucico_active) ? WAITSECS_ACTIVE : WAITSECS_IDLE) * 1000L;
  1143. X        while(timeout > 0)
  1144. X        {
  1145. X            timeout -= nap(200L);
  1146. X            if(rdchk(0))
  1147. X                break;
  1148. X        }
  1149. X#endif
  1150. X
  1151. X        if(rdchk(0))
  1152. X        {
  1153. X            read(0,&cmd,1);
  1154. X            cmd &= 0x7f;
  1155. X            switch(cmd &= 0x7f)
  1156. X            {
  1157. X                case 'q':
  1158. X                case 0x1B:
  1159. X                    bye(0);
  1160. X                case 'd':
  1161. X                    detail();
  1162. X                    break;
  1163. X                case ' ':
  1164. X                    break;
  1165. X                default:
  1166. X                    write(2,&bell,1);
  1167. X                    break;
  1168. X            }
  1169. X        }
  1170. X    }
  1171. X}    /* end of main */
  1172. X
  1173. X/* vi: set tabstop=4 shiftwidth=4: */
  1174. X/* end of uusnap.c */
  1175. SHAR_EOF
  1176. chmod 0644 siotools/uusnap.c ||
  1177. echo 'restore of siotools/uusnap.c failed'
  1178. Wc_c="`wc -c < 'siotools/uusnap.c'`"
  1179. test 25697 -eq "$Wc_c" ||
  1180.     echo 'siotools/uusnap.c: original size 25697, current size' "$Wc_c"
  1181. fi
  1182. # ============= siotools/wingets.c ==============
  1183. if test -f 'siotools/wingets.c' -a X"$1" != X"-c"; then
  1184.     echo 'x - skipping siotools/wingets.c (File already exists)'
  1185. else
  1186. echo 'x - extracting siotools/wingets.c (Text)'
  1187. sed 's/^X//' << 'SHAR_EOF' > 'siotools/wingets.c' &&
  1188. X/* CHK=0xF82A */
  1189. X/*+-------------------------------------------------------------------------
  1190. X    wingets.c - curses get string
  1191. X    wht@n4hgf.Mt-Park.GA.US
  1192. X
  1193. X  Defined functions:
  1194. X    clear_area_char(win,y,x,len,fillchar)
  1195. X    wingets(win,y,x,buf,bufsize,delim,edit,pwgpos)
  1196. X
  1197. X--------------------------------------------------------------------------*/
  1198. X/*+:EDITS:*/
  1199. X/*:07-15-1992-14:33-wht@n4hgf-2.60 release - u386mon+siotools merge */
  1200. X/*:06-22-1992-16:00-wht@n4hgf-creation */
  1201. X#ifndef SYSV
  1202. X#define SYSV
  1203. X#endif
  1204. X
  1205. X#include <curses.h>
  1206. X#include <string.h>
  1207. X#include <memory.h>
  1208. X
  1209. X#define mem_cpy memcpy    /* if ever executed, needs to avoid overlap */
  1210. X
  1211. X/*+-------------------------------------------------------------------------
  1212. X    clear_area_char(win,y,x,len,fillchar)
  1213. X--------------------------------------------------------------------------*/
  1214. Xvoid
  1215. Xclear_area_char(win,y,x,len,fillchar)
  1216. XWINDOW *win;
  1217. Xint y;
  1218. Xint x;
  1219. Xint len;
  1220. Xchar fillchar;
  1221. X{
  1222. X    wmove(win,y,x);
  1223. X    while(len-- > 0)
  1224. X        waddch(win,fillchar & 0xFF);
  1225. X    wmove(win,y,x);
  1226. X
  1227. X}    /* end of clear_area_char */
  1228. X
  1229. X/*+-------------------------------------------------------------------------
  1230. X    wingets(win,y,x,buf,bufsize,delim,edit,pwgpos)
  1231. X
  1232. XThis procedure reads a string from win and returns the number
  1233. Xof characters read.
  1234. X
  1235. XIf edit is non-zero and pwgpos is not null, the inital string
  1236. Xposition is set by dereferencing the pointer.
  1237. X
  1238. XThe terminating delim is returned in 'delim'.
  1239. X
  1240. XIf pwgpos is not null, the ending string position is returned in
  1241. Xthe integer pointed to.
  1242. X
  1243. X-1 is returned if an ESCape is typed by the keyboard user,
  1244. Xotherwise the count of characters in the string.
  1245. X
  1246. XThe entire line must be contained on one line (no line wrap supported).
  1247. X--------------------------------------------------------------------------*/
  1248. Xint
  1249. Xwingets(win,y,x,buf,bufsize,delim,edit,pwgpos)
  1250. XWINDOW *win;
  1251. Xint y;
  1252. Xregister x;
  1253. Xregister char *buf;
  1254. Xint bufsize;    /* includes room for null..field is 1 less */
  1255. Xchar *delim;
  1256. Xint edit;
  1257. Xint *pwgpos;
  1258. X{
  1259. X    register count = 0;
  1260. X    register pos = 0;
  1261. X    int insert_mode = 0;
  1262. X    int rtn_val = 0;
  1263. X    char bell = 7;
  1264. X
  1265. X    bufsize--;
  1266. X    clear_area_char(win,y,x,bufsize,'_');
  1267. X    if(edit)
  1268. X    {
  1269. X        waddstr(win,buf);
  1270. X        count = pos = strlen(buf);
  1271. X        if(pwgpos)
  1272. X        {
  1273. X            pos = *pwgpos;
  1274. X            if((pos < 0) || (pos > count))
  1275. X                pos = count;
  1276. X        }
  1277. X    }
  1278. X    else
  1279. X        *buf = 0;
  1280. X    wmove(win,y,x + pos);
  1281. X
  1282. X    while(1)
  1283. X    {
  1284. X        wrefresh(win);
  1285. X        read(0,delim,1);
  1286. X        *delim &= 0x7F;
  1287. X        if((*delim < 0x20) || (*delim >= 0x7F))
  1288. X        {
  1289. X            switch(*delim)
  1290. X            {
  1291. X                case 0x0D:
  1292. X                    *delim = 0x0A;;
  1293. X                case 0x0A:
  1294. X                    wrefresh(win);
  1295. X                    rtn_val = count;
  1296. X                    goto RETURN;
  1297. X
  1298. X                case 0x08:
  1299. X                    if(count)
  1300. X                    {
  1301. X                        if(count == pos)
  1302. X                        {
  1303. X                            *(buf + --count) = 0;
  1304. X                            wmove(win,y,x + count);
  1305. X                            waddch(win,'_');
  1306. X                            wmove(win,y,x + count);
  1307. X                            pos--;
  1308. X                        }
  1309. X                        else
  1310. X                        {
  1311. X                            if(!pos)
  1312. X                                continue;
  1313. X                            mem_cpy(buf + pos - 1,buf + pos,count - pos);
  1314. X                            *(buf + --count) = 0;
  1315. X                            wmove(win,y,x + --pos);
  1316. X                            waddstr(win,buf + pos);
  1317. X                            waddch(win,'_');
  1318. X                            wmove(win,y,x + pos);
  1319. X                        }
  1320. X                    }
  1321. X                    continue;
  1322. X
  1323. X                case 0x1B:
  1324. X                    rtn_val = -1;
  1325. X                    goto RETURN;
  1326. X
  1327. X                case 'U' & 0x1F:
  1328. X                    clear_area_char(win,y,x,bufsize,'_');
  1329. X                    count = 0;
  1330. X                    pos = 0;
  1331. X                    *buf = 0;
  1332. X                    continue;
  1333. X
  1334. X                default:
  1335. X                    write(2,&bell,1);
  1336. X                    continue;
  1337. X
  1338. X            }    /* end of switch(*delim) */
  1339. X            /*NOTREACHED*/
  1340. X        }        /* end of if read delimiter */
  1341. X
  1342. X        if(count == bufsize)
  1343. X        {
  1344. X            write(2,&bell,1);
  1345. X            continue;
  1346. X        }
  1347. X
  1348. X        if(insert_mode && (pos != count))
  1349. X        {
  1350. X            waddch(win,*delim);
  1351. X            waddstr(win,buf + pos);
  1352. X            mem_cpy(buf + pos + 1,buf + pos,count - pos);
  1353. X            *(buf + pos++) = *delim;
  1354. X            *(buf + ++count) = 0;
  1355. X            wmove(win,y,x + pos);
  1356. X        }
  1357. X        else
  1358. X        {
  1359. X            waddch(win,*delim);
  1360. X            *(buf + pos) = *delim;
  1361. X            if(pos == count)
  1362. X                *(buf + ++count) = 0;
  1363. X            pos++;
  1364. X        }
  1365. X    }    /* end of while can get character */
  1366. X
  1367. XRETURN:
  1368. X    if(pwgpos)
  1369. X        *pwgpos = pos;
  1370. X    return(rtn_val);
  1371. X
  1372. X}    /* end of wingets */
  1373. X
  1374. X/* vi: set tabstop=4 shiftwidth=4: */
  1375. X/* end of wingets.c */
  1376. SHAR_EOF
  1377. chmod 0644 siotools/wingets.c ||
  1378. echo 'restore of siotools/wingets.c failed'
  1379. Wc_c="`wc -c < 'siotools/wingets.c'`"
  1380. test 3933 -eq "$Wc_c" ||
  1381.     echo 'siotools/wingets.c: original size 3933, current size' "$Wc_c"
  1382. fi
  1383. # ============= siotools/wintio.c ==============
  1384. if test -f 'siotools/wintio.c' -a X"$1" != X"-c"; then
  1385.     echo 'x - skipping siotools/wintio.c (File already exists)'
  1386. else
  1387. echo 'x - extracting siotools/wintio.c (Text)'
  1388. sed 's/^X//' << 'SHAR_EOF' > 'siotools/wintio.c' &&
  1389. X/* CHK=0xC37E */
  1390. X/*+-------------------------------------------------------------------------
  1391. X    wintio.c - struct ermio curses display
  1392. X    ...!gatech!emory!tridom!wht
  1393. X
  1394. X000000000011111111112222222222333333333344444444445555555555666666666677777
  1395. X012345678901234567890123456789012345678901234567890123456789012345678901234
  1396. Xiflag: IGNBRK  BRKINT  IGNPAR  PARMRK  INPCK  ISTRIP INLCR  IGNCR   ICRNL
  1397. X       IUCLC   IXON    IXOFF   IXANY
  1398. Xoflag: OPOST   OLCUC   ONLCR   OCRNL   ONOCR  ONLRET OFDEL
  1399. Xcflag: 09600-8-N-1     CREAD   HUPCL   CLOCAL RTSFLO CTSFLO 
  1400. Xlflag: ISIG    ICANON  XCASE   ECHO    ECHOE  ECHOK  ECHONL NOFLSH  XCLUDE
  1401. X       INTR QUIT ERASE KILL EOF/VMIN  EOL/VTIME EOL2 SWTCH 
  1402. Xcc:     03   1c   08    15    01        00       00   00   
  1403. X
  1404. X  Defined functions:
  1405. X    B_to_baud_rate(code)
  1406. X    cflag_to_baud_d_p_s(cflag)
  1407. X    wintio(win,tly,tlx,tio)
  1408. X    wintio_template(win,tly,tlx)
  1409. X
  1410. X--------------------------------------------------------------------------*/
  1411. X/*+:EDITS:*/
  1412. X/*:07-15-1992-14:33-wht@n4hgf-2.60 release - u386mon+siotools merge */
  1413. X/*:12-28-1989-13:35-wht-B600 added */
  1414. X/*:12-21-1989-15:18-wht-display CTSFLOW and RTSFLOW if defined */
  1415. X/*:12-04-1989-13:43-wht-creation */
  1416. X
  1417. X#ifndef SYSV
  1418. X#define SYSV
  1419. X#endif
  1420. X
  1421. X#include <curses.h>
  1422. X#if !defined(CLOCAL)
  1423. X#include <termio.h>
  1424. X#endif
  1425. X#include "wintio.h"
  1426. X
  1427. Xtypedef struct slabel
  1428. X{
  1429. X    int y,x;
  1430. X    char *label;
  1431. X} SLABEL;
  1432. X
  1433. XSLABEL tio_slabels[] =
  1434. X{
  1435. X    {  0,  0, "iflag:" },
  1436. X    {  2,  0, "oflag:" },
  1437. X    {  3,  0, "cflag:" },
  1438. X    {  4,  0, "lflag:" },
  1439. X    {  5,  7, "INTR QUIT ERASE KILL EOF/VMIN  EOL/VTIME EOL2 SWTCH" },
  1440. X    {  6,  0, "cc:" },
  1441. X    {  -1,-1, (char *)0}
  1442. X};
  1443. X
  1444. Xtypedef struct tfield
  1445. X{
  1446. X    int y,x;
  1447. X    char *label;
  1448. X    int flag_num;
  1449. X    int mask;
  1450. X} TFIELD;
  1451. X
  1452. X#define IFLAG 1
  1453. X#define OFLAG 2
  1454. X#define LFLAG 3
  1455. X#define CFLAG 4
  1456. X
  1457. XTFIELD tio_tfields[] =
  1458. X{
  1459. X    {  0,  7, "IGNBRK", IFLAG, IGNBRK },
  1460. X    {  0, 15, "BRKINT", IFLAG, BRKINT },
  1461. X    {  0, 23, "IGNPAR", IFLAG, IGNPAR },
  1462. X    {  0, 31, "PARMRK", IFLAG, PARMRK },
  1463. X    {  0, 39, "INPCK",  IFLAG, INPCK },
  1464. X    {  0, 46, "ISTRIP", IFLAG, ISTRIP },
  1465. X    {  0, 53, "INLCR",  IFLAG, INLCR },
  1466. X    {  0, 60, "IGNCR",  IFLAG, IGNCR },
  1467. X    {  0, 68, "ICRNL",  IFLAG, ICRNL },
  1468. X    {  1,  7, "IUCLC",  IFLAG, IUCLC },
  1469. X    {  1, 15, "IXON",   IFLAG, IXON },
  1470. X    {  1, 23, "IXOFF",  IFLAG, IXOFF },
  1471. X    {  1, 31, "IXANY",  IFLAG, IXANY },
  1472. X    {  2,  7, "OPOST",  OFLAG, OPOST },
  1473. X    {  2, 15, "OLCUC",  OFLAG, OLCUC },
  1474. X    {  2, 23, "ONLCR",  OFLAG, ONLCR },
  1475. X    {  2, 31, "OCRNL",  OFLAG, OCRNL },
  1476. X    {  2, 39, "ONOCR",  OFLAG, ONOCR },
  1477. X    {  2, 46, "ONLRET", OFLAG, ONLRET },
  1478. X    {  2, 53, "OFDEL",  OFLAG, OFDEL },
  1479. X    {  3, 23, "CREAD",  CFLAG, CREAD },
  1480. X    {  3, 31, "HUPCL",  CFLAG, HUPCL },
  1481. X    {  3, 39, "CLOCAL", CFLAG, CLOCAL },
  1482. X#ifdef RTSFLOW
  1483. X    {  3, 46, "RTSFLO", CFLAG, RTSFLOW },
  1484. X#endif
  1485. X#ifdef CTSFLOW
  1486. X    {  3, 53, "CTSFLO", CFLAG, CTSFLOW },
  1487. X#endif
  1488. X    {  4,  7, "ISIG",   LFLAG, ISIG },
  1489. X    {  4, 15, "ICANON", LFLAG, ICANON },
  1490. X    {  4, 23, "XCASE",  LFLAG, XCASE },
  1491. X    {  4, 31, "ECHO",   LFLAG, ECHO },
  1492. X    {  4, 39, "ECHOE",  LFLAG, ECHOE },
  1493. X    {  4, 46, "ECHOK",  LFLAG, ECHOK },
  1494. X    {  4, 53, "ECHONL", LFLAG, ECHONL },
  1495. X    {  4, 60, "NOFLSH", LFLAG, NOFLSH },
  1496. X    {  4, 68, "XCLUDE", LFLAG, XCLUDE },
  1497. X    { -1, -1, (char *)0,    -1,    -1 }
  1498. X};
  1499. X
  1500. Xtypedef struct fcursor
  1501. X{
  1502. X    int y,x;
  1503. X} FCURSOR;
  1504. X
  1505. XFCURSOR tio_fcursors[] =
  1506. X{
  1507. X#define Fc_intr       0
  1508. X    {  6,  8 },
  1509. X#define Fcc_quit      1
  1510. X    {  6, 13 },
  1511. X#define Fcc_erase     2
  1512. X    {  6, 18 },
  1513. X#define Fcc_kill      3
  1514. X    {  6, 24 },
  1515. X#define Fcc_eof       4
  1516. X    {  6, 30 },
  1517. X#define Fcc_eol       5
  1518. X    {  6, 40 },
  1519. X#define Fcc_eol2      6
  1520. X    {  6, 49 },
  1521. X#define Fcc_swtch     7
  1522. X    {  6, 54 },
  1523. X#define Fbaud_b_p_s   8
  1524. X    {  3,  7 }
  1525. X};
  1526. X
  1527. Xtypedef struct b_to_br
  1528. X{
  1529. X    char *baud_rate;
  1530. X    int B_code;
  1531. X} B_TO_BR;
  1532. X
  1533. XB_TO_BR speeds[] =     /* ordered to put less common rates later in table */
  1534. X{                    /* and the vagaries of baud rates above 9600 "handled" */
  1535. X    " 2400",    B2400,
  1536. X    " 1200",    B1200,
  1537. X    " 9600",    B9600,
  1538. X#if defined(B19200)
  1539. X    "19200",    B19200,
  1540. X#endif
  1541. X#if defined(B38400)
  1542. X    "38400",    B38400,
  1543. X#endif
  1544. X    " 4800",    B4800,
  1545. X    "  300",    B300,
  1546. X    "  110",    B110,
  1547. X    "  600",    B600,
  1548. X    "   75",    B75,
  1549. X    "   50",    B50,
  1550. X    "  HUP",    B0,
  1551. X    " EXTA",    EXTA,
  1552. X    " EXTB",    EXTB,
  1553. X
  1554. X    (char *)0,0
  1555. X};
  1556. X
  1557. X/*+-------------------------------------------------------------------------
  1558. X    B_to_baud_rate(code) - convert CBAUD B_ code to baud rate string
  1559. X--------------------------------------------------------------------------*/
  1560. Xchar *
  1561. XB_to_baud_rate(code)
  1562. X{
  1563. Xregister int n;
  1564. X
  1565. X    for(n=0; speeds[n].baud_rate; n++)
  1566. X        if(speeds[n].B_code == code)
  1567. X            return(speeds[n].baud_rate);
  1568. X    return("-----");
  1569. X}    /* end of B_to_baud_rate */
  1570. X
  1571. X/*+-------------------------------------------------------------------------
  1572. X    cflag_to_baud_d_p_s(cflag)
  1573. X--------------------------------------------------------------------------*/
  1574. Xchar *
  1575. Xcflag_to_baud_d_p_s(cflag)
  1576. Xint cflag;
  1577. X{
  1578. Xregister char * cptr;
  1579. Xstatic char rtnstr[16];
  1580. X
  1581. X    strcpy(rtnstr,B_to_baud_rate(cflag & CBAUD));
  1582. X    cptr = rtnstr + strlen(rtnstr);
  1583. X    *cptr++ = '-';
  1584. X    switch(cflag & CSIZE)
  1585. X    {
  1586. X        case CS5: *cptr++ = '5'; break;
  1587. X        case CS6: *cptr++ = '6'; break;
  1588. X        case CS7: *cptr++ = '7'; break;
  1589. X        case CS8: *cptr++ = '8'; break;
  1590. X    }
  1591. X    *cptr++ = '-';
  1592. X    *cptr++ = (cflag & PARENB) ? ((cflag & PARODD) ? 'O' : 'E') : 'N';
  1593. X    *cptr++ = '-';
  1594. X    *cptr++ = (cflag & CSTOPB) ? '2' : '1';
  1595. X    *cptr = 0;
  1596. X    return(rtnstr);
  1597. X
  1598. X}    /* end of cflag_to_baud_d_p_s */
  1599. X
  1600. X/*+-----------------------------------------------------------------------
  1601. X    wintio(win,tly,tlx,tio)
  1602. X------------------------------------------------------------------------*/
  1603. Xvoid
  1604. Xwintio(win,tly,tlx,tio)
  1605. XWINDOW *win;
  1606. Xint tly;
  1607. Xint tlx;
  1608. Xstruct termio *tio;
  1609. X{
  1610. Xregister flag;
  1611. Xregister i_cc;
  1612. Xregister char *cptr;
  1613. XTFIELD *tptr = tio_tfields;
  1614. XFCURSOR *fptr = tio_fcursors;
  1615. X
  1616. X    while(tptr->y >= 0)
  1617. X    {
  1618. X        switch(tptr->flag_num)
  1619. X        {
  1620. X            case IFLAG: flag = tio->c_iflag; break;
  1621. X            case OFLAG: flag = tio->c_oflag; break;
  1622. X            case LFLAG: flag = tio->c_lflag; break;
  1623. X            case CFLAG: flag = tio->c_cflag; break;
  1624. X        }
  1625. X        flag &= tptr->mask;
  1626. X        wmove(win,tptr->y + tly,tptr->x + tlx);
  1627. X        if(flag)
  1628. X            wstandout(win);
  1629. X        waddstr(win,tptr->label);
  1630. X        if(flag)
  1631. X            wstandend(win);
  1632. X        tptr++;
  1633. X    }
  1634. X    for(i_cc = 0; i_cc < NCC; i_cc++)
  1635. X    {
  1636. X        wmove(win,fptr->y + tly,fptr->x + tlx);
  1637. X        wprintw(win,"%02x",tio->c_cc[i_cc]);
  1638. X        fptr++;
  1639. X    }
  1640. X
  1641. X    fptr = &tio_fcursors[Fbaud_b_p_s];
  1642. X    wmove(win,fptr->y + tly,fptr->x + tlx);
  1643. X    waddstr(win,"           ");
  1644. X    wmove(win,fptr->y + tly,fptr->x + tlx);
  1645. X    waddstr(win,cflag_to_baud_d_p_s(tioi->c_cflag));
  1646. X
  1647. X}    /* end of wintio */
  1648. X
  1649. X/*+-------------------------------------------------------------------------
  1650. X    wintio_template(win,tly,tlx)
  1651. X--------------------------------------------------------------------------*/
  1652. Xvoid
  1653. Xwintio_template(win,tly,tlx)
  1654. XWINDOW *win;
  1655. Xint tly;
  1656. Xint tlx;
  1657. X{
  1658. Xregister y;
  1659. XSLABEL *sptr = tio_slabels;
  1660. X
  1661. X    for(y = 0; y < 7; y++)
  1662. X    {
  1663. X        wmove(win,tly + y,0);
  1664. X        wclrtoeol(win);
  1665. X    }
  1666. X    while(sptr->y >= 0)
  1667. X    {
  1668. X        wmove(win,sptr->y + tly,sptr->x + tlx);
  1669. X        waddstr(win,sptr->label);
  1670. X        sptr++;
  1671. X    }
  1672. X
  1673. X}    /* end of wintio_template */
  1674. X
  1675. X/* vi: set tabstop=4 shiftwidth=4: */
  1676. X/* end of wintio.c */
  1677. SHAR_EOF
  1678. chmod 0644 siotools/wintio.c ||
  1679. echo 'restore of siotools/wintio.c failed'
  1680. Wc_c="`wc -c < 'siotools/wintio.c'`"
  1681. test 6995 -eq "$Wc_c" ||
  1682.     echo 'siotools/wintio.c: original size 6995, current size' "$Wc_c"
  1683. fi
  1684. # ============= siotools/wintio.h ==============
  1685. if test -f 'siotools/wintio.h' -a X"$1" != X"-c"; then
  1686.     echo 'x - skipping siotools/wintio.h (File already exists)'
  1687. else
  1688. echo 'x - extracting siotools/wintio.h (Text)'
  1689. sed 's/^X//' << 'SHAR_EOF' > 'siotools/wintio.h' &&
  1690. X/* CHK=0x3BC6 */
  1691. X/*+-----------------------------------------------------------------------
  1692. X    wintio.h
  1693. X------------------------------------------------------------------------*/
  1694. X/*+:EDITS:*/
  1695. X/*:07-15-1992-14:33-wht@n4hgf-2.60 release - u386mon+siotools merge */
  1696. X/*:12-04-1989-16:51-afterlint-creation */
  1697. X
  1698. X#ifndef _wintio_h
  1699. X#define _wintio_h
  1700. X
  1701. X#ifndef BUILDING_LINT_ARGS
  1702. X#ifdef LINT_ARGS
  1703. X
  1704. X/* wintio.c */
  1705. Xchar *B_to_baud_rate(int );
  1706. Xchar *cflag_to_baud_d_p_s(int );
  1707. Xvoid wintio(struct _win_st *,int ,int ,struct termio *);
  1708. Xvoid wintio_template(struct _win_st *,int ,int );
  1709. X
  1710. X#else        /* compiler doesn't know about prototyping */
  1711. X
  1712. X/* wintio.c */
  1713. Xchar *B_to_baud_rate();
  1714. Xchar *cflag_to_baud_d_p_s();
  1715. Xvoid wintio();
  1716. Xvoid wintio_template();
  1717. X
  1718. X#endif /* LINT_ARGS */
  1719. X#endif /* BUILDING_LINT_ARGS */
  1720. X#endif /* _wintio_h */
  1721. X
  1722. X/* vi: set tabstop=4 shiftwidth=4: */
  1723. X/* end of wintio.h */
  1724. SHAR_EOF
  1725. chmod 0644 siotools/wintio.h ||
  1726. echo 'restore of siotools/wintio.h failed'
  1727. Wc_c="`wc -c < 'siotools/wintio.h'`"
  1728. test 871 -eq "$Wc_c" ||
  1729.     echo 'siotools/wintio.h: original size 871, current size' "$Wc_c"
  1730. fi
  1731. # ============= siotools/wintty.c ==============
  1732. if test -f 'siotools/wintty.c' -a X"$1" != X"-c"; then
  1733.     echo 'x - skipping siotools/wintty.c (File already exists)'
  1734. else
  1735. echo 'x - extracting siotools/wintty.c (Text)'
  1736. sed 's/^X//' << 'SHAR_EOF' > 'siotools/wintty.c' &&
  1737. X/* CHK=0xCAD9 */
  1738. X/*+-------------------------------------------------------------------------
  1739. X    wintty.c - kernel struct tty curses display
  1740. X    wht@n4hgf.Mt-Park.GA.US
  1741. X
  1742. X000000000011111111112222222222333333333344444444445555555555666666666677777
  1743. X012345678901234567890123456789012345678901234567890123456789012345678901234
  1744. Xiflag: IGNBRK  BRKINT  IGNPAR  PARMRK  INPCK  ISTRIP INLCR  IGNCR   ICRNL
  1745. X       IUCLC   IXON    IXOFF   IXANY
  1746. Xoflag: OPOST   OLCUC   ONLCR   OCRNL   ONOCR  ONLRET OFDEL
  1747. Xcflag: 09600-8-N-1     CREAD   HUPCL   CLOCAL
  1748. Xlflag: ISIG    ICANON  XCASE   ECHO    ECHOE  ECHOK  ECHONL NOFLSH  XCLUDE
  1749. X       INTR QUIT ERASE KILL EOF/VMIN  EOL/VTIME EOL2 SWTCH 
  1750. Xcc:     03   1c   08    15    01        00       00   00   
  1751. X
  1752. X  Defined functions:
  1753. X    B_to_baud_rate(code)
  1754. X    cflag_to_baud_d_p_s(cflag)
  1755. X    wintty(win,tly,tlx,tty)
  1756. X    wintty_template(win,tly,tlx,show_flag)
  1757. X
  1758. X--------------------------------------------------------------------------*/
  1759. X/*+:EDITS:*/
  1760. X/*:07-15-1992-14:33-wht@n4hgf-2.60 release - u386mon+siotools merge */
  1761. X/*:01-29-1990-02:45-wht-add t_state display */
  1762. X/*:12-28-1989-13:35-wht-B600 added */
  1763. X/*:12-21-1989-15:18-wht-display CTSFLOW and RTSFLOW if defined */
  1764. X/*:12-04-1989-15:40-wht-creation */
  1765. X
  1766. X#ifndef SYSV
  1767. X#define SYSV
  1768. X#endif
  1769. X
  1770. X#include <curses.h>
  1771. X#ifndef TCSETA    /* 3.2v4 curses.h does not include termio.h */
  1772. X#undef NL1        /* in case sgtty.h was included */
  1773. X#undef CR1
  1774. X#undef CR2
  1775. X#undef CR3
  1776. X#undef TAB1
  1777. X#undef BS1
  1778. X#undef FF1
  1779. X#undef B50
  1780. X#undef B75
  1781. X#undef B110
  1782. X#undef B134
  1783. X#undef B150
  1784. X#undef B200
  1785. X#undef B300
  1786. X#undef B600
  1787. X#undef B1200
  1788. X#undef B1800
  1789. X#undef B2400
  1790. X#undef B4800
  1791. X#undef B9600
  1792. X#undef EXTA
  1793. X#undef EXTB
  1794. X#undef HUPCL
  1795. X#undef ECHO
  1796. X#undef TIOCHPCL
  1797. X#undef TIOCEXCL
  1798. X#undef TIOCNXCL
  1799. X#include <termio.h>
  1800. X#endif
  1801. X#include <sys/types.h>
  1802. X#include <sys/tty.h>
  1803. X#include "wintty.h"
  1804. X
  1805. Xtypedef struct slabel {
  1806. X    int y,x;
  1807. X    char *label;
  1808. X} SLABEL;
  1809. X
  1810. XSLABEL tty_slabels[] = {
  1811. X    {  0,  0, "iflag:" },
  1812. X    {  2,  0, "oflag:" },
  1813. X    {  3,  0, "cflag:" },
  1814. X    {  4,  0, "lflag:" },
  1815. X    {  5,  7, "INTR QUIT ERASE KILL EOF/VMIN  EOL/VTIME EOL2 SWTCH" },
  1816. X    {  6,  0, "cc:" },
  1817. X    {  7,  0, "state:" },
  1818. X    {  -1,-1, (char *)0}
  1819. X};
  1820. X
  1821. Xtypedef struct tfield {
  1822. X    int y,x;
  1823. X    char *label;
  1824. X    int flag_num;
  1825. X    int mask;
  1826. X} TFIELD;
  1827. X
  1828. X#define IFLAG 1
  1829. X#define OFLAG 2
  1830. X#define LFLAG 3
  1831. X#define CFLAG 4
  1832. X#define STATE 5
  1833. X
  1834. XTFIELD tty_tfields[] = {
  1835. X    {  0,  7, "IGNBRK", IFLAG, IGNBRK },
  1836. X    {  0, 15, "BRKINT", IFLAG, BRKINT },
  1837. X    {  0, 23, "IGNPAR", IFLAG, IGNPAR },
  1838. X    {  0, 31, "PARMRK", IFLAG, PARMRK },
  1839. X    {  0, 39, "INPCK",  IFLAG, INPCK },
  1840. X    {  0, 46, "ISTRIP", IFLAG, ISTRIP },
  1841. X    {  0, 53, "INLCR",  IFLAG, INLCR },
  1842. X    {  0, 60, "IGNCR",  IFLAG, IGNCR },
  1843. X    {  0, 68, "ICRNL",  IFLAG, ICRNL },
  1844. X    {  1,  7, "IUCLC",  IFLAG, IUCLC },
  1845. X    {  1, 15, "IXON",   IFLAG, IXON },
  1846. X    {  1, 23, "IXOFF",  IFLAG, IXOFF },
  1847. X    {  1, 31, "IXANY",  IFLAG, IXANY },
  1848. X    {  2,  7, "OPOST",  OFLAG, OPOST },
  1849. X    {  2, 15, "OLCUC",  OFLAG, OLCUC },
  1850. X    {  2, 23, "ONLCR",  OFLAG, ONLCR },
  1851. X    {  2, 31, "OCRNL",  OFLAG, OCRNL },
  1852. X    {  2, 39, "ONOCR",  OFLAG, ONOCR },
  1853. X    {  2, 46, "ONLRET", OFLAG, ONLRET },
  1854. X    {  2, 53, "OFDEL",  OFLAG, OFDEL },
  1855. X    {  3, 23, "CREAD",  CFLAG, CREAD },
  1856. X    {  3, 31, "HUPCL",  CFLAG, HUPCL },
  1857. X    {  3, 39, "CLOCAL", CFLAG, CLOCAL },
  1858. X#ifdef RTSFLOW
  1859. X    {  3, 46, "RTSFLO", CFLAG, RTSFLOW },
  1860. X#endif
  1861. X#ifdef CTSFLOW
  1862. X    {  3, 53, "CTSFLO", CFLAG, CTSFLOW },
  1863. X#endif
  1864. X    {  4,  7, "ISIG",   LFLAG, ISIG },
  1865. X    {  4, 15, "ICANON", LFLAG, ICANON },
  1866. X    {  4, 23, "XCASE",  LFLAG, XCASE },
  1867. X    {  4, 31, "ECHO",   LFLAG, ECHO },
  1868. X    {  4, 39, "ECHOE",  LFLAG, ECHOE },
  1869. X    {  4, 46, "ECHOK",  LFLAG, ECHOK },
  1870. X    {  4, 53, "ECHONL", LFLAG, ECHONL },
  1871. X    {  4, 60, "NOFLSH", LFLAG, NOFLSH },
  1872. X    {  4, 68, "XCLUDE", LFLAG, XCLUDE },
  1873. X    {  7,  7, "TO",     STATE, TIMEOUT },
  1874. X    {  7, 10, "WO",     STATE, WOPEN },
  1875. X    {  7, 13, "O",      STATE, ISOPEN },
  1876. X    {  7, 15, "TB",     STATE, TBLOCK },
  1877. X    {  7, 18, "CD",     STATE, CARR_ON },
  1878. X    {  7, 21, "BY",     STATE, BUSY },
  1879. X    {  7, 24, "OSLP",   STATE, OASLP },
  1880. X    {  7, 29, "ISLP",   STATE, IASLP },
  1881. X    {  7, 34, "STOP",   STATE, TTSTOP },
  1882. X    {  7, 39, "EXT",    STATE, EXTPROC },
  1883. X    {  7, 43, "TACT",   STATE, TACT },
  1884. X    {  7, 48, "ESC",    STATE, CLESC },
  1885. X    {  7, 52, "RTO",    STATE, RTO },
  1886. X    {  7, 56, "IOW",    STATE, TTIOW },
  1887. X    {  7, 60, "XON",    STATE, TTXON },
  1888. X    {  7, 64, "XOFF",   STATE, TTXOFF },
  1889. X    {  -1,-1, (char *)0,    -1,    -1 }
  1890. X};
  1891. X
  1892. Xtypedef struct fcursor {
  1893. X    int y,x;
  1894. X} FCURSOR;
  1895. X
  1896. XFCURSOR tty_fcursors[] = {
  1897. X#define Fc_intr       0
  1898. X    {  6,  8 },
  1899. X#define Fcc_quit      1
  1900. X    {  6, 13 },
  1901. X#define Fcc_erase     2
  1902. X    {  6, 18 },
  1903. X#define Fcc_kill      3
  1904. X    {  6, 24 },
  1905. X#define Fcc_eof       4
  1906. X    {  6, 30 },
  1907. X#define Fcc_eol       5
  1908. X    {  6, 40 },
  1909. X#define Fcc_eol2      6
  1910. X    {  6, 49 },
  1911. X#define Fcc_swtch     7
  1912. X    {  6, 54 },
  1913. X#define Fbaud_b_p_s   8
  1914. X    {  3,  7 }
  1915. X};
  1916. X
  1917. Xtypedef struct b_to_br {
  1918. X    char *baud_rate;
  1919. X    int B_code;
  1920. X} B_TO_BR;
  1921. X
  1922. XB_TO_BR speeds[] = {    /* ordered to put less common rates later in table */
  1923. X                        /* the vagaries of baud rates above 9600 "handled" */
  1924. X    " 2400",    B2400,
  1925. X    " 1200",    B1200,
  1926. X    " 9600",    B9600,
  1927. X#if defined(B19200)
  1928. X    "19200",    B19200,
  1929. X#endif
  1930. X#if defined(B38400)
  1931. X    "38400",    B38400,
  1932. X#endif
  1933. X    " 4800",    B4800,
  1934. X    "  300",    B300,
  1935. X    "  110",    B110,
  1936. X    "  600",    B600,
  1937. X    "   75",    B75,
  1938. X    "   50",    B50,
  1939. X    "  HUP",    B0,
  1940. X    " EXTA",    EXTA,
  1941. X    " EXTB",    EXTB,
  1942. X
  1943. X    (char *)0,0
  1944. X};
  1945. X
  1946. X/*+-------------------------------------------------------------------------
  1947. X    B_to_baud_rate(code) - convert CBAUD B_ code to baud rate string
  1948. X--------------------------------------------------------------------------*/
  1949. Xchar *
  1950. XB_to_baud_rate(code)
  1951. Xint code;
  1952. X{
  1953. X    register int n;
  1954. X
  1955. X    for(n=0; speeds[n].baud_rate; n++)
  1956. X        if(speeds[n].B_code == code)
  1957. X            return(speeds[n].baud_rate);
  1958. X    return("-----");
  1959. X}    /* end of B_to_baud_rate */
  1960. X
  1961. X/*+-------------------------------------------------------------------------
  1962. X    cflag_to_baud_d_p_s(cflag)
  1963. X--------------------------------------------------------------------------*/
  1964. Xchar *
  1965. Xcflag_to_baud_d_p_s(cflag)
  1966. Xint cflag;
  1967. X{
  1968. X    register char *cptr;
  1969. X    static char rtnstr[16];
  1970. X
  1971. X    strcpy(rtnstr,B_to_baud_rate(cflag & CBAUD));
  1972. X    cptr = rtnstr + strlen(rtnstr);
  1973. X    *cptr++ = '-';
  1974. X    switch(cflag & CSIZE)
  1975. X    {
  1976. X        case CS5: *cptr++ = '5'; break;
  1977. X        case CS6: *cptr++ = '6'; break;
  1978. X        case CS7: *cptr++ = '7'; break;
  1979. X        case CS8: *cptr++ = '8'; break;
  1980. X    }
  1981. X    *cptr++ = '-';
  1982. X    *cptr++ = (cflag & PARENB) ? ((cflag & PARODD) ? 'O' : 'E') : 'N';
  1983. X    *cptr++ = '-';
  1984. X    *cptr++ = (cflag & CSTOPB) ? '2' : '1';
  1985. X    *cptr = 0;
  1986. X    return(rtnstr);
  1987. X
  1988. X}    /* end of cflag_to_baud_d_p_s */
  1989. X
  1990. X/*+-----------------------------------------------------------------------
  1991. X    wintty(win,tly,tlx,tty)
  1992. X------------------------------------------------------------------------*/
  1993. Xvoid
  1994. Xwintty(win,tly,tlx,tty)
  1995. XWINDOW *win;
  1996. Xint tly;
  1997. Xint tlx;
  1998. Xstruct tty *tty;
  1999. X{
  2000. X    register flag = 0;
  2001. X    register i_cc;
  2002. X    TFIELD *tptr = tty_tfields;
  2003. X    FCURSOR *fptr = tty_fcursors;
  2004. X
  2005. X    while(tptr->y >= 0)
  2006. X    {
  2007. X        switch(tptr->flag_num)
  2008. X        {
  2009. X            case IFLAG: flag = tty->t_iflag; break;
  2010. X            case OFLAG: flag = tty->t_oflag; break;
  2011. X            case LFLAG: flag = tty->t_lflag; break;
  2012. X            case CFLAG: flag = tty->t_cflag; break;
  2013. X            case STATE: flag = tty->t_state; break;
  2014. X        }
  2015. X        flag &= tptr->mask;
  2016. X        wmove(win,tptr->y + tly,tptr->x + tlx);
  2017. X        if(flag)
  2018. X            wstandout(win);
  2019. X        waddstr(win,tptr->label);
  2020. X        if(flag)
  2021. X            wstandend(win);
  2022. X        tptr++;
  2023. X    }
  2024. X    for(i_cc = 0; i_cc < NCC; i_cc++)
  2025. X    {
  2026. X        wmove(win,fptr->y + tly,fptr->x + tlx);
  2027. X        wprintw(win,"%02x",tty->t_cc[i_cc]);
  2028. X        fptr++;
  2029. X    }
  2030. X
  2031. X    fptr = &tty_fcursors[Fbaud_b_p_s];
  2032. X    wmove(win,fptr->y + tly,fptr->x + tlx);
  2033. X    waddstr(win,"           ");
  2034. X    wmove(win,fptr->y + tly,fptr->x + tlx);
  2035. X    waddstr(win,cflag_to_baud_d_p_s(tty->t_cflag));
  2036. X
  2037. X}    /* end of wintty */
  2038. X
  2039. X/*+-------------------------------------------------------------------------
  2040. X    wintty_template(win,tly,tlx,show_flag)
  2041. X--------------------------------------------------------------------------*/
  2042. Xvoid
  2043. Xwintty_template(win,tly,tlx,show_flag)
  2044. XWINDOW *win;
  2045. Xint tly;
  2046. Xint tlx;
  2047. Xint show_flag;
  2048. X{
  2049. X    register y;
  2050. X    SLABEL *sptr = tty_slabels;
  2051. X
  2052. X    for(y = 0; y < 7; y++)
  2053. X    {
  2054. X        wmove(win,tly + y,0);
  2055. X        wclrtoeol(win);
  2056. X    }
  2057. X    if(show_flag)
  2058. X    {
  2059. X        while(sptr->y >= 0)
  2060. X        {
  2061. X            wmove(win,sptr->y + tly,sptr->x + tlx);
  2062. X            waddstr(win,sptr->label);
  2063. X            sptr++;
  2064. X        }
  2065. X    }
  2066. X
  2067. X}    /* end of wintty_template */
  2068. X
  2069. X/* vi: set tabstop=4 shiftwidth=4: */
  2070. X/* end of wintty.c */
  2071. SHAR_EOF
  2072. chmod 0644 siotools/wintty.c ||
  2073. echo 'restore of siotools/wintty.c failed'
  2074. Wc_c="`wc -c < 'siotools/wintty.c'`"
  2075. test 8232 -eq "$Wc_c" ||
  2076.     echo 'siotools/wintty.c: original size 8232, current size' "$Wc_c"
  2077. fi
  2078. # ============= siotools/wintty.h ==============
  2079. if test -f 'siotools/wintty.h' -a X"$1" != X"-c"; then
  2080.     echo 'x - skipping siotools/wintty.h (File already exists)'
  2081. else
  2082. echo 'x - extracting siotools/wintty.h (Text)'
  2083. sed 's/^X//' << 'SHAR_EOF' > 'siotools/wintty.h' &&
  2084. X/* CHK=0x57DF */
  2085. X/*+-----------------------------------------------------------------------
  2086. X    wintty.h
  2087. X------------------------------------------------------------------------*/
  2088. X/*+:EDITS:*/
  2089. X/*:07-15-1992-14:33-wht@n4hgf-2.60 release - u386mon+siotools merge */
  2090. X/*:12-04-1989-16:50-afterlint-creation */
  2091. X
  2092. X#ifndef _wintty_h
  2093. X#define _wintty_h
  2094. X
  2095. X#ifndef BUILDING_LINT_ARGS
  2096. X#ifdef LINT_ARGS
  2097. X
  2098. X/* wintty.c */
  2099. Xchar *B_to_baud_rate(int );
  2100. Xchar *cflag_to_baud_d_p_s(int );
  2101. Xvoid wintty(struct _win_st *,int ,int ,struct tty *);
  2102. Xvoid wintty_template(struct _win_st *,int ,int ,int );
  2103. X
  2104. X#else        /* compiler doesn't know about prototyping */
  2105. X
  2106. X/* wintty.c */
  2107. Xchar *B_to_baud_rate();
  2108. Xchar *cflag_to_baud_d_p_s();
  2109. Xvoid wintty();
  2110. Xvoid wintty_template();
  2111. X
  2112. X#endif /* LINT_ARGS */
  2113. X#endif /* BUILDING_LINT_ARGS */
  2114. X#endif /* _wintty_h */
  2115. X
  2116. X/* vi: set tabstop=4 shiftwidth=4: */
  2117. X/* end of wintty.h */
  2118. SHAR_EOF
  2119. chmod 0644 siotools/wintty.h ||
  2120. echo 'restore of siotools/wintty.h failed'
  2121. Wc_c="`wc -c < 'siotools/wintty.h'`"
  2122. test 873 -eq "$Wc_c" ||
  2123.     echo 'siotools/wintty.h: original size 873, current size' "$Wc_c"
  2124. fi
  2125. exit 0
  2126.  
  2127. exit 0 # Just in case...
  2128.