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
859aac72
Commit
859aac72
authored
Dec 28, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: removed myFgets()
Replaced myFgets() with fgets() + g_strchomp().
parent
2598cdd8
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
38 additions
and
32 deletions
+38
-32
audio.c
src/audio.c
+3
-1
conf.c
src/conf.c
+3
-2
database.c
src/database.c
+7
-3
directory_save.c
src/directory_save.c
+6
-4
playlist.c
src/playlist.c
+9
-4
song_save.c
src/song_save.c
+4
-2
stored_playlist.c
src/stored_playlist.c
+3
-1
utils.c
src/utils.c
+0
-12
utils.h
src/utils.h
+0
-2
volume.c
src/volume.c
+3
-1
No files found.
src/audio.c
View file @
859aac72
...
...
@@ -396,9 +396,11 @@ void readAudioDevicesState(FILE *fp)
assert
(
audioOutputArraySize
!=
0
);
while
(
myFgets
(
buffer
,
AUDIO_BUFFER_SIZE
,
fp
))
{
while
(
fgets
(
buffer
,
sizeof
(
buffer
)
,
fp
))
{
char
*
c
,
*
name
;
g_strchomp
(
buffer
);
if
(
!
g_str_has_prefix
(
buffer
,
AUDIO_DEVICE_STATE
))
continue
;
...
...
src/conf.c
View file @
859aac72
...
...
@@ -210,7 +210,7 @@ static ConfigParam *readConfigBlock(FILE * fp, int *count, char *string)
int
numberOfArgs
;
int
argsMinusComment
;
while
(
myF
gets
(
string
,
MAX_STRING_SIZE
,
fp
))
{
while
(
f
gets
(
string
,
MAX_STRING_SIZE
,
fp
))
{
char
*
array
[
CONF_LINE_TOKEN_MAX
]
=
{
NULL
};
(
*
count
)
++
;
...
...
@@ -270,8 +270,9 @@ void readConf(const char *file)
strerror
(
errno
));
}
while
(
myF
gets
(
string
,
MAX_STRING_SIZE
,
fp
))
{
while
(
f
gets
(
string
,
MAX_STRING_SIZE
,
fp
))
{
char
*
array
[
CONF_LINE_TOKEN_MAX
]
=
{
NULL
};
count
++
;
numberOfArgs
=
buffer2array
(
string
,
array
,
CONF_LINE_TOKEN_MAX
);
...
...
src/database.c
View file @
859aac72
...
...
@@ -268,9 +268,11 @@ db_load(void)
}
/* get initial info */
if
(
!
myF
gets
(
buffer
,
sizeof
(
buffer
),
fp
))
if
(
!
f
gets
(
buffer
,
sizeof
(
buffer
),
fp
))
FATAL
(
"Error reading db, fgets
\n
"
);
g_strchomp
(
buffer
);
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
"
);
...
...
@@ -278,8 +280,10 @@ db_load(void)
return
-
1
;
}
while
(
myFgets
(
buffer
,
sizeof
(
buffer
),
fp
)
&&
0
!=
strcmp
(
DIRECTORY_INFO_END
,
buffer
))
{
while
(
fgets
(
buffer
,
sizeof
(
buffer
),
fp
)
&&
!
g_str_has_prefix
(
buffer
,
DIRECTORY_INFO_END
))
{
g_strchomp
(
buffer
);
if
(
g_str_has_prefix
(
buffer
,
DIRECTORY_MPD_VERSION
))
{
if
(
foundVersion
)
FATAL
(
"already found version in db
\n
"
);
...
...
src/directory_save.c
View file @
859aac72
...
...
@@ -66,25 +66,27 @@ void
directory_load
(
FILE
*
fp
,
struct
directory
*
directory
)
{
char
buffer
[
MPD_PATH_MAX
*
2
];
int
bufferSize
=
MPD_PATH_MAX
*
2
;
char
key
[
MPD_PATH_MAX
*
2
];
char
*
name
;
while
(
myFgets
(
buffer
,
bufferSize
,
fp
)
while
(
fgets
(
buffer
,
sizeof
(
buffer
)
,
fp
)
&&
!
g_str_has_prefix
(
buffer
,
DIRECTORY_END
))
{
if
(
g_str_has_prefix
(
buffer
,
DIRECTORY_DIR
))
{
struct
directory
*
subdir
;
g_strchomp
(
buffer
);
strcpy
(
key
,
&
(
buffer
[
strlen
(
DIRECTORY_DIR
)]));
if
(
!
myFgets
(
buffer
,
bufferSize
,
fp
))
if
(
!
fgets
(
buffer
,
sizeof
(
buffer
)
,
fp
))
FATAL
(
"Error reading db, fgets
\n
"
);
/* for compatibility with db's prior to 0.11 */
if
(
g_str_has_prefix
(
buffer
,
DIRECTORY_MTIME
))
{
if
(
!
myFgets
(
buffer
,
bufferSize
,
fp
))
if
(
!
fgets
(
buffer
,
sizeof
(
buffer
)
,
fp
))
FATAL
(
"Error reading db, fgets
\n
"
);
}
if
(
!
g_str_has_prefix
(
buffer
,
DIRECTORY_BEGIN
))
FATAL
(
"Error reading db at line: %s
\n
"
,
buffer
);
g_strchomp
(
buffer
);
name
=
&
(
buffer
[
strlen
(
DIRECTORY_BEGIN
)]);
if
(
!
g_str_has_prefix
(
name
,
directory
->
path
)
!=
0
)
FATAL
(
"Wrong path in database: '%s' in '%s'
\n
"
,
...
...
src/playlist.c
View file @
859aac72
...
...
@@ -268,9 +268,11 @@ static void loadPlaylistFromStateFile(FILE *fp, char *buffer,
char
*
temp
;
int
song
;
if
(
!
myF
gets
(
buffer
,
PLAYLIST_BUFFER_SIZE
,
fp
))
if
(
!
f
gets
(
buffer
,
PLAYLIST_BUFFER_SIZE
,
fp
))
state_file_fatal
();
while
(
strcmp
(
buffer
,
PLAYLIST_STATE_FILE_PLAYLIST_END
))
{
while
(
!
g_str_has_prefix
(
buffer
,
PLAYLIST_STATE_FILE_PLAYLIST_END
))
{
g_strchomp
(
buffer
);
temp
=
strtok
(
buffer
,
":"
);
if
(
temp
==
NULL
)
state_file_fatal
();
...
...
@@ -290,7 +292,8 @@ static void loadPlaylistFromStateFile(FILE *fp, char *buffer,
seek_time
);
}
}
if
(
!
myFgets
(
buffer
,
PLAYLIST_BUFFER_SIZE
,
fp
))
if
(
!
fgets
(
buffer
,
PLAYLIST_BUFFER_SIZE
,
fp
))
state_file_fatal
();
}
}
...
...
@@ -302,7 +305,9 @@ void readPlaylistState(FILE *fp)
int
state
=
PLAYER_STATE_STOP
;
char
buffer
[
PLAYLIST_BUFFER_SIZE
];
while
(
myFgets
(
buffer
,
PLAYLIST_BUFFER_SIZE
,
fp
))
{
while
(
fgets
(
buffer
,
sizeof
(
buffer
),
fp
))
{
g_strchomp
(
buffer
);
if
(
g_str_has_prefix
(
buffer
,
PLAYLIST_STATE_FILE_STATE
))
{
if
(
strcmp
(
&
(
buffer
[
strlen
(
PLAYLIST_STATE_FILE_STATE
)]),
PLAYLIST_STATE_FILE_STATE_PLAY
)
==
0
)
{
...
...
src/song_save.c
View file @
859aac72
...
...
@@ -104,11 +104,13 @@ void readSongInfoIntoList(FILE *fp, struct songvec *sv,
struct
directory
*
parent
)
{
char
buffer
[
MPD_PATH_MAX
+
1024
];
int
bufferSize
=
MPD_PATH_MAX
+
1024
;
struct
song
*
song
=
NULL
;
int
itemType
;
while
(
myFgets
(
buffer
,
bufferSize
,
fp
)
&&
0
!=
strcmp
(
SONG_END
,
buffer
))
{
while
(
fgets
(
buffer
,
sizeof
(
buffer
),
fp
)
&&
!
g_str_has_prefix
(
buffer
,
SONG_END
))
{
g_strchomp
(
buffer
);
if
(
0
==
strncmp
(
SONG_KEY
,
buffer
,
strlen
(
SONG_KEY
)))
{
if
(
song
)
insertSongIntoList
(
sv
,
song
);
...
...
src/stored_playlist.c
View file @
859aac72
...
...
@@ -149,13 +149,15 @@ spl_load(const char *utf8path)
list
=
g_ptr_array_new
();
while
(
myF
gets
(
buffer
,
sizeof
(
buffer
),
file
))
{
while
(
f
gets
(
buffer
,
sizeof
(
buffer
),
file
))
{
char
*
s
=
buffer
;
const
char
*
path_utf8
;
if
(
*
s
==
PLAYLIST_COMMENT
)
continue
;
g_strchomp
(
buffer
);
if
(
!
isRemoteUrl
(
s
))
{
struct
song
*
song
;
...
...
src/utils.c
View file @
859aac72
...
...
@@ -33,18 +33,6 @@
#include <sys/socket.h>
#endif
char
*
myFgets
(
char
*
buffer
,
int
bufferSize
,
FILE
*
fp
)
{
char
*
ret
=
fgets
(
buffer
,
bufferSize
,
fp
);
if
(
ret
&&
strlen
(
buffer
)
>
0
&&
buffer
[
strlen
(
buffer
)
-
1
]
==
'\n'
)
{
buffer
[
strlen
(
buffer
)
-
1
]
=
'\0'
;
}
if
(
ret
&&
strlen
(
buffer
)
>
0
&&
buffer
[
strlen
(
buffer
)
-
1
]
==
'\r'
)
{
buffer
[
strlen
(
buffer
)
-
1
]
=
'\0'
;
}
return
ret
;
}
void
stripReturnChar
(
char
*
string
)
{
while
(
string
&&
(
string
=
strchr
(
string
,
'\n'
)))
{
...
...
src/utils.h
View file @
859aac72
...
...
@@ -37,8 +37,6 @@
} while (0)
#endif
/* !assert_static */
char
*
myFgets
(
char
*
buffer
,
int
bufferSize
,
FILE
*
fp
);
void
stripReturnChar
(
char
*
string
);
void
my_usleep
(
long
usec
);
...
...
src/volume.c
View file @
859aac72
...
...
@@ -522,9 +522,11 @@ void read_sw_volume_state(FILE *fp)
if
(
volume_mixerType
!=
VOLUME_MIXER_TYPE_SOFTWARE
)
return
;
while
(
myF
gets
(
buf
,
sizeof
(
buf
),
fp
))
{
while
(
f
gets
(
buf
,
sizeof
(
buf
),
fp
))
{
if
(
!
g_str_has_prefix
(
buf
,
SW_VOLUME_STATE
))
continue
;
g_strchomp
(
buf
);
sv
=
strtol
(
buf
+
strlen
(
SW_VOLUME_STATE
),
&
end
,
10
);
if
(
G_LIKELY
(
!*
end
))
changeSoftwareVolume
(
sv
,
0
);
...
...
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