Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
630d33b2
Commit
630d33b2
authored
Jun 04, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish ack error codes
git-svn-id:
https://svn.musicpd.org/mpd/trunk@1325
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
f958e0a4
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
121 additions
and
80 deletions
+121
-80
TODO
TODO
+1
-3
command.c
src/command.c
+38
-21
command.h
src/command.h
+8
-5
directory.c
src/directory.c
+17
-17
directory.h
src/directory.h
+1
-1
interface.c
src/interface.c
+1
-0
main.c
src/main.c
+1
-1
player.c
src/player.c
+2
-1
playlist.c
src/playlist.c
+40
-22
tables.c
src/tables.c
+5
-3
volume.c
src/volume.c
+7
-6
No files found.
TODO
View file @
630d33b2
1) put some sort of error reporting for streaming/inputStream!
2) ACK error codes
3) Fix charset errors so they don't goto stderr/out
2) Fix charset errors so they don't goto stderr/out
Post-1.0
...
...
src/command.c
View file @
630d33b2
...
...
@@ -154,7 +154,8 @@ int handlePlay(FILE * fp, unsigned int * permission, int argArrayLength,
if
(
argArrayLength
==
2
)
{
song
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"need a positive integer"
);
commandError
(
fp
,
ACK_ERROR_ARG
,
"need a positive integer"
);
return
-
1
;
}
}
...
...
@@ -174,7 +175,7 @@ int handlePause(FILE * fp, unsigned int * permission,
char
*
test
;
int
pause
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
||
(
pause
!=
0
&&
pause
!=
1
))
{
commandError
(
fp
,
"\%s
\"
is not 0 or 1"
,
argArray
[
1
]);
commandError
(
fp
,
ACK_ERROR_ARG
,
"\%s
\"
is not 0 or 1"
,
argArray
[
1
]);
return
-
1
;
}
return
playerSetPause
(
fp
,
pause
);
...
...
@@ -265,7 +266,8 @@ int handleDelete(FILE * fp, unsigned int * permission, int argArrayLength,
song
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"need a positive integer"
);
commandError
(
fp
,
ACK_ERROR_ARG
,
"need a positive integer"
);
return
-
1
;
}
return
deleteFromPlaylist
(
fp
,
song
);
...
...
@@ -329,7 +331,8 @@ int handlePlaylistInfo(FILE * fp, unsigned int * permission,
if
(
argArrayLength
==
2
)
{
song
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"%s need a positive integer"
);
commandError
(
fp
,
ACK_ERROR_ARG
,
"%s need a positive integer"
);
return
-
1
;
}
}
...
...
@@ -418,7 +421,7 @@ int handleVolume(FILE * fp, unsigned int * permission, int argArrayLength,
change
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"need an integer"
);
commandError
(
fp
,
ACK_ERROR_ARG
,
"need an integer"
);
return
-
1
;
}
return
changeVolumeLevel
(
fp
,
change
,
1
);
...
...
@@ -432,7 +435,7 @@ int handleSetVol(FILE * fp, unsigned int * permission, int argArrayLength,
level
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"need an integer"
);
commandError
(
fp
,
ACK_ERROR_ARG
,
"need an integer"
);
return
-
1
;
}
return
changeVolumeLevel
(
fp
,
level
,
0
);
...
...
@@ -446,7 +449,7 @@ int handleRepeat(FILE * fp, unsigned int * permission, int argArrayLength,
status
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"need an integer"
);
commandError
(
fp
,
ACK_ERROR_ARG
,
"need an integer"
);
return
-
1
;
}
return
setPlaylistRepeatStatus
(
fp
,
status
);
...
...
@@ -460,7 +463,7 @@ int handleRandom(FILE * fp, unsigned int * permission, int argArrayLength,
status
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"need an integer"
);
commandError
(
fp
,
ACK_ERROR_ARG
,
"need an integer"
);
return
-
1
;
}
return
setPlaylistRandomStatus
(
fp
,
status
);
...
...
@@ -497,12 +500,14 @@ int handleMove(FILE * fp, unsigned int * permission, int argArrayLength,
from
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"
\"
%s
\"
is not a integer"
,
argArray
[
1
]);
commandError
(
fp
,
ACK_ERROR_ARG
,
"
\"
%s
\"
is not a integer"
,
argArray
[
1
]);
return
-
1
;
}
to
=
strtol
(
argArray
[
2
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"
\"
%s
\"
is not a integer"
,
argArray
[
2
]);
commandError
(
fp
,
ACK_ERROR_ARG
,
"
\"
%s
\"
is not a integer"
,
argArray
[
2
]);
return
-
1
;
}
return
moveSongInPlaylist
(
fp
,
from
,
to
);
...
...
@@ -517,12 +522,14 @@ int handleSwap(FILE * fp, unsigned int * permission, int argArrayLength,
song1
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"
\"
%s
\"
is not a integer"
,
argArray
[
1
]);
commandError
(
fp
,
ACK_ERROR_ARG
,
"
\"
%s
\"
is not a integer"
,
argArray
[
1
]);
return
-
1
;
}
song2
=
strtol
(
argArray
[
2
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"
\"
%s
\"
is not a integer"
,
argArray
[
2
]);
commandError
(
fp
,
ACK_ERROR_ARG
,
"
\"
%s
\"
is not a integer"
,
argArray
[
2
]);
return
-
1
;
}
return
swapSongsInPlaylist
(
fp
,
song1
,
song2
);
...
...
@@ -537,12 +544,14 @@ int handleSeek(FILE * fp, unsigned int * permission, int argArrayLength,
song
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"
\"
%s
\"
is not a integer"
,
argArray
[
1
]);
commandError
(
fp
,
ACK_ERROR_ARG
,
"
\"
%s
\"
is not a integer"
,
argArray
[
1
]);
return
-
1
;
}
time
=
strtol
(
argArray
[
2
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
"
\"
%s
\"
is not a integer"
,
argArray
[
2
]);
commandError
(
fp
,
ACK_ERROR_ARG
,
"
\"
%s
\"
is not a integer"
,
argArray
[
2
]);
return
-
1
;
}
return
seekSongInPlaylist
(
fp
,
song
,
time
);
...
...
@@ -567,7 +576,7 @@ int handlePassword(FILE * fp, unsigned int * permission, int argArrayLength,
char
**
argArray
)
{
if
(
getPermissionFromPassword
(
argArray
[
1
],
permission
)
<
0
)
{
commandError
(
fp
,
"incorrect password"
);
commandError
(
fp
,
ACK_ERROR_PASSWORD
,
"incorrect password"
);
return
-
1
;
}
...
...
@@ -582,7 +591,8 @@ int handleCrossfade(FILE * fp, unsigned int * permission, int argArrayLength,
time
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
||
time
<
0
)
{
commandError
(
fp
,
"
\"
%s
\"
is not a integer >= 0"
,
argArray
[
1
]);
commandError
(
fp
,
ACK_ERROR_ARG
,
"
\"
%s
\"
is not a integer >= 0"
,
argArray
[
1
]);
return
-
1
;
}
...
...
@@ -647,7 +657,8 @@ int checkArgcAndPermission(CommandEntry * cmd, FILE *fp,
if
(
cmd
->
reqPermission
!=
(
permission
&
cmd
->
reqPermission
))
{
if
(
fp
)
{
commandError
(
fp
,
"you don't have permission for
\"
%s
\"
"
,
commandError
(
fp
,
ACK_ERROR_PERMISSION
,
"you don't have permission for
\"
%s
\"
"
,
cmd
->
cmd
);
}
return
-
1
;
...
...
@@ -657,21 +668,24 @@ int checkArgcAndPermission(CommandEntry * cmd, FILE *fp,
if
(
min
==
max
&&
max
!=
argc
)
{
if
(
fp
)
{
commandError
(
fp
,
"wrong number of arguments for
\"
%s
\"
"
,
commandError
(
fp
,
ACK_ERROR_ARG
,
"wrong number of arguments for
\"
%s
\"
"
,
argArray
[
0
]);
}
return
-
1
;
}
else
if
(
argc
<
min
)
{
if
(
fp
)
{
commandError
(
fp
,
"too few arguments for
\"
%s
\"
"
,
commandError
(
fp
,
ACK_ERROR_ARG
,
"too few arguments for
\"
%s
\"
"
,
argArray
[
0
]);
}
return
-
1
;
}
else
if
(
argc
>
max
&&
max
/* != 0 */
)
{
if
(
fp
)
{
commandError
(
fp
,
"too many arguments for
\"
%s
\"
"
,
commandError
(
fp
,
ACK_ERROR_ARG
,
"too many arguments for
\"
%s
\"
"
,
argArray
[
0
]);
}
return
-
1
;
...
...
@@ -690,7 +704,10 @@ CommandEntry * getCommandEntryAndCheckArgcAndPermission(FILE * fp,
if
(
argArrayLength
==
0
)
return
NULL
;
if
(
!
findInList
(
commandList
,
argArray
[
0
],(
void
*
)
&
cmd
))
{
if
(
fp
)
commandError
(
fp
,
"unknown command
\"
%s
\"
"
,
argArray
[
0
]);
if
(
fp
)
{
commandError
(
fp
,
ACK_ERROR_UNKNOWN
,
"unknown command
\"
%s
\"
"
,
argArray
[
0
]);
}
return
NULL
;
}
...
...
src/command.h
View file @
630d33b2
...
...
@@ -23,6 +23,8 @@
#include "list.h"
#include "myfprintf.h"
#include "log.h"
#include "ack.h"
#include <stdio.h>
...
...
@@ -43,17 +45,18 @@ void finishCommands();
#define commandSuccess(fp) myfprintf(fp, "OK\n")
#define commandError(fp, format, ... ) \
#define commandError(fp,
error,
format, ... ) \
{\
if(current_command) { \
myfprintf(fp, "ACK [%s:%i] " format "\n", \
myfprintf(fp, "ACK [%s:%i
:%i
] " format "\n", \
current_command, command_listNum, \
##__VA_ARGS__); \
(int)error,
##__VA_ARGS__); \
current_command = NULL; \
} \
else { \
myfprintf(fp, "ACK [:%i] " format "\n", \
command_listNum, ##__VA_ARGS__); \
myfprintf(fp, "ACK [:%i:%i] " format "\n", \
command_listNum, (int)error, \
##__VA_ARGS__); \
} \
}
...
...
src/directory.c
View file @
630d33b2
...
...
@@ -166,7 +166,7 @@ void readDirectoryDBIfUpdateIsFinished() {
int
updateInit
(
FILE
*
fp
,
List
*
pathList
)
{
if
(
directory_updatePid
>
0
)
{
commandError
(
fp
,
"already updating"
);
commandError
(
fp
,
ACK_ERROR_UPDATE_ALREADY
,
"already updating"
);
return
-
1
;
}
...
...
@@ -223,7 +223,8 @@ int updateInit(FILE * fp, List * pathList) {
else
if
(
directory_updatePid
<
0
)
{
unblockSignals
();
ERROR
(
"updateInit: Problems forking()'ing
\n
"
);
commandError
(
fp
,
"problems trying to update"
);
commandError
(
fp
,
ACK_ERROR_SYSTEM
,
"problems trying to update"
);
directory_updatePid
=
0
;
return
-
1
;
}
...
...
@@ -744,7 +745,7 @@ int printDirectoryInfo(FILE * fp, char * name) {
Directory
*
directory
;
if
((
directory
=
getDirectory
(
name
))
==
NULL
)
{
commandError
(
fp
,
"directory not found"
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"directory not found"
);
return
-
1
;
}
...
...
@@ -977,27 +978,25 @@ int readDirectoryDB() {
return
0
;
}
int
updateMp3Directory
(
FILE
*
fp
)
{
void
updateMp3Directory
(
)
{
switch
(
updateDirectory
(
mp3rootDirectory
))
{
case
0
:
/* nothing updated */
return
0
;
return
;
case
1
:
if
(
writeDirectoryDB
()
<
0
)
{
ERROR
(
"problems writing music db file,
\"
%s
\"\n
"
,
directory_db
);
exit
(
EXIT_FAILURE
);
}
/* something was updated and db should be written */
break
;
default:
ERROR
(
"problems updating music db
\n
"
);
commandError
(
fp
,
"problems updating music db"
);
return
-
1
;
exit
(
EXIT_FAILURE
);
}
if
(
writeDirectoryDB
()
<
0
)
{
ERROR
(
"problems writing music db file,
\"
%s
\"\n
"
,
directory_db
);
commandError
(
fp
,
"problems writing music db"
);
return
-
1
;
}
return
0
;
return
;
}
int
traverseAllInSubDirectory
(
FILE
*
fp
,
Directory
*
directory
,
...
...
@@ -1047,7 +1046,8 @@ int traverseAllIn(FILE * fp, char * name,
if
((
song
=
getSongFromDB
(
name
))
&&
forEachSong
)
{
return
forEachSong
(
fp
,
song
,
data
);
}
commandError
(
fp
,
"directory or file not found"
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"directory or file not found"
);
return
-
1
;
}
...
...
@@ -1129,7 +1129,7 @@ int searchForSongsIn(FILE * fp, char * name, char * item, char * string) {
ret
=
traverseAllIn
(
fp
,
name
,
searchForFilenameInDirectory
,
NULL
,
(
void
*
)
dup
);
}
else
commandError
(
fp
,
"unknown table"
);
else
commandError
(
fp
,
ACK_ERROR_ARG
,
"unknown table"
);
free
(
dup
);
...
...
@@ -1166,7 +1166,7 @@ int findSongsIn(FILE * fp, char * name, char * item, char * string) {
(
void
*
)
string
);
}
commandError
(
fp
,
"unknown table"
);
commandError
(
fp
,
ACK_ERROR_ARG
,
"unknown table"
);
return
-
1
;
}
...
...
src/directory.h
View file @
630d33b2
...
...
@@ -49,7 +49,7 @@ int writeDirectoryDB();
int
readDirectoryDB
();
int
updateMp3Directory
(
FILE
*
fp
);
void
updateMp3Directory
(
);
int
printAllIn
(
FILE
*
fp
,
char
*
name
);
...
...
src/interface.c
View file @
630d33b2
...
...
@@ -289,6 +289,7 @@ int interfaceReadInput(Interface * interface) {
==
0
)
{
commandError
(
interface
->
fp
,
ACK_ERROR_NOT_LIST
,
"not in command list mode"
);
ret
=
-
1
;
}
...
...
src/main.c
View file @
630d33b2
...
...
@@ -324,7 +324,7 @@ void openDB(Options * options, char * argv0) {
if
(
options
->
createDB
)
exit
(
EXIT_SUCCESS
);
}
if
(
options
->
updateDB
)
{
if
(
updateMp3Directory
(
stderr
)
<
0
)
exit
(
EXIT_FAILURE
);
updateMp3Directory
(
);
exit
(
EXIT_SUCCESS
);
}
}
...
...
src/player.c
View file @
630d33b2
...
...
@@ -386,7 +386,8 @@ int playerSeek(FILE * fp, Song * song, float time) {
PlayerControl
*
pc
=
&
(
getPlayerData
()
->
playerControl
);
if
(
pc
->
state
==
PLAYER_STATE_STOP
)
{
commandError
(
fp
,
"player not currently playing"
);
commandError
(
fp
,
ACK_ERROR_PLAYER_SYNC
,
"player not currently playing"
);
return
-
1
;
}
...
...
src/playlist.c
View file @
630d33b2
...
...
@@ -375,7 +375,8 @@ int playlistInfo(FILE * fp,int song) {
end
=
song
+
1
;
}
if
(
song
>=
playlist
.
length
)
{
commandError
(
fp
,
"song doesn't exist:
\"
%i
\"
"
,
song
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"song doesn't exist:
\"
%i
\"
"
,
song
);
return
-
1
;
}
...
...
@@ -486,7 +487,8 @@ int addToPlaylist(FILE * fp, char * url) {
{
}
else
{
commandError
(
fp
,
"
\"
%s
\"
is not in the music db or is"
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"
\"
%s
\"
is not in the music db or is"
"not a valid url
\n
"
,
url
);
return
-
1
;
}
...
...
@@ -496,7 +498,8 @@ int addToPlaylist(FILE * fp, char * url) {
int
addSongToPlaylist
(
FILE
*
fp
,
Song
*
song
)
{
if
(
playlist
.
length
==
playlist_max_length
)
{
commandError
(
fp
,
"playlist is at the max size"
);
commandError
(
fp
,
ACK_ERROR_PLAYLIST_MAX
,
"playlist is at the max size"
);
return
-
1
;
}
...
...
@@ -535,11 +538,13 @@ int swapSongsInPlaylist(FILE * fp, int song1, int song2) {
int
currentSong
=
-
1
;
if
(
song1
<
0
||
song1
>=
playlist
.
length
)
{
commandError
(
fp
,
"song doesn't exist:
\"
%i
\"
"
,
song1
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"song doesn't exist:
\"
%i
\"
"
,
song1
);
return
-
1
;
}
if
(
song2
<
0
||
song2
>=
playlist
.
length
)
{
commandError
(
fp
,
"song doesn't exist:
\"
%i
\"
"
,
song2
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"song doesn't exist:
\"
%i
\"
"
,
song2
);
return
-
1
;
}
...
...
@@ -586,7 +591,8 @@ int deleteFromPlaylist(FILE * fp, int song) {
int
songOrder
;
if
(
song
<
0
||
song
>=
playlist
.
length
)
{
commandError
(
fp
,
"song doesn't exist:
\"
%i
\"
"
,
song
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"song doesn't exist:
\"
%i
\"
"
,
song
);
return
-
1
;
}
...
...
@@ -710,7 +716,8 @@ int playPlaylist(FILE * fp, int song, int stopOnError) {
}
}
else
if
(
song
<
0
||
song
>=
playlist
.
length
)
{
commandError
(
fp
,
"song doesn't exist:
\"
%i
\"
"
,
song
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"song doesn't exist:
\"
%i
\"
"
,
song
);
playlist_state
=
PLAYLIST_STATE_STOP
;
return
-
1
;
}
...
...
@@ -831,7 +838,7 @@ int getPlaylistRandomStatus() {
int
setPlaylistRepeatStatus
(
FILE
*
fp
,
int
status
)
{
if
(
status
!=
0
&&
status
!=
1
)
{
commandError
(
fp
,
"
\"
%i
\"
is not 0 or 1"
,
status
);
commandError
(
fp
,
ACK_ERROR_ARG
,
"
\"
%i
\"
is not 0 or 1"
,
status
);
return
-
1
;
}
...
...
@@ -855,12 +862,14 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
int
currentSong
=
-
1
;
if
(
from
<
0
||
from
>=
playlist
.
length
)
{
commandError
(
fp
,
"song doesn't exist:
\"
%i
\"
"
,
from
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"song doesn't exist:
\"
%i
\"
"
,
from
);
return
-
1
;
}
if
(
to
<
0
||
to
>=
playlist
.
length
)
{
commandError
(
fp
,
"song doesn't exist:
\"
%i
\"
"
,
to
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"song doesn't exist:
\"
%i
\"
"
,
to
);
return
-
1
;
}
...
...
@@ -966,7 +975,7 @@ int setPlaylistRandomStatus(FILE * fp, int status) {
int
statusWas
=
playlist
.
random
;
if
(
status
!=
0
&&
status
!=
1
)
{
commandError
(
fp
,
"
\"
%i
\"
is not 0 or 1"
,
status
);
commandError
(
fp
,
ACK_ERROR_ARG
,
"
\"
%i
\"
is not 0 or 1"
,
status
);
return
-
1
;
}
...
...
@@ -1060,12 +1069,14 @@ int deletePlaylist(FILE * fp, char * utf8file) {
if
((
actualFile
=
rpp2app
(
rfile
))
&&
isPlaylist
(
actualFile
))
free
(
rfile
);
else
{
free
(
rfile
);
commandError
(
fp
,
"playlist
\"
%s
\"
not found"
,
utf8file
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"playlist
\"
%s
\"
not found"
,
utf8file
);
return
-
1
;
}
if
(
unlink
(
actualFile
)
<
0
)
{
commandError
(
fp
,
"problems deleting file"
);
commandError
(
fp
,
ACK_ERROR_SYSTEM
,
"problems deleting file"
);
return
-
1
;
}
...
...
@@ -1081,7 +1092,8 @@ int savePlaylist(FILE * fp, char * utf8file) {
char
*
actualFile
;
if
(
strstr
(
utf8file
,
"/"
))
{
commandError
(
fp
,
"cannot save
\"
%s
\"
, saving playlists to "
commandError
(
fp
,
ACK_ERROR_ARG
,
"cannot save
\"
%s
\"
, saving playlists to "
"subdirectories is not supported"
,
utf8file
);
return
-
1
;
}
...
...
@@ -1109,7 +1121,7 @@ int savePlaylist(FILE * fp, char * utf8file) {
while
(
!
(
fileP
=
fopen
(
actualFile
,
"w"
))
&&
errno
==
EINTR
);
if
(
fileP
==
NULL
)
{
commandError
(
fp
,
"problems opening file"
);
commandError
(
fp
,
ACK_ERROR_SYSTEM
,
"problems opening file"
);
return
-
1
;
}
...
...
@@ -1151,13 +1163,15 @@ int loadPlaylist(FILE * fp, char * utf8file) {
if
((
actualFile
=
rpp2app
(
rfile
))
&&
isPlaylist
(
actualFile
))
free
(
rfile
);
else
{
free
(
rfile
);
commandError
(
fp
,
"playlist
\"
%s
\"
not found"
,
utf8file
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"playlist
\"
%s
\"
not found"
,
utf8file
);
return
-
1
;
}
while
(
!
(
fileP
=
fopen
(
actualFile
,
"r"
))
&&
errno
==
EINTR
);
if
(
fileP
==
NULL
)
{
commandError
(
fp
,
"problems opening file
\"
%s
\"
"
,
utf8file
);
commandError
(
fp
,
ACK_ERROR_SYSTEM
,
"problems opening file
\"
%s
\"
"
,
utf8file
);
return
-
1
;
}
...
...
@@ -1175,7 +1189,9 @@ int loadPlaylist(FILE * fp, char * utf8file) {
strncat
(
s
,
"/"
,
MAXPATHLEN
-
parentlen
);
strncat
(
s
,
temp
,
MAXPATHLEN
-
parentlen
-
1
);
if
(
strlen
(
s
)
>=
MAXPATHLEN
)
{
commandError
(
fp
,
"
\"
%s
\"
too long"
,
commandError
(
fp
,
ACK_ERROR_PLAYLIST_LOAD
,
"
\"
%s
\"
too long"
,
temp
);
free
(
temp
);
while
(
fclose
(
fileP
)
&&
errno
==
EINTR
);
...
...
@@ -1201,7 +1217,8 @@ int loadPlaylist(FILE * fp, char * utf8file) {
}
else
if
(
slength
==
MAXPATHLEN
)
{
s
[
slength
]
=
'\0'
;
commandError
(
fp
,
"
\"
%s
\"
too long"
,
s
);
commandError
(
fp
,
ACK_ERROR_PLAYLIST_LOAD
,
"
\"
%s
\"
too long"
,
s
);
while
(
fclose
(
fileP
)
&&
errno
==
EINTR
);
if
(
erroredFile
)
free
(
erroredFile
);
return
-
1
;
...
...
@@ -1212,7 +1229,8 @@ int loadPlaylist(FILE * fp, char * utf8file) {
while
(
fclose
(
fileP
)
&&
errno
==
EINTR
);
if
(
erroredFile
)
{
commandError
(
fp
,
"can't add file
\"
%s
\"
"
,
erroredFile
);
commandError
(
fp
,
ACK_ERROR_PLAYLIST_LOAD
,
"can't add file
\"
%s
\"
"
,
erroredFile
);
free
(
erroredFile
);
return
-
1
;
}
...
...
@@ -1240,7 +1258,8 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
int
i
=
song
;
if
(
song
<
0
||
song
>=
playlist
.
length
)
{
commandError
(
fp
,
"song doesn't exist:
\"
%i
\"
"
,
song
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"song doesn't exist:
\"
%i
\"
"
,
song
);
return
-
1
;
}
...
...
@@ -1265,4 +1284,3 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
return
playerSeek
(
fp
,
playlist
.
songs
[
playlist
.
order
[
i
]],
time
);
}
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
src/tables.c
View file @
630d33b2
...
...
@@ -172,7 +172,8 @@ int printAllAlbums(FILE * fp, char * artist) {
}
}
else
{
commandError
(
fp
,
"artist
\"
%s
\"
not found"
,
artist
);
commandError
(
fp
,
ACK_ERROR_NO_EXIST
,
"artist
\"
%s
\"
not found"
,
artist
);
return
-
1
;
}
}
...
...
@@ -183,7 +184,8 @@ int printAllAlbums(FILE * fp, char * artist) {
int
printAllKeysOfTable
(
FILE
*
fp
,
char
*
table
,
char
*
arg1
)
{
if
(
strcmp
(
table
,
TABLES_ARTIST
)
==
0
)
{
if
(
arg1
!=
NULL
)
{
commandError
(
fp
,
"%s table takes no args"
,
table
);
commandError
(
fp
,
ACK_ERROR_ARG
,
"%s table takes no args"
,
table
);
return
-
1
;
}
return
printAllArtists
(
fp
);
...
...
@@ -192,7 +194,7 @@ int printAllKeysOfTable(FILE * fp, char * table, char * arg1) {
return
printAllAlbums
(
fp
,
arg1
);
}
else
{
commandError
(
fp
,
"table
\"
%s
\"
does not exist
"
,
table
);
commandError
(
fp
,
ACK_ERROR_ARG
,
"unknown table
"
,
table
);
return
-
1
;
}
}
src/volume.c
View file @
630d33b2
...
...
@@ -144,7 +144,8 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
if
(
rel
)
{
if
((
current
=
getOssVolumeLevel
())
<
0
)
{
commandError
(
fp
,
"problem getting current volume"
);
commandError
(
fp
,
ACK_ERROR_SYSTEM
,
"problem getting current volume"
);
return
-
1
;
}
...
...
@@ -158,7 +159,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
level
=
(
new
<<
8
)
+
new
;
if
(
ioctl
(
volume_ossFd
,
MIXER_WRITE
(
volume_ossControl
),
&
level
)
<
0
)
{
commandError
(
fp
,
"problems setting volume"
);
commandError
(
fp
,
ACK_ERROR_SYSTEM
,
"problems setting volume"
);
return
-
1
;
}
...
...
@@ -270,7 +271,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
if
((
err
=
snd_mixer_selem_get_playback_volume
(
volume_alsaElem
,
SND_MIXER_SCHN_FRONT_LEFT
,
&
level
))
<
0
)
{
commandError
(
fp
,
"problems getting volume"
);
commandError
(
fp
,
ACK_ERROR_SYSTEM
,
"problems getting volume"
);
ERROR
(
"problems getting alsa volume: %s
\n
"
,
snd_strerror
(
err
));
return
-
1
;
}
...
...
@@ -296,7 +297,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
if
((
err
=
snd_mixer_selem_set_playback_volume_all
(
volume_alsaElem
,
level
))
<
0
)
{
commandError
(
fp
,
"problems setting volume"
);
commandError
(
fp
,
ACK_ERROR_SYSTEM
,
"problems setting volume"
);
ERROR
(
"problems setting alsa volume: %s
\n
"
,
snd_strerror
(
err
));
return
-
1
;
}
...
...
@@ -423,8 +424,8 @@ int changeVolumeLevel(FILE * fp, int change, int rel) {
case
VOLUME_MIXER_TYPE_SOFTWARE
:
return
changeSoftwareVolume
(
fp
,
change
,
rel
);
default:
commandError
(
fp
,
"no volume support"
)
;
return
-
1
;
return
0
;
break
;
}
}
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment