eject: unification of coding style
Signed-off-by: Michal Luscon <mluscon@redhat.com>
This commit is contained in:
parent
d36e80a759
commit
6154d23821
|
@ -63,7 +63,7 @@
|
||||||
#include <scsi/scsi_ioctl.h>
|
#include <scsi/scsi_ioctl.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
/* Used by the ToggleTray() function. If ejecting the tray takes this
|
/* Used by the toggle_tray() function. If ejecting the tray takes this
|
||||||
* time or less, the tray was probably already ejected, so we close it
|
* time or less, the tray was probably already ejected, so we close it
|
||||||
* again.
|
* again.
|
||||||
*/
|
*/
|
||||||
|
@ -94,7 +94,7 @@ static long int x_arg;
|
||||||
* These are the basenames of devices which can have multiple
|
* These are the basenames of devices which can have multiple
|
||||||
* partitions per device.
|
* partitions per device.
|
||||||
*/
|
*/
|
||||||
const char *partitionDevice[] = {
|
const char *partition_device[] = {
|
||||||
"hd",
|
"hd",
|
||||||
"sd",
|
"sd",
|
||||||
"xd",
|
"xd",
|
||||||
|
@ -104,13 +104,13 @@ const char *partitionDevice[] = {
|
||||||
"ed",
|
"ed",
|
||||||
"ftl",
|
"ftl",
|
||||||
"pd",
|
"pd",
|
||||||
0};
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Display command usage on standard error and exit. */
|
/* Display command usage on standard error and exit. */
|
||||||
static void usage()
|
static void usage() {
|
||||||
{
|
fprintf(stderr, _(
|
||||||
fprintf(stderr,_(
|
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
" eject [options] <name>\n"
|
" eject [options] <name>\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
|
@ -271,9 +271,7 @@ void e_fclose(FILE *fp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return 1 if file/device exists, 0 otherwise. */
|
/* Return 1 if file/device exists, 0 otherwise. */
|
||||||
static int FileExists(const char *name)
|
static int file_exists(const char *name) {
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* access() uses the UID, not the EUID. This way a normal user
|
* access() uses the UID, not the EUID. This way a normal user
|
||||||
* cannot find out if a file (say, /root/fubar) exists or not, even
|
* cannot find out if a file (say, /root/fubar) exists or not, even
|
||||||
|
@ -286,7 +284,6 @@ static int FileExists(const char *name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Given name, such as foo, see if any of the following exist:
|
* Given name, such as foo, see if any of the following exist:
|
||||||
*
|
*
|
||||||
|
@ -296,21 +293,20 @@ static int FileExists(const char *name)
|
||||||
* If found, return the full path. If not found, return 0.
|
* If found, return the full path. If not found, return 0.
|
||||||
* Returns pointer to dynamically allocated string.
|
* Returns pointer to dynamically allocated string.
|
||||||
*/
|
*/
|
||||||
static char *find_device(const char *name)
|
static char *find_device(const char *name) {
|
||||||
{
|
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
buf = (char *) xmalloc(strlen(name)+14); /* to allow for "/dev/cdroms/ + "0" + null */
|
buf = (char *) xmalloc(strlen(name)+14); /* to allow for "/dev/cdroms/ + "0" + null */
|
||||||
|
|
||||||
if ((name[0] == '.') || (name[0] == '/')) {
|
if ((name[0] == '.') || (name[0] == '/')) {
|
||||||
strcpy(buf, name);
|
strcpy(buf, name);
|
||||||
if (FileExists(buf))
|
if (file_exists(buf))
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(buf, "/dev/");
|
strcpy(buf, "/dev/");
|
||||||
strcat(buf, name);
|
strcat(buf, name);
|
||||||
if (FileExists(buf))
|
if (file_exists(buf))
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
|
@ -320,8 +316,7 @@ static char *find_device(const char *name)
|
||||||
|
|
||||||
|
|
||||||
/* Set or clear auto-eject mode. */
|
/* Set or clear auto-eject mode. */
|
||||||
static void AutoEject(int fd, int onOff)
|
static void auto_eject(int fd, int onOff) {
|
||||||
{
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = ioctl(fd, CDROMEJECT_SW, onOff);
|
status = ioctl(fd, CDROMEJECT_SW, onOff);
|
||||||
|
@ -335,8 +330,7 @@ static void AutoEject(int fd, int onOff)
|
||||||
* Changer select. CDROM_SELECT_DISC is preferred, older kernels used
|
* Changer select. CDROM_SELECT_DISC is preferred, older kernels used
|
||||||
* CDROMLOADFROMSLOT.
|
* CDROMLOADFROMSLOT.
|
||||||
*/
|
*/
|
||||||
static void ChangerSelect(int fd, int slot)
|
static void changer_select(int fd, int slot) {
|
||||||
{
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
#ifdef CDROM_SELECT_DISC
|
#ifdef CDROM_SELECT_DISC
|
||||||
|
@ -358,8 +352,7 @@ static void ChangerSelect(int fd, int slot)
|
||||||
/*
|
/*
|
||||||
* Close tray. Not supported by older kernels.
|
* Close tray. Not supported by older kernels.
|
||||||
*/
|
*/
|
||||||
static void CloseTray(int fd)
|
static void close_tray(int fd) {
|
||||||
{
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
#ifdef CDROMCLOSETRAY
|
#ifdef CDROMCLOSETRAY
|
||||||
|
@ -382,8 +375,7 @@ static void CloseTray(int fd)
|
||||||
* CloseTray().
|
* CloseTray().
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void ToggleTray(int fd)
|
static void toggle_tray(int fd) {
|
||||||
{
|
|
||||||
struct timeval time_start, time_stop;
|
struct timeval time_start, time_stop;
|
||||||
int time_elapsed;
|
int time_elapsed;
|
||||||
|
|
||||||
|
@ -412,7 +404,7 @@ static void ToggleTray(int fd)
|
||||||
* was already open. In this case, close it now. Else the tray was
|
* was already open. In this case, close it now. Else the tray was
|
||||||
* closed before. This would mean that we are done. */
|
* closed before. This would mean that we are done. */
|
||||||
if (time_elapsed < TRAY_WAS_ALREADY_OPEN_USECS)
|
if (time_elapsed < TRAY_WAS_ALREADY_OPEN_USECS)
|
||||||
CloseTray(fd);
|
close_tray(fd);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
warnx( _("CD-ROM tray toggle command not supported by this kernel"));
|
warnx( _("CD-ROM tray toggle command not supported by this kernel"));
|
||||||
|
@ -425,8 +417,7 @@ static void ToggleTray(int fd)
|
||||||
* Thanks to Roland Krivanek (krivanek@fmph.uniba.sk)
|
* Thanks to Roland Krivanek (krivanek@fmph.uniba.sk)
|
||||||
* http://dmpc.dbp.fmph.uniba.sk/~krivanek/cdrom_speed/
|
* http://dmpc.dbp.fmph.uniba.sk/~krivanek/cdrom_speed/
|
||||||
*/
|
*/
|
||||||
static void SelectSpeedCdrom(int fd, int speed)
|
static void select_speed(int fd, int speed) {
|
||||||
{
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
#ifdef CDROM_SELECT_SPEED
|
#ifdef CDROM_SELECT_SPEED
|
||||||
|
@ -443,8 +434,7 @@ static void SelectSpeedCdrom(int fd, int speed)
|
||||||
/*
|
/*
|
||||||
* Eject using CDROMEJECT ioctl. Return 1 if successful, 0 otherwise.
|
* Eject using CDROMEJECT ioctl. Return 1 if successful, 0 otherwise.
|
||||||
*/
|
*/
|
||||||
static int EjectCdrom(int fd)
|
static int eject_cdrom(int fd) {
|
||||||
{
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = ioctl(fd, CDROMEJECT);
|
status = ioctl(fd, CDROMEJECT);
|
||||||
|
@ -455,8 +445,7 @@ static int EjectCdrom(int fd)
|
||||||
/*
|
/*
|
||||||
* Eject using SCSI commands. Return 1 if successful, 0 otherwise.
|
* Eject using SCSI commands. Return 1 if successful, 0 otherwise.
|
||||||
*/
|
*/
|
||||||
static int EjectScsi(int fd)
|
static int eject_scsi(int fd) {
|
||||||
{
|
|
||||||
int status;
|
int status;
|
||||||
struct sdata {
|
struct sdata {
|
||||||
int inlen;
|
int inlen;
|
||||||
|
@ -509,8 +498,7 @@ static int EjectScsi(int fd)
|
||||||
/*
|
/*
|
||||||
* Eject using FDEJECT ioctl. Return 1 if successful, 0 otherwise.
|
* Eject using FDEJECT ioctl. Return 1 if successful, 0 otherwise.
|
||||||
*/
|
*/
|
||||||
static int EjectFloppy(int fd)
|
static int eject_floppy(int fd) {
|
||||||
{
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = ioctl(fd, FDEJECT);
|
status = ioctl(fd, FDEJECT);
|
||||||
|
@ -521,8 +509,7 @@ static int EjectFloppy(int fd)
|
||||||
/*
|
/*
|
||||||
* Eject using tape ioctl. Return 1 if successful, 0 otherwise.
|
* Eject using tape ioctl. Return 1 if successful, 0 otherwise.
|
||||||
*/
|
*/
|
||||||
static int EjectTape(int fd)
|
static int eject_tape(int fd) {
|
||||||
{
|
|
||||||
int status;
|
int status;
|
||||||
struct mtop op;
|
struct mtop op;
|
||||||
|
|
||||||
|
@ -534,8 +521,7 @@ static int EjectTape(int fd)
|
||||||
|
|
||||||
|
|
||||||
/* Unmount a device. */
|
/* Unmount a device. */
|
||||||
static void Unmount(const char *fullName)
|
static void unmount(const char *fullName) {
|
||||||
{
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
|
@ -564,8 +550,7 @@ static void Unmount(const char *fullName)
|
||||||
|
|
||||||
|
|
||||||
/* Open a device file. */
|
/* Open a device file. */
|
||||||
static int OpenDevice(const char *fullName)
|
static int open_device(const char *fullName) {
|
||||||
{
|
|
||||||
int fd = open(fullName, O_RDONLY|O_NONBLOCK);
|
int fd = open(fullName, O_RDONLY|O_NONBLOCK);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
errx(1 , _("unable to open `%s'\n"), fullName);
|
errx(1 , _("unable to open `%s'\n"), fullName);
|
||||||
|
@ -578,8 +563,7 @@ static int OpenDevice(const char *fullName)
|
||||||
* Get major and minor device numbers for a device file name, so we
|
* Get major and minor device numbers for a device file name, so we
|
||||||
* can check for duplicate devices.
|
* can check for duplicate devices.
|
||||||
*/
|
*/
|
||||||
static int GetMajorMinor(const char *name, int *maj, int *min)
|
static int get_major_minor(const char *name, int *maj, int *min) {
|
||||||
{
|
|
||||||
struct stat sstat;
|
struct stat sstat;
|
||||||
*maj = *min = -1;
|
*maj = *min = -1;
|
||||||
if (stat(name, &sstat) == -1)
|
if (stat(name, &sstat) == -1)
|
||||||
|
@ -596,8 +580,7 @@ static int GetMajorMinor(const char *name, int *maj, int *min)
|
||||||
* See if device has been mounted by looking in mount table. If so, set
|
* See if device has been mounted by looking in mount table. If so, set
|
||||||
* device name and mount point name, and return 1, otherwise return 0.
|
* device name and mount point name, and return 1, otherwise return 0.
|
||||||
*/
|
*/
|
||||||
static int MountedDevice(const char *name, char **mountName, char **deviceName)
|
static int mounted_device(const char *name, char **mountName, char **deviceName) {
|
||||||
{
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char line[1024];
|
char line[1024];
|
||||||
char s1[1024];
|
char s1[1024];
|
||||||
|
@ -607,7 +590,7 @@ static int MountedDevice(const char *name, char **mountName, char **deviceName)
|
||||||
int maj;
|
int maj;
|
||||||
int min;
|
int min;
|
||||||
|
|
||||||
GetMajorMinor(name, &maj, &min);
|
get_major_minor(name, &maj, &min);
|
||||||
|
|
||||||
fp = fopen((p_option ? "/proc/mounts" : "/etc/mtab"), "r");
|
fp = fopen((p_option ? "/proc/mounts" : "/etc/mtab"), "r");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
|
@ -619,7 +602,7 @@ static int MountedDevice(const char *name, char **mountName, char **deviceName)
|
||||||
rc = sscanf(line, "%1023s %1023s", s1, s2);
|
rc = sscanf(line, "%1023s %1023s", s1, s2);
|
||||||
if (rc >= 2) {
|
if (rc >= 2) {
|
||||||
int mtabmaj, mtabmin;
|
int mtabmaj, mtabmin;
|
||||||
GetMajorMinor(s1, &mtabmaj, &mtabmin);
|
get_major_minor(s1, &mtabmaj, &mtabmin);
|
||||||
if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) ||
|
if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) ||
|
||||||
((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) {
|
((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) {
|
||||||
e_fclose(fp);
|
e_fclose(fp);
|
||||||
|
@ -640,8 +623,7 @@ static int MountedDevice(const char *name, char **mountName, char **deviceName)
|
||||||
* Step through mount table and unmount all devices that match a regular
|
* Step through mount table and unmount all devices that match a regular
|
||||||
* expression.
|
* expression.
|
||||||
*/
|
*/
|
||||||
static void UnmountDevices(const char *pattern)
|
static void unmount_devices(const char *pattern) {
|
||||||
{
|
|
||||||
regex_t preg;
|
regex_t preg;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char s1[1024];
|
char s1[1024];
|
||||||
|
@ -666,7 +648,7 @@ static void UnmountDevices(const char *pattern)
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
if (v_option)
|
if (v_option)
|
||||||
printf(_("%s: unmounting `%s'\n"), program_invocation_short_name, s1);
|
printf(_("%s: unmounting `%s'\n"), program_invocation_short_name, s1);
|
||||||
Unmount(s1);
|
unmount(s1);
|
||||||
regfree(&preg);
|
regfree(&preg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -679,18 +661,17 @@ static void UnmountDevices(const char *pattern)
|
||||||
* multiple partitions. If so, return a regular expression that matches
|
* multiple partitions. If so, return a regular expression that matches
|
||||||
* partitions for that device, otherwise return 0.
|
* partitions for that device, otherwise return 0.
|
||||||
*/
|
*/
|
||||||
static char *MultiplePartitions(const char *name)
|
static char *multiple_partitions(const char *name) {
|
||||||
{
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int status;
|
int status;
|
||||||
regex_t preg;
|
regex_t preg;
|
||||||
char pattern[256];
|
char pattern[256];
|
||||||
char *result = 0;
|
char *result = 0;
|
||||||
|
|
||||||
for (i = 0; partitionDevice[i] != 0; i++) {
|
for (i = 0; partition_device[i] != 0; i++) {
|
||||||
/* look for ^/dev/foo[a-z]([0-9]?[0-9])?$, e.g. /dev/hda1 */
|
/* look for ^/dev/foo[a-z]([0-9]?[0-9])?$, e.g. /dev/hda1 */
|
||||||
strcpy(pattern, "^/dev/");
|
strcpy(pattern, "^/dev/");
|
||||||
strcat(pattern, partitionDevice[i]);
|
strcat(pattern, partition_device[i]);
|
||||||
strcat(pattern, "[a-z]([0-9]?[0-9])?$");
|
strcat(pattern, "[a-z]([0-9]?[0-9])?$");
|
||||||
regcomp(&preg, pattern, REG_EXTENDED|REG_NOSUB);
|
regcomp(&preg, pattern, REG_EXTENDED|REG_NOSUB);
|
||||||
status = regexec(&preg, name, 1, 0, 0);
|
status = regexec(&preg, name, 1, 0, 0);
|
||||||
|
@ -698,7 +679,7 @@ static char *MultiplePartitions(const char *name)
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
result = (char *) malloc(strlen(name) + 25);
|
result = (char *) malloc(strlen(name) + 25);
|
||||||
strcpy(result, name);
|
strcpy(result, name);
|
||||||
result[strlen(partitionDevice[i]) + 6] = 0;
|
result[strlen(partition_device[i]) + 6] = 0;
|
||||||
strcat(result, "([0-9]?[0-9])?$");
|
strcat(result, "([0-9]?[0-9])?$");
|
||||||
if (v_option)
|
if (v_option)
|
||||||
printf(_("%s: `%s' is a multipartition device\n"), program_invocation_short_name, name);
|
printf(_("%s: `%s' is a multipartition device\n"), program_invocation_short_name, name);
|
||||||
|
@ -712,8 +693,7 @@ static char *MultiplePartitions(const char *name)
|
||||||
|
|
||||||
|
|
||||||
/* handle -x option */
|
/* handle -x option */
|
||||||
void HandleXOption(char *deviceName)
|
void handle_x_option(char *deviceName) {
|
||||||
{
|
|
||||||
int fd; /* file descriptor for device */
|
int fd; /* file descriptor for device */
|
||||||
if (x_option) {
|
if (x_option) {
|
||||||
if (v_option)
|
if (v_option)
|
||||||
|
@ -723,16 +703,15 @@ void HandleXOption(char *deviceName)
|
||||||
else
|
else
|
||||||
printf(_("%s: setting CD-ROM speed to %dX\n"), program_invocation_short_name, x_arg);
|
printf(_("%s: setting CD-ROM speed to %dX\n"), program_invocation_short_name, x_arg);
|
||||||
}
|
}
|
||||||
fd = OpenDevice(deviceName);
|
fd = open_device(deviceName);
|
||||||
SelectSpeedCdrom(fd, x_arg);
|
select_speed(fd, x_arg);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* main program */
|
/* main program */
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
|
||||||
|
|
||||||
const char *defaultDevice = EJECT_DEFAULT_DEVICE; /* default if no name passed by user */
|
const char *defaultDevice = EJECT_DEFAULT_DEVICE; /* default if no name passed by user */
|
||||||
int worked = 0; /* set to 1 when successfully ejected */
|
int worked = 0; /* set to 1 when successfully ejected */
|
||||||
|
@ -803,7 +782,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if mount point, get device name */
|
/* if mount point, get device name */
|
||||||
mounted = MountedDevice(fullName, &mountName, &deviceName);
|
mounted = mounted_device(fullName, &mountName, &deviceName);
|
||||||
if (v_option) {
|
if (v_option) {
|
||||||
if (mounted)
|
if (mounted)
|
||||||
printf(_("%s: `%s' is mounted at `%s'\n"), programName, deviceName, mountName);
|
printf(_("%s: `%s' is mounted at `%s'\n"), programName, deviceName, mountName);
|
||||||
|
@ -830,8 +809,8 @@ int main(int argc, char **argv)
|
||||||
else
|
else
|
||||||
printf(_("%s: disabling auto-eject mode for `%s'\n"), programName, deviceName);
|
printf(_("%s: disabling auto-eject mode for `%s'\n"), programName, deviceName);
|
||||||
}
|
}
|
||||||
fd = OpenDevice(deviceName);
|
fd = open_device(deviceName);
|
||||||
AutoEject(fd, a_arg);
|
auto_eject(fd, a_arg);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,9 +818,9 @@ int main(int argc, char **argv)
|
||||||
if (t_option) {
|
if (t_option) {
|
||||||
if (v_option)
|
if (v_option)
|
||||||
printf(_("%s: closing tray\n"), programName);
|
printf(_("%s: closing tray\n"), programName);
|
||||||
fd = OpenDevice(deviceName);
|
fd = open_device(deviceName);
|
||||||
CloseTray(fd);
|
close_tray(fd);
|
||||||
HandleXOption(deviceName);
|
handle_x_option(deviceName);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,35 +828,35 @@ int main(int argc, char **argv)
|
||||||
if (T_option) {
|
if (T_option) {
|
||||||
if (v_option)
|
if (v_option)
|
||||||
printf(_("%s: toggling tray\n"), programName);
|
printf(_("%s: toggling tray\n"), programName);
|
||||||
fd = OpenDevice(deviceName);
|
fd = open_device(deviceName);
|
||||||
ToggleTray(fd);
|
toggle_tray(fd);
|
||||||
HandleXOption(deviceName);
|
handle_x_option(deviceName);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle -x option only */
|
/* handle -x option only */
|
||||||
if (!c_option) HandleXOption(deviceName);
|
if (!c_option) handle_x_option(deviceName);
|
||||||
|
|
||||||
/* unmount device if mounted */
|
/* unmount device if mounted */
|
||||||
if ((m_option != 1) && mounted) {
|
if ((m_option != 1) && mounted) {
|
||||||
if (v_option)
|
if (v_option)
|
||||||
printf(_("%s: unmounting `%s'\n"), programName, deviceName);
|
printf(_("%s: unmounting `%s'\n"), programName, deviceName);
|
||||||
Unmount(deviceName);
|
unmount(deviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if it is a multipartition device, unmount any other partitions on
|
/* if it is a multipartition device, unmount any other partitions on
|
||||||
the device */
|
the device */
|
||||||
pattern = MultiplePartitions(deviceName);
|
pattern = multiple_partitions(deviceName);
|
||||||
if ((m_option != 1) && (pattern != 0))
|
if ((m_option != 1) && (pattern != 0))
|
||||||
UnmountDevices(pattern);
|
unmount_devices(pattern);
|
||||||
|
|
||||||
/* handle -c option */
|
/* handle -c option */
|
||||||
if (c_option) {
|
if (c_option) {
|
||||||
if (v_option)
|
if (v_option)
|
||||||
printf(_("%s: selecting CD-ROM disc #%d\n"), programName, c_arg);
|
printf(_("%s: selecting CD-ROM disc #%d\n"), programName, c_arg);
|
||||||
fd = OpenDevice(deviceName);
|
fd = open_device(deviceName);
|
||||||
ChangerSelect(fd, c_arg);
|
changer_select(fd, c_arg);
|
||||||
HandleXOption(deviceName);
|
handle_x_option(deviceName);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,13 +866,13 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* open device */
|
/* open device */
|
||||||
fd = OpenDevice(deviceName);
|
fd = open_device(deviceName);
|
||||||
|
|
||||||
/* try various methods of ejecting until it works */
|
/* try various methods of ejecting until it works */
|
||||||
if (r_option) {
|
if (r_option) {
|
||||||
if (v_option)
|
if (v_option)
|
||||||
printf(_("%s: trying to eject `%s' using CD-ROM eject command\n"), programName, deviceName);
|
printf(_("%s: trying to eject `%s' using CD-ROM eject command\n"), programName, deviceName);
|
||||||
worked = EjectCdrom(fd);
|
worked = eject_cdrom(fd);
|
||||||
if (v_option) {
|
if (v_option) {
|
||||||
if (worked)
|
if (worked)
|
||||||
printf(_("%s: CD-ROM eject command succeeded\n"), programName);
|
printf(_("%s: CD-ROM eject command succeeded\n"), programName);
|
||||||
|
@ -905,7 +884,7 @@ int main(int argc, char **argv)
|
||||||
if (s_option && !worked) {
|
if (s_option && !worked) {
|
||||||
if (v_option)
|
if (v_option)
|
||||||
printf(_("%s: trying to eject `%s' using SCSI commands\n"), programName, deviceName);
|
printf(_("%s: trying to eject `%s' using SCSI commands\n"), programName, deviceName);
|
||||||
worked = EjectScsi(fd);
|
worked = eject_scsi(fd);
|
||||||
if (v_option) {
|
if (v_option) {
|
||||||
if (worked)
|
if (worked)
|
||||||
printf(_("%s: SCSI eject succeeded\n"), programName);
|
printf(_("%s: SCSI eject succeeded\n"), programName);
|
||||||
|
@ -917,7 +896,7 @@ int main(int argc, char **argv)
|
||||||
if (f_option && !worked) {
|
if (f_option && !worked) {
|
||||||
if (v_option)
|
if (v_option)
|
||||||
printf(_("%s: trying to eject `%s' using floppy eject command\n"), programName, deviceName);
|
printf(_("%s: trying to eject `%s' using floppy eject command\n"), programName, deviceName);
|
||||||
worked = EjectFloppy(fd);
|
worked = eject_floppy(fd);
|
||||||
if (v_option) {
|
if (v_option) {
|
||||||
if (worked)
|
if (worked)
|
||||||
printf(_("%s: floppy eject command succeeded\n"), programName);
|
printf(_("%s: floppy eject command succeeded\n"), programName);
|
||||||
|
@ -929,7 +908,7 @@ int main(int argc, char **argv)
|
||||||
if (q_option && !worked) {
|
if (q_option && !worked) {
|
||||||
if (v_option)
|
if (v_option)
|
||||||
printf(_("%s: trying to eject `%s' using tape offline command\n"), programName, deviceName);
|
printf(_("%s: trying to eject `%s' using tape offline command\n"), programName, deviceName);
|
||||||
worked = EjectTape(fd);
|
worked = eject_tape(fd);
|
||||||
if (v_option) {
|
if (v_option) {
|
||||||
if (worked)
|
if (worked)
|
||||||
printf(_("%s: tape offline command succeeded\n"), programName);
|
printf(_("%s: tape offline command succeeded\n"), programName);
|
||||||
|
|
Loading…
Reference in New Issue