Windows NT 4.0 source code leak
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.

497 lines
14 KiB

4 years ago
  1. #define VT52 1
  2. /* indices for menus */
  3. #define imenuFile 0
  4. #define imenuEdit 1
  5. #define imenuOptions 2
  6. #define imenuMachine 3
  7. #define imenuHelp 4
  8. /* display rows array indices */
  9. #define idwDR25 0
  10. #define idwDR43 1
  11. #define idwDR50 2
  12. #define idwDRCustom 3
  13. #define cXNSMachines 6
  14. /* resource #defines */
  15. #define IDM_CONNECT 100
  16. #define IDM_HANGUP 101
  17. #define IDM_EXIT 102
  18. #define IDM_MARK 120
  19. #define IDM_COPY 121
  20. #define IDM_PASTE 122
  21. #define IDM_STOPPASTE 123
  22. #define IDM_TRIMSPACE 124
  23. #define IDM_QUICKEDIT 125
  24. /* these four menu items must be in consecutive order */
  25. #define IDM_25LINES 200
  26. #define IDM_43LINES 201
  27. #define IDM_50LINES 202
  28. #define IDM_CUSTOMLINES 203
  29. #define IDM_FONTS 204
  30. #define IDM_AUTOFONTS 205
  31. #define IDM_SMOOTHSCROLL 206
  32. #define IDM_NODOWNLOADPROMPT 207
  33. #define IDM_HIDEMENU 208
  34. /* these four must be in consecutive order */
  35. #define IDM_CONNECTLOSTNONE 210
  36. #define IDM_CONNECTLOSTDLG 211
  37. #define IDM_CONNECTLOSTRETRY 212
  38. #define IDM_CONNECTLOSTEXIT 213
  39. #define IDM_NOCONNECTRETRYDLG 220
  40. #define IDM_LOCALECHO 221
  41. #define IDM_TEXTCOLOUR 222
  42. #define IDM_BACKCOLOUR 223
  43. #define IDM_UNDERLINECURSOR 224
  44. #define IDM_BLINKCURSOR 225
  45. #define IDM_VT100CURSORKEYS 226
  46. #define IDM_VT52MODE 227
  47. /* these six menu items must be in consecutive order */
  48. #define IDM_BBS1 300
  49. #define IDM_BBS2 301
  50. #define IDM_CHAT1 302
  51. #define IDM_HEXNUT 303
  52. #define IDM_INGATE 304
  53. #define IDM_WINGNUT 305
  54. /* these four menu items must be in consecutive order */
  55. #define IDM_MACHINE1 306
  56. #define IDM_MACHINE2 307
  57. #define IDM_MACHINE3 308
  58. #define IDM_MACHINE4 309
  59. #define IDM_ABOUT 400
  60. #define IDM_HELP 401
  61. #define IDD_CONNECT 110
  62. #define IDD_DISPLAYLINES 111
  63. #define IDD_AUTORETRY 112
  64. #define IDD_CONNECTXNS 113
  65. #define CID_HOSTNAME 100
  66. #define CID_DISPLAYLINE 101
  67. #define CID_USESTDNETBIOS 102
  68. #define IDS_KEY 100
  69. #define IDS_WINPOSTOP 101
  70. #define IDS_WINPOSLEFT 102
  71. #define IDS_ROWS 103
  72. #define IDS_COLUMNS 104
  73. #define IDS_MACHINE1 105
  74. #define IDS_MACHINE2 106
  75. #define IDS_MACHINE3 107
  76. #define IDS_MACHINE4 108
  77. #define IDS_LASTMACHINE 109
  78. #define IDS_TEXTCOLOUR 110
  79. #define IDS_BKGCOLOUR 111
  80. #define IDS_FONTNAME 112
  81. #define IDS_FONTHEIGHT 113
  82. #define IDS_FONTWEIGHT 114
  83. #define IDS_FONTSTYLE 115
  84. #define IDS_SMOOTHSCROLL 116
  85. #define IDS_DEBUGFLAGS 117
  86. #define IDS_PROMPTFLAGS 118
  87. #define IDS_RETRYSECONDS 119
  88. #define IDS_XNSSTATE 120
  89. #define IDS_CURSOREDIT 121
  90. #define wKeyPressed ((WORD)0x8000)
  91. #define SV_PROGRESS (WM_USER+350)
  92. #define SV_END (WM_USER+351)
  93. #define SV_DATABUF (0x4000)
  94. #define SV_DONE 0
  95. #define SV_CONNECT 1
  96. #define SV_DISCONNECT 2
  97. #define SV_HANGUP 3
  98. #define SV_QUIT 4
  99. typedef struct _SendVTPInfo
  100. {
  101. LONG lExit;
  102. LONG lCleanup;
  103. HANDLE hthread;
  104. HANDLE hfile;
  105. UCHAR *puchBuffer;
  106. DWORD cbFile;
  107. DWORD cbReadTotal;
  108. volatile DWORD dwCommand;
  109. DWORD dwThreadId;
  110. int nSessionNumber;
  111. } SVI;
  112. /* Data structure and #defines for NetBios stuff */
  113. #define READ_BUF_SZ (512)
  114. #define DATA_BUF_SZ (2*READ_BUF_SZ)
  115. #define nSessionNone ((int)-1)
  116. typedef struct _NetOBJData
  117. {
  118. char szHostName[NAMSZ+1];
  119. char szMyName[NAMSZ+1];
  120. int SessionNumber;
  121. NCB ncbRecv;
  122. LPSTR lpReadBuffer;
  123. WORD iHead,
  124. iTail;
  125. char achData[DATA_BUF_SZ];
  126. } NETDATA, *LPNETDATA;
  127. #define dwMaxRows (99)
  128. #define dwDefaultRows (25)
  129. #define dwMinRows (16)
  130. #define dwMaxColumns (255)
  131. #define dwDefaultColumns (80)
  132. #define dwMinColumns (32)
  133. #define cchMaxHostName (NAMSZ+1)
  134. #define cMachinesMax (4)
  135. #define fdwItalic (1)
  136. #define fdwUnderline (2)
  137. #define fdwStrikeOut (4)
  138. #define dwRetrySecondsDefault ((DWORD)5)
  139. /* don't prompt for dest. dir on dl */
  140. #define fdwSuppressDestDirPrompt ((DWORD)0x01)
  141. /* don't show the connection lost dialog */
  142. #define fdwNoConnectLostDlg ((DWORD)0x02)
  143. /* don't show the connect auto-retry dialog */
  144. #define fdwNoConnectRetryDlg ((DWORD)0x04)
  145. #define mdwConnectLost ((DWORD)0x18)
  146. #define sConnectLost 3
  147. #define ConnectLostMode(ui) ((((ui).fPrompt &mdwConnectLost) >> sConnectLost) + IDM_CONNECTLOSTNONE)
  148. #define SetConnectLostMode(ui, val) ((ui).fPrompt &= ~mdwConnectLost, (ui).fPrompt |= ((val) - IDM_CONNECTLOSTNONE) << sConnectLost)
  149. #define fdwAutoFonts ((DWORD)0x40)
  150. /* Mask off high bit for ASCII-only */
  151. #define fdwASCIIOnly ((DWORD)0x01)
  152. /* Display output stream for debugging */
  153. #define fdwDebugOutput ((DWORD)0x02)
  154. /* Don't pass on VT100 function or cursor keys */
  155. #define fdwNoVT100Keys ((DWORD)0x04)
  156. /* Replace TABs by up to 8 spaces */
  157. #define fdwTABtoSpaces ((DWORD)0x08)
  158. /* Echo user input to display */
  159. #define fdwLocalEcho ((DWORD)0x0010)
  160. /* VT100 Cursor Keys mode */
  161. #define fdwVT100CursorKeys ((DWORD)0x0020)
  162. /* VT52 Mode */
  163. #define fdwVT52Mode ((DWORD)0x0040)
  164. /* Is XNS transport installed? */
  165. #define fdwXNSAvailable ((DWORD)0x01)
  166. /* Use XNS for this call? */
  167. #define fdwUseXNS ((DWORD)0x02)
  168. #define fdwXNSConnect (fdwXNSAvailable | fdwUseXNS)
  169. /* Is the cursor a block or underline? */
  170. #define fdwCursorUnderline ((DWORD)0x01)
  171. /* Is the cursor supposed to blink? */
  172. #define fdwCursorBlink ((DWORD)0x02)
  173. /* Are we in QuickEdit mode? */
  174. #define fdwQuickEditMode ((DWORD)0x04)
  175. /* Trim whitespace at end of every line? */
  176. #define fdwTrimEndWhitespace ((DWORD)0x08)
  177. typedef struct _USERINFO
  178. {
  179. DWORD dwTop; /* position of top side of display */
  180. DWORD dwLeft; /* position of left side of display */
  181. DWORD dwMaxRow; /* number of rows in display */
  182. DWORD dwMaxCol; /* number of columns in display */
  183. DWORD clrText; /* colour of text in display */
  184. DWORD clrBk; /* colour of background in display */
  185. DWORD fSmoothScroll; /* scroll window contents smoothly */
  186. DWORD fPrompt; /* prompt bit flags */
  187. DWORD fDebug; /* Debug bit flags */
  188. DWORD fCursorEdit; /* Cursor Flags */
  189. DWORD dwRetrySeconds; /* Number of seconds between retries */
  190. DWORD fXNS; /* if XNS being used */
  191. DWORD cMachines; /* # of machines in rgchMachine[] list */
  192. char rgchMachine[cMachinesMax][cchMaxHostName];
  193. char rgchLastMachine[cchMaxHostName]; /* last machine connected */
  194. LOGFONT lf; /* description of font used */
  195. } UI;
  196. #define uTerminalTimerID ((UINT)2)
  197. #define uCursorBlinkMsecs ((UINT)250)
  198. /* VT100 Flags */
  199. #define dwVTArrow ((DWORD)0x0001)
  200. #define dwVTKeypad ((DWORD)0x0002)
  201. #define dwVTWrap ((DWORD)0x0004)
  202. #define dwVT52 ((DWORD)0x0008)
  203. #define dwVTCursor ((DWORD)0x0010)
  204. #define dwVTScrSize ((DWORD)0x0020)
  205. #define dwDECCOLM ((DWORD)0x0040)
  206. #define dwDECSCNM ((DWORD)0x0080)
  207. #define dwLineMode ((DWORD)0x0100)
  208. #define dwInsertMode ((DWORD)0x0200)
  209. #define dwVT52Graphics ((DWORD)0x0400)
  210. #define dwKeyLock ((DWORD)0x0800)
  211. #define FIsVTArrow(ptrm) ((ptrm)->dwVT100Flags & dwVTArrow)
  212. #define SetVTArrow(ptrm) ((ptrm)->dwVT100Flags |= dwVTArrow)
  213. #define ClearVTArrow(ptrm) ((ptrm)->dwVT100Flags &= ~dwVTArrow)
  214. #define FIsVTKeypad(ptrm) ((ptrm)->dwVT100Flags & dwVTKeypad)
  215. #define SetVTKeypad(ptrm) ((ptrm)->dwVT100Flags |= dwVTKeypad)
  216. #define ClearVTKeypad(ptrm) ((ptrm)->dwVT100Flags &= ~dwVTKeypad)
  217. #define FIsVTWrap(ptrm) ((ptrm)->dwVT100Flags & dwVTWrap)
  218. #define SetVTWrap(ptrm) ((ptrm)->dwVT100Flags |= dwVTWrap)
  219. #define ClearVTWrap(ptrm) ((ptrm)->dwVT100Flags &= ~dwVTWrap)
  220. #define FIsVT52(ptrm) ((ptrm)->dwVT100Flags & dwVT52)
  221. #define SetVT52(ptrm) ((ptrm)->dwVT100Flags |= dwVT52)
  222. #define ClearVT52(ptrm) ((ptrm)->dwVT100Flags &= ~dwVT52)
  223. #define FIsVTCursor(ptrm) ((ptrm)->dwVT100Flags & dwVTCursor)
  224. #define SetVTCursor(ptrm) ((ptrm)->dwVT100Flags |= dwVTCursor)
  225. #define ClearVTCursor(ptrm) ((ptrm)->dwVT100Flags &= ~dwVTCursor)
  226. #define FIsVTScrSize(ptrm) ((ptrm)->dwVT100Flags & dwVTScrSize)
  227. #define SetVTScrSize(ptrm) ((ptrm)->dwVT100Flags |= dwVTScrSize)
  228. #define ClearVTScrSize(ptrm) ((ptrm)->dwVT100Flags &= ~dwVTScrSize)
  229. #define FIsDECCOLM(ptrm) ((ptrm)->dwVT100Flags & dwDECCOLM)
  230. #define SetDECCOLM(ptrm) ((ptrm)->dwVT100Flags |= dwDECCOLM)
  231. #define ClearDECCOLM(ptrm) ((ptrm)->dwVT100Flags &= ~dwDECCOLM)
  232. #define FIsDECSCNM(ptrm) ((ptrm)->dwVT100Flags & dwDECSCNM)
  233. #define SetDECSCNM(ptrm) ((ptrm)->dwVT100Flags |= dwDECSCNM)
  234. #define ClearDECSCNM(ptrm) ((ptrm)->dwVT100Flags &= ~dwDECSCNM)
  235. #define FIsLineMode(ptrm) ((ptrm)->dwVT100Flags & dwLineMode)
  236. #define SetLineMode(ptrm) ((ptrm)->dwVT100Flags |= dwLineMode)
  237. #define ClearLineMode(ptrm) ((ptrm)->dwVT100Flags &= ~dwLineMode)
  238. #define FIsInsertMode(ptrm) ((ptrm)->dwVT100Flags & dwInsertMode)
  239. #define SetInsertMode(ptrm) ((ptrm)->dwVT100Flags |= dwInsertMode)
  240. #define ClearInsertMode(ptrm) ((ptrm)->dwVT100Flags &= ~dwInsertMode)
  241. #define FIsVT52Graphics(ptrm) ((ptrm)->dwVT100Flags & dwVT52Graphics)
  242. #define SetVT52Graphics(ptrm) ((ptrm)->dwVT100Flags |= dwVT52Graphics)
  243. #define ClearVT52Graphics(ptrm) ((ptrm)->dwVT100Flags &= ~dwVT52Graphics)
  244. #define FIsKeyLock(ptrm) ((ptrm)->dwVT100Flags & dwKeyLock)
  245. #define SetKeyLock(ptrm) ((ptrm)->dwVT100Flags |= dwKeyLock)
  246. #define ClearKeyLock(ptrm) ((ptrm)->dwVT100Flags &= ~dwKeyLock)
  247. typedef struct _TERM
  248. {
  249. DWORD dwCurLine;
  250. DWORD dwCurChar;
  251. DWORD dwEscCodes[10];
  252. DWORD cEscParams;
  253. DWORD dwScrollTop;
  254. DWORD dwScrollBottom;
  255. DWORD fEsc;
  256. DWORD dwSum;
  257. UCHAR *puchCharSet;
  258. UINT uTimer;
  259. DWORD cTilde;
  260. DWORD dwVT100Flags;
  261. BOOL fRelCursor;
  262. BOOL fSavedState;
  263. BOOL fInverse;
  264. BOOL fHideCursor;
  265. BOOL fCursorOn;
  266. UCHAR rgchBufferText[256];
  267. int cchBufferText;
  268. DWORD dwCurCharBT;
  269. DWORD dwCurLineBT;
  270. BOOL fInverseBT;
  271. DWORD dwSaveChar;
  272. DWORD dwSaveLine;
  273. DWORD dwSaveRelCursor;
  274. } TRM;
  275. #define uRetryTimerID ((UINT)1)
  276. typedef struct _AUTORETRY
  277. {
  278. HWND hwnd;
  279. LPSTR szHostName;
  280. LPNETDATA lpData;
  281. UINT uTimer;
  282. } AR;
  283. #define dwMarkNone ((DWORD)0)
  284. #define dwMarkKeyboard ((DWORD)0x01)
  285. #define dwMarkMouse ((DWORD)0x02)
  286. #define dwNothingChanged ((DWORD)0)
  287. #define dwYChanged ((DWORD)0x01)
  288. #define dwXChanged ((DWORD)0x02)
  289. #define dwForceNone ((DWORD)0)
  290. #define dwForceOn ((DWORD)0x01)
  291. #define dwForceOff ((DWORD)0x02)
  292. #define fdwMarkMode ((DWORD)0x01)
  293. #define fdwSelected ((DWORD)0x02)
  294. #define fdwShowCursor ((DWORD)0x04)
  295. #define fdwCursorOn ((DWORD)0x08)
  296. #define fdwDataPending ((DWORD)0x10)
  297. #define fdwMouseSelected ((DWORD)0x20)
  298. #define fdwMouseCaptured ((DWORD)0x40)
  299. #define fdwMouseBtnDwnIgnore ((DWORD)0x80)
  300. #define fdwDontResetSelection ((DWORD)0x100)
  301. #define FInMarkMode(_spb) (!!((_spb).dwFlags & fdwMarkMode))
  302. #define FSelected(_spb) (!!((_spb).dwFlags & fdwSelected))
  303. #define FShowCursor(_spb) (!!((_spb).dwFlags & fdwShowCursor))
  304. #define FCursorOn(_spb) (!!((_spb).dwFlags & fdwCursorOn))
  305. #define FDataPending(_spb) (!!((_spb).dwFlags & fdwDataPending))
  306. #define FMouseSelected(_spb) (!!((_spb).dwFlags & fdwMouseSelected))
  307. #define FMouseCaptured(_spb) (!!((_spb).dwFlags & fdwMouseCaptured))
  308. #define FMouseBtnDwnIgnore(_spb) (!!((_spb).dwFlags & fdwMouseBtnDwnIgnore))
  309. #define FCanPaste(_pwi) (IsClipboardFormatAvailable(CF_TEXT) && \
  310. ((_pwi)->nd.SessionNumber != nSessionNone) && \
  311. ((_pwi)->svi.hthread == NULL) && \
  312. !FInMarkMode((_pwi)->spb))
  313. typedef struct _SPB
  314. {
  315. POINT ptCursor; /* cursor point */
  316. POINT ptAnchor; /* anchor point */
  317. RECT rectSelect; /* selection rect */
  318. DWORD dwFlags;
  319. WPARAM wData;
  320. } SPB;
  321. /* Window Information */
  322. #define WL_VTPWI (0)
  323. typedef struct _WI
  324. {
  325. NETDATA nd;
  326. TRM trm;
  327. DWORD ichVTPXfer;
  328. SVI svi;
  329. SPB spb;
  330. CHOOSEFONT cf;
  331. } WI;
  332. extern UI ui;
  333. extern int iCursorHeight; /* height of cursor */
  334. extern int iCursorWidth; /* width of cursor */
  335. extern int hPos, vPos; /* Scroll bar positions */
  336. extern BOOL fConnected; /* if we're connected to a machine */
  337. extern BOOL fHungUp;
  338. extern BOOL fInBackground;
  339. extern BOOL fFlashWindow;
  340. extern HWND hwndMain; /* HANDLE to main display window */
  341. extern DWORD *aixPos; /* horizontal position of character columns */
  342. extern DWORD *aiyPos; /* vertical position of character rows */
  343. extern UCHAR **apcRows; /* array of char ptrs of Rows */
  344. extern UCHAR *rgchRowEmpty; /* template of empty row for quick-copying */
  345. extern UCHAR *pchNBBuffer;
  346. extern DWORD dwMarkMode;
  347. extern ULONG imenuMRU;
  348. extern HFONT hfontDisplay; /* display font */
  349. extern DWORD rgdwCustColours[16]; /* custom colour array */
  350. extern LPSTR szTextPaste;
  351. extern char *pchTextPaste;
  352. extern DWORD cchTextPaste;
  353. extern DWORD cBlocks;
  354. extern UCHAR rgchHostName[cchMaxHostName]; /* name of host we're connected to */
  355. #if 0
  356. extern char rgchDbgBfr[80];
  357. #endif
  358. extern DWORD rgdwDisplayRows[4];
  359. extern UCHAR rgchNormalChars[256];
  360. extern UCHAR rgchAlternateChars[256];
  361. int PASCAL WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
  362. BOOL FInitApplication( HINSTANCE );
  363. BOOL FInitInstance(HINSTANCE, int);
  364. LONG APIENTRY MainWndProc(HWND, UINT, WPARAM, LPARAM);
  365. BOOL APIENTRY About(HWND, UINT, WPARAM, LPARAM);
  366. BOOL APIENTRY Connect(HWND, UINT, WPARAM, LPARAM);
  367. BOOL APIENTRY DisplayLines(HWND, UINT, WPARAM, LPARAM);
  368. void CenterDialog(HWND, HWND);
  369. void GetUserSettings(HINSTANCE, UI *);
  370. void SetUserSettings(HINSTANCE, UI *);
  371. HMENU HmenuGetMRUMenu(HWND, UI *);
  372. DWORD DwIsXNSMachine(LPSTR, DWORD);
  373. /* netio.c */
  374. BOOL FConnectToServer(HWND, LPSTR, LPNETDATA, BOOL);
  375. BOOL FPostReceive( LPNETDATA );
  376. WORD WGetData(LPNETDATA, LPSTR, WORD);
  377. void CALLBACK NBReceiveData( NCB * );
  378. BOOL FVtpXferStart(HWND, WI *, int);
  379. BOOL FVtpXferEnd(HWND, DWORD);
  380. BOOL FGetFileName(HWND, char *, char *);
  381. DWORD WINAPI SVReceive(SVI *);
  382. BOOL FHangupConnection(HWND, LPNETDATA);
  383. BOOL APIENTRY ConnectAutoRetry(HWND, UINT, WPARAM, LPARAM);
  384. BOOL FIsXenixAvailable( void );
  385. /* mcp.c */
  386. void MarkModeOn(HWND, DWORD);
  387. void MarkModeOff( HWND );
  388. void DoCursorFlicker(HWND, DWORD);
  389. void InvertSelection(HWND, RECT *);
  390. void ExtendSelection(HWND, POINT *, DWORD);
  391. void HandleMCPKeyEvent(HWND, WPARAM, LPARAM);
  392. void HandleMCPMouseEvent(HWND, UINT, WPARAM, LPARAM);
  393. void DoCopy( HWND );
  394. void DoPaste( HWND );
  395. void StopPaste( HWND );
  396. void SetWindowTitle(HWND, DWORD, LPSTR);
  397. /* trmio.c */
  398. void ResizeWindow( HWND );
  399. void RecalcWindowSize( HWND );
  400. void DoTermReset(HWND, TRM *, HDC);
  401. void DoIBMANSIOutput(HWND, TRM *, DWORD, UCHAR *);
  402. void Paint(HWND, WI *);
  403. void CursorOn( HWND );
  404. void CursorOff( HWND );
  405. void SetDisplaySize(HWND, DWORD, DWORD *);
  406. void HandleCharEvent(HWND, WI *, WPARAM, LPARAM);
  407. BOOL FHandleKeyDownEvent(HWND, WI *, WPARAM, LPARAM);