mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.3 KiB

  1. An eject functionality is rather handy on software controlled CD-ROM
  2. laptops (e.g. Apple ones) ...
  3. - Rene Rebe <rene@rocklinux.org>
  4. --- kiss-0.21/src/Makefile 1998-09-25 14:07:09.000000000 +0200
  5. +++ kiss-0.21-eject/src/Makefile 2004-03-06 15:11:57.000000000 +0100
  6. @@ -66,7 +66,7 @@
  7. addstringstack.o expandtilde.o splitcmd.o addstringtostack.o \
  8. dokill.o dogrep.o dochown.o dosleep.o expandbackquotes.o dols.o \
  9. listdir.o listfile.o listoutput.o domknod.o dowc.o domount.o \
  10. - doumount.o dotouch.o
  11. + doumount.o dotouch.o doeject.o
  12. # entry point for making
  13. foo:
  14. --- kiss-0.21/src/doeject.c 1970-01-01 01:00:00.000000000 +0100
  15. +++ kiss-0.21-eject/src/doeject.c 2004-03-06 17:08:46.000000000 +0100
  16. @@ -0,0 +1,37 @@
  17. +#include "kiss.h"
  18. +
  19. +#if __GNUC__ == 3 && __GNUC_MINOR__ > 2
  20. +#define __attribute_const__ __attribute__ ((const))
  21. +#endif
  22. +
  23. +#include <linux/cdrom.h>
  24. +
  25. +int doeject (Stringstack s)
  26. +{
  27. + register int
  28. + i;
  29. +
  30. + /* need at least one arg */
  31. + if (s.nstr == 1) {
  32. + error ("Bad commandline.\n"
  33. + "Usage: %s device\n", progname);
  34. + return (0);
  35. + }
  36. +
  37. + for (i = 1; i < s.nstr; i++) {
  38. + int status;
  39. + int fd = open(s.str[i], O_RDONLY|O_NONBLOCK);
  40. +
  41. + if (fd == -1) {
  42. + warning ("%s: unable to open %s\n", progname, s.str[i]);
  43. + continue;
  44. + }
  45. +
  46. + status = ioctl(fd, CDROMEJECT);
  47. + if (status != 0) {
  48. + error ("%s: failed\n");
  49. + }
  50. + close (fd);
  51. + }
  52. + return (0);
  53. +}
  54. --- kiss-0.21/src/kiss.c 1998-09-25 14:07:10.000000000 +0200
  55. +++ kiss-0.21-eject/src/kiss.c 2004-03-06 15:11:57.000000000 +0100
  56. @@ -32,6 +32,7 @@
  57. { "chown", dochown, 0 },
  58. { "cp", docp, 0 },
  59. { "echo", doecho, 0 },
  60. + { "eject", doeject, 0 },
  61. { "exec", doexec, 1 },
  62. { "exit", doquit, 1 },
  63. { "grep", dogrep, 0 },
  64. --- kiss-0.21/src/kiss.h 1998-09-25 14:07:10.000000000 +0200
  65. +++ kiss-0.21-eject/src/kiss.h 2004-03-06 15:11:57.000000000 +0100
  66. @@ -194,6 +194,7 @@
  67. extern int dochown (Stringstack s);
  68. extern int docp (Stringstack s);
  69. extern int doecho (Stringstack s);
  70. +extern int doeject (Stringstack s);
  71. extern int doexec (Stringstack s);
  72. extern int dogrep (Stringstack s);
  73. extern int dohelp (Stringstack s);