home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l170 / 3.ddi / SOURCE / QLBDUMP.BAS < prev    next >
Encoding:
BASIC Source File  |  1987-09-22  |  3.0 KB  |  83 lines

  1. ' This program prints the names of QuickLibrary procedures
  2.  
  3. DECLARE SUB DumpSym (SymStart AS INTEGER, QHdrPos AS LONG)
  4.  
  5. TYPE ExeHdr                  ' Part of DOS .EXE header
  6.     other1    AS STRING * 8  ' Other header information
  7.     CParHdr   AS INTEGER     ' Size of header in paragraphs
  8.     other2    AS STRING * 10 ' Other header information
  9.     IP        AS INTEGER     ' Initial IP value
  10.     CS        AS INTEGER     ' Initial (relative) CS value
  11. END TYPE
  12.  
  13. TYPE QBHdr                   ' QLB header
  14.     QBHead    AS STRING * 6  ' QB specific heading
  15.     Magic     AS INTEGER     ' Magic word: identifies file as
  16.                              ' a Quick library
  17.     SymStart  AS INTEGER     ' Offset from header to first code symbol
  18.     DatStart  AS INTEGER     ' Offset from header to first data symbol
  19. END TYPE
  20.  
  21. TYPE QbSym                   ' QuickLib symbol entry
  22.     Flags     AS INTEGER     ' Symbol flags
  23.     NameStart AS INTEGER     ' Offset into name table
  24.     other     AS STRING * 4  ' Other header info
  25. END TYPE
  26.  
  27. DIM EHdr AS ExeHdr, Qhdr AS QBHdr, QHdrPos AS LONG
  28.  
  29. INPUT "Enter QuickLibrary file name: ", FileName$
  30. FileName$ = UCASE$(FileName$)
  31. IF INSTR(FileName$, ".QLB") = 0 THEN FileName$ = FileName$ + ".QLB"
  32. OPEN FileName$ FOR BINARY AS #1
  33.  
  34. GET #1, , EHdr               ' Read the EXE format header.
  35.  
  36. QHdrPos = (EHdr.CParHdr + EHdr.CS) * 16 + EHdr.IP + 1
  37.  
  38. GET #1, QHdrPos, Qhdr        ' Read the QuickLib format header.
  39.  
  40. IF Qhdr.Magic <> &H6C75 THEN PRINT "Not a QB UserLibrary": END
  41.  
  42. PRINT "Code Symbols:": PRINT
  43. DumpSym Qhdr.SymStart, QHdrPos ' dump code symbols
  44. PRINT
  45.  
  46. PRINT "Data Symbols:": PRINT
  47. DumpSym Qhdr.DatStart, QHdrPos ' dump data symbols
  48. PRINT
  49.  
  50. END
  51.  
  52. SUB DumpSym (SymStart AS INTEGER, QHdrPos AS LONG)
  53.    DIM QlbSym AS QbSym
  54.    DIM NextSym AS LONG, CurrentSym AS LONG
  55.  
  56.    ' Calculate the location of the first symbol entry, then read that entry:
  57.    NextSym = QHdrPos + SymStart
  58.    GET #1, NextSym, QlbSym
  59.  
  60.    DO
  61.       NextSym = SEEK(1)          ' Save the location of the next
  62.                                  ' symbol.
  63.       CurrentSym = QHdrPos + QlbSym.NameStart
  64.       SEEK #1, CurrentSym        ' Use SEEK to move to the name
  65.                                  ' for the current symbol entry.
  66.       Prospect$ = INPUT$(40, 1)  ' Read the longest legal string,
  67.                                  ' plus one additonal byte for the
  68.                                  ' final null character (CHR$(0)).
  69.  
  70.       ' Extract the null-terminated name:
  71.       SName$ = LEFT$(Prospect$, INSTR(Prospect$, CHR$(0)))
  72.  
  73.       ' Print only those names that do not begin with "__", "$", or "b$"
  74.       ' as these names are usually considered reserved:
  75.       IF LEFT$(SName$, 2) <> "__" AND LEFT$(SName$, 1) <> "$" AND UCASE$(LEFT$(SName$, 2)) <> "B$" THEN
  76.          PRINT "  " + SName$
  77.       END IF
  78.  
  79.       GET #1, NextSym, QlbSym    ' Read a symbol entry.
  80.    LOOP WHILE QlbSym.Flags       ' Flags=0 (false) means end of table.
  81. END SUB
  82.  
  83.