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

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