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)  

read.h File Reference

The top-level header for sector (block, frame)-related libcdio calls. More...

#include <cdio/types.h>
Include dependency graph for read.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  cdio_read_mode_t {
  CDIO_READ_MODE_AUDIO, CDIO_READ_MODE_M1F1, CDIO_READ_MODE_M1F2, CDIO_READ_MODE_M2F1,
  CDIO_READ_MODE_M2F2
}
 

Functions

off_t cdio_lseek (const CdIo_t *p_cdio, off_t offset, int whence)
 
ssize_t cdio_read (const CdIo_t *p_cdio, void *p_buf, size_t i_size)
 
driver_return_code_t cdio_read_audio_sector (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn)
 
driver_return_code_t cdio_read_audio_sectors (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, uint32_t i_blocks)
 
driver_return_code_t cdio_read_data_sectors (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, uint16_t i_blocksize, uint32_t i_blocks)
 
driver_return_code_t cdio_read_mode1_sector (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, bool b_form2)
 
driver_return_code_t cdio_read_mode1_sectors (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, bool b_form2, uint32_t i_blocks)
 
driver_return_code_t cdio_read_mode2_sector (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, bool b_form2)
 
driver_return_code_t cdio_read_sector (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, cdio_read_mode_t read_mode)
 
driver_return_code_t cdio_read_mode2_sectors (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, bool b_form2, uint32_t i_blocks)
 
driver_return_code_t cdio_read_sectors (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, cdio_read_mode_t read_mode, uint32_t i_blocks)
 

Detailed Description

The top-level header for sector (block, frame)-related libcdio calls.

sector (block, frame)-related libcdio routines.

Definition in file read.h.

Enumeration Type Documentation

◆ cdio_read_mode_t

All the different ways a block/sector can be read.

Enumerator
CDIO_READ_MODE_AUDIO 

CD-DA, audio, Red Book

CDIO_READ_MODE_M1F1 

Mode 1 Form 1

CDIO_READ_MODE_M1F2 

Mode 1 Form 2

CDIO_READ_MODE_M2F1 

Mode 2 Form 1

CDIO_READ_MODE_M2F2 

Mode 2 Form 2

Definition at line 34 of file read.h.

Function Documentation

◆ cdio_lseek()

off_t cdio_lseek ( const CdIo_t p_cdio,
off_t  offset,
int  whence 
)

Reposition read offset Similar to (if not the same as) libc's fseek()

Parameters
p_cdioobject which gets adjusted
offsetamount to seek
whencelike corresponding parameter in libc's fseek, e.g. SEEK_SET or SEEK_END.
Returns
(off_t) -1 on error.

lseek - reposition read/write file offset Returns (off_t) -1 on error. Similar to (if not the same as) libc's lseek()

Definition at line 83 of file read.c.

References DRIVER_OP_UNINIT, DRIVER_OP_UNSUPPORTED, _CdIo::env, cdio_funcs_t::lseek, and _CdIo::op.

Referenced by cdio_read_mode1_sector(), and lseek().

◆ cdio_read()

ssize_t cdio_read ( const CdIo_t p_cdio,
void *  p_buf,
size_t  i_size 
)

Reads into buf the next size bytes. Similar to (if not the same as) libc's read(). This is a "cooked" read, or one handled by the OS. It probably won't work on audio data. For that use cdio_read_audio_sector(s).

Parameters
p_cdioobject to read from
p_bufplace to read data into. The caller should make sure this location can store at least i_size bytes.
i_sizenumber of bytes to read
Returns
(ssize_t) -1 on error.

Definition at line 105 of file read.c.

References DRIVER_OP_UNINIT, DRIVER_OP_UNSUPPORTED, _CdIo::env, _CdIo::op, and cdio_funcs_t::read.

Referenced by cdio_read_mode1_sector(), and read().

◆ cdio_read_audio_sector()

driver_return_code_t cdio_read_audio_sector ( const CdIo_t p_cdio,
void *  p_buf,
lsn_t  i_lsn 
)

Read an audio sector

Parameters
p_cdioobject to read from
p_bufplace to read data into. The caller should make sure this location can store at least CDIO_FRAMESIZE_RAW bytes.
i_lsnsector to read

Reads an audio sector from cd device into data starting from lsn. Returns DRIVER_OP_SUCCESS if no error.

Definition at line 119 of file read.c.

References check_lsn, DRIVER_OP_UNSUPPORTED, _CdIo::env, _CdIo::op, and cdio_funcs_t::read_audio_sectors.

◆ cdio_read_audio_sectors()

driver_return_code_t cdio_read_audio_sectors ( const CdIo_t p_cdio,
void *  p_buf,
lsn_t  i_lsn,
uint32_t  i_blocks 
)

Reads audio sectors

Parameters
p_cdioobject to read from
p_bufplace to read data into. The caller should make sure this location can store at least CDIO_FRAMESIZE_RAW i_blocks bytes.
i_lsnsector to read
i_blocksnumber of sectors to read

Reads audio sectors from cd device into data starting from lsn. Returns DRIVER_OP_SUCCESS if no error.

Definition at line 132 of file read.c.

References cdio_debug(), check_lsn_blocks, DRIVER_OP_SUCCESS, DRIVER_OP_UNSUPPORTED, _CdIo::env, _CdIo::op, and cdio_funcs_t::read_audio_sectors.

Referenced by cdio_read_sectors().

◆ cdio_read_data_sectors()

driver_return_code_t cdio_read_data_sectors ( const CdIo_t p_cdio,
void *  p_buf,
lsn_t  i_lsn,
uint16_t  i_blocksize,
uint32_t  i_blocks 
)

Read data sectors

Parameters
p_cdioobject to read from
p_bufplace to read data into. The caller should make sure this location can store at least ISO_BLOCKSIZE, M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE depending on the kind of sector getting read. If you don't know whether you have a Mode 1/2, Form 1/ Form 2/Formless sector best to reserve space for the maximum, M2RAW_SECTOR_SIZE.
i_lsnsector to read
i_blocksizesize of block. Should be either CDIO_CD_FRAMESIZE, M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE. See comment above under p_buf.
i_blocksnumber of blocks to read

Reads an audio sector from cd device into data starting from lsn. Returns DRIVER_OP_SUCCESS if no error.

Definition at line 153 of file read.c.

References cdio_debug(), check_lsn, DRIVER_OP_SUCCESS, DRIVER_OP_UNSUPPORTED, _CdIo::env, _CdIo::op, and cdio_funcs_t::read_data_sectors.

Referenced by _cdio_read_block(), _fs_stat_traverse(), iso9660_fs_read_pvd(), iso9660_fs_read_superblock(), iso9660_fs_readdir(), readDataBlocks(), and udf_read_sectors().

◆ cdio_read_mode1_sector()

driver_return_code_t cdio_read_mode1_sector ( const CdIo_t p_cdio,
void *  p_buf,
lsn_t  i_lsn,
bool  b_form2 
)

Reads a mode 1 sector

Parameters
p_cdioobject to read from
p_bufplace to read data into.
i_lsnsector to read
b_form2true for reading mode 1 form 2 sectors or false for mode 1 form 1 sectors.

Reads a single mode1 form1 or form2 sector from cd device into data starting from lsn. Returns DRIVER_OP_SUCCESS if no error.

Definition at line 179 of file read.c.

References CDIO_CD_FRAMESIZE, cdio_debug(), cdio_lseek(), cdio_read(), check_lsn, DRIVER_OP_SUCCESS, DRIVER_OP_UNSUPPORTED, _CdIo::env, cdio_funcs_t::lseek, M2RAW_SECTOR_SIZE, _CdIo::op, cdio_funcs_t::read, cdio_funcs_t::read_mode1_sector, and SEEK_SET.

◆ cdio_read_mode1_sectors()

driver_return_code_t cdio_read_mode1_sectors ( const CdIo_t p_cdio,
void *  p_buf,
lsn_t  i_lsn,
bool  b_form2,
uint32_t  i_blocks 
)

Reads mode 1 sectors

Parameters
p_cdioobject to read from
p_bufplace to read data into
i_lsnsector to read
b_form2true for reading mode 1 form 2 sectors or false for mode 1 form 1 sectors.
i_blocksnumber of sectors to read

Reads mode 1 sectors

Parameters
p_cdioobject to read from
bufplace to read data into
lsnsector to read
b_form2true for reading mode 1 form 2 sectors or false for mode 1 form 1 sectors.
i_blocksnumber of sectors to read

Definition at line 212 of file read.c.

References check_lsn_blocks, DRIVER_OP_SUCCESS, DRIVER_OP_UNSUPPORTED, _CdIo::env, _CdIo::op, and cdio_funcs_t::read_mode1_sectors.

Referenced by cdio_read_sectors(), and read_data_sectors_image().

◆ cdio_read_mode2_sector()

driver_return_code_t cdio_read_mode2_sector ( const CdIo_t p_cdio,
void *  p_buf,
lsn_t  i_lsn,
bool  b_form2 
)

Reads a mode 2 sector

Parameters
p_cdioobject to read from
p_bufplace to read data into. The caller should make sure this location can store at least M2RAW_SECTOR_SIZE (for form 1) or CDIO_CD_FRAMESIZE (for form 2) bytes.
i_lsnsector to read
b_form2true for reading mode 2 form 2 sectors or false for mode 2 form 1 sectors.
Returns
0 if no error, nonzero otherwise.

Reads a mode 2 sector

Parameters
p_cdioobject to read from
bufplace to read data into
lsnsector to read
b_form2true for reading mode 2 form 2 sectors or false for mode 2 form 1 sectors.

Definition at line 235 of file read.c.

References cdio_read_mode2_sectors(), check_lsn, DRIVER_OP_UNSUPPORTED, _CdIo::env, NULL, _CdIo::op, cdio_funcs_t::read_mode2_sector, and cdio_funcs_t::read_mode2_sectors.

◆ cdio_read_mode2_sectors()

driver_return_code_t cdio_read_mode2_sectors ( const CdIo_t p_cdio,
void *  p_buf,
lsn_t  i_lsn,
bool  b_form2,
uint32_t  i_blocks 
)

Reads mode 2 sectors

Parameters
p_cdioobject to read from
p_bufplace to read data into. The caller should make sure this location can store at least M2RAW_SECTOR_SIZE (for form 1) or CDIO_CD_FRAMESIZE (for form 2) * i_blocks bytes.
i_lsnsector to read
b_form2true for reading mode2 form 2 sectors or false for mode 2 form 1 sectors.
i_blocksnumber of sectors to read
Returns
0 if no error, nonzero otherwise.

Reads mode 2 sectors

Parameters
p_cdioobject to read from
bufplace to read data into
lsnsector to read
b_form2true for reading mode2 form 2 sectors or false for mode 2 form 1 sectors.
i_blocksnumber of sectors to read

Definition at line 259 of file read.c.

References check_lsn_blocks, DRIVER_OP_SUCCESS, DRIVER_OP_UNSUPPORTED, _CdIo::env, _CdIo::op, and cdio_funcs_t::read_mode2_sectors.

Referenced by cdio_read_mode2_sector(), cdio_read_sectors(), and read_data_sectors_image().

◆ cdio_read_sector()

driver_return_code_t cdio_read_sector ( const CdIo_t p_cdio,
void *  p_buf,
lsn_t  i_lsn,
cdio_read_mode_t  read_mode 
)

The special case of reading a single block is a common one so we provide a routine for that as a convenience.

Definition at line 278 of file read.c.

References cdio_read_sectors().

Referenced by main().

◆ cdio_read_sectors()

driver_return_code_t cdio_read_sectors ( const CdIo_t p_cdio,
void *  p_buf,
lsn_t  i_lsn,
cdio_read_mode_t  read_mode,
uint32_t  i_blocks 
)

Reads a number of sectors (AKA blocks).

Parameters
p_cdiocdio object
p_bufplace to read data into. The caller should make sure this location is large enough. See below for size information.
read_modethe kind of "mode" to use in reading.
i_lsnsector to read
i_blocksnumber of sectors to read
Returns
DRIVER_OP_SUCCESS (0) if no error, other (negative) enumerations are returned on error.

If read_mode is CDIO_MODE_AUDIO, p_buf should hold at least CDIO_FRAMESIZE_RAW * i_blocks bytes.

If read_mode is CDIO_MODE_DATA, p_buf should hold at least i_blocks times either ISO_BLOCKSIZE, M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of sector getting read. If you don't know whether you have a Mode 1/2, Form 1/ Form 2/Formless sector best to reserve space for the maximum which is M2RAW_SECTOR_SIZE.

If read_mode is CDIO_MODE_M2F1, p_buf should hold at least M2RAW_SECTOR_SIZE * i_blocks bytes.

If read_mode is CDIO_MODE_M2F2, p_buf should hold at least CDIO_CD_FRAMESIZE * i_blocks bytes.

Reads a number of sectors (AKA blocks).

Parameters
p_bufplace to read data into. The caller should make sure this location is large enough. See below for size information.
read_modethe kind of "mode" to use in reading.
i_lsnsector to read
i_blocksnumber of sectors to read
Returns
DRIVER_OP_SUCCESS (0) if no error, other (negative) enumerations are returned on error.

If read_mode is CDIO_MODE_AUDIO, p_buf should hold at least CDIO_FRAMESIZE_RAW * i_blocks bytes.

If read_mode is CDIO_MODE_DATA, p_buf should hold at least i_blocks times either ISO_BLOCKSIZE, M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of sector getting read. If you don't know whether you have a Mode 1/2, Form 1/ Form 2/Formless sector best to reserve space for the maximum which is M2RAW_SECTOR_SIZE.

If read_mode is CDIO_MODE_M2F1, p_buf should hold at least M2RAW_SECTOR_SIZE * i_blocks bytes.

If read_mode is CDIO_MODE_M2F2, p_buf should hold at least CDIO_CD_FRAMESIZE * i_blocks bytes.

Definition at line 314 of file read.c.

References cdio_read_audio_sectors(), cdio_read_mode1_sectors(), cdio_read_mode2_sectors(), CDIO_READ_MODE_AUDIO, CDIO_READ_MODE_M1F1, CDIO_READ_MODE_M1F2, CDIO_READ_MODE_M2F1, CDIO_READ_MODE_M2F2, and DRIVER_OP_ERROR.

Referenced by cdio_read_sector(), and readSectors().