libcdio  0.90
device.h
Go to the documentation of this file.
00001 /* -*- c -*-
00002 
00003     Copyright (C) 2005, 2006, 2008, 2009, 2010, 2011, 2012 Rocky Bernstein
00004     <rocky@gnu.org>
00005 
00006     This program is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00026 #ifndef CDIO_DEVICE_H_
00027 #define CDIO_DEVICE_H_
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif /* __cplusplus */
00032 
00033 #include <cdio/types.h>
00034 #include <cdio/cdio.h>
00035 
00037   typedef uint32_t cdio_drive_read_cap_t;
00038   typedef uint32_t cdio_drive_write_cap_t;
00039   typedef uint32_t cdio_drive_misc_cap_t;
00040   
00047   typedef enum {
00048     CDIO_DRIVE_CAP_ERROR             = 0x40000, 
00049     CDIO_DRIVE_CAP_UNKNOWN           = 0x80000, 
00053     CDIO_DRIVE_CAP_MISC_CLOSE_TRAY   = 0x00001, 
00055     CDIO_DRIVE_CAP_MISC_EJECT        = 0x00002, 
00056     CDIO_DRIVE_CAP_MISC_LOCK         = 0x00004, 
00057     CDIO_DRIVE_CAP_MISC_SELECT_SPEED = 0x00008, 
00058     CDIO_DRIVE_CAP_MISC_SELECT_DISC  = 0x00010, 
00060     CDIO_DRIVE_CAP_MISC_MULTI_SESSION= 0x00020, 
00061     CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED= 0x00080, 
00062     CDIO_DRIVE_CAP_MISC_RESET        = 0x00100, 
00063     CDIO_DRIVE_CAP_MISC_FILE         = 0x20000 
00065   } cdio_drive_cap_misc_t;
00066 
00068   typedef enum {
00069     CDIO_DRIVE_CAP_READ_AUDIO        = 0x00001, 
00070     CDIO_DRIVE_CAP_READ_CD_DA        = 0x00002, 
00071     CDIO_DRIVE_CAP_READ_CD_G         = 0x00004, 
00072     CDIO_DRIVE_CAP_READ_CD_R         = 0x00008, 
00073     CDIO_DRIVE_CAP_READ_CD_RW        = 0x00010, 
00074     CDIO_DRIVE_CAP_READ_DVD_R        = 0x00020, 
00075     CDIO_DRIVE_CAP_READ_DVD_PR       = 0x00040, 
00076     CDIO_DRIVE_CAP_READ_DVD_RAM      = 0x00080, 
00077     CDIO_DRIVE_CAP_READ_DVD_ROM      = 0x00100, 
00078     CDIO_DRIVE_CAP_READ_DVD_RW       = 0x00200, 
00079     CDIO_DRIVE_CAP_READ_DVD_RPW      = 0x00400, 
00080     CDIO_DRIVE_CAP_READ_C2_ERRS      = 0x00800, 
00081     CDIO_DRIVE_CAP_READ_MODE2_FORM1  = 0x01000, 
00082     CDIO_DRIVE_CAP_READ_MODE2_FORM2  = 0x02000, 
00083     CDIO_DRIVE_CAP_READ_MCN          = 0x04000, 
00084     CDIO_DRIVE_CAP_READ_ISRC         = 0x08000 
00085   } cdio_drive_cap_read_t;
00086 
00088   typedef enum {
00089     CDIO_DRIVE_CAP_WRITE_CD_R        = 0x00001, 
00090     CDIO_DRIVE_CAP_WRITE_CD_RW       = 0x00002, 
00091     CDIO_DRIVE_CAP_WRITE_DVD_R       = 0x00004, 
00092     CDIO_DRIVE_CAP_WRITE_DVD_PR      = 0x00008, 
00093     CDIO_DRIVE_CAP_WRITE_DVD_RAM     = 0x00010, 
00094     CDIO_DRIVE_CAP_WRITE_DVD_RW      = 0x00020, 
00095     CDIO_DRIVE_CAP_WRITE_DVD_RPW     = 0x00040, 
00096     CDIO_DRIVE_CAP_WRITE_MT_RAINIER  = 0x00080, 
00097     CDIO_DRIVE_CAP_WRITE_BURN_PROOF  = 0x00100, 
00098     CDIO_DRIVE_CAP_WRITE_CD =
00099     (CDIO_DRIVE_CAP_WRITE_CD_R | CDIO_DRIVE_CAP_WRITE_CD_RW),
00102     CDIO_DRIVE_CAP_WRITE_DVD = 
00103     (CDIO_DRIVE_CAP_WRITE_DVD_R | CDIO_DRIVE_CAP_WRITE_DVD_PR 
00104      | CDIO_DRIVE_CAP_WRITE_DVD_RAM | CDIO_DRIVE_CAP_WRITE_DVD_RW 
00105      | CDIO_DRIVE_CAP_WRITE_DVD_RPW ),
00108     CDIO_DRIVE_CAP_WRITE = 
00109     (CDIO_DRIVE_CAP_WRITE_CD | CDIO_DRIVE_CAP_WRITE_DVD)
00111   } cdio_drive_cap_write_t;
00112     
00114   typedef enum {
00115     CDIO_MMC_HW_VENDOR_LEN   =  8, 
00116     CDIO_MMC_HW_MODEL_LEN    = 16, 
00117     CDIO_MMC_HW_REVISION_LEN =  4  
00118   } cdio_mmc_hw_len_t;
00119     
00120 
00123   typedef struct cdio_hwinfo 
00124   {
00125     char psz_vendor  [CDIO_MMC_HW_VENDOR_LEN+1];
00126     char psz_model   [CDIO_MMC_HW_MODEL_LEN+1];
00127     char psz_revision[CDIO_MMC_HW_REVISION_LEN+1];
00128   } cdio_hwinfo_t;
00129 
00130 
00132   typedef enum {
00133     CDIO_SRC_IS_DISK_IMAGE_MASK = 0x0001, 
00134     CDIO_SRC_IS_DEVICE_MASK     = 0x0002, 
00135     CDIO_SRC_IS_SCSI_MASK       = 0x0004, 
00136     CDIO_SRC_IS_NATIVE_MASK     = 0x0008
00137   } cdio_src_category_mask_t;
00138     
00139 
00152   typedef enum  {
00153     DRIVER_UNKNOWN, 
00155     DRIVER_AIX,     
00156     DRIVER_BSDI,    
00157     DRIVER_FREEBSD, 
00158     DRIVER_NETBSD,  
00159     DRIVER_LINUX,   
00160     DRIVER_SOLARIS, 
00161     DRIVER_OS2,     
00162     DRIVER_OSX,     
00163     DRIVER_WIN32,   
00165     DRIVER_CDRDAO,  
00168     DRIVER_BINCUE,  
00171     DRIVER_NRG,     
00172     DRIVER_DEVICE   
00173   } driver_id_t;
00174 
00179   extern const driver_id_t cdio_drivers[];
00180 
00185   extern const driver_id_t cdio_device_drivers[];
00186 
00193   extern const driver_id_t cdio_os_driver;
00194   
00195 
00203 LIBCDIO_DEPRECATED(static const driver_id_t CDIO_MIN_DRIVER, "please use cdio_drivers") = DRIVER_AIX;
00204 LIBCDIO_DEPRECATED(static const driver_id_t CDIO_MIN_DEVICE_DRIVER, "please use cdio_device_drivers") = DRIVER_AIX;
00205 LIBCDIO_DEPRECATED(static const driver_id_t CDIO_MAX_DRIVER, "please use cdio_drivers") = DRIVER_NRG;
00206 LIBCDIO_DEPRECATED(static const driver_id_t CDIO_MAX_DEVICE_DRIVER, "please use cdio_device_drivers") = DRIVER_WIN32;
00207 
00220   typedef enum  {
00221     DRIVER_OP_SUCCESS        =  0, 
00226     DRIVER_OP_ERROR          = -1, 
00227     DRIVER_OP_UNSUPPORTED    = -2, 
00232     DRIVER_OP_UNINIT         = -3, 
00236     DRIVER_OP_NOT_PERMITTED  = -4, 
00240     DRIVER_OP_BAD_PARAMETER  = -5, 
00241     DRIVER_OP_BAD_POINTER    = -6, 
00242     DRIVER_OP_NO_DRIVER      = -7, 
00244     DRIVER_OP_MMC_SENSE_DATA = -8, 
00246   } driver_return_code_t;
00247 
00257   driver_return_code_t cdio_close_tray (const char *psz_drive, 
00258                                         /*in/out*/ driver_id_t *p_driver_id);
00259 
00264   const char *cdio_driver_errmsg(driver_return_code_t drc);
00265   
00272   driver_return_code_t cdio_eject_media (CdIo_t **p_cdio);
00273 
00280   driver_return_code_t cdio_eject_media_drive (const char *psz_drive);
00281 
00292   void cdio_free_device_list (char * device_list[]);
00293 
00307   char * cdio_get_default_device (const CdIo_t *p_cdio);
00308 
00316   char * cdio_get_default_device_driver (/*in/out*/ driver_id_t *p_driver_id);
00317 
00329   char ** cdio_get_devices (driver_id_t driver_id);
00330 
00367   char ** cdio_get_devices_with_cap (/*in*/ char *ppsz_search_devices[],
00368                                      cdio_fs_anal_t capabilities, bool b_any);
00369 
00376   char ** cdio_get_devices_with_cap_ret (/*in*/ char* ppsz_search_devices[],
00377                                          cdio_fs_anal_t capabilities, 
00378                                          bool b_any,
00379                                          /*out*/ driver_id_t *p_driver_id);
00380 
00389   char ** cdio_get_devices_ret (/*in/out*/ driver_id_t *p_driver_id);
00390 
00403   void cdio_get_drive_cap (const CdIo_t *p_cdio,
00404                            cdio_drive_read_cap_t  *p_read_cap,
00405                            cdio_drive_write_cap_t *p_write_cap,
00406                            cdio_drive_misc_cap_t  *p_misc_cap);
00407   
00417   void cdio_get_drive_cap_dev (const char *device,
00418                                cdio_drive_read_cap_t  *p_read_cap,
00419                                cdio_drive_write_cap_t *p_write_cap,
00420                                cdio_drive_misc_cap_t  *p_misc_cap);
00421 
00428   const char * cdio_get_driver_name (const CdIo_t *p_cdio);
00429 
00437   driver_id_t cdio_get_driver_id (const CdIo_t *p_cdio);
00438 
00443   bool cdio_get_hwinfo ( const CdIo_t *p_cdio, 
00444                          /*out*/ cdio_hwinfo_t *p_hw_info );
00445 
00446 
00454   driver_return_code_t cdio_get_last_session (CdIo_t *p_cdio,
00455                                               /*out*/ lsn_t *i_last_session);
00456 
00463   int cdio_get_media_changed(CdIo_t *p_cdio);
00464 
00466   bool_3way_t cdio_have_atapi (CdIo_t *p_cdio);
00467 
00469   bool cdio_have_driver (driver_id_t driver_id);
00470 
00477   void cdio_destroy (CdIo_t *p_cdio);
00478 
00485   const char *cdio_driver_describe (driver_id_t driver_id);
00486   
00497   CdIo_t * cdio_open (const char *psz_source, driver_id_t driver_id);
00498 
00510   CdIo_t * cdio_open_am (const char *psz_source, 
00511                          driver_id_t driver_id, const char *psz_access_mode);
00512 
00519   CdIo_t * cdio_open_bincue (const char *psz_cue_name);
00520   
00527   CdIo_t * cdio_open_am_bincue (const char *psz_cue_name, 
00528                                 const char *psz_access_mode);
00529   
00535   CdIo_t * cdio_open_cdrdao (const char *psz_toc_name);
00536   
00542   CdIo_t * cdio_open_am_cdrdao (const char *psz_toc_name, 
00543                                 const char *psz_access_mode);
00544   
00551   char * cdio_get_default_device_bincue(void);
00552 
00553   char **cdio_get_devices_bincue(void);
00554 
00560   char * cdio_get_default_device_cdrdao(void);
00561 
00562   char **cdio_get_devices_cdrdao(void);
00563 
00571   CdIo_t * cdio_open_cd (const char *device_name);
00572 
00580   CdIo_t * cdio_open_am_cd (const char *psz_device,
00581                             const char *psz_access_mode);
00582 
00589   CdIo_t * cdio_open_cue (const char *cue_name);
00590 
00600   CdIo_t * cdio_open_am_aix (const char *psz_source,
00601                              const char *psz_access_mode);
00602   
00612   CdIo_t * cdio_open_aix (const char *psz_source);
00613   
00623   char * cdio_get_default_device_aix(void);
00624 
00633   char **cdio_get_devices_aix(void);
00634   
00645   CdIo_t * cdio_open_bsdi (const char *psz_source);
00646   
00656   CdIo_t * cdio_open_am_bsdi (const char *psz_source,
00657                               const char *psz_access_mode);
00658   
00668   char * cdio_get_default_device_bsdi(void);
00669 
00678   char **cdio_get_devices_bsdi(void);
00679   
00688   CdIo_t * cdio_open_freebsd (const char *paz_psz_source);
00689   
00698   CdIo_t * cdio_open_am_freebsd (const char *psz_source,
00699                                  const char *psz_access_mode);
00700   
00707   char * cdio_get_default_device_freebsd(void);
00708 
00713   char **cdio_get_devices_freebsd(void);
00714   
00726   CdIo_t * cdio_open_linux (const char *psz_source);
00727 
00735   CdIo_t * cdio_open_am_linux (const char *psz_source,
00736                                const char *access_mode);
00737 
00751   char * cdio_get_default_device_linux(void);
00752 
00757   char **cdio_get_devices_linux(void);
00758   
00766   CdIo_t * cdio_open_solaris (const char *psz_source);
00767   
00775   CdIo_t * cdio_open_am_solaris (const char *psz_source, 
00776                                  const char *psz_access_mode);
00777   
00791   char * cdio_get_default_device_solaris(void);
00792   
00797   char **cdio_get_devices_solaris(void);
00798   
00811   CdIo_t * cdio_open_osx (const char *psz_source);
00812 
00821   CdIo_t * cdio_open_am_osx (const char *psz_source,
00822                              const char *psz_access_mode);
00823 
00833   char * cdio_get_default_device_osx(void);
00834   
00839   char **cdio_get_devices_osx(void);
00840   
00849   CdIo_t * cdio_open_win32 (const char *psz_source);
00850   
00857   CdIo_t * cdio_open_am_win32 (const char *psz_source,
00858                                const char *psz_access_mode);
00859   
00871   char * cdio_get_default_device_win32(void);
00872 
00873   char **cdio_get_devices_win32(void);
00874   
00887   CdIo_t * cdio_open_os2 (const char *psz_source);
00888 
00897   CdIo_t * cdio_open_am_os2 (const char *psz_source,
00898                             const char *psz_access_mode);
00899 
00909   char * cdio_get_default_device_os2(void);
00910 
00915   char **cdio_get_devices_os2(void);
00916 
00923   CdIo_t * cdio_open_nrg (const char *psz_source);
00924   
00931   CdIo_t * cdio_open_am_nrg (const char *psz_source,
00932                              const char *psz_access_mode);
00933   
00942   char * cdio_get_default_device_nrg(void);
00943 
00944   char **cdio_get_devices_nrg(void);
00945 
00954   char *cdio_is_binfile(const char *bin_name);
00955   
00962   char *cdio_is_cuefile(const char *cue_name);
00963   
00971   bool cdio_is_nrg(const char *psz_nrg);
00972   
00980   bool cdio_is_tocfile(const char *psz_toc);
00981   
00991   bool cdio_is_device(const char *psz_source, driver_id_t driver_id);
00992 
00996   driver_return_code_t cdio_set_blocksize ( const CdIo_t *p_cdio, 
00997                                             int i_blocksize );
00998 
01015   driver_return_code_t cdio_set_speed ( const CdIo_t *p_cdio, 
01016                                         int i_drive_speed );
01017 
01026   const char * cdio_get_arg (const CdIo_t *p_cdio,  const char key[]);
01027 
01035   driver_return_code_t cdio_set_arg (CdIo_t *p_cdio, const char key[], 
01036                                      const char value[]);
01037   
01041   bool cdio_init(void);
01042   
01043 #ifdef __cplusplus
01044 }
01045 #endif /* __cplusplus */
01046 
01052 extern cdio_drive_cap_misc_t          debug_cdio_drive_cap_misc;
01053 extern cdio_drive_cap_read_t          debug_cdio_drive_cap_read_t;
01054 extern cdio_drive_cap_write_t         debug_drive_cap_write_t;
01055 extern cdio_mmc_hw_len_t              debug_cdio_mmc_hw_len;
01056 extern cdio_src_category_mask_t       debug_cdio_src_category_mask;
01057 
01058 #endif /* CDIO_DEVICE_H_ */