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.

797 lines
25 KiB

  1. /*===========================================================================*/
  2. /* Copyright (c) 1987 - 1988, Future Soft Engineering, Inc. */
  3. /* Houston, Texas */
  4. /*===========================================================================*/
  5. #define NOGDICAPMASKS TRUE
  6. #define NOVIRTUALKEYCODES TRUE
  7. #define NOICONS TRUE
  8. #define NOKEYSTATES TRUE
  9. #define NOSYSCOMMANDS TRUE
  10. #define NOATOM TRUE
  11. #define NOCLIPBOARD TRUE
  12. #define NODRAWTEXT TRUE
  13. #define NOMINMAX TRUE
  14. #define NOSCROLL TRUE
  15. #define NOHELP TRUE
  16. #define NOPROFILER TRUE
  17. #define NODEFERWINDOWPOS TRUE
  18. #define NOPEN TRUE
  19. #define NO_TASK_DEFINES TRUE
  20. #define NOLSTRING TRUE
  21. #define WIN31
  22. #define USECOMM
  23. #include <windows.h>
  24. #include "port1632.h"
  25. #include "dcrc.h"
  26. #include "dynacomm.h"
  27. #include "fileopen.h"
  28. #include "task.h"
  29. /*---------------------------------------------------------------------------*/
  30. #define DCS_OLD_FKEYLEVELS 4
  31. #define DCS_OLD_NUMFKEYS 8
  32. #define DCS_OLD_FKEYLEN 64
  33. #define DCS_OLD_FKEYTITLESZ 20
  34. #define DCS_OLD_XTRALEN 44
  35. #define DCS_OLD_MDMCMDLEN 32
  36. #define DCS_OLD_MISCSTRLEN 21
  37. #define TITLEREC struct tagTITLEREC
  38. struct tagTITLEREC
  39. {
  40. BYTE title[DCS_OLD_FKEYTITLESZ];
  41. BYTE xtra[DCS_OLD_XTRALEN];
  42. };
  43. #define oldTrmParams struct tagOldTrmParams
  44. #define LPOLDSETTINGS oldTrmParams FAR *
  45. struct tagOldTrmParams
  46. {
  47. INT inpRefNum;
  48. INT outRefNum;
  49. INT emulate;
  50. INT dataBits;
  51. INT parity;
  52. INT speed;
  53. INT stopBits;
  54. BYTE col80Or132;
  55. BYTE flowControl;
  56. BOOL localEcho;
  57. BOOL lineWrap;
  58. BOOL inpCRLF;
  59. BOOL outCRLF;
  60. BOOL inpLFCR;
  61. BOOL fCtrlBits;
  62. STRING fKeyText[DCS_OLD_FKEYLEVELS][DCS_OLD_NUMFKEYS][DCS_OLD_FKEYLEN];
  63. TITLEREC fKeyTitle[DCS_OLD_FKEYLEVELS][DCS_OLD_NUMFKEYS];
  64. STRING phone[DCS_OLD_MDMCMDLEN];
  65. STRING binTXPrefix[DCS_OLD_MDMCMDLEN];
  66. STRING dialPrefix[DCS_OLD_MDMCMDLEN];
  67. STRING binTXSuffix[DCS_OLD_MDMCMDLEN];
  68. STRING dialSuffix[DCS_OLD_MDMCMDLEN];
  69. STRING binRXPrefix[DCS_OLD_MDMCMDLEN];
  70. STRING hangPrefix[DCS_OLD_MDMCMDLEN];
  71. STRING binRXSuffix[DCS_OLD_MDMCMDLEN];
  72. STRING hangSuffix[DCS_OLD_MDMCMDLEN];
  73. STRING fastInq[DCS_OLD_MDMCMDLEN];
  74. STRING originate[DCS_OLD_MDMCMDLEN];
  75. STRING fastRsp[DCS_OLD_MDMCMDLEN];
  76. STRING answer[DCS_OLD_MDMCMDLEN];
  77. STRING strXtra8[DCS_OLD_MDMCMDLEN];
  78. BOOL flgRetry;
  79. BYTE padding2;
  80. INT dlyRetry;
  81. INT cntRetry;
  82. BOOL flgSignal;
  83. BYTE version;
  84. BOOL carrierFlag;
  85. BYTE padding3;
  86. STRING xLinStr[DCS_OLD_MISCSTRLEN+1];
  87. STRING mdmConnect[DCS_OLD_MISCSTRLEN+1];
  88. STRING strXtra2[DCS_OLD_MISCSTRLEN+1];
  89. STRING strXtra3[DCS_OLD_MISCSTRLEN+1];
  90. STRING strXtra4[DCS_OLD_MISCSTRLEN+1];
  91. INT rcvBlSz;
  92. INT sendBlSz;
  93. INT retryCt;
  94. BYTE remote;
  95. BYTE padding9;
  96. INT xtraInt[4];
  97. INT xWrapCol;
  98. BYTE termCursor;
  99. BOOL cursorBlink;
  100. BOOL bsKey;
  101. BYTE language;
  102. STRING autoExecute[DCS_OLD_FKEYLEN];
  103. BYTE xTxtType;
  104. BYTE xChrType;
  105. INT xChrDelay;
  106. BYTE xLinType;
  107. BYTE padding10;
  108. INT xLinDelay;
  109. BYTE xMdmType;
  110. BOOL xWordWrap;
  111. BYTE xBinType;
  112. BYTE xBinFork;
  113. };
  114. /*---------------------------------------------------------------------------*/
  115. #define MSSETTINGS struct tagMSSETTINGS
  116. #define LPMSSETTINGS MSSETTINGS FAR *
  117. struct tagMSSETTINGS
  118. {
  119. INT iCRC; /* The CRC checksum for the settings */
  120. INT iVersion; /* The version number */
  121. BOOL fModem; /* True if port is connected to a modem */
  122. BOOL fNewLine; /* True if new-line button is on */
  123. BOOL fLocalEcho; /* True if local-echo button is on */
  124. BOOL fAutoWrap; /* True if auto-wrap button is on */
  125. BOOL fVT52; /* True if term is VT52, false if ANSI */
  126. BOOL fLarge; /* True for large text size */
  127. BOOL fTone; /* True if dial type is tone */
  128. BOOL fFast; /* True if dial pulses are short */
  129. INT clnBuf; /* Count of lines in buffer */
  130. INT iBaud; /* The baud rate */
  131. INT iPort; /* The port number */
  132. INT iByteSize; /* The number of bits per char */
  133. INT iStopBits; /* The number of stop bits */
  134. INT iParity; /* The parity method */
  135. INT iHandshake; /* The handshake method */
  136. INT iAnswer; /* The number of seconds to wait for answer */
  137. INT iToneWait; /* Number of seconds to wait for tone */
  138. CHAR szPhNum[30]; /* The phone number */
  139. CHAR szFNCapture[128]; /* The capture file name */
  140. INT iCountry; /* The character translation country code */
  141. };
  142. /*---------------------------------------------------------------------------*/
  143. BOOL termInitSetup(HANDLE); /* ==> termfile.h */
  144. VOID termCloseEnable(BOOL);
  145. BOOL termCloseFile(VOID);
  146. BOOL termCloseAll(VOID);
  147. BOOL termSaveFile(BOOL);
  148. BOOL NEAR termReadFile(BYTE *);
  149. VOID NEAR termCloseWindow(VOID);
  150. BOOL NEAR termCloseFileInternal(VOID);
  151. INT TF_ErrProc(WORD, WORD, WORD);
  152. BOOL NEAR readTermSettings(INT, WORD); /* mbbx 2.00: was LONG */
  153. VOID NEAR convertMSToIBM(LPMSSETTINGS, recTrmParams *);
  154. BOOL NEAR writeTermSettings(INT);
  155. VOID NEAR convertInternalToVirtual(LPSETTINGS, LPSETTINGS); /* rkhx 2.00 */
  156. /*---------------------------------------------------------------------------*/
  157. /* termInitSetup() - [mbb] */
  158. /*---------------------------------------------------------------------------*/
  159. BOOL termInitSetup(HANDLE hPrevInstance)
  160. {
  161. // sdj: was unref local- WNDCLASS termClass;
  162. activTerm = FALSE;
  163. strcpy(termData.filePath, fileDocData[FILE_NDX_SETTINGS].filePath);
  164. *termData.fileName = 0;
  165. strcpy(termData.fileExt, fileDocData[FILE_NDX_SETTINGS].fileExt);
  166. LoadString(hInst, STR_TERMINAL, (LPSTR) termData.title, MINRESSTR);
  167. termData.flags = TF_DEFTITLE;
  168. resetEmul(); /* must have init settings! */
  169. return(TRUE);
  170. }
  171. /*---------------------------------------------------------------------------*/
  172. /* termFile() - [mbb] */
  173. /*---------------------------------------------------------------------------*/
  174. BOOL termFile(BYTE *filePath, BYTE *fileName,BYTE *fileExt,BYTE *title,WORD flags)
  175. {
  176. BYTE work[PATHLEN];
  177. RECT termRect;
  178. BYTE OEMname[STR255]; /* jtf 3.20 */
  179. if(strlen(fileName) > 0) /* mbbx 1.03 ... */
  180. {
  181. #ifdef ORGCODE
  182. strcpy(work, filePath); /* mbbx 2.00: no forced extents... */
  183. strcpy(work+strlen(work), fileName); /* jtf 3.20 */
  184. #else
  185. strcpy(work, filePath); /* mbbx 2.00: no forced extents... */
  186. strcpy(work+strlen(work), "\\"); /* jtf 3.20 */
  187. strcpy(work+strlen(work), fileName); /* jtf 3.20 */
  188. #endif
  189. // JYF -- replace below two lines with following if()
  190. // to remove the use of AnsiToOem()
  191. //
  192. //AnsiToOem((LPSTR) work, (LPSTR) OEMname); /* jtf 3.20 */
  193. //if(!fileExist(OEMname))
  194. if (!fileExist(work))
  195. return(FALSE);
  196. }
  197. if(termCloseFileInternal())
  198. {
  199. if((flags & TF_DEFTITLE) && (strlen(fileName) > 0))
  200. strcpy(termData.title, fileName);
  201. else
  202. strcpy(termData.title, title);
  203. SetWindowText(hTermWnd, (LPSTR) termData.title);
  204. setAppTitle();
  205. SetCursor(LoadCursor(NULL, IDC_WAIT));
  206. strcpy(termData.filePath, filePath);
  207. strcpy(termData.fileName, fileName);
  208. strcpy(termData.fileExt, fileExt);
  209. termData.flags = flags | (termData.flags & (TF_DIM | TF_HIDE));
  210. setDefaults(); /* mbbx 2.00: do this first! */
  211. if(strlen(fileName) > 0)
  212. {
  213. if(!termReadFile(work))
  214. doFileNew(); /* jtf 3.31 */
  215. }
  216. activTerm = TRUE;
  217. setFKeyLevel(1, TRUE); /* mbbx 2.00 ... */
  218. showHidedbmyControls(trmParams.environmentFlags & DCS_EVF_FKEYSSHOW, TRUE); /* jtf 3.20 */
  219. resetSerial(&trmParams, TRUE, FALSE, 0);
  220. resetEmul();
  221. initChildSize(&termRect); /* mbbx 2.00: reset window pos... */
  222. if(IsZoomed(hTermWnd))
  223. SetFocus(NULL);
  224. if(!(termData.flags & TF_HIDE))
  225. showTerminal(TRUE, TRUE);
  226. SetCursor(LoadCursor(NULL, IDC_ARROW));
  227. }
  228. gotCommEvent = TRUE;
  229. return(TRUE);
  230. }
  231. /*---------------------------------------------------------------------------*/
  232. /* termCloseFile() - [mbb] */
  233. /*---------------------------------------------------------------------------*/
  234. BOOL termCloseFile(VOID)
  235. {
  236. BOOL termCloseFile = TRUE;
  237. if(activTerm)
  238. {
  239. if(termCloseFile = termCloseFileInternal())
  240. termCloseWindow();
  241. }
  242. return(termCloseFile);
  243. }
  244. /*---------------------------------------------------------------------------*/
  245. /* termCloseAll() - [mbb] */
  246. /*---------------------------------------------------------------------------*/
  247. BOOL termCloseAll(VOID)
  248. {
  249. return(termCloseFile());
  250. }
  251. /*---------------------------------------------------------------------------*/
  252. /* termSaveFile() - [mbb] */
  253. /*---------------------------------------------------------------------------*/
  254. BOOL termSaveFile(BOOL bGetName)
  255. {
  256. BOOL termSaveFile = TRUE;
  257. BYTE titleText[MINRESSTR];
  258. BYTE filePath[PATHLEN+1];
  259. INT hFile;
  260. // sdj: was unref local - OFSTRUCT ofDummy;
  261. BYTE fileName[PATHLEN];
  262. SetCursor(LoadCursor(NULL, IDC_WAIT));
  263. if(activTerm)
  264. {
  265. if(bGetName || (strlen(termData.fileName) == 0))
  266. {
  267. /* rjs swat - default to *.trm if no default term name */
  268. if(strlen(termData.fileName))
  269. strcpy(fileName, termData.fileName);
  270. else
  271. strcpy(fileName, "*.TRM");
  272. /* end rjs swat */
  273. /* mbbx 1.10: CUA... */
  274. LoadString(hInst, !bGetName ? STR_SAVE : STR_SAVEAS, (LPSTR) titleText, MINRESSTR);
  275. if(termData.filePath[strlen(termData.filePath) - 1] != '\\')
  276. strcat(termData.filePath, "\\");
  277. termSaveFile = FileOpen(termData.filePath, fileName, NULL, termData.fileExt,
  278. titleText, 0, NULL, FO_PUTFILE | FO_FORCEEXTENT);
  279. if(strrchr(fileName, '\\'))
  280. strcpy(termData.fileName, strrchr(fileName, '\\') + 1);
  281. else
  282. strcpy(termData.fileName, fileName);
  283. }
  284. if(termSaveFile)
  285. {
  286. setFileDocData(FILE_NDX_SETTINGS, termData.filePath, termData.fileName, NULL, NULL); /* mbbx 2.00: no forced extents... */
  287. if(termData.flags & TF_DEFTITLE)
  288. {
  289. strcpy(termData.title, termData.fileName);
  290. SetWindowText(hTermWnd, (LPSTR) termData.fileName);
  291. setAppTitle(); /* mbbx 1.00 */
  292. }
  293. #ifdef ORGCODE
  294. strcpy(filePath, termData.filePath);
  295. strcpy(filePath+strlen(filePath), termData.fileName);
  296. #else
  297. /* jtf 3.20 */
  298. strcpy(filePath, termData.filePath);
  299. strcpy(filePath+strlen(filePath), "\\");
  300. strcpy(filePath+strlen(filePath), termData.fileName);
  301. DEBOUT("termSaveFile: opening the file[%s]\n",filePath);
  302. DEBOUT("termSaveFile: with flags [%lx]\n",O_WRONLY|O_TRUNC|O_CREAT|S_IWRITE);
  303. #endif
  304. if((hFile = _open((LPSTR) filePath, O_WRONLY | O_TRUNC | O_CREAT, S_IWRITE)) != -1)
  305. {
  306. if(termSaveFile = writeTermSettings(hFile))
  307. termData.flags &= ~TF_CHANGED;
  308. _close(hFile);
  309. }
  310. else
  311. termSaveFile = FALSE;
  312. if(!termSaveFile)
  313. {
  314. TF_ErrProc(STREWRERR, MB_OK | MB_ICONHAND, 999);
  315. strcpy(termData.fileName, ""); /* rjs swat */
  316. }
  317. }
  318. else
  319. strcpy(termData.fileName, ""); /* rjs swat */
  320. }
  321. SetCursor(LoadCursor(NULL, IDC_ARROW));
  322. return(termSaveFile);
  323. }
  324. /*---------------------------------------------------------------------------*/
  325. /* termReadFile() - [mbb] */
  326. /*---------------------------------------------------------------------------*/
  327. BOOL NEAR termReadFile(BYTE *filePath)
  328. {
  329. BOOL termReadFile = FALSE;
  330. INT hFile;
  331. // sdj: was unref local - OFSTRUCT ofDummy;
  332. // sdj: was unref local - LOGFONT logFont;
  333. BYTE *junk;
  334. /* jtf 3.20 */
  335. DEBOUT("termReadFile: opening the file[%s]\n",filePath);
  336. DEBOUT("termReadFile: with flags [%lx]\n",O_RDONLY);
  337. junk = strrchr(filePath, '.');
  338. AnsiUpper((LPSTR)junk);
  339. if((hFile = _open((LPSTR) filePath, O_RDONLY)) != -1)
  340. {
  341. if(termReadFile = readTermSettings(hFile, _filelength(hFile)))
  342. {
  343. resetTermBuffer(); /* mbbx 1.03 */
  344. icsResetTable((WORD) trmParams.language); /* mbbx 1.04: ics */
  345. buildTermFont(); /* mbbx 2.00: font selection... */
  346. trmParams.fResetDevice = TRUE; /* mbbx 2.00: network... */
  347. trmParams.newDevRef = trmParams.comDevRef;
  348. trmParams.comDevRef = ITMNOCOM;
  349. }
  350. _close(hFile);
  351. }
  352. else
  353. TF_ErrProc(STRFERROPEN, MB_OK | MB_ICONHAND, 999);
  354. return(termReadFile);
  355. }
  356. /*---------------------------------------------------------------------------*/
  357. /* termCloseWindow() - [mbb] */
  358. /*---------------------------------------------------------------------------*/
  359. VOID NEAR termCloseWindow(VOID)
  360. {
  361. if(IsWindowVisible(hTermWnd))
  362. {
  363. if(childZoomStatus(0x0001, 0) && (countChildWindows(FALSE) == 1))
  364. {
  365. childZoomStatus(0, 0x4000);
  366. ShowWindow(hTermWnd, SW_RESTORE);
  367. }
  368. /* added typecast to param 2 as HWND -sdj*/
  369. SetWindowPos(hTermWnd,(HWND) 1, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW);
  370. selectTopWindow(); /* mbbx 1.03 ... */
  371. }
  372. }
  373. /*---------------------------------------------------------------------------*/
  374. /* termCloseFileInternal() - [mbb] */
  375. /*---------------------------------------------------------------------------*/
  376. BOOL NEAR termCloseFileInternal(VOID)
  377. {
  378. BOOL termCloseFileInternal = TRUE;
  379. if(activTerm)
  380. {
  381. if(termData.flags & TF_NOCLOSE) /* mbbx 1.01 */
  382. {
  383. termCloseFileInternal = FALSE;
  384. }
  385. else if(xferFlag != XFRNONE)
  386. {
  387. if(termCloseFileInternal = (TF_ErrProc(STR_STOPXFER, MB_YESNO | MB_ICONEXCLAMATION, 0) == IDYES))
  388. {
  389. xferBytes = 0;
  390. xferEndTimer = 0;
  391. xferWaitEcho = FALSE;
  392. xferStopped = TRUE;
  393. xferEnd();
  394. }
  395. }
  396. if(termCloseFileInternal)
  397. {
  398. if(termData.flags & TF_CHANGED)
  399. {
  400. switch(TF_ErrProc(STR_SAVECHANGES, MB_YESNOCANCEL | MB_ICONEXCLAMATION, 0))
  401. {
  402. case IDYES:
  403. termCloseFileInternal = termSaveFile(FALSE); /* mbbx 2.00 */
  404. break;
  405. case IDCANCEL:
  406. termCloseFileInternal = FALSE;
  407. break;
  408. }
  409. }
  410. if(termCloseFileInternal)
  411. {
  412. exitSerial();
  413. activTerm = FALSE;
  414. }
  415. }
  416. }
  417. return(termCloseFileInternal);
  418. }
  419. /*---------------------------------------------------------------------------*/
  420. /* TF_ErrProc() - */
  421. /*---------------------------------------------------------------------------*/
  422. INT TF_ErrProc(WORD errMess, WORD errType,WORD errCode)
  423. {
  424. // sdj: was unref local - INT result;
  425. //BYTE temp1[PATHLEN]; /* rjs bugs 008 -> from 80 to 255 sdj:see below..*/
  426. BYTE temp1[256]; /* sdj: rjs just said it should be 255 but left it 80!*/
  427. /* sdj: with PATHLEN as 80, LoadString was corrupting the */
  428. /* sdj: stack with a err popup of invalid rcbfile */
  429. BYTE temp2[80];
  430. GetWindowText(hItWnd, (LPSTR) temp2, 80);
  431. if(!strchr(temp2, '-'))
  432. {
  433. sprintf(temp1, " - %s", termData.title);
  434. strcpy(temp2+strlen(temp2), temp1);
  435. }
  436. /* NOTE: some messages use taskState.result to pass fileName to error handler... */
  437. LoadString(hInst, errMess, (LPSTR) temp1, 255); /* rjs bugs 008 -> from 80 to 255 */
  438. MessageBeep(0);
  439. /* jtf 3.20 this was GetFocus() changed to GetActiveWindow() to stop rip */
  440. return(MessageBox(GetActiveWindow(), (LPSTR) temp1, (LPSTR) temp2, errType));
  441. }
  442. /*---------------------------------------------------------------------------*/
  443. /* */
  444. /* SETTINGS FILE I/O ROUTINES */
  445. /* */
  446. /*---------------------------------------------------------------------------*/
  447. /*---------------------------------------------------------------------------*/
  448. /* readTermSettings() - [mbb] */
  449. /*---------------------------------------------------------------------------*/
  450. BOOL NEAR readTermSettings(INT hFile, WORD fileSize) /* mbbx 2.00: support NEW & OLD DCS and MS settings... */
  451. //INT hFile;
  452. //WORD fileSize; /* mbbx 2.00: was LONG */
  453. {
  454. BOOL readTermSettings = FALSE;
  455. HANDLE hData;
  456. LPSTR lpData;
  457. BOOL flag; /* jtf 3.31 */
  458. flag = TRUE; /* jtf 3.31 */
  459. if((hData = GlobalAlloc(GMEM_MOVEABLE, (DWORD) fileSize)) != NULL)
  460. {
  461. if((lpData = GlobalLock(hData)) != NULL)
  462. {
  463. /******** this was to debug the 4K trm file/struct compact bug
  464. now we can avoid this noise on the debug machine, so
  465. that we get the satisfaction of resolving one more bug(5399)!
  466. DbgPrint("sizeof (recTrm) = %lx\n",sizeof(trmParams));
  467. DbgPrint("Address of trmParams.fileID = %lx\n",&(trmParams.fileID));
  468. DbgPrint("Address of trmParams.newDevRef = %lx\n",&(trmParams.newDevRef));
  469. DbgPrint("Address of trmParams.speed = %lx\n",&(trmParams.speed));
  470. DbgPrint("Address of trmParams.answerBack = %lx\n",&(trmParams.answerBack));
  471. DbgPrint("Address of trmParams.bufferLines= %lx\n",&(trmParams.bufferLines));
  472. DbgPrint("Address of trmParams.retryCt = %lx\n",&(trmParams.retryCt));
  473. DbgPrint("Address of trmParams.xWrapCol = %lx\n",&(trmParams.xWrapCol));
  474. DbgPrint("Address of trmParams.xLinStr = %lx\n",&(trmParams.xLinStr));
  475. DbgPrint("Address of trmParams.phone = %lx\n",&(trmParams.phone));
  476. DbgPrint("Address of trmParams.dialSuffix = %lx\n",&(trmParams.dialSuffix));
  477. **************/
  478. if(_read(hFile, lpData, fileSize) == fileSize)
  479. {
  480. readTermSettings = TRUE; /* mbbx 2.00: read OLD DCS... */
  481. switch(fileSize)
  482. {
  483. case sizeof(recTrmParams):
  484. lmovmem(lpData, (LPBYTE) &trmParams, fileSize);
  485. break;
  486. case sizeof(MSSETTINGS):
  487. convertMSToIBM((LPMSSETTINGS) lpData, &trmParams);
  488. break;
  489. default:
  490. TF_ErrProc(STRFERRFILELENGTH, MB_OK | MB_ICONHAND, 999);
  491. flag = FALSE; /* jtf 3.31 */
  492. readTermSettings = FALSE;
  493. break;
  494. }
  495. }
  496. GlobalUnlock(hData);
  497. }
  498. GlobalFree(hData);
  499. }
  500. if ((!readTermSettings) && (flag))
  501. TF_ErrProc(STRFERRREAD, MB_OK | MB_ICONHAND, 999);
  502. return(readTermSettings);
  503. }
  504. /*---------------------------------------------------------------------------*/
  505. /* convertMSToIBM() - [mbb] */
  506. /*---------------------------------------------------------------------------*/
  507. #define MS_HSSOFTWARE 0
  508. #define MS_HSHARDWARE 1
  509. #define MS_HSNONE 2
  510. #define MS_IDS_NONE 0
  511. #define MS_IDS_BRITISH 1
  512. #define MS_IDS_DANISH 2
  513. #define MS_IDS_FINNISH 3
  514. #define MS_IDS_FRENCH 4
  515. #define MS_IDS_CANADIAN 5
  516. #define MS_IDS_GERMAN 6
  517. #define MS_IDS_ITALIAN 7
  518. #define MS_IDS_SPANISH 8
  519. #define MS_IDS_SWEDISH 9
  520. #define MS_IDS_SWISS 10
  521. VOID NEAR convertMSToIBM(LPMSSETTINGS lpMSSettings, recTrmParams *ptrTrmParams)
  522. {
  523. ptrTrmParams->outCRLF = (BYTE) lpMSSettings->fNewLine;
  524. ptrTrmParams->localEcho = (BYTE) lpMSSettings->fLocalEcho;
  525. ptrTrmParams->lineWrap = (BYTE) lpMSSettings->fAutoWrap;
  526. ptrTrmParams->bufferLines = lpMSSettings->clnBuf; /* jtf term */
  527. ptrTrmParams->emulate = lpMSSettings->fVT52 ? ITMVT52 : ITMVT100;
  528. ptrTrmParams->speed = lpMSSettings->iBaud; /* jtf term */
  529. switch(lpMSSettings->iPort) /* mbbx 2.00: network... */
  530. {
  531. case 0: /* jtf term */
  532. case 1:
  533. ptrTrmParams->comDevRef = ITMWINCOM;
  534. ptrTrmParams->comPortRef = ITMCOM1 + (lpMSSettings->iPort); /* jtf term */
  535. break;
  536. default:
  537. ptrTrmParams->comDevRef = ITMNOCOM;
  538. break;
  539. }
  540. switch(lpMSSettings->iByteSize)
  541. {
  542. case 4:
  543. ptrTrmParams->dataBits = ITMDATA4;
  544. break;
  545. case 5:
  546. ptrTrmParams->dataBits = ITMDATA5;
  547. break;
  548. case 6:
  549. ptrTrmParams->dataBits = ITMDATA6;
  550. break;
  551. case 7:
  552. ptrTrmParams->dataBits = ITMDATA7;
  553. break;
  554. default:
  555. ptrTrmParams->dataBits = ITMDATA8;
  556. break;
  557. }
  558. switch(lpMSSettings->iStopBits)
  559. {
  560. case ONE5STOPBITS:
  561. ptrTrmParams->stopBits = ITMSTOP5;
  562. break;
  563. case TWOSTOPBITS:
  564. ptrTrmParams->stopBits = ITMSTOP2;
  565. break;
  566. default:
  567. ptrTrmParams->stopBits = ITMSTOP1;
  568. break;
  569. }
  570. switch(lpMSSettings->iParity)
  571. {
  572. case EVENPARITY:
  573. ptrTrmParams->parity = ITMEVENPARITY;
  574. break;
  575. case ODDPARITY:
  576. ptrTrmParams->parity = ITMODDPARITY;
  577. break;
  578. case MARKPARITY:
  579. ptrTrmParams->parity = ITMMARKPARITY;
  580. break;
  581. case SPACEPARITY:
  582. ptrTrmParams->parity = ITMSPACEPARITY;
  583. break;
  584. default:
  585. ptrTrmParams->parity = ITMNOPARITY;
  586. break;
  587. }
  588. switch(lpMSSettings->iHandshake)
  589. {
  590. case MS_HSHARDWARE:
  591. ptrTrmParams->flowControl = ITMHARDFLOW;
  592. break;
  593. case MS_HSNONE:
  594. ptrTrmParams->flowControl = ITMNOFLOW;
  595. break;
  596. default:
  597. ptrTrmParams->flowControl = ITMXONFLOW;
  598. break;
  599. }
  600. ptrTrmParams->dlyRetry = (lpMSSettings->iAnswer + lpMSSettings->iToneWait);
  601. lstrcpy(ptrTrmParams->phone, lpMSSettings->szPhNum);
  602. switch(lpMSSettings->iCountry)
  603. {
  604. case MS_IDS_BRITISH:
  605. ptrTrmParams->language = ICS_BRITISH;
  606. break;
  607. case MS_IDS_GERMAN:
  608. ptrTrmParams->language = ICS_GERMAN;
  609. break;
  610. case MS_IDS_FRENCH:
  611. ptrTrmParams->language = ICS_FRENCH;
  612. break;
  613. case MS_IDS_SWEDISH:
  614. ptrTrmParams->language = ICS_SWEDISH;
  615. break;
  616. case MS_IDS_ITALIAN:
  617. ptrTrmParams->language = ICS_ITALIAN;
  618. break;
  619. case MS_IDS_SPANISH:
  620. ptrTrmParams->language = ICS_SPANISH;
  621. break;
  622. case MS_IDS_DANISH:
  623. ptrTrmParams->language = ICS_DANISH;
  624. break;
  625. case MS_IDS_FINNISH:
  626. ptrTrmParams->language = ICS_FINISH;
  627. break;
  628. case MS_IDS_CANADIAN:
  629. ptrTrmParams->language = ICS_CANADIAN;
  630. break;
  631. case MS_IDS_SWISS:
  632. ptrTrmParams->language = ICS_SWISS;
  633. break;
  634. default:
  635. ptrTrmParams->language = ICS_NONE;
  636. break;
  637. }
  638. }
  639. /*---------------------------------------------------------------------------*/
  640. /* writeTermSettings() - [scf] */
  641. /*---------------------------------------------------------------------------*/
  642. BOOL NEAR writeTermSettings(INT fileHandle)
  643. {
  644. BOOL writeTermSettings = FALSE;
  645. HANDLE hSettings;
  646. LPSETTINGS lpSettings;
  647. if((hSettings = GlobalAlloc(GMEM_MOVEABLE, (DWORD) sizeof(recTrmParams))) != NULL)
  648. {
  649. if(lpSettings = (LPSETTINGS) GlobalLock(hSettings))
  650. {
  651. lmovmem((LPBYTE) &trmParams, (LPBYTE) lpSettings, sizeof(recTrmParams));
  652. /* perform conversions here, if necessary... */
  653. if(_write(fileHandle, (LPSTR) lpSettings, sizeof(recTrmParams)) == sizeof(recTrmParams)) /* jtf 3.15 */
  654. writeTermSettings = TRUE;
  655. GlobalUnlock(hSettings);
  656. }
  657. GlobalFree(hSettings);
  658. }
  659. return(writeTermSettings);
  660. }