~ubuntu-branches/ubuntu/maverick/libcdio/maverick

« back to all changes in this revision

Viewing changes to example/C++/OO/tracks.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Nicolas Boullis
  • Date: 2007-10-04 00:52:35 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20071004005235-4e3gdi4x2q2d14jx
Tags: 0.78.2+dfsg1-1
* Repack the source tarball to remove non-DFSG-free
  documentation. Thanks to Joerg Jaspert for pointing this.
* Also update debian/copyright to reflect the status of the removed
  documentation.
* Add libncurses5-dev | libncurses-dev to the build-dependencies, for
  cdda-player.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  $Id: tracks.cpp,v 1.1 2005/11/10 11:11:15 rocky Exp $
 
3
 
 
4
  Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
 
5
  
 
6
  This program is free software; you can redistribute it and/or modify
 
7
  it under the terms of the GNU General Public License as published by
 
8
  the Free Software Foundation; either version 2 of the License, or
 
9
  (at your option) any later version.
 
10
  
 
11
  This program is distributed in the hope that it will be useful,
 
12
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
  GNU General Public License for more details.
 
15
  
 
16
  You should have received a copy of the GNU General Public License
 
17
  along with this program; if not, write to the Free Software
 
18
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
*/
 
20
 
 
21
/* Simple program to list track numbers and logical sector numbers of
 
22
   a Compact Disc using libcdio. */
 
23
#ifdef HAVE_CONFIG_H
 
24
# include "config.h"
 
25
#endif
 
26
#include <stdio.h>
 
27
#ifdef HAVE_SYS_TYPES_H
 
28
#include <sys/types.h>
 
29
#endif
 
30
#include <cdio++/cdio.hpp>
 
31
int
 
32
main(int argc, const char *argv[])
 
33
{
 
34
  CdioDevice device;
 
35
  track_t i_first_track;
 
36
  track_t i_tracks;
 
37
  int j, i;
 
38
  CdioTrack *track;
 
39
 
 
40
  if (!device.open (NULL)) {
 
41
    printf("Couldn't find a driver.. leaving.\n");
 
42
    return 1;
 
43
  }
 
44
  
 
45
  i_tracks      = device.getNumTracks();
 
46
  i_first_track = i = device.getFirstTrackNum();
 
47
 
 
48
  printf("CD-ROM Track List (%i - %i)\n", i_first_track, i_tracks);
 
49
 
 
50
  printf("  #:  LSN\n");
 
51
  
 
52
  for (j = 0; j < i_tracks; i++, j++) {
 
53
    track = device.getTrackFromNum(i);
 
54
    lsn_t lsn = track->getLsn();
 
55
    if (CDIO_INVALID_LSN != lsn)
 
56
        printf("%3d: %06lu\n", (int) i, (long unsigned int) lsn);
 
57
    delete(track);
 
58
  }
 
59
 
 
60
  track = device.getTrackFromNum(CDIO_CDROM_LEADOUT_TRACK);
 
61
  printf("%3X: %06lu  leadout\n", CDIO_CDROM_LEADOUT_TRACK, 
 
62
         (long unsigned int) track->getLsn());
 
63
  delete(track);
 
64
  return 0;
 
65
}