1 /*
2   Copyright (C) 2005, 2008, 2009 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 /* Simple program to list track numbers and logical sector numbers of
19    a Compact Disc using libcdio. */
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #define __CDIO_CONFIG_H__ 1
23 #endif
24 
25 #ifdef HAVE_STDIO_H
26 #include <stdio.h>
27 #endif
28 #ifdef HAVE_SYS_TYPES_H
29 #include <sys/types.h>
30 #endif
31 
32 #include <cdio++/cdio.hpp>
33 
34 int
main(int argc,const char * argv[])35 main(int argc, const char *argv[])
36 {
37   CdioDevice device;
38   track_t i_first_track;
39   track_t i_tracks;
40   int j, i;
41   CdioTrack *track;
42 
43   if (!device.open (NULL)) {
44     printf("Couldn't find a driver.. leaving.\n");
45     return 1;
46   }
47 
48   i_tracks      = device.getNumTracks();
49   i_first_track = i = device.getFirstTrackNum();
50 
51   printf("CD-ROM Track List (%i - %i)\n", i_first_track, i_tracks);
52 
53   printf("  #:  LSN\n");
54 
55   for (j = 0; j < i_tracks; i++, j++) {
56     track = device.getTrackFromNum(i);
57     lsn_t lsn = track->getLsn();
58     if (CDIO_INVALID_LSN != lsn)
59 	printf("%3d: %06lu\n", (int) i, (long unsigned int) lsn);
60     delete(track);
61   }
62 
63   track = device.getTrackFromNum(CDIO_CDROM_LEADOUT_TRACK);
64   printf("%3X: %06lu  leadout\n", CDIO_CDROM_LEADOUT_TRACK,
65 	 (long unsigned int) track->getLsn());
66   delete(track);
67   return 0;
68 }
69