home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l196 / 3.ddi / QLBDUMP.BA$ / QLBDUMP.bin
Encoding:
Text File  |  1990-06-24  |  3.2 KB  |  85 lines

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