Date: Sun, 29 Apr 2001 15:00:03 -0700 (PDT) From: Maxime Henrion <mux@qualys.com> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/26962: [PATCH] add ``next'' and ``previous'' commands to cdcontrol(1). Message-ID: <200104292200.f3TM03t70742@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/26962; it has been noted by GNATS.
From: Maxime Henrion <mux@qualys.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Bill Fumerola <billf@mu.org>
Subject: Re: bin/26962: [PATCH] add ``next'' and ``previous'' commands to cdcontrol(1).
Date: Sun, 29 Apr 2001 23:53:38 +0200
Whitespace problems fixed in this patch. Actually I used tabs as I
think it should have been done, but the original source code was using
spaces :/
*** cdcontrol.c.old Sun Apr 29 21:33:09 2001
--- cdcontrol.c Sun Apr 29 21:32:48 2001
***************
*** 69,74 ****
--- 69,76 ----
#define CMD_SET 13
#define CMD_STATUS 14
#define CMD_CDID 15
+ #define CMD_NEXT 16
+ #define CMD_PREVIOUS 17
#define STATUS_AUDIO 0x1
#define STATUS_MEDIA 0x2
#define STATUS_VOLUME 0x4
***************
*** 85,95 ****
--- 87,99 ----
{ CMD_HELP, "?", 1, 0 },
{ CMD_HELP, "help", 1, "" },
{ CMD_INFO, "info", 1, "" },
+ { CMD_NEXT, "next", 1, "" },
{ CMD_PAUSE, "pause", 2, "" },
{ CMD_PLAY, "play", 1, "min1:sec1[.fram1] [min2:sec2[.fram2]]" },
{ CMD_PLAY, "play", 1, "track1[.index1] [track2[.index2]]" },
{ CMD_PLAY, "play", 1, "tr1 m1:s1[.f1] [[tr2] [m2:s2[.f2]]]" },
{ CMD_PLAY, "play", 1, "[#block [len]]" },
+ { CMD_PREVIOUS, "previous", 2, "" },
{ CMD_QUIT, "quit", 1, "" },
{ CMD_RESET, "reset", 4, "" },
{ CMD_RESUME, "resume", 1, "" },
***************
*** 115,120 ****
--- 119,126 ----
int get_vol __P((int *, int *));
int status __P((int *, int *, int *, int *));
int open_cd __P((void));
+ int next __P((void));
+ int previous __P((void));
int play __P((char *arg));
int info __P((char *arg));
int cdid __P((void));
***************
*** 287,298 ****
--- 293,316 ----
return pstatus (arg);
+ case CMD_NEXT:
+ if (fd < 0 && ! open_cd ())
+ return (0);
+
+ return next ();
+
case CMD_PAUSE:
if (fd < 0 && ! open_cd ())
return (0);
return ioctl (fd, CDIOCPAUSE);
+ case CMD_PREVIOUS:
+ if (fd < 0 && ! open_cd ())
+ return (0);
+
+ return previous ();
+
case CMD_RESUME:
if (fd < 0 && ! open_cd ())
return (0);
***************
*** 1180,1183 ****
--- 1198,1245 ----
err(1, "%s", devbuf);
}
return (1);
+ }
+
+ int
+ next()
+ {
+ int trk;
+ struct ioc_toc_header h;
+ int rc, n;
+
+ rc = ioctl(fd, CDIOREADTOCHEADER, &h);
+
+ if (rc < 0)
+ return (rc);
+
+ n = h.ending_track - h.starting_track + 1;
+
+ if (status(&trk, &rc, &rc, &rc) < 0)
+ return (-1);
+
+ if (++trk > h.ending_track)
+ trk = 1;
+ return play_track(trk, 1, n, 1);
+ }
+
+ int
+ previous()
+ {
+ int trk;
+ struct ioc_toc_header h;
+ int rc, n;
+
+ rc = ioctl(fd, CDIOREADTOCHEADER, &h);
+
+ if (rc < 0)
+ return (rc);
+
+ n = h.ending_track - h.starting_track + 1;
+
+ if (status(&trk, &rc, &rc, &rc) < 0)
+ return (-1);
+
+ if (--trk < 1)
+ trk = h.ending_track;
+ return play_track(trk, 1, n, 1);
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200104292200.f3TM03t70742>
