FreeBSD Bugzilla – Attachment 11525 Details for
Bug 22672
Add "next" and "prev" commands to cdcontrol(1).
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 4.57 KB, created by
Seth Kingsley
on 2000-11-08 00:00:02 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Seth Kingsley
Created:
2000-11-08 00:00:02 UTC
Size:
4.57 KB
patch
obsolete
>Index: cdcontrol.1 >=================================================================== >RCS file: /ncvs/src/usr.sbin/cdcontrol/cdcontrol.1,v >retrieving revision 1.23 >diff -u -r1.23 cdcontrol.1 >--- cdcontrol.1 2000/07/13 22:56:43 1.23 >+++ cdcontrol.1 2000/10/25 06:14:02 >@@ -52,9 +52,13 @@ > The available commands are listed below. Only as many > characters as are required to uniquely identify a command > need be specified. >-Word >+The word > .Em play >-can be omitted. >+can be omitted or the characters ``+'' and ``-'' can be used in the >+place of >+.Em next >+and >+.Em prev . > .Bl -tag -width Cm > > .It Cm play Ar first_track Op Ar last_track >@@ -89,6 +93,12 @@ > using > .Ar length > logical blocks. >+ >+.It Cm next Op Ar tracks >+Skip forward a number of tracks (default 1). >+ >+.It Cm prev Op Ar tracks >+Skip back a number of tracks (default 1). > > .It Cm pause > Stop playing. >Index: cdcontrol.c >=================================================================== >RCS file: /ncvs/src/usr.sbin/cdcontrol/cdcontrol.c,v >retrieving revision 1.27 >diff -u -r1.27 cdcontrol.c >--- cdcontrol.c 2000/07/13 22:56:43 1.27 >+++ cdcontrol.c 2000/11/07 23:38:10 >@@ -25,6 +25,7 @@ > > #include <ctype.h> > #include <err.h> >+#include <vis.h> > #include <errno.h> > #include <stdio.h> > #include <stdlib.h> >@@ -59,15 +60,17 @@ > #define CMD_INFO 4 > #define CMD_PAUSE 5 > #define CMD_PLAY 6 >-#define CMD_QUIT 7 >-#define CMD_RESUME 8 >-#define CMD_STOP 9 >-#define CMD_VOLUME 10 >-#define CMD_CLOSE 11 >-#define CMD_RESET 12 >-#define CMD_SET 13 >-#define CMD_STATUS 14 >-#define CMD_CDID 15 >+#define CMD_NEXT 7 >+#define CMD_PREV 8 >+#define CMD_QUIT 9 >+#define CMD_RESUME 10 >+#define CMD_STOP 11 >+#define CMD_VOLUME 12 >+#define CMD_CLOSE 13 >+#define CMD_RESET 14 >+#define CMD_SET 15 >+#define CMD_STATUS 16 >+#define CMD_CDID 17 > #define STATUS_AUDIO 0x1 > #define STATUS_MEDIA 0x2 > #define STATUS_VOLUME 0x4 >@@ -89,6 +92,8 @@ > { 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_NEXT, "next", 1, "[tracks]"}, >+{ CMD_PREV, "prev", 2, "[tracks]"}, > { CMD_QUIT, "quit", 1, "" }, > { CMD_RESET, "reset", 4, "" }, > { CMD_RESUME, "resume", 1, "" }, >@@ -115,6 +120,7 @@ > int status __P((int *, int *, int *, int *)); > int open_cd __P((void)); > int play __P((char *arg)); >+int next_prev __P((char *arg, int)); > int info __P((char *arg)); > int cdid __P((void)); > int pstatus __P((char *arg)); >@@ -347,6 +353,16 @@ > > return play (arg); > >+ case CMD_NEXT: >+ case CMD_PREV: >+ if (fd < 0 && ! open_cd ()) >+ return (0); >+ >+ while (isspace (*arg)) >+ arg++; >+ >+ return next_prev (arg, cmd); >+ > case CMD_SET: > if (! strcasecmp (arg, "msf")) > msf = 1; >@@ -672,6 +688,42 @@ > return (0); > } > >+int next_prev (char *arg, int cmd) >+{ >+ struct ioc_toc_header h; >+ int rc, n, trk, off, jnk; >+ int dir = (cmd == CMD_NEXT) ? 1 : -1; >+ >+ rc = ioctl (fd, CDIOREADTOCHEADER, &h); >+ >+ if (rc < 0) >+ return (rc); >+ >+ n = h.ending_track - h.starting_track + 1; >+ rc = status (&trk, &jnk, &jnk, &jnk); >+ >+ if (rc < 1) >+ trk = 1; >+ >+ if (arg && *arg) >+ { >+ if (1 != sscanf (arg, "%u", &off)) >+ { >+ warnx("invalid command argument"); >+ return (0); >+ } >+ else >+ trk += off * dir; >+ } >+ else >+ trk+= dir; >+ >+ trk %= (n + 1); >+ trk = (trk < 1) ? 1 : trk; >+ >+ return (play_track (trk, 1, n, 1)); >+} >+ > char *strstatus (int sts) > { > switch (sts) { >@@ -692,7 +744,7 @@ > struct cd_sub_channel_info data; > int rc, trk, m, s, f; > int what = 0; >- char *p; >+ char *p, vmcn[(4 * 15) + 1]; > > while ((p = strtok(arg, " \t"))) { > arg = 0; >@@ -732,8 +784,11 @@ > ss.data->what.media_catalog.mc_valid ? "": "in"); > if (ss.data->what.media_catalog.mc_valid && > ss.data->what.media_catalog.mc_number[0]) >- printf(", number \"%.15s\"", >- ss.data->what.media_catalog.mc_number); >+ { >+ strvisx (vmcn, ss.data->what.media_catalog.mc_number, >+ 15, VIS_OCTAL | VIS_NL); >+ printf(", number \"%.61s\"", vmcn); >+ } > putchar('\n'); > } else > printf("No media catalog info available\n"); >@@ -1086,7 +1141,17 @@ > *cmd = CMD_PLAY; > return (p); > } >- >+ else if (*p == '+') >+ { >+ *cmd = CMD_NEXT; >+ return (p + 1); >+ } >+ else if (*p == '-') >+ { >+ *cmd = CMD_PREV; >+ return (p + 1); >+ } >+ > for (buf = p; *p && ! isspace (*p); p++) > continue;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 22672
: 11525