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.

248 lines
7.1 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. VOID sndBPre(BYTE *fname, INT actionString)
  13. {
  14. showXferCtrls(IDSTOP | IDFORK | IDSCALE | IDSENDING | IDBERRORS); /* mbbx 2.00: xfer ctrls... */
  15. showRXFname(fname, actionString);
  16. }
  17. /*---------------------------------------------------------------------------*/
  18. /* sndBFileErr() - [scf] */
  19. /*---------------------------------------------------------------------------*/
  20. VOID sndBFileErr(INT ioErrFlag, STRING *fileName)
  21. {
  22. memcpy(taskState.string, fileName, *fileName+2);
  23. TF_ErrProc(ioErrFlag, MB_OK | MB_ICONHAND, 999); /* taskState.error */
  24. }
  25. #ifdef ORGCODE
  26. #else
  27. VOID swapWords(PVOID pVoid)
  28. {
  29. WORD wTmpHigh,wTmpLow;
  30. PWORD pw;
  31. pw = (PWORD)pVoid;
  32. wTmpHigh = *pw;
  33. wTmpLow = *(pw+1);
  34. *pw = wTmpLow;
  35. *(pw+1) = wTmpHigh;
  36. }
  37. #endif
  38. /*---------------------------------------------------------------------------*/
  39. /* getSndBFile() - [scf] */
  40. /*---------------------------------------------------------------------------*/
  41. BOOL getSndBFile(INT actionString)
  42. {
  43. BOOL getSndBFile;
  44. FSReply reply;
  45. INT refNo;
  46. DOSTIME fileDate;
  47. LONG secs;
  48. LONG tmp;
  49. WORD wMode;
  50. BYTE fileExt[FILENAMELEN+1];
  51. OFSTRUCT file;
  52. getSndBFile = FALSE;
  53. *reply.vRefNum = *reply.fName = 0;
  54. wMode = FO_GETFILE | FO_FILEEXIST; /* rjs - added fileexist */
  55. if(xferBinType == XFRYMODEM) /* mbbx 1.01 */
  56. wMode |= FO_BATCHMODE;
  57. else if(xferBinType == XFRKERMIT)
  58. /* jtf 3.17 wMode |= FO_REMOTEFILE */ ;
  59. getFileDocData(FILE_NDX_DATA, reply.vRefNum, reply.fName, fileExt, NULL);
  60. *macFileName = 0;
  61. if(reply.vRefNum[strlen(reply.vRefNum) - 1] != '\\')
  62. strcat(reply.vRefNum, "\\");
  63. if(reply.good = FileOpen(reply.vRefNum, reply.fName, macFileName, fileExt,
  64. NULL, FO_DBSNDFILE, NULL, wMode))
  65. {
  66. useMacFileName = (*macFileName != 0);
  67. }
  68. if(reply.good)
  69. {
  70. setFileDocData(FILE_NDX_DATA, reply.vRefNum, reply.fName, NULL, NULL); /* mbbx 2.00: no forced extents */
  71. strcpy(xferVRefNum+1, reply.vRefNum); /* mbbx 0.62: save the path !!! */
  72. *xferVRefNum = strlen(xferVRefNum+1);
  73. strcpy(xferFname+1, useMacFileName ? macFileName : reply.fName);
  74. *xferFname = strlen(xferFname+1);
  75. xferRefNo = 0;
  76. if(xferBinType != XFRYMODEM) /* mbbx 1.01: ymodem */
  77. {
  78. if((xferBinType == XFRYTERM) && !answerMode) /* mbbx: yterm */
  79. return(FALSE);
  80. #ifdef ORGCODE
  81. strcpy(reply.vRefNum+strlen(reply.vRefNum), reply.fName);
  82. #else
  83. strcpy(reply.vRefNum+strlen(reply.vRefNum), "\\");
  84. strcpy(reply.vRefNum+strlen(reply.vRefNum), reply.fName);
  85. DEBOUT("getSndBFile: opening the file[%s]\n",reply.vRefNum);
  86. DEBOUT("getSndBFile: with flags [%lx]\n",O_RDONLY);
  87. #endif
  88. if((xferRefNo = OpenFile((LPSTR) reply.vRefNum, (LPOFSTRUCT)&file,
  89. OF_READ)) == -1)
  90. {
  91. sndBFileErr(STRFERROPEN, reply.fName);
  92. xferRefNo = 0;
  93. return FALSE;
  94. }
  95. if((xferBytes = fileLength(xferRefNo)) == -1L)
  96. {
  97. sndBFileErr(STRFERROPEN, reply.fName);
  98. if(xferBinType == XFRYTERM) /* mbbx: yterm */
  99. answerMode = FALSE;
  100. _lclose(xferRefNo);
  101. xferRefNo = 0;
  102. return FALSE;
  103. }
  104. xferParams.ioFlLgLen = xferBytes;
  105. swapWords (&xferParams.ioFlLgLen); /* intel tch tch */
  106. xferParams.ioFlRLgLen = 0l;
  107. xferLgLen = xferBytes;
  108. getFileDate (&fileDate, xferRefNo);
  109. secs = 0;
  110. xferParams.ioFlCrDat =
  111. xferParams.ioFlMdDat = secs;
  112. xferParams.fdFlags = 0;
  113. }
  114. else
  115. {
  116. xferBytes = 1L;
  117. }
  118. xferErrors = 0;
  119. xferLength = 0L;
  120. xferOrig = xferBytes;
  121. xferPct = 0;
  122. sndBPre(reply.fName, actionString);
  123. getSndBFile = TRUE;
  124. }
  125. return(getSndBFile);
  126. }
  127. /*---------------------------------------------------------------------------*/
  128. /* sndBFile() - Send a binary file. [scf] */
  129. /*---------------------------------------------------------------------------*/
  130. VOID sndBFile()
  131. {
  132. if(xferFlag != XFRNONE) /* mbbx 1.10: answerMode... */
  133. {
  134. return;
  135. }
  136. xferFast = FALSE;
  137. if(!answerMode)
  138. {
  139. switch(trmParams.xBinType)
  140. {
  141. case ITMXMODEM:
  142. xferBinType = XFRXMODEM;
  143. break;
  144. case ITMKERMIT:
  145. xferBinType = XFRKERMIT;
  146. break;
  147. }
  148. xferBinFork = XFRDATA;
  149. }
  150. if(getSndBFile(STR_SENDING))
  151. xferFlag = XFRBSND;
  152. }
  153. /*---------------------------------------------------------------------------*/
  154. /* sndAbort() - [scf] */
  155. /*---------------------------------------------------------------------------*/
  156. VOID sndAbort ()
  157. {
  158. BYTE tmp1[TMPNSTR+1];
  159. LoadString(hInst, STR_ABORTSND, (LPSTR) tmp1, TMPNSTR);
  160. testMsg(tmp1, &xferFname[1],NULL);
  161. }
  162. /*---------------------------------------------------------------------------*/
  163. /* xSndBFile() - */
  164. /*---------------------------------------------------------------------------*/
  165. VOID xSndBFile()
  166. {
  167. BYTE saveDataBits, saveParity, saveFlowCtrl;
  168. termSendCmd(trmParams.binTXPrefix, strlen(trmParams.binTXPrefix), 0x0042 | TRUE); /* mbbx 2.01.19 ... */
  169. saveDataBits = trmParams.dataBits; /* mbbx 2.00: auto adjust settings... */
  170. saveParity = trmParams.parity;
  171. saveFlowCtrl = trmParams.flowControl; /* mbbx 2.00.05: eliminate flowSerial()... */
  172. if((xferBinType != XFRKERMIT) && (xferBinType != XFRYTERM))
  173. {
  174. trmParams.dataBits = ITMDATA8;
  175. trmParams.parity = ITMNOPARITY;
  176. trmParams.flowControl = ITMNOFLOW;
  177. resetSerial(&trmParams, FALSE, FALSE, 0); /* slc swat */
  178. }
  179. switch(xferBinType)
  180. {
  181. case XFRXMODEM:
  182. XM_SndFile(0x0800); /* XM_CRC */
  183. break;
  184. case XFRKERMIT:
  185. KER_Send(); /* rkhx 2.00 */
  186. break;
  187. }
  188. if((trmParams.dataBits != saveDataBits) || (trmParams.parity != saveParity) || (trmParams.flowControl != saveFlowCtrl))
  189. {
  190. trmParams.dataBits = saveDataBits;
  191. trmParams.parity = saveParity;
  192. trmParams.flowControl = saveFlowCtrl;
  193. resetSerial(&trmParams, FALSE, FALSE, 0); /* slc swat */
  194. }
  195. termSendCmd(trmParams.binTXSuffix, strlen(trmParams.binTXSuffix), 0x0042 | TRUE); /* mbbx 2.01.19 ... */
  196. }