home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sources / misc / 3933 < prev    next >
Encoding:
Text File  |  1992-09-11  |  57.1 KB  |  2,068 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: wht@n4hgf.mt-park.ga.us (Warren Tucker)
  4. Subject:  v32i041:  ecu - ECU Asynchronous Communications v3.20, Part06/40
  5. Message-ID: <1992Sep11.192451.6777@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: f00f24dbcf81224d13c2fa1672638fbf
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. References: <csm-v32i036=ecu.141245@sparky.IMD.Sterling.COM>
  11. Date: Fri, 11 Sep 1992 19:24:51 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 2053
  14.  
  15. Submitted-by: wht@n4hgf.mt-park.ga.us (Warren Tucker)
  16. Posting-number: Volume 32, Issue 41
  17. Archive-name: ecu/part06
  18. Environment: SCO,XENIX,ISC,SUNOS,SYSVR4,HDB,Curses
  19. Supersedes: ecu: Volume 21, Issue 53-89
  20.  
  21. ---- Cut Here and feed the following to sh ----
  22. #!/bin/sh
  23. # this is ecu320.06 (part 6 of ecu320)
  24. # do not concatenate these parts, unpack them in order with /bin/sh
  25. # file ecuDCE.c continued
  26. #
  27. if test ! -r _shar_seq_.tmp; then
  28.     echo 'Please unpack part 1 first!'
  29.     exit 1
  30. fi
  31. (read Scheck
  32.  if test "$Scheck" != 6; then
  33.     echo Please unpack part "$Scheck" next!
  34.     exit 1
  35.  else
  36.     exit 0
  37.  fi
  38. ) < _shar_seq_.tmp || exit 1
  39. if test ! -f _shar_wnt_.tmp; then
  40.     echo 'x - still skipping ecuDCE.c'
  41. else
  42. echo 'x - continuing file ecuDCE.c'
  43. sed 's/^X//' << 'SHAR_EOF' >> 'ecuDCE.c' &&
  44. X        }
  45. X
  46. X        if(sigint || !strcmp(last_dial_result,interrupted_string))
  47. X            goto ABORT_CYCLE;
  48. X
  49. X        if((retries == 0) || (erc >= e_FATAL))
  50. X            break;
  51. X
  52. X        pprintf("%d %s left ... ",retries,(retries == 1) ? "retry" : "retries");
  53. X        nap_msec = delay * 1000L;
  54. X        ff(se,"waiting %d seconds ... 'c' to cycle, %s to abort\r\n",
  55. X            delay,(kbdintr == DEL) ?"DEL":make_char_graphic(kbdintr,0));
  56. X        while(nap_msec > 0)
  57. X        {
  58. X            nap_msec -= Nap(100L);
  59. X            while(ttyrdchk())
  60. X            {
  61. X                ans = to_lower(ttygetc(1));
  62. X                if(ans == 'c')
  63. X                    goto CONTINUE_CYCLE;
  64. X                else if(ans == kbdintr)
  65. X                    goto ABORT_CYCLE;
  66. X                else
  67. X                    ring_bell();
  68. X            }
  69. X            if(sigint)
  70. X                goto ABORT_CYCLE;
  71. X        }
  72. XCONTINUE_CYCLE:
  73. X        DCE_hangup();
  74. X    }
  75. X
  76. XERROR_RETURN:
  77. X    DCE_hangup();
  78. X    start_rcvr_process(1);
  79. X    return(-1);
  80. X
  81. XABORT_CYCLE:
  82. X    DCE_hangup();
  83. X    ff(se,"redial ABORTED\r\n");
  84. X    sigint = 0;
  85. X    goto ERROR_RETURN;
  86. X}    /* end of DCE_redial */
  87. X
  88. X/*+-------------------------------------------------------------------------
  89. X    DCE_now_on_hook() - DCE no longer in connection
  90. X
  91. XThis may be called, however, when no connection is active
  92. X--------------------------------------------------------------------------*/
  93. Xvoid
  94. XDCE_now_on_hook()
  95. X{
  96. X    char s128[128];
  97. X    long connect_secs;
  98. X
  99. X    lCLOCAL(1);        /* turn on CLOCAL */
  100. X
  101. X    if(shm->Lconnected)
  102. X    {
  103. X        connect_secs = time((long *)0) - shm->Loff_hook_time;
  104. X        sprintf(s128,"DISCONNECT %s (%s) %ld %s",
  105. X            shm->Llogical,shm->Ltelno,connect_secs,
  106. X            get_elapsed_time(connect_secs));
  107. X        ecu_log_event(getpid(),s128);
  108. X#if defined(WHT2) || defined(XTERM_FRIEND)
  109. X        /*
  110. X         * if xterm, put disconnected status in title bar
  111. X         * but this really should be done in _hangup.ep
  112. X         */
  113. X        xterm_title("disconnected",1);
  114. X#endif
  115. X        /*
  116. X         * do the _hangup.ep execution
  117. X         */
  118. X        if(find_procedure("_hangup"))
  119. X        {
  120. X            char *_hangup_args[2];
  121. X            sprintf(s128,"%ld",connect_secs);
  122. X            _hangup_args[0] = "_hangup";
  123. X            _hangup_args[1] = s128;
  124. X            (void)do_proc(2,_hangup_args);
  125. X        }
  126. X        shm->Lconnected = 0;
  127. X    }
  128. X    shm->Lrname[0] = 0;
  129. X    set_default_escape_prompt();
  130. X
  131. X}    /* end of DCE_now_on_hook */
  132. X
  133. X/*+-------------------------------------------------------------------------
  134. X    DCE_hangup() - terminate any active connection
  135. X--------------------------------------------------------------------------*/
  136. Xvoid
  137. XDCE_hangup()
  138. X{
  139. X    int restart_rcvr = need_rcvr_restart();
  140. X
  141. X    if(restart_rcvr)
  142. X        kill_rcvr_process(SIGUSR1);
  143. X
  144. X    lflash_dtr();
  145. X    DCE_now_on_hook();
  146. X
  147. X    if(restart_rcvr)
  148. X        start_rcvr_process(0);
  149. X
  150. X}    /* end of DCE_hangup */
  151. X
  152. X/*+-------------------------------------------------------------------------
  153. X    DCE_get_sreg_value(regnum)
  154. X assumes rcvr process has been killed
  155. X--------------------------------------------------------------------------*/
  156. Xint
  157. XDCE_get_sreg_value(regnum)
  158. Xint regnum;
  159. X{
  160. X    char s128[128];
  161. X    LRWT lr;
  162. X
  163. X    sprintf(s128,"ATS%d?",regnum);
  164. X    DCE_send_cmd(s128);
  165. X    lflush(0);
  166. X    lr.to1 = 2000L;
  167. X    lr.to2 = 140L;
  168. X    lr.raw_flag = 0;
  169. X    lr.buffer = s128;
  170. X    lr.bufsize = sizeof(s128);
  171. X    lr.delim = (char *)0;
  172. X    lr.echo_flag = 0;
  173. X    lgets_timeout(&lr);
  174. X    if(lr.count != 3)
  175. X        return(-1);
  176. X    return(atoi(s128));
  177. X
  178. X}    /* end of DCE_get_sreg_value */
  179. X
  180. X/*+-------------------------------------------------------------------------
  181. X    DCE_set_sreg(regnum,value)
  182. X assumes rcvr process has been killed
  183. X returns 0 if no error (reads back value set),
  184. X else -1 and error message has been printed
  185. X--------------------------------------------------------------------------*/
  186. Xint
  187. XDCE_set_sreg(regnum,value)
  188. Xint regnum;
  189. Xint value;
  190. X{
  191. X    char s128[128];
  192. X    int value2;
  193. X    LRWT lr;
  194. X
  195. X    sprintf(s128,"ATS%d=%d",regnum,value);
  196. X    DCE_send_cmd(s128);
  197. X    lflush(0);
  198. X    lr.to1 = 2000L;
  199. X    lr.to2 = 140L;
  200. X    lr.raw_flag = 0;
  201. X    lr.buffer = s128;
  202. X    lr.bufsize = sizeof(s128);
  203. X    lr.delim = (char *)0;
  204. X    lr.echo_flag = 0;
  205. X    lgets_timeout(&lr);
  206. X    value2 = DCE_get_sreg_value(regnum);
  207. X    if(value2 < 0)
  208. X        pprintf("PROBLEM setting modem S%d=%d; cannot talk to modem\n",
  209. X                regnum,value);
  210. X    else if(value != value2)
  211. X        pprintf("PROBLEM setting modem S%d=%d; got %d back\n",
  212. X                regnum,value,value2);
  213. X    return((value != value2) ? -1 : 0);
  214. X
  215. X}    /* end of DCE_set_sreg */
  216. X
  217. X/*+-------------------------------------------------------------------------
  218. X    DCE_autoanswer()
  219. X--------------------------------------------------------------------------*/
  220. Xvoid
  221. XDCE_autoanswer()
  222. X{
  223. X    if(!Lmodem_autoans[0])
  224. X        return;
  225. X    (void)Nap(200L);
  226. X    lputs_paced(20,"AT\r");
  227. X    (void)Nap(100L);
  228. X    lputs_paced(20,Lmodem_autoans); /* quiet modem */
  229. X    lputs_paced(20,"\r");
  230. X    (void)Nap(200L);
  231. X    lputs_paced(20,Lmodem_autoans); /* quiet modem */
  232. X    lputs_paced(20,"\r");
  233. X    (void)Nap(200L);
  234. X    lflush(0);
  235. X}    /* end of DCE_autoanswer */
  236. X
  237. X/* end of ecuDCE.c */
  238. X/* vi: set tabstop=4 shiftwidth=4: */
  239. SHAR_EOF
  240. echo 'File ecuDCE.c is complete' &&
  241. chmod 0644 ecuDCE.c ||
  242. echo 'restore of ecuDCE.c failed'
  243. Wc_c="`wc -c < 'ecuDCE.c'`"
  244. test 24153 -eq "$Wc_c" ||
  245.     echo 'ecuDCE.c: original size 24153, current size' "$Wc_c"
  246. rm -f _shar_wnt_.tmp
  247. fi
  248. # ============= ecuLCK.c ==============
  249. if test -f 'ecuLCK.c' -a X"$1" != X"-c"; then
  250.     echo 'x - skipping ecuLCK.c (File already exists)'
  251.     rm -f _shar_wnt_.tmp
  252. else
  253. > _shar_wnt_.tmp
  254. echo 'x - extracting ecuLCK.c (Text)'
  255. sed 's/^X//' << 'SHAR_EOF' > 'ecuLCK.c' &&
  256. X#define HONEYDANBER /* means use ASCII pids in lock files */
  257. X#if defined(SHARE_DEBUG)
  258. X#define LOG_LOCKS
  259. X#endif
  260. X/*+-----------------------------------------------------------------------
  261. X    ecuLCK.c -- ECU lock file management
  262. X    wht@n4hgf.Mt-Park.GA.US
  263. X
  264. X  Defined functions:
  265. X    is_active_lock(name)
  266. X    line_lock_status(ttyname)
  267. X    make_lock_name(ttyname,lock_file_name)
  268. X
  269. XLock files under XENIX are supposed to use the direct line name
  270. X(lower-case last letter); we create only the lower-case case, but
  271. Xcheck for both.
  272. X------------------------------------------------------------------------*/
  273. X/*+:EDITS:*/
  274. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  275. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  276. X/*:08-21-1992-13:39-wht@n4hgf-rewire direct/modem device use */
  277. X/*:04-24-1992-21:59-wht@n4hgf-more SCO tty name normalizing */
  278. X/*:08-25-1991-14:39-wht@n4hgf-ISCSVR4 port thanks to aega84!lh */
  279. X/*:08-21-1991-03:37-wht@n4hgf-kill LINST_INVALID check */
  280. X/*:08-11-1991-18:06-wht@n4hgf-SCO_TTY_NAMING considerations */
  281. X/*:08-09-1991-11:07-wht@n4hgf-configurable lock directory */
  282. X/*:08-07-1991-14:41-wht@n4hgf-race with ecuungetty over lock resolved */
  283. X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  284. X/*:11-19-1990-01:05-wht@n4hgf-remove lock in is_active_lock if we locked */
  285. X/*:10-16-1990-20:43-wht@n4hgf-add SHARE_DEBUG */
  286. X/*:09-19-1990-19:36-wht@n4hgf-ecu_log_event now gets pid for log from caller */
  287. X/*:08-14-1990-20:39-wht@n4hgf-ecu3.00-flush old edit history */
  288. X
  289. X#include "ecu.h"
  290. X#include "utmpstatus.h"
  291. X#if defined(SVR4)
  292. X# include <sys/sysmacros.h>
  293. X#endif
  294. X
  295. Xextern int errno;
  296. Xextern char ungetty_ttyname[];
  297. X
  298. Xchar *lock_dir_name = LOCK_DIR_NAME; /* location of LCK.. files */
  299. X
  300. X/*+-------------------------------------------------------------------------
  301. X    make_lock_name(ttyname,lock_file_name)
  302. X--------------------------------------------------------------------------*/
  303. Xint
  304. Xmake_lock_name(ttyname,lock_file_name)
  305. Xchar *ttyname;
  306. Xchar *lock_file_name;
  307. X{
  308. X
  309. X#if defined(SVR4)
  310. X    struct stat tbuf;
  311. X
  312. X    if(stat(ttyname, &tbuf) < 0)
  313. X    {
  314. X        if(errno == ENOENT)
  315. X            return(LINST_NODEV);        /* device does not exist */
  316. X        else
  317. X            return(LINST_OPNFAIL);        /* could not access line */
  318. X    }
  319. X    sprintf(lock_file_name,"%s/LK.%03u.%03u.%03u",
  320. X        lock_dir_name,major(tbuf.st_dev),
  321. X        tbuf.st_rdev >> 18, minor(tbuf.st_rdev));
  322. X#else
  323. X
  324. X    /*
  325. X     * SVR3 and before
  326. X     */
  327. X    strcpy(lock_file_name,lock_dir_name);
  328. X    strcat(lock_file_name,"/LCK..");
  329. X#ifdef SCO_TTY_NAMING
  330. X    strcat(lock_file_name,direct_tty(ttyname) + 5);
  331. X#else
  332. X    strcat(lock_file_name,ttyname + 5);
  333. X#endif /* SCO_TTY_NAMING */
  334. X
  335. X#endif /* SVR4 */
  336. X
  337. X    return(0);
  338. X
  339. X}    /* end of make_lock_name */
  340. X
  341. X/*+-------------------------------------------------------------------------
  342. X    is_active_lock(name) - check to see if lock still active
  343. X
  344. Xif not unlink any old lock name
  345. X--------------------------------------------------------------------------*/
  346. Xis_active_lock(name)
  347. Xregister char *name;
  348. X{
  349. X    register itmp;
  350. X    PID_T lockpid;
  351. X    int fd;
  352. X    int status = 0;
  353. X    char pidstr[12];
  354. X
  355. X#ifdef SCO_TTY_NAMING
  356. X    char name2[256];
  357. X
  358. X    if(isupper(name[itmp = strlen(name) - 1]))
  359. X    {
  360. X        strcpy(name2,name);
  361. X        name2[itmp] = to_lower(name2[itmp]);
  362. X        name = name2;
  363. X    }
  364. X#endif /* SCO_TTY_NAMING */
  365. X
  366. X    errno = 0;
  367. X    if((fd = open(name,O_RDONLY,0)) < 0)
  368. X    {
  369. X        if(errno != ENOENT)
  370. X            status = LINST_LCKERR;
  371. X        goto RETURN_STATUS;
  372. X    }
  373. X
  374. X#if defined(HONEYDANBER)
  375. X    itmp = read(fd,(char *)pidstr,11);
  376. X    pidstr[11] = 0;
  377. X    close(fd);
  378. X    if(itmp != 11)
  379. X        goto UNLINK_OLD_LOCK;
  380. X    lockpid = atoi(pidstr);
  381. X#else
  382. X    itmp = read(fd,(char *)&lockpid,sizeof(int));
  383. X    close(fd);
  384. X    if(itmp != sizeof(int))
  385. X        goto UNLINK_OLD_LOCK;
  386. X#endif
  387. X
  388. X    /* if we are the locker, return no error */
  389. X    if(lockpid == xmtr_pid)
  390. X    {
  391. X        status = LINST_WEGOTIT;
  392. X        goto RETURN_STATUS;
  393. X    }
  394. X
  395. X    if((!(itmp = kill(lockpid,0))) || (errno != ESRCH))
  396. X    {
  397. X        errno = EACCES;        /* for termecu() */
  398. X        status = lockpid;
  399. X        goto RETURN_STATUS;
  400. X    }
  401. X
  402. XUNLINK_OLD_LOCK:
  403. X    if(unlink(name))
  404. X        status = LINST_LCKERR;
  405. X
  406. XRETURN_STATUS:
  407. X
  408. X#if defined(LOG_LOCKS)
  409. X{ char s128[128];
  410. X  extern char *errno_text();
  411. X    sprintf(s128,"ISLOCK %s status=%d errno=%d",name,status,errno);
  412. X    ecu_log_event(getpid(),s128);
  413. X}
  414. X#endif
  415. X
  416. X    return(status);
  417. X}    /* end of is_active_lock */
  418. X
  419. X/*+-----------------------------------------------------------------------
  420. X    line_lock_status(ttyname)
  421. X
  422. X  ttyname must be of style "/dev/ttyxx"
  423. X  Returns locking pid if locked else LOPEN lock error code (< 0) else 0
  424. X------------------------------------------------------------------------*/
  425. Xint
  426. Xline_lock_status(ttyname)
  427. Xchar *ttyname;
  428. X{
  429. X    register itmp;
  430. X    char lock_file_name[128];
  431. X    
  432. X    if(itmp = make_lock_name(ttyname,lock_file_name))
  433. X        return(itmp);
  434. X
  435. X    if(itmp = is_active_lock(lock_file_name))
  436. X        return(itmp);
  437. X
  438. X    return(0);
  439. X
  440. X}    /* end of line_lock_status */
  441. X
  442. X/* end of ecuLCK.c */
  443. X/* vi: set tabstop=4 shiftwidth=4: */
  444. SHAR_EOF
  445. chmod 0644 ecuLCK.c ||
  446. echo 'restore of ecuLCK.c failed'
  447. Wc_c="`wc -c < 'ecuLCK.c'`"
  448. test 4765 -eq "$Wc_c" ||
  449.     echo 'ecuLCK.c: original size 4765, current size' "$Wc_c"
  450. rm -f _shar_wnt_.tmp
  451. fi
  452. # ============= ecu_pwd.h ==============
  453. if test -f 'ecu_pwd.h' -a X"$1" != X"-c"; then
  454.     echo 'x - skipping ecu_pwd.h (File already exists)'
  455.     rm -f _shar_wnt_.tmp
  456. else
  457. > _shar_wnt_.tmp
  458. echo 'x - extracting ecu_pwd.h (Text)'
  459. sed 's/^X//' << 'SHAR_EOF' > 'ecu_pwd.h' &&
  460. X/*+-------------------------------------------------------------------------
  461. X    ecu_pwd.h
  462. X    wht@n4hgf.Mt-Park.GA.US
  463. X
  464. XWe cannot always guarantee against multiple inclusion because
  465. Xsome old development environments don't protect against it.
  466. XWe try and do it here ..... 1/2 of my incoming long distance 
  467. Xsupport calls are because old XENIX systems don't do this.
  468. X
  469. XThis is sort of moot since ecu code does not multiply
  470. Xinclude <pwd.h> and there is no ubiquitous #define in
  471. X<pwd.h> to protect other system headers from including it too
  472. X--------------------------------------------------------------------------*/
  473. X/*+:EDITS:*/
  474. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  475. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  476. X/*:03-27-1992-16:21-wht@n4hgf-re-include protection for all .h files */
  477. X/*:01-29-1992-16:49-wht@n4hgf-creation */
  478. X
  479. X#ifndef _ecu_pwd_h
  480. X#define _ecu_pwd_h
  481. X
  482. X#include <pwd.h>
  483. X
  484. X#endif /* _ecu_pwd_h */
  485. X
  486. X/* vi: set tabstop=4 shiftwidth=4: */
  487. X/* end of ecu_pwd.h */
  488. SHAR_EOF
  489. chmod 0644 ecu_pwd.h ||
  490. echo 'restore of ecu_pwd.h failed'
  491. Wc_c="`wc -c < 'ecu_pwd.h'`"
  492. test 981 -eq "$Wc_c" ||
  493.     echo 'ecu_pwd.h: original size 981, current size' "$Wc_c"
  494. rm -f _shar_wnt_.tmp
  495. fi
  496. # ============= ecu_stat.h ==============
  497. if test -f 'ecu_stat.h' -a X"$1" != X"-c"; then
  498.     echo 'x - skipping ecu_stat.h (File already exists)'
  499.     rm -f _shar_wnt_.tmp
  500. else
  501. > _shar_wnt_.tmp
  502. echo 'x - extracting ecu_stat.h (Text)'
  503. sed 's/^X//' << 'SHAR_EOF' > 'ecu_stat.h' &&
  504. X/*+-------------------------------------------------------------------------
  505. X    ecu_stat.h
  506. X    wht@n4hgf.Mt-Park.GA.US
  507. X
  508. XWe cannot always guarantee against multiple inclusion because
  509. Xsome old development environments don't protect against it.
  510. XWe try and do it here ..... 1/2 of my incoming long distance 
  511. Xsupport calls are because old XENIX systems don't do this.
  512. X--------------------------------------------------------------------------*/
  513. X/*+:EDITS:*/
  514. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  515. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  516. X/*:03-27-1992-16:21-wht@n4hgf-re-include protection for all .h files */
  517. X/*:01-29-1992-16:49-wht@n4hgf-creation */
  518. X
  519. X#ifndef ___ECU_STAT_H___
  520. X#define ___ECU_STAT_H___
  521. X#ifndef S_IFMT    /* some stat.h included by stdio.h and cannot be reincluded
  522. X                 * this is just an attempt ... you may have to hack */
  523. X#include <sys/stat.h>
  524. X#endif
  525. X#endif
  526. X
  527. X/* vi: set tabstop=4 shiftwidth=4: */
  528. X/* end of ecu_stat.h */
  529. SHAR_EOF
  530. chmod 0644 ecu_stat.h ||
  531. echo 'restore of ecu_stat.h failed'
  532. Wc_c="`wc -c < 'ecu_stat.h'`"
  533. test 951 -eq "$Wc_c" ||
  534.     echo 'ecu_stat.h: original size 951, current size' "$Wc_c"
  535. rm -f _shar_wnt_.tmp
  536. fi
  537. # ============= ecu_types.h ==============
  538. if test -f 'ecu_types.h' -a X"$1" != X"-c"; then
  539.     echo 'x - skipping ecu_types.h (File already exists)'
  540.     rm -f _shar_wnt_.tmp
  541. else
  542. > _shar_wnt_.tmp
  543. echo 'x - extracting ecu_types.h (Text)'
  544. sed 's/^X//' << 'SHAR_EOF' > 'ecu_types.h' &&
  545. X/*+-------------------------------------------------------------------------
  546. X    ecu_types.h
  547. X    wht@n4hgf.Mt-Park.GA.US
  548. X
  549. XWe cannot always guarantee against multiple inclusion because
  550. Xsome old development environments don't protect against it.
  551. XWe try and do it here ..... 1/2 of my incoming long distance 
  552. Xsupport calls are because old XENIX systems don't do this.
  553. X--------------------------------------------------------------------------*/
  554. X/*+:EDITS:*/
  555. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  556. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  557. X/*:03-27-1992-16:21-wht@n4hgf-re-include protection for all .h files */
  558. X/*:01-29-1992-16:49-wht@n4hgf-creation */
  559. X
  560. X#ifndef ___ECU_TYPES_H___
  561. X#define ___ECU_TYPES_H___
  562. X#ifndef NBBY    /* some types.h included by stdio.h and cannot be reincluded
  563. X                 * this is just an attempt ... you may have to hack */
  564. X#include <sys/types.h>
  565. X#endif
  566. X#endif
  567. X
  568. X/* vi: set tabstop=4 shiftwidth=4: */
  569. X/* end of ecu_types.h */
  570. SHAR_EOF
  571. chmod 0644 ecu_types.h ||
  572. echo 'restore of ecu_types.h failed'
  573. Wc_c="`wc -c < 'ecu_types.h'`"
  574. test 955 -eq "$Wc_c" ||
  575.     echo 'ecu_types.h: original size 955, current size' "$Wc_c"
  576. rm -f _shar_wnt_.tmp
  577. fi
  578. # ============= ecuchdir.c ==============
  579. if test -f 'ecuchdir.c' -a X"$1" != X"-c"; then
  580.     echo 'x - skipping ecuchdir.c (File already exists)'
  581.     rm -f _shar_wnt_.tmp
  582. else
  583. > _shar_wnt_.tmp
  584. echo 'x - extracting ecuchdir.c (Text)'
  585. sed 's/^X//' << 'SHAR_EOF' > 'ecuchdir.c' &&
  586. X/*+-------------------------------------------------------------------------
  587. X    ecuchdir.c - ECU change directory command/history
  588. X    wht@n4hgf.Mt-Park.GA.US
  589. X
  590. X  Defined functions:
  591. X    cd_array_delete(arg,narg)
  592. X    cd_array_delete_usage()
  593. X    cd_array_init()
  594. X    cd_array_read()
  595. X    cd_array_save()
  596. X    change_directory(dirname,arg_present_flag)
  597. X    expand_dirname(dirname,maxlen)
  598. X    pop_directory(arg,arg_present,pcmd)
  599. X    push_directory(dirname,arg_present,pcmd)
  600. X
  601. X--------------------------------------------------------------------------*/
  602. X/*+:EDITS:*/
  603. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  604. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  605. X/*:09-25-1991-18:24-wht@n4hgf2-fix seg viol in popd w/o argument on Sun */
  606. X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  607. X/*:07-14-1991-18:18-wht@n4hgf-new ttygets functions */
  608. X/*:05-21-1991-18:53-wht@n4hgf-add push_directory and pop_directory */
  609. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  610. X
  611. X#include "ecu.h"
  612. X#include "ecukey.h"
  613. X#include "ecutty.h"
  614. X#include "termecu.h"
  615. X
  616. Xint push_directory();
  617. X
  618. X#define CD_PATHLEN    256
  619. X
  620. X#define CD_QUAN        44
  621. Xchar *cd_array[CD_QUAN];
  622. Xuint cd_in_use = 0;
  623. X
  624. X#define DIR_PUSH_MAX    10
  625. Xchar *dir_push_stack[DIR_PUSH_MAX];
  626. Xuint dir_push_level = 0;
  627. X
  628. Xextern char curr_dir[CURR_DIRSIZ];        /* current working directory */
  629. Xextern int proctrace;
  630. Xextern char errmsg[];
  631. Xextern int errno;
  632. X
  633. X/*+-------------------------------------------------------------------------
  634. X    cd_array_read() - read ~/.ecu/dir
  635. X--------------------------------------------------------------------------*/
  636. Xvoid
  637. Xcd_array_read()
  638. X{
  639. Xchar dirpath[CD_PATHLEN];
  640. XFILE *fpcd;
  641. XFILE *fopen();
  642. Xregister char *cptr;
  643. Xchar *skip_ld_break();
  644. X
  645. X    get_home_dir(dirpath);
  646. X    strcat(dirpath,"/.ecu/dir");
  647. X    if((fpcd = fopen(dirpath,"r")) == (FILE *)0)
  648. X        return;        /* none found */
  649. X
  650. X    for(cd_in_use = 0; cd_in_use < CD_QUAN; cd_in_use++)
  651. X    {
  652. X        if(fgets(dirpath,sizeof(dirpath),fpcd) == (char *)0)
  653. X            break;
  654. X        dirpath[strlen(dirpath) - 1] = 0;
  655. X        cptr = skip_ld_break(dirpath);
  656. X        if(strlen(cptr) == 0)
  657. X        {
  658. X            --cd_in_use;
  659. X            continue;
  660. X        }
  661. X        strcpy(cd_array[cd_in_use],cptr);
  662. X    }
  663. X    fclose(fpcd);
  664. X}    /* end of cd_array_read */
  665. X
  666. X/*+-------------------------------------------------------------------------
  667. X    cd_array_save() - save ~/.ecu/dir
  668. X--------------------------------------------------------------------------*/
  669. Xvoid
  670. Xcd_array_save()
  671. X{
  672. Xregister icd;
  673. Xchar savepath[256];
  674. XFILE *fpcd;
  675. XFILE *fopen();
  676. X
  677. X    get_home_dir(savepath);
  678. X    strcat(savepath,"/.ecu/dir");
  679. X
  680. X    if(cd_in_use == 0)
  681. X    {
  682. X        ff(se,"No directory list to save in %s\r\n",savepath);
  683. X        return;
  684. X    }
  685. X    if((fpcd = fopen(savepath,"w")) == (FILE *)0)
  686. X    {
  687. X        ff(se,"%s could not be opened\r\n",savepath);
  688. X        return;
  689. X    }
  690. X
  691. X    for(icd = 0; icd < cd_in_use; icd++)
  692. X        fprintf(fpcd,"%s\n",cd_array[icd]);
  693. X    fclose(fpcd);
  694. X    ff(se,"%d entries saved in %s\r\n",cd_in_use,savepath);
  695. X
  696. X}    /* end of cd_array_save */
  697. X
  698. X/*+-------------------------------------------------------------------------
  699. X    cd_array_delete_usage()
  700. X--------------------------------------------------------------------------*/
  701. Xvoid
  702. Xcd_array_delete_usage()
  703. X{
  704. X    ff(se,"usage: d[elete] <1st> [<last>]\r\n");
  705. X}    /* end of cd_array_delete_usage */
  706. X
  707. X/*+-------------------------------------------------------------------------
  708. X    cd_array_delete(arg,narg)
  709. X--------------------------------------------------------------------------*/
  710. Xcd_array_delete(arg,narg)
  711. Xchar **arg;
  712. Xint narg;
  713. X{
  714. Xuint first;        /* 1st to delete */
  715. Xuint last;        /* last to delete */
  716. X
  717. X    if((narg < 2) || (narg > 3))
  718. X    {
  719. X        cd_array_delete_usage();
  720. X        return(-1);
  721. X    }
  722. X
  723. X    first = atoi(arg[1]) - 1;
  724. X    if(narg == 2)
  725. X        last = first;
  726. X    else
  727. X        last = atoi(arg[2]) - 1;
  728. X
  729. X    if((first > (cd_in_use - 1)) || (last > (cd_in_use - 1)) || (last < first))
  730. X    {
  731. X        cd_array_delete_usage();
  732. X        return(-1);
  733. X    }
  734. X
  735. X    if(last == (cd_in_use - 1))
  736. X    {
  737. X        cd_in_use = first;
  738. X    }
  739. X    else
  740. X    {
  741. X    int count_less = last - first + 1;
  742. X        last++;
  743. X        while(last != cd_in_use)
  744. X            strcpy(cd_array[first++],cd_array[last++]);
  745. X        cd_in_use -= count_less;
  746. X    }
  747. X    return(0);
  748. X}    /* end of cd_array_delete */
  749. X
  750. X/*+-------------------------------------------------------------------------
  751. X    cd_array_init()
  752. X--------------------------------------------------------------------------*/
  753. Xvoid
  754. Xcd_array_init()
  755. X{
  756. Xregister itmp;
  757. X
  758. X/*allocate change_directory stack */
  759. X    for(itmp = 0; itmp < CD_QUAN; itmp++)
  760. X    {
  761. X        if(!(cd_array[itmp] = malloc(CD_PATHLEN + 1)))
  762. X        {
  763. X            ff(se,"Not enough memory for cd stack\r\n");
  764. X            termecu(TERMECU_MALLOC);
  765. X        }
  766. X        *cd_array[itmp] = 0;
  767. X    }
  768. X    (void)cd_array_read();
  769. X}    /* end of cd_array_init */
  770. X
  771. X/*+-------------------------------------------------------------------------
  772. X    expand_dirname(dirname,maxlen) - convert dirname with shell chars
  773. X--------------------------------------------------------------------------*/
  774. Xexpand_dirname(dirname,maxlen)
  775. Xchar *dirname;
  776. Xint maxlen;
  777. X{
  778. Xchar s256[256];
  779. Xchar *expcmd;
  780. X
  781. X    if(!find_shell_chars(dirname))
  782. X        return(0);
  783. X
  784. X    sprintf(s256,"`ls -d %s`",dirname);
  785. X    if(expand_wildcard_list(s256,&expcmd))
  786. X    {
  787. X        strcpy(errmsg,"No such directory");
  788. X        return(-1);
  789. X    }
  790. X    strncpy(dirname,expcmd,maxlen);
  791. X    dirname[maxlen - 1] = 0;
  792. X    free(expcmd);
  793. X    if(strchr(dirname,' '))
  794. X    {
  795. X        strcpy(errmsg,"Too many files");
  796. X        return(-1);
  797. X    }
  798. X    return(0);
  799. X
  800. X}    /* end of expand_dirname */
  801. X
  802. X/*+-------------------------------------------------------------------------
  803. X    change_directory(dirname,arg_present_flag) - 'cd' interactive cmd hdlr
  804. X
  805. X  Change directory to 'dirname' if arg_present_flag is true,
  806. X  else if flag 0, ask for new directory name and change to it
  807. X  This procedure maintains the global variable 'curr_dir' that
  808. X  reflects the ecu transmitter process current working directory.
  809. X--------------------------------------------------------------------------*/
  810. Xint
  811. Xchange_directory(dirname,arg_present_flag)
  812. Xchar *dirname;
  813. Xint arg_present_flag;
  814. X{
  815. Xregister icd;
  816. Xregister itmp;
  817. Xchar s256[256];
  818. Xuchar delim;
  819. X#define BLD_ARG_MAX    5
  820. Xchar *arg[BLD_ARG_MAX];
  821. Xint narg;
  822. Xint longest;
  823. Xint pushing = 0;
  824. X
  825. X    if(cd_in_use == 0)
  826. X        cd_array_read();
  827. X
  828. X    fputs("  ",se);
  829. X
  830. X    if(arg_present_flag)        /* if there is an argument ... */
  831. X    {
  832. X        if(isdigit(*dirname))        /* ... and first char is digit */
  833. X        {
  834. X            icd = atoi(dirname) - 1;
  835. X            if((icd < 0) || (icd >= cd_in_use))
  836. X                goto DISPLAY_CD_ARRAY;
  837. X            strncpy(s256,cd_array[icd],sizeof(s256) - 1);
  838. X        }
  839. X        else
  840. X            strncpy(s256,dirname,sizeof(s256) - 1);    /* literal dir spec */
  841. X
  842. X        s256[sizeof(s256) - 1] = 0;
  843. X    }
  844. X    else        /* no arg to cd command */
  845. X    {
  846. XDISPLAY_CD_ARRAY:
  847. X        fputs("\r\n",se);
  848. X        longest = 0;
  849. X        for(icd = 0; icd < CD_QUAN/2; icd++)
  850. X        {
  851. X            if(icd >= cd_in_use)
  852. X                break;
  853. X            if(longest < (itmp = strlen(cd_array[icd])))
  854. X                longest = itmp;
  855. X        }
  856. X        longest += 4;
  857. X        if(longest < 36)
  858. X            longest += 4;
  859. X        for(icd = 0; icd < CD_QUAN/2; icd++)
  860. X        {
  861. X            if(icd >= cd_in_use)
  862. X                break;
  863. X            sprintf(s256,"%2d %s ",icd + 1,cd_array[icd]);
  864. X            fputs(s256,se);
  865. X            if(icd + CD_QUAN/2 >= cd_in_use)
  866. X                fputs("\r\n",se);
  867. X            else
  868. X            {
  869. X                itmp = longest - strlen(s256);
  870. X                while(itmp-- > 0)
  871. X                    fputc(' ',se);
  872. X                sprintf(s256,"%2d %s\r\n",
  873. X                    icd + 1 + CD_QUAN/2,cd_array[icd + CD_QUAN/2]);
  874. X                fputs(s256,se);
  875. X            
  876. X            }
  877. X        }
  878. X        fputs("current dir: ",se);
  879. X        tcap_stand_out();
  880. X        ff(se," %s ",curr_dir);
  881. X        tcap_stand_end();
  882. X        tcap_eeol();
  883. X        fputs("\r\n",se);
  884. X
  885. XGET_NEW_DIR:
  886. X        fputs(
  887. X            "New dir, <#>, %save, %read, %del, %xmitcd, %pushd, <enter>:  ",se);
  888. X        ttygets(s256,sizeof(s256),TG_CRLF,&delim,(int *)0);
  889. X
  890. XTRY_AGAIN:
  891. X        if((delim == ESC) || !strlen(s256))
  892. X        {
  893. X            ff(se,"no directory change\r\n");
  894. X            return(0);
  895. X        }
  896. X        else if(s256[0] == '%')
  897. X        {
  898. X            if(pushing)
  899. X            {
  900. X                ff(se,"syntax error\r\n");
  901. X                return(-1);
  902. X            }
  903. X            build_str_array(s256,arg,BLD_ARG_MAX,&narg);
  904. X
  905. X            if(minunique("save",&s256[1],1))
  906. X            {
  907. X                cd_array_save();
  908. X                goto GET_NEW_DIR;
  909. X            }
  910. X            else if(minunique("read",&s256[1],1))
  911. X            {
  912. X                cd_array_read();
  913. X                goto DISPLAY_CD_ARRAY;
  914. X            }
  915. X            else if(minunique("delete",&s256[1],1))
  916. X            {
  917. X                if(cd_array_delete(arg,narg))
  918. X                    goto GET_NEW_DIR;
  919. X                else
  920. X                    goto DISPLAY_CD_ARRAY;
  921. X            }
  922. X            else if(minunique("xmitcd",&s256[1],1))
  923. X            {
  924. X                lputs("cd ");
  925. X                lputs(curr_dir);
  926. X                lputc('\r');
  927. X                return(0);
  928. X            }
  929. X            else if(minunique("pushd",&s256[1],1))
  930. X            {
  931. X                strcpy(s256,arg[1]);
  932. X                pushing = 1;
  933. X                goto TRY_AGAIN;
  934. X            }
  935. X            else
  936. X            {
  937. X                ff(se,"Invalid cd subcommand\r\n");
  938. X                goto GET_NEW_DIR;
  939. X            }
  940. X        }
  941. X        else if(icd = atoi(s256))
  942. X        {
  943. X            icd--;
  944. X            if(icd >= cd_in_use)
  945. X                goto GET_NEW_DIR;
  946. X            strncpy(s256,cd_array[icd],sizeof(s256) - 1);
  947. X            s256[sizeof(s256) - 1] = 0;
  948. X        }
  949. X    }
  950. X    if(pushing)
  951. X    {
  952. X        if(push_directory(s256,1,1))
  953. X            return(-1);
  954. X    }
  955. X    else
  956. X    {
  957. X        if(expand_dirname(s256,sizeof(s256)))
  958. X        {
  959. X            ff(se,"%s\r\n",errmsg);
  960. X            return(-1);
  961. X        }
  962. X        if(chdir(s256) < 0)        /* now change to the new directory */
  963. X        {
  964. X            perror(s256);        /* print error if we get one */
  965. X            ff(se,"\r\n");
  966. X            return(-1);
  967. X        }
  968. X        get_curr_dir(curr_dir,sizeof(curr_dir));
  969. X        fputs("confirmed: ",se);
  970. X        tcap_stand_out();
  971. X        ff(se," %s ",curr_dir);
  972. X        tcap_stand_end();
  973. X        fputs("\r\n",se);
  974. X    }
  975. X
  976. X    for(icd = 0; icd < cd_in_use; icd++)
  977. X    {
  978. X        if(strcmp(curr_dir,cd_array[icd]) == 0)
  979. X            return(0);
  980. X    }
  981. X    if(cd_in_use == CD_QUAN)
  982. X    {
  983. X        for(icd = 1; icd < CD_QUAN; icd++)
  984. X        {
  985. X            strcpy(cd_array[icd - 1],cd_array[icd]);
  986. X        }
  987. X        strcpy(cd_array[CD_QUAN - 1],curr_dir);
  988. X    }
  989. X    else
  990. X        strcpy(cd_array[cd_in_use++],curr_dir);
  991. X
  992. X    return(0);
  993. X
  994. X}    /* end of change_directory */
  995. X
  996. X/*+-------------------------------------------------------------------------
  997. X    push_directory(dirname,arg_present,pcmd) - 'pushd' function
  998. X
  999. XThis function performs 'pushd' actions for both the interactive
  1000. Xand procedure 'pushd' commands
  1001. X
  1002. Xdirname is new directory name if arg_present true
  1003. Xpcmd true if procedure command or cd %p interactive, else interactive command
  1004. X
  1005. Xreturns -1 if error, else 0
  1006. X--------------------------------------------------------------------------*/
  1007. Xint
  1008. Xpush_directory(dirname,arg_present,pcmd)
  1009. Xchar *dirname;
  1010. Xint arg_present;
  1011. Xint pcmd;
  1012. X{
  1013. Xregister itmp;
  1014. Xchar s256[256];
  1015. X
  1016. X    if(!pcmd)
  1017. X        ff(se,"\r\n");
  1018. X
  1019. X    if(!arg_present)
  1020. X    {
  1021. X        if(!dir_push_level)
  1022. X        {
  1023. X            if(!pcmd || proctrace)
  1024. X                pprintf("---: no directories pushed\n");
  1025. X        }
  1026. X        else
  1027. X        {
  1028. X            for(itmp = 0; itmp < dir_push_level; itmp++)
  1029. X                pprintf("%3d: %s\n",itmp,dir_push_stack[itmp]);
  1030. X        }
  1031. X        pprintf("cwd: %s\n",curr_dir);
  1032. X        return(0);
  1033. X    }
  1034. X
  1035. X    if(dir_push_level == DIR_PUSH_MAX)
  1036. X    {
  1037. X        pputs("too many pushds\n");
  1038. X        return(-1);
  1039. X    }
  1040. X
  1041. X    if(!dir_push_stack[dir_push_level])
  1042. X    {
  1043. X        if(!(dir_push_stack[dir_push_level] = malloc(CD_PATHLEN)))
  1044. X        {
  1045. X            pputs("no memory for pushd\n");
  1046. X            return(-1);
  1047. X        }
  1048. X    }
  1049. X
  1050. X    get_curr_dir(dir_push_stack[dir_push_level],CD_PATHLEN);
  1051. X
  1052. X    strncpy(s256,dirname,sizeof(s256) - 1);
  1053. X    s256[sizeof(s256) - 1] = 0;
  1054. X    if(expand_dirname(s256,sizeof(s256)))
  1055. X    {
  1056. X        pprintf("'%s': %s\n",s256,errmsg);
  1057. X        return(-1);
  1058. X    }
  1059. X    if(chdir(s256) < 0)        /* now change to the new directory */
  1060. X    {
  1061. X        pperror(s256);        /* print error if we get one */
  1062. X        return(-1);
  1063. X    }
  1064. X    get_curr_dir(curr_dir,sizeof(curr_dir));
  1065. X
  1066. X    if(pcmd && proctrace)
  1067. X        pprintf("pushed to directory %s\n",curr_dir);
  1068. X    else
  1069. X    {
  1070. X        fputs("confirmed: ",se);
  1071. X        tcap_stand_out();
  1072. X        ff(se," %s ",curr_dir);
  1073. X        tcap_stand_end();
  1074. X        ff(se," (level %d)\r\n",dir_push_level);
  1075. X    }
  1076. X
  1077. X    dir_push_level++;
  1078. X    return(0);
  1079. X
  1080. X}    /* end of push_directory */
  1081. X
  1082. X/*+-------------------------------------------------------------------------
  1083. X    pop_directory(arg,arg_present,pcmd) - 'popd' function
  1084. X
  1085. XThis function performs 'popd' actions for both the interactive
  1086. Xand procedure 'popd' commands
  1087. X
  1088. Xarg is empty if arg_present false
  1089. Xif not empty, it is == 'all' or a numeric level to pop to
  1090. Xpcmd true if procedure command, else interactive command
  1091. X
  1092. Xreturns -1 if error, else 0
  1093. X--------------------------------------------------------------------------*/
  1094. Xint
  1095. Xpop_directory(arg,arg_present,pcmd)
  1096. Xchar *arg;
  1097. Xint arg_present;
  1098. Xint pcmd;
  1099. X{
  1100. Xint new_level = -1;
  1101. X
  1102. X    if(!pcmd)
  1103. X        pputs("\n");
  1104. X
  1105. X    if(!dir_push_level)
  1106. X    {
  1107. X        if(!pcmd || proctrace)
  1108. X        {
  1109. X            pprintf("---: no directories pushed\n");
  1110. X            pprintf("cwd: %s\n",curr_dir);
  1111. X        }
  1112. X        return(-1);
  1113. X    }
  1114. X
  1115. X    if(!arg_present)
  1116. X        new_level = dir_push_level - 1;
  1117. X    else if(minunique("all",arg,1))
  1118. X        new_level = 0;
  1119. X    else if(isdigit(*arg))
  1120. X        new_level = atoi(arg);
  1121. X    else 
  1122. X    {
  1123. X        pprintf("argument error: '%s'\n",arg);
  1124. X        return(-1);
  1125. X    }
  1126. X
  1127. X    if((new_level < 0) || (new_level > (dir_push_level - 1)))
  1128. X    {
  1129. X        pprintf("invalid popd argument (or not pushed to level): '%s'\n",arg);
  1130. X        return(-1);
  1131. X    }
  1132. X
  1133. X    dir_push_level = new_level;
  1134. X    if(chdir(dir_push_stack[dir_push_level]) < 0)
  1135. X    {
  1136. X        pperror(dir_push_stack[dir_push_level]);
  1137. X        return(-1);
  1138. X    }
  1139. X    get_curr_dir(curr_dir,sizeof(curr_dir));
  1140. X
  1141. X    if(pcmd && proctrace)
  1142. X        pprintf("popped to directory %s (level %d)\n",curr_dir,dir_push_level);
  1143. X    else
  1144. X    {
  1145. X        fputs("confirmed: ",se);
  1146. X        tcap_stand_out();
  1147. X        ff(se," %s ",curr_dir);
  1148. X        tcap_stand_end();
  1149. X        ff(se," (level %d)\r\n",dir_push_level);
  1150. X    }
  1151. X
  1152. X    return(0);
  1153. X
  1154. X}    /* end of pop_directory */
  1155. X
  1156. X/* end of ecuchdir.c */
  1157. X/* vi: set tabstop=4 shiftwidth=4: */
  1158. SHAR_EOF
  1159. chmod 0644 ecuchdir.c ||
  1160. echo 'restore of ecuchdir.c failed'
  1161. Wc_c="`wc -c < 'ecuchdir.c'`"
  1162. test 12742 -eq "$Wc_c" ||
  1163.     echo 'ecuchdir.c: original size 12742, current size' "$Wc_c"
  1164. rm -f _shar_wnt_.tmp
  1165. fi
  1166. # ============= ecucmd.h ==============
  1167. if test -f 'ecucmd.h' -a X"$1" != X"-c"; then
  1168.     echo 'x - skipping ecucmd.h (File already exists)'
  1169.     rm -f _shar_wnt_.tmp
  1170. else
  1171. > _shar_wnt_.tmp
  1172. echo 'x - extracting ecucmd.h (Text)'
  1173. sed 's/^X//' << 'SHAR_EOF' > 'ecucmd.h' &&
  1174. X/*+-------------------------------------------------------------------------
  1175. X    ecucmd.h -- command definitions
  1176. X    wht@n4hgf.Mt-Park.GA.US
  1177. X--------------------------------------------------------------------------*/
  1178. X/*+:EDITS:*/
  1179. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  1180. X/*:08-30-1992-23:06-wht@n4hgf-add fkmap */
  1181. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1182. X/*:04-19-1992-19:54-wht@n4hgf-kbdtest command now visible to users */
  1183. X/*:03-27-1992-16:21-wht@n4hgf-re-include protection for all .h files */
  1184. X/*:03-01-1992-13:28-wht@n4hgf-come up to modern times ... enum for CT */
  1185. X/*:11-16-1991-14:34-wht@n4hgf-add upon + rearrance pcmd_... decls */
  1186. X/*:11-11-1991-14:33-wht@n4hgf-add dcdwatch */
  1187. X/*:09-01-1991-18:12-wht@n4hgf2-add setline */
  1188. X/*:09-01-1991-18:11-wht@n4hgf2-add setline */
  1189. X/*:08-17-1991-16:41-wht@n4hgf-add kbdtest */
  1190. X/*:07-29-1991-17:57-wht@n4hgf-add memstat */
  1191. X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  1192. X/*:07-04-1991-20:07-wht@n4hgf-add procedure rlog cmd */
  1193. X/*:05-21-1991-18:07-wht@n4hgf-add pushd/popd commands */
  1194. X/*:03-20-1991-05:25-root@n4hgf-experimental eto command */
  1195. X/*:03-16-1991-15:24-wht@n4hgf-add nice */
  1196. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1197. X
  1198. X#ifndef _ecucmd_h
  1199. X#define _ecucmd_h
  1200. X
  1201. X/* interactive command tokens */
  1202. X
  1203. Xenum CT_codes
  1204. X{
  1205. X    CTRSVD = 15,    /* codes 0-15 reserved */
  1206. X    CTautorz,
  1207. X    CTax,
  1208. X    CTbaud,
  1209. X    CTbn,
  1210. X    CTbreak,
  1211. X    CTcd,
  1212. X    CTclrx,
  1213. X    CTda,
  1214. X    CTdcdwatch,
  1215. X    CTdial,
  1216. X    CTdo,
  1217. X    CTduplex,
  1218. X    CTeto,
  1219. X    CTexit,
  1220. X    CTfasi,
  1221. X    CTfi,
  1222. X    CTfkey,
  1223. X    CTfkmap,
  1224. X    CTgetf,
  1225. X    CThangup,
  1226. X    CThelp,
  1227. X    CTkbdtest,
  1228. X    CTllp,
  1229. X    CTloff,
  1230. X    CTlog,
  1231. X    CTmemstat,
  1232. X    CTnice,
  1233. X    CTnl,
  1234. X    CTnlin,
  1235. X    CTnlout,
  1236. X    CToa,
  1237. X    CTparity,
  1238. X    CTpcmd,
  1239. X    CTpid,
  1240. X    CTplog,
  1241. X    CTpopd,
  1242. X    CTptrace,
  1243. X    CTpushd,
  1244. X    CTputf,
  1245. X    CTpwd,
  1246. X    CTredial,
  1247. X    CTrev,
  1248. X    CTrk,
  1249. X    CTrs,
  1250. X    CTrtscts,
  1251. X    CTrx,
  1252. X    CTry,
  1253. X    CTrz,
  1254. X    CTsdname,
  1255. X    CTsgr,
  1256. X    CTsk,
  1257. X    CTss,
  1258. X    CTstat,
  1259. X    CTsx,
  1260. X    CTsy,
  1261. X    CTsz,
  1262. X    CTtime,
  1263. X    CTts,
  1264. X    CTtty,
  1265. X    CTxa,
  1266. X    CTxlog,
  1267. X    CTxon,
  1268. X    CT____end,
  1269. X
  1270. X    CTdummy1 = 120,
  1271. X    CTdummy2,
  1272. X    CTdummy3,
  1273. X    CTdummy4
  1274. X};
  1275. X
  1276. X#define TOKEN_QUAN    128        /* for help package */
  1277. X
  1278. X/*
  1279. X * if compiling helpgen, we need dummy functions for linker
  1280. X * to resolve though they are never called; when compiling ecu,
  1281. X * we just declare them as integer functions
  1282. X */
  1283. X#if defined(HELPGEN)
  1284. X#define S static
  1285. X#define BODY {;}
  1286. X#else
  1287. X#define S
  1288. X#define BODY ;
  1289. X#endif
  1290. X
  1291. XS int pcmd_autorz() BODY
  1292. XS int pcmd_baud() BODY
  1293. XS int pcmd_break() BODY
  1294. XS int pcmd_cd() BODY
  1295. XS int pcmd_clrx() BODY
  1296. XS int pcmd_cls() BODY
  1297. XS int pcmd_color() BODY
  1298. XS int pcmd_continue() BODY
  1299. XS int pcmd_cursor() BODY
  1300. XS int pcmd_dcdwatch() BODY
  1301. XS int pcmd_delline() BODY
  1302. XS int pcmd_dial() BODY
  1303. XS int pcmd_do() BODY
  1304. XS int pcmd_duplex() BODY
  1305. XS int pcmd_echo() BODY
  1306. XS int pcmd_eeol() BODY
  1307. XS int pcmd_else() BODY
  1308. XS int pcmd_exec() BODY
  1309. XS int pcmd_exit() BODY
  1310. XS int pcmd_expresp() BODY
  1311. XS int pcmd_getf() BODY
  1312. X#if    defined(FASI)
  1313. XS int pcmd_fasi() BODY
  1314. X#endif
  1315. XS int pcmd_fchmod() BODY
  1316. XS int pcmd_fclose() BODY
  1317. XS int pcmd_fgetc() BODY
  1318. XS int pcmd_fgets() BODY
  1319. XS int pcmd_fkey() BODY
  1320. XS int pcmd_fkmap() BODY
  1321. XS int pcmd_flush() BODY
  1322. XS int pcmd_fopen() BODY
  1323. XS int pcmd_fputc() BODY
  1324. XS int pcmd_fputs() BODY
  1325. XS int pcmd_fread() BODY
  1326. XS int pcmd_fseek() BODY
  1327. XS int pcmd_fdel() BODY
  1328. XS int pcmd_fwrite() BODY
  1329. XS int pcmd_gosub() BODY
  1330. XS int pcmd_gosubb() BODY
  1331. XS int pcmd_goto() BODY
  1332. XS int pcmd_gotob() BODY
  1333. XS int pcmd_hangup() BODY
  1334. XS int pcmd_hexdump() BODY
  1335. XS int pcmd_home() BODY
  1336. XS int pcmd_icolor() BODY
  1337. XS int pcmd_insline() BODY
  1338. XS int pcmd_ifge() BODY
  1339. XS int pcmd_ifgt() BODY
  1340. XS int pcmd_ifi() BODY
  1341. XS int pcmd_ifle() BODY
  1342. XS int pcmd_iflt() BODY
  1343. XS int pcmd_ifnz() BODY
  1344. XS int pcmd_ifs() BODY
  1345. XS int pcmd_ifz() BODY
  1346. XS int pcmd_lbreak() BODY
  1347. XS int pcmd_lgets() BODY
  1348. XS int pcmd_logevent() BODY
  1349. XS int pcmd_lookfor() BODY
  1350. X/* S int pcmd_mkdir() BODY */
  1351. XS int pcmd_mkvar() BODY
  1352. XS int pcmd_nap() BODY
  1353. XS int pcmd_nice() BODY
  1354. XS int pcmd_parity() BODY
  1355. XS int pcmd_pclose() BODY
  1356. XS int pcmd_plog() BODY
  1357. XS int pcmd_popd() BODY
  1358. XS int pcmd_popen() BODY
  1359. XS int pcmd_prompt() BODY
  1360. XS int pcmd_ptrace() BODY
  1361. XS int pcmd_pushd() BODY
  1362. XS int pcmd_putf() BODY
  1363. XS int pcmd_return() BODY
  1364. XS int pcmd_rk() BODY
  1365. XS int pcmd_rlog() BODY
  1366. XS int pcmd_rname() BODY
  1367. XS int pcmd_rs() BODY
  1368. XS int pcmd_rtscts() BODY
  1369. XS int pcmd_rx() BODY
  1370. XS int pcmd_ry() BODY
  1371. XS int pcmd_rz() BODY
  1372. XS int pcmd_scrdump() BODY
  1373. XS int pcmd_send() BODY
  1374. XS int pcmd_set() BODY
  1375. XS int pcmd_setline() BODY
  1376. XS int pcmd_sk() BODY
  1377. XS int pcmd_ss() BODY
  1378. XS int pcmd_sx() BODY
  1379. XS int pcmd_sy() BODY
  1380. XS int pcmd_system() BODY
  1381. XS int pcmd_sz() BODY
  1382. XS int pcmd_upon() BODY
  1383. XS int pcmd_vidcolor() BODY
  1384. XS int pcmd_vidnorm() BODY
  1385. XS int pcmd_vidrev() BODY
  1386. XS int pcmd_whilei() BODY
  1387. XS int pcmd_whiles() BODY
  1388. XS int pcmd_xon() BODY
  1389. X
  1390. X/* command classification */
  1391. X#define ccG  1    /* general command */
  1392. X#define ccC  2    /* comm command */
  1393. X#define ccT  3    /* transfer command */
  1394. X#define ccP  4    /* procedure-related command */
  1395. X
  1396. Xtypedef struct p_cmd
  1397. X{ 
  1398. X    char *cmd;        /* command string */
  1399. X    short min_ch;    /* min chars for match (0 if not interactive) */
  1400. X    short token;    /* command number (if interactive) */
  1401. X    char *descr;    /* command description (if interactive) */
  1402. X    PFI proc;        /* procedure cmd handler (or 0) */
  1403. X    short cmdclass;    /* cc{C,G,P,X} or 0 (for help processor) */
  1404. X}    P_CMD;
  1405. X
  1406. X#if !defined(DECLARE_P_CMD)
  1407. X#if defined(NEED_P_CMD)
  1408. Xextern P_CMD icmd_cmds[];
  1409. X#endif
  1410. X#else
  1411. XP_CMD icmd_cmds[] =
  1412. X{
  1413. X    { "ax",        2,CTax,        "ascii char to hex/oct/dec",    0,            ccG},
  1414. X    { "autorz",    6,CTautorz,    "set auto ZMODEM receive",        pcmd_autorz,ccT},
  1415. X    { "baud",    2,CTbaud,    "set/display line baud rate",    pcmd_baud,    ccC},
  1416. X    { "bn",        2,CTbn,        "all console event alarm",        0,            ccG},
  1417. X    { "break",    2,CTbreak,    "send break to remote",            pcmd_break,    ccC},
  1418. X    { "cd",        2,CTcd,        "change current directory",        pcmd_cd,    ccG},
  1419. X    { "clrx",    2,CTclrx,    "simulate XON from remote",        pcmd_clrx,    ccC},
  1420. X    { "cls",    0,0,        "",                                pcmd_cls,    0  },
  1421. X    { "color",    0,0,        "",                                pcmd_color,    0  },
  1422. X    { "continue",0,0,        "",                                pcmd_continue,0},
  1423. X    { "cursor",    0,0,        "",                                pcmd_cursor,0  },
  1424. X    { "da",        2,CTda,        "decimal to ascii char",        0,          ccG},
  1425. X    { "dcdwatch",3,CTdcdwatch,"control DCD disconnect",        pcmd_dcdwatch,ccC},
  1426. X    { "dial",    1,CTdial,    "dial remote destination",        pcmd_dial, ccC},
  1427. X    { "delline",0,0,        "",                                pcmd_delline,0 },
  1428. X    { "do",        2,CTdo,        "perform procedure",            pcmd_do,   ccP},
  1429. X    { "duplex",    2,CTduplex,    "set/display duplex",            pcmd_duplex,ccC},
  1430. X    { "echo",    0,0,        "",                                pcmd_echo,  0  },
  1431. X    { "eeol",    0,0,        "",                                pcmd_eeol,  0  },
  1432. X    { "else",    0,0,        "",                                pcmd_else,  0  },
  1433. X    { "eto",    3,CTeto,    "ESC/fkey timeout",                0,         ccG},
  1434. X    { "exec",    0,0,        "",                                pcmd_exec,  0 },
  1435. X    { "exit",    2,CTexit,    "hang up, exit program",        pcmd_exit, ccG},
  1436. X    { "expresp",0,0,        "",                                pcmd_expresp,0 },
  1437. X#if    defined(FASI)
  1438. X    { "fasi",    2,CTfasi,    "FAS/i driver control",            pcmd_fasi,    ccC},
  1439. X#endif
  1440. X    { "fchmod",    0,0,        "",                                pcmd_fchmod,0  },
  1441. X    { "fclose",    0,0,        "",                                pcmd_fclose,0  },
  1442. X    { "fdel",    0,0,        "",                                pcmd_fdel,  0  },
  1443. X    { "fgetc",    0,0,        "",                                pcmd_fgetc, 0  },
  1444. X    { "fgets",    0,0,        "",                                pcmd_fgets, 0  },
  1445. X    { "fi",        2,CTfi,        "send text file to line",        0,         ccG },
  1446. X    { "fkey",    3,CTfkey,    "function key definition",        pcmd_fkey, ccG },
  1447. X    { "fkmap",    3,CTfkmap,    "redefine function key map",    pcmd_fkmap,ccG },
  1448. X    { "flush",    0,0,        "",                                pcmd_flush, 0  },
  1449. X    { "fopen",    0,0,        "",                                pcmd_fopen, 0  },
  1450. X    { "fputc",    0,0,        "",                                pcmd_fputc, 0  },
  1451. X    { "fputs",    0,0,        "",                                pcmd_fputs, 0  },
  1452. X    { "fread",    0,0,        "",                                pcmd_fread, 0  },
  1453. X    { "fseek",    0,0,        "",                                pcmd_fseek, 0  },
  1454. X    { "fwrite",    0,0,        "",                                pcmd_fwrite,0  },
  1455. X    { "getf",    0,0,        "",                                pcmd_getf,  0  },
  1456. X    { "gosub",    0,0,        "",                                pcmd_gosub, 0  },
  1457. X    { "gosubb",    0,0,        "",                                pcmd_gosubb,0  },
  1458. X    { "goto",    0,0,        "",                                pcmd_goto,  0  },
  1459. X    { "gotob",    0,0,        "",                                pcmd_gotob, 0  },
  1460. X    { "hangup",    2,CThangup,    "hang up modem",                pcmd_hangup,ccC},
  1461. X    { "help",    2,CThelp,    "invoke help",                    0,         ccG },
  1462. X    { "hexdump",0,0,        "",                                pcmd_hexdump,0 },
  1463. X    { "home",    0,0,        "",                                pcmd_home,  0  },
  1464. X    { "icolor",    0,0,        "",                                pcmd_icolor,0  },
  1465. X    { "ifge",    0,0,        "",                                pcmd_ifge,  0  },
  1466. X    { "ifgt",    0,0,        "",                                pcmd_ifgt,  0  },
  1467. X    { "ifi",    0,0,        "",                                pcmd_ifi,   0  },
  1468. X    { "ifle",    0,0,        "",                                pcmd_ifle,  0  },
  1469. X    { "iflt",    0,0,        "",                                pcmd_iflt,  0  },
  1470. X    { "ifnz",    0,0,        "",                                pcmd_ifnz,  0  },
  1471. X    { "ifs",    0,0,        "",                                pcmd_ifs,   0  },
  1472. X    { "ifz",    0,0,        "",                                pcmd_ifz,   0  },
  1473. X    { "insline",0,0,        "",                                pcmd_insline,0 },
  1474. X    { "kbdtest",4,CTkbdtest,"test keyboard mapping",        0,         ccG },
  1475. X    { "lbreak",    0,0,        "",                                pcmd_lbreak,0  },
  1476. X    { "llp",    2,CTllp,    "set session log to /dev/lp",    0,         ccG },
  1477. X    { "lgets",    0,0,        "",                                pcmd_lgets, 0  },
  1478. X    { "loff",    3,CTloff,    "turn off session logging",        0,         ccG },
  1479. X    { "log",    3,CTlog,    "session logging control",        0,         ccG },
  1480. X    { "logevent",0,0,        "",                                pcmd_logevent,0},
  1481. X    { "lookfor",0,0,        "",                                pcmd_lookfor,0 },
  1482. X#if defined(MALLOC_3X)
  1483. X    { "memstat",3,CTmemstat,"",                                0,          0  },
  1484. X#endif
  1485. X/*    { "mkdir",    3,CTmkdir,    "mkdir <dirname>",                pcmd_mkdir, ccG}, */
  1486. X    { "mkvar",    0,0,        "",                                pcmd_mkvar, 0  },
  1487. X    { "nap",    0,0,        "",                                pcmd_nap,   0  },
  1488. X    { "nice",    2,CTnice,    "change process nice (0-39)",    pcmd_nice,  0  },
  1489. X    { "nl",        2,CTnl,        "display CR/LF mapping",        0,         ccC },
  1490. X    { "nlin",    3,CTnlin,    "set receive CR/LF mapping",    0,         ccC },
  1491. X    { "nlout",    3,CTnlout,    "set transmit CR/LF mapping",    0,         ccC },
  1492. X    { "oa",        2,CToa,        "octal to ascii char",            0,         ccG },
  1493. X    { "parity",    3,CTparity,    "set/display line parity",        pcmd_parity,ccC},
  1494. X    { "pclose",    0,0,        "",                                pcmd_pclose,0  },
  1495. X    { "pcmd",    2,CTpcmd,    "execute procedure command",    0,         ccP },
  1496. X    { "pid",    2,CTpid,    "display process ids",            0,         ccG },
  1497. X    { "plog",    2,CTplog,    "control procedure logging",    pcmd_plog, ccP },
  1498. X    { "popd",    2,CTpopd,    "pop to previous directory",    pcmd_popd, ccG },
  1499. X    { "popen",    0,0,        "",                                pcmd_popen, 0  },
  1500. X    { "prompt",    0,0,        "",                                pcmd_prompt,0  },
  1501. X    { "ptrace",    2,CTptrace,    "control procedure trace",        pcmd_ptrace,ccP},
  1502. X    { "pushd",    2,CTpushd,    "push to new directory",        pcmd_pushd, ccG},
  1503. X    { "putf",    0,0,        "",                                pcmd_putf,  0  },
  1504. X    { "pwd",    2,CTpwd,    "print working directory",        0,         ccG },
  1505. X    { "redial",    3,CTredial,    "redial last number",            0,         ccC },
  1506. X    { "return",    0,0,        "",                                pcmd_return,0  },
  1507. X    { "rev",    3,CTrev,    "ecu revision/make date",        0,         ccG },
  1508. X    { "rk",        2,CTrk,        "receive via C-Kermit",            pcmd_rk,   ccT },
  1509. X    { "rlog",    0,0,        "",                                pcmd_rlog,  0  },
  1510. X    { "rname",    0,0,        "",                                pcmd_rname, 0  },
  1511. X    { "rs",        2,CTrs,        "receive via SEAlink",            pcmd_rs,   ccT },
  1512. X    { "rtscts",    3,CTrtscts,    "RTS/CTS flow control",            pcmd_rtscts,ccC},
  1513. X    { "rx",        2,CTrx,        "receive via XMODEM/CRC",        pcmd_rx,   ccT },
  1514. X    { "ry",        2,CTry,        "receive via YMODEM Batch",        pcmd_ry,   ccT },
  1515. X    { "rz",        2,CTrz,        "receive via ZMODEM/CRC32",        pcmd_rz,   ccT },
  1516. X    { "scrdump",0,0,        "",                                pcmd_scrdump,0 },
  1517. X    { "sdname",    3,CTsdname,    "select screen dump name",        0,         ccC },
  1518. X    { "send",    0,0,        "",                                pcmd_send,  0  },
  1519. X    { "set",    0,0,        "",                                pcmd_set,   0  },
  1520. X    { "setline",0,0,        "",                                pcmd_setline,0 },
  1521. X    { "sgr",    2,CTsgr,    "send command/get response",    0,         ccC },
  1522. X    { "sk",        2,CTsk,        "send via C-Kermit",            pcmd_sk,   ccT },
  1523. X    { "ss",        2,CTss,        "send via SEAlink",                pcmd_ss,   ccT },
  1524. X    { "stat",    2,CTstat,    "general status",                0,         ccG },
  1525. X    { "sx",        2,CTsx,        "send via XMODEM/CRC",            pcmd_sx,   ccT },
  1526. X    { "sy",        2,CTsy,        "send via YMODEM Batch",        pcmd_sy,   ccT },
  1527. X    { "system",    0,CTsy,        "",                                pcmd_system,0  },
  1528. X    { "sz",        2,CTsz,        "send via ZMODEM/CRC32",        pcmd_sz,   ccT },
  1529. X    { "time",    2,CTtime,    "time of day",                    0,         ccG },
  1530. X    { "ts",        2,CTts,        "termio display",                0,         ccC },
  1531. X    { "tty",    2,CTtty,    "console tty name",                0,         ccG },
  1532. X    { "upon",    0,0,        "",                                pcmd_upon, 0   },
  1533. X    { "vidcolor",0,0,        "",                                pcmd_vidcolor,0},
  1534. X    { "vidnorm",0,0,        "",                                pcmd_vidnorm,0 },
  1535. X    { "vidrev",    0,0,        "",                                pcmd_vidrev,0  },
  1536. X    { "whilei",    0,0,        "",                                pcmd_whilei,0  },
  1537. X    { "whiles",    0,0,        "",                                pcmd_whiles,0  },
  1538. X    { "xa",        2,CTxa,        "hex to ascii char",            0,         ccG },
  1539. X    { "xlog",    2,CTxlog,    "protocol packet logging",        0,         ccT },
  1540. X    { "xon",    2,CTxon,    "xon/xoff flow control",        pcmd_xon,  ccC },
  1541. X/* these cmds are interecepted by special code in ecucmd.h and appear
  1542. X * here only so they will be picked up by the help system.
  1543. X */
  1544. X    { "!",        1,CTdummy1,    "execute shell (tty)",            0,         ccG },
  1545. X    { "$",        1,CTdummy2,    "execute shell (comm line)",    0,         ccG },
  1546. X    { "-",        1,CTdummy3,    "execute program",                0,         ccG },
  1547. X    { "?",        1,CTdummy4,    "get help",                        0,         ccG },
  1548. X    { "",        0,-1,"",0,0 }    /* list ends with token value of -1 */
  1549. X};
  1550. X#endif
  1551. X
  1552. X#endif /* _ecucmd_h */
  1553. X
  1554. X/* end of ecucmd.h */
  1555. X/* vi: set tabstop=4 shiftwidth=4: */
  1556. SHAR_EOF
  1557. chmod 0644 ecucmd.h ||
  1558. echo 'restore of ecucmd.h failed'
  1559. Wc_c="`wc -c < 'ecucmd.h'`"
  1560. test 12720 -eq "$Wc_c" ||
  1561.     echo 'ecucmd.h: original size 12720, current size' "$Wc_c"
  1562. rm -f _shar_wnt_.tmp
  1563. fi
  1564. # ============= ecucurses.h ==============
  1565. if test -f 'ecucurses.h' -a X"$1" != X"-c"; then
  1566.     echo 'x - skipping ecucurses.h (File already exists)'
  1567.     rm -f _shar_wnt_.tmp
  1568. else
  1569. > _shar_wnt_.tmp
  1570. echo 'x - extracting ecucurses.h (Text)'
  1571. sed 's/^X//' << 'SHAR_EOF' > 'ecucurses.h' &&
  1572. X/*+-------------------------------------------------------------------------
  1573. X    ecucurses.h - bypass SCO <curses.h> problems
  1574. X    wht@n4hgf.Mt-Park.GA.US
  1575. X
  1576. XIt is impossible to avoid warnings with various SCO curses installation
  1577. Xoptions, so we do it here
  1578. X--------------------------------------------------------------------------*/
  1579. X/*+:EDITS:*/
  1580. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  1581. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1582. X/*:03-27-1992-16:21-wht@n4hgf-re-include protection for all .h files */
  1583. X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  1584. X/*:05-02-1991-02:35-wht@n4hgf-creation */
  1585. X
  1586. X#ifndef _ecucurses_h
  1587. X#define _ecucurses_h
  1588. X
  1589. X/*
  1590. X * remove any pre-conceived notion of TERMINFO vs. TERMCAP curses (SCO)
  1591. X */
  1592. X#if defined(M_TERMINFO)
  1593. X#undef M_TERMINFO
  1594. X#endif /* M_TERMINFO */
  1595. X
  1596. X#if defined(M_TERMCAP)
  1597. X#undef M_TERMCAP
  1598. X#endif /* M_TERMCAP */
  1599. X
  1600. X
  1601. X#if defined(M_SYSV)        /* any SCO */
  1602. X/*
  1603. X * SCO uses TERMCAP curses at this time
  1604. X */
  1605. X#define M_TERMCAP
  1606. X#if defined(M_TERMCAP)
  1607. X# include <tcap.h>
  1608. X#else /* !M_TERMCAP */
  1609. X# include <tinfo.h>
  1610. X#endif /* M_TERMCAP */
  1611. X#else /* !M_SYSV */
  1612. X#if defined(sun)
  1613. X# include <curses.h>
  1614. X#else
  1615. X/*
  1616. X * other uses TERMINFO curses at this time
  1617. X */
  1618. X#define M_TERMINFO        /* some ecu code requires this despite non-SCO */
  1619. X# include <curses.h>
  1620. X#endif /* sun */
  1621. X#endif /* M_SYSV */
  1622. X
  1623. X#endif /* _ecucurses_h */
  1624. X
  1625. X/* vi: set tabstop=4 shiftwidth=4: */
  1626. X/* end of ecucurses.h */
  1627. SHAR_EOF
  1628. chmod 0644 ecucurses.h ||
  1629. echo 'restore of ecucurses.h failed'
  1630. Wc_c="`wc -c < 'ecucurses.h'`"
  1631. test 1402 -eq "$Wc_c" ||
  1632.     echo 'ecucurses.h: original size 1402, current size' "$Wc_c"
  1633. rm -f _shar_wnt_.tmp
  1634. fi
  1635. # ============= ecudump.c ==============
  1636. if test -f 'ecudump.c' -a X"$1" != X"-c"; then
  1637.     echo 'x - skipping ecudump.c (File already exists)'
  1638.     rm -f _shar_wnt_.tmp
  1639. else
  1640. > _shar_wnt_.tmp
  1641. echo 'x - extracting ecudump.c (Text)'
  1642. sed 's/^X//' << 'SHAR_EOF' > 'ecudump.c' &&
  1643. X/*+-----------------------------------------------------------------------
  1644. X    ecudump.c  -- very generic hex/graphics dump development aid
  1645. X    wht@n4hgf.Mt-Park.GA.US
  1646. X
  1647. X  Defined functions:
  1648. X    dump_putc(ch)
  1649. X    dump_puts(str)
  1650. X    hex_dump(str,len,title,terse_flag)
  1651. X    hex_dump16(int16)
  1652. X    hex_dump32(int32)
  1653. X    hex_dump4(int4)
  1654. X    hex_dump8(int8)
  1655. X    hex_dump_fp(fp,str,len,title,terse_flag)
  1656. X
  1657. X------------------------------------------------------------------------*/
  1658. X/*+:EDITS:*/
  1659. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  1660. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1661. X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  1662. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1663. X
  1664. X#include "ecu.h"
  1665. X
  1666. XFILE *dumpfp;
  1667. X
  1668. X/*+-------------------------------------------------------------------------
  1669. X    dump_putc(ch)
  1670. X--------------------------------------------------------------------------*/
  1671. Xvoid
  1672. Xdump_putc(ch)
  1673. Xchar ch;
  1674. X{
  1675. X    if(dumpfp == stderr)
  1676. X        pputc(ch);
  1677. X    else
  1678. X        fputc(ch,dumpfp);
  1679. X}    /* end of dump_putc */
  1680. X
  1681. X
  1682. X/*+-------------------------------------------------------------------------
  1683. X    dump_puts(str)
  1684. X--------------------------------------------------------------------------*/
  1685. Xvoid
  1686. Xdump_puts(str)
  1687. Xchar *str;
  1688. X{
  1689. X    if(dumpfp == stderr)
  1690. X        pputs(str);
  1691. X    else
  1692. X        fputs(str,dumpfp);
  1693. X}    /* end of dump_puts */
  1694. X
  1695. X
  1696. X/*+-----------------------------------------------------------------------
  1697. X    hex_dump#... subservient routines
  1698. X------------------------------------------------------------------------*/
  1699. Xvoid hex_dump4(int4)
  1700. Xuchar int4;
  1701. X{
  1702. X    int4 &= 15;
  1703. X    dump_putc((int4 >= 10) ? (int4 + 'A' - 10) : (int4 + '0'));
  1704. X}
  1705. X
  1706. Xvoid hex_dump8(int8)
  1707. Xuchar int8;
  1708. X{
  1709. X    hex_dump4(int8 >> 4);
  1710. X    hex_dump4(int8);
  1711. X}
  1712. X
  1713. Xvoid hex_dump16(int16)
  1714. Xushort int16;
  1715. X{
  1716. X    hex_dump8(int16 >> 8);
  1717. X    hex_dump8(int16);
  1718. X}
  1719. X
  1720. Xvoid hex_dump32(int32)
  1721. Xulong int32;
  1722. X{
  1723. X    hex_dump16(int32 >> 16);
  1724. X    hex_dump16(int32);
  1725. X}
  1726. X
  1727. X
  1728. X/*+-----------------------------------------------------------------
  1729. X    hex_dump_fp(fp,str,len,title,terse_flag)
  1730. X
  1731. X  if 'title' not NULL, title is printed... 'terse_flag'
  1732. X  controls whether or not the title is "conspicuous" with
  1733. X  hyphens before and after it making title line >70 chars long
  1734. X  If len negative, print no buffer offsets.
  1735. X------------------------------------------------------------------*/
  1736. Xvoid
  1737. Xhex_dump_fp(fp,str,len,title,terse_flag)
  1738. XFILE *fp;
  1739. Xchar *str;
  1740. Xint len;
  1741. Xchar *title;
  1742. Xint terse_flag;
  1743. X{
  1744. X    register ipos = 0;
  1745. X    register itmp;
  1746. X    int istr;
  1747. X    int print_offset = (len > 16);
  1748. X
  1749. X    if(!print_offset)
  1750. X        len = -len;
  1751. X
  1752. X    dumpfp = fp;
  1753. X
  1754. X    if(title && (istr = strlen(title)))
  1755. X    {
  1756. X        if(!terse_flag)
  1757. X        {
  1758. X            ipos = (((print_offset) ? 73 : 67) - istr) / 2;
  1759. X            itmp = ipos;
  1760. X            while(itmp--)
  1761. X                dump_putc('-');
  1762. X            dump_putc(' ');
  1763. X            if(istr & 1)
  1764. X                ipos--;
  1765. X        }
  1766. X        dump_puts(title);
  1767. X        if(!terse_flag)
  1768. X        {
  1769. X            dump_putc(' ');
  1770. X            while(ipos--)
  1771. X                dump_putc('-');
  1772. X        }
  1773. X        if(terse_flag && (len < 12))
  1774. X            dump_putc(' ');
  1775. X        else
  1776. X        {
  1777. X            if(dumpfp == stderr)
  1778. X                dump_puts("\r\n");
  1779. X            else
  1780. X                dump_puts("\n");
  1781. X        }
  1782. X    }
  1783. X
  1784. X    istr = 0;
  1785. X    while(istr < len)
  1786. X    {
  1787. X        if(print_offset)
  1788. X        {
  1789. X            hex_dump16(istr);
  1790. X            dump_puts("  ");
  1791. X        }
  1792. X        for(itmp = 0; itmp < 16; ++itmp)
  1793. X        {
  1794. X            ipos = istr + itmp;
  1795. X            if(ipos >= len)
  1796. X            {
  1797. X                if(!terse_flag)
  1798. X                    dump_puts("   ");
  1799. X                continue;
  1800. X            }
  1801. X            if(itmp)
  1802. X                dump_putc(' ');
  1803. X            hex_dump8(str[ipos]);
  1804. X        }
  1805. X        dump_puts("  | ");
  1806. X        for(itmp = 0; itmp < 16; ++itmp)
  1807. X        {
  1808. X            ipos = istr + itmp;
  1809. X            if( (ipos) >= len)
  1810. X            {
  1811. X                if(!terse_flag)
  1812. X                    dump_putc(' ');
  1813. X            }
  1814. X            else
  1815. X            {
  1816. X                dump_putc((str[ipos] >= ' ' && str[ipos] < 0x7f)
  1817. X                    ? str[ipos] : '.' );
  1818. X            }
  1819. X        }
  1820. X        if(dumpfp == stderr)
  1821. X            dump_puts(" |\r\n");
  1822. X        else
  1823. X            dump_puts(" |\n");
  1824. X        istr += 16;
  1825. X    }   /* end of while(istr < len) */
  1826. X
  1827. X}    /* end of hex_dump_fp */
  1828. X
  1829. X/*+-------------------------------------------------------------------------
  1830. X    hex_dump(str,len,title,terse_flag)
  1831. X--------------------------------------------------------------------------*/
  1832. Xvoid
  1833. Xhex_dump(str,len,title,terse_flag)
  1834. Xchar *str;
  1835. Xint len;
  1836. Xchar *title;
  1837. Xint terse_flag;
  1838. X{
  1839. X    hex_dump_fp(stderr,str,len,title,terse_flag);
  1840. X}    /* end of hex_dump_fp */
  1841. X/* end of ecudump.c */
  1842. X/* vi: set tabstop=4 shiftwidth=4: */
  1843. SHAR_EOF
  1844. chmod 0644 ecudump.c ||
  1845. echo 'restore of ecudump.c failed'
  1846. Wc_c="`wc -c < 'ecudump.c'`"
  1847. test 4079 -eq "$Wc_c" ||
  1848.     echo 'ecudump.c: original size 4079, current size' "$Wc_c"
  1849. rm -f _shar_wnt_.tmp
  1850. fi
  1851. # ============= ecuerror.h ==============
  1852. if test -f 'ecuerror.h' -a X"$1" != X"-c"; then
  1853.     echo 'x - skipping ecuerror.h (File already exists)'
  1854.     rm -f _shar_wnt_.tmp
  1855. else
  1856. > _shar_wnt_.tmp
  1857. echo 'x - extracting ecuerror.h (Text)'
  1858. sed 's/^X//' << 'SHAR_EOF' > 'ecuerror.h' &&
  1859. X/*+-------------------------------------------------------------------------
  1860. X    ecuerror.h
  1861. X    wht@n4hgf.Mt-Park.GA.US
  1862. X
  1863. Xe_... values must not be changed without careful looking through code
  1864. Xerror numbers should be <= 0x7FFF to avoid problems with M_I286 versions
  1865. X--------------------------------------------------------------------------*/
  1866. X/*+:EDITS:*/
  1867. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  1868. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1869. X/*:03-27-1992-16:21-wht@n4hgf-re-include protection for all .h files */
  1870. X/*:08-25-1991-23:45-root@n4hgf2-add eSwitchesTooLong */
  1871. X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  1872. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1873. X
  1874. X#ifndef _ecuerror_h
  1875. X#define _ecuerror_h
  1876. X
  1877. X/* vi: set tabstop=4 shiftwidth=4: */
  1878. X/* end of ecuerror.h */
  1879. X#define e_USER                0x1000    /* user error differentiation */
  1880. X
  1881. X/* warning errors - do not stop proc execution */
  1882. X#define e_WARNING            0x3000
  1883. X#define eProcEmpty            0x3001  /* empty procedure */
  1884. X#define eWARNING_ALREADY    0x3002  /* warning already printed */
  1885. X#define eConnectFailed        0x3003    /* failed to connect */
  1886. X#define eNoSwitches            0x3004    /* no switch(es) to command */
  1887. X
  1888. X/* fatal errors - stop proc execution */
  1889. X#define e_FATAL                0x4000
  1890. X#define eIllegalCommand        0x4003  /* invalid command */
  1891. X#define eNoMemory            0x4004  /* no more memory available */
  1892. X#define eSyntaxError        0x4005  /* syntax error */
  1893. X#define eIllegalVarNumber    0x4006  /* number is invalid or out of range */
  1894. X#define eIllegalVarType        0x4007  /* unrecognized variable type */
  1895. X#define eNotInteger            0x4008  /* integer expected and not found */
  1896. X#define eFATAL_ALREADY        0x4011  /* fatal to proc, info already printed */
  1897. X#define eCONINT                0x4012  /* abort due to interrupt */
  1898. X#define eInvalidFunction    0x4013  /* invalid function name */
  1899. X#define eMissingLeftParen    0x4014  /* did not find expected left paren */
  1900. X#define eMissingRightParen    0x4015  /* did not find expected right paren */
  1901. X#define eCommaExpected        0x4016  /* expected comma not found */
  1902. X#define eProcStackTooDeep    0x4017  /* procedure stack depth exceeded */
  1903. X#define eInvalidRelOp        0x4018  /* invalid relational operator */
  1904. X#define eInvalidIntOp        0x4019  /* invalid integer operator */
  1905. X#define eInvalidStrOp        0x4020  /* invalid string operator */
  1906. X#define eNotExecutingProc    0x4022  /* not executing DO at this time */
  1907. X#define eInvalidLabel        0x4023  /* invalid label */
  1908. X#define eInternalLogicError    0x4025  /* internal logic error ... whoops */
  1909. X#define eEOF                0x4026  /* end of file or read error */
  1910. X#define eBufferTooSmall        0x4027  /* string too long */
  1911. X#define eNoParameter        0x4028  /* expected parameter not found */
  1912. X#define eBadParameter        0x4029  /* bad parameter */
  1913. X#define eInvalidHexNumber    0x402A    /* invalid hexadecimal digit */
  1914. X#define eInvalidDecNumber    0x402B    /* invalid decimal digit */
  1915. X#define eInvalidOctNumber    0x402C    /* invalid octal digit */
  1916. X#define eInteractiveCmd        0x402E    /* interactive command */
  1917. X#define eNoLineAttached        0x402F    /* no line (modem) attached */
  1918. X#define eBadFileNumber        0x4030    /* file number out of range */
  1919. X#define eNotImplemented        0x4031    /* not implemented */
  1920. X#define eDuplicateMatch        0x4032    /* more than one condition matches */
  1921. X#define eColonExpected        0x4033  /* expected colon not found */
  1922. X#define eLabelInvalidHere    0x4034  /* label not allowed on this statement */
  1923. X#define eNoCloseFrame        0x4035  /* missing '}' for '{' */
  1924. X#define eNoFrame            0x4036  /* missing command or command group after 'while' or 'if' */
  1925. X#define eMissingCommand        0x4037  /* expected command not found */
  1926. X#define eBreakCommand        0x4038  /* 'break' outside 'while' */
  1927. X#define eContinueCommand    0x4039  /* 'continue' outside 'while' */
  1928. X#define eElseCommand        0x403A  /* 'else' without matching 'if' */
  1929. X#define eInvalidVarName        0x403B  /* invalid variable name */
  1930. X#define eNoSuchVariable        0x403C  /* variable by this name not defined */
  1931. X#define eInvalidLogicOp        0x403D  /* invalid logical operator */
  1932. X#define eExpectRespondFail    0x403E  /* expect-respond failed */
  1933. X#define eSwitchesTooLong    0x403F    /* switches too long */
  1934. X
  1935. X/* DO attention getter */
  1936. X#define e_ProcAttn            0x7000
  1937. X#define eProcAttn_GOTO        0x7000  /* GOTO detected */
  1938. X#define eProcAttn_GOTOB        0x7001  /* GOTOB detected */
  1939. X#define eProcAttn_RETURN    0x7002  /* RETURN detected */
  1940. X#define eProcAttn_ESCAPE    0x7003  /* ESCAPE detected */
  1941. X#define eProcAttn_Interrupt    0x7004  /* procedure interrupted */
  1942. X#define eProcAttn_DCDloss    0x7005    /* DCD lost during procedure execution */
  1943. X
  1944. X#endif /* _ecuerror_h */
  1945. X
  1946. X/* vi: set tabstop=4 shiftwidth=4: */
  1947. X/* end of ecuerror.h */
  1948. SHAR_EOF
  1949. chmod 0644 ecuerror.h ||
  1950. echo 'restore of ecuerror.h failed'
  1951. Wc_c="`wc -c < 'ecuerror.h'`"
  1952. test 4535 -eq "$Wc_c" ||
  1953.     echo 'ecuerror.h: original size 4535, current size' "$Wc_c"
  1954. rm -f _shar_wnt_.tmp
  1955. fi
  1956. # ============= ecufinsert.c ==============
  1957. if test -f 'ecufinsert.c' -a X"$1" != X"-c"; then
  1958.     echo 'x - skipping ecufinsert.c (File already exists)'
  1959.     rm -f _shar_wnt_.tmp
  1960. else
  1961. > _shar_wnt_.tmp
  1962. echo 'x - extracting ecufinsert.c (Text)'
  1963. sed 's/^X//' << 'SHAR_EOF' > 'ecufinsert.c' &&
  1964. X#define USE_XON_XOFF
  1965. X/*+-------------------------------------------------------------------------
  1966. X    ecufinsert.c -- insert file onto comm line
  1967. X    wht@n4hgf.Mt-Park.GA.US
  1968. X
  1969. X  Defined functions:
  1970. X    expand_filename(fname,maxlen)
  1971. X    file_insert_clear_xoff()
  1972. X    file_insert_to_line(narg,arg)
  1973. X
  1974. X--------------------------------------------------------------------------*/
  1975. X/*+:EDITS:*/
  1976. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  1977. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1978. X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  1979. X/*:07-17-1991-07:04-wht@n4hgf-avoid SCO UNIX nap bug */
  1980. X/*:07-14-1991-18:18-wht@n4hgf-new ttygets functions */
  1981. X/*:04-27-1991-01:24-wht@n4hgf-expand_filename was NFG */
  1982. X/*:03-30-1991-12:40-wht@n4hgf-redi!donovan found q does not restart receiver */
  1983. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1984. X
  1985. X#include "ecu.h"
  1986. X#include "ecukey.h"
  1987. X#include "ecutty.h"
  1988. X
  1989. Xextern char kbdintr;        /* current input INTR */
  1990. Xextern ulong colors_current;
  1991. Xextern ulong colors_alert;
  1992. Xextern ulong colors_errors;
  1993. X
  1994. X/*+-------------------------------------------------------------------------
  1995. X    expand_filename(fname) - convert fnames with shell chars
  1996. X
  1997. Xreturn 0 if no shell characters found
  1998. X       -1 if shell expansion match found
  1999. X       1 if shell expansion found
  2000. X--------------------------------------------------------------------------*/
  2001. Xint
  2002. Xexpand_filename(fname,maxlen)
  2003. Xchar *fname;
  2004. Xint maxlen;
  2005. X{
  2006. Xchar *expcmd;
  2007. X
  2008. X    if(!find_shell_chars(fname))
  2009. X        return(0);
  2010. X
  2011. X    if(expand_wildcard_list(fname,&expcmd))
  2012. X    {
  2013. X        fputs("\r\n",se);
  2014. X        fputs(expcmd,se);
  2015. X        fputs("\r\n",se);
  2016. X        return(-1);
  2017. X    }
  2018. X    strncpy(fname,expcmd,maxlen);
  2019. X    fname[maxlen - 1] = 0;
  2020. X    if(strchr(expcmd,' '))
  2021. X    {
  2022. X        fputs("\r\nToo many files:\r\n",se);
  2023. X        fputs(expcmd,se);
  2024. X        fputs("\r\n",se);
  2025. X        free(expcmd);
  2026. X        return(-1);
  2027. X    }
  2028. X    strncpy(fname,expcmd,maxlen - 1);
  2029. X    *(fname + maxlen - 1) = 0;
  2030. X    free(expcmd);
  2031. X    return(0);
  2032. X
  2033. X}    /* end of expand_filename */
  2034. X
  2035. X/*+-------------------------------------------------------------------------
  2036. X    file_insert_clear_xoff()
  2037. X--------------------------------------------------------------------------*/
  2038. Xvoid
  2039. Xfile_insert_clear_xoff()
  2040. X{
  2041. X#ifdef USE_XON_XOFF
  2042. X#ifdef SAY_CLEARED_XOFF
  2043. Xulong colors_at_entry = colors_current;
  2044. X
  2045. X    setcolor(colors_alert);
  2046. X    fputs("--> local XOFF cleared\r",se);
  2047. X    setcolor(colors_at_entry);
  2048. X#endif
  2049. X    lclear_xmtr_xoff();
  2050. X#endif
  2051. X}    /* end of file_insert_clear_xoff */
  2052. X
  2053. X/*+-------------------------------------------------------------------------
  2054. X    file_insert_to_line(narg,arg)
  2055. X--------------------------------------------------------------------------*/
  2056. Xfile_insert_to_line(narg,arg)
  2057. Xint narg;
  2058. Xchar **arg;
  2059. SHAR_EOF
  2060. true || echo 'restore of ecufinsert.c failed'
  2061. fi
  2062. echo 'End of ecu320 part 6'
  2063. echo 'File ecufinsert.c is continued in part 7'
  2064. echo 7 > _shar_seq_.tmp
  2065. exit 0
  2066.  
  2067. exit 0 # Just in case...
  2068.