Source code of Windows XP (NT5)
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.

229 lines
7.0 KiB

  1. /*===========================================================================*/
  2. /* Copyright (c) 1987 - 1988, Future Soft Engineering, Inc. */
  3. /* Houston, Texas */
  4. /*===========================================================================*/
  5. #define NOLSTRING TRUE /* jtf win3 mod */
  6. #include <windows.h>
  7. #include "port1632.h"
  8. #include "dcrc.h"
  9. #include "dynacomm.h"
  10. #include "fileopen.h"
  11. #include "task.h"
  12. /*---------------------------------------------------------------------------*/
  13. /* rcvBPre() - [mbb] */
  14. /*---------------------------------------------------------------------------*/
  15. VOID rcvBPre(BYTE *fileName)
  16. {
  17. WORD fScale = ((xferBinType != XFRYMODEM) && (xferBinFork == XFRBOTH)) ? IDSCALE : 0;
  18. showXferCtrls(IDSTOP | IDFORK | fScale | IDSENDING | IDBERRORS);
  19. showRXFname(fileName, STR_RECEIVING);
  20. }
  21. /*---------------------------------------------------------------------------*/
  22. /* rcvPutBFile() - [scf] */
  23. /*---------------------------------------------------------------------------*/
  24. BOOL rcvPutBFile()
  25. {
  26. BOOL rcvPutBFile = FALSE;
  27. FSReply reply;
  28. WORD wMode;
  29. BYTE fileExt[FILENAMELEN+1];
  30. OFSTRUCT file;
  31. wMode = FO_PUTFILE; /* jtf 3.31 | ((xferBinType == XFRYMODEM) ? FO_BATCHMODE : FO_NONDOSFILE); */
  32. if(xferBinType == XFRKERMIT)
  33. /* jtf 3.17 wMode |= FO_REMOTEFILE */ ;
  34. getFileDocData(FILE_NDX_DATA, reply.vRefNum, reply.fName, fileExt, NULL);
  35. *macFileName = 0;
  36. /* mbbx 1.10: CUA... */
  37. if(reply.vRefNum[strlen(reply.vRefNum) - 1] != '\\')
  38. strcat(reply.vRefNum, "\\");
  39. if(reply.good = FileOpen(reply.vRefNum, reply.fName, macFileName, fileExt,
  40. NULL, FO_DBRCVFILE, NULL, wMode))
  41. {
  42. useMacFileName = (*macFileName != 0);
  43. }
  44. if(reply.good)
  45. {
  46. setFileDocData(FILE_NDX_DATA, reply.vRefNum, reply.fName, NULL, NULL); /* mbbx 2.00: no forced extents */
  47. strcpy(xferVRefNum+1, reply.vRefNum); /* mbbx 0.62: save the path !!! */
  48. *xferVRefNum = strlen(xferVRefNum+1);
  49. xferRefNo = 0;
  50. if(xferBinType != XFRYMODEM) /* mbbx 1.01: ymodem */
  51. {
  52. strcpy(xferFname+1, useMacFileName ? macFileName : reply.fName);
  53. *xferFname = strlen(xferFname+1);
  54. if((xferBinType == XFRYTERM) && !answerMode) /* mbbx: yterm */
  55. return(FALSE);
  56. #ifdef ORGCODE
  57. strcpy(reply.vRefNum+strlen(reply.vRefNum), reply.fName);
  58. #else
  59. strcpy(reply.vRefNum+strlen(reply.vRefNum), "\\");
  60. strcpy(reply.vRefNum+strlen(reply.vRefNum), reply.fName);
  61. DEBOUT("rcvPutBfile: opening %s\n",reply.vRefNum);
  62. DEBOUT("rcvPutBfile: %s","using O_CREAT|O_TRUNC, S_IWRITE args\n");
  63. #endif
  64. /* jtf 3.20 */
  65. if((xferRefNo = OpenFile((LPSTR) reply.vRefNum, (LPOFSTRUCT)&file,
  66. OF_WRITE | OF_CREATE)) == -1)
  67. {
  68. xferRefNo = 0; /* mbbx 2.00: remove XTalk... */
  69. rcvErr(reply.fName);
  70. return(FALSE);
  71. }
  72. }
  73. xferErrors = 0;
  74. xferLength = 0L;
  75. xferPct = 0;
  76. xferOrig = -1;
  77. rcvBPre(reply.fName);
  78. rcvPutBFile = TRUE;
  79. }
  80. return(rcvPutBFile);
  81. }
  82. /*---------------------------------------------------------------------------*/
  83. /* rcvBFile() - [scf] */
  84. /*---------------------------------------------------------------------------*/
  85. VOID rcvBFile()
  86. {
  87. if(xferFlag != XFRNONE) /* mbbx 1.10: answerMode... */
  88. {
  89. return;
  90. }
  91. xferFast = FALSE;
  92. if(!answerMode)
  93. {
  94. switch(trmParams.xBinType)
  95. {
  96. case ITMXMODEM:
  97. xferBinType = XFRXMODEM;
  98. break;
  99. case ITMKERMIT:
  100. KERRCVFLAG = KERFILE;
  101. xferBinType = XFRKERMIT;
  102. break;
  103. }
  104. }
  105. xferBinFork = XFRDATA;
  106. if(rcvPutBFile())
  107. {
  108. xferFlag = XFRBRCV;
  109. }
  110. }
  111. /*---------------------------------------------------------------------------*/
  112. /* rcvTerminate() - [scf] */
  113. /*---------------------------------------------------------------------------*/
  114. VOID rcvTerminate()
  115. {
  116. BYTE filePath[PATHLEN];
  117. OFSTRUCT dummy;
  118. if(xferRefNo != 0) /* mbbx 1.01: ymodem */
  119. {
  120. _lclose(xferRefNo);
  121. strcpy(filePath, xferVRefNum+1);
  122. strcpy(filePath+strlen(filePath), xferFname+1);
  123. MOpenFile((LPSTR) filePath, (LPOFSTRUCT) &dummy, OF_DELETE);
  124. }
  125. }
  126. /*---------------------------------------------------------------------------*/
  127. /* rcvAbort() - [scf] */
  128. /*---------------------------------------------------------------------------*/
  129. VOID rcvAbort()
  130. {
  131. BYTE tmp1[TMPNSTR+1];
  132. LoadString(hInst, STR_ABORTRCV, (LPSTR) tmp1, TMPNSTR);
  133. testBox(NULL, -(MB_ICONEXCLAMATION | MB_OK), STR_APPNAME, tmp1, &xferFname[1]);
  134. rcvTerminate();
  135. }
  136. /*---------------------------------------------------------------------------*/
  137. /* rcvFileErr() - [scf] */
  138. /*---------------------------------------------------------------------------*/
  139. VOID rcvFileErr()
  140. {
  141. memcpy(taskState.string, xferFname, *xferFname+2);
  142. TF_ErrProc(STREWRERR, MB_OK | MB_ICONHAND, 999);
  143. rcvTerminate();
  144. }
  145. /*---------------------------------------------------------------------------*/
  146. /* xRcvBFile() - [mbb] */
  147. /*---------------------------------------------------------------------------*/
  148. VOID xRcvBFile()
  149. {
  150. BYTE saveDataBits, saveParity, saveFlowCtrl;
  151. termSendCmd(trmParams.binRXPrefix, strlen(trmParams.binRXPrefix), 0x42 | TRUE); /* mbbx 2.01.19 ... */
  152. saveDataBits = trmParams.dataBits; /* mbbx 2.00: auto adjust settings... */
  153. saveParity = trmParams.parity;
  154. saveFlowCtrl = trmParams.flowControl; /* mbbx 2.00.05: eliminate flowSerial()... */
  155. trmParams.dataBits = ITMDATA8;
  156. trmParams.parity = ITMNOPARITY;
  157. trmParams.flowControl = ITMNOFLOW;
  158. resetSerial(&trmParams, FALSE, FALSE, 0); /* mbbx 2.00.05: auto reset... */
  159. switch(xferBinType)
  160. {
  161. case XFRXMODEM:
  162. XM_RcvFile(0x0800); /* XM_CRC */
  163. break;
  164. case XFRKERMIT:
  165. KER_Receive(FALSE); /* rkhx 2.00 */
  166. break;
  167. }
  168. if((trmParams.dataBits != saveDataBits) || (trmParams.parity != saveParity) || (trmParams.flowControl != saveFlowCtrl))
  169. {
  170. trmParams.dataBits = saveDataBits;
  171. trmParams.parity = saveParity;
  172. trmParams.flowControl = saveFlowCtrl;
  173. resetSerial(&trmParams, FALSE, FALSE, 0); /* slc swat */
  174. }
  175. termSendCmd(trmParams.binRXSuffix, strlen(trmParams.binRXSuffix), 0x42 | TRUE); /* mbbx 2.01.19 ... */
  176. }