libcdio  2.1.0
About: GNU libcdio is a library for CD-ROM and CD image access.
  Fossies Dox: libcdio-2.1.0.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

cdio_private.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003-2005, 2008-2009, 2011-2012, 2016-2017
3  Rocky Bernstein <rocky@gnu.org>
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 /* Internal routines for CD I/O drivers. */
20 
21 
22 #ifndef CDIO_DRIVER_PRIVATE_H_
23 #define CDIO_DRIVER_PRIVATE_H_
24 
25 #if defined(HAVE_CONFIG_H) && !defined(LIBCDIO_CONFIG_H)
26 # include "config.h"
27 #endif
28 
29 #ifdef HAVE_STDLIB_H
30 #include <stdlib.h>
31 #endif
32 #ifdef HAVE_STRING_H
33 #include <string.h>
34 #endif
35 
36 #include <cdio/cdio.h>
37 #include <cdio/audio.h>
38 #include <cdio/cdtext.h>
39 #include "mmc/mmc_private.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif /* __cplusplus */
44 
45 #ifndef HAVE_STRNDUP
46 #undef strndup
47 #define strndup libcdio_strndup
48 static inline char *libcdio_strndup(const char *s, size_t n)
49 {
50  char *result;
51  size_t len = strlen (s);
52  if (n < len)
53  len = n;
54  result = (char *) malloc (len + 1);
55  if (!result)
56  return 0;
57  result[len] = '\0';
58  return (char *) strncpy (result, s, len);
59 }
60 #endif /*HAVE_STRNDUP*/
61 
67  extern char *cdio_dirname(const char *fname);
68 
74  extern char *cdio_abspath(const char *cwd, const char *fname);
75 
76  /* Opaque type */
78 
79 #ifdef __cplusplus
80 }
81 
82 #endif /* __cplusplus */
83 
84 #include "generic.h"
85 
86 #ifdef __cplusplus
87 extern "C" {
88 #endif /* __cplusplus */
89 
90 
91  typedef struct {
92 
99  driver_return_code_t (*audio_get_volume)
100  (void *p_env, /*out*/ cdio_audio_volume_t *p_volume);
101 
107  driver_return_code_t (*audio_pause) (void *p_env);
108 
114  driver_return_code_t (*audio_play_msf) ( void *p_env,
115  msf_t *p_start_msf,
116  msf_t *p_end_msf );
117 
123  driver_return_code_t (*audio_play_track_index)
124  ( void *p_env, cdio_track_index_t *p_track_index );
125 
131  driver_return_code_t (*audio_read_subchannel)
132  ( void *p_env, cdio_subchannel_t *subchannel );
133 
140  driver_return_code_t (*audio_resume) ( void *p_env );
141 
148  driver_return_code_t (*audio_set_volume)
149  ( void *p_env, cdio_audio_volume_t *p_volume );
150 
157  driver_return_code_t (*audio_stop) ( void *p_env );
158 
166  driver_return_code_t (*eject_media) ( void *p_env );
167 
171  void (*free) (void *p_env);
172 
176  const char * (*get_arg) (void *p_env, const char key[]);
177 
182  int (*get_blocksize) ( void *p_env );
183 
191  cdtext_t * (*get_cdtext) ( void *p_env );
192 
202  uint8_t * (*get_cdtext_raw) ( void *p_env );
203 
211  char ** (*get_devices) ( void );
212 
223  char * (*get_default_device) ( void );
224 
229  lsn_t (*get_disc_last_lsn) ( void *p_env );
230 
234  discmode_t (*get_discmode) ( void *p_env );
235 
241  void (*get_drive_cap) (const void *p_env,
242  cdio_drive_read_cap_t *p_read_cap,
243  cdio_drive_write_cap_t *p_write_cap,
244  cdio_drive_misc_cap_t *p_misc_cap);
249  track_t (*get_first_track_num) ( void *p_env );
250 
255  bool (*get_hwinfo)
256  ( const CdIo_t *p_cdio, /* out*/ cdio_hwinfo_t *p_hw_info );
257 
264  driver_return_code_t (*get_last_session)
265  ( void *p_env, /*out*/ lsn_t *i_last_session );
266 
273  int (*get_media_changed) ( const void *p_env );
274 
279  char * (*get_mcn) ( const void *p_env );
280 
285  track_t (*get_num_tracks) ( void *p_env );
286 
291  int (*get_track_channels) ( const void *p_env, track_t i_track );
292 
297  track_flag_t (*get_track_copy_permit) ( void *p_env, track_t i_track );
298 
306  lba_t (*get_track_lba) ( void *p_env, track_t i_track );
307 
313  lba_t (*get_track_pregap_lba) ( const void *p_env, track_t i_track );
314 
322  char * (*get_track_isrc) ( const void *p_env, track_t i_track );
323 
327  track_format_t (*get_track_format) ( void *p_env, track_t i_track );
328 
337  bool (*get_track_green) ( void *p_env, track_t i_track );
338 
346  bool (*get_track_msf) ( void *p_env, track_t i_track, msf_t *p_msf );
347 
352  track_flag_t (*get_track_preemphasis)
353  ( const void *p_env, track_t i_track );
354 
360  off_t (*lseek) ( void *p_env, off_t offset, int whence );
361 
367  ssize_t (*read) ( void *p_env, void *p_buf, size_t i_size );
368 
373  int (*read_audio_sectors) ( void *p_env, void *p_buf, lsn_t i_lsn,
374  unsigned int i_blocks );
375 
393  driver_return_code_t (*read_data_sectors)
394  ( void *p_env, void *p_buf, lsn_t i_lsn, uint16_t i_blocksize,
395  uint32_t i_blocks );
396 
401  int (*read_mode2_sector)
402  ( void *p_env, void *p_buf, lsn_t i_lsn, bool b_mode2_form2 );
403 
409  int (*read_mode2_sectors)
410  ( void *p_env, void *p_buf, lsn_t i_lsn, bool b_mode2_form2,
411  unsigned int i_blocks );
412 
417  int (*read_mode1_sector)
418  ( void *p_env, void *p_buf, lsn_t i_lsn, bool mode1_form2 );
419 
425  int (*read_mode1_sectors)
426  ( void *p_env, void *p_buf, lsn_t i_lsn, bool mode1_form2,
427  unsigned int i_blocks );
428 
429  bool (*read_toc) ( void *p_env ) ;
430 
448 
452  int (*set_arg) ( void *p_env, const char key[], const char value[] );
453 
457  driver_return_code_t (*set_blocksize) ( void *p_env,
458  uint16_t i_blocksize );
459 
466  int (*set_speed) ( void *p_env, int i_speed );
467 
468  } cdio_funcs_t;
469 
470 
472  struct _CdIo {
476  void *env;
477  };
478 
479  /* This is used in drivers that must keep their own internal
480  position pointer for doing seeks. Stream-based drivers (like bincue,
481  nrg, toc, network) would use this.
482  */
483  typedef struct
484  {
485  off_t buff_offset; /* buffer offset in disk-image seeks. */
486  track_t index; /* Current track index in tocent. */
487  lba_t lba; /* Current LBA */
489 
490  CdIo_t * cdio_new (generic_img_private_t *p_env, cdio_funcs_t *p_funcs);
491 
492  /* The below structure describes a specific CD Input driver */
493  typedef struct
494  {
496  unsigned int flags;
497  const char *name;
498  const char *describe;
499  bool (*have_driver) (void);
500  CdIo_t *(*driver_open) (const char *psz_source_name);
501  CdIo_t *(*driver_open_am) (const char *psz_source_name,
502  const char *psz_access_mode);
503  char *(*get_default_device) (void);
504  bool (*is_device) (const char *psz_source_name);
505  char **(*get_devices) (void);
506  driver_return_code_t (*close_tray) (const char *psz_device);
507  } CdIo_driver_t;
508 
509  /* The below array gives of the drivers that are currently available for
510  on a particular host. */
511  extern CdIo_driver_t CdIo_driver[];
512 
513  /* The last valid entry of Cdio_driver. -1 means uninitialzed. -2
514  means some sort of error.
515  */
516  extern int CdIo_last_driver;
517 
518  /* The below array gives all drivers that can possibly appear.
519  on a particular host. */
521 
526  void cdio_add_device_list(char **device_list[], const char *psz_drive,
527  unsigned int *i_drives);
528 
529  driver_return_code_t close_tray_bsdi (const char *psz_drive);
530  driver_return_code_t close_tray_freebsd (const char *psz_drive);
531  driver_return_code_t close_tray_linux (const char *psz_drive);
532  driver_return_code_t close_tray_netbsd (const char *psz_drive);
533  driver_return_code_t close_tray_osx (const char *psz_drive);
534  driver_return_code_t close_tray_solaris (const char *psz_drive);
535  driver_return_code_t close_tray_win32 (const char *psz_drive);
536 
537  bool cdio_have_netbsd(void);
538  CdIo_t * cdio_open_netbsd (const char *psz_source);
539  char * cdio_get_default_device_netbsd(void);
540  char **cdio_get_devices_netbsd(void);
548  CdIo_t * cdio_open_am_netbsd (const char *psz_source,
549  const char *psz_access_mode);
550 
553  bool cdio_have_aix (void);
554 
557  bool cdio_have_bsdi (void);
558 
561  bool cdio_have_freebsd (void);
562 
565  bool cdio_have_linux (void);
566 
569  bool cdio_have_solaris (void);
570 
573  bool cdio_have_os2 (void);
574 
577  bool cdio_have_osx (void);
578 
581  bool cdio_have_win32 (void);
582 
584  bool cdio_have_nrg (void);
585 
587  bool cdio_have_bincue (void);
588 
590  bool cdio_have_cdrdao (void);
591 
592 #ifdef __cplusplus
593 }
594 #endif /* __cplusplus */
595 
596 #endif /* CDIO_DRIVER_PRIVATE_H_ */
cdio_have_aix
bool cdio_have_aix(void)
Definition: aix.c:1024
lseek
off_t lseek(off_t offset, int whence)
Definition: read.hpp:34
close_tray_solaris
driver_return_code_t close_tray_solaris(const char *psz_drive)
Definition: solaris.c:1158
lba_t
int32_t lba_t
Definition: types.h:259
_CdioDataSource
Definition: _cdio_stream.c:48
CdIo_driver_t::flags
unsigned int flags
Definition: cdio_private.h:496
close_tray_linux
driver_return_code_t close_tray_linux(const char *psz_drive)
Definition: gnu_linux.c:1501
cdio.h
The top-level header for libcdio: the CD Input and Control library. Applications include this for any...
bool
#define bool
Definition: types.h:119
cdio_open_netbsd
CdIo_t * cdio_open_netbsd(const char *psz_source)
Definition: netbsd.c:873
CdIo_driver
CdIo_driver_t CdIo_driver[]
Definition: device.c:248
lsn_t
int32_t lsn_t
Definition: types.h:266
close_tray_win32
driver_return_code_t close_tray_win32(const char *psz_drive)
Definition: win32.c:930
driver_return_code_t
driver_return_code_t
Definition: device.h:205
cdio_funcs_t::run_mmc_cmd
mmc_run_cmd_fn_t run_mmc_cmd
Definition: cdio_private.h:447
read_toc
static void read_toc(CdIo_t *p_cdio)
Definition: cdda-player.c:589
track_t
uint8_t track_t
Definition: types.h:276
CdIo_last_driver
int CdIo_last_driver
Definition: device.c:59
cdio_new
CdIo_t * cdio_new(generic_img_private_t *p_env, cdio_funcs_t *p_funcs)
Definition: cdio.c:58
CdIo_driver_t::describe
const char * describe
Definition: cdio_private.h:498
close_tray_freebsd
driver_return_code_t close_tray_freebsd(const char *psz_drive)
Definition: freebsd.c:926
generic.h
cdio_dirname
char * cdio_dirname(const char *fname)
Definition: abs_path.c:84
_CdIo
Definition: cdio_private.h:472
cdio_track_index_s
Definition: audio.h:54
CdIo_driver_t
Definition: cdio_private.h:493
discmode_t
discmode_t
Definition: disc.h:37
_CdIo::env
void * env
Definition: cdio_private.h:476
read
ssize_t read(void *p_buf, size_t i_size)
Definition: read.hpp:49
cdio_have_bincue
bool cdio_have_bincue(void)
Definition: bincue.c:1346
cdio_have_win32
bool cdio_have_win32(void)
Definition: win32.c:1075
cdio_open_am_netbsd
CdIo_t * cdio_open_am_netbsd(const char *psz_source, const char *psz_access_mode)
Definition: netbsd.c:929
close_tray_netbsd
driver_return_code_t close_tray_netbsd(const char *psz_drive)
Definition: netbsd.c:804
cdio_have_netbsd
bool cdio_have_netbsd(void)
Definition: netbsd.c:935
CdIo_driver_t::name
const char * name
Definition: cdio_private.h:497
libcdio_strndup
static char * libcdio_strndup(const char *s, size_t n)
Definition: cdio_private.h:48
cdio_have_nrg
bool cdio_have_nrg(void)
Definition: nrg.c:1406
cdio_abspath
char * cdio_abspath(const char *cwd, const char *fname)
Definition: abs_path.c:94
cdio_have_bsdi
bool cdio_have_bsdi(void)
track_format_t
track_format_t
Definition: track.h:31
cdtext.h
The top-level header for CD-Text information. Applications include this for CD-Text access.
cdio_have_osx
bool cdio_have_osx(void)
Definition: osx.c:2081
msf_s
MSF (minute/second/frame) structure.
Definition: types.h:219
cdio_hwinfo
Structure to return CD vendor, model, and revision-level strings obtained via the INQUIRY command
Definition: device.h:122
cdio_add_device_list
void cdio_add_device_list(char **device_list[], const char *psz_drive, unsigned int *i_drives)
Definition: _cdio_generic.c:238
cdio_get_default_device_netbsd
char * cdio_get_default_device_netbsd(void)
Definition: netbsd.c:792
cdio_have_linux
bool cdio_have_linux(void)
Definition: gnu_linux.c:1767
_CdIo::op
cdio_funcs_t op
Definition: cdio_private.h:474
internal_position_t::buff_offset
off_t buff_offset
Definition: cdio_private.h:485
cdio_have_cdrdao
bool cdio_have_cdrdao(void)
Definition: cdrdao.c:1381
generic_img_private_t
Definition: generic.h:47
config.h
cdio_drive_write_cap_t
uint32_t cdio_drive_write_cap_t
Definition: device.h:37
CdIo_all_drivers
CdIo_driver_t CdIo_all_drivers[]
Definition: device.c:99
_CdIo::driver_id
driver_id_t driver_id
Definition: cdio_private.h:473
cdio_have_os2
bool cdio_have_os2(void)
close_tray_osx
driver_return_code_t close_tray_osx(const char *psz_drive)
Definition: osx.c:1749
audio.h
The top-level header for CD audio-related libcdio calls. These control playing of the CD-ROM through ...
cdio_have_freebsd
bool cdio_have_freebsd(void)
Definition: freebsd.c:1259
cdtext_s
Definition: cdtext_private.h:127
close_tray_bsdi
driver_return_code_t close_tray_bsdi(const char *psz_drive)
cdio_drive_read_cap_t
uint32_t cdio_drive_read_cap_t
Definition: device.h:36
track_flag_t
track_flag_t
Definition: track.h:42
mmc_run_cmd_fn_t
driver_return_code_t(* mmc_run_cmd_fn_t)(void *p_user_data, unsigned int i_timeout_ms, unsigned int i_cdb, const mmc_cdb_t *p_cdb, cdio_mmc_direction_t e_direction, unsigned int i_buf, void *p_buf)
Definition: mmc_private.h:108
cdio_get_devices_netbsd
char ** cdio_get_devices_netbsd(void)
Definition: netbsd.c:702
internal_position_t::index
track_t index
Definition: cdio_private.h:486
internal_position_t
Definition: cdio_private.h:483
driver_id_t
driver_id_t
Definition: device.h:151
cdio_drive_misc_cap_t
uint32_t cdio_drive_misc_cap_t
Definition: device.h:38
internal_position_t::lba
lba_t lba
Definition: cdio_private.h:487
cdio_funcs_t
Definition: cdio_private.h:91
cdio_subchannel_s
Definition: audio.h:34
cdio_audio_volume_s
Definition: audio.h:47
mmc_private.h
CdIo_driver_t::id
driver_id_t id
Definition: cdio_private.h:495
cdio_have_solaris
bool cdio_have_solaris(void)
Definition: solaris.c:1480