/*! Reads nblocks of mode2 sectors from cd device into data starting from lsn. Returns 0 if no error. */ static int _cdio_read_mode2_sectors (void *env, void *data, lsn_t lsn, bool mode2_form2, unsigned int nblocks) { _img_private_t *_obj = env; unsigned int i; int retval; for (i = 0; i < nblocks; i++) { if (mode2_form2) { if ( (retval = _cdio_read_mode2_sector (_obj, ((char *)data) + (M2RAW_SECTOR_SIZE * i), lsn + i, true)) ) return retval; } else { char buf[M2RAW_SECTOR_SIZE] = { 0, }; if ( (retval = _cdio_read_mode2_sector (_obj, buf, lsn + i, true)) ) return retval; memcpy (((char *)data) + (CDIO_CD_FRAMESIZE * i), buf + CDIO_CD_SUBHEADER_SIZE, CDIO_CD_FRAMESIZE); } } return 0; }
/*! Reads nblocks of mode2 sectors from cd device into data starting from lsn. Returns 0 if no error. */ static int _cdio_read_mode2_sectors (void *p_user_data, void *data, lsn_t lsn, bool b_form2, unsigned int nblocks) { int i; int retval; unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE; for (i = 0; i < nblocks; i++) { if ( (retval = _cdio_read_mode2_sector (p_user_data, ((char *)data) + (blocksize * i), lsn + i, b_form2)) ) return retval; } return 0; }
static int _cdio_read_mode2_sectors(void *user_data, void *data, lsn_t lsn, bool mode2_form2, unsigned int nblocks) { int i, res; char *buf = data; for (i = 0; i < nblocks; i++) { res = _cdio_read_mode2_sector(user_data, buf, lsn, mode2_form2); if (res) return res; buf += (mode2_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE); lsn++; } return 0; }