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

  1. Newsgroups: comp.sources.misc
  2. From: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
  3. Subject:  v21i069:  ecu - ECU async comm package rev 3.10, Part17/37
  4. Message-ID: <1991Aug4.015850.9156@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 1e29e3d2feb4db23702e8e7d68082877
  6. Date: Sun, 4 Aug 1991 01:58:50 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 69
  11. Archive-name: ecu/part17
  12. Environment: SCO, XENIX, ISC
  13. Supersedes: ecu3: Volume 16, Issue 25-59
  14.  
  15. ---- Cut Here and feed the following to sh ----
  16. #!/bin/sh
  17. # this is ecu310.17 (part 17 of ecu310)
  18. # do not concatenate these parts, unpack them in order with /bin/sh
  19. # file pcmdif.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" != 17; 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 pcmdif.c'
  39. else
  40. echo 'x - continuing file pcmdif.c'
  41. sed 's/^X//' << 'SHAR_EOF' >> 'pcmdif.c' &&
  42. X    erc = eInvalidLogicOp;
  43. X    if(!strncmp(cptr,"&&",2))
  44. X    {
  45. X        *op_returned = OP_AND;
  46. X        erc = 0;
  47. X    }
  48. X    else if(!strncmp(cptr,"||",2))
  49. X    {
  50. X        *op_returned = OP_OR;
  51. X        erc = 0;
  52. X    }
  53. X    if(!erc)
  54. X        param->index += 2;
  55. X    return(erc);
  56. X
  57. X}    /* end of get_logicop */
  58. X
  59. X/*+-------------------------------------------------------------------------
  60. X    test_truth_int(int1,relop,int2)
  61. X--------------------------------------------------------------------------*/
  62. Xint
  63. Xtest_truth_int(int1,relop,int2)
  64. Xlong int1;
  65. Xint relop;
  66. Xlong int2;
  67. X{
  68. Xregister truth = 0;
  69. X
  70. X    switch(relop)
  71. X    {
  72. X    case OP_EQ:
  73. X        truth = (int1 == int2);
  74. X        break;
  75. X    case OP_NE:
  76. X        truth = (int1 != int2);
  77. X        break;
  78. X    case OP_GT:
  79. X        truth = (int1 > int2);
  80. X        break;
  81. X    case OP_LT:
  82. X        truth = (int1 < int2);
  83. X        break;
  84. X    case OP_GE:
  85. X        truth = (int1 >= int2);
  86. X        break;
  87. X    case OP_LE:
  88. X        truth = (int1 <= int2);
  89. X        break;
  90. X    }
  91. X    return(truth);
  92. X
  93. X}    /* end of test_truth_int */
  94. X
  95. X/*+-------------------------------------------------------------------------
  96. X    get_truth_int(param,truth)
  97. X--------------------------------------------------------------------------*/
  98. Xint
  99. Xget_truth_int(param,truth)
  100. XESD *param;
  101. Xint *truth;
  102. X{
  103. Xregister erc;
  104. Xlong int1;
  105. Xlong int2;
  106. Xint operator;
  107. Xint truth2;
  108. X
  109. X    if(erc = gint(param,&int1))
  110. X        return(erc);
  111. X    if(erc = get_relop(param,&operator))
  112. X        return(erc);
  113. X    if(erc = gint(param,&int2))
  114. X        return(erc);
  115. X    *truth = test_truth_int(int1,operator,int2);
  116. X
  117. X    while(!get_logicop(param,&operator))
  118. X    {
  119. X        if(erc = get_truth_int(param,&truth2))
  120. X            return(erc);
  121. X        switch(operator)
  122. X        {
  123. X            case OP_AND:
  124. X                *truth &= truth2;
  125. X                break;
  126. X
  127. X            case OP_OR:
  128. X                *truth |= truth2;
  129. X                break;
  130. X        }
  131. X    }
  132. X    return(0);
  133. X
  134. X}    /* end of get_truth_int */
  135. X
  136. X/*+-------------------------------------------------------------------------
  137. X    get_truth_str(param,truth)
  138. X--------------------------------------------------------------------------*/
  139. Xint
  140. Xget_truth_str(param,truth)
  141. XESD *param;
  142. Xint *truth;
  143. X{
  144. Xregister erc;
  145. XESD *tesd1 = (ESD *)0;
  146. XESD *tesd2 = (ESD *)0;
  147. Xint operator;
  148. Xint strcmp_result;
  149. Xint truth2;
  150. X
  151. X    if(!(tesd1 = esdalloc(256)) || !(tesd2 = esdalloc(256)))
  152. X    {
  153. X        erc = eNoMemory;
  154. X        goto RETURN;
  155. X    }    
  156. X
  157. X    if(erc = gstr(param,tesd1,1))
  158. X        goto RETURN;
  159. X    if(erc = get_relop(param,&operator))
  160. X        goto RETURN;
  161. X    if(erc = gstr(param,tesd2,1))
  162. X        goto RETURN;
  163. X
  164. X    strcmp_result = strcmp(tesd1->pb,tesd2->pb);
  165. X
  166. X    switch(operator)
  167. X    {
  168. X        case OP_EQ:
  169. X            *truth = (strcmp_result == 0);
  170. X            break;
  171. X        case OP_NE:
  172. X            *truth = (strcmp_result != 0);
  173. X            break;
  174. X        case OP_GT:
  175. X            *truth = (strcmp_result > 0);
  176. X            break;
  177. X        case OP_LT:
  178. X            *truth = (strcmp_result < 0);
  179. X            break;
  180. X        case OP_GE:
  181. X            *truth = (strcmp_result >= 0);
  182. X            break;
  183. X        case OP_LE:
  184. X            *truth = (strcmp_result <= 0);
  185. X            break;
  186. X        default:
  187. X            return(eInvalidStrOp);
  188. X    }
  189. X
  190. X    while(!get_logicop(param,&operator))
  191. X    {
  192. X        if(erc = get_truth_str(param,&truth2))
  193. X            return(erc);
  194. X        switch(operator)
  195. X        {
  196. X            case OP_AND:
  197. X                *truth &= truth2;
  198. X                break;
  199. X
  200. X            case OP_OR:
  201. X                *truth |= truth2;
  202. X                break;
  203. X        }
  204. X    }
  205. X
  206. X    erc = 0;
  207. X
  208. XRETURN:
  209. X    if(tesd1)
  210. X        esdfree(tesd1);
  211. X    if(tesd2)
  212. X        esdfree(tesd2);
  213. X    return(erc);
  214. X
  215. X}   /* end of get_truth_str */
  216. X
  217. X/*+-------------------------------------------------------------------------
  218. X    _if_common(param,truth)
  219. X--------------------------------------------------------------------------*/
  220. Xint
  221. X_if_common(param,truth)
  222. XESD *param;
  223. Xint truth;
  224. X{
  225. Xregister erc = 0;
  226. Xchar s80[80];
  227. XPCB *pcb;
  228. XESD *else_line;
  229. Xint label_on_else_line;
  230. Xint truth2;
  231. Xint save_index;
  232. Xlong int1;
  233. X
  234. X    if(proctrace > 1)
  235. X    {
  236. X        pprintf("if condition %s",(truth) ? "TRUE: " : "FALSE\n");
  237. X        if(truth)
  238. X        {
  239. X            skip_cmd_break(param);
  240. X            pputs(param->pb + param->index);
  241. X            pputc('\n');
  242. X        }
  243. X    }
  244. X
  245. X    truth_already[if_level] = truth;
  246. X
  247. X/* if end of command, execute frame else conditionally execute rest of esd */
  248. X    s80[0] = 0;
  249. X    if(end_of_cmd(param))
  250. X        erc = execute_frame(truth);
  251. X    else if(truth)
  252. X        erc = execute_esd(param);
  253. X    else
  254. X        param->index = param->cb;
  255. X
  256. X    if(erc)
  257. X        return(erc);
  258. X
  259. X/* check for else statement */
  260. X    pcb = pcb_stack[proc_level - 1];
  261. X    if(!pcb->current->next)        /* if no next line, no "else" */
  262. X        return(0);
  263. X
  264. X    else_line = pcb->current->next->text;
  265. X    else_line->index = else_line->old_index = 0;
  266. X    if(label_on_else_line = (*else_line->pb != 0x20))
  267. X    {    /* strip label */
  268. X        if(get_alphanum_zstr(else_line,s80,sizeof(s80)))
  269. X            return(eInvalidLabel);
  270. X    }
  271. X    if(get_alphanum_zstr(else_line,s80,sizeof(s80)))
  272. X        return(0);        /* not "else" */
  273. X    if(strcmp(s80,"else"))
  274. X        return(0);        /* not "else" */
  275. X    if(label_on_else_line)
  276. X    {
  277. X        else_line->old_index = 0;
  278. X        pputs("label not allowed on else statement\n");
  279. X        return(eFATAL_ALREADY);
  280. X    }
  281. X
  282. X/* we have an "else" condition */
  283. X    truth = !truth;
  284. X    pcb->current = pcb->current->next;
  285. X
  286. X    trace_proc_cmd(pcb);
  287. X
  288. X    if(end_of_cmd(else_line))
  289. X        erc = execute_frame(truth);
  290. X    else
  291. X    {
  292. X        save_index = else_line->old_index = else_line->index;
  293. X        s80[0] = 0;
  294. X        if((*(else_line->pb + else_line->index) != '$') &&
  295. X            get_alpha_zstr(else_line,s80,sizeof(s80)))
  296. X        {
  297. X            pputs("illegal command after 'else'\n");
  298. X            return(eFATAL_ALREADY);
  299. X        }
  300. X        if(!strcmp(s80,"ifi"))
  301. X        {
  302. X            if(erc = get_truth_int(else_line,&truth2))
  303. X                return(erc);
  304. X            erc = _if_common(else_line,!truth_already[if_level] & truth2);
  305. X            truth_already[if_level] |= truth2;
  306. X        }
  307. X        else if(!strcmp(s80,"ifs"))
  308. X        {
  309. X            if(erc = get_truth_str(else_line,&truth2))
  310. X                return(erc);
  311. X            erc = _if_common(else_line,!truth_already[if_level] & truth2);
  312. X            truth_already[if_level] |= truth2;
  313. X        }
  314. X        else if(!strcmp(s80,"ifz"))
  315. X        {
  316. X            if(erc = gint(else_line,&int1))
  317. X                return(erc);
  318. X            truth2 = test_truth_int(int1,OP_EQ,0L);
  319. X            erc = _if_common(else_line,!truth_already[if_level] & truth2);
  320. X            truth_already[if_level] |= truth2;
  321. X        }
  322. X        else if(!strcmp(s80,"ifnz"))
  323. X        {
  324. X            if(erc = gint(else_line,&int1))
  325. X                return(erc);
  326. X            truth2 = test_truth_int(int1,OP_NE,0L);
  327. X            erc = _if_common(else_line,!truth_already[if_level] & truth2);
  328. X            truth_already[if_level] |= truth2;
  329. X        }
  330. X        else if(!strcmp(s80,"iflt"))
  331. X        {
  332. X            if(erc = gint(else_line,&int1))
  333. X                return(erc);
  334. X            truth2 = test_truth_int(int1,OP_LT,0L);
  335. X            erc = _if_common(else_line,!truth_already[if_level] & truth2);
  336. X            truth_already[if_level] |= truth2;
  337. X        }
  338. X        else if(!strcmp(s80,"ifle"))
  339. X        {
  340. X            if(erc = gint(else_line,&int1))
  341. X                return(erc);
  342. X            truth2 = test_truth_int(int1,OP_LE,0L);
  343. X            erc = _if_common(else_line,!truth_already[if_level] & truth2);
  344. X            truth_already[if_level] |= truth2;
  345. X        }
  346. X        else if(!strcmp(s80,"ifgt"))
  347. X        {
  348. X            if(erc = gint(else_line,&int1))
  349. X                return(erc);
  350. X            truth2 = test_truth_int(int1,OP_GT,0L);
  351. X            erc = _if_common(else_line,!truth_already[if_level] & truth2);
  352. X            truth_already[if_level] |= truth2;
  353. X        }
  354. X        else if(!strcmp(s80,"ifge"))
  355. X        {
  356. X            if(erc = gint(else_line,&int1))
  357. X                return(erc);
  358. X            truth2 = test_truth_int(int1,OP_GE,0L);
  359. X            erc = _if_common(else_line,!truth_already[if_level] & truth2);
  360. X            truth_already[if_level] |= truth2;
  361. X        }
  362. X        else if(!strncmp(s80,"while",5))
  363. X        {
  364. X            pputs("'while' command not allowed as 'else' conditional\n");
  365. X            return(eFATAL_ALREADY);
  366. X        }
  367. X        else
  368. X        {
  369. X            else_line->index = save_index;
  370. X            if(truth)
  371. X                erc = execute_esd(else_line);
  372. X        }
  373. X    }
  374. X
  375. X    return(erc);
  376. X}    /* end of _if_common */
  377. X
  378. X/*+-------------------------------------------------------------------------
  379. X    pcmd_ifi(param)
  380. X--------------------------------------------------------------------------*/
  381. Xint
  382. Xpcmd_ifi(param)
  383. XESD *param;
  384. X{
  385. Xregister erc;
  386. Xint truth;
  387. X
  388. X    if(!proc_level)
  389. X        return(eNotExecutingProc);
  390. X
  391. X    if(if_level == MAX_IF)
  392. X    {
  393. X        pputs("if statements nested too deeply\n");
  394. X        return(eFATAL_ALREADY);
  395. X    }
  396. X    if_level++;
  397. X    truth_already[if_level] = 0;
  398. X
  399. X    if(!(erc = get_truth_int(param,&truth)))
  400. X        erc = _if_common(param,truth);
  401. X    if_level--;
  402. X    return(erc);
  403. X
  404. X}   /* end of pcmd_ifi */
  405. X
  406. X/*+-------------------------------------------------------------------------
  407. X    _cmd_ifrel_common(param,relop)
  408. X--------------------------------------------------------------------------*/
  409. Xint
  410. X_cmd_ifrel_common(param,relop)
  411. XESD *param;
  412. Xint relop;
  413. X{
  414. Xregister erc;
  415. Xint truth;
  416. Xlong int1;
  417. X
  418. X    if(!proc_level)
  419. X        return(eNotExecutingProc);
  420. X
  421. X    if(if_level == MAX_IF)
  422. X    {
  423. X        pputs("if statements nested too deeply\n");
  424. X        return(eFATAL_ALREADY);
  425. X    }
  426. X    if_level++;
  427. X    truth_already[if_level] = 0;
  428. X
  429. X    if(erc = gint(param,&int1))
  430. X        return(erc);
  431. X    truth = test_truth_int(int1,relop,0L);
  432. X    erc = _if_common(param,truth);
  433. X    if_level--;
  434. X    return(erc);
  435. X
  436. X}    /* end of _cmd_ifrel_common */
  437. X
  438. X/*+-------------------------------------------------------------------------
  439. X    pcmd_ifz(param)
  440. X--------------------------------------------------------------------------*/
  441. Xint
  442. Xpcmd_ifz(param)
  443. XESD *param;
  444. X{
  445. X    return(_cmd_ifrel_common(param,OP_EQ));
  446. X}    /* end of pcmd_ifz */
  447. X
  448. X/*+-------------------------------------------------------------------------
  449. X    pcmd_ifnz(param)
  450. X--------------------------------------------------------------------------*/
  451. Xint
  452. Xpcmd_ifnz(param)
  453. XESD *param;
  454. X{
  455. X    return(_cmd_ifrel_common(param,OP_NE));
  456. X}    /* end of pcmd_ifnz */
  457. X
  458. X/*+-------------------------------------------------------------------------
  459. X    pcmd_ifle(param)
  460. X--------------------------------------------------------------------------*/
  461. Xint
  462. Xpcmd_ifle(param)
  463. XESD *param;
  464. X{
  465. X    return(_cmd_ifrel_common(param,OP_LE));
  466. X}    /* end of pcmd_ifle */
  467. X
  468. X/*+-------------------------------------------------------------------------
  469. X    pcmd_ifge(param)
  470. X--------------------------------------------------------------------------*/
  471. Xint
  472. Xpcmd_ifge(param)
  473. XESD *param;
  474. X{
  475. X    return(_cmd_ifrel_common(param,OP_GE));
  476. X}    /* end of pcmd_ifge */
  477. X
  478. X/*+-------------------------------------------------------------------------
  479. X    pcmd_iflt(param)
  480. X--------------------------------------------------------------------------*/
  481. Xint
  482. Xpcmd_iflt(param)
  483. XESD *param;
  484. X{
  485. X    return(_cmd_ifrel_common(param,OP_LT));
  486. X}    /* end of pcmd_iflt */
  487. X
  488. X/*+-------------------------------------------------------------------------
  489. X    pcmd_ifgt(param)
  490. X--------------------------------------------------------------------------*/
  491. Xint
  492. Xpcmd_ifgt(param)
  493. XESD *param;
  494. X{
  495. X    return(_cmd_ifrel_common(param,OP_GT));
  496. X}    /* end of pcmd_ifgt */
  497. X
  498. X/*+-------------------------------------------------------------------------
  499. X    pcmd_ifs(param)
  500. X--------------------------------------------------------------------------*/
  501. Xint
  502. Xpcmd_ifs(param)
  503. XESD *param;
  504. X{
  505. Xregister erc;
  506. Xint truth;
  507. X
  508. X    if(!proc_level)
  509. X        return(eNotExecutingProc);
  510. X
  511. X    if(if_level == MAX_IF)
  512. X    {
  513. X        pputs("if statements nested too deeply\n");
  514. X        return(eFATAL_ALREADY);
  515. X    }
  516. X    if_level++;
  517. X    truth_already[if_level] = 0;
  518. X
  519. X    if(!(erc = get_truth_str(param,&truth)))
  520. X        erc = _if_common(param,truth);
  521. X    if_level--;
  522. X    return(erc);
  523. X
  524. X}   /* end of pcmd_ifs */
  525. X
  526. X/*+-------------------------------------------------------------------------
  527. X    pcmd_else(param)
  528. X--------------------------------------------------------------------------*/
  529. Xint
  530. Xpcmd_else(param)
  531. XESD *param;
  532. X{
  533. X    return(eElseCommand);
  534. X}    /* end of pcmd_else */
  535. X
  536. X/* vi: set tabstop=4 shiftwidth=4: */
  537. X/* end of pcmdif.c */
  538. SHAR_EOF
  539. echo 'File pcmdif.c is complete' &&
  540. $TOUCH -am 0725125991 'pcmdif.c' &&
  541. chmod 0644 pcmdif.c ||
  542. echo 'restore of pcmdif.c failed'
  543. Wc_c="`wc -c < 'pcmdif.c'`"
  544. test 13866 -eq "$Wc_c" ||
  545.     echo 'pcmdif.c: original size 13866, current size' "$Wc_c"
  546. rm -f _shar_wnt_.tmp
  547. fi
  548. # ============= pcmdtty.c ==============
  549. if test -f 'pcmdtty.c' -a X"$1" != X"-c"; then
  550.     echo 'x - skipping pcmdtty.c (File already exists)'
  551.     rm -f _shar_wnt_.tmp
  552. else
  553. > _shar_wnt_.tmp
  554. echo 'x - extracting pcmdtty.c (Text)'
  555. sed 's/^X//' << 'SHAR_EOF' > 'pcmdtty.c' &&
  556. X/*+-------------------------------------------------------------------------
  557. X    pcmdtty.c - tty (console) related procedure commands
  558. X    wht@n4hgf.Mt-Park.GA.US
  559. X
  560. X  Defined functions:
  561. X    pcmd_cls(param)
  562. X    pcmd_color(param)
  563. X    pcmd_cursor(param)
  564. X    pcmd_delline(param)
  565. X    pcmd_eeol(param)
  566. X    pcmd_fkey(param)
  567. X    pcmd_home(param)
  568. X    pcmd_icolor(param)
  569. X    pcmd_insline(param)
  570. X    pcmd_scrdump(param)
  571. X    pcmd_vidcolor(param)
  572. X    pcmd_vidnorm(param)
  573. X    pcmd_vidrev(param)
  574. X    ifunc_colors(pvalue)
  575. X
  576. X--------------------------------------------------------------------------*/
  577. X/*+:EDITS:*/
  578. X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  579. X/*:05-21-1991-00:45-wht@n4hgf-added -3 error code to keyset_read */
  580. X/*:01-23-1991-01:58-wht@n4hgf-illegal color name make hi_white on hi_white */
  581. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  582. X
  583. X#include "ecu.h"
  584. X#include "ecuerror.h"
  585. X#include "esd.h"
  586. X#include "ecutty.h"
  587. X
  588. Xextern int proctrace;
  589. Xextern ulong colors_current;
  590. X
  591. X/*+-------------------------------------------------------------------------
  592. X    pcmd_color(param)
  593. X
  594. XUsage:   color [-r] [argument] [argument]
  595. XOptions:
  596. X   color color      Set foreground and background normal video colors
  597. X   -r color color   Set foreground & background reverse video colors
  598. X
  599. XColor names
  600. X   blue      magenta      brown      black
  601. X   lt_blue   lt_magenta   yellow     gray
  602. X   cyan      white        green      red
  603. X   lt_cyan   hi_white     lt_green   lt_red
  604. X
  605. X--------------------------------------------------------------------------*/
  606. Xpcmd_color(param)
  607. XESD *param;
  608. X{
  609. Xregister erc;
  610. Xchar switches[8];
  611. Xint normal;
  612. Xchar s32[32];
  613. Xulong foreground;
  614. Xulong background;
  615. X
  616. X    get_switches(param,switches,sizeof(switches));
  617. X    if(!strlen(switches))
  618. X        normal = 1;
  619. X    else if(switches[1] == 'r')
  620. X        normal = 0;        /* reverse */
  621. X    else
  622. X    {
  623. X        pputs("unrecognized switch\n");
  624. X        return(eFATAL_ALREADY);
  625. X    }
  626. X
  627. X    if((erc = get_alpha_zstr(param,s32,sizeof(s32))) ||
  628. X            ((int)(foreground = color_name_to_num(s32)) < 0))
  629. X        goto ERROR;
  630. X
  631. X    if(erc = get_alpha_zstr(param,s32,sizeof(s32)))
  632. X    {
  633. X        if(!end_of_cmd(param))
  634. X            goto ERROR;
  635. X        background = 0;
  636. X    }
  637. X    else if((int)(background = color_name_to_num(s32)) < 0)
  638. X        goto ERROR;
  639. X
  640. X    if(normal)
  641. X    {
  642. X        colors_current &= 0xFFFF0000;
  643. X        colors_current |= (foreground << 8) | background;
  644. X        if(proctrace > 1)
  645. X        {
  646. X            pprintf("normal %ld,%ld current=0x%08lx\n",
  647. X                foreground,background,colors_current);
  648. X        }
  649. X    }
  650. X    else
  651. X    {
  652. X        colors_current &= 0x0000FFFF;
  653. X        colors_current |= (foreground << 24) | (background << 16);
  654. X        if(proctrace > 1)
  655. X        {
  656. X            pprintf("reverse %ld,%ld current=0x%08lx\n",
  657. X                foreground,background,colors_current);
  658. X        }
  659. X    }
  660. X
  661. X    setcolor(colors_current);
  662. X    return(0);
  663. X
  664. XERROR:
  665. X    if(erc)
  666. X        return(erc);
  667. X    pputs("invalid color\n");
  668. X    return(eFATAL_ALREADY);
  669. X
  670. X}    /* end of pcmd_color */
  671. X
  672. X/*+-------------------------------------------------------------------------
  673. X    ifunc_colors(pvalue)
  674. X--------------------------------------------------------------------------*/
  675. Xint
  676. Xifunc_colors(pvalue)
  677. Xulong *pvalue;
  678. X{
  679. X    *pvalue = colors_current;
  680. X    return(0);
  681. X}    /* end of ifunc_colors */
  682. X
  683. X/*+-------------------------------------------------------------------------
  684. X    pcmd_icolor(param)
  685. X--------------------------------------------------------------------------*/
  686. Xpcmd_icolor(param)
  687. XESD *param;
  688. X{
  689. Xint erc;
  690. Xulong new_colors;
  691. X
  692. X    if(erc = gint(param,&new_colors))
  693. X        return(erc);
  694. X
  695. X    setcolor(new_colors);
  696. X    return(0);
  697. X}    /* end of pcmd_icolor */
  698. X
  699. X/*+-------------------------------------------------------------------------
  700. X    pcmd_cls(param)
  701. X--------------------------------------------------------------------------*/
  702. Xint
  703. Xpcmd_cls(param)
  704. XESD *param;
  705. X{
  706. X    tcap_clear_screen();
  707. X    return(0);
  708. X}    /* end of pcmd_cls */
  709. X
  710. X/*+-------------------------------------------------------------------------
  711. X    pcmd_cursor(param)
  712. X--------------------------------------------------------------------------*/
  713. Xint
  714. Xpcmd_cursor(param)
  715. XESD *param;
  716. X{
  717. Xint erc;
  718. Xlong row;
  719. Xlong col = 0;
  720. X
  721. X    if(erc = gint(param,&row))
  722. X        return(erc);
  723. X    if(gint(param,&col))
  724. X    {
  725. X        /* if something there non-integer */
  726. X        if(!end_of_cmd(param))
  727. X            return(eSyntaxError);
  728. X    }
  729. X    tcap_cursor((int)row,(int)col);
  730. X    return(0);
  731. X}    /* end of pcmd_cursor */
  732. X
  733. X/*+-------------------------------------------------------------------------
  734. X    pcmd_scrdump(param)
  735. X--------------------------------------------------------------------------*/
  736. Xint
  737. Xpcmd_scrdump(param)
  738. XESD *param;
  739. X{
  740. Xint erc;
  741. XESD *fname;
  742. XFILE *fp;
  743. X
  744. X    if((fname = esdalloc(256)) == (ESD *)0)
  745. X        return(eNoMemory);
  746. X
  747. X    if(erc = gstr(param,fname,1))
  748. X    {
  749. X        if(!end_of_cmd(param))
  750. X        {
  751. X            erc = eSyntaxError;
  752. X            goto RETURN;
  753. X        }
  754. X    }
  755. X
  756. X    if(fname->cb)
  757. X    {
  758. X        if((fp = fopen(fname->pb,"a")) == NULL)
  759. X        {
  760. X            pperror(fname->pb);
  761. X            erc = eFATAL_ALREADY;
  762. X            goto RETURN;
  763. X        }
  764. X        fclose(fp);
  765. X    }
  766. X
  767. X    screen_dump((fname->cb) ? fname->pb : (char *)0);
  768. X
  769. XRETURN:
  770. X    esdfree(fname);
  771. X    return(erc);
  772. X}    /* end of pcmd_scrdump */
  773. X
  774. X/*+-------------------------------------------------------------------------
  775. X    pcmd_vidnorm(param)
  776. X--------------------------------------------------------------------------*/
  777. Xint
  778. Xpcmd_vidnorm(param)
  779. XESD *param;
  780. X{
  781. X    tcap_stand_end();
  782. X    return(0);
  783. X}    /* end of pcmd_vidnorm */
  784. X
  785. X/*+-------------------------------------------------------------------------
  786. X    pcmd_vidrev(param)
  787. X--------------------------------------------------------------------------*/
  788. Xint
  789. Xpcmd_vidrev(param)
  790. XESD *param;
  791. X{
  792. X    tcap_stand_out();
  793. X    return(0);
  794. X}    /* end of pcmd_vidrev */
  795. X
  796. X/*+-------------------------------------------------------------------------
  797. X    pcmd_fkey(param)
  798. X--------------------------------------------------------------------------*/
  799. Xpcmd_fkey(param)
  800. XESD *param;
  801. X{
  802. Xint erc;
  803. XESD *tesd;
  804. X
  805. X    if((tesd = esdalloc(64)) == (ESD *)0)
  806. X        return(eNoMemory);
  807. X
  808. X    if(erc = gstr(param,tesd,0))
  809. X        goto RETURN;
  810. X
  811. X    switch(keyset_read(tesd->pb))
  812. X    {
  813. X        case  0:
  814. X            if(proctrace)
  815. X                keyset_display();
  816. X            break;
  817. X        case -1:
  818. X            pprintf("cannot find ~/.ecu/keys\n");
  819. X            erc = eFATAL_ALREADY;
  820. X            break;
  821. X        case -2:
  822. X            pprintf("'%s' not found in ~/.ecu/keys\n",tesd->pb);
  823. X            erc = eFATAL_ALREADY;
  824. X            break;
  825. X        case -3:
  826. X            pprintf("'%s' has a syntax error\n",tesd->pb);
  827. X            erc = eFATAL_ALREADY;
  828. X            break;
  829. X    }
  830. X
  831. XRETURN:
  832. X    esdfree(tesd);
  833. X    return(erc);
  834. X}    /* end of pcmd_fkey */
  835. X
  836. X/*+-------------------------------------------------------------------------
  837. X    pcmd_vidcolor(param)
  838. X
  839. Xvidcolor normal|reverse|notify|success|alert|error fcolor [bcolor]
  840. X--------------------------------------------------------------------------*/
  841. Xint
  842. Xpcmd_vidcolor(param)
  843. XESD *param;
  844. X{
  845. Xint erc;
  846. Xint ntokens = 0;
  847. Xchar *tokens[3];
  848. Xint param_index[3];
  849. Xchar tokenbuf[64];
  850. X
  851. X    tokens[0] = tokenbuf;
  852. X    tokens[1] = tokenbuf + 20;
  853. X    tokens[2] = tokenbuf + 40;
  854. X
  855. X    while(ntokens < 3)
  856. X    {
  857. X        skip_cmd_break(param);
  858. X        param_index[ntokens] = param->index;
  859. X        if(erc = get_word_zstr(param,tokens[ntokens],20))
  860. X            break;
  861. X        ntokens++;
  862. X    }
  863. X
  864. X    if(erc && ((erc != eNoParameter) || (ntokens < 2)))
  865. X        return(erc);
  866. X
  867. X    switch(erc = setcolor_internal(ntokens,tokens))
  868. X    {
  869. X        case 0:
  870. X            break;
  871. X        default:
  872. X            param->old_index = param->index = param_index[erc - 1];
  873. X            erc = eBadParameter;
  874. X    }
  875. X    return(erc);
  876. X}    /* end of pcmd_vidcolor */
  877. X
  878. X/*+-------------------------------------------------------------------------
  879. X    pcmd_home(param) - home the cursor
  880. X--------------------------------------------------------------------------*/
  881. Xint
  882. Xpcmd_home(param)
  883. XESD *param;
  884. X{
  885. X    tcap_cursor(0,0);
  886. X    return(0);
  887. X}    /* end of pcmd_home */
  888. X
  889. X/*+-------------------------------------------------------------------------
  890. X    pcmd_eeol(param) - erase to end of line
  891. X--------------------------------------------------------------------------*/
  892. Xint
  893. Xpcmd_eeol(param)
  894. XESD *param;
  895. X{
  896. X    tcap_eeol();
  897. X    return(0);
  898. X}    /* end of pcmd_eeol */
  899. X
  900. X/*+-------------------------------------------------------------------------
  901. X    pcmd_insline(param) - insert line in display
  902. X--------------------------------------------------------------------------*/
  903. Xint
  904. Xpcmd_insline(param)
  905. XESD *param;
  906. X{
  907. X    tcap_insert_lines(1);
  908. X    return(0);
  909. X}    /* end of pcmd_insline */
  910. X
  911. X/*+-------------------------------------------------------------------------
  912. X    pcmd_delline(param) - delete line from display
  913. X--------------------------------------------------------------------------*/
  914. Xint
  915. Xpcmd_delline(param)
  916. XESD *param;
  917. X{
  918. X    tcap_delete_lines(1);
  919. X    return(0);
  920. X}    /* end of pcmd_delline */
  921. X
  922. X/* vi: set tabstop=4 shiftwidth=4: */
  923. X/* end of pcmdtty.c */
  924. SHAR_EOF
  925. $TOUCH -am 0725125991 'pcmdtty.c' &&
  926. chmod 0644 pcmdtty.c ||
  927. echo 'restore of pcmdtty.c failed'
  928. Wc_c="`wc -c < 'pcmdtty.c'`"
  929. test 8241 -eq "$Wc_c" ||
  930.     echo 'pcmdtty.c: original size 8241, current size' "$Wc_c"
  931. rm -f _shar_wnt_.tmp
  932. fi
  933. # ============= pcmdwhile.c ==============
  934. if test -f 'pcmdwhile.c' -a X"$1" != X"-c"; then
  935.     echo 'x - skipping pcmdwhile.c (File already exists)'
  936.     rm -f _shar_wnt_.tmp
  937. else
  938. > _shar_wnt_.tmp
  939. echo 'x - extracting pcmdwhile.c (Text)'
  940. sed 's/^X//' << 'SHAR_EOF' > 'pcmdwhile.c' &&
  941. X/*+-------------------------------------------------------------------------
  942. X    pcmdwhile.c - ecu while procedure commands
  943. X    wht@n4hgf.Mt-Park.GA.US
  944. X
  945. X    WHILEI $i0 rel-op $i1 cmd
  946. X    WHILES $s0 rel-op $s1 cmd
  947. X
  948. X    where rel-op is "=", "==", "!=", "<>", ">", "<", ">=", "=<"
  949. X
  950. X  Defined functions:
  951. X    pcmd_whilei(param)
  952. X    pcmd_whiles(param)
  953. X
  954. X--------------------------------------------------------------------------*/
  955. X/*+:EDITS:*/
  956. X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  957. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  958. X
  959. X#include <ctype.h>
  960. X#include "ecu.h"
  961. X#include "ecuerror.h"
  962. X#include "esd.h"
  963. X#include "var.h"
  964. X#include "proc.h"
  965. X#include "relop.h"
  966. X
  967. Xextern PCB *pcb_stack[];
  968. Xextern int proc_level;
  969. X
  970. X/*+-------------------------------------------------------------------------
  971. X    pcmd_whilei(param)
  972. X--------------------------------------------------------------------------*/
  973. Xint
  974. Xpcmd_whilei(param)
  975. XESD *param;
  976. X{
  977. Xregister erc;
  978. Xint truth;
  979. XPCB *pcb;
  980. XLCB *condition_lcb;
  981. Xint condition_index = param->index;
  982. X
  983. X    if(!proc_level)
  984. X        return(eNotExecutingProc);
  985. X
  986. X    pcb = pcb_stack[proc_level - 1];
  987. X    condition_lcb = pcb->current;
  988. X
  989. XREPEAT_WHILE:
  990. X
  991. X    if(erc = get_truth_int(param,&truth))
  992. X        return(erc);
  993. X
  994. X/* if end of command, execute frame */
  995. X    if(end_of_cmd(param))
  996. X    {
  997. X        if(erc = execute_frame(truth))
  998. X        {
  999. X            if(erc == eContinueCommand)
  1000. X                goto CONTINUE;
  1001. X            if(erc == eBreakCommand)
  1002. X                erc = 0;
  1003. X            return(erc);
  1004. X        }
  1005. X    }
  1006. X    else if(truth)
  1007. X    {
  1008. X        if(erc = execute_esd(param))
  1009. X            return(erc);
  1010. X    }
  1011. X
  1012. X/* repeat if indicated */
  1013. XCONTINUE:
  1014. X    if(truth)
  1015. X    {
  1016. X        pcb->current = condition_lcb;
  1017. X        param->index = param->old_index = condition_index;
  1018. X        goto REPEAT_WHILE;
  1019. X    }
  1020. X
  1021. X    return(0);
  1022. X}   /* end of pcmd_whilei */
  1023. X
  1024. X/*+-------------------------------------------------------------------------
  1025. X    pcmd_whiles(param)
  1026. X--------------------------------------------------------------------------*/
  1027. Xint
  1028. Xpcmd_whiles(param)
  1029. XESD *param;
  1030. X{
  1031. Xregister erc;
  1032. Xint truth;
  1033. XPCB *pcb;
  1034. XLCB *condition_lcb;
  1035. Xint condition_index = param->index;
  1036. X
  1037. X    if(!proc_level)
  1038. X        return(eNotExecutingProc);
  1039. X
  1040. X    pcb = pcb_stack[proc_level - 1];
  1041. X    condition_lcb = pcb->current;
  1042. X
  1043. XREPEAT_WHILE:
  1044. X
  1045. X    if(erc = get_truth_str(param,&truth))
  1046. X        return(erc);
  1047. X
  1048. X/* if end of command, execute frame */
  1049. X    if(end_of_cmd(param))
  1050. X    {
  1051. X        if(erc = execute_frame(truth))
  1052. X        {
  1053. X            if(erc == eContinueCommand)
  1054. X                goto CONTINUE;
  1055. X            if(erc == eBreakCommand)
  1056. X                erc = 0;
  1057. X            return(erc);
  1058. X        }
  1059. X    }
  1060. X    else if(truth)
  1061. X    {
  1062. X        if(erc = execute_esd(param))
  1063. X            return(erc);
  1064. X    }
  1065. X
  1066. X/* repeat if indicated */
  1067. XCONTINUE:
  1068. X    if(truth)
  1069. X    {
  1070. X        pcb->current = condition_lcb;
  1071. X        param->index = param->old_index = condition_index;
  1072. X        goto REPEAT_WHILE;
  1073. X    }
  1074. X
  1075. X    return(0);
  1076. X}   /* end of pcmd_whiles */
  1077. X
  1078. X/* vi: set tabstop=4 shiftwidth=4: */
  1079. X/* end of pcmdwhile.c */
  1080. SHAR_EOF
  1081. $TOUCH -am 0725125991 'pcmdwhile.c' &&
  1082. chmod 0644 pcmdwhile.c ||
  1083. echo 'restore of pcmdwhile.c failed'
  1084. Wc_c="`wc -c < 'pcmdwhile.c'`"
  1085. test 2736 -eq "$Wc_c" ||
  1086.     echo 'pcmdwhile.c: original size 2736, current size' "$Wc_c"
  1087. rm -f _shar_wnt_.tmp
  1088. fi
  1089. # ============= pcmdxfer.c ==============
  1090. if test -f 'pcmdxfer.c' -a X"$1" != X"-c"; then
  1091.     echo 'x - skipping pcmdxfer.c (File already exists)'
  1092.     rm -f _shar_wnt_.tmp
  1093. else
  1094. > _shar_wnt_.tmp
  1095. echo 'x - extracting pcmdxfer.c (Text)'
  1096. sed 's/^X//' << 'SHAR_EOF' > 'pcmdxfer.c' &&
  1097. X/*+-------------------------------------------------------------------------
  1098. X    pcmdxfer.c - ecu file transfer related procedure commands
  1099. X    wht@n4hgf.Mt-Park.GA.US
  1100. X
  1101. X  Defined functions:
  1102. X    _adjust_erc_and_iv0(adj_erc)
  1103. X    _make_bottom_label(param,default_flag,sending_flag)
  1104. X    _pcmd_report_send_status()
  1105. X    _smart_sender_common(cmd)
  1106. X    pcmd_rk(param)
  1107. X    pcmd_rs(param)
  1108. X    pcmd_rx(param)
  1109. X    pcmd_ry(param)
  1110. X    pcmd_rz(param)
  1111. X    pcmd_sk(param)
  1112. X    pcmd_ss(param)
  1113. X    pcmd_sx(param)
  1114. X    pcmd_sy(param)
  1115. X    pcmd_sz(param)
  1116. X
  1117. X--------------------------------------------------------------------------*/
  1118. X/*+:EDITS:*/
  1119. X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  1120. X/*:04-23-1991-23:44-wht@n4hgf-big time overhaul - better but flames expected */
  1121. X/*:04-23-1991-05:10-wht@n4hgf-new cmd build mechanism for long file lists */
  1122. X/*:01-17-1991-17:01-wht@n4hgf-skipped files in sz aborted proc */
  1123. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1124. X
  1125. X#include "ecu.h"
  1126. X#include "ecukey.h"
  1127. X#include "ecuerror.h"
  1128. X#include "esd.h"
  1129. X#include "var.h"
  1130. X#include "proc.h"
  1131. X
  1132. X/*
  1133. X * file transmission command and pathname list ESD initial size
  1134. X * (lengths can grow to ESD_MAXSIZE)
  1135. X */
  1136. X#define CMDESD_INITIAL_SIZE  384 /* executable command initial size */
  1137. X#define PATHESD_INITIAL_SIZE 256 /* pathname list initial size */
  1138. X#define CMDSTR_SIZE          384 /* receive command string size */
  1139. X
  1140. Xextern int proctrace;
  1141. Xextern int last_child_wait_status;
  1142. Xextern char curr_dir[CURR_DIRSIZ];
  1143. X
  1144. Xstatic char bottom_label[80];
  1145. X
  1146. X/*+-------------------------------------------------------------------------
  1147. X    _make_bottom_label(param,default_flag)
  1148. X--------------------------------------------------------------------------*/
  1149. Xint
  1150. X_make_bottom_label(param,default_flag,sending_flag)
  1151. XESD *param;
  1152. Xint default_flag;
  1153. Xint sending_flag;
  1154. X{
  1155. Xregister erc;
  1156. XESD *label = (ESD *)0;
  1157. X
  1158. X    if(default_flag)
  1159. X    {
  1160. X        sprintf(bottom_label,
  1161. X            (sending_flag) ? "-C \"'Connected to %s'\" "
  1162. X                           : "-C 'Connected to %s' ",
  1163. X            (shm->Lrname[0]) ? shm->Lrname : "?");
  1164. X        return(0);
  1165. X    }
  1166. X    if((label = esdalloc(64)) == (ESD *)0)
  1167. X        return(eNoMemory);
  1168. X    if(erc = gstr(param,label,0))
  1169. X    {
  1170. X        esdfree(label);
  1171. X        return(erc);
  1172. X    }
  1173. X    strcpy(bottom_label,(sending_flag) ? "-C \"'" : "-C '");
  1174. X    strcat(bottom_label,label->pb);
  1175. X    strcat(bottom_label,(sending_flag) ? "'\"" : "'");
  1176. X    esdfree(label);
  1177. X    return(0);
  1178. X
  1179. X}    /* end of _make_bottom_label */
  1180. X
  1181. X/*+-------------------------------------------------------------------------
  1182. X    _adjust_erc_and_iv0(adj_erc)
  1183. X--------------------------------------------------------------------------*/
  1184. Xint
  1185. X_adjust_erc_and_iv0(adj_erc)
  1186. Xint adj_erc;
  1187. X{
  1188. X
  1189. X    if(adj_erc)
  1190. X        return(adj_erc);
  1191. X
  1192. X    iv[0] = (last_child_wait_status & 0xFF)
  1193. X            ? 0x100L : (long)((last_child_wait_status >> 8) & 0xFFFF);
  1194. X
  1195. X    if(proctrace)
  1196. X        pprintf("$i00 = %ld (transfer %s)\n",iv[0],
  1197. X            (iv[0] == 0x100L) ? "interrupted" : "program exit status");
  1198. X
  1199. X    return(0);
  1200. X
  1201. X}    /* end of _adjust_erc_and_iv0 */
  1202. X
  1203. X/*+-------------------------------------------------------------------------
  1204. X    _pcmd_report_send_status() - report file transmission result
  1205. X
  1206. Xfor "ecu knowledgeable" protocols only
  1207. Xreturns proc-type erc
  1208. X--------------------------------------------------------------------------*/
  1209. Xint
  1210. X_pcmd_report_send_status()
  1211. X{
  1212. Xregister ushort ustmp;
  1213. Xint erc = eFATAL_ALREADY;
  1214. Xint iv0_set = 0;
  1215. Xchar *signal_name_text();
  1216. X
  1217. X    ustmp = last_child_wait_status;
  1218. X    if((ustmp & 0xFF) == 0)    /* exit() called */
  1219. X    {
  1220. X        ustmp >>= 8;
  1221. X        if(!ustmp)
  1222. X        {
  1223. X            if(proctrace)
  1224. X                pputs("transfer successful\n");
  1225. X            erc = 0;
  1226. X        }
  1227. X        else if(ustmp == 255)
  1228. X            pputs("ecu error: transfer program usage error\n");
  1229. X        else if(ustmp == 254)
  1230. X        {
  1231. X            pputs(
  1232. X            "protocol failure: bad line conditions or remote not ready\n");
  1233. X        }
  1234. X        else if(ustmp == 253)
  1235. X            pputs("no requested files exist\n");
  1236. X        else if(ustmp < 128)
  1237. X        {
  1238. X            if(proctrace)
  1239. X            {
  1240. X                if(ustmp == 127)
  1241. X                    pputs("127 or more files skipped\n");
  1242. X                else
  1243. X                    pprintf("%u files rejected\n",ustmp);
  1244. X            }
  1245. X            iv[0] = (long)ustmp;
  1246. X            iv0_set = 1;
  1247. X            last_child_wait_status = 0;
  1248. X            erc = 0;
  1249. X        }
  1250. X        else
  1251. X        {
  1252. X            pprintf("transfer aborted by %s\n",signal_name_text(ustmp & 0x7F));
  1253. X            erc = eProcAttn_Interrupt;
  1254. X        }
  1255. X    }
  1256. X    else
  1257. X    {
  1258. X        pprintf("transfer killed by %s\n",signal_name_text(ustmp & 0x7F));
  1259. X        erc = eProcAttn_Interrupt;
  1260. X    }
  1261. X
  1262. X    if(!iv0_set)
  1263. X    {
  1264. X        iv[0] = (last_child_wait_status & 0xFF)
  1265. X            ? 0x100L : (long)((last_child_wait_status >> 8) & 0xFFFF);
  1266. X    }
  1267. X
  1268. X    if(proctrace)
  1269. X        pprintf("$i00 = %ld (transfer %s)\n",iv[0],
  1270. X            (iv[0] == 0x100L) ? "interrupted" : "program exit status");
  1271. X
  1272. X    return(erc);
  1273. X
  1274. X}    /* end of _pcmd_report_send_status */
  1275. X
  1276. X/*+-------------------------------------------------------------------------
  1277. X    _smart_sender_common(cmd) - common exec and bottom processing
  1278. X
  1279. Xfor "ecu knowledgeable" protocols only
  1280. Xreturns proc-type erc
  1281. X--------------------------------------------------------------------------*/
  1282. Xint
  1283. X_smart_sender_common(cmd)
  1284. Xchar *cmd;
  1285. X{
  1286. Xint erc = 0;
  1287. X
  1288. X    last_child_wait_status = 0;
  1289. X    file_xfer_start();
  1290. X
  1291. X    if(find_shell_chars(cmd))
  1292. X    {
  1293. X    char *expcmd;
  1294. X
  1295. X        if(expand_wildcard_list(cmd,&expcmd))
  1296. X        {
  1297. X            pputs("No files match wildcard list\n");
  1298. X            iv[0] = -1;
  1299. X            return(0);
  1300. X        }
  1301. X        else
  1302. X        {
  1303. X            exec_cmd(expcmd);
  1304. X            erc = _pcmd_report_send_status();
  1305. X            free(expcmd);
  1306. X        }
  1307. X    }
  1308. X    else
  1309. X    {
  1310. X        exec_cmd(cmd);
  1311. X        erc = _pcmd_report_send_status();
  1312. X    }
  1313. X
  1314. X    lreset_ksr();
  1315. X    file_xfer_done_bell();
  1316. X
  1317. X    return(erc);
  1318. X
  1319. X}    /* end of _smart_sender_common */
  1320. X
  1321. X/*+-------------------------------------------------------------------------
  1322. X    pcmd_sx(param)
  1323. X
  1324. Xsx [-ak[l]] [<label-str>] <filelist-str>
  1325. X--------------------------------------------------------------------------*/
  1326. Xint
  1327. Xpcmd_sx(param)
  1328. XESD *param;
  1329. X{
  1330. Xint erc;
  1331. Xchar switches[8];
  1332. XESD *pathesd = (ESD *)0;
  1333. XESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
  1334. X
  1335. X    get_switches(param,switches,sizeof(switches));
  1336. X
  1337. X    if(erc = _make_bottom_label(param,!strchr(switches,'l'),1))
  1338. X        return(erc);
  1339. X
  1340. X    /*
  1341. X     * build command at beginning of 'cmdesd' ESD
  1342. X     */
  1343. X    sprintf(cmdesd->pb,"ecusz -X -. %d ",shm->Liofd);
  1344. X    strcat(cmdesd->pb,bottom_label);
  1345. X
  1346. X#if defined(WHT)    /* for testing */
  1347. X    if(strchr(switches,'p'))
  1348. X        strcat(cmdesd->pb,"-, ");
  1349. X#endif
  1350. X
  1351. X    if(strchr(switches,'a'))
  1352. X        strcat(cmdesd->pb,"-a ");
  1353. X
  1354. X    if(strchr(switches,'k'))
  1355. X        strcat(cmdesd->pb,"-k");
  1356. X
  1357. X    /*
  1358. X     * update cmdesd esd
  1359. X     */
  1360. X    cmdesd->cb = strlen(cmdesd->pb);
  1361. X
  1362. X    if(!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
  1363. X    {
  1364. X        erc = eNoMemory;
  1365. X        goto FREE_MEM_AND_EXIT;
  1366. X    }
  1367. X
  1368. X    /*
  1369. X     * get list of pathnames to send
  1370. X     */
  1371. X    if(erc = gstr(param,pathesd,1))
  1372. X        goto FREE_MEM_AND_EXIT;
  1373. X
  1374. X    /*
  1375. X     * append filelist to command
  1376. X     */
  1377. X    if(erc = esdcat(cmdesd,pathesd,1))
  1378. X        goto FREE_MEM_AND_EXIT;
  1379. X
  1380. X    /*
  1381. X     * perform the operation
  1382. X     */
  1383. X    erc = _smart_sender_common(cmdesd->pb);
  1384. X
  1385. XFREE_MEM_AND_EXIT:
  1386. X    if(pathesd)
  1387. X        esdfree(pathesd);
  1388. X    if(cmdesd)
  1389. X        esdfree(cmdesd);
  1390. X    return(erc);
  1391. X
  1392. X}    /* end of pcmd_sx */
  1393. X
  1394. X/*+-------------------------------------------------------------------------
  1395. X    pcmd_sy(param)
  1396. X
  1397. Xsy [-a[l]] [<label-str>] <filelist-str>
  1398. X--------------------------------------------------------------------------*/
  1399. Xint
  1400. Xpcmd_sy(param)
  1401. XESD *param;
  1402. X{
  1403. Xint erc;
  1404. Xchar switches[8];
  1405. XESD *pathesd = (ESD *)0;
  1406. XESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
  1407. X
  1408. X    get_switches(param,switches,sizeof(switches));
  1409. X
  1410. X    if(erc = _make_bottom_label(param,!strchr(switches,'l'),1))
  1411. X        return(erc);
  1412. X
  1413. X    /*
  1414. X     * build command at beginning of 'cmdesd' ESD
  1415. X     */
  1416. X    sprintf(cmdesd->pb,"ecusz -Y -. %d -k ",shm->Liofd);
  1417. X    strcat(cmdesd->pb,bottom_label);
  1418. X    if(strchr(switches,'a'))
  1419. X        strcat(cmdesd->pb,"-a ");
  1420. X    else
  1421. X        strcat(cmdesd->pb,"-b ");
  1422. X
  1423. X    /*
  1424. X     * update cmdesd esd
  1425. X     */
  1426. X    cmdesd->cb = strlen(cmdesd->pb);
  1427. X
  1428. X    if(!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
  1429. X    {
  1430. X        erc = eNoMemory;
  1431. X        goto FREE_MEM_AND_EXIT;
  1432. X    }
  1433. X
  1434. X    /*
  1435. X     * get list of pathnames to send
  1436. X     */
  1437. X    if(erc = gstr(param,pathesd,1))
  1438. X        goto FREE_MEM_AND_EXIT;
  1439. X
  1440. X    /*
  1441. X     * append filelist to command
  1442. X     */
  1443. X    if(erc = esdcat(cmdesd,pathesd,1))
  1444. X        goto FREE_MEM_AND_EXIT;
  1445. X
  1446. X    /*
  1447. X     * perform the operation
  1448. X     */
  1449. X    erc = _smart_sender_common(cmdesd->pb);
  1450. X
  1451. XFREE_MEM_AND_EXIT:
  1452. X    if(pathesd)
  1453. X        esdfree(pathesd);
  1454. X    if(cmdesd)
  1455. X        esdfree(cmdesd);
  1456. X    return(erc);
  1457. X
  1458. X}    /* end of pcmd_sy */
  1459. X
  1460. X/*+-------------------------------------------------------------------------
  1461. X    pcmd_sz(param)
  1462. X
  1463. Xsz [-anf[l]] [<label-str>] <filelist-str>
  1464. X-a ascii, else binary
  1465. X-n send only newer, else all files
  1466. X-f full, else simple pathnames
  1467. X-l non-default bottom line label on transfer string
  1468. X$i0 set to:
  1469. X    0: file transfer completely successful
  1470. X    -1 program did not run
  1471. X--------------------------------------------------------------------------*/
  1472. Xint
  1473. Xpcmd_sz(param)
  1474. XESD *param;
  1475. X{
  1476. Xint erc;
  1477. Xchar switches[8];
  1478. XESD *pathesd = (ESD *)0;
  1479. XESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
  1480. X
  1481. X    if(!cmdesd)
  1482. X        return(eNoMemory);
  1483. X
  1484. X    get_switches(param,switches,sizeof(switches));
  1485. X
  1486. X    if(erc = _make_bottom_label(param,!strchr(switches,'l'),1))
  1487. X        return(erc);
  1488. X
  1489. X    /*
  1490. X     * build command at beginning of 'cmdesd' ESD
  1491. X     */
  1492. X    sprintf(cmdesd->pb,"ecusz -Z -. %d -y ",shm->Liofd);
  1493. X    strcat(cmdesd->pb,bottom_label);
  1494. X
  1495. X    if(strchr(switches,'N'))        /* force "no curses" */
  1496. X        strcat(cmdesd->pb,"-@ ");
  1497. X
  1498. X    if(strchr(switches,'a'))
  1499. X        strcat(cmdesd->pb,"-a ");
  1500. X
  1501. X    if(strchr(switches,'n'))
  1502. X        strcat(cmdesd->pb,"-n ");    /* overrides -y choice earlier */
  1503. X
  1504. X    if(strchr(switches,'f'))
  1505. X        strcat(cmdesd->pb,"-f ");
  1506. X
  1507. X#if defined(WHT)    /* for testing */
  1508. X    if(strchr(switches,'p'))
  1509. X        strcat(cmdesd->pb,"-, ");
  1510. X#endif
  1511. X
  1512. X    /*
  1513. X     * update cmdesd esd
  1514. X     */
  1515. X    cmdesd->cb = strlen(cmdesd->pb);
  1516. X
  1517. X    if(!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
  1518. X    {
  1519. X        erc = eNoMemory;
  1520. X        goto FREE_MEM_AND_EXIT;
  1521. X    }
  1522. X
  1523. X    /*
  1524. X     * get list of pathnames to send
  1525. X     */
  1526. X    if(erc = gstr(param,pathesd,1))
  1527. X        goto FREE_MEM_AND_EXIT;
  1528. X
  1529. X    /*
  1530. X     * append filelist to command
  1531. X     */
  1532. X    if(erc = esdcat(cmdesd,pathesd,1))
  1533. X        goto FREE_MEM_AND_EXIT;
  1534. X
  1535. X    /*
  1536. X     * perform the operation
  1537. X     */
  1538. X    erc = _smart_sender_common(cmdesd->pb);
  1539. X
  1540. XFREE_MEM_AND_EXIT:
  1541. X    if(pathesd)
  1542. X        esdfree(pathesd);
  1543. X    if(cmdesd)
  1544. X        esdfree(cmdesd);
  1545. X    return(erc);
  1546. X
  1547. X}    /* end of pcmd_sz */
  1548. X
  1549. X/*+-------------------------------------------------------------------------
  1550. X    pcmd_sk(param)
  1551. X
  1552. Xsk [-a] <str>
  1553. X--------------------------------------------------------------------------*/
  1554. Xint
  1555. Xpcmd_sk(param)
  1556. XESD *param;
  1557. X{
  1558. Xint erc;
  1559. Xchar switches[8];
  1560. XESD *pathesd = (ESD *)0;
  1561. XESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
  1562. X
  1563. X    if(!cmdesd)
  1564. X        return(eNoMemory);
  1565. X
  1566. X    get_switches(param,switches,sizeof(switches));
  1567. X
  1568. X    /*
  1569. X     * build command at beginning of 'cmdesd' ESD
  1570. X     */
  1571. X    sprintf(cmdesd->pb,"ckermit -l %d -b %u -p %c%s%s -s ",
  1572. X        shm->Liofd,shm->Lbaud,
  1573. X        (shm->Lparity) ? shm->Lparity : 'n',
  1574. X        (strchr(switches,'a')) ? "" : " -i",
  1575. X        (1 /* overwrite*/ ) ? "" : " -w");
  1576. X
  1577. X    if(strchr(switches,'b'))
  1578. X        strcat(cmdesd->pb,"-a ");
  1579. X    else
  1580. X        strcat(cmdesd->pb,"-b ");
  1581. X
  1582. X    if(strchr(switches,'n'))
  1583. X        strcat(cmdesd->pb,"-n ");    /* overrides -y choice earlier */
  1584. X    if(strchr(switches,'f'))
  1585. X        strcat(cmdesd->pb,"-f ");
  1586. X
  1587. X    /*
  1588. X     * update cmdesd esd
  1589. X     */
  1590. X    cmdesd->cb = strlen(cmdesd->pb);
  1591. X
  1592. X    if(!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
  1593. X    {
  1594. X        erc = eNoMemory;
  1595. X        goto FREE_MEM_AND_EXIT;
  1596. X    }
  1597. X
  1598. X    /*
  1599. X     * get list of pathnames to send
  1600. X     */
  1601. X    if(erc = gstr(param,pathesd,1))
  1602. X        goto FREE_MEM_AND_EXIT;
  1603. X
  1604. X    /*
  1605. X     * append filelist to command
  1606. X     */
  1607. X    if(erc = esdcat(cmdesd,pathesd,1))
  1608. X        goto FREE_MEM_AND_EXIT;
  1609. X
  1610. X    /*
  1611. X     * perform the operation
  1612. X     */
  1613. X    last_child_wait_status = 0;
  1614. X    if(exec_cmd(cmdesd->pb))
  1615. X        erc = eFATAL_ALREADY;
  1616. X
  1617. XFREE_MEM_AND_EXIT:
  1618. X    if(pathesd)
  1619. X        esdfree(pathesd);
  1620. X    if(cmdesd)
  1621. X        esdfree(cmdesd);
  1622. X
  1623. X    file_xfer_done_bell();
  1624. X    lreset_ksr();
  1625. X
  1626. X    return(_adjust_erc_and_iv0(erc));
  1627. X
  1628. X}    /* end of pcmd_sk */
  1629. X
  1630. X/*+-------------------------------------------------------------------------
  1631. X    pcmd_ss(param)
  1632. X--------------------------------------------------------------------------*/
  1633. Xint
  1634. Xpcmd_ss(param)
  1635. XESD *param;
  1636. X{
  1637. Xint erc;
  1638. XESD *pathesd = (ESD *)0;
  1639. XESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
  1640. X
  1641. X    if(!cmdesd)
  1642. X        return(eNoMemory);
  1643. X
  1644. X    /*
  1645. X     * build command at beginning of 'cmdesd' ESD
  1646. X     */
  1647. X    sprintf(cmdesd->pb,"ecusea -. %d -/ %s -s ",shm->Liofd,curr_dir);
  1648. X
  1649. X    /*
  1650. X     * update cmdesd esd
  1651. X     */
  1652. X    cmdesd->cb = strlen(cmdesd->pb);
  1653. X
  1654. X    if(!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
  1655. X    {
  1656. X        erc = eNoMemory;
  1657. X        goto FREE_MEM_AND_EXIT;
  1658. X    }
  1659. X
  1660. X    /*
  1661. X     * get list of pathnames to send
  1662. X     */
  1663. X    if(erc = gstr(param,pathesd,1))
  1664. X        goto FREE_MEM_AND_EXIT;
  1665. X
  1666. X    /*
  1667. X     * append filelist to command
  1668. X     */
  1669. X    if(erc = esdcat(cmdesd,pathesd,1))
  1670. X        goto FREE_MEM_AND_EXIT;
  1671. X
  1672. X    /*
  1673. X     * perform the operation
  1674. X     */
  1675. X    last_child_wait_status = 0;
  1676. X    if(exec_cmd(cmdesd->pb))
  1677. X        erc = eFATAL_ALREADY;
  1678. X
  1679. XFREE_MEM_AND_EXIT:
  1680. X    if(pathesd)
  1681. X        esdfree(pathesd);
  1682. X    if(cmdesd)
  1683. X        esdfree(cmdesd);
  1684. X
  1685. X    file_xfer_done_bell();
  1686. X    lreset_ksr();
  1687. X
  1688. X    return(_adjust_erc_and_iv0(erc));
  1689. X
  1690. X}    /* end of pcmd_ss */
  1691. X
  1692. X/*+-------------------------------------------------------------------------
  1693. X    pcmd_rx(param)
  1694. X
  1695. Xrx [-b] <str>
  1696. X--------------------------------------------------------------------------*/
  1697. Xint
  1698. Xpcmd_rx(param)
  1699. XESD *param;
  1700. X{
  1701. Xint erc = 0;
  1702. Xchar cmdstr[CMDSTR_SIZE];
  1703. Xchar switches[8];
  1704. XESD *pathesd = esdalloc(PATHESD_INITIAL_SIZE);
  1705. X
  1706. X    if(!pathesd)
  1707. X        return(eNoMemory);
  1708. X
  1709. X    get_switches(param,switches,sizeof(switches));
  1710. X
  1711. X    if(erc = gstr(param,pathesd,1))
  1712. X    {
  1713. X        esdfree(pathesd);
  1714. X        return(erc);
  1715. X    }
  1716. X
  1717. X    if(erc = _make_bottom_label(param,!strchr(switches,'l'),0))
  1718. X        return(erc);
  1719. X
  1720. X    /*
  1721. X     * build command in 'cmdstr' string
  1722. X     */
  1723. X    sprintf(cmdstr,"ecurz -X -. %d -c ",shm->Liofd);
  1724. X    strcat(cmdstr,bottom_label);
  1725. X    if(!strchr(switches,'b'))
  1726. X        strcat(cmdstr,"-b ");
  1727. X    else
  1728. X        strcat(cmdstr,"-a ");
  1729. X    strcat(cmdstr,pathesd->pb);
  1730. X    esdfree(pathesd);
  1731. X    file_xfer_start();
  1732. X
  1733. X    last_child_wait_status = 0;
  1734. X
  1735. X    if(exec_cmd(cmdstr))
  1736. X        erc = eFATAL_ALREADY;
  1737. X    else
  1738. X        erc = _adjust_erc_and_iv0(erc);
  1739. X
  1740. X    file_xfer_done_bell();
  1741. X    lreset_ksr();
  1742. X    return(erc);
  1743. X
  1744. X}    /* end of pcmd_rx */
  1745. X
  1746. X/*+-------------------------------------------------------------------------
  1747. X    pcmd_ry(param)
  1748. X
  1749. Xry
  1750. X--------------------------------------------------------------------------*/
  1751. Xint
  1752. Xpcmd_ry(param)
  1753. XESD *param;
  1754. X{
  1755. Xint erc = 0;
  1756. Xchar cmdstr[CMDSTR_SIZE];
  1757. Xchar switches[8];
  1758. X
  1759. X    get_switches(param,switches,sizeof(switches));
  1760. X
  1761. X    last_child_wait_status = 0;
  1762. X
  1763. X    if(erc = _make_bottom_label(param,!strchr(switches,'l'),0))
  1764. X        return(erc);
  1765. X
  1766. X    /*
  1767. X     * build command in 'cmdstr' string
  1768. X     */
  1769. X    sprintf(cmdstr,"ecurz -Y -. %d -y ",shm->Liofd);
  1770. X    strcat(cmdstr,bottom_label);
  1771. X    file_xfer_start();
  1772. X    if(exec_cmd(cmdstr))
  1773. X        erc = eFATAL_ALREADY;
  1774. X    else
  1775. X        erc = _adjust_erc_and_iv0(erc);
  1776. X
  1777. X    file_xfer_done_bell();
  1778. X    lreset_ksr();
  1779. X
  1780. X    return(erc);
  1781. X}    /* end of pcmd_ry */
  1782. X
  1783. X/*+-------------------------------------------------------------------------
  1784. X    pcmd_rz(param)
  1785. X--------------------------------------------------------------------------*/
  1786. Xint
  1787. Xpcmd_rz(param)
  1788. XESD *param;
  1789. X{
  1790. Xint erc = 0;
  1791. Xchar cmdstr[CMDSTR_SIZE];
  1792. Xchar switches[8];
  1793. X
  1794. X    get_switches(param,switches,sizeof(switches));
  1795. X
  1796. X    last_child_wait_status = 0;
  1797. X
  1798. X    if(erc = _make_bottom_label(param,!strchr(switches,'l'),0))
  1799. X        return(erc);
  1800. X
  1801. X    /*
  1802. X     * build command in 'cmdstr' string
  1803. X     */
  1804. X    sprintf(cmdstr,"ecurz -Z -. %d ",shm->Liofd);
  1805. X    strcat(cmdstr,bottom_label);
  1806. X
  1807. X    if(strchr(switches,'N'))        /* force "no curses" */
  1808. X        strcat(cmdstr,"-@ ");
  1809. X#if defined(WHT)    /* for testing */
  1810. X    if(strchr(switches,'c'))
  1811. X        strcat(cmdstr,"-: ");
  1812. X    if(strchr(switches,'p'))
  1813. X        strcat(cmdstr,"-, ");
  1814. X#endif
  1815. X    file_xfer_start();
  1816. X    if(exec_cmd(cmdstr))
  1817. X        erc = eFATAL_ALREADY;
  1818. X    else
  1819. X        erc = _adjust_erc_and_iv0(erc);
  1820. X
  1821. X    file_xfer_done_bell();
  1822. X    lreset_ksr();
  1823. X
  1824. X    return(erc);
  1825. X}    /* end of pcmd_rz */
  1826. X
  1827. X/*+-------------------------------------------------------------------------
  1828. X    pcmd_rk(param)
  1829. X
  1830. Xrk [-a]
  1831. X--------------------------------------------------------------------------*/
  1832. Xint
  1833. Xpcmd_rk(param)
  1834. XESD *param;
  1835. X{
  1836. Xint erc = 0;
  1837. Xchar cmdstr[CMDSTR_SIZE];
  1838. Xchar switches[8];
  1839. X
  1840. X    get_switches(param,switches,sizeof(switches));
  1841. X
  1842. X    last_child_wait_status = 0;
  1843. X    sprintf(cmdstr,"ckermit -r -e 512 -l %d -b %d -p %c",
  1844. X        shm->Liofd,shm->Lbaud,(shm->Lparity) ? shm->Lparity : 'n');
  1845. X    if(strchr(switches,'a'))
  1846. X        strcat(cmdstr,"-i ");
  1847. X    file_xfer_start();
  1848. X
  1849. X    if(exec_cmd(cmdstr))
  1850. X        erc = eFATAL_ALREADY;
  1851. X    else
  1852. X        erc = _adjust_erc_and_iv0(erc);
  1853. X
  1854. X    file_xfer_done_bell();
  1855. X    lreset_ksr();
  1856. X
  1857. X    return(erc);
  1858. X}    /* end of pcmd_rk */
  1859. X
  1860. X/*+-------------------------------------------------------------------------
  1861. X    pcmd_rs(param)
  1862. X
  1863. Xrs
  1864. X--------------------------------------------------------------------------*/
  1865. Xint
  1866. Xpcmd_rs(param)
  1867. XESD *param;
  1868. X{
  1869. Xint erc = 0;
  1870. Xchar cmdstr[CMDSTR_SIZE];
  1871. X
  1872. X    file_xfer_start();
  1873. X    sprintf(cmdstr,"ecusea -r -. %d -/ %s",shm->Liofd,curr_dir);
  1874. X
  1875. X    if(exec_cmd(cmdstr))
  1876. X        erc = eFATAL_ALREADY;
  1877. X    else
  1878. X        erc = _adjust_erc_and_iv0(erc);
  1879. X
  1880. X    file_xfer_done_bell();
  1881. X    lreset_ksr();
  1882. X
  1883. X    return(erc);
  1884. X}    /* end of pcmd_rs */
  1885. X
  1886. X
  1887. X/* vi: set tabstop=4 shiftwidth=4: */
  1888. X/* end of pcmdxfer.c */
  1889. SHAR_EOF
  1890. $TOUCH -am 0725125991 'pcmdxfer.c' &&
  1891. chmod 0644 pcmdxfer.c ||
  1892. echo 'restore of pcmdxfer.c failed'
  1893. Wc_c="`wc -c < 'pcmdxfer.c'`"
  1894. test 16424 -eq "$Wc_c" ||
  1895.     echo 'pcmdxfer.c: original size 16424, current size' "$Wc_c"
  1896. rm -f _shar_wnt_.tmp
  1897. fi
  1898. # ============= poutput.c ==============
  1899. if test -f 'poutput.c' -a X"$1" != X"-c"; then
  1900.     echo 'x - skipping poutput.c (File already exists)'
  1901.     rm -f _shar_wnt_.tmp
  1902. else
  1903. > _shar_wnt_.tmp
  1904. echo 'x - extracting poutput.c (Text)'
  1905. sed 's/^X//' << 'SHAR_EOF' > 'poutput.c' &&
  1906. X/*+-------------------------------------------------------------------------
  1907. X    poutput.c - ecu procedure output routines
  1908. X    wht@n4hgf.Mt-Park.GA.US
  1909. X
  1910. X  Defined functions:
  1911. X    pcmd_plog(param)
  1912. X    pperror(str)
  1913. X    pputc(ch)
  1914. X    pputs(str)
  1915. X
  1916. X--------------------------------------------------------------------------*/
  1917. X/*+:EDITS:*/
  1918. X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  1919. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1920. X
  1921. X#include "ecu.h"
  1922. X#include "ecukey.h"
  1923. X#include "ecuerror.h"
  1924. X#include "esd.h"
  1925. X
  1926. Xextern int proctrace;
  1927. Xextern FILE *rcvr_log_fp;
  1928. X
  1929. XFILE *plog_fp = (FILE *)0;
  1930. XESD *plog_name = (ESD *)0;
  1931. X
  1932. X/*+-------------------------------------------------------------------------
  1933. X    plogs(str)
  1934. X--------------------------------------------------------------------------*/
  1935. Xvoid
  1936. Xplogs(str)
  1937. Xchar *str;
  1938. X{
  1939. X    if(plog_fp)
  1940. X        fputs(str,plog_fp);
  1941. X}    /* end of plogs */
  1942. X
  1943. X/*+-------------------------------------------------------------------------
  1944. X    plogc(ch)
  1945. X--------------------------------------------------------------------------*/
  1946. Xvoid
  1947. Xplogc(ch)
  1948. Xchar ch;
  1949. X{
  1950. X    if(plog_fp)
  1951. X        fputc(ch,plog_fp);
  1952. X}    /* end of plogc */
  1953. X
  1954. X/*+-------------------------------------------------------------------------
  1955. X    pputc(ch) - put procedure output character to stderr and log
  1956. X--------------------------------------------------------------------------*/
  1957. Xvoid
  1958. Xpputc(ch)
  1959. Xchar ch;
  1960. X{
  1961. X    if(ch == NL)
  1962. X        fputc(CRET,se);
  1963. X    fputc(ch,se);
  1964. X    if(plog_fp && (ch != CRET))
  1965. X        fputc(ch,plog_fp);
  1966. X    if(rcvr_log_fp && (ch != CRET))
  1967. X        fputc(ch,rcvr_log_fp);
  1968. X}    /* end of pputc */
  1969. X
  1970. X/*+-------------------------------------------------------------------------
  1971. X    pputs(str) - put procedure output string to stderr and log
  1972. X--------------------------------------------------------------------------*/
  1973. Xvoid
  1974. Xpputs(str)
  1975. Xregister char *str;
  1976. X{
  1977. X    while(*str)
  1978. X    {
  1979. X        if(*str == NL)
  1980. X            fputc(CRET,se);
  1981. X        fputc(*str,se);
  1982. X        if(plog_fp && (*str != CRET))
  1983. X            fputc(*str,plog_fp);
  1984. X        if(rcvr_log_fp && (*str != CRET))
  1985. X            fputc(*str,rcvr_log_fp);
  1986. X        str++;
  1987. X    }
  1988. X}    /* end of pputs */
  1989. X
  1990. X/*+-------------------------------------------------------------------------
  1991. X    pflush()
  1992. X--------------------------------------------------------------------------*/
  1993. Xvoid
  1994. Xpflush()
  1995. X{
  1996. X    if(plog_fp)
  1997. X        fflush(plog_fp);
  1998. X}    /* end of pflush */
  1999. X
  2000. X/*+-------------------------------------------------------------------------
  2001. X    pperror(str)
  2002. X--------------------------------------------------------------------------*/
  2003. Xvoid
  2004. Xpperror(str)
  2005. Xchar *str;
  2006. X{
  2007. Xextern char *sys_errlist[];
  2008. Xextern int sys_nerr;
  2009. Xextern int errno;
  2010. Xint save_errno = errno;
  2011. X
  2012. X    if(str && *str)
  2013. X    {
  2014. X        pputs(str);
  2015. X        pputs(": ");
  2016. X    }
  2017. X    if(save_errno <= sys_nerr)
  2018. X        pputs(sys_errlist[save_errno]);
  2019. X    else
  2020. X        pprintf("error %d",save_errno);
  2021. X    pputs("\n");
  2022. X}    /* end of pperror */
  2023. X
  2024. X/*+-------------------------------------------------------------------------
  2025. X    plog_control(fname)
  2026. X fname == 0, close
  2027. X fname == 1, plog_name already plugged
  2028. X--------------------------------------------------------------------------*/
  2029. Xint
  2030. Xplog_control(fname)
  2031. Xchar *fname;
  2032. X{
  2033. X    if(!fname)    /* close */
  2034. X    {
  2035. X        if(plog_fp)
  2036. X            fclose(plog_fp);
  2037. X        plog_fp = (FILE *)0;
  2038. X        return(0);
  2039. X    }
  2040. X
  2041. X    if(plog_fp)
  2042. X        plog_control((char *)0);
  2043. X
  2044. X    if(fname != (char *)1)
  2045. X    {
  2046. X        strcpy(plog_name->pb,fname);
  2047. X        plog_name->cb = strlen(fname);
  2048. X    }
  2049. X
  2050. X    if((plog_fp = fopen(plog_name->pb,"a")) == NULL)
  2051. X    {
  2052. X        pperror(plog_name->pb);
  2053. X        return(eFATAL_ALREADY);
  2054. X    }
  2055. X    return(0);
  2056. X}    /* end of plog_control */
  2057. X
  2058. X/*+-------------------------------------------------------------------------
  2059. X    pcmd_plog(param)
  2060. X
  2061. Xplog $s0     log to file
  2062. Xplog off     stop logging
  2063. Xplog         show status
  2064. X--------------------------------------------------------------------------*/
  2065. Xint
  2066. Xpcmd_plog(param)
  2067. XESD *param;
  2068. X{
  2069. Xint erc = eSyntaxError;
  2070. Xchar off_str[8];
  2071. X
  2072. X    if(!skip_cmd_break(param))    /* if arguments */
  2073. X    {
  2074. X        if(!get_alpha_zstr(param,off_str,sizeof(off_str)))
  2075. X        {
  2076. X            if(strcmp(off_str,"off"))
  2077. X                return(eBadParameter);
  2078. X            erc = plog_control((char *)0);
  2079. X        }
  2080. X        else
  2081. X        {
  2082. X            if(erc = gstr(param,plog_name,1))
  2083. X                return(erc);
  2084. X            erc = plog_control((char *)1);
  2085. X        }
  2086. X    }
  2087. X    return(erc);
  2088. X
  2089. X}    /* end of pcmd_plog */
  2090. X
  2091. X/*+-------------------------------------------------------------------------
  2092. X    poutput_init()
  2093. X--------------------------------------------------------------------------*/
  2094. Xvoid
  2095. Xpoutput_init()
  2096. X{
  2097. X    if((plog_name = esdalloc(256)) == (ESD *)0)
  2098. X    {
  2099. X        ff(se,"Out of memory\r\n");
  2100. X        termecu(1);
  2101. X    }
  2102. X}    /* end of poutput_init */
  2103. X
  2104. X/* vi: set tabstop=4 shiftwidth=4: */
  2105. X/* end of poutput.c */
  2106. SHAR_EOF
  2107. $TOUCH -am 0725125991 'poutput.c' &&
  2108. chmod 0644 poutput.c ||
  2109. echo 'restore of poutput.c failed'
  2110. Wc_c="`wc -c < 'poutput.c'`"
  2111. test 4430 -eq "$Wc_c" ||
  2112.     echo 'poutput.c: original size 4430, current size' "$Wc_c"
  2113. rm -f _shar_wnt_.tmp
  2114. fi
  2115. # ============= pprintf.c ==============
  2116. if test -f 'pprintf.c' -a X"$1" != X"-c"; then
  2117.     echo 'x - skipping pprintf.c (File already exists)'
  2118.     rm -f _shar_wnt_.tmp
  2119. else
  2120. > _shar_wnt_.tmp
  2121. echo 'x - extracting pprintf.c (Text)'
  2122. sed 's/^X//' << 'SHAR_EOF' > 'pprintf.c' &&
  2123. X/*+-------------------------------------------------------------------------
  2124. X    pprintf.c - procedure printf
  2125. X
  2126. X  This module has been hacked a bit to work for ECU applications
  2127. X  as of its writing.  If you use this with SCO MSC, the ifdefs
  2128. X  will work in any environment.  Using it without any SCO
  2129. X  predefines will cause %p to print as a 32-bit linear pointer.
  2130. X  M_I286 assumes %p is a segmented pointer unless M_SDATA is
  2131. X  supplied too, in which case %p prints as a 16-bit segment offset.
  2132. X--------------------------------------------------------------------------*/
  2133. X/*+:EDITS:*/
  2134. X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  2135. X/*:01-09-1991-22:31-wht@n4hgf-ISC port */
  2136. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  2137. X
  2138. X/* based on Portable vsprintf  by Robert A. Larson <blarson@skat.usc.edu> */
  2139. X
  2140. X/* Copyright 1989 Robert A. Larson.
  2141. X * Distribution in any form is allowed as long as the author
  2142. X * retains credit, changes are noted by their author and the
  2143. X * copyright message remains intact.  This program comes as-is
  2144. X * with no warentee of fitness for any purpouse.
  2145. X *
  2146. X * Thanks to Doug Gwen, Chris Torek, and others who helped clarify
  2147. X * the ansi printf specs.
  2148. X *
  2149. X * Please send any bug fixes and improvments to blarson@skat.usc.edu .
  2150. X * The use of goto is NOT a bug.
  2151. X */
  2152. X
  2153. X#if !defined(BUILDING_PROTOTYPES)
  2154. X
  2155. X#include <stdio.h>
  2156. X#include <varargs.h>
  2157. X
  2158. X#if defined(M_I386) || defined(i386)
  2159. X#define LONGINT
  2160. X#endif
  2161. X
  2162. X/* This must be a typedef not a #define! */
  2163. X#define NOVOID
  2164. X#if defined(NOVOID)
  2165. Xtypedef char *pointer;
  2166. X#else
  2167. Xtypedef void *pointer;
  2168. X#endif
  2169. X
  2170. Xtypedef int *intp;
  2171. X
  2172. X/*+-------------------------------------------------------------------------
  2173. X    pprintf(format,va_alist)
  2174. X--------------------------------------------------------------------------*/
  2175. Xvoid
  2176. Xpprintf(format,va_alist)
  2177. Xregister char *format;
  2178. Xva_dcl
  2179. X{
  2180. Xva_list args;
  2181. Xregister char c;
  2182. Xregister char *tp;
  2183. Xchar tempfmt[64];
  2184. X#if !defined(LONGINT)
  2185. Xint longflag;
  2186. X#endif
  2187. Xchar accum_string[256];
  2188. Xregister char *dp = accum_string;
  2189. X
  2190. X    va_start(args);
  2191. X
  2192. X    tempfmt[0] = '%';
  2193. X    while(c = *format++)
  2194. X    {
  2195. X        if(c=='%')
  2196. X        {
  2197. X            tp = &tempfmt[1];
  2198. X#if !defined(LONGINT)
  2199. X            longflag = 0;
  2200. X#endif
  2201. Xcontinue_format:
  2202. X            switch(c = *format++)
  2203. X            {
  2204. X            case 's':
  2205. X                *tp++ = c;
  2206. X                *tp = '\0';
  2207. X                dp += sprintf(dp,tempfmt,va_arg(args,char *));
  2208. X                break;
  2209. X            case 'u':
  2210. X            case 'x':
  2211. X            case 'o':
  2212. X            case 'X':
  2213. X#if defined(UNSIGNEDSPECIAL)
  2214. X                *tp++ = c;
  2215. X                *tp = '\0';
  2216. X#if !defined(LONGINT)
  2217. X                if(longflag)
  2218. X                    dp += sprintf(dp,tempfmt,va_arg(args,unsigned long));
  2219. X                else
  2220. X#endif
  2221. X                    dp += sprintf(dp,tempfmt,va_arg(args,unsigned));
  2222. X                break;
  2223. X#endif
  2224. X            case 'd':
  2225. X            case 'c':
  2226. X            case 'i':
  2227. X                *tp++ = c;
  2228. X                *tp = '\0';
  2229. X#if !defined(LONGINT)
  2230. X                if(longflag)
  2231. X                    dp += sprintf(dp,tempfmt,va_arg(args,long));
  2232. X                else
  2233. X#endif
  2234. X                    dp += sprintf(dp,tempfmt,va_arg(args,int));
  2235. X                break;
  2236. X            case 'f':
  2237. X            case 'e':
  2238. X            case 'E':
  2239. X            case 'g':
  2240. X            case 'G':
  2241. X                *tp++ = c;
  2242. X                *tp = '\0';
  2243. X                dp += sprintf(dp,tempfmt,va_arg(args,double));
  2244. X                break;
  2245. X            case 'p':
  2246. X#if defined(M_I286)
  2247. X                tp = va_arg(args,pointer);
  2248. X#if defined(M_SDATA)
  2249. X                dp += sprintf(dp,"0x%04x",tp);
  2250. X#else
  2251. X                dp += sprintf(dp,"%04x:%04x",(int)tp,(int)((long)tp >> 16));
  2252. X#endif /* M_SDATA */
  2253. X#else
  2254. X                dp += sprintf(dp,"0x%08lx",va_arg(args,pointer));
  2255. X#endif /* M_I286 */
  2256. X                break;
  2257. X            case '-':
  2258. X            case '+':
  2259. X            case '0':
  2260. X            case '1':
  2261. X            case '2':
  2262. X            case '3':
  2263. X            case '4':
  2264. X            case '5':
  2265. X            case '6':
  2266. X            case '7':
  2267. X            case '8':
  2268. X            case '9':
  2269. X            case '.':
  2270. X            case ' ':
  2271. X            case '#':
  2272. X            case 'h':
  2273. X                *tp++ = c;
  2274. X                goto continue_format;
  2275. X            case 'l':
  2276. X#if !defined(LONGINT)
  2277. X                longflag = 1;
  2278. X                *tp++ = c;
  2279. X#endif
  2280. X                goto continue_format;
  2281. X            case '*':
  2282. X                tp += sprintf(tp,"%d",va_arg(args,int));
  2283. X                goto continue_format;
  2284. X            case '%':
  2285. X            default:
  2286. X                *dp++ = c;
  2287. X                break;
  2288. X            }
  2289. X        }
  2290. X        else *dp++ = c;
  2291. X    }
  2292. X    *dp = '\0';
  2293. X    va_end(args);
  2294. X    pputs(accum_string);
  2295. X}    /* end of pprintf */
  2296. X#endif /* !defined(BUILDING_PROTOTYPES) */
  2297. X
  2298. X/* vi: set tabstop=4 shiftwidth=4: */
  2299. X/* end of pprintf.c */
  2300. SHAR_EOF
  2301. $TOUCH -am 0725125991 'pprintf.c' &&
  2302. chmod 0644 pprintf.c ||
  2303. echo 'restore of pprintf.c failed'
  2304. Wc_c="`wc -c < 'pprintf.c'`"
  2305. test 3984 -eq "$Wc_c" ||
  2306.     echo 'pprintf.c: original size 3984, current size' "$Wc_c"
  2307. rm -f _shar_wnt_.tmp
  2308. fi
  2309. # ============= proc.c ==============
  2310. if test -f 'proc.c' -a X"$1" != X"-c"; then
  2311.     echo 'x - skipping proc.c (File already exists)'
  2312.     rm -f _shar_wnt_.tmp
  2313. else
  2314. > _shar_wnt_.tmp
  2315. echo 'x - extracting proc.c (Text)'
  2316. sed 's/^X//' << 'SHAR_EOF' > 'proc.c' &&
  2317. X/*+-------------------------------------------------------------------------
  2318. X    proc.c - procedure command and control
  2319. X    wht@n4hgf.Mt-Park.GA.US
  2320. X
  2321. X  Defined functions:
  2322. X    _cmd_gosub_common(param,type)
  2323. X    _get_goto_label(param)
  2324. X    pcmd_do(param)
  2325. X    pcmd_gosub(param)
  2326. X    pcmd_gosubb(param)
  2327. X    pcmd_goto(param)
  2328. X    pcmd_gotob(param)
  2329. X    pcmd_return(param)
  2330. X    do_proc(argc,argv)
  2331. X    dump_proc(pcb)
  2332. X    execute_esd(tesd)
  2333. X    execute_goto(pcb,goto_type)
  2334. X    execute_labelled_esd(tesd)
  2335. X    execute_proc(pcb,use_goto_label)
  2336. X    find_labelled_lcb(label,first,last)
  2337. X    find_proc_cmd(cmd_list,cmd)
  2338. X    find_procedure(name)
  2339. X    free_lcb_chain(lcb)
  2340. X    show_error_position(pcb)
  2341. X    trace_proc_cmd(pcb)
  2342. X
  2343. X--------------------------------------------------------------------------*/
  2344. X/*+:EDITS:*/
  2345. X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  2346. X/*:07-01-1991-01:53-wht@n4hgf-fix return with value */
  2347. X/*:05-01-1991-04:18-wht@n4hgf-new find_procedure failed on home subdir match */
  2348. SHAR_EOF
  2349. true || echo 'restore of proc.c failed'
  2350. fi
  2351. echo 'End of ecu310 part 17'
  2352. echo 'File proc.c is continued in part 18'
  2353. echo 18 > _shar_seq_.tmp
  2354. exit 0
  2355. --------------------------------------------------------------------
  2356. Warren Tucker, TuckerWare emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
  2357. Hacker Extraordinaire  d' async PADs,  pods,  proteins and protocols
  2358.  
  2359. exit 0 # Just in case...
  2360. -- 
  2361. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  2362. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  2363. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  2364. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  2365.