home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume32 / ecu / part06 < prev    next >
Encoding:
Text File  |  1992-09-10  |  56.9 KB  |  2,062 lines

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