Leaked source code of windows server 2003
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.

812 lines
30 KiB

  1. /*** mep.h - primary include file for editor
  2. *
  3. * Copyright <C> 1988, Microsoft Corporation
  4. *
  5. * Revision History:
  6. * 10-Jan-1991 ramonsa Converted to Win32 API
  7. * 26-Nov-1991 mz Strip off near/far
  8. *
  9. ************************************************************************/
  10. #include <ctype.h>
  11. #include <direct.h>
  12. #include <fcntl.h>
  13. #include <io.h>
  14. #include <malloc.h>
  15. #include <math.h>
  16. #include <process.h>
  17. #include <signal.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include <sys\types.h>
  21. #include <sys\stat.h>
  22. #include <time.h>
  23. #include <stdio.h>
  24. #include <share.h>
  25. //
  26. // WINDOWS includes
  27. //
  28. #include <windows.h>
  29. #include <dos.h>
  30. #include <tools.h>
  31. #include <remi.h>
  32. #include "console.h"
  33. typedef HANDLE FILEHANDLE, *PFILEHANDLE;
  34. typedef DWORD ACCESSMODE, *PACCESSMODE;
  35. typedef DWORD SHAREMODE, *PSHAREMODE;
  36. typedef DWORD MOVEMETHOD, *PMOVEMETHOD;
  37. #define ACCESSMODE_READ GENERIC_READ
  38. #define ACCESSMODE_WRITE GENERIC_WRITE
  39. #define ACCESSMODE_RW (GENERIC_READ | GENERIC_WRITE)
  40. #define SHAREMODE_READ FILE_SHARE_READ
  41. #define SHAREMODE_WRITE FILE_SHARE_WRITE
  42. #define SHAREMODE_NONE 0
  43. #define FROM_BEGIN FILE_BEGIN
  44. #define FROM_CURRENT FILE_CURRENT
  45. #define FROM_END FILE_END
  46. #define SHAREMODE_RW (SHAREMODE_READ | SHAREMODE_WRITE)
  47. //
  48. // assertion support
  49. //
  50. // assert - assertion macro. We define our own, because if we abort we need
  51. // to be able to shut down cleanly (or at least die trying). This
  52. // version also saves us some code over the C library one.
  53. //
  54. // asserte - version of assert that always executes the expression, regardless
  55. // of debug state.
  56. //
  57. #ifdef DEBUG
  58. #define REGISTER
  59. #define assert(exp) { \
  60. if (!(exp)) \
  61. _assertexit (#exp, __FILE__, __LINE__); \
  62. }
  63. #define asserte(exp) assert(exp)
  64. #else
  65. #define REGISTER register
  66. #define assert(exp)
  67. #define asserte(exp) ((exp) != 0)
  68. #endif
  69. typedef long LINE; // line number within file
  70. // LINEREC - The text of the file is an array of line pointers/lengths. A
  71. // single procedure call can be used to grab the line *AND* its length.
  72. // Color in the file is an array of pointer to attr/length arrays.
  73. typedef struct _lineRecType {
  74. PVOID vaLine; // long address of line
  75. BOOL Malloced; // Ture if address allocated via malloc
  76. int cbLine; // number of bytes in line
  77. } LINEREC;
  78. // VALINE (l) - Returns virtual address of the line record
  79. // (lineRecType) for line l.
  80. #define VALINE(l) (pFile->plr + (l))
  81. // Each file that is in memory has a unique descriptor. This is so that
  82. // editing the same file in two windows will allow updates to be reflected
  83. // in both.
  84. //
  85. // NOTE: pFileNext must be the first field in the structure. Certain places
  86. // in the code require this.
  87. typedef struct fileType {
  88. struct fileType *pFileNext; // next file in chain
  89. #ifdef DEBUG
  90. int id; // debug id byte
  91. #endif
  92. char *pName; // file name
  93. LINEREC *plr; // addr of line table
  94. BYTE *pbFile; // addr of full file image
  95. LINE lSize; // number of lines in block
  96. LINE cLines; // number of lines in file
  97. PVOID vaColor; // addr of color table
  98. PVOID vaHiLite; // highlighting info
  99. PVOID vaUndoHead; // head of undo list
  100. PVOID vaUndoTail; // end of undo list
  101. PVOID vaUndoCur; // current pos in undo list
  102. PVOID vaMarks; // Marks in this file
  103. int cUndo; // number of undo-able entries
  104. int refCount; // reference count window references
  105. int type; // type of this file
  106. int flags; // flags for dirty, permanent, etc
  107. time_t modify; // Date/Time of last modify
  108. } *PFILE;
  109. //
  110. // for the display manager, there is a separate window allocated for each
  111. // window on the screen. Each window has display-relevant information.
  112. //
  113. typedef struct windowType *PWND;
  114. //
  115. // ext.h is the include file provided to extension writers. It should contain
  116. // only definitions that are meaningfull to them. The EDITOR definition below
  117. // prevents it from defining some typedefs and function prototypes which
  118. // conflict with editor internals.
  119. //
  120. #define EDITOR
  121. #include "ext.h"
  122. struct windowType {
  123. struct instanceType *pInstance; // address of instance list
  124. sl Size; // size of window
  125. sl Pos; // position of window
  126. };
  127. #define BELL 0x07
  128. #define SHELL "cmd.exe"
  129. #define TMPVER "TMP4" // temp file revision
  130. //
  131. // debug at a certain place
  132. //
  133. #if defined (DEBUG)
  134. #define MALLOC(x) DebugMalloc(x, FALSE, __FILE__, __LINE__)
  135. #define REALLOC(x, y) DebugRealloc(x, y, FALSE, __FILE__, __LINE__)
  136. #define FREE(x) DebugFree(x, __FILE__, __LINE__)
  137. #define ZEROMALLOC(x) DebugMalloc(x, TRUE, __FILE__, __LINE__)
  138. #define ZEROREALLOC(x,y ) DebugRealloc(x, y, TRUE, __FILE__, __LINE__)
  139. #define MEMSIZE(x) DebugMemSize(x, __FILE__, __LINE__)
  140. #else
  141. #define MALLOC(x) malloc(x)
  142. #define REALLOC(x, y) realloc(x, y)
  143. #define FREE(x) free(x)
  144. #define ZEROMALLOC(x) ZeroMalloc(x)
  145. #define ZEROREALLOC(x,y ) ZeroRealloc(x, y)
  146. #define MEMSIZE(x) MemSize(x)
  147. #endif
  148. //
  149. // ID's for assertion checking
  150. //
  151. #ifdef DEBUG
  152. #define ID_PFILE 0x5046 // PF
  153. #define ID_INSTANCE 0x494E // IN
  154. #endif
  155. //
  156. // list of files and their debug values
  157. //
  158. #define TEXTLINE 0x1
  159. #define ZALLOC 0x2
  160. #define VMUTIL 0x4
  161. #define VM 0x8
  162. #define FILEIO 0x10
  163. #define CMD 0x20
  164. #define PICK 0x40
  165. #define ZINIT 0x80
  166. #define WINDOW 0x100
  167. #define DISP 0x200
  168. #define Z 0x400
  169. #define Z19 0x800
  170. #define LOAD 0x1000
  171. #define MAXWIN 8
  172. #define MAXMAC 1024
  173. // **************************************************************
  174. //
  175. // Macros for accessing fields of struct instanceType
  176. //
  177. // **************************************************************
  178. #define XWIN(f) (f)->flWindow.col
  179. #define YWIN(f) (f)->flWindow.lin
  180. #define XCUR(f) (f)->flCursorCur.col
  181. #define YCUR(f) (f)->flCursorCur.lin
  182. #define FLAGS(f) (f)->flags
  183. #define XOLDWIN(f) (f)->flOldWin.col
  184. #define YOLDWIN(f) (f)->flOldWin.lin
  185. #define XOLDCUR(f) (f)->flOldCur.col
  186. #define YOLDCUR(f) (f)->flOldCur.lin
  187. #define FTYPE(f) (f)->type
  188. // **************************************************************
  189. //
  190. // VACOLOR (l) - Returns virtual address of the color record
  191. // (colorRecType) for line l.
  192. //
  193. // **************************************************************
  194. #define VACOLOR(l) (PVOID)((PBYTE)pFile->vaColor+sizeof(struct colorRecType)*((long)(l)))
  195. // **************************************************************
  196. //
  197. // Flags indicating what has changed since the last display update.
  198. //
  199. // RCURSOR: The cursor has moved. This means the cursor should
  200. // be physically moved on the screen, and that the
  201. // cursor position status should be changed.
  202. // RTEXT: The editing area has been changed. A more precise
  203. // breakdown is available by examining the fChange array.
  204. // RSTATUS: In the original interface, this means that something
  205. // on the bottom screen line has changed. In the CW
  206. // interface, this means something in the status window
  207. // has changed (either the insert mode or the learn mode)
  208. // RHIGH: This is set to mean highlighting should be displayed.
  209. // RFILE: The file-specific information has changed. CW
  210. // interface only.
  211. // RHELP: The Help window has changed. CW interface only.
  212. //
  213. // **************************************************************
  214. #define RCURSOR 0x01
  215. #define RTEXT 0x02
  216. #define RSTATUS 0x04
  217. #define RHIGH 0x08
  218. // **************************************************************
  219. //
  220. // argument types and arg structures
  221. //
  222. // **************************************************************
  223. #define GETARG (NOARG|TEXTARG|NULLARG|NULLEOL|NULLEOW|LINEARG|STREAMARG|BOXARG)
  224. // arg processing required
  225. #define COLORBG -1
  226. #define COLORNOR 0
  227. #define COLORINF 1
  228. #define COLORERR 2
  229. #define COLORSTA 3
  230. #define INTENSE 8
  231. #define WHITE 7
  232. #define YELLOW 6
  233. #define MAGENTA 5
  234. #define RED 4
  235. #define CYAN 3
  236. #define GREEN 2
  237. #define BLUE 1
  238. #define BLACK 0
  239. #define B_BAK 0
  240. #define B_UNDEL 1
  241. #define B_NONE 2
  242. #define MONO 0
  243. #define CGA 1
  244. #define EGA 2
  245. #define VGA 3
  246. #define MCGA 4
  247. #define VIKING 5
  248. #define MAXUSE 20
  249. #define GRAPH 0x01 // parsing editing chars in macro body
  250. #define EXEC 0x02 // macro is an execution; ending sets fBreak
  251. #define INIT 0x04 // macro needs to be initialized
  252. struct macroInstanceType {
  253. char *beg; // pointer to beginning of string
  254. char *text; // pointer to next command
  255. flagType flags; // what type of function is next
  256. };
  257. typedef struct macroInstanceType MI, *PMI;
  258. //
  259. // flags for fChange
  260. //
  261. #define FMODIFY 0x01 // TRUE => line was modified
  262. // **************************************************************
  263. //
  264. // Macros for dealing with windows.
  265. //
  266. // **************************************************************
  267. #define WINYSIZE(pwin) ((pwin)->Size.lin)
  268. #define WINXSIZE(pwin) ((pwin)->Size.col)
  269. #define WINYPOS(pwin) ((pwin)->Pos.lin)
  270. #define WINXPOS(pwin) ((pwin)->Pos.col)
  271. #define WININST(pwin) ((pwin)->pInstance)
  272. #define XSCALE(x) max(1,(x)*WINXSIZE(pWinCur)/slSize.col)
  273. #define YSCALE(y) max(1,(y)*WINYSIZE(pWinCur)/slSize.lin)
  274. // **************************************************************
  275. //
  276. // for each instance of a file in memory, there is a window that is
  277. // allocated for it. The structure has all relevant information for the
  278. // instance within the window. No display information is kept here
  279. //
  280. // **************************************************************
  281. struct instanceType {
  282. struct instanceType *pNext; // ptr to next file activation
  283. #ifdef DEBUG
  284. int id; // debug id byte
  285. #endif
  286. PFILE pFile; // ptr to file structure
  287. fl flOldWin; // previous file pos of window
  288. fl flOldCur; // previous file cursor
  289. fl flWindow; // file coord of window
  290. fl flCursorCur; // file pos of cursor
  291. fl flSaveWin; // saved coord of window
  292. fl flSaveCur; // saved y coord of cursor
  293. fl flArg; // Last Arg position
  294. fl flCursor; // Cursor just before last function
  295. flagType fSaved; // TRUE => values below valid
  296. };
  297. typedef struct instanceType *PINS;
  298. // **************************************************************
  299. //
  300. // Each mark that is defined is present in a linked list
  301. //
  302. // **************************************************************
  303. typedef struct mark MARK;
  304. typedef struct filemarks FILEMARKS;
  305. struct mark {
  306. unsigned flags; //
  307. unsigned cb; // Bytes in this mark structure, including name
  308. fl fl; // Location of the mark
  309. char szName[1]; // Name of mark
  310. };
  311. struct filemarks {
  312. unsigned cb; // Total bytes in struct, including marks
  313. MARK marks[1]; // marks for this file
  314. };
  315. struct colorRecType {
  316. PVOID vaColors; // Address of lineAttr array
  317. int cbColors;
  318. };
  319. extern struct cmdDesc cmdTable[];
  320. extern struct swiDesc swiTable[];
  321. extern char * cftab[];
  322. struct fTypeInfo {
  323. char *ext; // extention of file type
  324. int ftype; // numerical type
  325. };
  326. struct compType {
  327. struct compType *pNext; // next link in compile list
  328. char *pExt; // pointer to extension
  329. char *pCompile; // pointer to compile text
  330. };
  331. typedef struct compType COMP;
  332. #define TEXTFILE 0
  333. #define CFILE 1
  334. #define ASMFILE 2
  335. #define PASFILE 3
  336. #define FORFILE 4
  337. #define LSPFILE 5
  338. #define BASFILE 6
  339. //
  340. // return values for FileStatus
  341. //
  342. #define FILECHANGED 0 // timestamps differ
  343. #define FILEDELETED 1 // file is not on disk
  344. #define FILESAME 2 // timestamps match
  345. extern struct fTypeInfo ftypetbl[];
  346. extern char * mpTypepName[];
  347. // **************************************************************
  348. //
  349. // Initialization flags. These are set when an initialization task has
  350. // been performed. It is examined in CleanExit to determine what needs
  351. // to be restored.
  352. //
  353. // **************************************************************
  354. #define INIT_VIDEO 1 // Video state is set up
  355. #define INIT_KBD 2 // Keyboard is set to editor state
  356. #define INIT_EDITVIDEO 4 // Editor video state is established
  357. #define INIT_SIGNALS 8 // Signal handlers have been set up
  358. #define INIT_VM 0x10 // VM has been initialized
  359. // **************************************************************
  360. //
  361. // CleanExit() flags
  362. //
  363. // **************************************************************
  364. #define CE_VM 1 // Clean Up VM
  365. #define CE_SIGNALS 2 // Clean up signals
  366. #define CE_STATE 4 // Update state file
  367. // **************************************************************
  368. //
  369. // zloop() flags
  370. //
  371. // **************************************************************
  372. #define ZL_CMD 1 // command key, should be an event
  373. #define ZL_BRK 2 // take fBreak into account
  374. // **************************************************************
  375. //
  376. // getstring() flags
  377. //
  378. // **************************************************************
  379. #define GS_NEWLINE 1 // Entry must be terminated by newline
  380. #define GS_INITIAL 2 // Entry is hilighted and cleared if graphic
  381. #define GS_KEYBOARD 4 // Entry must from the keyboard
  382. #define GS_GETSTR 8 // Called from getstring(), not SDM
  383. // **************************************************************
  384. //
  385. // type for pointer to function *
  386. //
  387. // **************************************************************
  388. typedef void ( *PFUNCTION)(char *, flagType);
  389. //
  390. // Internal structure of a key
  391. //
  392. typedef struct _EDITOR_KEY {
  393. KEY_INFO KeyInfo;
  394. WORD KeyCode;
  395. } EDITOR_KEY, *PEDITOR_KEY;
  396. // **************************************************************
  397. //
  398. // Editor Globals.
  399. //
  400. // slSize - Under CW, these are the total number of rows and
  401. // columns available. Without CW, these represent the
  402. // editing area, which is 2 less.
  403. //
  404. // **************************************************************
  405. extern sl slSize; // dimensions of the screen
  406. #define XSIZE slSize.col
  407. #define YSIZE slSize.lin
  408. extern PFILE pFilePick; // pick buffer
  409. extern PFILE pFileFileList; // command line file list
  410. extern PFILE pFileIni; // TOOLS.INI
  411. extern PFILE pFileMark; // Current mark definition file
  412. extern PFILE pFileAssign; // <assign>
  413. extern struct instanceType *pInsCur; // currently active window
  414. extern PWND pWinCur; // pointer to current window
  415. extern struct windowType WinList[]; // head of all windows
  416. extern int iCurWin; // index of current window
  417. extern int cWin; // count of active windows
  418. extern PFILE pFileHead; // address of head of file list
  419. extern COMP *pCompHead; // address of head of compile extension list
  420. extern MARK *pMarkHead; // address of head of mark list
  421. extern char *pMarkFile; // additional file to search for marks
  422. extern char *pPrintCmd; // pointer to <printcmd> string
  423. extern PFILE pPrintFile; // file currently printed (to PRN)
  424. //
  425. // Global vars for the fScan routine.
  426. //
  427. extern buffer scanbuf; // buffer for file scanning
  428. extern buffer scanreal; // buffer for file scanning
  429. extern int scanlen; // length of said buffer
  430. extern fl flScan; // file loc of current scan
  431. extern rn rnScan; // range of scan
  432. #if DEBUG
  433. extern int debug, indent; // debugging flags
  434. extern FILEHANDLE debfh; // debugging output file
  435. #endif
  436. //
  437. // ARG processing vars
  438. //
  439. extern fl flArg; // file pos of 1st arg
  440. extern int argcount; // number of args hit
  441. extern flagType fBoxArg; // TRUE => boxarg, FALSE => streamarg
  442. extern ARG NoArg; // predefined no arg struct
  443. extern flagType fInSelection; // TRUE => Selecting text
  444. extern fl flLow; // low values for args
  445. extern fl flHigh; // high values for args
  446. extern LINE lSwitches; // Line # in <assign> of switches
  447. extern int cRepl; // number of replaces
  448. extern COL xMargin; // column of right margin
  449. extern int backupType; // type of backup being done
  450. extern int cUndelCount; // max num of undel backups of the same file
  451. extern char *ronlypgm; // program to run on readonly files
  452. extern buffer buf; // temp line buffer
  453. extern buffer textbuf; // buffer for text arguments
  454. extern int Zvideo; // Handle for Z video state
  455. extern int DOSvideo; // Handle for DOS video state
  456. extern flagType fAskExit; // TRUE => prompt at exit
  457. extern flagType fAskRtn; // TRUE => prompt on return from PUSHED
  458. extern flagType fAutoSave; // TRUE => always save files on switches
  459. extern flagType fBreak; // TRUE => exit current TopLoop call
  460. extern flagType fCgaSnow; // TRUE => CGA has snow, so fix it
  461. extern flagType *fChange; // TRUE => line was changed
  462. extern unsigned fInit; // Flags describing what has been initialized
  463. extern flagType fCtrlc; // TRUE => control-c interrupt
  464. extern flagType fDebugMode; // TRUE => compiles are debug
  465. extern flagType fMetaRecord; // TRUE => Don't execute anything
  466. extern flagType fDefaults; // TRUE => do not load users TOOLS.INI
  467. extern flagType fDisplay; // TRUE => need to redisplay
  468. extern flagType fDisplayCursorLoc; // TRUE => pos of cursor vs window displayed
  469. extern flagType fEditRO; // TRUE => allow editting of DISKRO files
  470. extern flagType fErrPrompt; // TRUE => prompt after errors
  471. extern flagType fGlobalRO; // TRUE => no editing allowed
  472. extern flagType fInsert; // TRUE => insertmode is on
  473. extern flagType fMacroRecord; // TRUE => We're recording into <record>
  474. extern flagType fMessUp; // TRUE => there is a message on dialog line
  475. extern flagType fMeta; // TRUE => <meta> command pressed
  476. extern flagType fMsgflush; // TRUE => flush previous compile messages
  477. extern flagType fNewassign; // TRUE => <assign> needs refreshing
  478. extern flagType fRealTabs; // TRUE => tabs are VI-like
  479. extern flagType fRetVal; // return value of last editing function call
  480. extern flagType fSaveScreen; // TRUE => Restore DOS screen
  481. extern flagType fShortNames; // TRUE => do short-filename matching
  482. extern flagType fSoftCR; // TRUE => use soft carriage returns
  483. extern flagType fTabAlign; // TRUE => allign cursor to tab characters
  484. extern flagType fTextarg; // TRUE => text was typed in
  485. extern flagType fTrailSpace; // TRUE => allow trailing spaces in lines
  486. extern flagType fWordWrap; // TRUE => space in col 72 goes to newline
  487. //
  488. // Search/Replace globals
  489. //
  490. extern flagType fUnixRE; // TRUE => Use UNIX RE's (unixre: switch)
  491. extern flagType fSrchAllPrev; // TRUE => previously searched for all
  492. extern flagType fSrchCaseSwit; // TRUE => case is significant (case: switch)
  493. extern flagType fSrchCasePrev; // TRUE => case was significant
  494. extern flagType fSrchDirPrev; // TRUE => previously searched forward
  495. extern flagType fSrchRePrev; // TRUE => search previously used RE's
  496. extern flagType fSrchWrapSwit; // TRUE => searches wrap (wrap: switch)
  497. extern flagType fSrchWrapPrev; // TRUE => previously did wrap
  498. extern flagType fRplRePrev; // TRUE => replace previously used RE's
  499. extern buffer srchbuf; // search buffer
  500. extern buffer srcbuf; // source string for replace
  501. extern buffer rplbuf; // destination string for replace
  502. extern flagType fUseMouse; // TRUE => Handle mouse events
  503. #define SIGBREAK 21 // Taken from signal.h
  504. extern flagType fReDraw; // TRUE => Screen is already locked
  505. extern unsigned LVBlength; // Bytes in LVB (returned from VioGetBuf)
  506. extern unsigned kbdHandle; // Handle of logical keyboard
  507. extern HANDLE semIdle; // Idle thread semaphore
  508. extern PCMD *rgMac; // set of macro definitions
  509. extern int cMac; // number of macros
  510. extern int ballevel; // current level in paren balance
  511. extern char *balopen, *balclose; // balance open string, close string
  512. extern unsigned kindpick; // what is in the pick buffer
  513. extern char tabDisp; // character for tab expansion in display
  514. extern char trailDisp; // Character for trailing spaces
  515. extern char Name[]; // editor name
  516. extern char Version[]; // editor version
  517. extern char CopyRight[]; // editor copyright message
  518. extern int EnTab; // 0 => no tab 1 => min 2 => max tabification
  519. extern int tmpsav; // number of past files to remember
  520. extern int hike; // value of HIKE: switch
  521. extern int vscroll; // value of VSCROLL: switch
  522. extern int hscroll; // value of HSCROLL: switch
  523. extern int tabstops; // value of TABSTOPS: switch
  524. extern int fileTab; // spacing of tab chars in file
  525. extern int CursorSize; // cursor size
  526. extern EDITOR_KEY keyCmd; // last commands keystroke
  527. #define isaUserMin 21 // cw min isa, for consistancy in indecies
  528. extern int ColorTab[]; // 16 available colors.
  529. #define fgColor ColorTab[0] // foreground color
  530. #define hgColor ColorTab[1] // highlight color
  531. #define infColor ColorTab[2] // information color
  532. #define selColor ColorTab[3] // selection color
  533. #define wdColor ColorTab[4] // window border color
  534. #define staColor ColorTab[5] // status color
  535. #define errColor ColorTab[6] // error color
  536. extern LINE cNoise; // number of lines between noise on status
  537. extern int cUndo; // count of undo operations retained
  538. extern int cArgs; // number of files on command line
  539. extern char **pArgs; // pointer to files in command line
  540. extern PFILE pFileIni; // pfile for tools.ini
  541. extern char * pNameEditor; // Base name of editor as invoked
  542. extern char * pNameTmp; // Pathname of .TMP file ( based on name )
  543. extern char * pNameInit; // Pathname of tools.ini
  544. extern char * pNameHome; // "INIT", or "HOME" if "INIT" not defined
  545. extern char *pComSpec; // name of command processor
  546. extern char *eolText; // eol characters for text files
  547. extern struct cmdDesc cmdUnassigned; // unassigned function
  548. extern struct cmdDesc cmdGraphic; // self editing function
  549. extern char *getlbuf; // pointer to fast read-in buffer
  550. extern unsigned getlsize; // length of buffer
  551. extern int cMacUse; // number of macros in use
  552. extern struct macroInstanceType mi[]; // state of macros
  553. #define MAXEXT 50
  554. extern int cCmdTab; // number of cmd tables
  555. extern PCMD cmdSet[]; // set of cmd tables
  556. extern PSWI swiSet[]; // set of swi tables
  557. extern char *pExtName[]; // set of extension names
  558. // CONSIDER: making pExtNames be or include
  559. // CONSIDER: the handles, such that arg meta
  560. // CONSIDER: load can discard an extension
  561. extern PSCREEN OriginalScreen; // Original screen
  562. extern PSCREEN MepScreen; // Out screen
  563. extern KBDMODE OriginalScreenMode; // Original screen Mode
  564. // **************************************************************
  565. //
  566. // Background threads
  567. //
  568. // **************************************************************
  569. //
  570. // A global critical section is used for synchronizing
  571. // threads
  572. //
  573. extern CRITICAL_SECTION IOCriticalSection;
  574. extern CRITICAL_SECTION UndoCriticalSection;
  575. extern CRITICAL_SECTION ScreenCriticalSection;
  576. #define MAXBTQ 32 // Maximum number of entries in
  577. // background threads queues
  578. //
  579. // Background thread data structure
  580. //
  581. typedef struct BTD {
  582. PFILE pBTFile; // Log file handle
  583. LPBYTE pBTName; // Log file name
  584. flagType flags; // Flags: BT_BUSY and BT_UPDATE
  585. ULONG cBTQ; // # of entries in queue
  586. ULONG iBTQPut; // Index at wich to put next
  587. ULONG iBTQGet; // Index at wich to get next
  588. CRITICAL_SECTION CriticalSection;// Protects critical info
  589. PROCESS_INFORMATION ProcessInfo; // Process information
  590. HANDLE ThreadHandle; // Thread Handle
  591. BOOL ProcAlive; // True if child process
  592. struct {
  593. PFUNCTION pBTJProc; // Procedure to call
  594. LPBYTE pBTJStr; // Command to spawn or parameter
  595. } BTQJob[MAXBTQ]; // Holds queued jobs
  596. struct BTD *pBTNext; // Next BTD in list
  597. } BTD;
  598. //
  599. // Background threads flags
  600. //
  601. #define BT_BUSY 1
  602. #define BT_UPDATE 2
  603. #define fBusy(pBTD) (pBTD->flags & BT_BUSY)
  604. #define UpdLog(pBTD) (pBTD->flags |= BT_UPDATE)
  605. #define NoUpdLog(pBTD) (pBTD->flags &= ~BT_UPDATE)
  606. //
  607. // Background compile and print threads
  608. //
  609. extern BTD *pBTDComp; // Compile thread
  610. extern BTD *pBTDPrint; // Print thread
  611. //
  612. // For dual code
  613. //
  614. #define PFILECOMP pBTDComp->pBTFile
  615. // **************************************************************
  616. //
  617. // Constant strings. Various strings that are used many times are
  618. // defined here once to save space. The values are set in ZINIT.C
  619. //
  620. // Macro versions are also defined to cast to a non-const, for use where
  621. // where only a non-const expression will do.
  622. //
  623. // **************************************************************
  624. extern char rgchComp[]; // "<compile>"
  625. extern char rgchPrint[]; // "<print>"
  626. extern char rgchAssign[]; // "<assign>"
  627. extern char rgchAutoLoad[]; // "m*.mxt" or equiv...
  628. extern char rgchEmpty[]; // ""
  629. extern char rgchInfFile[]; // "<information-file>"
  630. extern char rgchWSpace[]; // our defintion of whitespace
  631. extern char rgchUntitled[]; // "<untitled>"
  632. #define RGCHASSIGN ((char *)rgchAssign)
  633. #define RGCHEMPTY ((char *)rgchEmpty)
  634. #define RGCHWSPACE ((char *)rgchWSpace)
  635. #define RGCHUNTITLED ((char *)rgchUntitled)
  636. typedef struct MSG_TXT{
  637. WORD usMsgNo;
  638. LPBYTE pMsgTxt;
  639. } MSG_TXT;
  640. extern MSG_TXT MsgStr[]; // Message strings
  641. extern flagType fInCleanExit;
  642. extern flagType fSpawned;
  643. #include "meptype.h"
  644. #include "msg.h"
  645. #ifdef FPO
  646. #pragma optimize( "y", off )
  647. #endif