Lines 1-64
Link Here
|
1 |
--- src/command.c Wed Mar 3 19:05:02 2004 |
|
|
2 |
+++ src/command.c Wed Mar 3 19:05:47 2004 |
3 |
@@ -243,16 +243,23 @@ |
4 |
int cmd_seek ( int argc, char ** argv, mpd_Connection * conn ) |
5 |
{ |
6 |
mpd_Status * status = mpd_getStatus(conn); |
7 |
+ char * arg = argv[0]; |
8 |
+ int seekmode; |
9 |
+ char * test; |
10 |
+ int seekchange; |
11 |
+ char * last_char; |
12 |
+ int sec; |
13 |
+ float perc; |
14 |
+ int seekto; |
15 |
+ |
16 |
my_finishCommand(conn); |
17 |
if(status->state==MPD_STATUS_STATE_STOP) |
18 |
DIE("not currently playing\n"); |
19 |
|
20 |
- char * arg = argv[0]; |
21 |
- |
22 |
if(!strlen(arg)) |
23 |
DIE("\"%s\" is not a positive number\n", arg); |
24 |
|
25 |
- int seekmode = Absolute; |
26 |
+ seekmode = Absolute; |
27 |
|
28 |
if(arg[0] == '+') { |
29 |
seekmode = RelForward; |
30 |
@@ -262,15 +269,13 @@ |
31 |
arg++; |
32 |
} |
33 |
|
34 |
- char * test; |
35 |
- int seekchange; |
36 |
|
37 |
- char * last_char = &arg[strlen(arg)-1]; |
38 |
+ last_char = &arg[strlen(arg)-1]; |
39 |
if(*last_char == 's') { |
40 |
/* absolute seek (in seconds) */ |
41 |
|
42 |
*last_char = '\0'; /* chop off the s */ |
43 |
- int sec = strtol(arg,&test,10); /* get the # of seconds */ |
44 |
+ sec = strtol(arg,&test,10); /* get the # of seconds */ |
45 |
|
46 |
if(*test!='\0' || sec<0) |
47 |
DIE("\"%s\" is not a positive number\n", arg); |
48 |
@@ -280,14 +285,14 @@ |
49 |
} else { |
50 |
/* percent seek */ |
51 |
|
52 |
- float perc = strtod(arg,&test); |
53 |
+ perc = strtod(arg,&test); |
54 |
if(*test!='\0' || perc<0 || perc>100) |
55 |
DIE("\"%s\" is not an number between 0 and 100\n",arg); |
56 |
|
57 |
seekchange = perc*status->totalTime/100+0.5; |
58 |
} |
59 |
|
60 |
- int seekto = calculate_seek(status->elapsedTime, seekchange, seekmode); |
61 |
+ seekto = calculate_seek(status->elapsedTime, seekchange, seekmode); |
62 |
|
63 |
if(seekto > status->totalTime) |
64 |
DIE("seek amount would seek past the end of the song\n"); |