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
f4d959a0
Commit
f4d959a0
authored
May 26, 2007
by
J. Alexander Treuman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More formatting/error message cleanups in storedPlaylist.c.
git-svn-id:
https://svn.musicpd.org/mpd/trunk@6265
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
fd645486
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
46 deletions
+14
-46
storedPlaylist.c
src/storedPlaylist.c
+14
-46
No files found.
src/storedPlaylist.c
View file @
f4d959a0
...
@@ -34,15 +34,9 @@ static char *utf8pathToFsPathInStoredPlaylist(const char *utf8path, int fd)
...
@@ -34,15 +34,9 @@ static char *utf8pathToFsPathInStoredPlaylist(const char *utf8path, int fd)
char
*
actualFile
;
char
*
actualFile
;
if
(
strstr
(
utf8path
,
"/"
))
{
if
(
strstr
(
utf8path
,
"/"
))
{
if
(
fd
!=
-
1
)
{
commandError
(
fd
,
ACK_ERROR_ARG
,
"playlist name
\"
%s
\"
is "
commandError
(
fd
,
ACK_ERROR_ARG
,
"playlist name
\"
%s
\"
"
"invalid: playlist names may not contain slashes"
,
"is invalid: playlist names may not "
utf8path
);
"contain slashes"
,
utf8path
);
}
ERROR
(
"playlist name
\"
%s
\"
is invalid: playlist names may not "
"contain slashes
\n
"
,
utf8path
);
return
NULL
;
return
NULL
;
}
}
...
@@ -118,7 +112,6 @@ StoredPlaylist *newStoredPlaylist(const char *utf8name, int fd, int ignoreExisti
...
@@ -118,7 +112,6 @@ StoredPlaylist *newStoredPlaylist(const char *utf8name, int fd, int ignoreExisti
commandError
(
fd
,
ACK_ERROR_EXIST
,
commandError
(
fd
,
ACK_ERROR_EXIST
,
"a file or directory already exists with "
"a file or directory already exists with "
"the name
\"
%s
\"
"
,
utf8name
);
"the name
\"
%s
\"
"
,
utf8name
);
free
(
sp
);
free
(
sp
);
return
NULL
;
return
NULL
;
}
}
...
@@ -152,31 +145,22 @@ StoredPlaylist *loadStoredPlaylist(const char *utf8path, int fd)
...
@@ -152,31 +145,22 @@ StoredPlaylist *loadStoredPlaylist(const char *utf8path, int fd)
while
(
!
(
file
=
fopen
(
filename
,
"r"
))
&&
errno
==
EINTR
);
while
(
!
(
file
=
fopen
(
filename
,
"r"
))
&&
errno
==
EINTR
);
if
(
file
==
NULL
)
{
if
(
file
==
NULL
)
{
if
(
fd
!=
-
1
)
{
commandError
(
fd
,
ACK_ERROR_NO_EXIST
,
"could not open file "
commandError
(
fd
,
ACK_ERROR_NO_EXIST
,
"
\"
%s
\"
: %s"
,
filename
,
strerror
(
errno
));
"could not open file
\"
%s
\"
: %s"
,
filename
,
strerror
(
errno
));
}
ERROR
(
"could not open file
\"
%s
\"
: %s
\n
"
,
filename
,
strerror
(
errno
));
return
NULL
;
return
NULL
;
}
}
sp
=
newStoredPlaylist
(
utf8path
,
fd
,
1
);
sp
=
newStoredPlaylist
(
utf8path
,
fd
,
1
);
if
(
!
sp
)
{
if
(
!
sp
)
goto
out
;
goto
out
;
}
while
((
tempInt
=
fgetc
(
file
))
!=
EOF
)
{
while
((
tempInt
=
fgetc
(
file
))
!=
EOF
)
{
s
[
slength
]
=
tempInt
;
s
[
slength
]
=
tempInt
;
if
(
s
[
slength
]
==
'\n'
||
s
[
slength
]
==
'\0'
)
{
if
(
s
[
slength
]
==
'\n'
||
s
[
slength
]
==
'\0'
)
{
commentCharFound
=
0
;
commentCharFound
=
0
;
s
[
slength
]
=
'\0'
;
s
[
slength
]
=
'\0'
;
if
(
s
[
0
]
==
PLAYLIST_COMMENT
)
{
if
(
s
[
0
]
==
PLAYLIST_COMMENT
)
commentCharFound
=
1
;
commentCharFound
=
1
;
}
if
(
strncmp
(
s
,
musicDir
,
strlen
(
musicDir
))
==
0
)
{
if
(
strncmp
(
s
,
musicDir
,
strlen
(
musicDir
))
==
0
)
{
strcpy
(
s
,
&
(
s
[
strlen
(
musicDir
)]));
strcpy
(
s
,
&
(
s
[
strlen
(
musicDir
)]));
}
else
if
(
parentlen
)
{
}
else
if
(
parentlen
)
{
...
@@ -186,12 +170,9 @@ StoredPlaylist *loadStoredPlaylist(const char *utf8path, int fd)
...
@@ -186,12 +170,9 @@ StoredPlaylist *loadStoredPlaylist(const char *utf8path, int fd)
strncat
(
s
,
"/"
,
MAXPATHLEN
-
parentlen
);
strncat
(
s
,
"/"
,
MAXPATHLEN
-
parentlen
);
strncat
(
s
,
temp
,
MAXPATHLEN
-
parentlen
-
1
);
strncat
(
s
,
temp
,
MAXPATHLEN
-
parentlen
-
1
);
if
(
strlen
(
s
)
>=
MAXPATHLEN
)
{
if
(
strlen
(
s
)
>=
MAXPATHLEN
)
{
if
(
sp
->
fd
!=
-
1
)
{
commandError
(
sp
->
fd
,
commandError
(
sp
->
fd
,
ACK_ERROR_PLAYLIST_LOAD
,
ACK_ERROR_PLAYLIST_LOAD
,
"
\"
%s
\"
is too long"
,
temp
);
"
\"
%s
\"
is too long"
,
temp
);
}
ERROR
(
"
\"
%s
\"
is too long
\n
"
,
temp
);
free
(
temp
);
free
(
temp
);
freeStoredPlaylist
(
sp
);
freeStoredPlaylist
(
sp
);
sp
=
NULL
;
sp
=
NULL
;
...
@@ -203,24 +184,20 @@ StoredPlaylist *loadStoredPlaylist(const char *utf8path, int fd)
...
@@ -203,24 +184,20 @@ StoredPlaylist *loadStoredPlaylist(const char *utf8path, int fd)
temp
=
fsCharsetToUtf8
(
s
);
temp
=
fsCharsetToUtf8
(
s
);
if
(
!
temp
)
if
(
!
temp
)
continue
;
continue
;
if
(
!
commentCharFound
)
{
if
(
!
commentCharFound
)
insertInListWithoutKey
(
sp
->
list
,
strdup
(
s
));
insertInListWithoutKey
(
sp
->
list
,
strdup
(
s
));
}
}
else
if
(
slength
==
MAXPATHLEN
)
{
}
else
if
(
slength
==
MAXPATHLEN
)
{
s
[
slength
]
=
'\0'
;
s
[
slength
]
=
'\0'
;
if
(
sp
->
fd
!=
-
1
)
{
commandError
(
sp
->
fd
,
ACK_ERROR_PLAYLIST_LOAD
,
commandError
(
sp
->
fd
,
ACK_ERROR_PLAYLIST_LOAD
,
"line
\"
%s
\"
in playlist
\"
%s
\"
"
"line
\"
%s
\"
in playlist
\"
%s
\"
"
"is too long"
,
s
,
utf8path
);
"is too long"
,
s
,
utf8path
);
}
ERROR
(
"line
\"
%s
\"
in playlist
\"
%s
\"
is too long
\n
"
,
s
,
utf8path
);
freeStoredPlaylist
(
sp
);
freeStoredPlaylist
(
sp
);
sp
=
NULL
;
sp
=
NULL
;
goto
out
;
goto
out
;
}
else
if
(
s
[
slength
]
!=
'\r'
)
}
else
if
(
s
[
slength
]
!=
'\r'
)
{
slength
++
;
slength
++
;
}
}
}
out:
out:
while
(
fclose
(
file
)
&&
errno
==
EINTR
);
while
(
fclose
(
file
)
&&
errno
==
EINTR
);
...
@@ -396,14 +373,8 @@ static int writeStoredPlaylistToPath(StoredPlaylist *sp, const char *fspath)
...
@@ -396,14 +373,8 @@ static int writeStoredPlaylistToPath(StoredPlaylist *sp, const char *fspath)
while
(
!
(
file
=
fopen
(
fspath
,
"w"
))
&&
errno
==
EINTR
);
while
(
!
(
file
=
fopen
(
fspath
,
"w"
))
&&
errno
==
EINTR
);
if
(
file
==
NULL
)
{
if
(
file
==
NULL
)
{
if
(
sp
->
fd
!=
-
1
)
{
commandError
(
sp
->
fd
,
ACK_ERROR_NO_EXIST
,
"could not open file "
commandError
(
sp
->
fd
,
ACK_ERROR_NO_EXIST
,
"
\"
%s
\"
: %s"
,
fspath
,
strerror
(
errno
));
"could not open file
\"
%s
\"
: %s"
,
fspath
,
strerror
(
errno
));
}
ERROR
(
"could not open file
\"
%s
\"
: %s
\n
"
,
fspath
,
strerror
(
errno
));
return
-
1
;
return
-
1
;
}
}
...
@@ -486,7 +457,6 @@ int renameStoredPlaylist(int fd, const char *utf8from, const char *utf8to)
...
@@ -486,7 +457,6 @@ int renameStoredPlaylist(int fd, const char *utf8from, const char *utf8to)
if
(
stat
(
from
,
&
st
)
!=
0
)
{
if
(
stat
(
from
,
&
st
)
!=
0
)
{
commandError
(
fd
,
ACK_ERROR_NO_EXIST
,
commandError
(
fd
,
ACK_ERROR_NO_EXIST
,
"no playlist named
\"
%s
\"
"
,
utf8from
);
"no playlist named
\"
%s
\"
"
,
utf8from
);
ret
=
-
1
;
ret
=
-
1
;
goto
out
;
goto
out
;
}
}
...
@@ -494,7 +464,6 @@ int renameStoredPlaylist(int fd, const char *utf8from, const char *utf8to)
...
@@ -494,7 +464,6 @@ int renameStoredPlaylist(int fd, const char *utf8from, const char *utf8to)
if
(
stat
(
to
,
&
st
)
==
0
)
{
if
(
stat
(
to
,
&
st
)
==
0
)
{
commandError
(
fd
,
ACK_ERROR_EXIST
,
"a file or directory "
commandError
(
fd
,
ACK_ERROR_EXIST
,
"a file or directory "
"already exists with the name
\"
%s
\"
"
,
utf8to
);
"already exists with the name
\"
%s
\"
"
,
utf8to
);
ret
=
-
1
;
ret
=
-
1
;
goto
out
;
goto
out
;
}
}
...
@@ -503,7 +472,6 @@ int renameStoredPlaylist(int fd, const char *utf8from, const char *utf8to)
...
@@ -503,7 +472,6 @@ int renameStoredPlaylist(int fd, const char *utf8from, const char *utf8to)
commandError
(
fd
,
ACK_ERROR_UNKNOWN
,
commandError
(
fd
,
ACK_ERROR_UNKNOWN
,
"could not rename playlist
\"
%s
\"
to
\"
%s
\"
: %s"
,
"could not rename playlist
\"
%s
\"
to
\"
%s
\"
: %s"
,
utf8from
,
utf8to
,
strerror
(
errno
));
utf8from
,
utf8to
,
strerror
(
errno
));
ret
=
-
1
;
ret
=
-
1
;
goto
out
;
goto
out
;
}
}
...
...
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