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.

367 lines
12 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. /* sndPre() - */
  14. /*---------------------------------------------------------------------------*/
  15. VOID sndPre(BYTE *fileName, INT actionString)
  16. {
  17. showXferCtrls(IDSTOP | IDPAUSE | IDSCALE | IDSENDING); /* mbbx 2.00: xfer ctrls... */
  18. showRXFname(fileName, actionString);
  19. }
  20. /*---------------------------------------------------------------------------*/
  21. /* sndFileErr() - */
  22. /*---------------------------------------------------------------------------*/
  23. VOID sndFileErr(BYTE *fileName, INT wID)
  24. {
  25. BYTE tmp1[TMPNSTR+1];
  26. LoadString(hInst, wID, tmp1, TMPNSTR);
  27. testMsg("%s %s", tmp1, fileName);
  28. }
  29. /*---------------------------------------------------------------------------*/
  30. /* getSndTFile() - */
  31. /*---------------------------------------------------------------------------*/
  32. INT_PTR APIENTRY FO_SendTextFile(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam) /* mbbx 2.00: new FO hook scheme... */
  33. {
  34. switch(message)
  35. {
  36. case WM_INITDIALOG:
  37. if(xferSndLF != 0)
  38. CheckDlgButton(hDlg, (xferSndLF > 0) ? FO_IDSNDLF : FO_IDSNDNOLF, TRUE);
  39. break;
  40. case WM_COMMAND:
  41. switch(GET_WM_COMMAND_ID(wParam, lParam))
  42. {
  43. case FO_IDSNDLF:
  44. if(xferSndLF == -1)
  45. CheckDlgButton(hDlg, FO_IDSNDNOLF, FALSE);
  46. xferSndLF = ((xferSndLF == 1) ? 0 : 1);
  47. CheckDlgButton(hDlg, FO_IDSNDLF, xferSndLF);
  48. break;
  49. case FO_IDSNDNOLF:
  50. if(xferSndLF == 1)
  51. CheckDlgButton(hDlg, FO_IDSNDLF, FALSE);
  52. xferSndLF = ((xferSndLF == -1) ? 0 : -1);
  53. CheckDlgButton(hDlg, FO_IDSNDNOLF, xferSndLF);
  54. break;
  55. }
  56. break;
  57. }
  58. return FALSE;
  59. }
  60. BOOL getSndTFile(INT actionString)
  61. {
  62. BYTE fileExt[FILENAMELEN+1];
  63. FSReply reply;
  64. BYTE szTitle[MINRESSTR];
  65. OFSTRUCT file;
  66. DEBOUT("getSndTFile: %s\n","Got IN");
  67. getFileDocData(FILE_NDX_MEMO, reply.vRefNum, reply.fName, fileExt, NULL); /* mbbx 1.03 */
  68. if(actionString == STR_VIEWING)
  69. {
  70. xferSndLF = 0; /* mbbx: WAS xferSndLF = TRUE; */
  71. LoadString(hInst, STR_VIEWTEXTFILE, szTitle, MINRESSTR);
  72. }
  73. else
  74. {
  75. xferSndLF = -1; /* jtf 3.22 */
  76. LoadString(hInst, STR_SENDTEXTFILE, szTitle, MINRESSTR);
  77. }
  78. /* mbbx 2.00: new FO hook scheme... */
  79. DEBOUT("getSndTFile: %s\n","Calling FileOpen");
  80. if(reply.vRefNum[strlen(reply.vRefNum) - 1] != '\\')
  81. strcat(reply.vRefNum, "\\");
  82. reply.good = FileOpen(reply.vRefNum, reply.fName, NULL, fileExt, szTitle,
  83. FO_DBSNDTEXT, FO_SendTextFile, FO_FILEEXIST);
  84. if(reply.good)
  85. {
  86. DEBOUT("getSndTFile: %s\n","FileOpen reply was good");
  87. setFileDocData(FILE_NDX_MEMO, reply.vRefNum, reply.fName, fileExt, NULL); /* mbbx 2.00: no forced extents */
  88. strcpy(xferVRefNum+1, reply.vRefNum); /* mbbx 0.62: save the path !!! */
  89. *xferVRefNum = strlen(xferVRefNum+1);
  90. strcpy(xferFname+1, reply.fName);
  91. *xferFname = strlen(xferFname+1);
  92. #ifdef ORGCODE
  93. strcpy(reply.vRefNum+strlen(reply.vRefNum), reply.fName);
  94. #else
  95. strcpy(reply.vRefNum+strlen(reply.vRefNum), "\\");
  96. strcpy(reply.vRefNum+strlen(reply.vRefNum), reply.fName);
  97. DEBOUT("getSndTFile: opening the file[%s]\n",reply.vRefNum);
  98. DEBOUT("getSndTFile: with flags [%lx]\n",O_RDONLY);
  99. #endif
  100. /* jtf 3.20 */
  101. if((xferRefNo = OpenFile(reply.vRefNum, &file,
  102. OF_READ)) == -1)
  103. {
  104. //sndFileErr (STRFERROPEN, reply.fName); BUG:12588 args are swaped!
  105. sndFileErr (reply.fName,STRFERROPEN);
  106. DEBOUT("getSndTFile: %s\n","Got OUT with FAIL(open)");
  107. return FALSE;
  108. }
  109. if ((xferBytes = fileLength (xferRefNo)) == -1l)
  110. {
  111. //sndFileErr (STRFERRFILELENGTH, reply.fName); BUG:12588 args are swapped!
  112. sndFileErr (reply.fName,STRFERRFILELENGTH);
  113. DEBOUT("getSndTFile: %s\n","Got OUT with FAIL(filelength)");
  114. return FALSE;
  115. }
  116. DEBOUT("getSndTFile: size of file put in xferBytes=%lx\n",xferBytes);
  117. xferOrig = xferBytes;
  118. xferPct = 0;
  119. sndPre(reply.fName, actionString);
  120. DEBOUT("getSndTFile: %s\n","Got OUT with success");
  121. return TRUE;
  122. }
  123. DEBOUT("getSndTFile: %s\n","Got OUT with FAIL(!reply.good)");
  124. return(FALSE);
  125. }
  126. /*---------------------------------------------------------------------------*/
  127. /* sndTfile() - */
  128. /*---------------------------------------------------------------------------*/
  129. VOID sndTFile ()
  130. {
  131. xferFlag = XFRNONE;
  132. xferPaused = FALSE;
  133. xferTxtType = (TTXTTYPE) (trmParams.xTxtType - ITMSTD);
  134. xferChrType = (TCHRTYPE) (trmParams.xChrType - ITMCHRDELAY);
  135. xferLinType = (TLINTYPE) (trmParams.xLinType - ITMLINDELAY);
  136. xferChrDelay = trmParams.xChrDelay;
  137. xferLinDelay = trmParams.xLinDelay;
  138. strcpy(xferLinStr+1, trmParams.xLinStr);
  139. xferLinStr[0] = strlen(trmParams.xLinStr);
  140. stripControl(xferLinStr);
  141. if(getSndTFile(STR_SENDING))
  142. {
  143. xferFlag = XFRSND;
  144. *outBuf = 0; /* (mbbx) clear out residuals */
  145. if(trmParams.xWordWrap)
  146. {
  147. outBufCol = 0;
  148. outBufSeq = FALSE;
  149. xferBlkSize = 1; /* (xmbb) */
  150. }
  151. }
  152. }
  153. /*---------------------------------------------------------------------------*/
  154. /* typTFile() - */
  155. /*---------------------------------------------------------------------------*/
  156. VOID typTFile()
  157. {
  158. xferFlag = XFRNONE;
  159. xferPaused = FALSE;
  160. xferStopped = FALSE;
  161. if(getSndTFile(STR_VIEWING))
  162. {
  163. xferFlag = XFRTYP;
  164. *outBuf = 0; /* (mbbx) */
  165. if(trmParams.xWordWrap && (xferSndLF >= 0)) /* mbb?: wth??? */
  166. {
  167. outBufCol = 0;
  168. outBufSeq = FALSE;
  169. }
  170. }
  171. }
  172. /*---------------------------------------------------------------------------*/
  173. /* rcvErr() - */
  174. /*---------------------------------------------------------------------------*/
  175. VOID rcvErr(BYTE *fileName)
  176. {
  177. strcpy(taskState.string+1, fileName);
  178. *taskState.string = strlen(fileName);
  179. TF_ErrProc(STREWRERR, MB_OK | MB_ICONHAND, 999);
  180. }
  181. /*---------------------------------------------------------------------------*/
  182. /* rcvPutFile() - */
  183. /*---------------------------------------------------------------------------*/
  184. INT_PTR APIENTRY FO_RcvTextFile(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam) /* mbbx 2.00: new FO hook scheme... */
  185. //HWND hDlg;
  186. //WORD message;
  187. //WPARAM wParam;
  188. //LONG lParam;
  189. {
  190. switch(message)
  191. {
  192. case WM_INITDIALOG:
  193. xferAppend = FALSE;
  194. CheckDlgButton(hDlg, FO_IDCTRL, xferSaveCtlChr);
  195. CheckDlgButton(hDlg, FO_IDTABLE, xferTableSave);
  196. break;
  197. case WM_COMMAND:
  198. switch(GET_WM_COMMAND_ID(wParam, lParam))
  199. {
  200. case FO_IDAPPEND:
  201. if(xferAppend = !xferAppend)
  202. pFOData->wMode |= FO_FILEEXIST;
  203. else
  204. pFOData->wMode &= ~FO_FILEEXIST;
  205. CheckDlgButton(hDlg, FO_IDAPPEND, xferAppend);
  206. break;
  207. case FO_IDCTRL:
  208. CheckDlgButton(hDlg, FO_IDCTRL, xferSaveCtlChr = !xferSaveCtlChr);
  209. break;
  210. case FO_IDTABLE:
  211. CheckDlgButton(hDlg, FO_IDTABLE, xferTableSave = !xferTableSave);
  212. break;
  213. }
  214. break;
  215. }
  216. return FALSE;
  217. }
  218. VOID rcvPutFile(FSReply *reply, BYTE *fileExt)
  219. {
  220. *reply->fName = 0; /* mbbx 2.00: CUA */
  221. /* mbbx 2.00: new FO hook scheme... */
  222. if(reply->vRefNum[strlen(reply->vRefNum) - 1] != '\\')
  223. strcat(reply->vRefNum, "\\");
  224. reply->good = FileOpen(reply->vRefNum, reply->fName, NULL, fileExt, NULL,
  225. FO_DBRCVTEXT, FO_RcvTextFile, FO_PUTFILE);
  226. }
  227. /*---------------------------------------------------------------------------*/
  228. /* rcvPre() - Show transfer control & set up for receiving text.[scf] */
  229. /*---------------------------------------------------------------------------*/
  230. VOID rcvPre(BYTE *fileName, INT actionString)
  231. {
  232. xferFlag = XFRRCV;
  233. xferBytes = -1; /* Special flag to enable stop */
  234. xferPaused = FALSE; /* button */
  235. xferLength = 0L; /* mbbx 2.00: mac */
  236. tblPos = TBLBEGINLINE;
  237. showXferCtrls(IDSTOP | IDPAUSE | IDSENDING); /* mbbx 2.00: xfer ctrls... */
  238. showRXFname(fileName, actionString);
  239. }
  240. /*---------------------------------------------------------------------------*/
  241. /* rcvTFile() - */
  242. /*---------------------------------------------------------------------------*/
  243. VOID rcvTFile()
  244. {
  245. FSReply reply;
  246. BYTE fileExt[FILENAMELEN+1];
  247. OFSTRUCT file;
  248. BYTE OEMname[STR255]; /* jtf 3.20 */
  249. getFileDocData(FILE_NDX_MEMO, reply.vRefNum, NULL, fileExt, NULL); /* mbbx 1.03 */
  250. xferSaveCtlChr = FALSE;
  251. xferTableSave = FALSE;
  252. rcvPutFile(&reply, fileExt);
  253. if(reply.good)
  254. {
  255. setFileDocData(FILE_NDX_MEMO, reply.vRefNum, reply.fName, fileExt, NULL); /* mbbx 2.00: no forced extents */
  256. strcpy(xferVRefNum+1, reply.vRefNum); /* mbbx 0.62: save the path !!! */
  257. *xferVRefNum = strlen(xferVRefNum+1);
  258. strcpy(xferFname+1, reply.fName);
  259. *xferFname = strlen(xferFname+1);
  260. #ifdef ORGCODE
  261. strcpy(reply.vRefNum+strlen(reply.vRefNum), reply.fName);
  262. #else
  263. strcpy(reply.vRefNum+strlen(reply.vRefNum), "\\");
  264. strcpy(reply.vRefNum+strlen(reply.vRefNum), reply.fName);
  265. #endif
  266. // JYF -- replace below two lines with the following if ()
  267. // to remove the use of AnsiToOem()
  268. //
  269. //AnsiToOem(reply.vRefNum, OEMname); /* jtf 3.20 */
  270. //if(xferAppend && fileExist(OEMname))
  271. if (xferAppend && fileExist((LPSTR)reply.vRefNum))
  272. {
  273. /* jtf 3.20 */
  274. DEBOUT("rcvTFile: doing open(%s)\n",reply.vRefNum);
  275. DEBOUT("rcvTFile: with flag [%lx]\n",O_WRONLY);
  276. if((xferRefNo = OpenFile(reply.vRefNum,
  277. &file,
  278. OF_WRITE | OF_CANCEL)) == -1)
  279. {
  280. rcvErr(reply.fName);
  281. return;
  282. }
  283. _lseek(xferRefNo, 0L, 2);
  284. }
  285. else
  286. {
  287. /* jtf 3.20 */
  288. DEBOUT("rcvTFile: doing open(%s)\n",reply.vRefNum);
  289. DEBOUT("rcvTFile: with flag [%lx]\n",O_WRONLY|O_CREAT|O_TRUNC|S_IWRITE);
  290. if((xferRefNo = OpenFile(reply.vRefNum,
  291. &file,
  292. OF_WRITE | OF_CREATE)) == -1)
  293. {
  294. rcvErr(reply.fName);
  295. return;
  296. }
  297. }
  298. xferBufferCount = 0; /* rjs bugs 016 */
  299. xferBufferHandle = GlobalAlloc(GMEM_MOVEABLE, (DWORD) 1024); /* rjs bugs 016 */
  300. rcvPre(reply.fName, STR_RECEIVING);
  301. }
  302. }