From Mike Andrew
get the zip file here
This Application Programming Interface is a single, rather small, C file (with header). It is designed for use in both C and C++ environments and tested on both.
It handles all aspects of CD opening, closing, and ioctl functions transparently for both IDE and SCSI CDROMS (SCSI is not fully tested).
Programs which control the CDROM (such as playing a CD, or ejecting it) can be written in userland using this API.
Kernels 2.2.x cleaned up the cdrom interface. Various scattered headers (such as ucdrom.h) were eliminated, and, common ioctl function paramaters were organised to match SCSI and IDE. (In fact, the IDE section was made to look more like SCSI)
This APIremoves the need for the programmer to become involved with the nitty gritty of the specific (and sometimes esoteric) function paramaters of the ioctl call, and the sometimes vague ... (ellipses) required. In fact, there is no requirement for the programmer to use any ioctl() function.
Having said that, the source code is fully documented and all ioctl functions as they apply to CDROM are supported. The code should give all programmers a very good insight into what is required, should they choose to go it alone.
This code incidentally, is the bottom layer to the user
applications Xcd and Kcd audio players. The only requirement of
the programmer using this API is to match the calls against a
GUI interface that they can design to suit their tastes.
Without risking the crippling effect of trying to control everything, this code handles most error status so that the programmer need only concern himself with a boolean pass / fail test of the return status for most of the API function calls. All errors are negative returns and fully documented. The need however to analyse the actual value is best left to debugging purposes only.
General Program Flow
The general flow used by a programmer with this api will be
cd_load(); // if it isn't
cd_get_toc(); // read the track info