2003-09-21 04:21:39 +00:00
|
|
|
/*
|
2004-08-06 00:53:58 +00:00
|
|
|
$Id: util.c,v 1.12 2004/08/06 00:53:59 rocky Exp $
|
2003-09-21 04:21:39 +00:00
|
|
|
|
2004-01-10 03:21:50 +00:00
|
|
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
2003-09-21 04:21:39 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Miscellaneous things common to standalone programs. */
|
|
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
|
|
cdio_log_handler_t gl_default_cdio_log_handler = NULL;
|
|
|
|
|
char *source_name = NULL;
|
|
|
|
|
char *program_name;
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
myexit(CdIo *cdio, int rc)
|
|
|
|
|
{
|
2004-02-07 02:40:20 +00:00
|
|
|
if (NULL != cdio) cdio_destroy(cdio);
|
|
|
|
|
if (NULL != program_name) free(program_name);
|
|
|
|
|
if (NULL != source_name) free(source_name);
|
2003-09-21 04:21:39 +00:00
|
|
|
exit(rc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2004-02-07 02:40:20 +00:00
|
|
|
print_version (char *program_name, const char *version,
|
2003-09-21 04:21:39 +00:00
|
|
|
int no_header, bool version_only)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
driver_id_t driver_id;
|
|
|
|
|
|
|
|
|
|
if (no_header == 0)
|
2004-01-10 03:21:50 +00:00
|
|
|
printf( "%s version %s\nCopyright (c) 2003, 2004 R. Bernstein\n",
|
2003-09-21 04:21:39 +00:00
|
|
|
program_name, version);
|
|
|
|
|
printf( _("This is free software; see the source for copying conditions.\n\
|
|
|
|
|
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
|
|
|
|
|
PARTICULAR PURPOSE.\n\
|
|
|
|
|
"));
|
|
|
|
|
|
|
|
|
|
if (version_only) {
|
|
|
|
|
char *default_device;
|
|
|
|
|
for (driver_id=DRIVER_UNKNOWN+1; driver_id<=CDIO_MAX_DRIVER; driver_id++) {
|
|
|
|
|
if (cdio_have_driver(driver_id)) {
|
|
|
|
|
printf("Have driver: %s\n", cdio_driver_describe(driver_id));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
default_device=cdio_get_default_device(NULL);
|
|
|
|
|
if (default_device)
|
|
|
|
|
printf("Default CD-ROM device: %s\n", default_device);
|
|
|
|
|
else
|
|
|
|
|
printf("No CD-ROM device found.\n");
|
2004-02-07 02:40:20 +00:00
|
|
|
free(program_name);
|
2003-09-21 04:21:39 +00:00
|
|
|
exit(100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define DEV_PREFIX "/dev/"
|
|
|
|
|
char *
|
|
|
|
|
fillout_device_name(const char *device_name)
|
|
|
|
|
{
|
|
|
|
|
#if defined(HAVE_WIN32_CDROM)
|
|
|
|
|
return strdup(device_name);
|
|
|
|
|
#else
|
2004-06-19 19:15:15 +00:00
|
|
|
unsigned int prefix_len = strlen(DEV_PREFIX);
|
2003-09-21 04:21:39 +00:00
|
|
|
if (0 == strncmp(device_name, DEV_PREFIX, prefix_len))
|
|
|
|
|
return strdup(device_name);
|
|
|
|
|
else {
|
2004-06-19 19:15:15 +00:00
|
|
|
char *full_device_name = (char*) malloc(strlen(device_name)+prefix_len);
|
2003-09-21 04:21:39 +00:00
|
|
|
sprintf(full_device_name, DEV_PREFIX "%s", device_name);
|
|
|
|
|
return full_device_name;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-25 00:46:34 +00:00
|
|
|
/* Prints out drive capabilities */
|
2004-07-17 22:16:46 +00:00
|
|
|
void print_drive_capabilities(cdio_drive_read_cap_t i_read_cap,
|
|
|
|
|
cdio_drive_write_cap_t i_write_cap,
|
|
|
|
|
cdio_drive_misc_cap_t i_misc_cap)
|
2004-04-25 00:46:34 +00:00
|
|
|
{
|
2004-07-17 22:16:46 +00:00
|
|
|
if (CDIO_DRIVE_CAP_ERROR == i_misc_cap) {
|
|
|
|
|
printf("Error in getting drive hardware properties\n");
|
2004-04-25 00:46:34 +00:00
|
|
|
} else {
|
2004-07-17 22:16:46 +00:00
|
|
|
printf(_("Hardware : %s\n"),
|
|
|
|
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_FILE
|
2004-04-25 14:07:23 +00:00
|
|
|
? "Disk Image" : "CD-ROM or DVD");
|
2004-07-18 03:35:07 +00:00
|
|
|
printf(_("Can eject : %s\n"),
|
|
|
|
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_EJECT ? "Yes" : "No");
|
2004-07-17 22:16:46 +00:00
|
|
|
printf(_("Can close tray : %s\n"),
|
|
|
|
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_CLOSE_TRAY ? "Yes" : "No");
|
|
|
|
|
printf(_("Can disable manual eject : %s\n"),
|
|
|
|
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_LOCK ? "Yes" : "No");
|
|
|
|
|
printf(_("Can select juke-box disc : %s\n\n"),
|
|
|
|
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_SELECT_DISC ? "Yes" : "No");
|
2004-06-27 16:37:34 +00:00
|
|
|
|
2004-07-17 22:16:46 +00:00
|
|
|
printf(_("Can set drive speed : %s\n"),
|
|
|
|
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_SELECT_SPEED ? "Yes" : "No");
|
|
|
|
|
printf(_("Can detect if CD changed : %s\n"),
|
|
|
|
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED ? "Yes" : "No");
|
|
|
|
|
printf(_("Can read multiple sessions : %s\n"),
|
|
|
|
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_MULTI_SESSION ? "Yes" : "No");
|
|
|
|
|
printf(_("Can hard reset device : %s\n\n"),
|
|
|
|
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_RESET ? "Yes" : "No");
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-25 00:46:34 +00:00
|
|
|
|
2004-07-17 22:16:46 +00:00
|
|
|
if (CDIO_DRIVE_CAP_ERROR == i_read_cap) {
|
|
|
|
|
printf("Error in getting drive reading properties\n");
|
|
|
|
|
} else {
|
|
|
|
|
printf("Reading....\n");
|
|
|
|
|
printf(_(" Can play audio : %s\n"),
|
|
|
|
|
i_read_cap & CDIO_DRIVE_CAP_READ_AUDIO ? "Yes" : "No");
|
|
|
|
|
printf(_(" Can read CD-R : %s\n"),
|
|
|
|
|
i_read_cap & CDIO_DRIVE_CAP_READ_CD_R ? "Yes" : "No");
|
|
|
|
|
printf(_(" Can read CD-RW : %s\n"),
|
|
|
|
|
i_read_cap & CDIO_DRIVE_CAP_READ_CD_RW ? "Yes" : "No");
|
|
|
|
|
printf(_(" Can read DVD-ROM : %s\n"),
|
|
|
|
|
i_read_cap & CDIO_DRIVE_CAP_READ_DVD_ROM ? "Yes" : "No");
|
2004-04-25 00:46:34 +00:00
|
|
|
}
|
2004-07-17 22:16:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CDIO_DRIVE_CAP_ERROR == i_write_cap) {
|
|
|
|
|
printf("Error in getting drive writing properties\n");
|
|
|
|
|
} else {
|
|
|
|
|
printf("\nWriting....\n");
|
|
|
|
|
printf(_(" Can write CD-RW : %s\n"),
|
2004-08-06 00:53:58 +00:00
|
|
|
i_read_cap & CDIO_DRIVE_CAP_WRITE_CD_RW ? "Yes" : "No");
|
2004-07-17 22:16:46 +00:00
|
|
|
printf(_(" Can write DVD-R : %s\n"),
|
2004-08-06 00:53:58 +00:00
|
|
|
i_write_cap & CDIO_DRIVE_CAP_WRITE_DVD_R ? "Yes" : "No");
|
2004-07-17 22:16:46 +00:00
|
|
|
printf(_(" Can write DVD-RAM : %s\n"),
|
2004-08-06 00:53:58 +00:00
|
|
|
i_write_cap & CDIO_DRIVE_CAP_WRITE_DVD_RAM ? "Yes" : "No");
|
|
|
|
|
printf(_(" Can write DVD-RW : %s\n"),
|
|
|
|
|
i_write_cap & CDIO_DRIVE_CAP_WRITE_DVD_RW ? "Yes" : "No");
|
|
|
|
|
printf(_(" Can write DVD+RW : %s\n"),
|
|
|
|
|
i_write_cap & CDIO_DRIVE_CAP_WRITE_DVD_RPW ? "Yes" : "No");
|
2004-04-25 00:46:34 +00:00
|
|
|
}
|
|
|
|
|
}
|