File: cdio.c

package info (click to toggle)
libcdio 0.78.2%2Bdfsg1-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 11,492 kB
  • ctags: 4,911
  • sloc: ansic: 36,479; sh: 9,268; cpp: 2,554; makefile: 736; perl: 29
file content (113 lines) | stat: -rw-r--r-- 2,988 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
    $Id: cdio.c,v 1.13 2005/02/03 07:35:15 rocky Exp $

    Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
    Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/


#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#include "cdio_assert.h"
#include <cdio/cdio.h>
#include <cdio/util.h>
#include "cdio_private.h"

static const char _rcsid[] = "$Id: cdio.c,v 1.13 2005/02/03 07:35:15 rocky Exp $";


/*!
  Return the value associatied with key. NULL is returned if obj is NULL
  or "key" does not exist.
 */
const char *
cdio_get_arg (const CdIo *obj, const char key[])
{
  if (obj == NULL) return NULL;
  
  if (obj->op.get_arg) {
    return obj->op.get_arg (obj->env, key);
  } else {
    return NULL;
  }
}

/*! 
  Get cdtext information for a CdIo object .
  
  @param obj the CD object that may contain CD-TEXT information.
  @return the CD-TEXT object or NULL if obj is NULL
  or CD-TEXT information does not exist.
*/
cdtext_t *
cdio_get_cdtext (CdIo *obj, track_t i_track)
{
  if (obj == NULL) return NULL;
  
  if (obj->op.get_cdtext) {
    return obj->op.get_cdtext (obj->env, i_track);
  } else {
    return NULL;
  }
}

CdIo_t *
cdio_new (generic_img_private_t *p_env, cdio_funcs_t *p_funcs)
{
  CdIo_t *p_new_cdio = calloc(1, sizeof (CdIo_t));

  if (NULL == p_new_cdio) return NULL;
  
  p_new_cdio->env = p_env;      /* This is the private "environment" that
                                   driver-dependent routines use. */
  p_new_cdio->op  = *p_funcs;
  p_env->cdio     = p_new_cdio; /* A way for the driver-dependent routines 
                                   to access the higher-level general cdio 
                                   object. */
  return p_new_cdio;
}

/*!
  Set the arg "key" with "value" in the source device.
*/
driver_return_code_t
cdio_set_arg (CdIo_t *p_cdio, const char key[], const char value[])
{
  if (!p_cdio) return DRIVER_OP_UNINIT;
  if (!p_cdio->op.set_arg) return DRIVER_OP_UNSUPPORTED;
  if (!key) return DRIVER_OP_ERROR;

  return p_cdio->op.set_arg (p_cdio->env, key, value);
}



/* 
 * Local variables:
 *  c-file-style: "gnu"
 *  tab-width: 8
 *  indent-tabs-mode: nil
 * End:
 */