📄 cdio.h
字号:
/* -*- c -*- $Id: cdio.h,v 1.4 2005/04/27 23:28:42 rockyb Exp $ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*//** \file cdio.h * * \brief The top-level header for libcdio: the CD Input and Control * library. Applications include this for anything regarding libcdio. */#ifndef __CDIO_H__#define __CDIO_H__/** Application Interface or Protocol version number. If the public * interface changes, we increase this number. */#define CDIO_API_VERSION 2#include <cdio/version.h>#ifdef HAVE_SYS_TYPES_H#include <sys/types.h>#endif#ifdef HAVE_UNISTD_H#include <unistd.h>#endif#include <cdio/types.h>#include <cdio/sector.h>/**! Flags specifying the category of device to open or is opened. */#define CDIO_SRC_IS_DISK_IMAGE_MASK 0x0001 /**< Read source is a CD image. */#define CDIO_SRC_IS_DEVICE_MASK 0x0002 /**< Read source is a CD device. */#define CDIO_SRC_IS_SCSI_MASK 0x0004 /**< Read source SCSI device. */#define CDIO_SRC_IS_NATIVE_MASK 0x0008#ifdef __cplusplusextern "C" {#endif /* __cplusplus *//*! Size of fields returned by an INQUIRY command */#define CDIO_MMC_HW_VENDOR_LEN 8 /**< length of vendor field */#define CDIO_MMC_HW_MODEL_LEN 16 /**< length of model field */#define CDIO_MMC_HW_REVISION_LEN 4 /**< length of revision field */ /*! \brief Structure to return CD vendor, model, and revision-level strings obtained via the INQUIRY command */ typedef struct cdio_hwinfo { char psz_vendor [CDIO_MMC_HW_VENDOR_LEN+1]; char psz_model [CDIO_MMC_HW_MODEL_LEN+1]; char psz_revision[CDIO_MMC_HW_REVISION_LEN+1]; } cdio_hwinfo_t;/* For compatability. */#define CdIo CdIo_t /** This is an opaque structure for the CD object. */ typedef struct _CdIo CdIo_t; /** This is an opaque structure for the CD-Text object. */ typedef struct cdtext cdtext_t; /** The driver_id_t enumerations may be used to tag a specific driver * that is opened or is desired to be opened. Note that this is * different than what is available on a given host. * * Order is a little significant since the order is used in scans. * We have to start with DRIVER_UNKNOWN and devices should come before * disk-image readers. By putting something towards the top (a lower * enumeration number), in an iterative scan we prefer that to * something with a higher enumeration number. * * NOTE: IF YOU MODIFY ENUM MAKE SURE INITIALIZATION IN CDIO.C AGREES. * */ typedef enum { DRIVER_UNKNOWN, /**< Used as input when we don't care what kind of driver to use. */ DRIVER_BSDI, /**< BSDI driver */ DRIVER_FREEBSD, /**< FreeBSD driver - includes CAM and ioctl access */ DRIVER_LINUX, /**< GNU/Linux Driver */ DRIVER_SOLARIS, /**< Sun Solaris Driver */ DRIVER_OSX, /**< Apple OSX Driver */ DRIVER_WIN32, /**< Microsoft Windows Driver. Includes ASPI and ioctl acces. */ DRIVER_CDRDAO, /**< cdrdao format CD image. This is listed before BIN/CUE, to make the code prefer cdrdao over BIN/CUE when both exist. */ DRIVER_BINCUE, /**< CDRWIN BIN/CUE format CD image. This is listed before NRG, to make the code prefer BIN/CUE over NRG when both exist. */ DRIVER_NRG, /**< Nero NRG format CD image. */ DRIVER_DEVICE /**< Is really a set of the above; should come last */ } driver_id_t; /** There will generally be only one hardware for a given build/platform from the list above. You can use the variable below to determine which you've got. If the build doesn't make an hardware driver, then the value will be DRIVER_UNKNOWN. */ extern const driver_id_t cdio_os_driver; /** Make sure what's listed for CDIO_MIN_DRIVER is the last enumeration in driver_id_t. Since we have a bogus (but useful) 0th entry above we don't have to add one.*/#define CDIO_MIN_DRIVER DRIVER_BSDI#define CDIO_MIN_DEVICE_DRIVER CDIO_MIN_DRIVER#define CDIO_MAX_DRIVER DRIVER_NRG#define CDIO_MAX_DEVICE_DRIVER DRIVER_WIN32 typedef enum { TRACK_FORMAT_AUDIO, /**< Audio track, e.g. CD-DA */ TRACK_FORMAT_CDI, /**< CD-i. How this is different from DATA below? */ TRACK_FORMAT_XA, /**< Mode2 of some sort */ TRACK_FORMAT_DATA, /**< Mode1 of some sort */ TRACK_FORMAT_PSX, /**< Playstation CD. Like audio but only 2336 bytes * of user data. */ TRACK_FORMAT_ERROR /**< Dunno what is, or some other error. */ } track_format_t; extern const char *discmode2str[]; /*! Printable tags for track_format_t enumeration. */ extern const char *track_format2str[6]; /*! Eject media in CD drive if there is a routine to do so. @param p_cdio the CD object to be acted upon. @return 0 if success and 1 for failure, and 2 if no routine. If the CD is ejected *p_cdio is freed and p_cdio set to NULL. */ int cdio_eject_media (CdIo_t **p_cdio); /*! Free any resources associated with p_cdio. Call this when done using p_cdio and using CD reading/control operations. @param p_cdio the CD object to eliminated. */ void cdio_destroy (CdIo_t *p_cdio); /*! Free device list returned by cdio_get_devices or cdio_get_devices_with_cap. @param device_list list returned by cdio_get_devices or cdio_get_devices_with_cap @see cdio_get_devices, cdio_get_devices_with_cap */ void cdio_free_device_list (char * device_list[]); /*! Get the value associatied with key. @param p_cdio the CD object queried @param key the key to retrieve @return the value associatd with "key" or NULL if p_cdio is NULL or "key" does not exist. */ const char * cdio_get_arg (const CdIo_t *p_cdio, const char key[]); /*! Get CD-Text information for a CdIo object. @param p_cdio the CD object that may contain CD-Text information. @param i_track track for which we are requesting CD-Text information. @return the CD-Text object or NULL if obj is NULL or CD-Text information does not exist. If i_track is 0 or CDIO_CDROM_LEADOUT_TRACK the track returned is the information assocated with the CD. */ const cdtext_t *cdio_get_cdtext (CdIo_t *p_cdio, track_t i_track); /*! Get the default CD device. if p_cdio is NULL (we haven't initialized a specific device driver), then find a suitable one and return the default device for that. @param p_cdio the CD object queried @return a string containing the default CD device or NULL is if we couldn't get a default device. In some situations of drivers or OS's we can't find a CD device if there is no media in it and it is possible for this routine to return NULL even though there may be a hardware CD-ROM. */ char * cdio_get_default_device (const CdIo_t *p_cdio); /*! Return an array of device names. If you want a specific devices for a driver, give that device. If you want hardware devices, give DRIVER_DEVICE and if you want all possible devices, image drivers and hardware drivers give DRIVER_UNKNOWN. NULL is returned if we couldn't return a list of devices. In some situations of drivers or OS's we can't find a CD device if there is no media in it and it is possible for this routine to return NULL even though there may be a hardware CD-ROM. */ char ** cdio_get_devices (driver_id_t driver_id); /*! Get an array of device names in search_devices that have at least the capabilities listed by the capabities parameter. If search_devices is NULL, then we'll search all possible CD drives. If "b_any" is set false then every capability listed in the extended portion of capabilities (i.e. not the basic filesystem) must be satisified. If "any" is set true, then if any of the capabilities matches, we call that a success. To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL. @return the array of device names or NULL if we couldn't get a default device. It is also possible to return a non NULL but after dereferencing the the value is NULL. This also means nothing was found. */ char ** cdio_get_devices_with_cap (char* ppsz_search_devices[], cdio_fs_anal_t capabilities, bool b_any); /*! Like cdio_get_devices_with_cap but we return the driver we found as well. This is because often one wants to search for kind of drive and then *open* it afterwards. Giving the driver back facilitates this, and speeds things up for libcdio as well. */ char ** cdio_get_devices_with_cap_ret (/*out*/ char* ppsz_search_devices[], cdio_fs_anal_t capabilities, bool b_any, /*out*/ driver_id_t *p_driver_id); /*! Like cdio_get_devices, but we may change the p_driver_id if we were given DRIVER_DEVICE or DRIVER_UNKNOWN. This is because often one wants to get a drive name and then *open* it afterwards. Giving the driver back facilitates this, and speeds things up for libcdio as well. */ char ** cdio_get_devices_ret (/*in/out*/ driver_id_t *p_driver_id); /*! Get disc mode - the kind of CD (CD-DA, CD-ROM mode 1, CD-MIXED, etc. that we've got. The notion of "CD" is extended a little to include DVD's. */ discmode_t cdio_get_discmode (CdIo_t *p_cdio); /*! Get the what kind of device we've got. @param p_cdio the CD object queried @param p_read_cap pointer to return read capabilities @param p_write_cap pointer to return write capabilities @param p_misc_cap pointer to return miscellaneous other capabilities In some situations of drivers or OS's we can't find a CD device if there is no media in it and it is possible for this routine to return NULL even though there may be a hardware CD-ROM. */ void cdio_get_drive_cap (const CdIo_t *p_cdio, cdio_drive_read_cap_t *p_read_cap, cdio_drive_write_cap_t *p_write_cap, cdio_drive_misc_cap_t *p_misc_cap); /*! Get the drive capabilities for a specified device. @return a list of device capabilities. In some situations of drivers or OS's we can't find a CD device if there is no media in it and it is possible for this routine to return NULL even though there may be a hardware CD-ROM. */ void cdio_get_drive_cap_dev (const char *device, cdio_drive_read_cap_t *p_read_cap, cdio_drive_write_cap_t *p_write_cap, cdio_drive_misc_cap_t *p_misc_cap); /*! Get a string containing the name of the driver in use. @return a string with driver name or NULL if CdIo is NULL (we haven't initialized a specific device. */ const char * cdio_get_driver_name (const CdIo_t *p_cdio); /*! Get the driver id. if CdIo is NULL (we haven't initialized a specific device driver), then return DRIVER_UNKNOWN. @return the driver id.. */ driver_id_t cdio_get_driver_id (const CdIo_t *p_cdio); /*! Get the number of the first track. @return the track number or CDIO_INVALID_TRACK
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -