Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

915 lines
20 KiB

  1. /* File: C:\WACKER\xfer\hpr_sd.c (Created: 25-Jan-1994)
  2. * created from HAWIN source file
  3. * hpr_sd.c -- System dependent routines to support HyperProtocol
  4. *
  5. * Copyright 1989,1994 by Hilgraeve Inc. -- Monroe, MI
  6. * All rights reserved
  7. *
  8. * $Revision: 1 $
  9. * $Date: 10/05/98 1:16p $
  10. */
  11. // #define DEBUGSTR
  12. #include <windows.h>
  13. #include <setjmp.h>
  14. #include <time.h>
  15. #include <term\res.h>
  16. #include <sys\types.h>
  17. #include <sys\utime.h>
  18. #include <tdll\stdtyp.h>
  19. #include <tdll\mc.h>
  20. #include <tdll\com.h>
  21. #include <tdll\assert.h>
  22. #include <tdll\session.h>
  23. #include <tdll\load_res.h>
  24. #include <tdll\xfer_msc.h>
  25. #include <tdll\globals.h>
  26. #include <tdll\file_io.h>
  27. #if !defined(BYTE)
  28. #define BYTE unsigned char
  29. #endif
  30. #include "cmprs.h"
  31. #include "xfr_dsp.h"
  32. #include "xfr_todo.h"
  33. #include "xfr_srvc.h"
  34. #include "xfer.h"
  35. #include "xfer.hh"
  36. #include "xfer_tsc.h"
  37. #include "hpr.h"
  38. #include "hpr.hh"
  39. #include "hpr_sd.hh"
  40. // struct s_hprsd FAR *hsd;
  41. /* RECEIVING */
  42. #define DRR_RCV_FILE 1
  43. #define DRR_STORING 2
  44. // int suspend_for_disk = 0;
  45. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  46. * hr_setup
  47. *
  48. * DESCRIPTION:
  49. * Called as a HyperProtocol receive session is beginning. This routine
  50. * must allocate memory for control structures hc and hrc. It may also
  51. * initiate a screen display to use during the transfer and do any other
  52. * necessary setup.
  53. * Values for the user-settable globals, h_useattr, h_trycompress, h_chkt
  54. * and h_suspenddsk, should also be set here if they have not already been
  55. * set through the use of program options or menu settings.
  56. *
  57. * ARGUMENTS:
  58. * none
  59. *
  60. * RETURNS:
  61. * TRUE if transfer can continue.
  62. * FALSE if a memory allocation or other type of error occurred.
  63. */
  64. int hr_setup(struct s_hc *hc)
  65. {
  66. unsigned int uiOldOptions;
  67. XFR_PARAMS *pX;
  68. XFR_HP_PARAMS *pH;
  69. pX = (XFR_PARAMS *)0;
  70. xfrQueryParameters(hc->hSession, (VOID **)&pX);
  71. if (pX != (XFR_PARAMS *)0)
  72. hc->h_useattr = pX->fUseDateTime;
  73. pH = (XFR_HP_PARAMS *)xfer_get_params(hc->hSession, XF_HYPERP);
  74. hc->blocksize = pH->nBlockSize;
  75. hc->h_chkt = (pH->nCheckType == HP_CT_CRC) ? H_CRC : H_CHECKSUM;
  76. hc->h_resynctime = pH->nResyncTimeout;
  77. hc->h_trycompress = pH->nTryCompression;
  78. if (xfer_set_comport(hc->hSession, FALSE, &uiOldOptions) != TRUE)
  79. {
  80. /* TODO: put in an error message of some sort */
  81. return FALSE;
  82. }
  83. hc->sd.hld_options = uiOldOptions;
  84. hrdsp_compress(hc, compress_status() == COMPRESS_ACTIVE);
  85. hc->sd.k_received = 0;
  86. return TRUE;
  87. }
  88. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  89. * hr_wrapup
  90. *
  91. * DESCRIPTION:
  92. *
  93. *
  94. * ARGUMENTS:
  95. *
  96. *
  97. * RETURNS:
  98. *
  99. */
  100. int hr_wrapup(struct s_hc *hc, int attended, int status)
  101. {
  102. xfer_restore_comport(hc->hSession, hc->sd.hld_options);
  103. /* TODO: decide if anything can be done if we get an error */
  104. if (hc->fhdl || status == H_FILEERR) /* abnormal exit */
  105. {
  106. xfer_log_xfer(hc->hSession, FALSE,
  107. hc->rc.rmtfname, NULL,
  108. hr_result_codes[hc->rc.cancel_reason]);
  109. fio_close(hc->fhdl);
  110. hc->fhdl = NULL;
  111. DeleteFile(hc->rc.ourfname);
  112. }
  113. if (hc->fhdl)
  114. {
  115. fio_close(hc->fhdl);
  116. hc->fhdl = NULL;
  117. }
  118. if (attended)
  119. {
  120. #if FALSE
  121. menu_bottom_line(BL_ESC, 0L);
  122. #if defined(OS2)
  123. if (os2_cfg_popup)
  124. popup_replybox(-1, ENTER_RESP, T_POPUP_WAIT, TM_POPUP_COMPLETE);
  125. #endif
  126. DosBeep(beepfreq, beeplen);
  127. menu_replybox(hc->sd.msgrow, ENTER_RESP, 0,
  128. (int)transfer_status_msg((USHORT)hr_result_codes[hc->rc.cancel_reason]));
  129. #endif
  130. }
  131. xferMsgClose(hc->hSession);
  132. return status;
  133. }
  134. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  135. * hrdsp_progress
  136. *
  137. * DESCRIPTION:
  138. * Displays the progress of a filetransfer on screen by showing the number of
  139. * bytes transferred and updating the vu meters if they have been initialized.
  140. *
  141. * ARGUMENTS:
  142. * final -- If TRUE, indicates that the transfer is finished and the final
  143. * progress display is needed. Durning a transfer the number of
  144. * bytes is rounded off to the next lower 'k'. After a transfer
  145. * is completed, the final display is rounded UP.
  146. *
  147. * RETURNS:
  148. *
  149. */
  150. void hrdsp_progress(struct s_hc *hc, int status)
  151. {
  152. long ttime, stime;
  153. long bytes_rcvd;
  154. long cps;
  155. long new_elapsed = -1;
  156. long new_remaining = -1;
  157. long new_cps = -1;
  158. long new_file = -1;
  159. long new_total = -1;
  160. if (hc->xfertimer == -1L)
  161. return;
  162. ttime = bittest(status, TRANSFER_DONE) ?
  163. hc->xfertime : interval(hc->xfertimer);
  164. if ((stime = ttime / 10L) != hc->displayed_time ||
  165. bittest(status, FILE_DONE | TRANSFER_DONE))
  166. {
  167. /* Display elapsed time */
  168. new_elapsed = (hc->displayed_time = stime);
  169. /* Display amount received */
  170. bytes_rcvd = hc->total_dsp + hc->h_filebytes;
  171. /* if an error occurs at the end of an interrupt data block, it
  172. * can temporarily appear that we've received more data than is
  173. * actually available -- make sure we don't show more received than
  174. * is coming.
  175. */
  176. if (hc->rc.bytes_expected > 0L && bytes_rcvd > hc->rc.bytes_expected)
  177. bytes_rcvd = hc->rc.bytes_expected;
  178. new_file = hc->h_filebytes;
  179. new_total = bytes_rcvd;
  180. /* Display current compression status */
  181. if (!bittest(status, FILE_DONE | TRANSFER_DONE))
  182. hrdsp_compress(hc, compress_status() == COMPRESS_ACTIVE);
  183. /* Display throughput and time remaining */
  184. if (stime > 0 &&
  185. (cps = ((hc->total_thru + hc->h_filebytes) * 10L) / ttime) > 0)
  186. {
  187. new_cps = cps;
  188. /* calculate time to completion */
  189. if (hc->rc.bytes_expected > 0L)
  190. {
  191. ttime = (hc->rc.bytes_expected - bytes_rcvd) / cps;
  192. if (hc->rc.files_expected > 1)
  193. ttime += (hc->rc.files_expected - hc->current_filen);
  194. new_remaining = ttime;
  195. }
  196. else if (hc->rc.filesize > 0L)
  197. {
  198. ttime = (hc->rc.filesize - hc->h_filebytes) / cps;
  199. new_remaining = ttime;
  200. }
  201. }
  202. }
  203. DbgOutStr("elapsed=%ld, remaining=%ld, cps=%ld\r\n",
  204. new_elapsed, new_remaining, new_cps, 0, 0);
  205. xferMsgProgress(hc->hSession,
  206. new_elapsed,
  207. new_remaining,
  208. new_cps,
  209. new_file,
  210. new_total);
  211. }
  212. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  213. * hrdsp_status
  214. *
  215. * DESCRIPTION:
  216. *
  217. *
  218. * ARGUMENTS:
  219. *
  220. *
  221. * RETURNS:
  222. *
  223. */
  224. void hrdsp_status(struct s_hc *hc, int status)
  225. {
  226. xferMsgStatus(hc->hSession, status);
  227. }
  228. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  229. * hrdsp_event
  230. *
  231. * DESCRIPTION:
  232. *
  233. *
  234. * ARGUMENTS:
  235. *
  236. *
  237. * RETURNS:
  238. *
  239. */
  240. void hrdsp_event(struct s_hc *hc, int event)
  241. {
  242. xferMsgEvent(hc->hSession, event);
  243. }
  244. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  245. * hrdsp_filecnt
  246. *
  247. * DESCRIPTION:
  248. *
  249. *
  250. * ARGUMENTS:
  251. *
  252. *
  253. * RETURNS:
  254. *
  255. */
  256. void hrdsp_filecnt(struct s_hc *hc, int cnt)
  257. {
  258. xferMsgFilecnt(hc->hSession, cnt);
  259. }
  260. void hrdsp_errorcnt(struct s_hc *hc, int cnt)
  261. {
  262. xferMsgErrorcnt(hc->hSession, cnt);
  263. }
  264. void hrdsp_compress(struct s_hc *hc, int cnt)
  265. {
  266. xferMsgCompression(hc->hSession, cnt);
  267. }
  268. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  269. * hrdsp_totalsize
  270. *
  271. * DESCRIPTION:
  272. *
  273. *
  274. * ARGUMENTS:
  275. *
  276. *
  277. * RETURNS:
  278. *
  279. */
  280. void hrdsp_totalsize(struct s_hc *hc, long bytes)
  281. {
  282. xferMsgTotalsize(hc->hSession, bytes);
  283. }
  284. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  285. * hrdsp_newfile
  286. *
  287. * DESCRIPTION:
  288. *
  289. *
  290. * ARGUMENTS:
  291. *
  292. *
  293. * RETURNS:
  294. *
  295. */
  296. void hrdsp_newfile(struct s_hc *hc,
  297. int filen,
  298. BYTE *theirname,
  299. TCHAR *ourname)
  300. {
  301. xferMsgNewfile(hc->hSession, filen, theirname, ourname);
  302. }
  303. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  304. * hrdsp_filesize
  305. *
  306. * DESCRIPTION:
  307. *
  308. *
  309. * ARGUMENTS:
  310. *
  311. *
  312. * RETURNS:
  313. *
  314. */
  315. void hrdsp_filesize(struct s_hc *hc, long fsize)
  316. {
  317. xferMsgFilesize(hc->hSession, fsize);
  318. }
  319. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  320. *
  321. *
  322. * DESCRIPTION:
  323. *
  324. *
  325. * ARGUMENTS:
  326. *
  327. *
  328. * RETURNS:
  329. *
  330. */
  331. #if FALSE
  332. void NEARF hpr_idle(HSESSION hS)
  333. {
  334. /* update elapsed time */
  335. // task_exec();
  336. DoYield(mGetCLoopHdl(hS));
  337. }
  338. #endif
  339. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  340. * SENDING *
  341. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  342. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  343. * hs_setup
  344. *
  345. * DESCRIPTION:
  346. * Handles transfer initialization and intial screen display.
  347. *
  348. * ARGUMENTS:
  349. * nfiles -- The number of files that will be sent
  350. * nbytes -- The total number of bytes to be sent.
  351. *
  352. * RETURNS:
  353. * TRUE if no errors were encountered and its ok for transfer to proceed.
  354. * FALSE if lack of memory prevents start of transfer.
  355. */
  356. int hs_setup(struct s_hc *hc, int nfiles, long nbytes)
  357. {
  358. unsigned int uiOldOptions;
  359. int enough_memory = TRUE;
  360. XFR_PARAMS *pX;
  361. XFR_HP_PARAMS *pH;
  362. pX = (XFR_PARAMS *)0;
  363. xfrQueryParameters(hc->hSession, (VOID **)&pX);
  364. if (pX != (XFR_PARAMS *)0)
  365. hc->h_useattr = pX->fUseDateTime;
  366. pH = (XFR_HP_PARAMS *)xfer_get_params(hc->hSession, XF_HYPERP);
  367. hc->blocksize = pH->nBlockSize;
  368. hc->h_chkt = (pH->nCheckType == HP_CT_CRC) ? H_CRC : H_CHECKSUM;
  369. hc->h_resynctime = pH->nResyncTimeout;
  370. hc->h_trycompress = pH->nTryCompression;
  371. hc->dptr = hc->msgdata;
  372. hc->rmcnt = 0;
  373. if (xfer_set_comport(hc->hSession, TRUE, &uiOldOptions) != TRUE)
  374. {
  375. /* TODO: decide of we need an error message or something */
  376. return FALSE;
  377. }
  378. hc->hsxb.bufrsize = HSXB_SIZE;
  379. hc->hsxb.cnt = HSXB_CYCLE;
  380. hc->hsxb.total = hc->hsxb.bufrsize - hc->hsxb.cnt;
  381. hc->hsxb.bptr = hc->hsxb.curbufr;
  382. hc->hsxb.curbufr = NULL;
  383. hc->hsxb.altbufr = NULL;
  384. if (enough_memory)
  385. hc->hsxb.curbufr = malloc(hc->hsxb.bufrsize);
  386. if (hc->hsxb.curbufr == NULL)
  387. enough_memory = FALSE;
  388. if (enough_memory)
  389. hc->hsxb.altbufr = malloc(hc->hsxb.bufrsize);
  390. if (hc->hsxb.altbufr == NULL)
  391. enough_memory = FALSE;
  392. /* allocate as much memory as is available for the file table */
  393. if (enough_memory)
  394. {
  395. hc->sc.ft_limit = 32; /* just for now */
  396. hc->sc.hs_ftbl = malloc((size_t)(hc->sc.ft_limit + 1) * sizeof(struct s_ftbl));
  397. if (hc->sc.hs_ftbl == NULL)
  398. enough_memory = FALSE;
  399. }
  400. /* if we couldn't get enough memory, report it and leave */
  401. if (!enough_memory)
  402. {
  403. if (hc->hsxb.curbufr != NULL)
  404. free(hc->hsxb.curbufr);
  405. if (hc->hsxb.altbufr != NULL)
  406. free(hc->hsxb.altbufr);
  407. if (hc->sc.hs_ftbl != NULL)
  408. free(hc->sc.hs_ftbl);
  409. /* TODO: add reperror call, or something like it */
  410. assert(enough_memory);
  411. return(FALSE);
  412. }
  413. hc->sd.hld_options = uiOldOptions;
  414. hsdsp_compress(hc, compress_status() == COMPRESS_ACTIVE);
  415. xferMsgFilecnt(hc->hSession, nfiles);
  416. xferMsgTotalsize(hc->hSession, nbytes);
  417. return TRUE;
  418. }
  419. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  420. * hs_wrapup
  421. *
  422. * DESCRIPTION:
  423. *
  424. *
  425. * ARGUMENTS:
  426. *
  427. *
  428. * RETURNS:
  429. *
  430. */
  431. void hs_wrapup(struct s_hc *hc, int attended, int bailout_status)
  432. {
  433. // bxmit_clear(); /* make sure no dregs are left in xmitter buffer */
  434. ComSndBufrClear(sessQueryComHdl(hc->hSession));
  435. xfer_restore_comport(hc->hSession, hc->sd.hld_options);
  436. /* TODO: decide if it is useful to actually check for an error */
  437. if (bailout_status == TSC_OK)
  438. {
  439. // hp_report_xtime((unsigned)hc->xfertime);
  440. }
  441. /* free all the memory we used */
  442. xferMsgClose(hc->hSession);
  443. free(hc->hsxb.curbufr);
  444. free(hc->hsxb.altbufr);
  445. free(hc->sc.hs_ftbl);
  446. }
  447. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  448. * hs_fxmit
  449. *
  450. * DESCRIPTION:
  451. * Sends a single character using HyperProtocol's dual buffering system.
  452. * This functions does exactly what the macro hs_xmit_ does, but is in
  453. * function form so it can be passed as a pointer.
  454. *
  455. * ARGUMENTS:
  456. * c -- The character to be transmitted.
  457. *
  458. * RETURNS:
  459. * nothing
  460. */
  461. void hs_fxmit(struct s_hc *hc, BYTE c)
  462. {
  463. hs_xmit_(hc, c);
  464. }
  465. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  466. * hs_xmit_switch
  467. *
  468. * DESCRIPTION:
  469. * Sends a character using HyperProtocol's dual buffering system and checks
  470. * whether it is time to switch buffers. Normally, one buffer will be in the
  471. * process of being transmitted while the other is being filled. If the
  472. * transmission is completed before the next buffer has been filled, some
  473. * idle time could be wasted waiting for the second buffer to fill. This
  474. * routine checks whether the transmitter is idle. If it is, it sets up the
  475. * current buffer to start transmitting and begins filling the other buffer.
  476. * If the transmitter is still busy, it continues on filling the current
  477. * buffer.
  478. *
  479. * ARGUMENTS:
  480. * c -- The character to be transmitted.
  481. *
  482. * RETURNS:
  483. * Returns the argument as a convenience.
  484. */
  485. BYTE hs_xmit_switch(struct s_hc *hc, BYTE c)
  486. {
  487. *hc->hsxb.bptr++ = c; /* place the character in the current buffer */
  488. if (!ComSndBufrBusy(sessQueryComHdl(hc->hSession)) || (hc->hsxb.total == 0))
  489. {
  490. /* start xmitting this buffer and filling the other */
  491. hs_xbswitch(hc);
  492. }
  493. else
  494. {
  495. /* keep going with same buffer by starting a new fill cycle */
  496. #if defined(FINETUNE)
  497. hc->hsxb.cnt = min(usr_hsxb_cycle, hc->hsxb.total);
  498. #else
  499. hc->hsxb.cnt = min(HSXB_CYCLE, hc->hsxb.total);
  500. #endif
  501. hc->hsxb.total -= hc->hsxb.cnt;
  502. }
  503. xfer_idle(hc->hSession);
  504. return(c);
  505. }
  506. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  507. * hs_xbswitch
  508. *
  509. * DESCRIPTION:
  510. * Switches the currently filling buffer with the transmitting buffer.
  511. * This function performs the actual switch described in the header for the
  512. * function hs_xmit_switch(). The current buffer is set up be transmitted
  513. * and the other buffer is setup to be filled. If the transmitter is busy
  514. * This function will wait for a defined period of time for it to complete.
  515. * If the function has to wait longer than a certain minimum time, the
  516. * event and status messages will be updated to inform the user of the delay.
  517. *
  518. * ARGUMENTS:
  519. * none
  520. *
  521. * RETURNS:
  522. * nothing
  523. */
  524. void hs_xbswitch(struct s_hc *hc)
  525. {
  526. HCOM hCom;
  527. register int displayed = FALSE;
  528. long timer;
  529. long time;
  530. unsigned bsize;
  531. hCom = sessQueryComHdl(hc->hSession);
  532. if (hc->hsxb.bptr > hc->hsxb.curbufr)/* if there is anything to transmit */
  533. {
  534. bsize = (unsigned)(hc->hsxb.bptr - hc->hsxb.curbufr);
  535. if (ComSndBufrSend(hCom, hc->hsxb.curbufr, bsize, 10))
  536. {
  537. timer = startinterval();
  538. while (ComSndBufrSend(hCom, hc->hsxb.curbufr, bsize, 10))
  539. {
  540. // hs_background(hSession);
  541. /* keep elapsed time display accurate */
  542. if ((time = (interval(hc->xfertimer) / 10L)) != hc->displayed_time)
  543. xferMsgProgress(hc->hSession,
  544. (hc->displayed_time = time),
  545. -1, -1, -1, -1);
  546. if (!displayed && interval(timer) > 40L)
  547. {
  548. hsdsp_event(hc, HSE_FULL);
  549. hsdsp_status(hc, HSS_WAITRESUME);
  550. displayed = TRUE;
  551. }
  552. }
  553. if (displayed)
  554. {
  555. hsdsp_event(hc, HSE_GOTRESUME);
  556. hsdsp_status(hc, HSS_SENDING);
  557. }
  558. }
  559. /* hc->sc.bytes_sent is used in the throughput and time remaining
  560. * calculations. It is always ahead of the number of characters
  561. * actually transmitted because of buffering. To keep it from
  562. * being too far ahead, we add in only half of the buffer about
  563. * to be queued for transmission. Since a buffer-full may span
  564. * more than one file, don't let value go negative
  565. */
  566. if ((hc->sc.bytes_sent = hc->h_filebytes - (bsize / 2)) < 0)
  567. hc->sc.bytes_sent = 0;
  568. hc->hsxb.bptr = hc->hsxb.altbufr;
  569. hc->hsxb.altbufr = hc->hsxb.curbufr;
  570. hc->hsxb.curbufr = hc->hsxb.bptr;
  571. #if defined(FINETUNE)
  572. hc->hsxb.cnt = usr_hsxb_cycle;
  573. #else
  574. hc->hsxb.cnt = HSXB_CYCLE;
  575. #endif
  576. hc->hsxb.total = hc->hsxb.bufrsize - hc->hsxb.cnt;
  577. }
  578. }
  579. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  580. * hs_xbclear
  581. *
  582. * DESCRIPTION:
  583. * Clears the dual buffering system used in HyperProtocol. Any buffer being
  584. * transitted is cut off and the current fill buffer is emptied.
  585. *
  586. * ARGUMENTS:
  587. * none
  588. *
  589. * RETURNS:
  590. * nothing
  591. */
  592. void hs_xbclear(struct s_hc *hc)
  593. {
  594. hc->hsxb.bptr = hc->hsxb.curbufr;
  595. #if defined(FINETUNE)
  596. hc->hsxb.cnt = usr_hsxb_cycle;
  597. #else
  598. hc->hsxb.cnt = HSXB_CYCLE;
  599. #endif
  600. hc->hsxb.total = hc->hsxb.bufrsize - hc->hsxb.cnt;
  601. // xmit_count = 0;
  602. }
  603. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  604. * hsdsp_progress
  605. *
  606. * DESCRIPTION:
  607. * Updates display fields on screen to indicate the progress of the transfer.
  608. *
  609. * ARGUMENTS:
  610. * none
  611. *
  612. * RETURNS:
  613. * nothing
  614. */
  615. void hsdsp_progress(struct s_hc *hc, int status)
  616. {
  617. long new_stime = -1;
  618. long new_ttime = -1;
  619. long new_cps = -1;
  620. long file_so_far = -1;
  621. long total_so_far = -1;
  622. long ttime, stime;
  623. long bytes_sent;
  624. long cps;
  625. // int k_sent;
  626. if (hc->xfertimer == -1L)
  627. return;
  628. ttime = bittest(status, TRANSFER_DONE) ?
  629. hc->xfertime : interval(hc->xfertimer);
  630. if ((stime = ttime / 10L) != hc->displayed_time ||
  631. bittest(status, FILE_DONE | TRANSFER_DONE))
  632. {
  633. new_stime = stime;
  634. /* Display amount transferred */
  635. bytes_sent = hc->total_dsp + hc->sc.bytes_sent;
  636. if (!bittest(status, TRANSFER_DONE))
  637. file_so_far = hc->sc.bytes_sent;
  638. total_so_far = bytes_sent;
  639. /* Display throughput and time remaining */
  640. if ((stime > 2 ||
  641. ttime > 0 && bittest(status, FILE_DONE | TRANSFER_DONE)) &&
  642. (cps = ((hc->total_thru + hc->sc.bytes_sent) * 10L) / ttime) > 0)
  643. {
  644. new_cps = cps;
  645. ttime = ((hc->sc.nbytes - bytes_sent) / cps) +
  646. hc->sc.nfiles - hc->current_filen;
  647. new_ttime = ttime;
  648. }
  649. hc->displayed_time = stime;
  650. }
  651. xferMsgProgress(hc->hSession,
  652. new_stime,
  653. new_ttime,
  654. new_cps,
  655. file_so_far,
  656. total_so_far);
  657. }
  658. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  659. * hsdsp_newfile
  660. *
  661. * DESCRIPTION:
  662. *
  663. *
  664. * ARGUMENTS:
  665. *
  666. *
  667. * RETURNS:
  668. *
  669. */
  670. void hsdsp_newfile(struct s_hc *hc, int filen, TCHAR *fname, long flength)
  671. {
  672. xferMsgNewfile(hc->hSession,
  673. filen,
  674. NULL,
  675. fname);
  676. xferMsgFilesize(hc->hSession, flength);
  677. }
  678. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  679. * hsdsp_compress
  680. *
  681. * DESCRIPTION:
  682. *
  683. *
  684. * ARGUMENTS:
  685. *
  686. *
  687. * RETURNS:
  688. *
  689. */
  690. void hsdsp_compress(struct s_hc *hc, int tf)
  691. {
  692. xferMsgCompression(hc->hSession, tf);
  693. }
  694. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  695. * hsdsp_retries
  696. *
  697. * DESCRIPTION:
  698. *
  699. *
  700. * ARGUMENTS:
  701. *
  702. *
  703. * RETURNS:
  704. *
  705. */
  706. void hsdsp_retries(struct s_hc *hc, int t)
  707. {
  708. xferMsgErrorcnt(hc->hSession, t);
  709. }
  710. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  711. * hsdsp_status
  712. *
  713. * DESCRIPTION:
  714. *
  715. *
  716. * ARGUMENTS:
  717. *
  718. *
  719. * RETURNS:
  720. *
  721. */
  722. void hsdsp_status(struct s_hc *hc, int s)
  723. {
  724. xferMsgStatus(hc->hSession, s);
  725. }
  726. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  727. * hsdsp_event
  728. *
  729. * DESCRIPTION:
  730. *
  731. *
  732. * ARGUMENTS:
  733. *
  734. *
  735. * RETURNS:
  736. *
  737. */
  738. void hsdsp_event(struct s_hc *hc, int e)
  739. {
  740. xferMsgEvent(hc->hSession, e);
  741. }
  742. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  743. * hpr_id_get
  744. *
  745. * DESCRIPTION:
  746. *
  747. *
  748. * ARGUMENTS:
  749. *
  750. *
  751. * RETURNS:
  752. *
  753. */
  754. void hpr_id_get(struct s_hc *hc, BYTE *dst)
  755. {
  756. wsprintf(dst, "V%u,%s", 100, (BYTE *)"HyperTerm by Hilgraeve, Inc.");
  757. }
  758. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  759. * hpr_id_check
  760. *
  761. * DESCRIPTION:
  762. *
  763. *
  764. * ARGUMENTS:
  765. *
  766. *
  767. * RETURNS:
  768. *
  769. */
  770. int hpr_id_check(struct s_hc *hc, int rev, BYTE *name)
  771. {
  772. /* no restrictions on who we'll talk to */
  773. rev = rev; /* keep compiler and lint from complaining */
  774. name = name;
  775. return TRUE;
  776. }