~ubuntu-branches/ubuntu/edgy/libcdio/edgy-updates

« back to all changes in this revision

Viewing changes to lib/driver/disc.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2005-11-15 16:53:23 UTC
  • mfrom: (3.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20051115165323-peroku75syl2j36u
Tags: 0.76-1ubuntu1
* Sync to new Debian version, manually apply Ubuntu patches:
  - debian/control: Remove dpkg-awk build dependency.
  - debian/rules: hardcode $LIBCDEV. This keeps the diff small (compared to
    the original patch of changing every ${libcdev} occurence).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    $Id: disc.c,v 1.5 2005/02/05 14:42:28 rocky Exp $
 
3
 
 
4
    Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
 
5
    Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
 
6
 
 
7
    This program is free software; you can redistribute it and/or modify
 
8
    it under the terms of the GNU General Public License as published by
 
9
    the Free Software Foundation; either version 2 of the License, or
 
10
    (at your option) any later version.
 
11
 
 
12
    This program is distributed in the hope that it will be useful,
 
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
    GNU General Public License for more details.
 
16
 
 
17
    You should have received a copy of the GNU General Public License
 
18
    along with this program; if not, write to the Free Software
 
19
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
20
*/
 
21
 
 
22
 
 
23
#ifdef HAVE_CONFIG_H
 
24
# include "config.h"
 
25
#endif
 
26
 
 
27
#include <cdio/cdio.h>
 
28
#include "cdio_private.h"
 
29
 
 
30
/* Must match discmode enumeration */
 
31
const char *discmode2str[] = {
 
32
  "CD-DA", 
 
33
  "CD-DATA (Mode 1)", 
 
34
  "CD DATA (Mode 2)", 
 
35
  "CD-ROM Mixed",
 
36
  "DVD-ROM", 
 
37
  "DVD-RAM", 
 
38
  "DVD-R", 
 
39
  "DVD-RW", 
 
40
  "DVD+R",
 
41
  "DVD+RW", 
 
42
  "Unknown/unclassified DVD", 
 
43
  "No information",
 
44
  "Error in getting information",
 
45
  "CD-i" 
 
46
};
 
47
 
 
48
/*!
 
49
  Get the size of the CD in logical block address (LBA) units.
 
50
  
 
51
  @param p_cdio the CD object queried
 
52
  @return the lsn. On error 0 or CDIO_INVALD_LSN.
 
53
*/
 
54
lsn_t 
 
55
cdio_get_disc_last_lsn(const CdIo_t *p_cdio)
 
56
{
 
57
  if (!p_cdio) return CDIO_INVALID_LSN;
 
58
  return p_cdio->op.get_disc_last_lsn (p_cdio->env);
 
59
}
 
60
 
 
61
/*! 
 
62
  Get medium associated with cd_obj.
 
63
*/
 
64
discmode_t
 
65
cdio_get_discmode (CdIo_t *cd_obj)
 
66
{
 
67
  if (!cd_obj) return CDIO_DISC_MODE_ERROR;
 
68
  
 
69
  if (cd_obj->op.get_discmode) {
 
70
    return cd_obj->op.get_discmode (cd_obj->env);
 
71
  } else {
 
72
    return CDIO_DISC_MODE_NO_INFO;
 
73
  }
 
74
}
 
75
 
 
76
/*!
 
77
  Return a string containing the name of the driver in use.
 
78
  if CdIo is NULL (we haven't initialized a specific device driver), 
 
79
  then return NULL.
 
80
*/
 
81
char *
 
82
cdio_get_mcn (const CdIo_t *p_cdio) 
 
83
{
 
84
  if (p_cdio->op.get_mcn) {
 
85
    return p_cdio->op.get_mcn (p_cdio->env);
 
86
  } else {
 
87
    return NULL;
 
88
  }
 
89
}
 
90
 
 
91
bool
 
92
cdio_is_discmode_cdrom(discmode_t discmode) 
 
93
{
 
94
  switch (discmode) {
 
95
  case CDIO_DISC_MODE_CD_DA:
 
96
  case CDIO_DISC_MODE_CD_DATA:
 
97
  case CDIO_DISC_MODE_CD_XA:
 
98
  case CDIO_DISC_MODE_CD_MIXED:
 
99
  case CDIO_DISC_MODE_NO_INFO:
 
100
    return true;
 
101
  default:
 
102
    return false;
 
103
  }
 
104
}
 
105
 
 
106
bool
 
107
cdio_is_discmode_dvd(discmode_t discmode) 
 
108
{
 
109
  switch (discmode) {
 
110
  case CDIO_DISC_MODE_DVD_ROM:
 
111
  case CDIO_DISC_MODE_DVD_RAM:
 
112
  case CDIO_DISC_MODE_DVD_R:
 
113
  case CDIO_DISC_MODE_DVD_RW:
 
114
  case CDIO_DISC_MODE_DVD_PR:
 
115
  case CDIO_DISC_MODE_DVD_PRW:
 
116
    return true;
 
117
  default:
 
118
    return false;
 
119
  }
 
120
}