View | Details | Raw Unified | Return to bug 22672
Collapse All | Expand All

(-)cdcontrol.1 (-2 / +12 lines)
Lines 52-60 Link Here
52
The available commands are listed below.  Only as many
52
The available commands are listed below.  Only as many
53
characters as are required to uniquely identify a command
53
characters as are required to uniquely identify a command
54
need be specified.
54
need be specified.
55
Word
55
The word
56
.Em play
56
.Em play
57
can be omitted.
57
can be omitted or the characters ``+'' and ``-'' can be used in the
58
place of
59
.Em next
60
and
61
.Em prev .
58
.Bl -tag -width Cm
62
.Bl -tag -width Cm
59
63
60
.It Cm play Ar first_track Op Ar last_track
64
.It Cm play Ar first_track Op Ar last_track
Lines 89-94 Link Here
89
using
93
using
90
.Ar length
94
.Ar length
91
logical blocks.
95
logical blocks.
96
97
.It Cm next Op Ar tracks
98
Skip forward a number of tracks (default 1).
99
100
.It Cm prev Op Ar tracks
101
Skip back a number of tracks (default 1).
92
102
93
.It Cm pause
103
.It Cm pause
94
Stop playing.
104
Stop playing.
(-)cdcontrol.c (-13 / +78 lines)
Lines 25-30 Link Here
25
25
26
#include <ctype.h>
26
#include <ctype.h>
27
#include <err.h>
27
#include <err.h>
28
#include <vis.h>
28
#include <errno.h>
29
#include <errno.h>
29
#include <stdio.h>
30
#include <stdio.h>
30
#include <stdlib.h>
31
#include <stdlib.h>
Lines 59-73 Link Here
59
#define CMD_INFO        4
60
#define CMD_INFO        4
60
#define CMD_PAUSE       5
61
#define CMD_PAUSE       5
61
#define CMD_PLAY        6
62
#define CMD_PLAY        6
62
#define CMD_QUIT        7
63
#define CMD_NEXT        7
63
#define CMD_RESUME      8
64
#define CMD_PREV        8
64
#define CMD_STOP        9
65
#define CMD_QUIT        9
65
#define CMD_VOLUME      10
66
#define CMD_RESUME      10
66
#define CMD_CLOSE       11
67
#define CMD_STOP        11
67
#define CMD_RESET       12
68
#define CMD_VOLUME      12
68
#define CMD_SET         13
69
#define CMD_CLOSE       13
69
#define CMD_STATUS      14
70
#define CMD_RESET       14
70
#define CMD_CDID        15
71
#define CMD_SET         15
72
#define CMD_STATUS      16
73
#define CMD_CDID        17
71
#define STATUS_AUDIO    0x1
74
#define STATUS_AUDIO    0x1
72
#define STATUS_MEDIA    0x2
75
#define STATUS_MEDIA    0x2
73
#define STATUS_VOLUME   0x4
76
#define STATUS_VOLUME   0x4
Lines 89-94 Link Here
89
{ CMD_PLAY,     "play",         1, "track1[.index1] [track2[.index2]]" },
92
{ CMD_PLAY,     "play",         1, "track1[.index1] [track2[.index2]]" },
90
{ CMD_PLAY,     "play",         1, "tr1 m1:s1[.f1] [[tr2] [m2:s2[.f2]]]" },
93
{ CMD_PLAY,     "play",         1, "tr1 m1:s1[.f1] [[tr2] [m2:s2[.f2]]]" },
91
{ CMD_PLAY,     "play",         1, "[#block [len]]" },
94
{ CMD_PLAY,     "play",         1, "[#block [len]]" },
95
{ CMD_NEXT,     "next",         1, "[tracks]"},
96
{ CMD_PREV,     "prev",         2, "[tracks]"},
92
{ CMD_QUIT,     "quit",         1, "" },
97
{ CMD_QUIT,     "quit",         1, "" },
93
{ CMD_RESET,    "reset",        4, "" },
98
{ CMD_RESET,    "reset",        4, "" },
94
{ CMD_RESUME,   "resume",       1, "" },
99
{ CMD_RESUME,   "resume",       1, "" },
Lines 115-120 Link Here
115
int             status __P((int *, int *, int *, int *));
120
int             status __P((int *, int *, int *, int *));
116
int             open_cd __P((void));
121
int             open_cd __P((void));
117
int             play __P((char *arg));
122
int             play __P((char *arg));
123
int		next_prev __P((char *arg, int));
118
int             info __P((char *arg));
124
int             info __P((char *arg));
119
int             cdid __P((void));
125
int             cdid __P((void));
120
int             pstatus __P((char *arg));
126
int             pstatus __P((char *arg));
Lines 347-352 Link Here
347
353
348
		return play (arg);
354
		return play (arg);
349
355
356
	case CMD_NEXT:
357
	case CMD_PREV:
358
		if (fd < 0 && ! open_cd ())
359
			return (0);
360
361
		while (isspace (*arg))
362
			arg++;
363
364
		return next_prev (arg, cmd);
365
350
	case CMD_SET:
366
	case CMD_SET:
351
		if (! strcasecmp (arg, "msf"))
367
		if (! strcasecmp (arg, "msf"))
352
			msf = 1;
368
			msf = 1;
Lines 672-677 Link Here
672
	return (0);
688
	return (0);
673
}
689
}
674
690
691
int next_prev (char *arg, int cmd)
692
{
693
	struct ioc_toc_header h;
694
	int rc, n, trk, off, jnk;
695
	int dir = (cmd == CMD_NEXT) ? 1 : -1;
696
697
	rc = ioctl (fd, CDIOREADTOCHEADER, &h);
698
699
	if (rc < 0)
700
		return (rc);
701
702
	n = h.ending_track - h.starting_track + 1;
703
	rc = status (&trk, &jnk, &jnk, &jnk);
704
705
	if (rc < 1)
706
		trk = 1;
707
708
	if (arg && *arg)
709
	{
710
		if (1 != sscanf (arg, "%u", &off)) 
711
		{
712
			warnx("invalid command argument");
713
			return (0);
714
		}
715
		else
716
			trk += off * dir;
717
	}
718
	else
719
		trk+= dir;
720
721
	trk %= (n + 1);
722
	trk = (trk < 1) ? 1 : trk;
723
724
	return (play_track (trk, 1, n, 1));
725
}
726
675
char *strstatus (int sts)
727
char *strstatus (int sts)
676
{
728
{
677
	switch (sts) {
729
	switch (sts) {
Lines 692-698 Link Here
692
	struct cd_sub_channel_info data;
744
	struct cd_sub_channel_info data;
693
	int rc, trk, m, s, f;
745
	int rc, trk, m, s, f;
694
	int what = 0;
746
	int what = 0;
695
	char *p;
747
	char *p, vmcn[(4 * 15) + 1];
696
748
697
	while ((p = strtok(arg, " \t"))) {
749
	while ((p = strtok(arg, " \t"))) {
698
	    arg = 0;
750
	    arg = 0;
Lines 732-739 Link Here
732
		       ss.data->what.media_catalog.mc_valid ? "": "in");
784
		       ss.data->what.media_catalog.mc_valid ? "": "in");
733
		if (ss.data->what.media_catalog.mc_valid &&
785
		if (ss.data->what.media_catalog.mc_valid &&
734
		    ss.data->what.media_catalog.mc_number[0])
786
		    ss.data->what.media_catalog.mc_number[0])
735
		    printf(", number \"%.15s\"",
787
		{
736
			   ss.data->what.media_catalog.mc_number);
788
		    strvisx (vmcn, ss.data->what.media_catalog.mc_number,
789
			    15, VIS_OCTAL | VIS_NL);
790
		    printf(", number \"%.61s\"", vmcn);
791
		}
737
		putchar('\n');
792
		putchar('\n');
738
	    } else
793
	    } else
739
		printf("No media catalog info available\n");
794
		printf("No media catalog info available\n");
Lines 1086-1092 Link Here
1086
		*cmd = CMD_PLAY;
1141
		*cmd = CMD_PLAY;
1087
		return (p);
1142
		return (p);
1088
	}
1143
	}
1089
1144
	else if (*p == '+')
1145
	{
1146
		*cmd = CMD_NEXT;
1147
		return (p + 1);
1148
	}
1149
	else if (*p == '-')
1150
	{
1151
		*cmd = CMD_PREV;
1152
		return (p + 1);
1153
	}
1154
	    
1090
	for (buf = p; *p && ! isspace (*p); p++)
1155
	for (buf = p; *p && ! isspace (*p); p++)
1091
		continue;
1156
		continue;

Return to bug 22672