aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2006-07-30 23:32:39 +0000
committerEric Wong <normalperson@yhbt.net>2006-07-30 23:32:39 +0000
commit381d7232a0d63c0a145fae5e2c40e577ff2f44f1 (patch)
tree6a9191774f3c797a77ef7d85dbe71564ff252ada /src
parent71fe871908db4317e5afd4308a044909a1799c9e (diff)
downloadmpd-381d7232a0d63c0a145fae5e2c40e577ff2f44f1.tar.gz
mpd-381d7232a0d63c0a145fae5e2c40e577ff2f44f1.tar.xz
mpd-381d7232a0d63c0a145fae5e2c40e577ff2f44f1.zip
remove deprecated myfprintf wrapper
This shaves another 5-6k because we've removed the paranoid fflush() calls after every fprintf. Now we only fflush() when we need to git-svn-id: https://svn.musicpd.org/mpd/trunk@4493 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r--src/audio.c2
-rw-r--r--src/audioOutput.c5
-rw-r--r--src/directory.c14
-rw-r--r--src/inputPlugin.c5
-rw-r--r--src/log.c2
-rw-r--r--src/log.h12
-rw-r--r--src/main.c8
-rw-r--r--src/myfprintf.h5
-rw-r--r--src/playlist.c27
-rw-r--r--src/song.c9
10 files changed, 45 insertions, 44 deletions
diff --git a/src/audio.c b/src/audio.c
index 03e706d68..8ecae5ec3 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -480,7 +480,7 @@ void saveAudioDevicesState(void)
assert(audioOutputArraySize != 0);
for (i = 0; i < audioOutputArraySize; i++) {
- myfprintf(fp, AUDIO_DEVICE_STATE "%d:%s\n",
+ fprintf(fp, AUDIO_DEVICE_STATE "%d:%s\n",
(int)pdAudioDevicesEnabled[i],
audioOutputArray[i]->name);
}
diff --git a/src/audioOutput.c b/src/audioOutput.c
index f6a6fea9e..f938a0deb 100644
--- a/src/audioOutput.c
+++ b/src/audioOutput.c
@@ -267,8 +267,9 @@ void printAllOutputPluginTypes(FILE * fp)
while (node) {
plugin = (AudioOutputPlugin *) node->data;
- myfprintf(fp, "%s ", plugin->name);
+ fprintf(fp, "%s ", plugin->name);
node = node->nextNode;
}
- myfprintf(fp, "\n");
+ fprintf(fp, "\n");
+ fflush(fp);
}
diff --git a/src/directory.c b/src/directory.c
index fe98ec67e..9f07b203e 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -906,13 +906,13 @@ static void writeDirectoryInfo(FILE * fp, Directory * directory)
Directory *subDirectory;
if (directory->path) {
- myfprintf(fp, "%s%s\n", DIRECTORY_BEGIN,
+ fprintf(fp, "%s%s\n", DIRECTORY_BEGIN,
getDirectoryPath(directory));
}
while (node != NULL) {
subDirectory = (Directory *) node->data;
- myfprintf(fp, "%s%s\n", DIRECTORY_DIR, node->key);
+ fprintf(fp, "%s%s\n", DIRECTORY_DIR, node->key);
writeDirectoryInfo(fp, subDirectory);
node = node->nextNode;
}
@@ -920,7 +920,7 @@ static void writeDirectoryInfo(FILE * fp, Directory * directory)
writeSongInfoFromList(fp, directory->songs);
if (directory->path) {
- myfprintf(fp, "%s%s\n", DIRECTORY_END,
+ fprintf(fp, "%s%s\n", DIRECTORY_END,
getDirectoryPath(directory));
}
}
@@ -1106,10 +1106,10 @@ int writeDirectoryDB()
}
/* block signals when writing the db so we don't get a corrupted db */
- myfprintf(fp, "%s\n", DIRECTORY_INFO_BEGIN);
- myfprintf(fp, "%s%s\n", DIRECTORY_MPD_VERSION, VERSION);
- myfprintf(fp, "%s%s\n", DIRECTORY_FS_CHARSET, getFsCharset());
- myfprintf(fp, "%s\n", DIRECTORY_INFO_END);
+ fprintf(fp, "%s\n", DIRECTORY_INFO_BEGIN);
+ fprintf(fp, "%s%s\n", DIRECTORY_MPD_VERSION, VERSION);
+ fprintf(fp, "%s%s\n", DIRECTORY_FS_CHARSET, getFsCharset());
+ fprintf(fp, "%s\n", DIRECTORY_INFO_END);
writeDirectoryInfo(fp, mp3rootDirectory);
diff --git a/src/inputPlugin.c b/src/inputPlugin.c
index 80781774b..1c795c59c 100644
--- a/src/inputPlugin.c
+++ b/src/inputPlugin.c
@@ -128,12 +128,13 @@ void printAllInputPluginSuffixes(FILE * fp)
plugin = (InputPlugin *) node->data;
suffixes = plugin->suffixes;
while (suffixes && *suffixes) {
- myfprintf(fp, "%s ", *suffixes);
+ fprintf(fp, "%s ", *suffixes);
suffixes++;
}
node = node->nextNode;
}
- myfprintf(fp, "\n");
+ fprintf(fp, "\n");
+ fflush(fp);
}
extern InputPlugin mp3Plugin;
diff --git a/src/log.c b/src/log.c
index 39d05e14a..7890d2014 100644
--- a/src/log.c
+++ b/src/log.c
@@ -83,7 +83,7 @@ void flushWarningLog(void)
s = strtok(warningBuffer, "\n");
while (s != NULL) {
- myfprintf(stderr, "%s\n", s);
+ fdprintf(STDERR_FILENO, "%s\n", s);
s = strtok(NULL, "\n");
}
diff --git a/src/log.h b/src/log.h
index 78ad75326..2e888a510 100644
--- a/src/log.h
+++ b/src/log.h
@@ -23,6 +23,8 @@
#include "myfprintf.h"
+#include <unistd.h>
+
#define LOG_LEVEL_LOW 0
#define LOG_LEVEL_SECURE 1
#define LOG_LEVEL_DEBUG 2
@@ -30,18 +32,18 @@
extern int logLevel;
extern short warningFlushed;
-#define ERROR(...) myfprintf(stderr, __VA_ARGS__)
+#define ERROR(...) fdprintf(STDERR_FILENO, __VA_ARGS__)
-#define LOG(...) myfprintf(stdout, __VA_ARGS__)
+#define LOG(...) fdprintf(STDOUT_FILENO, __VA_ARGS__)
#define SECURE(...) if(logLevel>=LOG_LEVEL_SECURE) \
- myfprintf(stdout, __VA_ARGS__)
+ fdprintf(STDOUT_FILENO, __VA_ARGS__)
#define DEBUG(...) if(logLevel>=LOG_LEVEL_DEBUG) \
- myfprintf(stdout, __VA_ARGS__)
+ fdprintf(STDOUT_FILENO, __VA_ARGS__)
#define WARNING(...) { \
- if(warningFlushed) myfprintf(stderr, __VA_ARGS__); \
+ if(warningFlushed) fdprintf(STDERR_FILENO, __VA_ARGS__); \
else bufferWarning(__VA_ARGS__); \
}
diff --git a/src/main.c b/src/main.c
index 40e0274ed..67ae0f76b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -191,8 +191,8 @@ static void parseOptions(int argc, char **argv, Options * options)
version();
exit(EXIT_SUCCESS);
} else {
- myfprintf(stderr,
- "unknown command line option: %s\n",
+ fprintf(stderr,
+ "unknown command line option: %s\n",
argv[i]);
exit(EXIT_FAILURE);
}
@@ -447,13 +447,13 @@ static void setupLogOutput(Options * options, FILE * out, FILE * err)
fflush(NULL);
if (dup2(fileno(out), STDOUT_FILENO) < 0) {
- myfprintf(err, "problems dup2 stdout : %s\n",
+ fprintf(err, "problems dup2 stdout : %s\n",
strerror(errno));
exit(EXIT_FAILURE);
}
if (dup2(fileno(err), STDERR_FILENO) < 0) {
- myfprintf(err, "problems dup2 stderr : %s\n",
+ fprintf(err, "problems dup2 stderr : %s\n",
strerror(errno));
exit(EXIT_FAILURE);
}
diff --git a/src/myfprintf.h b/src/myfprintf.h
index fe918a101..5c876bc29 100644
--- a/src/myfprintf.h
+++ b/src/myfprintf.h
@@ -30,11 +30,6 @@ void myfprintfStdLogMode(FILE * out, FILE * err);
mpd_fprintf void fdprintf(const int fd, const char *fmt, ...);
void vfdprintf(const int fd, const char *fmt, va_list arglist);
-#define myfprintf(fp, ...) do { \
- fprintf(fp, __VA_ARGS__); \
- fflush(fp); \
- } while (0)
-
int myfprintfCloseAndOpenLogFile();
void myfprintfCloseLogFile();
diff --git a/src/playlist.c b/src/playlist.c
index 374de976b..64350d471 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -270,36 +270,37 @@ void savePlaylistState(void)
return;
}
- myfprintf(fp, "%s", PLAYLIST_STATE_FILE_STATE);
+ fprintf(fp, "%s", PLAYLIST_STATE_FILE_STATE);
switch (playlist_state) {
case PLAYLIST_STATE_PLAY:
switch (getPlayerState()) {
case PLAYER_STATE_PAUSE:
- myfprintf(fp, "%s\n",
+ fprintf(fp, "%s\n",
PLAYLIST_STATE_FILE_STATE_PAUSE);
break;
default:
- myfprintf(fp, "%s\n",
+ fprintf(fp, "%s\n",
PLAYLIST_STATE_FILE_STATE_PLAY);
}
- myfprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CURRENT,
+ fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CURRENT,
playlist.order[playlist.current]);
- myfprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_TIME,
+ fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_TIME,
getPlayerElapsedTime());
break;
default:
- myfprintf(fp, "%s\n", PLAYLIST_STATE_FILE_STATE_STOP);
+ fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_STATE_STOP);
break;
}
- myfprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_RANDOM,
+ fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_RANDOM,
playlist.random);
- myfprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_REPEAT,
+ fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_REPEAT,
playlist.repeat);
- myfprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CROSSFADE,
+ fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CROSSFADE,
(int)(getPlayerCrossFade()));
- myfprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_BEGIN);
+ fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_BEGIN);
+ fflush(fp);
showPlaylist(fileno(fp));
- myfprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_END);
+ fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_END);
while (fclose(fp) && errno == EINTR) ;
}
@@ -1414,12 +1415,12 @@ int savePlaylist(int fd, char *utf8file)
for (i = 0; i < playlist.length; i++) {
if (playlist_saveAbsolutePaths &&
playlist.songs[i]->type == SONG_TYPE_FILE) {
- myfprintf(fileP, "%s\n",
+ fprintf(fileP, "%s\n",
rmp2amp(utf8ToFsCharset
((getSongUrl(playlist.songs[i])))));
} else {
url = utf8ToFsCharset(getSongUrl(playlist.songs[i]));
- myfprintf(fileP, "%s\n", url);
+ fprintf(fileP, "%s\n", url);
free(url);
}
diff --git a/src/song.c b/src/song.c
index a601d5f67..62e699839 100644
--- a/src/song.c
+++ b/src/song.c
@@ -170,17 +170,18 @@ void writeSongInfoFromList(FILE * fp, SongList * list)
{
ListNode *tempNode = list->firstNode;
- myfprintf(fp, "%s\n", SONG_BEGIN);
+ fprintf(fp, "%s\n", SONG_BEGIN);
while (tempNode != NULL) {
- myfprintf(fp, "%s%s\n", SONG_KEY, tempNode->key);
+ fprintf(fp, "%s%s\n", SONG_KEY, tempNode->key);
+ fflush(fp);
printSongInfo(fileno(fp), (Song *) tempNode->data);
- myfprintf(fp, "%s%li\n", SONG_MTIME,
+ fprintf(fp, "%s%li\n", SONG_MTIME,
(long)((Song *) tempNode->data)->mtime);
tempNode = tempNode->nextNode;
}
- myfprintf(fp, "%s\n", SONG_END);
+ fprintf(fp, "%s\n", SONG_END);
}
static void insertSongIntoList(SongList * list, ListNode ** nextSongNode,