"Fossies" - the Fresh Open Source Software Archive

Member "libcdio-2.1.0/include/cdio/read.h" (12 Aug 2018, 8624 Bytes) of package /linux/privat/libcdio-2.1.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "read.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2     Copyright (C) 2005, 2006, 2007, 2008, 2012 Rocky Bernstein <rocky@gnu.org>
    3 
    4     This program is free software: you can redistribute it and/or modify
    5     it under the terms of the GNU General Public License as published by
    6     the Free Software Foundation, either version 3 of the License, or
    7     (at your option) any later version.
    8 
    9     This program is distributed in the hope that it will be useful,
   10     but WITHOUT ANY WARRANTY; without even the implied warranty of
   11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12     GNU General Public License for more details.
   13 
   14     You should have received a copy of the GNU General Public License
   15     along with this program.  If not, see <http://www.gnu.org/licenses/>.
   16 */
   17 
   18 /** \file read.h 
   19  *
   20  *  \brief The top-level header for sector (block, frame)-related
   21  *  libcdio calls. 
   22  */
   23 
   24 #ifndef CDIO_READ_H_
   25 #define CDIO_READ_H_
   26 
   27 #include <cdio/types.h>
   28 
   29 #ifdef __cplusplus
   30 extern "C" {
   31 #endif /* __cplusplus */
   32 
   33   /** All the different ways a block/sector can be read. */
   34   typedef enum {
   35     CDIO_READ_MODE_AUDIO,  /**< CD-DA, audio, Red Book */
   36     CDIO_READ_MODE_M1F1,   /**< Mode 1 Form 1 */
   37     CDIO_READ_MODE_M1F2,   /**< Mode 1 Form 2 */
   38     CDIO_READ_MODE_M2F1,   /**< Mode 2 Form 1 */
   39     CDIO_READ_MODE_M2F2    /**< Mode 2 Form 2 */
   40   } cdio_read_mode_t;
   41   
   42   /*!
   43     Reposition read offset
   44     Similar to (if not the same as) libc's fseek()
   45 
   46     @param p_cdio object which gets adjusted
   47     @param offset amount to seek
   48     @param whence  like corresponding parameter in libc's fseek, e.g. 
   49                    SEEK_SET or SEEK_END.
   50     @return (off_t) -1 on error. 
   51   */
   52 
   53   off_t cdio_lseek(const CdIo_t *p_cdio, off_t offset, int whence);
   54     
   55   /*!  Reads into buf the next size bytes.  Similar to (if not the
   56     same as) libc's read(). This is a "cooked" read, or one handled by
   57     the OS. It probably won't work on audio data. For that use
   58     cdio_read_audio_sector(s).
   59 
   60     @param p_cdio object to read from
   61     @param p_buf place to read data into. The caller should make sure
   62                  this location can store at least i_size bytes.
   63     @param i_size number of bytes to read
   64 
   65     @return (ssize_t) -1 on error. 
   66   */
   67   ssize_t cdio_read(const CdIo_t *p_cdio, void *p_buf, size_t i_size);
   68     
   69   /*!
   70     Read an audio sector
   71 
   72     @param p_cdio object to read from
   73     @param p_buf place to read data into. The caller should make sure
   74                  this location can store at least CDIO_FRAMESIZE_RAW
   75                  bytes.
   76     @param i_lsn sector to read
   77   */
   78   driver_return_code_t cdio_read_audio_sector (const CdIo_t *p_cdio, 
   79                                                void *p_buf, lsn_t i_lsn);
   80 
   81   /*!
   82     Reads audio sectors
   83 
   84     @param p_cdio object to read from
   85     @param p_buf place to read data into. The caller should make sure
   86                  this location can store at least CDIO_FRAMESIZE_RAW
   87                  * i_blocks bytes.
   88     @param i_lsn sector to read
   89     @param i_blocks number of sectors to read
   90   */
   91   driver_return_code_t cdio_read_audio_sectors (const CdIo_t *p_cdio, 
   92                                                 void *p_buf, lsn_t i_lsn,
   93                                                 uint32_t i_blocks);
   94 
   95   /*!
   96     Read data sectors
   97 
   98     @param p_cdio object to read from
   99     @param p_buf place to read data into.  The caller should make sure
  100                  this location can store at least ISO_BLOCKSIZE, 
  101                  M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE depending
  102                  on the kind of sector getting read. If you don't 
  103                  know whether you have a Mode 1/2, Form 1/ Form 2/Formless
  104                  sector best to reserve space for the maximum, 
  105                  M2RAW_SECTOR_SIZE.
  106     @param i_lsn sector to read
  107     @param i_blocksize size of block. Should be either CDIO_CD_FRAMESIZE, 
  108     M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE. See comment above under p_buf.
  109 
  110     @param i_blocks number of blocks to read
  111   */
  112   driver_return_code_t cdio_read_data_sectors ( const CdIo_t *p_cdio, 
  113                                                 void *p_buf, lsn_t i_lsn,
  114                                                 uint16_t i_blocksize,
  115                                                 uint32_t i_blocks );
  116   /*!
  117     Reads a mode 1 sector
  118 
  119     @param p_cdio object to read from
  120     @param p_buf place to read data into.
  121     @param i_lsn sector to read
  122     @param b_form2 true for reading mode 1 form 2 sectors or false for 
  123     mode 1 form 1 sectors.
  124   */
  125   driver_return_code_t cdio_read_mode1_sector (const CdIo_t *p_cdio, 
  126                                                void *p_buf, lsn_t i_lsn, 
  127                                                bool b_form2);
  128   /*!
  129     Reads mode 1 sectors
  130 
  131     @param p_cdio object to read from
  132     @param p_buf place to read data into
  133     @param i_lsn sector to read
  134     @param b_form2 true for reading mode 1 form 2 sectors or false for 
  135     mode 1 form 1 sectors.
  136     @param i_blocks number of sectors to read
  137   */
  138   driver_return_code_t cdio_read_mode1_sectors (const CdIo_t *p_cdio, 
  139                                                 void *p_buf, lsn_t i_lsn, 
  140                                                 bool b_form2, 
  141                                                 uint32_t i_blocks);
  142   /*!
  143     Reads a mode 2 sector
  144 
  145     @param p_cdio object to read from
  146     @param p_buf place to read data into. The caller should make sure
  147                  this location can store at least 
  148                  M2RAW_SECTOR_SIZE (for form 1) or CDIO_CD_FRAMESIZE (for 
  149                  form 2) bytes.
  150     @param i_lsn sector to read
  151     @param b_form2 true for reading mode 2 form 2 sectors or false for 
  152     mode 2 form 1 sectors.
  153 
  154     @return 0 if no error, nonzero otherwise.
  155   */
  156   driver_return_code_t cdio_read_mode2_sector (const CdIo_t *p_cdio, 
  157                                                void *p_buf, lsn_t i_lsn, 
  158                                                bool b_form2);
  159   
  160   /** The special case of reading a single block is a common one so we
  161       provide a routine for that as a convenience.
  162   */
  163   driver_return_code_t cdio_read_sector(const CdIo_t *p_cdio, void *p_buf, 
  164                                         lsn_t i_lsn, 
  165                                         cdio_read_mode_t read_mode);
  166   /*!
  167     Reads mode 2 sectors
  168 
  169     @param p_cdio object to read from
  170     @param p_buf place to read data into. The caller should make sure
  171                  this location can store at least 
  172                  M2RAW_SECTOR_SIZE (for form 1) or CDIO_CD_FRAMESIZE (for 
  173                  form 2) * i_blocks bytes.
  174     @param i_lsn sector to read
  175     @param b_form2 true for reading mode2 form 2 sectors or false for 
  176            mode 2  form 1 sectors.
  177     @param i_blocks number of sectors to read
  178 
  179     @return 0 if no error, nonzero otherwise.
  180   */
  181   driver_return_code_t cdio_read_mode2_sectors (const CdIo_t *p_cdio, 
  182                                                 void *p_buf, lsn_t i_lsn, 
  183                                                 bool b_form2, 
  184                                                 uint32_t i_blocks);
  185   
  186   /*!
  187     Reads a number of sectors (AKA blocks).
  188 
  189     @param p_cdio cdio object
  190     @param p_buf place to read data into. The caller should make sure
  191     this location is large enough. See below for size information.
  192     @param read_mode the kind of "mode" to use in reading.
  193     @param i_lsn sector to read
  194     @param i_blocks number of sectors to read
  195     @return DRIVER_OP_SUCCESS (0) if no error, other (negative) enumerations
  196     are returned on error.
  197 
  198     If read_mode is CDIO_MODE_AUDIO,
  199       *p_buf should hold at least CDIO_FRAMESIZE_RAW * i_blocks bytes.
  200 
  201     If read_mode is CDIO_MODE_DATA,
  202       *p_buf should hold at least i_blocks times either ISO_BLOCKSIZE, 
  203       M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of 
  204       sector getting read. If you don't know whether you have a Mode 1/2, 
  205     Form 1/ Form 2/Formless sector best to reserve space for the maximum
  206     which is M2RAW_SECTOR_SIZE.
  207 
  208     If read_mode is CDIO_MODE_M2F1,
  209     *p_buf should hold at least M2RAW_SECTOR_SIZE * i_blocks bytes.
  210     
  211     If read_mode is CDIO_MODE_M2F2,
  212     *p_buf should hold at least CDIO_CD_FRAMESIZE * i_blocks bytes.
  213     
  214   */
  215   driver_return_code_t cdio_read_sectors(const CdIo_t *p_cdio, void *p_buf, 
  216                                          lsn_t i_lsn, 
  217                                          cdio_read_mode_t read_mode,
  218                                          uint32_t i_blocks);
  219 
  220 #ifdef __cplusplus
  221 }
  222 #endif /* __cplusplus */
  223 
  224 #endif /* CDIO_READ_H_ */