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
5dc4c325
Commit
5dc4c325
authored
Oct 09, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
database: simplify db_load()
Removed a superfluous closure.
parent
5583b6c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
47 deletions
+42
-47
database.c
src/database.c
+42
-47
No files found.
src/database.c
View file @
5dc4c325
...
...
@@ -238,6 +238,10 @@ db_load(void)
FILE
*
fp
=
NULL
;
char
*
dbFile
=
db_get_file
();
struct
stat
st
;
char
buffer
[
100
];
int
bufferSize
=
100
;
int
foundFsCharset
=
0
;
int
foundVersion
=
0
;
if
(
!
music_root
)
music_root
=
directory_new
(
""
,
NULL
);
...
...
@@ -249,54 +253,45 @@ db_load(void)
}
/* get initial info */
{
char
buffer
[
100
];
int
bufferSize
=
100
;
int
foundFsCharset
=
0
;
int
foundVersion
=
0
;
if
(
!
myFgets
(
buffer
,
bufferSize
,
fp
))
FATAL
(
"Error reading db, fgets
\n
"
);
if
(
0
==
strcmp
(
DIRECTORY_INFO_BEGIN
,
buffer
))
{
while
(
myFgets
(
buffer
,
bufferSize
,
fp
)
&&
0
!=
strcmp
(
DIRECTORY_INFO_END
,
buffer
))
{
if
(
!
prefixcmp
(
buffer
,
DIRECTORY_MPD_VERSION
))
{
if
(
foundVersion
)
FATAL
(
"already found version in db
\n
"
);
foundVersion
=
1
;
}
else
if
(
!
prefixcmp
(
buffer
,
DIRECTORY_FS_CHARSET
))
{
char
*
fsCharset
;
char
*
tempCharset
;
if
(
foundFsCharset
)
FATAL
(
"already found fs charset in db
\n
"
);
foundFsCharset
=
1
;
fsCharset
=
&
(
buffer
[
strlen
(
DIRECTORY_FS_CHARSET
)]);
if
((
tempCharset
=
getConfigParamValue
(
CONF_FS_CHARSET
))
&&
strcmp
(
fsCharset
,
tempCharset
))
{
WARNING
(
"Using
\"
%s
\"
for the "
"filesystem charset "
"instead of
\"
%s
\"\n
"
,
fsCharset
,
tempCharset
);
WARNING
(
"maybe you need to "
"recreate the db?
\n
"
);
setFsCharset
(
fsCharset
);
}
}
else
{
FATAL
(
"directory: unknown line in db info: %s
\n
"
,
buffer
);
}
if
(
!
myFgets
(
buffer
,
bufferSize
,
fp
))
FATAL
(
"Error reading db, fgets
\n
"
);
if
(
0
!=
strcmp
(
DIRECTORY_INFO_BEGIN
,
buffer
))
{
ERROR
(
"db info not found in db file
\n
"
);
ERROR
(
"you should recreate the db using --create-db
\n
"
);
while
(
fclose
(
fp
)
&&
errno
==
EINTR
)
;
return
-
1
;
}
while
(
myFgets
(
buffer
,
bufferSize
,
fp
)
&&
0
!=
strcmp
(
DIRECTORY_INFO_END
,
buffer
))
{
if
(
!
prefixcmp
(
buffer
,
DIRECTORY_MPD_VERSION
))
{
if
(
foundVersion
)
FATAL
(
"already found version in db
\n
"
);
foundVersion
=
1
;
}
else
if
(
!
prefixcmp
(
buffer
,
DIRECTORY_FS_CHARSET
))
{
char
*
fsCharset
;
char
*
tempCharset
;
if
(
foundFsCharset
)
FATAL
(
"already found fs charset in db
\n
"
);
foundFsCharset
=
1
;
fsCharset
=
&
(
buffer
[
strlen
(
DIRECTORY_FS_CHARSET
)]);
if
((
tempCharset
=
getConfigParamValue
(
CONF_FS_CHARSET
))
&&
strcmp
(
fsCharset
,
tempCharset
))
{
WARNING
(
"Using
\"
%s
\"
for the "
"filesystem charset "
"instead of
\"
%s
\"\n
"
,
fsCharset
,
tempCharset
);
WARNING
(
"maybe you need to "
"recreate the db?
\n
"
);
setFsCharset
(
fsCharset
);
}
}
else
{
ERROR
(
"db info not found in db file
\n
"
);
ERROR
(
"you should recreate the db using --create-db
\n
"
);
while
(
fclose
(
fp
)
&&
errno
==
EINTR
)
;
return
-
1
;
}
}
else
FATAL
(
"directory: unknown line in db info: %s
\n
"
,
buffer
);
}
DEBUG
(
"reading DB
\n
"
);
...
...
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