diff --git a/example/C++/iso2.cpp b/example/C++/iso2.cpp index 897bb1cd..10d1c793 100644 --- a/example/C++/iso2.cpp +++ b/example/C++/iso2.cpp @@ -1,5 +1,5 @@ /* - $Id: iso2.cpp,v 1.4 2005/10/30 14:25:46 rocky Exp $ + $Id: iso2.cpp,v 1.5 2005/11/07 07:44:00 rocky Exp $ Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -21,6 +21,10 @@ /* Simple program to show using libiso9660 to extract a file from a cue/bin CD-IMAGE. + If a single argument is given, it is used as the CUE file of a CD image + to use. Otherwise a compiled-in default image name (that + comes with the libcdio distribution) will be used. + This program can be compiled with either a C or C++ compiler. In the distribution we prefer C++ just to make sure we haven't broken things on the C++ side. diff --git a/example/eject.c b/example/eject.c new file mode 100644 index 00000000..c92ffd14 --- /dev/null +++ b/example/eject.c @@ -0,0 +1,78 @@ +/* + $Id: eject.c,v 1.1 2005/11/07 07:44:00 rocky Exp $ + + Copyright (C) 2005 Rocky Bernstein + + 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 +*/ + +/* Simple program to eject a CD-ROM drive door and then close it again. + + If a single argument is given, it is used as the CD-ROM device to + eject/close. Otherwise a CD-ROM drive will be scanned for. +*/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STDIO_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#ifdef HAVE_STRING_H +#include +#endif + +int +main(int argc, const char *argv[]) +{ + driver_return_code_t ret; + driver_id_t driver_id = DRIVER_DEVICE; + char *psz_drive = NULL; + + if (argc > 1) + psz_drive = strdup(argv[1]); + + if (!psz_drive) { + psz_drive = cdio_get_default_device_driver(&driver_id); + if (!psz_drive) { + printf("Can't find a CD-ROM to eject\n"); + exit(1); + } + } + ret = cdio_eject_media_drive(psz_drive); + switch(ret) { + case DRIVER_OP_UNSUPPORTED: + printf("Eject not supported for %s.\n", psz_drive); + break; + case DRIVER_OP_SUCCESS: + printf("CD-ROM drive %s ejected.\n", psz_drive); + break; + default: + printf("Eject of CD-ROM drive %s failed.\n", psz_drive); + break; + } + + if (DRIVER_OP_SUCCESS == cdio_close_tray(psz_drive, &driver_id)) { + printf("Closed tray of CD-ROM drive %s.\n", psz_drive); + } else { + printf("Closing tray of CD-ROM drive %s failed.\n", psz_drive); + } + free(psz_drive); + + return 0; +} diff --git a/example/iso1.c b/example/iso1.c index 2b691c80..a37fab8b 100644 --- a/example/iso1.c +++ b/example/iso1.c @@ -1,5 +1,5 @@ /* - $Id: iso1.c,v 1.4 2005/02/03 07:32:32 rocky Exp $ + $Id: iso1.c,v 1.5 2005/11/07 07:44:00 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein @@ -20,6 +20,10 @@ /* Simple program to show using libiso9660 to list files in a directory of an ISO-9660 image. + + If a single argument is given, it is used as the ISO 9660 image to + use in the listing. Otherwise a compiled-in default ISO 9660 image + name (that comes with the libcdio distribution) will be used. */ /* This is the ISO 9660 image. */ diff --git a/example/iso2.c b/example/iso2.c index 8c0a6e23..fb68e011 100644 --- a/example/iso2.c +++ b/example/iso2.c @@ -1,5 +1,5 @@ /* - $Id: iso2.c,v 1.9 2005/10/30 14:26:11 rocky Exp $ + $Id: iso2.c,v 1.10 2005/11/07 07:44:00 rocky Exp $ Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -19,7 +19,11 @@ */ /* Simple program to show using libiso9660 to extract a file from a - cue/bin CD-IMAGE. + CUE/BIN CD image. + + If a single argument is given, it is used as the CUE file of a CD image + to use. Otherwise a compiled-in default image name (that + comes with the libcdio distribution) will be used. This program can be compiled with either a C or C++ compiler. In the distribution we prefer C++ just to make sure we haven't broken diff --git a/example/iso3.c b/example/iso3.c index 765ee974..ff3bd514 100644 --- a/example/iso3.c +++ b/example/iso3.c @@ -1,7 +1,7 @@ /* - $Id: iso3.c,v 1.4 2005/02/19 11:42:18 rocky Exp $ + $Id: iso3.c,v 1.5 2005/11/07 07:44:00 rocky Exp $ - Copyright (C) 2004 Rocky Bernstein + Copyright (C) 2004, 2005 Rocky Bernstein 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 @@ -20,6 +20,10 @@ /* Simple program to show using libiso9660 to extract a file from an ISO-9660 image. + + If a single argument is given, it is used as the ISO 9660 image to + use in the extraction. Otherwise a compiled in default ISO 9660 image + name (that comes with the libcdio distribution) will be used. */ /* This is the ISO 9660 image. */ diff --git a/example/isofuzzy.c b/example/isofuzzy.c index 2619e339..be6840d3 100644 --- a/example/isofuzzy.c +++ b/example/isofuzzy.c @@ -1,5 +1,5 @@ /* - $Id: isofuzzy.c,v 1.1 2005/02/09 02:50:47 rocky Exp $ + $Id: isofuzzy.c,v 1.2 2005/11/07 07:44:00 rocky Exp $ Copyright (C) 2005 Rocky Bernstein @@ -19,6 +19,10 @@ */ /* Program to show using libiso9660 with fuzzy search to get file info. + + If a single argument is given, it is used as the ISO 9660 image. + Otherwise we use a compiled-in default ISO 9660 image + name. */ /* This is the BIN we think there is an ISO 9660 image inside of. */ diff --git a/include/cdio/cdio.h b/include/cdio/cdio.h index 97243f3a..c65243ea 100644 --- a/include/cdio/cdio.h +++ b/include/cdio/cdio.h @@ -1,5 +1,5 @@ /* -*- c -*- - $Id: cdio.h,v 1.80 2005/02/10 01:59:05 rocky Exp $ + $Id: cdio.h,v 1.81 2005/11/07 07:44:00 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -50,7 +50,7 @@ extern "C" { #endif /* __cplusplus */ -/* For compatability. */ +/* For compatibility. */ #define CdIo CdIo_t /** This is an opaque structure for the CD object. */ diff --git a/include/cdio/device.h b/include/cdio/device.h index d82df734..9801e799 100644 --- a/include/cdio/device.h +++ b/include/cdio/device.h @@ -1,5 +1,5 @@ /* -*- c -*- - $Id: device.h,v 1.24 2005/11/06 22:50:37 rocky Exp $ + $Id: device.h,v 1.25 2005/11/07 07:44:00 rocky Exp $ Copyright (C) 2005 Rocky Bernstein @@ -237,6 +237,13 @@ extern "C" { */ driver_return_code_t cdio_eject_media (CdIo_t **p_cdio); + /*! + Eject media in CD drive if there is a routine to do so. + + @param psz_drive the name of the device to be acted upon. + */ + driver_return_code_t cdio_eject_media_drive (const char *psz_drive); + /*! Free device list returned by cdio_get_devices or cdio_get_devices_with_cap. diff --git a/lib/driver/device.c b/lib/driver/device.c index 3bc4acbb..4d2f9ceb 100644 --- a/lib/driver/device.c +++ b/lib/driver/device.c @@ -1,5 +1,5 @@ /* - $Id: device.c,v 1.27 2005/04/11 01:03:46 rocky Exp $ + $Id: device.c,v 1.28 2005/11/07 07:44:00 rocky Exp $ Copyright (C) 2005 Rocky Bernstein @@ -345,7 +345,6 @@ cdio_close_tray (const char *psz_drive, /*in/out*/ driver_id_t driver_return_code_t cdio_eject_media (CdIo_t **pp_cdio) { - if ((pp_cdio == NULL) || (*pp_cdio == NULL)) return DRIVER_OP_UNINIT; if ((*pp_cdio)->op.eject_media) { @@ -362,6 +361,23 @@ cdio_eject_media (CdIo_t **pp_cdio) } } +/*! + Eject media in CD drive if there is a routine to do so. If you want + to scan for any CD-ROM and eject that, pass NULL for psz_drive. + + @param psz_drive the CD object to be acted upon. +*/ +driver_return_code_t +cdio_eject_media_drive (const char *psz_drive) +{ + CdIo_t *p_cdio = cdio_open (psz_drive, DRIVER_DEVICE); + if (p_cdio) { + return cdio_eject_media(&p_cdio); + } else { + return DRIVER_OP_UNINIT; + } +} + /*! Free device list returned by cdio_get_devices or cdio_get_devices_with_cap.