Репозитории ALT
S: | 2.1.5-alt4 |
5.1: | 2.1.5-alt3 |
4.1: | 2.1.5-alt3 |
4.0: | 2.1.5-alt3 |
3.0: | 2.1.0-alt1 |
Другие репозитории
Upstream: | 2.1.5 |
Группа :: Система/Ядро и оборудование
Пакет: eject
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: eject-2.1.0-alt.patch
Скачать
Скачать
--- eject-2.1.0/eject.c~ 2005-05-02 07:33:04 +0400
+++ eject-2.1.0/eject.c 2005-08-03 17:32:26 +0400
@@ -78,12 +78,12 @@
#define CLOSE(fd) if (close(fd)==-1) { \
- perror(programName); \
+ perror(__progname); \
exit(1); \
}
#define FCLOSE(fd) if (fclose(fd)==-1) { \
- perror(programName); \
+ perror(__progname); \
exit(1); \
}
@@ -107,7 +107,7 @@ int m_option = 0;
int a_arg = 0;
int c_arg = 0;
int x_arg = 0;
-char *programName; /* used in error messages */
+extern const char *__progname;
/*
* These are the basenames of devices which can have multiple
@@ -217,7 +217,7 @@ static void parse_args(int argc, char **
else if (!strcmp(optarg, "on"))
a_arg = 1;
else {
- fprintf(stderr, _("%s: invalid argument to --auto/-a option\n"), programName);
+ fprintf(stderr, _("%s: invalid argument to --auto/-a option\n"), __progname);
exit(1);
}
break;
@@ -229,7 +229,7 @@ static void parse_args(int argc, char **
else {
c_arg = atoi(optarg);
if (c_arg <= 0) {
- fprintf(stderr, _("%s: invalid argument to --changerslot/-c option\n"), programName);
+ fprintf(stderr, _("%s: invalid argument to --changerslot/-c option\n"), __progname);
exit(1);
}
}
@@ -241,7 +241,7 @@ static void parse_args(int argc, char **
else {
x_arg = atoi(optarg);
if (x_arg <= 0) {
- fprintf(stderr, _("%s: invalid argument to --cdspeed/-x option\n"), programName);
+ fprintf(stderr, _("%s: invalid argument to --cdspeed/-x option\n"), __progname);
exit(1);
}
}
@@ -294,7 +294,7 @@ static void parse_args(int argc, char **
}
/* check for a single additional argument */
if ((argc - optind) > 1) {
- fprintf(stderr, _("%s: too many arguments\n"), programName);
+ fprintf(stderr, _("%s: too many arguments\n"), __progname);
exit(1);
}
if ((argc - optind) == 1) { /* one argument */
@@ -342,7 +342,7 @@ static char *FindDevice(const char *name
buf = (char *) malloc(strlen(name)+14); /* to allow for "/dev/cdroms/ + "0" + null */
if (buf==NULL) {
- fprintf(stderr, _("%s: could not allocate memory\n"), programName);
+ fprintf(stderr, _("%s: could not allocate memory\n"), __progname);
exit(1);
}
if ((name[0] == '.') || (name[0] == '/')) {
@@ -407,7 +407,7 @@ static void AutoEject(int fd, int onOff)
status = ioctl(fd, CDROMEJECT_SW, onOff);
if (status != 0) {
- fprintf(stderr, _("%s: CD-ROM auto-eject command failed: %s\n"), programName, strerror(errno));
+ fprintf(stderr, _("%s: CD-ROM auto-eject command failed: %s\n"), __progname, strerror(errno));
exit(1);
}
}
@@ -424,17 +424,17 @@ static void ChangerSelect(int fd, int sl
#ifdef CDROM_SELECT_DISC
status = ioctl(fd, CDROM_SELECT_DISC, slot);
if (status < 0) {
- fprintf(stderr, _("%s: CD-ROM select disc command failed: %s\n"), programName, strerror(errno));
+ fprintf(stderr, _("%s: CD-ROM select disc command failed: %s\n"), __progname, strerror(errno));
exit(1);
}
#elif defined CDROMLOADFROMSLOT
status = ioctl(fd, CDROMLOADFROMSLOT, slot);
if (status != 0) {
- fprintf(stderr, _("%s: CD-ROM load from slot command failed: %s\n"), programName, strerror(errno));
+ fprintf(stderr, _("%s: CD-ROM load from slot command failed: %s\n"), __progname, strerror(errno));
exit(1);
}
#else
- fprintf(stderr, _("%s: IDE/ATAPI CD-ROM changer not supported by this kernel\n"), programName);
+ fprintf(stderr, _("%s: IDE/ATAPI CD-ROM changer not supported by this kernel\n"), __progname);
#endif
}
@@ -449,11 +449,11 @@ static void CloseTray(int fd)
#ifdef CDROMCLOSETRAY
status = ioctl(fd, CDROMCLOSETRAY);
if (status != 0) {
- fprintf(stderr, _("%s: CD-ROM tray close command failed: %s\n"), programName, strerror(errno));
+ fprintf(stderr, _("%s: CD-ROM tray close command failed: %s\n"), __progname, strerror(errno));
exit(1);
}
#else
- fprintf(stderr, _("%s: CD-ROM tray close command not supported by this kernel\n"), programName);
+ fprintf(stderr, _("%s: CD-ROM tray close command not supported by this kernel\n"), __progname);
#endif
}
@@ -500,7 +500,7 @@ static void ToggleTray(int fd)
CloseTray(fd);
#else
- fprintf(stderr, _("%s: CD-ROM tray toggle command not supported by this kernel\n"), programName);
+ fprintf(stderr, _("%s: CD-ROM tray toggle command not supported by this kernel\n"), __progname);
#endif
}
@@ -517,11 +517,11 @@ static void SelectSpeedCdrom(int fd, int
#ifdef CDROM_SELECT_SPEED
status = ioctl(fd, CDROM_SELECT_SPEED, speed);
if (status != 0) {
- fprintf(stderr, _("%s: CD-ROM select speed command failed: %s\n"), programName, strerror(errno));
+ fprintf(stderr, _("%s: CD-ROM select speed command failed: %s\n"), __progname, strerror(errno));
exit(1);
}
#else
- fprintf(stderr, _("%s: CD-ROM select speed command not supported by this kernel\n"), programName);
+ fprintf(stderr, _("%s: CD-ROM select speed command not supported by this kernel\n"), __progname);
#endif
}
@@ -632,20 +632,20 @@ static void Unmount(const char *fullName
else
execl("/bin/umount", "/bin/umount", fullName, NULL);
fprintf(stderr, _("%s: unable to exec /bin/umount of `%s': %s\n"),
- programName, fullName, strerror(errno));
+ __progname, fullName, strerror(errno));
exit(1);
break;
case -1:
- fprintf(stderr, _("%s: unable to fork: %s\n"), programName, strerror(errno));
+ fprintf(stderr, _("%s: unable to fork: %s\n"), __progname, strerror(errno));
break;
default: /* parent */
wait(&status);
if (WIFEXITED(status) == 0) {
- fprintf(stderr, _("%s: unmount of `%s' did not exit normally\n"), programName, fullName);
+ fprintf(stderr, _("%s: unmount of `%s' did not exit normally\n"), __progname, fullName);
exit(1);
}
if (WEXITSTATUS(status) != 0) {
- fprintf(stderr, _("%s: unmount of `%s' failed\n"), programName, fullName);
+ fprintf(stderr, _("%s: unmount of `%s' failed\n"), __progname, fullName);
exit(1);
}
break;
@@ -658,7 +658,7 @@ static int OpenDevice(const char *fullNa
{
int fd = open(fullName, O_RDONLY|O_NONBLOCK);
if (fd == -1) {
- fprintf(stderr, _("%s: unable to open `%s'\n"), programName, fullName);
+ fprintf(stderr, _("%s: unable to open `%s'\n"), __progname, fullName);
exit(1);
}
return fd;
@@ -747,10 +747,10 @@ static int MountableDevice(const char *n
* /etc/fstab may be unreadable in some situations due to passwords in the
* file.
*/
-/* fprintf(stderr, _("%s: unable to open /etc/fstab: %s\n"), programName, strerror(errno));
+/* fprintf(stderr, _("%s: unable to open /etc/fstab: %s\n"), __progname, strerror(errno));
exit(1);*/
if (v_option) {
- printf( _("%s: unable to open /etc/fstab: %s\n"), programName, strerror(errno));
+ printf( _("%s: unable to open /etc/fstab: %s\n"), __progname, strerror(errno));
}
return -1;
}
@@ -783,7 +783,7 @@ static void UnmountDevices(const char *p
int status;
if (regcomp(&preg, pattern, REG_EXTENDED)!=0) {
- perror(programName);
+ perror(__progname);
exit(1);
}
@@ -800,7 +800,7 @@ static void UnmountDevices(const char *p
status = regexec(&preg, s1, 0, 0, 0);
if (status == 0) {
if (v_option)
- printf(_("%s: unmounting `%s'\n"), programName, s1);
+ printf(_("%s: unmounting `%s'\n"), __progname, s1);
Unmount(s1);
regfree(&preg);
}
@@ -873,12 +873,12 @@ static char *MultiplePartitions(const ch
result[strlen(partitionDevice[i]) + 6] = 0;
strcat(result, "([0-9]?[0-9])?$");
if (v_option)
- printf(_("%s: `%s' is a multipartition device\n"), programName, name);
+ printf(_("%s: `%s' is a multipartition device\n"), __progname, name);
return result;
}
}
if (v_option)
- printf(_("%s: `%s' is not a multipartition device\n"), programName, name);
+ printf(_("%s: `%s' is not a multipartition device\n"), __progname, name);
return 0;
}
@@ -891,9 +891,9 @@ void HandleXOption(char *deviceName)
if (v_option)
{
if (x_arg == 0)
- printf(_("%s: setting CD-ROM speed to auto\n"), programName);
+ printf(_("%s: setting CD-ROM speed to auto\n"), __progname);
else
- printf(_("%s: setting CD-ROM speed to %dX\n"), programName, x_arg);
+ printf(_("%s: setting CD-ROM speed to %dX\n"), __progname, x_arg);
}
fd = OpenDevice(deviceName);
SelectSpeedCdrom(fd, x_arg);
@@ -920,16 +920,13 @@ int main(int argc, char **argv)
I18NCODE
- /* program name is global variable used by other procedures */
- programName = strdup(argv[0]);
-
/* parse the command line arguments */
parse_args(argc, argv, &device);
/* handle -d option */
if (d_option) {
- printf(_("%s: default device: `%s'\n"), programName, defaultDevice);
+ printf(_("%s: default device: `%s'\n"), __progname, defaultDevice);
exit(0);
}
@@ -937,7 +934,7 @@ int main(int argc, char **argv)
if (device == 0) {
device = strdup(defaultDevice);
if (v_option)
- printf(_("%s: using default device `%s'\n"), programName, device);
+ printf(_("%s: using default device `%s'\n"), __progname, device);
}
/* Strip any trailing slash from name in case user used bash/tcsh
@@ -946,21 +943,21 @@ int main(int argc, char **argv)
device[strlen(device)-1] = 0;
if (v_option)
- printf(_("%s: device name is `%s'\n"), programName, device);
+ printf(_("%s: device name is `%s'\n"), __progname, device);
/* figure out full device or mount point name */
fullName = FindDevice(device);
if (fullName == 0) {
- fprintf(stderr, _("%s: unable to find or open device for: `%s'\n"), programName, device);
+ fprintf(stderr, _("%s: unable to find or open device for: `%s'\n"), __progname, device);
exit(1);
}
if (v_option)
- printf(_("%s: expanded name is `%s'\n"), programName, fullName);
+ printf(_("%s: expanded name is `%s'\n"), __progname, fullName);
/* check for a symbolic link */
while ((linkName = SymLink(fullName)) && (ld > 0)) {
if (v_option)
- printf(_("%s: `%s' is a link to `%s'\n"), programName, fullName, linkName);
+ printf(_("%s: `%s' is a link to `%s'\n"), __progname, fullName, linkName);
free(fullName);
fullName = strdup(linkName);
free(linkName);
@@ -969,7 +966,7 @@ int main(int argc, char **argv)
}
/* handle max depth exceeded option */
if (ld <= 0) {
- printf(_("%s: maximum symbolic link depth exceeded: `%s'\n"), programName, fullName);
+ printf(_("%s: maximum symbolic link depth exceeded: `%s'\n"), __progname, fullName);
exit(1);
}
@@ -977,9 +974,9 @@ int main(int argc, char **argv)
mounted = MountedDevice(fullName, &mountName, &deviceName);
if (v_option) {
if (mounted)
- printf(_("%s: `%s' is mounted at `%s'\n"), programName, deviceName, mountName);
+ printf(_("%s: `%s' is mounted at `%s'\n"), __progname, deviceName, mountName);
else
- printf(_("%s: `%s' is not mounted\n"), programName, fullName);
+ printf(_("%s: `%s' is not mounted\n"), __progname, fullName);
}
if (!mounted) {
deviceName = strdup(fullName);
@@ -991,17 +988,17 @@ int main(int argc, char **argv)
/* if return value -1 then fstab could not be read */
if (v_option && mountable >= 0) {
if (mountable)
- printf(_("%s: `%s' can be mounted at `%s'\n"), programName, deviceName, mountName);
+ printf(_("%s: `%s' can be mounted at `%s'\n"), __progname, deviceName, mountName);
else
- printf(_("%s: `%s' is not a mount point\n"), programName, fullName);
+ printf(_("%s: `%s' is not a mount point\n"), __progname, fullName);
}
}
/* handle -n option */
if (n_option) {
- printf(_("%s: device is `%s'\n"), programName, deviceName);
+ printf(_("%s: device is `%s'\n"), __progname, deviceName);
if (v_option)
- printf(_("%s: exiting due to -n/--noop option\n"), programName);
+ printf(_("%s: exiting due to -n/--noop option\n"), __progname);
exit(0);
}
@@ -1009,9 +1006,9 @@ int main(int argc, char **argv)
if (a_option) {
if (v_option) {
if (a_arg)
- printf(_("%s: enabling auto-eject mode for `%s'\n"), programName, deviceName);
+ printf(_("%s: enabling auto-eject mode for `%s'\n"), __progname, deviceName);
else
- printf(_("%s: disabling auto-eject mode for `%s'\n"), programName, deviceName);
+ printf(_("%s: disabling auto-eject mode for `%s'\n"), __progname, deviceName);
}
fd = OpenDevice(deviceName);
AutoEject(fd, a_arg);
@@ -1021,7 +1018,7 @@ int main(int argc, char **argv)
/* handle -t option */
if (t_option) {
if (v_option)
- printf(_("%s: closing tray\n"), programName);
+ printf(_("%s: closing tray\n"), __progname);
fd = OpenDevice(deviceName);
CloseTray(fd);
HandleXOption(deviceName);
@@ -1031,7 +1028,7 @@ int main(int argc, char **argv)
/* handle -T option */
if (T_option) {
if (v_option)
- printf(_("%s: toggling tray\n"), programName);
+ printf(_("%s: toggling tray\n"), __progname);
fd = OpenDevice(deviceName);
ToggleTray(fd);
HandleXOption(deviceName);
@@ -1044,7 +1041,7 @@ int main(int argc, char **argv)
/* unmount device if mounted */
if ((m_option != 1) && mounted) {
if (v_option)
- printf(_("%s: unmounting `%s'\n"), programName, deviceName);
+ printf(_("%s: unmounting `%s'\n"), __progname, deviceName);
Unmount(deviceName);
}
@@ -1057,7 +1054,7 @@ int main(int argc, char **argv)
/* handle -c option */
if (c_option) {
if (v_option)
- printf(_("%s: selecting CD-ROM disc #%d\n"), programName, c_arg);
+ printf(_("%s: selecting CD-ROM disc #%d\n"), __progname, c_arg);
fd = OpenDevice(deviceName);
ChangerSelect(fd, c_arg);
HandleXOption(deviceName);
@@ -1075,54 +1072,54 @@ int main(int argc, char **argv)
/* try various methods of ejecting until it works */
if (r_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"), __progname, deviceName);
worked = EjectCdrom(fd);
if (v_option) {
if (worked)
- printf(_("%s: CD-ROM eject command succeeded\n"), programName);
+ printf(_("%s: CD-ROM eject command succeeded\n"), __progname);
else
- printf(_("%s: CD-ROM eject command failed\n"), programName);
+ printf(_("%s: CD-ROM eject command failed\n"), __progname);
}
}
if (s_option && !worked) {
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"), __progname, deviceName);
worked = EjectScsi(fd);
if (v_option) {
if (worked)
- printf(_("%s: SCSI eject succeeded\n"), programName);
+ printf(_("%s: SCSI eject succeeded\n"), __progname);
else
- printf(_("%s: SCSI eject failed\n"), programName);
+ printf(_("%s: SCSI eject failed\n"), __progname);
}
}
if (f_option && !worked) {
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"), __progname, deviceName);
worked = EjectFloppy(fd);
if (v_option) {
if (worked)
- printf(_("%s: floppy eject command succeeded\n"), programName);
+ printf(_("%s: floppy eject command succeeded\n"), __progname);
else
- printf(_("%s: floppy eject command failed\n"), programName);
+ printf(_("%s: floppy eject command failed\n"), __progname);
}
}
if (q_option && !worked) {
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"), __progname, deviceName);
worked = EjectTape(fd);
if (v_option) {
if (worked)
- printf(_("%s: tape offline command succeeded\n"), programName);
+ printf(_("%s: tape offline command succeeded\n"), __progname);
else
- printf(_("%s: tape offline command failed\n"), programName);
+ printf(_("%s: tape offline command failed\n"), __progname);
}
}
if (!worked) {
- fprintf(stderr, _("%s: unable to eject, last error: %s\n"), programName, strerror(errno));
+ fprintf(stderr, _("%s: unable to eject, last error: %s\n"), __progname, strerror(errno));
exit(1);
}