home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / MAKEDE.ZIP / OBJUTILS.H < prev    next >
C/C++ Source or Header  |  1992-09-09  |  4KB  |  98 lines

  1. //***** objutils.h  --  Global include info for Object Library Engine (objutils.c) ******
  2.  
  3. #define THEADR              0x80        // OMF module header
  4. #define COMENT              0x88        // OMF comment record
  5. #define MODEND              0x8A        // OMF module end record
  6. #define LIBMOD              0xA3        // library module name comment class
  7. #define LIBHEADER           0xF0        // LIB file header
  8. #define MARKER_RECORD       0xF1        // marker between modules & dictionary
  9. #define NUMBUCKETS          37          // number of buckets/block    
  10. #define DICTBLOCKSIZE       512         // bytes/symbol dictionary block
  11. #define DICTBLKFULL         0xFF        // Symbol dictionary block full
  12.  
  13. #define UNDEFINED           -1          // to indicate non-initialized data
  14. #define STR_EQUAL           0           // string equality
  15.  
  16. // These two macros will rotate word operand opw by nbits bits (0 - 16) 
  17. #define WORDBITS            16
  18. #define ROL(opw, nbits) (((opw) << (nbits)) | ((opw) >> (WORDBITS - (nbits))))
  19. #define ROR(opw, nbits) (((opw) >> (nbits)) | ((opw) << (WORDBITS - (nbits))))
  20.  
  21. typedef enum {
  22.     false,
  23.     true
  24. } bool;
  25.  
  26. #pragma pack(1)
  27.  
  28. typedef struct {
  29.     unsigned char RecType;
  30.     int RecLength;
  31. } OMFHEADER;
  32.  
  33. typedef struct {
  34.     unsigned char RecType;
  35.     int RecLength;
  36.     unsigned char Attrib;
  37.     unsigned char CommentClass;
  38. } COMENTHEADER;
  39.  
  40. typedef struct {                    // Record Type F0h
  41.     int PageSize;                   // Header length (excl. first 3 bytes)
  42.                                     // == page size (module at page boundary)
  43.                                     // page size == 2 ** n, 4 <= n <= 15
  44.     long DictionaryOffset;          // file offset of Symbol Dictionary
  45.     int NumDictBlocks;              // number of Symbol Dictionary blocks
  46.                                     // <= 251 512-byte dictionary pages
  47.     unsigned char Flags;            // only valid flag: 01h => case-sensitive
  48.     bool IsCaseSensitive;
  49.     bool IsLIBMODFormat;            // is MS extension type LIBMOD present?
  50. } LIBHDR;
  51.  
  52. typedef struct {
  53.     unsigned char MarkerType;       // This's better be F1h
  54.     int MarkerLength;               // filler to dictionary's 512-byte alignment
  55. } DICTMARKER;
  56.  
  57. typedef struct {
  58.     int  BlockNumber;
  59.     int  BucketNumber;
  60.     unsigned char *SymbolP;
  61.     long ModuleFilePos;
  62.     bool IsFound;
  63. } DICTENTRY;
  64.  
  65. typedef struct {
  66.     int BlockHash;
  67.     int BlockOvfl;
  68.     int BucketHash;
  69.     int BucketOvfl;
  70. } HashT;
  71.  
  72. void GetLibHeader(LIBHDR *LibHeader, FILE *InLibFH);
  73. HashT Hash(char SymbolZ[], int NumHashBlocks);
  74. DICTENTRY FindSymbol(char *SymbolZ, LIBHDR *LibHeader, FILE *InLibFH);
  75. void GetSymDictBlock(int BlockNumber, LIBHDR *LibHeader, 
  76.         FILE *InLibFH);
  77. long FindModule(char *ModuleName, LIBHDR *LibHeader, FILE *InLibFH);
  78. DICTENTRY GetSymDictEntry(int BlockNumber, int BucketNumber, 
  79.         LIBHDR *LibHeader, FILE *InLibFH);
  80. char *GetModuleName(long ModuleFilePos, LIBHDR *LibHeader, FILE *InLibFH);
  81. bool FindLIBMOD(FILE *InLibFH);
  82. bool FindObjRecord(FILE *ObjFH, unsigned char RecType);
  83. bool ExtractModule(char *ModuleName, char *NewModuleName, LIBHDR *LibHeader, 
  84.         FILE *InLibFH);
  85. void CopyObjModule(FILE *NewObjFH, long FilePos, FILE *InLibFH);
  86.  
  87. //******  --  Service functions *******
  88.  
  89. #define NOFILE              NULL        // no error log file
  90. typedef enum {
  91.     Message,
  92.     Warning,
  93.     Error
  94. } MESSAGETYPE;
  95.  
  96. char *MakeASCIIZ(unsigned char *LString);
  97. void Output(MESSAGETYPE MsgType, FILE *Stream, char *OutputFormat, ...);
  98.