home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume21 / ecu / part04 < prev    next >
Text File  |  1991-08-05  |  55KB  |  1,982 lines

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