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.

176 lines
4.8 KiB

  1. /*
  2. * EXTRACT.H
  3. *
  4. * Common definitions for the EXTRACT program to process source code
  5. * comment blocks and remove tagged documentation.
  6. *
  7. */
  8. /*
  9. * General type definitions, since I've been programming windows
  10. * too long.
  11. */
  12. #define NEAR near
  13. #define FAR far
  14. //#define NULL 0
  15. #define True 1
  16. #define TRUE 1
  17. #define False 0
  18. #define FALSE 0
  19. typedef char NEAR *PSTR;
  20. typedef char FAR *LPSTR;
  21. typedef unsigned long DWORD;
  22. typedef long LONG;
  23. typedef unsigned short WORD;
  24. typedef int BOOL;
  25. /*
  26. * Set version of stuff here
  27. */
  28. #define VERSIONNAME "Source Code Documentation Extraction Tool"
  29. /*
  30. * GENERAL GLOBAL STATUS VARIABLES
  31. */
  32. extern BOOL fNoOutput;
  33. extern PSTR szOutputFile;
  34. extern FILE *fpOutput;
  35. /*
  36. * Source code type definitions - used by input parser in FileEntry struct.
  37. */
  38. #define SRC_UNKNOWN 0
  39. #define SRC_C 1
  40. #define SRC_MASM 2
  41. /*
  42. * File name parser stuff
  43. */
  44. typedef struct _FileEntry {
  45. struct _FileEntry *next;
  46. int type;
  47. char *filename;
  48. } FileEntry;
  49. /* list of files to process, built by parser */
  50. extern FileEntry *FilesToProcess;
  51. /* Command line argument processor */
  52. void ParseArgs(int argc, char **argv);
  53. void Usage(PSTR progName);
  54. /*
  55. * SOURCE FILE STRUCTURE - struct used during parsing of source file
  56. */
  57. typedef struct _SourceFile {
  58. /* Direct file stuff */
  59. FileEntry *fileEntry; // fileentry struct pointer
  60. FILE *fp; // file pointer
  61. BOOL fExitAfter; // exit after processing file
  62. int wLineNo; // file line number currently at
  63. /* Buffer holders */
  64. PSTR lpbuf; // global copy buffer
  65. PSTR pt; // buffer `point'
  66. PSTR mark; // buffer `mark'
  67. int wLineBuf; // line number start of buffer is
  68. /* Stuff for reading in comment block */
  69. BOOL fTag; // tag on this line, and status
  70. BOOL fHasTags; // tags appear in this buffer.
  71. /* Stuff used while processing block tags */
  72. PSTR pDocLevel; // @doc output for this block
  73. PSTR pXref; // @xref line for this block
  74. WORD wFlags; // flags indicating state?
  75. } SourceFile;
  76. typedef SourceFile NEAR *NPSourceFile;
  77. /* Proc to process a filled buffer to the output file */
  78. void TagProcessBuffer(NPSourceFile sf);
  79. /*
  80. * General Comment buffer parsing routines - bfuncs.c
  81. */
  82. void OutputTag(NPSourceFile sf, WORD wBlock, WORD wTag);
  83. void OutputTagText(NPSourceFile sf, PSTR szTag);
  84. void OutputRegion(NPSourceFile sf, char chPost);
  85. void OutputText(NPSourceFile sf, PSTR szText);
  86. void OutputFileHeader(FILE *fpOut);
  87. void CopyRegion(NPSourceFile sf, PSTR buf, WORD wLen);
  88. BOOL FindNextTag(NPSourceFile sf);
  89. WORD GetFirstBlock(NPSourceFile sf);
  90. WORD GetNextBlock(NPSourceFile sf);
  91. WORD FixLineCounts(NPSourceFile sf, PSTR pt);
  92. void PrintError(NPSourceFile sf, PSTR szMessage, BOOL fExit);
  93. WORD ProcessWordList(NPSourceFile sf, PSTR *bufPt, BOOL fCap);
  94. /* Flags for return from GetFirstBlock && GetNextBlock */
  95. #define RET_EMPTYBLOCK 1
  96. #define RET_ENDCOMMENT 2
  97. #define RET_ENDBLOCK 3
  98. #define RET_ENDTAG 4
  99. /*
  100. * INNERLEVEL TAG PROCESSING ROUTINES - innertag.c
  101. */
  102. BOOL DoDocTag(NPSourceFile sf);
  103. BOOL DoFlagTag(NPSourceFile sf, WORD wBlock, WORD wNameFlag, WORD wDescFlag);
  104. BOOL ProcessFlagList(NPSourceFile sf, WORD wBlock,
  105. WORD wNameFlag, WORD wDescFlag);
  106. BOOL DoParameterTag(NPSourceFile sf, WORD wBlock);
  107. BOOL DoParameterizedReturnTag(NPSourceFile sf, WORD wBlock);
  108. BOOL DoRegisterizedReturnTag(NPSourceFile sf, WORD wBlock);
  109. BOOL DoCommentTag(NPSourceFile sf, WORD wBlock);
  110. BOOL DoUsesTag(NPSourceFile sf, WORD wBlock);
  111. BOOL DoPrintedCommentTag(NPSourceFile sf);
  112. void ProcessXrefTag(NPSourceFile sf);
  113. BOOL DoRegisterTag(NPSourceFile sf, WORD wBlock, BOOL fReturn);
  114. BOOL DoRegisterDeclaration(NPSourceFile sf, WORD wBlock);
  115. void DoBlockBegin(NPSourceFile sf);
  116. void DoBlockEnd(NPSourceFile sf, WORD wBlock, BOOL fFlushXref);
  117. BOOL DoFieldTag(NPSourceFile sf, WORD wBlock);
  118. BOOL DoOthertypeTag(NPSourceFile sf, WORD wBlock);
  119. BOOL DoStructTag(NPSourceFile sf, WORD wBlock, BOOL fStructure);
  120. BOOL DoTagnameTag(NPSourceFile sf, WORD wBlock);
  121. /* Flags indicating status of comment block tag parsing */
  122. #define SFLAG_SMASK 0xF800
  123. #define SFLAG_RDESC 0x8000
  124. #define SFLAG_COMM 0x4000
  125. #define SFLAG_PARMS 0x2000
  126. #define SFLAG_REGS 0x1000
  127. #define SFLAG_USES 0x0800
  128. /*
  129. * Memory manager stuff - misc.c
  130. */
  131. extern WORD wNearMemoryUsed; /* counts of how much memory used */
  132. extern DWORD dwFarMemoryUsed;
  133. PSTR NearMalloc(WORD size, BOOL fZero);
  134. PSTR NearRealloc(PSTR pblock, WORD newsize);
  135. void NearFree(PSTR pblock);
  136. WORD NearSize(PSTR pblock);
  137. PSTR StringAlloc(PSTR string);
  138. void NearHeapCheck();
  139. #if 0
  140. LPSTR FarMalloc(int size, BOOL fZero);
  141. void FarFree(LPSTR lpblock);
  142. extern int far lmemzero(LPSTR lpBase, WORD wLength);
  143. #endif
  144. /*
  145. * Debugging support
  146. */
  147. #ifdef DEBUG
  148. BOOL fDebug;
  149. void cdecl COMprintf(PSTR format, ...);
  150. #define dprintf if (fDebug) COMprintf
  151. #else
  152. #define dprintf if (0) ((int (*)(char *, ...)) 0)
  153. #endif