"Fossies" - the Fresh Open Source Software Archive

Member "libcdio-2.1.0/lib/driver/cdio.c" (12 Aug 2018, 2429 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 "cdio.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2   Copyright (C) 2003, 2004, 2005, 2008, 2011
    3   Rocky Bernstein <rocky@gnu.org>
    4   Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
    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 3 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, see <http://www.gnu.org/licenses/>.
   18 */
   19 
   20 
   21 #ifdef HAVE_CONFIG_H
   22 # include "config.h"
   23 # define __CDIO_CONFIG_H__ 1
   24 #endif
   25 
   26 #ifdef HAVE_SYS_TYPES_H
   27 #include <sys/types.h>
   28 #endif
   29 #ifdef HAVE_SYS_STAT_H
   30 #include <sys/stat.h>
   31 #endif
   32 #ifdef HAVE_UNISTD_H
   33 #include <unistd.h>
   34 #endif
   35 
   36 #include "cdio_assert.h"
   37 #include <cdio/cdio.h>
   38 #include <cdio/util.h>
   39 #include "cdio_private.h"
   40 
   41 /*!
   42   Return the value associatied with key. NULL is returned if obj is NULL
   43   or "key" does not exist.
   44  */
   45 const char *
   46 cdio_get_arg (const CdIo *obj, const char key[])
   47 {
   48   if (obj == NULL) return NULL;
   49 
   50   if (obj->op.get_arg) {
   51     return obj->op.get_arg (obj->env, key);
   52   } else {
   53     return NULL;
   54   }
   55 }
   56 
   57 CdIo_t *
   58 cdio_new (generic_img_private_t *p_env, cdio_funcs_t *p_funcs)
   59 {
   60   CdIo_t *p_new_cdio = calloc(1, sizeof (CdIo_t));
   61 
   62   if (NULL == p_new_cdio) return NULL;
   63 
   64   p_new_cdio->env = p_env;      /* This is the private "environment" that
   65                                    driver-dependent routines use. */
   66   p_new_cdio->op  = *p_funcs;
   67   p_env->cdio     = p_new_cdio; /* A way for the driver-dependent routines
   68                                    to access the higher-level general cdio
   69                                    object. */
   70   return p_new_cdio;
   71 }
   72 
   73 /*!
   74   Set the arg "key" with "value" in the source device.
   75 */
   76 driver_return_code_t
   77 cdio_set_arg (CdIo_t *p_cdio, const char key[], const char value[])
   78 {
   79   if (!p_cdio) return DRIVER_OP_UNINIT;
   80   if (!p_cdio->op.set_arg) return DRIVER_OP_UNSUPPORTED;
   81   if (!key) return DRIVER_OP_ERROR;
   82 
   83   return p_cdio->op.set_arg (p_cdio->env, key, value);
   84 }
   85 
   86 
   87 
   88 /*
   89  * Local variables:
   90  *  c-file-style: "gnu"
   91  *  tab-width: 8
   92  *  indent-tabs-mode: nil
   93  * End:
   94  */