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.

1307 lines
51 KiB

  1. /*
  2. * Copyright Microsoft Corporation, 1987
  3. *
  4. * This Module contains Proprietary Information of Microsoft
  5. * Corporation and should be treated as Confidential.
  6. */
  7. /*
  8. * EXTERN.H: external declarations
  9. */
  10. #include <malloc.h>
  11. #include <memory.h>
  12. #if NOT OSXENIX
  13. #include <io.h>
  14. #include <stdlib.h>
  15. #endif
  16. #include <string.h>
  17. #include <search.h>
  18. #ifdef _MBCS
  19. #define _CRTVAR1
  20. #include <mbctype.h>
  21. #include <mbstring.h>
  22. #define strchr _mbschr
  23. #define strrchr _mbsrchr
  24. #endif
  25. #ifndef DECLSPEC_NORETURN
  26. #if (_MSC_VER >= 1200)
  27. #define DECLSPEC_NORETURN __declspec(noreturn)
  28. #else
  29. #define DECLSPEC_NORETURN
  30. #endif
  31. #endif
  32. /****************************************************************
  33. * *
  34. * External function declarations *
  35. * *
  36. ****************************************************************/
  37. extern void AddContribution(unsigned short gsn,
  38. unsigned short offMin,
  39. unsigned short offMac,
  40. unsigned short cbPad);
  41. extern void AddContributor(SNTYPE gsn,
  42. unsigned long raComdat,
  43. unsigned long size);
  44. extern void NEAR AddLibPath(unsigned short i);
  45. extern void AddLibrary(unsigned char *psbName);
  46. extern void AddComdatUses(APROPCOMDAT*, APROPCOMDAT*);
  47. extern PLTYPE FAR * NEAR AddVmProp (PLTYPE FAR *list, RBTYPE rprop);
  48. extern void NEAR AllocateScratchSpace(void);
  49. extern void NEAR AllocComDat(void);
  50. extern void NEAR AllocSortBuffer(unsigned max, int AOrder);
  51. extern void NEAR AssignAddresses(void);
  52. extern void NEAR AssignDos3Addr(void);
  53. extern void NEAR AssignSegAddr(void);
  54. extern void AttachComdat(RBTYPE vrComdat, SNTYPE gsn);
  55. extern void NEAR BakPat(void);
  56. extern void BigEnSyms(void (*pproc)(APROPNAMEPTR papropName,
  57. RBTYPE rhte,
  58. RBTYPE rprop,
  59. WORD fNewHte),
  60. ATTRTYPE attr);
  61. #if QBLIB
  62. extern void NEAR BldQbSymbols(unsigned short gsnQbSym);
  63. #endif
  64. #if CMDMSDOS
  65. extern void BreakLine(unsigned char *psb,
  66. void (*pfunc)(unsigned char *psb),
  67. char sepchar);
  68. #endif
  69. extern void ChkInput(void);
  70. extern APROPSNPTR CheckClass(APROPSNPTR apropSn, RBTYPE rhteClass);
  71. #if OVERLAYS
  72. extern void CheckOvl(APROPSNPTR apropSn, WORD iovFile);
  73. #endif
  74. #if OEXE
  75. extern void NEAR Check_edata_end(SNTYPE gsnTop, SEGTYPE segTop);
  76. extern void CheckSegmentsMemory(void);
  77. #if INMEM
  78. extern void ChkSum(WORD,BYTE FAR *,FTYPE);
  79. #else
  80. extern void ChkSum(WORD,BYTE *, WORD);
  81. #endif
  82. #endif
  83. #if FALSE
  84. extern void CheckSum (WORD cb, BYTE *pb, WORD fOdd);
  85. #else
  86. #define CheckSum(cb, pb, fOdd)
  87. #endif
  88. #if OSMSDOS
  89. extern void CleanupNearHeap(void);
  90. #endif
  91. extern void NEAR ComDatRc1(void);
  92. extern void NEAR ComDatRc2(void);
  93. extern void CputcQC(int ch);
  94. extern void CputsQC(char *str);
  95. extern void CputcStd(int ch);
  96. extern void CputsStd(char *str);
  97. #if EXE386
  98. extern WORD NEAR CrossingPage(RLCPTR rlcp);
  99. #endif
  100. extern short CURDSK(void);
  101. extern void CtrlC(void);
  102. #if SYMDEB
  103. extern void NEAR DoComdatDebugging(void);
  104. extern void DebPublic(RBTYPE rprop, WORD type);
  105. extern void DebMd2(void);
  106. extern void DeclareStdIds(void);
  107. extern void NEAR Define_edata_end(APROPSNPTR papropSn);
  108. extern void DisplayBanner(void);
  109. extern WORD DoDebSrc(void);
  110. #endif
  111. #if OSEGEXE
  112. extern void NEAR DoIteratedFixups(unsigned short cb,unsigned char *pb);
  113. extern void ProcesNTables(char *pName);
  114. #endif
  115. #if OSMSDOS
  116. extern short Dos3AllocMem(short *pcparMem);
  117. #endif
  118. extern void Dos3FreeMem(short saMem);
  119. extern void NEAR DrivePass(void (NEAR *pProcessPass)(void));
  120. extern void NEAR DupErr(BYTE *sb);
  121. extern void NEAR EmitStub(void);
  122. extern void EndPack(void *prun);
  123. extern void NEAR EndRec(void);
  124. extern PROPTYPE EnterName(BYTE *,ATTRTYPE, WORD);
  125. extern void ErrPrefix(void);
  126. extern RBTYPE NEAR ExtractMin(unsigned n);
  127. extern DECLSPEC_NORETURN void cdecl Fatal (MSGTYPE msg, ...);
  128. extern unsigned char FCHGDSK(int drive);
  129. extern int cdecl FGtAddr(const RBTYPE *rb1,
  130. const RBTYPE *rb2);
  131. extern int cdecl FGtName(const RBTYPE *rb1,
  132. const RBTYPE *rb2);
  133. extern void FindLib(char *sbLib);
  134. extern void NEAR FixBakpat(void);
  135. extern void FixComdatRa(void);
  136. extern void NEAR FixErrSub(MSGTYPE msg,
  137. RATYPE ra,
  138. WORD gsnFrame,
  139. WORD gsnTarget,
  140. RATYPE raTarget,
  141. FTYPE fErr);
  142. extern void NEAR FixOld(void);
  143. extern void NEAR FixNew(void);
  144. #ifdef LEGO
  145. extern void NEAR FixNewKeep(void);
  146. #endif /* LEGO */
  147. extern void NEAR FixOvlData(void);
  148. extern void NEAR FixRc2(void);
  149. extern void flskbd(void);
  150. extern void cdecl FmtPrint(char *fmt, ...);
  151. extern unsigned char fPathChr(char ch);
  152. extern void NEAR fpagcpy(char FAR *,char FAR *);
  153. extern void FreeHandle(void);
  154. extern void NEAR FreeSortBuffer(void);
  155. extern void FreeSymTab(void);
  156. #if EXE386
  157. extern void FillInImportTable(void);
  158. extern void GenImportTable(void);
  159. extern APROPSNPTR GenSeg(unsigned char *sbName,
  160. unsigned char *sbClass,
  161. unsigned char ggr,
  162. unsigned short fPublic);
  163. #else
  164. extern APROPSNPTR NEAR GenSeg(unsigned char *sbName,
  165. unsigned char *sbClass,
  166. unsigned char ggr,
  167. unsigned short fPublic);
  168. #endif
  169. extern void NEAR GetBytes(unsigned char *pb,unsigned short n);
  170. extern void NEAR GetBytesNoLim(unsigned char *pb,unsigned short n);
  171. extern char * NEAR getdicpage(unsigned short pn);
  172. extern WORD GetGsnInfo(GSNINFO *pInfo);
  173. extern AHTEPTR GetHte(RBTYPE rprop);
  174. #if CMDMSDOS
  175. extern void NEAR GetLibAll(unsigned char *sbLib);
  176. extern void NEAR GetLine(unsigned char *pcmdlin,char *prompt);
  177. #endif
  178. extern void GetLineOff(WORD *pLine, RATYPE *pRa);
  179. extern void NEAR GetLocName(unsigned char *psb);
  180. extern void GetLocSb(BYTE *);
  181. #if DEBUG_HEAP_ALLOCS
  182. extern BYTE FAR *GETMEM(unsigned size, char* pFile, int Line);
  183. #define GetMem(x) GETMEM((x), __FILE__, __LINE__)
  184. #define REALLOC(x, y) REALLOC_((x), (y), __FILE__, __LINE__)
  185. extern void *REALLOC_( void*, size_t, char* pFile, int Line);
  186. extern void FreeMem(void*);
  187. #else
  188. extern BYTE FAR *GetMem(unsigned size);
  189. #define REALLOC realloc
  190. #define FreeMem(x) free(x)
  191. #endif
  192. extern unsigned char * NEAR GetPropName(void FAR *ahte);
  193. #if defined(M_I386) OR defined( _WIN32 )
  194. extern WORD cbRec; /* Size of object record in bytes */
  195. extern BSTYPE bsInput; /* Current input file stream */
  196. #else
  197. extern WORD NEAR Gets(void);
  198. #endif
  199. extern RBTYPE NEAR GetSymPtr(unsigned n);
  200. extern unsigned short IFind(unsigned char *sb,unsigned char b);
  201. #if SYMDEB
  202. extern void NEAR InitDeb1(void);
  203. extern void InitDbRhte(void);
  204. extern void InitializeWorld(void);
  205. extern WORD NEAR IsDebSeg(RBTYPE rhteClass, RBTYPE rhteSeg);
  206. #endif
  207. #if USE_REAL
  208. extern int IsDosxnt(void);
  209. extern int IsWin31(void);
  210. #endif
  211. extern void NEAR InitEntTab(void);
  212. extern void InitP2Tabs (void);
  213. #if QBLIB
  214. extern void NEAR InitQbLib(void);
  215. #endif
  216. extern void NEAR InitSort(RBTYPE **buf, WORD *base1, WORD *lim1,
  217. WORD *base2, WORD *lim2 );
  218. extern void InitSym(void);
  219. extern void InitTabs(void);
  220. extern void initvm(void);
  221. #if EXE386
  222. extern void InitVmBase(void);
  223. #endif
  224. extern DECLSPEC_NORETURN void NEAR InvalidObject(void);
  225. extern WORD NEAR GetIndexHard(WORD imin,WORD imax);
  226. extern WORD NEAR GetIndex(WORD imin,WORD imax);
  227. extern void KillRunfile(void);
  228. #if OEXE OR EXE386
  229. extern void NEAR LChkSum(unsigned short cb,unsigned char *pb);
  230. #endif
  231. extern DWORD NEAR LGets(void);
  232. extern void NEAR LibEnv(void);
  233. extern void NEAR LibrarySearch(void);
  234. extern void NEAR LinRec2(void);
  235. extern void NEAR LNmRc1(WORD fLocal);
  236. extern WORD NEAR LookupLibSym(unsigned char *psb);
  237. extern long NEAR MakeHole(long cb);
  238. extern void MkPubSym(unsigned char *sb,
  239. unsigned char ggr,
  240. unsigned short gsn,
  241. RATYPE ra);
  242. extern void NEAR ModRc1(void);
  243. #if EXE386
  244. extern void MoveToVm(unsigned short cb,
  245. unsigned char *obData,
  246. unsigned short seg,
  247. RATYPE ra);
  248. #else
  249. extern void NEAR MoveToVm(unsigned short cb,
  250. unsigned char *obData,
  251. unsigned short seg,
  252. RATYPE ra);
  253. #endif
  254. #if OSEGEXE
  255. extern unsigned short NEAR MpSaRaEto(unsigned short sa, RATYPE ra);
  256. #endif
  257. extern BYTE FAR * NEAR msaNew(SEGTYPE seg);
  258. extern BYTE FAR * NEAR msaOld(SEGTYPE seg);
  259. extern void NewExport(unsigned char *sbEntry,
  260. unsigned char *sbInternal,
  261. unsigned short ordno,
  262. unsigned short flags);
  263. #if EXE386
  264. extern void NewImport(unsigned char *sbEntry,
  265. unsigned long ordEntry,
  266. unsigned char *sbModule,
  267. unsigned char *sbInternal,
  268. unsigned short impFlags);
  269. extern void NEAR NewSeg(unsigned char *sbName,
  270. unsigned char *sbClass,
  271. unsigned short iOvl,
  272. unsigned long flags);
  273. #else
  274. extern void NewImport(unsigned char *sbEntry,
  275. unsigned short ordEntry,
  276. unsigned char *sbModule,
  277. unsigned char *sbInternal);
  278. extern void NEAR NewSeg(unsigned char *sbName,
  279. unsigned char *sbClass,
  280. unsigned short iOvl,
  281. unsigned short flags);
  282. #endif
  283. #if OSEGEXE
  284. extern BSTYPE LinkOpenExe(BYTE *sbExe);
  285. #endif
  286. #if SYMDEB
  287. extern void OutDebSections(void);
  288. #endif
  289. extern void NEAR OutDos3Exe(void);
  290. extern void NEAR OutEntTab(void);
  291. extern void cdecl OutError(MSGTYPE msg, ...);
  292. extern void OutFileCur(BSTYPE bs);
  293. extern void NEAR OutFixTab(SATYPE sa);
  294. extern void OutHeader(struct exe_hdr *prun);
  295. #if FEXEPACK
  296. extern void OutPack(unsigned char *pb, unsigned cb);
  297. extern long Out5Pack(SATYPE sa, unsigned short *packed);
  298. #endif
  299. extern void OutputIlk(void);
  300. extern void NEAR OutSas(void *mpsasec);
  301. extern void NEAR OutSegExe(void);
  302. #if EXE386
  303. extern void NEAR OutExe386(void);
  304. #endif
  305. extern void cdecl OutWarn (MSGTYPE msg, ...);
  306. extern void OutWord(unsigned short x);
  307. #define OutVm(va,cb) WriteExe(va, cb)
  308. extern void NEAR PadToPage(unsigned short align);
  309. extern void NEAR PatchStub(long lfahdr, long lfaseg);
  310. extern void NEAR pagein(REGISTER char *pb, unsigned short fpn);
  311. extern void NEAR pageout(REGISTER char *pb, unsigned short fpn);
  312. extern void ParseCmdLine(int argc,char * *argv);
  313. extern void ParseDeffile(void);
  314. extern void PeelFlags(unsigned char *psb);
  315. extern void * PInit(void);
  316. extern void * PAlloc(void *, int);
  317. extern void PFree(void *);
  318. extern void PReinit(void *);
  319. extern void PrintGroupOrigins(APROPNAMEPTR papropGroup,
  320. RBTYPE rhte,
  321. RBTYPE rprop,
  322. WORD fNewHte);
  323. extern void PrintMap(void);
  324. #if QBLIB
  325. extern void NEAR PrintQbStart(void);
  326. #endif
  327. extern void ProcFlag(unsigned char *psb);
  328. extern void ProcObject(unsigned char *psbObj);
  329. extern void NEAR ProcP1(void);
  330. extern void NEAR ProcP2(void);
  331. extern int cdecl PromptQC(unsigned char *sbNew,
  332. MSGTYPE msg,
  333. int msgparm,
  334. MSGTYPE pmt,
  335. int pmtparm);
  336. extern int cdecl PromptStd(unsigned char *sbNew,
  337. MSGTYPE msg,
  338. int msgparm,
  339. MSGTYPE pmt,
  340. int pmtparm);
  341. extern PROPTYPE NEAR PropAdd(RBTYPE rhte,
  342. unsigned char attr);
  343. extern PROPTYPE NEAR PropRhteLookup(RBTYPE rhte,
  344. unsigned char attr,
  345. unsigned char fCreate);
  346. extern RBTYPE NEAR RhteFromProp(APROPPTR aprop);
  347. extern PROPTYPE NEAR PropSymLookup(BYTE *, ATTRTYPE, WORD);
  348. #if QBLIB
  349. extern int cdecl QbCompSym(const RBTYPE *prb1,
  350. const RBTYPE *prb2);
  351. #endif
  352. #if USE_REAL
  353. extern int RelockConvMem(void);
  354. extern void RealMemExit(void);
  355. extern int MakeConvMemPageable(void);
  356. #endif
  357. #if AUTOVM
  358. extern RBTYPE NEAR RbAllocSymNode(unsigned short cb);
  359. #else
  360. extern RBTYPE NEAR RbAllocSymNode(unsigned short cb);
  361. #endif
  362. extern char * ReclaimVM(unsigned short cnt);
  363. extern void ReclaimScratchSpace(void);
  364. extern void NEAR RecordSegmentReference(SEGTYPE seg,
  365. RATYPE ra,
  366. SEGTYPE segDst);
  367. extern int NEAR relscr(void);
  368. extern void NEAR ReleaseRlcMemory(void);
  369. extern void resetmax(void);
  370. #if SYMDEB
  371. extern void SaveCode(SNTYPE gsn, DWORD cb, DWORD raInit);
  372. #endif
  373. #if OSEGEXE
  374. #if EXE386
  375. extern RATYPE NEAR SaveFixup(SATYPE obj, DWORD page, RLCPTR rlcp);
  376. extern void EmitFixup(SATYPE objTarget, DWORD raTarget,
  377. WORD locKind, DWORD virtAddr);
  378. #else
  379. extern RATYPE NEAR SaveFixup(unsigned short saLoc,
  380. RLCPTR rlcp);
  381. #endif
  382. #endif
  383. extern unsigned short SaveInput(unsigned char *psbFile,
  384. long lfa,
  385. unsigned short ifh,
  386. unsigned short iov);
  387. extern void SavePropSym(APROPNAMEPTR prop,
  388. RBTYPE rhte,
  389. RBTYPE rprop,
  390. WORD fNewHte);
  391. extern WORD SbCompare(unsigned char *ps1,
  392. unsigned char *ps2,
  393. unsigned short fncs);
  394. extern unsigned char SbSuffix(unsigned char *sb,
  395. unsigned char *sbSuf,
  396. unsigned short fIgnoreCase);
  397. extern void SbUcase(unsigned char *sb);
  398. extern int NEAR SearchPathLink(char FAR *lpszPath, char *pszFile, int ifh, WORD fStripPath);
  399. extern void SetDosseg(void);
  400. extern void NEAR SetupOverlays(void);
  401. extern BSTYPE NEAR ShrOpenRd(char *pname);
  402. #if NEWSYM
  403. #if NOT NOASM AND (CPU8086 OR CPU286)
  404. extern void SmallEnSyms(void (*pproc)(APROPNAMEPTR papropName,
  405. RBTYPE rhte,
  406. RBTYPE rprop,
  407. WORD fNewHte),
  408. ATTRTYPE attr);
  409. #endif
  410. #endif /* NEWSYM */
  411. #if NEWIO
  412. extern int NEAR SmartOpen(char *sbInput, int ifh);
  413. #endif
  414. #if EXE386
  415. extern void SortPtrTable(void);
  416. #endif
  417. extern void NEAR SortSyms(ATTRTYPE attr,
  418. void (*savf)(APROPNAMEPTR prop,
  419. RBTYPE rhte,
  420. RBTYPE rprop,
  421. WORD fNewHte),
  422. int (cdecl *scmpf)(const RBTYPE *sb1,
  423. const RBTYPE *sb2),
  424. void (NEAR *hdrf)(ATTRTYPE attr),
  425. void (NEAR *lstf)(WORD irbMac,
  426. ATTRTYPE attr));
  427. extern void NEAR Store(RBTYPE element);
  428. #if SYMDEB OR OVERLAYS
  429. extern unsigned char * StripDrivePath(unsigned char *sb);
  430. #endif
  431. #if WIN_3
  432. void cdecl SysFatal (MSGTYPE msg);
  433. #endif
  434. extern void StripPath(unsigned char *sb);
  435. extern char * cdecl swapin(long vp,unsigned short fp);
  436. extern void termvm(void);
  437. extern long NEAR TypLen(void);
  438. extern void UndecorateSb (char FAR* sbSrc, char FAR* sbDst, unsigned cbDst);
  439. extern void UpdateComdatContrib(
  440. #if ILINK
  441. WORD fIlk,
  442. #endif
  443. WORD fMap);
  444. extern void UpdateFileParts(unsigned char *psbOld,
  445. unsigned char *psbUpdate);
  446. extern void cdecl UserKill(void);
  447. extern WORD NEAR WGetsHard(void);
  448. extern WORD NEAR WGets(void);
  449. #if CMDMSDOS
  450. extern void NEAR ValidateRunFileName(BYTE *ValidExtension,
  451. WORD ForceExtension,
  452. WORD WarnUser);
  453. #endif
  454. #if ( NOT defined( M_I386 ) ) AND ( NOT defined( _WIN32 ) )
  455. extern void WriteExe(void FAR *pb, unsigned cb);
  456. #endif
  457. extern void WriteZeros(unsigned cb);
  458. #if EXE386
  459. extern DWORD WriteExportTable(DWORD *expSize, DWORD timestamp);
  460. extern DWORD WriteImportTable(DWORD *impSize, DWORD timestamp, DWORD *mpsaLfa);
  461. #endif
  462. extern unsigned short zcheck(unsigned char *pb,unsigned short cb);
  463. extern int NEAR yyparse(void);
  464. /* No argument type lists */
  465. extern char FAR *brkctl(); /* Xenix call for new memory */
  466. extern long NEAR msa386(SATYPE sa);
  467. /*
  468. * Version-dependent macro and function declarations. Hide some #ifdef's
  469. * from the source code.
  470. */
  471. #if NEWSYM
  472. #if AUTOVM
  473. extern BYTE FAR * NEAR FetchSym(RBTYPE rb, WORD fDirty);
  474. extern BYTE FAR * NEAR FetchSym1(RBTYPE rb, WORD fDirty);
  475. #define MARKVP() markvp()
  476. #else
  477. #define FetchSym(a,b) (a)
  478. #define MARKVP()
  479. #define markvp()
  480. #endif
  481. #if defined(M_I386) OR defined( _WIN32 )
  482. #define GetFarSb(a) (a)
  483. #else
  484. extern char *GetFarSb(RBTYPE psb);
  485. #endif
  486. #else
  487. extern BYTE *FetchSym(RBTYPE,FTYPE);
  488. #define MARKVP() markvp()
  489. #define GetFarSb(a) (BYTE *)(a)
  490. #endif
  491. #if NEWSYM
  492. extern FTYPE NEAR SbNewComp(BYTE *, BYTE FAR *, FTYPE);
  493. extern void OutSb(BSTYPE f, BYTE *pb);
  494. #else
  495. #define SbNewComp SbCompare
  496. #endif
  497. #if ECS
  498. extern int GetTxtChr(BSTYPE bs);
  499. #else
  500. #define GetTxtChr(a) getc(a)
  501. #endif
  502. #if NEWSYM AND NOT NOASM AND (CPU286 OR CPU8086)
  503. extern void (*pfEnSyms)(void (*pproc)(APROPNAMEPTR papropName,
  504. RBTYPE rhte,
  505. RBTYPE rprop,
  506. WORD fNewHte),
  507. ATTRTYPE attr);
  508. #define EnSyms(a,b) (*pfEnSyms)(a,b)
  509. #else
  510. #define EnSyms(a,b) BigEnSyms(a,b)
  511. #endif
  512. #if OSMSDOS
  513. extern FTYPE fNoprompt;
  514. #else
  515. #define fNoprompt TRUE
  516. #endif
  517. #if CPU8086 OR CPU286
  518. #define FMALLOC _fmalloc
  519. #define FFREE _ffree
  520. #define FMEMSET _fmemset
  521. #define FREALLOC _frealloc
  522. #define FMEMCPY _fmemcpy
  523. #define FSTRLEN _fstrlen
  524. #define FSTRCPY _fstrcpy
  525. #else
  526. #define FMALLOC malloc
  527. #define FFREE free
  528. #define FMEMSET memset
  529. #define FREALLOC realloc
  530. #define FMEMCPY memcpy
  531. #define FSTRLEN strlen
  532. #define FSTRCPY strcpy
  533. #endif
  534. #if WIN_3
  535. #define EXIT WinAppExit
  536. extern FTYPE fSeverity; /* Severity for QW_ERROR message */
  537. extern void ReportVersion(void );
  538. extern void ErrorMsg( char *pszError );
  539. extern void __cdecl ErrMsgWin (char *fmt);
  540. extern void WErrorMsg( char *pszError );
  541. extern void WinAppExit( short RetCode );
  542. extern void ProcessWinArgs( char FAR *pszCmdLine );
  543. extern void ParseLinkCmdStr( void );
  544. extern void ReportProgress( char *pszStatus );
  545. extern void SendPacket(void *pPacket);
  546. extern void __cdecl StatMsgWin (char *fmt, int p1);
  547. extern void StatHdrWin ( char *pszHdr );
  548. extern void WinYield( void );
  549. extern void CputcWin(int ch);
  550. extern void CputsWin(char *str);
  551. #else
  552. #define EXIT exit
  553. #endif
  554. /****************************************************************
  555. * *
  556. * External data declarations *
  557. * *
  558. ****************************************************************/
  559. extern char FAR *lpszLink;
  560. extern char FAR *lpszPath;
  561. extern char FAR *lpszTMP;
  562. extern char FAR *lpszLIB;
  563. extern char FAR *lpszQH;
  564. extern char FAR *lpszHELPFILES;
  565. extern char FAR *lpszCmdLine;
  566. #if OSEGEXE
  567. extern RBTYPE procOrder; /* Procedure order as defined in .DEF file */
  568. #endif
  569. extern BSTYPE bsErr; /* Error message file stream */
  570. extern BSTYPE bsInput; /* Current input file stream */
  571. extern BSTYPE bsLst; /* Listing (map) file stream */
  572. extern BSTYPE bsRunfile; /* Executable file stream */
  573. extern WORD cbBakpat; /* # bytes in backpatch area */
  574. extern WORD cbRec; /* Size of object record in bytes */
  575. extern WORD cErrors; /* Number of non-fatal errors */
  576. extern int (cdecl *cmpf)(const RBTYPE *sb1,
  577. const RBTYPE *sb2);
  578. /* Pointer to sorting comparator */
  579. #if OMF386
  580. extern FTYPE f386; /* True if 386 binary */
  581. #endif
  582. #if (OSEGEXE AND defined(LEGO)) OR EXE386
  583. extern FTYPE fKeepFixups; /* TRUE if FLAT offset fixups have to be poropagated to the .EXE file */
  584. #endif
  585. #if EXE386
  586. extern SNTYPE gsnImport; /* Global index of Import Address Table segment */
  587. extern GRTYPE ggrFlat; /* Group number of pseudo-group FLAT */
  588. extern FTYPE fFullMap; /* More map information */
  589. extern FTYPE fKeepVSize; /* TRUE if VSIZE to be set */
  590. #endif
  591. extern WORD extMac; /* Count of EXTDEFs */
  592. extern WORD extMax; /* Maximum number of EXTDEFs */
  593. extern int ExitCode; /* Linker exit code */
  594. extern FTYPE fFullMap; /* More map information */
  595. extern FTYPE fCommon; /* True if any communal variables */
  596. extern FTYPE fC8IDE; /* True if running under C8 IDE */
  597. extern FTYPE fDelexe; /* True if /DELEXECUTABLE is on */
  598. extern FTYPE fDrivePass; /* True if executing DrivePass() */
  599. extern FTYPE fFarCallTrans; /* True if /FARCALLTRANSLATION on */
  600. extern FTYPE fFarCallTransSave;
  601. /* Previous state of fFarCallTrans */
  602. extern FTYPE fIgnoreCase; /* True if ignoring case */
  603. extern FTYPE fInOverlay; /* True if parsing overlay spec */
  604. extern FTYPE fLibPass; /* True if in library pass */
  605. extern FTYPE fLibraryFile; /* True if input from library */
  606. extern FTYPE fListAddrOnly; /* True if sorting by address only */
  607. extern FTYPE fLstFileOpen; /* True of map file open */
  608. extern FTYPE fScrClosed; /* True if scratch file closed */
  609. extern FTYPE fSkipFixups; /* True if skipping COMDAT and its fixups */
  610. extern FTYPE fUndefinedExterns;
  611. /* True if any unresolved externals */
  612. extern FTYPE fExeStrSeen; /* True if EXESTR comment seen */
  613. extern FTYPE fPackFunctions; /* True if elimination uncalled COMDATs */
  614. #if TCE
  615. extern FTYPE fTCE; /* True if /PACKF:MAX = Transitive Comdat Elimination */
  616. #endif
  617. #if USE_REAL
  618. extern FTYPE fUseReal; /* True if using conv memory for paging */
  619. extern FTYPE fSwNoUseReal; /* True if switch /NOUSEREAL set */
  620. #endif
  621. #if O68K
  622. extern FTYPE f68k; /* True if target is a 68k */
  623. extern FTYPE fTBigEndian; /* True if target is big-endian */
  624. extern BYTE iMacType; /* Type of Macintosh exe */
  625. #endif /* O68K */
  626. extern GRTYPE ggrDGroup; /* Group number of DGROUP */
  627. extern GRTYPE ggrMac; /* Count of global GRPDEFs */
  628. extern GRTYPE grMac; /* Count of local GRPDEFs */
  629. extern SNTYPE gsnMac; /* Count of global SEGDEFs */
  630. extern SNTYPE gsnMax; /* Maximum number of SEGDEFs */
  631. extern SNTYPE gsnStack; /* Glob. SEGDEF no. of STACK segment */
  632. extern SNTYPE gsnText; /* Global SEGDEF for _TEXT segment */
  633. extern WORD ifhLibCur; /* File index of current library */
  634. extern WORD ifhLibMac; /* Count of library files */
  635. extern long lfaLast; /* Last file position */
  636. extern WORD lnameMac; /* Count of LNAMEs */
  637. extern WORD lnameMax; /* Max count of LNAMEs */
  638. extern unsigned char LINKREV; /* Release number */
  639. extern unsigned char LINKVER; /* Version number */
  640. extern WORD modkey; /* Module ID key */
  641. extern SNTYPE *mpextgsn; /* f(EXTDEF no.) = glob. SEGDEF no. */
  642. extern RATYPE *mpextra; /* f(EXTDEF no.) = symbol offset */
  643. extern RBTYPE FAR *mpextprop; /* f(EXTDEF no.) = external name property */
  644. extern SNTYPE mpggrgsn[]; /* f(glob GRPDEF) = glob. SEGDEF no. */
  645. extern GRTYPE *mpgrggr; /* f(loc. GRPDEF #) = glob. GRPDEF # */
  646. #if FAR_SEG_TABLES
  647. extern RATYPE FAR *mpgsndra; /* f(glob SEGDEF) = segment offset */
  648. extern BYTE FAR *mpgsnfCod; /* f(glob SEGDEF) = true if code */
  649. extern RBTYPE FAR *mpgsnrprop; /* f(glob SEGDEF) = property cell */
  650. extern SEGTYPE FAR *mpgsnseg; /* f(glob SEGDEF) = segment number */
  651. extern RATYPE FAR *mpsegraFirst; /* f(segment #) = offset of 1st byte */
  652. extern SATYPE FAR *mpsegsa; /* f(seg) = sa */
  653. extern BYTE FAR * FAR *mpsegMem; /* f(segment) = memory image */
  654. extern BYTE FAR * FAR *mpsaMem; /* f(segment) = memory image */
  655. #else
  656. extern RATYPE *mpgsndra; /* f(glob SEGDEF) = segment offset */
  657. extern BYTE *mpgsnfCod; /* f(glob SEGDEF) = true if code */
  658. extern RBTYPE *mpgsnrprop; /* f(glob SEGDEF) = property cell */
  659. extern SEGTYPE *mpgsnseg; /* f(glob SEGDEF) = segment number */
  660. extern RATYPE *mpsegraFirst; /* f(segment #) = offset of 1st byte */
  661. extern SATYPE *mpsegsa; /* f(seg) = sa */
  662. #endif
  663. extern SNTYPE *mpsngsn; /* f(local SEGDEF) = global SEGDEF */
  664. extern RBTYPE mpifhrhte[]; /* f(lib. index) = library name */
  665. extern long *mpitypelen; /* f(TYPDEF no.) = type length */
  666. extern WORD *mpityptyp; /* f(TYPDEF no.) = TYPDEF no. */
  667. extern RBTYPE FAR *mplnamerhte; /* f(LNAME no.) = hash table addr */
  668. extern BYTE *psbRun; /* Name of run file */
  669. extern WORD pubMac; /* Count of PUBDEFs */
  670. extern APROPCOMDAT *pActiveComdat;
  671. extern int QCExtDefDelta; /* QC incremental compilation support */
  672. extern int QCLinNumDelta; /* EXTDEF and LINNUM deltas */
  673. extern WORD symMac; /* Number of symbols defined */
  674. extern long raStart; /* Program starting address */
  675. #if NOT NEWSYM OR AUTOVM
  676. #if AUTOVM
  677. extern WORD rbMacSyms;
  678. #else
  679. extern RBTYPE rbMacSyms; /* Count of symbol table entries */
  680. #endif
  681. #endif
  682. extern RECTTYPE rect; /* Current record type */
  683. #if RGMI_IN_PLACE
  684. extern BYTE *rgmi;
  685. extern BYTE bufg[DATAMAX + 4];
  686. #else
  687. extern BYTE rgmi[DATAMAX + 4];
  688. #define bufg rgmi
  689. #endif
  690. /* Array of code or data */
  691. extern RBTYPE rhteBegdata; /* "BEGDATA" */
  692. extern RBTYPE rhteBss; /* "BSS" */
  693. extern RBTYPE rhteFirstObject;/* Name of first object file */
  694. extern RBTYPE rhteRunfile; /* Name of run file */
  695. extern RBTYPE rhteStack; /* "STACK" */
  696. extern RBTYPE rprop1stFile; /* Property cell of 1st file */
  697. extern RBTYPE rprop1stOpenFile;/* Property cell of 1st open file */
  698. extern RBTYPE r1stFile; /* 1st input file */
  699. extern SBTYPE sbModule; /* Name of current module */
  700. extern SEGTYPE segCodeLast; /* Last (highest) code segment */
  701. extern SEGTYPE segDataLast; /* Last (highest) data segment */
  702. extern SEGTYPE segLast; /* Last (highest) segment */
  703. extern SEGTYPE segStart; /* Program starting segment */
  704. extern WORD snkey; /* SEGDEF ID key */
  705. extern SNTYPE snMac; /* Local count of SEGDEFs */
  706. extern WORD typMac; /* Local count of TYPDEFs */
  707. extern WORD vcbData; /* # bytes in data record */
  708. extern WORD vcln; /* # line-no entries on line */
  709. extern FTYPE vfCreated; /* True if symbol property created */
  710. extern FTYPE vfLineNos; /* True if line numbers requested */
  711. extern FTYPE vfMap; /* True if public symbols requeste */
  712. extern FTYPE vfNewOMF; /* True if OMF extensions */
  713. extern FTYPE vfNoDefaultLibrarySearch;
  714. /* True if not searching def. libs. */
  715. extern FTYPE vfPass1; /* True if executing Pass 1 */
  716. extern SNTYPE vgsnCur; /* SEGDEF no. of current segment */
  717. extern SNTYPE vgsnLineNosPrev;/* Previous SEGDEF no. for linnums */
  718. extern int vmfd; /* VM scratch file handle */
  719. #if EXE386
  720. extern DWORD vpageCur; /* Current object page number */
  721. #endif
  722. extern RATYPE vraCur; /* Current data record offset */
  723. extern RECTTYPE vrectData; /* Type of current data record */
  724. extern RBTYPE vrhte; /* Address of hash table entry */
  725. extern RBTYPE vrhteCODEClass; /* "CODE" */
  726. extern RBTYPE vrhteFile; /* Name of current file */
  727. extern RBTYPE vrprop; /* Address of property cell */
  728. extern RBTYPE vrpropFile; /* Prop. cell of current file */
  729. extern RBTYPE vrpropTailFile; /* Prop. cell of last file */
  730. extern SEGTYPE vsegCur; /* Current segment */
  731. extern WORD ExeStrLen; // Length of EXE strings in buffer
  732. extern WORD ExeStrMax; // Length of EXE strings buffer
  733. extern char FAR *ExeStrBuf; // EXE strings buffer
  734. #if FDEBUG
  735. extern FTYPE fDebug; /* True if /INFORMATION on */
  736. #endif
  737. #if CMDXENIX
  738. extern WORD symlen; /* Maximum symbol length */
  739. #endif
  740. #if OSMSDOS
  741. extern char bigbuf[LBUFSIZ];/* File I/O buffer */
  742. extern FTYPE fPauseRun; /* True if /PAUSE */
  743. extern BYTE chRunFile; /* Run file drive LETTER */
  744. extern BYTE chListFile; /* List file drive NUMBER */
  745. extern RBTYPE rhteLstfile; /* Name of list file */
  746. extern BYTE DskCur; /* Default drive number */
  747. #endif
  748. #if C8_IDE
  749. extern char msgBuf[]; /* Message buffer */
  750. #endif
  751. #if LIBMSDOS
  752. extern long libHTAddr; /* Offset of dictionary */
  753. #endif
  754. #if SYMDEB
  755. extern FTYPE fSkipPublics; /* True if no public subsection */
  756. extern FTYPE fSymdeb; /* True if /CODEVIEW */
  757. extern FTYPE fCVpack; /* True if CV packing requested */
  758. extern FTYPE fTextMoved; /* True if /DOSSEG & !/NONULLS */
  759. extern int NullDelta; /* _TEXT was moved by so many bytes */
  760. extern SEGTYPE segDebFirst; /* First debug segment */
  761. extern SEGTYPE segDebLast; /* Last debug segment */
  762. extern FTYPE fDebSeg; /* True if datarec from debug segment */
  763. extern WORD ObjDebTotal; /* Total number of OBJ modules with debug info */
  764. extern RBTYPE rhteDebSrc; /* Class "DEBSRC" virt addr */
  765. extern RBTYPE rhteDebSym; /* Class "DEBSYM" virt addr */
  766. extern RBTYPE rhteDebTyp; /* Class "DEBTYP" virt addr */
  767. extern RBTYPE rhteTypes;
  768. extern RBTYPE rhteSymbols;
  769. extern RBTYPE rhte0Types;
  770. extern RBTYPE rhte0Symbols;
  771. #if OSEGEXE
  772. extern WORD cbImpSeg; /* Size of $$IMPORTS segment */
  773. extern SNTYPE gsnImports; /* $$IMPORTS global segment number */
  774. extern char bufExportsFileName[]; /* Name of exports file */
  775. #endif
  776. #endif
  777. #if OSEGEXE
  778. extern SNTYPE gsnAppLoader; /* Aplication loader global segment number */
  779. extern RBTYPE vpropAppLoader; /* Pointer to application loader name */
  780. #if EXE386
  781. extern DWORD hdrSize; /* Default size of .EXE header */
  782. extern DWORD virtBase; /* Virtual base address of memory image */
  783. extern DWORD cbEntTab; /* Count of bytes in Export Address Table */
  784. extern DWORD cbAuxTab; /* Count of bytes in Auxiliary Data Table */
  785. extern DWORD cbNamePtr; /* Count of bytes in Export Name Pointer Table */
  786. extern DWORD cbOrdinal; /* Count of bytes in Export Ordinal Table */
  787. extern DWORD cbExpName; /* Count of bytes in Export Name Table */
  788. extern WORD cGateSel; /* Number of selectors required by call-gate exports */
  789. extern DWORD cbImports; /* # bytes in Imported Names table */
  790. extern DWORD cbImportsMod; /* # bytes in Imported Module Names table */
  791. extern DWORD *mpsaVMArea; /* VM area for AREASA(sa) */
  792. extern DWORD *mpsaBase; /* Base virtual address of memory object */
  793. extern WORD cChainBuckets; /* Count of entry table chain buckets */
  794. extern DWORD cbStack; /* Reserved size of stack in bytes */
  795. extern DWORD cbStackCommit; /* Commited size of stack in bytes */
  796. extern DWORD cbHeap; /* Reserved size of heap in bytes */
  797. extern DWORD cbHeapCommit; /* Commited size of heap in bytes */
  798. #else
  799. extern WORD cbEntTab; /* Count of bytes in Entry Table */
  800. extern WORD cbImports; /* # bytes in Imported Names table */
  801. extern WORD cbHeap; /* Size of heap in bytes */
  802. extern WORD cbStack; /* Size of stack in bytes */
  803. #endif
  804. extern WORD cFixupBuckets; /* Count of entry table buckets */
  805. extern long chksum32; /* Long checksum */
  806. extern WORD cMovableEntries;/* Count of movable entries */
  807. #if EXE386
  808. extern DWORD dfCode; /* Default code segment attributes */
  809. extern DWORD dfData; /* Default data segment attributes */
  810. #else
  811. extern WORD dfCode; /* Default code segment attributes */
  812. extern WORD dfData; /* Default data segment attributes */
  813. #endif
  814. extern WORD expMac; /* Count of exported names */
  815. extern FTYPE fHeapMax; /* True if heap size = 64k - size of DGROUP */
  816. extern FTYPE fRealMode; /* True if REALMODE specified */
  817. extern FTYPE fStub; /* True if DOS3 stub given */
  818. extern FTYPE fWarnFixup; /* True if /WARNFIXUP */
  819. extern BYTE TargetOs; /* Target operating system */
  820. #if EXE386
  821. extern BYTE TargetSubsys; /* Target operating subsystem */
  822. extern BYTE UserMajorVer; /* User program version */
  823. extern BYTE UserMinorVer; /* User program version */
  824. #endif
  825. extern BYTE ExeMajorVer; /* Executable major version number */
  826. extern BYTE ExeMinorVer; /* Executable minor version number */
  827. extern EPTYPE FAR * FAR *htsaraep; /* Hash SA:RA to entry point */
  828. extern DWORD FAR *mpsacb; /* f(sa) = # bytes */
  829. #if O68K
  830. extern DWORD *mpsadraDP; /* offset from start of segment to DP */
  831. #endif
  832. extern DWORD FAR *mpsacbinit; /* f(sa) = # initialized bytes */
  833. #if EXE386
  834. extern DWORD *mpsacrlc; /* f(sa) = # relocations */
  835. extern DWORD *mpsaflags; /* f(sa) = segment attributes */
  836. extern WORD *mpextflags; /* f(glob. EXTDEF) = flags */
  837. #else
  838. extern RLCHASH FAR * FAR *mpsaRlc; /* f(sa) = relocations hash vector */
  839. extern WORD FAR *mpsaflags; /* f(sa) = segment attributes */
  840. extern BYTE FAR *mpextflags; /* f(glob. EXTDEF) = flags */
  841. #endif
  842. extern WORD raChksum; /* Offset for checksum */
  843. extern RBTYPE rhteDeffile; /* Name of definitions file */
  844. extern RBTYPE rhteModule; /* Name of module */
  845. extern RBTYPE rhteStub; /* Name of DOS3 stub program */
  846. extern WORD fileAlign; /* Segment alignment shift count */
  847. #if EXE386
  848. extern WORD pageAlign; /* Page alignment shift count */
  849. extern WORD objAlign; /* Memory object alignment shift count */
  850. #endif
  851. extern SATYPE saMac; /* Count of physical segments */
  852. extern WORD vepMac; /* Count of entry point records */
  853. #if EXE386
  854. extern WORD vFlags; /* Image flags */
  855. extern WORD dllFlags; /* DLL flags */
  856. #else
  857. extern WORD vFlags; /* Program flags word */
  858. #endif
  859. extern BYTE vFlagsOthers; /* Other program flags */
  860. #endif /* OSEGEXE */
  861. extern FTYPE fExePack; /* True if /EXEPACK */
  862. #if PCODE
  863. extern FTYPE fMPC;
  864. extern FTYPE fIgnoreMpcRun; /* True if /PCODE:NOMPC */
  865. #endif
  866. #if ODOS3EXE
  867. extern FTYPE fBinary; /* True if producing .COM file */
  868. extern WORD cparMaxAlloc; /* Max # paragraphs to ask for */
  869. extern WORD csegsAbs; /* Number of absolute segments */
  870. extern WORD dosExtMode; /* DOS extender mode */
  871. extern FTYPE fNoGrpAssoc; /* True if ignoring group association */
  872. extern SEGTYPE segResLast; /* Number of highest resident segment */
  873. extern WORD vchksum; /* DOS3 checksum word */
  874. extern FTYPE vfDSAlloc; /* True if allocating DGROUP high */
  875. #if FEXEPACK
  876. extern FRAMERLC FAR mpframeRlc[]; /* f(frame number) = run time relocs */
  877. #endif
  878. #endif /* ODOS3EXE */
  879. #if OVERLAYS
  880. extern FTYPE fOverlays; /* True if overlays specified */
  881. extern FTYPE fOldOverlay; /* True if /OLDOVERLAY set */
  882. extern FTYPE fDynamic; /* True if dynamic overlays */
  883. extern SNTYPE gsnOvlData; /* Global SEGDEF of OVERLAY_DATA */
  884. extern SNTYPE gsnOverlay; /* Global SEGDEF of OVERLAY_THUNKS */
  885. extern SNTYPE FAR *htgsnosn; /* Hash(glob SEGDEF) = overlay segnum */
  886. extern SNTYPE FAR *mposngsn; /* f(ovl segnum) = global SEGDEF */
  887. extern IOVTYPE FAR *mpsegiov; /* f(seg number) = overlay number */
  888. extern RUNRLC FAR *mpiovRlc; /* f(overlay number) = run time relocs */
  889. extern ALIGNTYPE FAR *mpsegalign; /* f(seg number) = alignment type */
  890. extern SNTYPE osnMac; /* Count of overlay segments */
  891. extern BYTE vintno; /* Overlay interrupt number */
  892. extern WORD iovFile; /* Overlay number of input file */
  893. extern WORD iovMac; /* Count of overlays */
  894. extern WORD ovlThunkMax; /* Number of thunks that will fit into thunk segment */
  895. extern WORD ovlThunkMac; /* Current number of allocated thunks */
  896. #else
  897. #define iovMac 0
  898. #endif
  899. #if OIAPX286
  900. extern long absAddr; /* Absolute program starting address */
  901. extern FTYPE fPack; /* True if packing segments */
  902. extern SATYPE *mpstsa; /* f(seg table number) = selector */
  903. extern SATYPE stBias; /* Segment selector bias */
  904. extern SATYPE stDataBias; /* Data segment selector bias */
  905. extern SATYPE stLast; /* Last segment table entry */
  906. extern WORD stMac; /* Count of seg table entries */
  907. #if EXE386
  908. extern WORD xevmod; /* Virtual module information */
  909. extern RATYPE rbaseText; /* Text relocation factor */
  910. extern RATYPE rbaseData; /* Data relocation factor */
  911. extern FTYPE fPageswitch; /* True if -N given */
  912. extern BYTE cblkPage; /* # 512-byte blocks in pagesize */
  913. #endif
  914. #endif
  915. #if OIAPX286 OR ODOS3EXE
  916. extern GRTYPE *mpextggr; /* f(EXTDEF) = global GRPDEF */
  917. extern long FAR *mpsegcb; /* f(segment number) = size in bytes */
  918. extern BYTE FAR *mpsegFlags; /* f(segment number) = flags */
  919. extern char *ompimisegDstIdata;
  920. /* pointer to LIDATA relocations */
  921. #endif
  922. #if DOSEXTENDER AND NOT WIN_NT
  923. extern WORD cdecl _fDosExt; /* TRUE if running under DOS extender */
  924. #endif
  925. #if OXOUT OR OIAPX286
  926. extern FTYPE fIandD; /* True if "pure" (-i) */
  927. extern FTYPE fLarge; /* True if FAR data */
  928. extern FTYPE fLocals; /* True if including local symbols */
  929. extern FTYPE fMedium; /* True if FAR code */
  930. extern FTYPE fMixed; /* True if mixed model */
  931. extern FTYPE fSymbol; /* True if including symbol table */
  932. extern WORD xever; /* Xenix version number */
  933. #endif
  934. #if WIN_3
  935. #define fZ1 TRUE
  936. #else
  937. #if QCLINK
  938. extern FTYPE fZ1;
  939. #endif
  940. #endif
  941. #if QCLINK OR Z2_ON
  942. extern FTYPE fZ2;
  943. #endif
  944. #if ILINK
  945. extern FTYPE fZincr;
  946. extern FTYPE fQCIncremental;
  947. extern FTYPE fIncremental;
  948. extern WORD imodFile;
  949. extern WORD locMac; /* count of LPUBDEFs */
  950. extern WORD imodCur;
  951. #endif
  952. extern WORD cbPadCode; /* code padding size */
  953. extern WORD cbPadData; /* data padding size */
  954. #if OEXE
  955. extern FTYPE fDOSExtended;
  956. extern FTYPE fNoNulls; /* True if /NONULLS given */
  957. extern FTYPE fPackData; /* True if /PACKDATA given */
  958. extern FTYPE fPackSet; /* True if /PACK or /NOPACK given */
  959. extern FTYPE fSegOrder; /* True if special DOS seg order */
  960. extern DWORD packLim; /* Code seg packing limit */
  961. extern DWORD DataPackLim; /* Data seg packing limit */
  962. #endif
  963. #if OSEGEXE AND ODOS3EXE
  964. extern FTYPE fOptimizeFixups;/* True if fixups optimization possible */
  965. extern void (NEAR *pfProcFixup)();
  966. #endif
  967. /* Ptr to FIXUPP processing routine */
  968. extern RBTYPE mpggrrhte[]; /* f(global GRPDEF) = name */
  969. #if FAR_SEG_TABLES
  970. extern SNTYPE FAR *mpseggsn; /* f(segment #) = global SEGDEF */
  971. #else
  972. extern SNTYPE *mpseggsn; /* f(segment #) = global SEGDEF */
  973. #endif
  974. extern FTYPE fNoEchoLrf; /* True if not echoing response file */
  975. extern FTYPE fNoBanner; /* True if not displaing banner */
  976. extern FTYPE BannerOnScreen; /* True if banner displayed */
  977. #if CMDMSDOS
  978. extern BYTE bSep; /* Separator character */
  979. extern BYTE chMaskSpace; /* Space mask character */
  980. extern FTYPE fEsc; /* True if command line escaped */
  981. extern FTYPE fStuffed; /* Put-back-character flag */
  982. extern RBTYPE rgLibPath[]; /* Default library paths */
  983. extern WORD cLibPaths; /* Count of library paths */
  984. extern char CHSWITCH; /* Switch character */
  985. #if OSMSDOS
  986. extern int (cdecl *pfPrompt)(unsigned char *sbNew,
  987. MSGTYPE msg,
  988. int msgparm,
  989. MSGTYPE pmt,
  990. int pmtparm);
  991. /* Pointer to prompt routine */
  992. #endif
  993. #endif /* CMDMSDOS */
  994. #if QBLIB
  995. extern FTYPE fQlib; /* True if generating Quick-library */
  996. #else
  997. #define fQlib FALSE
  998. #endif
  999. extern char *lnknam; /* Name of linker */
  1000. #if NEWSYM
  1001. extern long cbSymtab; /* # bytes in symbol table */
  1002. #endif /* NEWSYM */
  1003. extern void (*pfCputc)(int ch); /* Ptr to char output routine */
  1004. extern void (*pfCputs)(char *str); /* Ptr to string output routine */
  1005. #if NEWIO
  1006. extern RBTYPE rbFilePrev; /* Pointer to previous file */
  1007. extern char mpifhfh[]; /* f(lib no.) = file handle */
  1008. #endif
  1009. #if MSGMOD AND OSMSDOS
  1010. #if defined(M_I386) OR defined( _WIN32 )
  1011. #define GetMsg(x) GET_MSG(x)
  1012. #else
  1013. extern char FAR * PASCAL __FMSG_TEXT ( unsigned );
  1014. /* Get a msg from the message segment */
  1015. extern char * GetMsg(unsigned short num);
  1016. #define __NMSG_TEXT(x) GetMsg(x)
  1017. #endif
  1018. #endif
  1019. #if MSGMOD AND OSXENIX
  1020. #define __FMSG_TEXT __NMSG_TEXT
  1021. #define GetMsg(x) __NMSG_TEXT(x)
  1022. #endif
  1023. #if NOT MSGMOD
  1024. #define GetMsg(x) (x)
  1025. #define __NMSG_TEXT(x) (x)
  1026. #endif
  1027. #define SEV_WARNING 0
  1028. #define SEV_ERROR 1
  1029. #define SEV_NOTIFICATION 2 /* Possible sev. of QW_ERROR message */
  1030. #if NEW_LIB_SEARCH
  1031. extern void StoreUndef(APROPNAMEPTR, RBTYPE, RBTYPE, WORD);
  1032. extern FTYPE fStoreUndefsInLookaside;
  1033. #endif
  1034. #if RGMI_IN_PLACE
  1035. BYTE FAR * PchSegAddress(WORD cb, SEGTYPE seg, RATYPE ra);
  1036. #endif
  1037. #if ALIGN_REC
  1038. extern BYTE *pbRec; // data for current record
  1039. extern char recbuf[8192]; // record buffer...
  1040. #endif
  1041. //////////////// inline functions ////////////////////
  1042. __inline void NEAR SkipBytes(WORD n)
  1043. {
  1044. #if ALIGN_REC
  1045. pbRec += n;
  1046. cbRec -= n;
  1047. #elif WIN_NT
  1048. WORD cbRead;
  1049. SBTYPE skipBuf;
  1050. cbRec -= n; // Update byte count
  1051. while (n) // While there are bytes to skip
  1052. {
  1053. cbRead = n < sizeof(SBTYPE) ? n : sizeof(SBTYPE);
  1054. if (fread(skipBuf, 1, cbRead, bsInput) != cbRead)
  1055. InvalidObject();
  1056. n -= cbRead;
  1057. }
  1058. #else
  1059. FILE *f = bsInput;
  1060. if ((WORD)f->_cnt >= n)
  1061. {
  1062. f->_cnt -= n;
  1063. f->_ptr += n;
  1064. }
  1065. else if(fseek(f,(long) n,1))
  1066. InvalidObject();
  1067. cbRec -= n; /* Update byte count */
  1068. #endif
  1069. }
  1070. #if ALIGN_REC
  1071. __inline WORD NEAR Gets(void)
  1072. {
  1073. cbRec--;
  1074. return *pbRec++;
  1075. }
  1076. #else
  1077. __inline WORD NEAR Gets(void)
  1078. {
  1079. --cbRec;
  1080. return(getc(bsInput));
  1081. }
  1082. #endif
  1083. __inline WORD NEAR GetIndex(WORD imin,WORD imax)
  1084. {
  1085. #if ALIGN_REC
  1086. WORD w;
  1087. if (*pbRec & 0x80)
  1088. {
  1089. w = (pbRec[0] & 0x7f) << 8 | pbRec[1];
  1090. pbRec += 2;
  1091. cbRec -= 2;
  1092. }
  1093. else
  1094. {
  1095. w = *pbRec++;
  1096. cbRec--;
  1097. }
  1098. if(w < imin || w > imax) InvalidObject();
  1099. return w;
  1100. #else
  1101. WORD index;
  1102. FILE *f = bsInput;
  1103. if (f->_cnt && (index = *(BYTE *)f->_ptr) < 0x80)
  1104. {
  1105. f->_cnt--;
  1106. f->_ptr++;
  1107. cbRec--;
  1108. if(index < imin || index > imax) InvalidObject();
  1109. return(index); /* Return a good value */
  1110. }
  1111. return GetIndexHard(imin, imax);
  1112. #endif
  1113. }
  1114. #if ALIGN_REC
  1115. __inline WORD NEAR WGets(void)
  1116. {
  1117. WORD w = getword(pbRec);
  1118. pbRec += sizeof(WORD);
  1119. cbRec -= sizeof(WORD);
  1120. return w;
  1121. }
  1122. #else
  1123. __inline WORD NEAR WGets(void)
  1124. {
  1125. FILE *f = bsInput;
  1126. // NOTE: this code will only work on a Little Endian machine
  1127. if (f->_cnt >= sizeof(WORD))
  1128. {
  1129. WORD w = *(WORD *)(f->_ptr);
  1130. f->_ptr += sizeof(WORD);
  1131. f->_cnt -= sizeof(WORD);
  1132. cbRec -= sizeof(WORD);
  1133. return w;
  1134. }
  1135. else
  1136. return WGetsHard();
  1137. }
  1138. #endif
  1139. __inline WORD NEAR WSGets(void)
  1140. {
  1141. cbRec -= 2;
  1142. return (WORD)(getc(bsInput) | (getc(bsInput) << 8));
  1143. }
  1144. __inline int Qwrite(char *pch, int cb, FILE *f)
  1145. {
  1146. if (f->_cnt >= cb)
  1147. {
  1148. memcpy(f->_ptr, pch, cb);
  1149. f->_ptr += cb;
  1150. f->_cnt -= cb;
  1151. return cb;
  1152. }
  1153. return fwrite(pch, 1, cb, f);
  1154. }
  1155. #ifdef NEWSYM
  1156. __inline void OutSb(BSTYPE f, BYTE *pb)
  1157. {
  1158. Qwrite(&pb[1],B2W(pb[0]),f);
  1159. }
  1160. #endif
  1161. #if defined( M_I386 ) OR defined( _WIN32 )
  1162. extern void NoRoomForExe(void);
  1163. #if DISPLAY_ON
  1164. #pragma inline_depth(0)
  1165. __inline void WriteExe(void FAR *pb, unsigned cb)
  1166. {
  1167. WORD i,iTotal=0,j=1;
  1168. if (Qwrite((char *) pb, (int)cb, bsRunfile) != (int)cb)
  1169. {
  1170. NoRoomForExe();
  1171. }
  1172. if(TurnDisplayOn)
  1173. {
  1174. fprintf( stdout,"\r\nOutVm : %lx bytes left\r\n", cb);
  1175. for(i=0; i<cb; i++)
  1176. {
  1177. if(j==1)
  1178. {
  1179. fprintf( stdout,"\r\n\t%04X\t",iTotal);
  1180. }
  1181. fprintf( stdout,"%02X ",*((char*)pb+i));
  1182. iTotal++;
  1183. if(++j > 16)
  1184. j=1;
  1185. }
  1186. fprintf( stdout,"\r\n");
  1187. }
  1188. }
  1189. #pragma inline_depth()
  1190. #else // DISPLAY NOT ON
  1191. #define WriteExe(pb,cb) \
  1192. if (Qwrite((char *)(pb),(int)(cb),bsRunfile) != (int)(cb)) NoRoomForExe()
  1193. #endif
  1194. #endif
  1195. #if ALIGN_REC
  1196. __inline void GetBytes(BYTE *pb, WORD n)
  1197. {
  1198. if (n >= SBLEN || n > cbRec)
  1199. InvalidObject();
  1200. memcpy(pb, pbRec, n);
  1201. cbRec -= n;
  1202. pbRec += n;
  1203. }
  1204. __inline DWORD LGets()
  1205. {
  1206. // NOTE: this code will only work on a Little-Endian machine
  1207. DWORD dw = getdword(pbRec);
  1208. pbRec += sizeof(dw);
  1209. cbRec -= sizeof(dw);
  1210. return dw;
  1211. }
  1212. __inline void GetBytesNoLim(BYTE *pb, WORD n)
  1213. {
  1214. if (n > cbRec)
  1215. InvalidObject();
  1216. memcpy(pb, pbRec, n);
  1217. pbRec += n;
  1218. cbRec -= n;
  1219. }
  1220. #endif