pcmdxfer.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. /*+-------------------------------------------------------------------------
  2. pcmdxfer.c - ecu file transfer related procedure commands
  3. wht@wht.net
  4. Defined functions:
  5. _adjust_erc_and_iv0(adj_erc)
  6. _make_bottom_label(param, default_flag, sending_flag)
  7. _pcmd_report_send_status()
  8. _smart_sender_common(cmd)
  9. pcmd_rk(param)
  10. pcmd_rx(param)
  11. pcmd_ry(param)
  12. pcmd_rz(param)
  13. pcmd_sk(param)
  14. pcmd_sx(param)
  15. pcmd_sy(param)
  16. pcmd_sz(param)
  17. --------------------------------------------------------------------------*/
  18. /*+:EDITS:*/
  19. /*:04-26-2000-11:16-wht@bob-RELEASE 4.42 */
  20. /*:02-25-1997-14:36-wht@yuriatin-anonymous caller fix for sx/sy (-@ missing) */
  21. /*:01-24-1997-02:38-wht@yuriatin-SOURCE RELEASE 4.00 */
  22. /*:09-11-1996-20:01-wht@yuriatin-3.48-major telnet,curses,structural overhaul */
  23. /*:01-01-1996-18:57-wht@kepler-fix sz with force overwrite */
  24. /*:11-27-1995-20:16-wht@kepler-add -T on sz */
  25. /*:11-27-1995-20:15-wht@kepler-CMDESD_INITIAL_SIZE from 384 to 512 */
  26. /*:11-27-1995-11:57-wht@kepler-honor protocol_log_packets */
  27. /*:11-24-1995-09:57-wht@kepler-improve rz command for telnet */
  28. /*:11-23-1995-11:20-wht@kepler-source control 3.37 for tsx-11 */
  29. /*:11-14-1995-10:23-wht@kepler-3.37.80-source control point: SOCKETS */
  30. /*:10-14-1995-23:49-wht@kepler-switch -@ now passed line baud value */
  31. /*:10-14-1995-23:22-wht@kepler-drop SEAlink support */
  32. /*:03-12-1995-03:27-wht@kepler-use ECU_MAXPN */
  33. /*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
  34. /*:10-21-1992-19:15-wht@n4hgf-proc file xfer didnt learn about eculibdir */
  35. /*:09-10-1992-14:00-wht@n4hgf-ECU release 3.20 */
  36. /*:09-05-1992-15:35-wht@n4hgf-add -r to sz */
  37. /*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
  38. /*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  39. /*:04-23-1991-23:44-wht@n4hgf-big time overhaul - better but flames expected */
  40. /*:04-23-1991-05:10-wht@n4hgf-new cmd build mechanism for long file lists */
  41. /*:01-17-1991-17:01-wht@n4hgf-skipped files in sz aborted proc */
  42. /*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  43. #include "ecu.h"
  44. #include "ecukey.h"
  45. #include "ecuerror.h"
  46. #include "esd.h"
  47. #include "var.h"
  48. #include "procedure.h"
  49. /*
  50. * file transmission command and pathname list ESD initial size
  51. * (lengths can grow to ESD_MAXSZ)
  52. */
  53. #define CMDESD_INITIAL_SIZE 512 /* executable command initial size */
  54. #define PATHESD_INITIAL_SIZE 256 /* pathname list initial size */
  55. #define CMDSTR_SIZE 384 /* receive command string size */
  56. extern int last_child_wait_status;
  57. extern char curr_dir[ECU_MAXPN];
  58. extern int protocol_log_packets;
  59. static char bottom_label[80];
  60. /*+-------------------------------------------------------------------------
  61. _make_bottom_label(param,default_flag)
  62. --------------------------------------------------------------------------*/
  63. int
  64. _make_bottom_label(param, default_flag, sending_flag)
  65. ESD *param;
  66. int default_flag;
  67. int sending_flag;
  68. {
  69. int erc;
  70. ESD *label = (ESD *) 0;
  71. if (default_flag)
  72. {
  73. sprintf(bottom_label,
  74. (sending_flag) ? "-C \"'Connected to %s'\" "
  75. : "-C 'Connected to %s' ",
  76. (shm->Lrname[0]) ? shm->Lrname : "?");
  77. return (0);
  78. }
  79. if ((label = esdalloc(64)) == (ESD *) 0)
  80. return (eNoMemory);
  81. if (erc = gstr(param, label, 0))
  82. {
  83. esdfree(label);
  84. return (erc);
  85. }
  86. strcpy(bottom_label, (sending_flag) ? "-C \"'" : "-C '");
  87. strcat(bottom_label, label->pb);
  88. strcat(bottom_label, (sending_flag) ? "'\"" : "'");
  89. esdfree(label);
  90. return (0);
  91. } /* end of _make_bottom_label */
  92. /*+-------------------------------------------------------------------------
  93. _adjust_erc_and_iv0(adj_erc)
  94. --------------------------------------------------------------------------*/
  95. int
  96. _adjust_erc_and_iv0(adj_erc)
  97. int adj_erc;
  98. {
  99. if (adj_erc)
  100. return (adj_erc);
  101. iv[0] = (last_child_wait_status & 0xFF)
  102. ? 0x100L : (long)((last_child_wait_status >> 8) & 0xFFFF);
  103. if (proc_trace)
  104. pprintf("$i00 = %ld (transfer %s)\n", iv[0],
  105. (iv[0] == 0x100L) ? "interrupted" : "program exit status");
  106. return (0);
  107. } /* end of _adjust_erc_and_iv0 */
  108. /*+-------------------------------------------------------------------------
  109. _pcmd_report_send_status() - report file transmission result
  110. for "ecu knowledgeable" protocols only
  111. returns proc-type erc
  112. --------------------------------------------------------------------------*/
  113. int
  114. _pcmd_report_send_status()
  115. {
  116. UINT16 ustmp;
  117. int erc = eFATAL_ALREADY;
  118. int iv0_set = 0;
  119. char *signal_name_text();
  120. pputs("\n");
  121. ustmp = last_child_wait_status;
  122. if ((ustmp & 0xFF) == 0) /* exit() called */
  123. {
  124. ustmp >>= 8;
  125. if (!ustmp)
  126. {
  127. if (proc_trace)
  128. pputs("transfer successful\n");
  129. erc = 0;
  130. }
  131. else if (ustmp == 255)
  132. pputs("ecu error: transfer program usage error\n");
  133. else if (ustmp == 254)
  134. {
  135. pputs(
  136. "protocol failure: bad line conditions or remote not ready\n");
  137. }
  138. else if (ustmp == 253)
  139. pputs("no requested files exist\n");
  140. else if (ustmp < 128)
  141. {
  142. if (proc_trace)
  143. {
  144. if (ustmp == 127)
  145. pputs("127 or more files skipped\n");
  146. else
  147. pprintf("%u files rejected\n", ustmp);
  148. }
  149. iv[0] = (long)ustmp;
  150. iv0_set = 1;
  151. last_child_wait_status = 0;
  152. erc = 0;
  153. }
  154. else
  155. {
  156. pprintf("transfer aborted by %s\n", signal_name_text(ustmp & 0x7F));
  157. erc = eProcAttn_Interrupt;
  158. }
  159. }
  160. else
  161. {
  162. pprintf("transfer killed by %s\n", signal_name_text(ustmp & 0x7F));
  163. erc = eProcAttn_Interrupt;
  164. }
  165. if (!iv0_set)
  166. {
  167. iv[0] = (last_child_wait_status & 0xFF)
  168. ? 0x100L : (long)((last_child_wait_status >> 8) & 0xFFFF);
  169. }
  170. if (proc_trace)
  171. {
  172. pprintf("$i00 = %ld (transfer %s)\n", iv[0],
  173. (iv[0] == 0x100L) ? "interrupted" : "program exit status");
  174. }
  175. return (erc);
  176. } /* end of _pcmd_report_send_status */
  177. /*+-------------------------------------------------------------------------
  178. _smart_sender_common(cmd) - common exec and bottom processing
  179. for "ecu knowledgeable" protocols only
  180. returns proc-type erc
  181. --------------------------------------------------------------------------*/
  182. int
  183. _smart_sender_common(cmd)
  184. char *cmd;
  185. {
  186. int erc = 0;
  187. last_child_wait_status = 0;
  188. file_xfer_start();
  189. if (find_shell_chars(cmd))
  190. {
  191. char *expcmd;
  192. if (expand_wildcard_list(cmd, &expcmd))
  193. {
  194. pputs("No files match wildcard list\n");
  195. iv[0] = -1;
  196. return (0);
  197. }
  198. else
  199. {
  200. exec_cmd(expcmd);
  201. erc = _pcmd_report_send_status();
  202. free(expcmd);
  203. }
  204. }
  205. else
  206. {
  207. exec_cmd(cmd);
  208. erc = _pcmd_report_send_status();
  209. }
  210. lreset_ksr();
  211. file_xfer_done_bell();
  212. return (erc);
  213. } /* end of _smart_sender_common */
  214. /*+-------------------------------------------------------------------------
  215. pcmd_sx(param)
  216. sx [-ak[l]] [<label-str>] <filelist-str>
  217. --------------------------------------------------------------------------*/
  218. int
  219. pcmd_sx(param)
  220. ESD *param;
  221. {
  222. int erc;
  223. char switches[8];
  224. ESD *pathesd = (ESD *) 0;
  225. ESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
  226. get_switches(param, switches, sizeof(switches));
  227. if (erc = _make_bottom_label(param, !strchr(switches, 'l'), 1))
  228. return (erc);
  229. /*
  230. * build command at beginning of 'cmdesd' ESD
  231. */
  232. sprintf(cmdesd->pb, "%s/ecusz -X -@ %d -. %d ",
  233. eculibdir, shm->Lbitrate, shm->Liofd);
  234. strcat(cmdesd->pb, bottom_label);
  235. if (strchr(switches, 'p') || protocol_log_packets)
  236. strcat(cmdesd->pb, "-, ");
  237. if (strchr(switches, 'a'))
  238. strcat(cmdesd->pb, "-a ");
  239. if (strchr(switches, 'k'))
  240. strcat(cmdesd->pb, "-k");
  241. if (tty_not_char_special || (shm->ttyuse == TTYUSE_FORCE_SIMPLE) ||
  242. strchr(switches, 'N')) /* force "no curses" */
  243. {
  244. strcat(cmdesd->pb, "-_ ");
  245. }
  246. /*
  247. * update cmdesd esd
  248. */
  249. cmdesd->cb = strlen(cmdesd->pb);
  250. if (!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
  251. {
  252. erc = eNoMemory;
  253. goto FREE_MEM_AND_EXIT;
  254. }
  255. /*
  256. * get list of pathnames to send
  257. */
  258. if (erc = gstr(param, pathesd, 1))
  259. goto FREE_MEM_AND_EXIT;
  260. /*
  261. * append filelist to command
  262. */
  263. if (erc = esdcat(cmdesd, pathesd, 1))
  264. goto FREE_MEM_AND_EXIT;
  265. /*
  266. * perform the operation
  267. */
  268. erc = _smart_sender_common(cmdesd->pb);
  269. FREE_MEM_AND_EXIT:
  270. if (pathesd)
  271. esdfree(pathesd);
  272. if (cmdesd)
  273. esdfree(cmdesd);
  274. return (erc);
  275. } /* end of pcmd_sx */
  276. /*+-------------------------------------------------------------------------
  277. pcmd_sy(param)
  278. sy [-a[l]] [<label-str>] <filelist-str>
  279. --------------------------------------------------------------------------*/
  280. int
  281. pcmd_sy(param)
  282. ESD *param;
  283. {
  284. int erc;
  285. char switches[8];
  286. ESD *pathesd = (ESD *) 0;
  287. ESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
  288. get_switches(param, switches, sizeof(switches));
  289. if (erc = _make_bottom_label(param, !strchr(switches, 'l'), 1))
  290. return (erc);
  291. /*
  292. * build command at beginning of 'cmdesd' ESD
  293. */
  294. sprintf(cmdesd->pb, "%s/ecusz -Y -@ %d -. %d ",
  295. eculibdir, shm->Lbitrate, shm->Liofd);
  296. strcat(cmdesd->pb, bottom_label);
  297. if (strchr(switches, 'a'))
  298. strcat(cmdesd->pb, "-a ");
  299. else
  300. strcat(cmdesd->pb, "-b ");
  301. if (strchr(switches, 'p') || protocol_log_packets)
  302. strcat(cmdesd->pb, "-, ");
  303. if (tty_not_char_special || (shm->ttyuse == TTYUSE_FORCE_SIMPLE) ||
  304. strchr(switches, 'N')) /* force "no curses" */
  305. {
  306. strcat(cmdesd->pb, "-_ ");
  307. }
  308. /*
  309. * update cmdesd esd
  310. */
  311. cmdesd->cb = strlen(cmdesd->pb);
  312. if (!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
  313. {
  314. erc = eNoMemory;
  315. goto FREE_MEM_AND_EXIT;
  316. }
  317. /*
  318. * get list of pathnames to send
  319. */
  320. if (erc = gstr(param, pathesd, 1))
  321. goto FREE_MEM_AND_EXIT;
  322. /*
  323. * append filelist to command
  324. */
  325. if (erc = esdcat(cmdesd, pathesd, 1))
  326. goto FREE_MEM_AND_EXIT;
  327. /*
  328. * perform the operation
  329. */
  330. erc = _smart_sender_common(cmdesd->pb);
  331. FREE_MEM_AND_EXIT:
  332. if (pathesd)
  333. esdfree(pathesd);
  334. if (cmdesd)
  335. esdfree(cmdesd);
  336. return (erc);
  337. } /* end of pcmd_sy */
  338. /*+-------------------------------------------------------------------------
  339. pcmd_sz(param)
  340. sz [-anf[l]] [<label-str>] <filelist-str>
  341. -a ascii, else binary
  342. -n send only newer, else all files
  343. -f full, else simple pathnames
  344. -r resume interrupted xfer
  345. -l non-default bottom line label on transfer string
  346. $i0 set to:
  347. 0: file transfer completely successful
  348. -1 program did not run
  349. --------------------------------------------------------------------------*/
  350. int
  351. pcmd_sz(param)
  352. ESD *param;
  353. {
  354. int erc;
  355. char switches[8];
  356. ESD *pathesd = (ESD *) 0;
  357. ESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
  358. if (!cmdesd)
  359. return (eNoMemory);
  360. get_switches(param, switches, sizeof(switches));
  361. if (erc = _make_bottom_label(param, !strchr(switches, 'l'), 1))
  362. return (erc);
  363. /*
  364. * build command at beginning of 'cmdesd' ESD
  365. */
  366. sprintf(cmdesd->pb, "%s/ecusz -Z -@ %d -. %d ",
  367. eculibdir, shm->Lbitrate, shm->Liofd);
  368. strcat(cmdesd->pb, bottom_label);
  369. if (tty_not_char_special || (shm->ttyuse == TTYUSE_FORCE_SIMPLE) ||
  370. strchr(switches, 'N')) /* force "no curses" */
  371. {
  372. strcat(cmdesd->pb, "-_ ");
  373. }
  374. if (shm->Ltelnet)
  375. strcat(cmdesd->pb, "-T ");
  376. if (strchr(switches, 'a'))
  377. strcat(cmdesd->pb, "-a ");
  378. if (strchr(switches, 'n'))
  379. strcat(cmdesd->pb, "-n ");
  380. else
  381. strcat(cmdesd->pb, "-y ");
  382. if (strchr(switches, 'f'))
  383. strcat(cmdesd->pb, "-f ");
  384. if (strchr(switches, 'r'))
  385. strcat(cmdesd->pb, "-r ");
  386. if (strchr(switches, 'p') || protocol_log_packets)
  387. strcat(cmdesd->pb, "-, ");
  388. /*
  389. * update cmdesd esd
  390. */
  391. cmdesd->cb = strlen(cmdesd->pb);
  392. if (!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
  393. {
  394. erc = eNoMemory;
  395. goto FREE_MEM_AND_EXIT;
  396. }
  397. /*
  398. * get list of pathnames to send
  399. */
  400. if (erc = gstr(param, pathesd, 1))
  401. goto FREE_MEM_AND_EXIT;
  402. /*
  403. * append filelist to command
  404. */
  405. if (erc = esdcat(cmdesd, pathesd, 1))
  406. goto FREE_MEM_AND_EXIT;
  407. /*
  408. * perform the operation
  409. */
  410. erc = _smart_sender_common(cmdesd->pb);
  411. FREE_MEM_AND_EXIT:
  412. if (pathesd)
  413. esdfree(pathesd);
  414. if (cmdesd)
  415. esdfree(cmdesd);
  416. return (erc);
  417. } /* end of pcmd_sz */
  418. /*+-------------------------------------------------------------------------
  419. pcmd_sk(param)
  420. sk [-a] <str>
  421. --------------------------------------------------------------------------*/
  422. int
  423. pcmd_sk(param)
  424. ESD *param;
  425. {
  426. int erc;
  427. char switches[8];
  428. ESD *pathesd = (ESD *) 0;
  429. ESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
  430. if (!cmdesd)
  431. return (eNoMemory);
  432. get_switches(param, switches, sizeof(switches));
  433. /*
  434. * build command at beginning of 'cmdesd' ESD
  435. */
  436. sprintf(cmdesd->pb, "ckermit -l %d -b %u -p %c%s%s -s ",
  437. shm->Liofd, shm->Lbitrate,
  438. (shm->Lparity) ? shm->Lparity : 'n',
  439. (strchr(switches, 'a')) ? "" : " -i",
  440. (1 /* overwrite */ )? "" : " -w");
  441. if (strchr(switches, 'b'))
  442. strcat(cmdesd->pb, "-a ");
  443. else
  444. strcat(cmdesd->pb, "-b ");
  445. if (strchr(switches, 'n'))
  446. strcat(cmdesd->pb, "-n "); /* overrides -y choice earlier */
  447. if (strchr(switches, 'f'))
  448. strcat(cmdesd->pb, "-f ");
  449. /*
  450. * update cmdesd esd
  451. */
  452. cmdesd->cb = strlen(cmdesd->pb);
  453. if (!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
  454. {
  455. erc = eNoMemory;
  456. goto FREE_MEM_AND_EXIT;
  457. }
  458. /*
  459. * get list of pathnames to send
  460. */
  461. if (erc = gstr(param, pathesd, 1))
  462. goto FREE_MEM_AND_EXIT;
  463. /*
  464. * append filelist to command
  465. */
  466. if (erc = esdcat(cmdesd, pathesd, 1))
  467. goto FREE_MEM_AND_EXIT;
  468. /*
  469. * perform the operation
  470. */
  471. last_child_wait_status = 0;
  472. if (exec_cmd(cmdesd->pb))
  473. erc = eFATAL_ALREADY;
  474. FREE_MEM_AND_EXIT:
  475. if (pathesd)
  476. esdfree(pathesd);
  477. if (cmdesd)
  478. esdfree(cmdesd);
  479. file_xfer_done_bell();
  480. lreset_ksr();
  481. return (_adjust_erc_and_iv0(erc));
  482. } /* end of pcmd_sk */
  483. /*+-------------------------------------------------------------------------
  484. pcmd_rx(param)
  485. rx [-b] <str>
  486. --------------------------------------------------------------------------*/
  487. int
  488. pcmd_rx(param)
  489. ESD *param;
  490. {
  491. int erc = 0;
  492. char cmdstr[CMDSTR_SIZE];
  493. char switches[8];
  494. ESD *pathesd = esdalloc(PATHESD_INITIAL_SIZE);
  495. if (!pathesd)
  496. return (eNoMemory);
  497. get_switches(param, switches, sizeof(switches));
  498. if (erc = gstr(param, pathesd, 1))
  499. {
  500. esdfree(pathesd);
  501. return (erc);
  502. }
  503. if (erc = _make_bottom_label(param, !strchr(switches, 'l'), 0))
  504. return (erc);
  505. /*
  506. * build command in 'cmdstr' string
  507. */
  508. sprintf(cmdstr, "%s/ecurz -X -. %d ", eculibdir, shm->Liofd);
  509. strcat(cmdstr, bottom_label);
  510. if (!strchr(switches, 'b'))
  511. strcat(cmdstr, "-b ");
  512. else
  513. strcat(cmdstr, "-a ");
  514. strcat(cmdstr, pathesd->pb);
  515. esdfree(pathesd);
  516. file_xfer_start();
  517. last_child_wait_status = 0;
  518. if (exec_cmd(cmdstr))
  519. erc = eFATAL_ALREADY;
  520. else
  521. erc = _adjust_erc_and_iv0(erc);
  522. file_xfer_done_bell();
  523. lreset_ksr();
  524. return (erc);
  525. } /* end of pcmd_rx */
  526. /*+-------------------------------------------------------------------------
  527. pcmd_ry(param)
  528. ry
  529. --------------------------------------------------------------------------*/
  530. int
  531. pcmd_ry(param)
  532. ESD *param;
  533. {
  534. int erc = 0;
  535. char cmdstr[CMDSTR_SIZE];
  536. char switches[8];
  537. get_switches(param, switches, sizeof(switches));
  538. last_child_wait_status = 0;
  539. if (erc = _make_bottom_label(param, !strchr(switches, 'l'), 0))
  540. return (erc);
  541. /*
  542. * build command in 'cmdstr' string
  543. */
  544. sprintf(cmdstr, "%s/ecurz -Y -. %d ", eculibdir, shm->Liofd);
  545. strcat(cmdstr, bottom_label);
  546. file_xfer_start();
  547. if (exec_cmd(cmdstr))
  548. erc = eFATAL_ALREADY;
  549. else
  550. erc = _adjust_erc_and_iv0(erc);
  551. file_xfer_done_bell();
  552. lreset_ksr();
  553. return (erc);
  554. } /* end of pcmd_ry */
  555. /*+-------------------------------------------------------------------------
  556. pcmd_rz(param)
  557. --------------------------------------------------------------------------*/
  558. int
  559. pcmd_rz(param)
  560. ESD *param;
  561. {
  562. int erc = 0;
  563. char switches[8];
  564. char *argv[16];
  565. int argc = 0;
  566. ESD *label = (ESD *) 0;
  567. get_switches(param, switches, sizeof(switches));
  568. last_child_wait_status = 0;
  569. if (strchr(switches, 'l'))
  570. {
  571. if ((label = esdalloc(64)) == (ESD *) 0)
  572. return (eNoMemory);
  573. if (erc = gstr(param, label, 0))
  574. goto FUNC_EXIT;
  575. esdprefix(label, "\"");
  576. esdstrcat(label, "\"");
  577. }
  578. /*
  579. * call xfer program
  580. */
  581. argv[argc++] = "rz";
  582. if (strchr(switches, 'N')) /* force "no curses" */
  583. argv[argc++] = "-_";
  584. if (strchr(switches, 'c')) /* ZCAN upon receive ZEOF */
  585. argv[argc++] = "-:";
  586. if (strchr(switches, 'p')) /* log packets */
  587. argv[argc++] = "-,"; /* protocol_log_packets handled by
  588. * receive_files_from_remote */
  589. if (label) /* bottom label */
  590. {
  591. argv[argc++] = "-C";
  592. argv[argc++] = label->pb;
  593. }
  594. if (receive_files_from_remote(argc, argv) < 0)
  595. erc = eFATAL_ALREADY;
  596. else
  597. erc = _adjust_erc_and_iv0(erc);
  598. FUNC_EXIT:
  599. esdfree(label);
  600. return (erc);
  601. } /* end of pcmd_rz */
  602. /*+-------------------------------------------------------------------------
  603. pcmd_rk(param)
  604. rk [-a]
  605. --------------------------------------------------------------------------*/
  606. int
  607. pcmd_rk(param)
  608. ESD *param;
  609. {
  610. int erc = 0;
  611. char cmdstr[CMDSTR_SIZE];
  612. char switches[8];
  613. get_switches(param, switches, sizeof(switches));
  614. last_child_wait_status = 0;
  615. sprintf(cmdstr, "ckermit -r -e 512 -l %d -b %d -p %c",
  616. shm->Liofd, shm->Lbitrate, (shm->Lparity) ? shm->Lparity : 'n');
  617. if (strchr(switches, 'a'))
  618. strcat(cmdstr, "-i ");
  619. file_xfer_start();
  620. if (exec_cmd(cmdstr))
  621. erc = eFATAL_ALREADY;
  622. else
  623. erc = _adjust_erc_and_iv0(erc);
  624. file_xfer_done_bell();
  625. lreset_ksr();
  626. return (erc);
  627. } /* end of pcmd_rk */
  628. /* vi: set tabstop=4 shiftwidth=4: */
  629. /* end of pcmdxfer.c */