Beispiel #1
0
/*!
  Initialization routine. This is the only thing that doesn't
  get called via a function pointer. In fact *we* are the
  ones to set that up.
 */
CdIo *
cdio_open_linux (const char *orig_source_name)
{

#ifdef HAVE_LINUX_CDROM
  CdIo *ret;
  _img_private_t *_data;
  char *source_name;

  cdio_funcs _funcs = {
    .eject_media        = _cdio_eject_media,
    .free               = cdio_generic_free,
    .get_arg            = _cdio_get_arg,
    .get_devices        = cdio_get_devices_linux,
    .get_default_device = cdio_get_default_device_linux,
    .get_first_track_num= _cdio_get_first_track_num,
    .get_mcn            = _cdio_get_mcn,
    .get_num_tracks     = _cdio_get_num_tracks,
    .get_track_format   = _cdio_get_track_format,
    .get_track_green    = _cdio_get_track_green,
    .get_track_lba      = NULL, /* This could be implemented if need be. */
    .get_track_msf      = _cdio_get_track_msf,
    .lseek              = cdio_generic_lseek,
    .read               = cdio_generic_read,
    .read_audio_sectors = _cdio_read_audio_sectors,
    .read_mode2_sector  = _cdio_read_mode2_sector,
    .read_mode2_sectors = _cdio_read_mode2_sectors,
    .set_arg            = _cdio_set_arg,
    .stat_size          = _cdio_stat_size
  };

  _data                 = _cdio_malloc (sizeof (_img_private_t));
  _data->access_mode    = _AM_READ_CD;
  _data->gen.init       = false;
  _data->gen.fd         = -1;

  if (NULL == orig_source_name) {
    source_name=cdio_get_default_device_linux();
    if (NULL == source_name) return NULL;
    _cdio_set_arg(_data, "source", source_name);
    free(source_name);
  } else 
    _cdio_set_arg(_data, "source", orig_source_name);

  ret = cdio_new (_data, &_funcs);
  if (ret == NULL) return NULL;

  if (cdio_generic_init(_data))
    return ret;
  else {
    cdio_generic_free (_data);
    return NULL;
  }
  
#else 
  return NULL;
#endif /* HAVE_LINUX_CDROM */

}
Beispiel #2
0
CdIo *
cdio_open_freebsd(const char *source_name)
{
	CdIo *ret;
	_img_private_t *_data;

	_data = calloc(1, sizeof(_img_private_t));
	_data->gen.init = false;
	_data->gen.fd = -1;
	_data->toc_valid = false;
	_data->sessionformat_valid = false;

	_cdio_set_arg(_data, "source",
		      (source_name ? source_name : DEFAULT_CDIO_DEVICE));

	if (source_name && !cdio_is_device_generic(source_name))
		return (NULL);

	ret = cdio_new(&_data->gen, &_funcs);
	if (!ret)
		return NULL;

	if (cdio_generic_init(_data, O_RDONLY)) {
		return ret;
	} else {
		cdio_generic_free(_data);
		return NULL;
	}
}