README.txt 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. This directory contains some CD-ROM support routines for Free Pascal.
  2. The routines are demonstrated by the 'getdiscid' and 'showcds' programs.
  3. The latter shows the available CD-rom drives on the system, the former
  4. calculates a disc-id and query for use with a freecddb server.
  5. Unit cdrom
  6. ----------
  7. The unit 'cdrom' implements a cross-platform interface for handling CD-roms.
  8. Currently, it is implemented for Linux and Windows only.
  9. The other units are support units, needed by various implementations.
  10. The unit presents 2 calls:
  11. Type
  12. TTocEntry = Record
  13. min, sec, frame : Integer
  14. end;
  15. PTocEntry = ^TTocEntry;
  16. Function GetCDRomDevices(Var Devices : Array of string) : Integer;
  17. Function ReadCDTOC(Device : String; Var CDTOC : Array of TTocEntry) : Integer;
  18. The GetCDRomDevices call retrieves a list of available CD-ROM devices/drives
  19. on the system. The algorithm used to detect these devices depends on the
  20. system. The function returns the number of devices found, or a negative
  21. number on error. The 'Devices' array is filled with strings that describe
  22. the devices. For unix like systems, these are the device files (/dev/hdc
  23. etc), for windows, these can be drive letters (D: etc) or ASPI Adaptor,
  24. Target, lun IDs triples, for example ASPI[1;0;0].
  25. (an algorithm mapping these to drive letters would be appreciated)
  26. The ReadCDTOC call retrieves the table of contents of a CD in the CD-rom
  27. drive (Device) This returns the number of tracks on the CD-ROM. On return,
  28. The CDTOC array will be filled with the length of the tracks, and the frame
  29. number, manipulated to be usable in a disc ID calculation. There will be one
  30. extra entry at the end of the array, describing the lead-out.
  31. unit discid
  32. -----------
  33. The DISCID unit calculates a DISC-ID as needed by a freecddb server to
  34. query for the contents of a disc.
  35. Function CDDBDiscID(Const CDTOC : Array of TTocEntry; Count : Integer) : integer ;
  36. The count is the number of tracks, the array should contain Count+1
  37. elements, the last one being the lead out. The output of the ReadCDToc
  38. function can be used as input for this function.
  39. Function GetCDDBQueryString(Const Tracks : Array of TTocEntry; Count : Integer) : String;
  40. This function returns a query string as expected by a freecddb server.
  41. It consists of the disc id, number of tracks, and the frame fields of the
  42. TCDToc records in the tracks array.
  43. unit lincd
  44. ----------
  45. Essentially translation of the linux/cdrom.h include file, plus 2 functions
  46. Function IsCDDevice(Device : String) : Boolean;
  47. Returns True if the device file is a cdrom.
  48. Function DetectCd : String;
  49. Detects the first cd in the system; it does this by checking a number of
  50. well-known common device files; the first once for which IsCDDevice returns
  51. True is returned. Note that this can take some time.
  52. unit major
  53. ----------
  54. Definitions of the major device numbers under linux. used by the lincd unit.
  55. unit wincd
  56. ----------
  57. Some CD-routines. Essentially the low-level counterpart of the cd-rom unit.
  58. The unit tries to use the windows ASPI layer to detect cd-roms. If the layer
  59. is not present, the common IOCTL or SPTI interfaces are used.
  60. TCDAccessMethod = (camNone,camASPI,camSPTI,camIOCTL);
  61. Determines which access method is used.
  62. Records used in the low-level calls:
  63. TTOCTrack = packed record
  64. rsvd,
  65. ADR,
  66. trackNumber,
  67. rsvd2 : Byte;
  68. addr : Array[0..3] of byte;
  69. end;
  70. TTOC = packed Record
  71. toclen : word;
  72. firsttrack,
  73. lastTrack : byte;
  74. toctrack: Array[0..99] of TTocTrack;
  75. end;
  76. Const
  77. AccessMethodNames : Array[TCDAccessMethod] of string
  78. = ('None','ASPI','SPTI','IOCTL');
  79. Function GetCDAccessMethod : TCDAccessMethod;
  80. Returns the current CD-rom detection method.
  81. Procedure SetCDAccessMethod (Value : TCDAccessMethod);
  82. Sets the current CD-rom detection method.
  83. Function ReadTOC(Device : String; Var TOC : TTOc) : Integer;
  84. Reads the CD-Rom devices. Device is a drive letter, or if ASPI is used
  85. a string of the form [Aid,TgID,LunID] (Adapter ID, Target ID, LUN id)
  86. Function EnumCDDrives(Var Drives : Array of String) : Integer;
  87. Returns the CD-ROM drive letters of the system, or strings describing ASPI
  88. drives.
  89. Function GetNumDrives : Integer;
  90. Returns the number of drives.
  91. NOTE: A function mapping an ASPI triple to a drive letter would be
  92. appreciated.
  93. unit Wnaspi32:
  94. --------------
  95. Low-level ASPI unit. Contains all structures, plus the following:
  96. TSendASPI32Command = function( LPSRB : Pointer ) : DWORD; cdecl;
  97. TGetASPI32SupportInfo = function : DWORD; cdecl;
  98. SendASPI32Command : TSendASPI32Command = nil;
  99. GetASPI32SupportInfo : TGetASPI32SupportInfo = nil;
  100. These procedural variables map to the actual API calls. They are only valid
  101. and usable if ASPILoaded returns TRUE.
  102. Function ASPILoaded : Boolean;
  103. Returns TRUE if ASPI is available and loaded.
  104. Procedure CheckASPI;
  105. Checks whether ASPI is available. After calling this it is possible to use
  106. the ASPIAvailable function. This procedure is called in the initialization
  107. section of the unit.
  108. procedure UnloadASPI;
  109. Unloads the ASPI library if it was loaded. This procedure is called in the
  110. finalization section of the unit.
  111. scsidefs.pp
  112. -----------
  113. Bare translation of the scsidefs.h windows SDK header.
  114. cdromioctl.pp
  115. -------------
  116. This unit contains some records and constants defined in window's
  117. cdromioctl.h
  118. Michael.