diff options
-rw-r--r-- | src/audio.c | 4 | ||||
-rw-r--r-- | src/database.c | 4 | ||||
-rw-r--r-- | src/decoder/mp3_plugin.c | 3 | ||||
-rw-r--r-- | src/directory_save.c | 12 | ||||
-rw-r--r-- | src/ls.c | 3 | ||||
-rw-r--r-- | src/main.c | 5 | ||||
-rw-r--r-- | src/playlist.c | 16 | ||||
-rw-r--r-- | src/utils.c | 10 | ||||
-rw-r--r-- | src/utils.h | 2 | ||||
-rw-r--r-- | src/volume.c | 4 |
10 files changed, 28 insertions, 35 deletions
diff --git a/src/audio.c b/src/audio.c index ce8b06151..bfebac4fc 100644 --- a/src/audio.c +++ b/src/audio.c @@ -28,6 +28,8 @@ #include "utils.h" #include "os_compat.h" +#include <glib.h> + #define AUDIO_DEVICE_STATE "audio_device_state:" #define AUDIO_BUFFER_SIZE 2*MPD_PATH_MAX @@ -434,7 +436,7 @@ void readAudioDevicesState(FILE *fp) while (myFgets(buffer, AUDIO_BUFFER_SIZE, fp)) { char *c, *name; - if (prefixcmp(buffer, AUDIO_DEVICE_STATE)) + if (!g_str_has_prefix(buffer, AUDIO_DEVICE_STATE)) continue; c = strchr(buffer, ':'); diff --git a/src/database.c b/src/database.c index 74a3a3e3c..2fd61dd08 100644 --- a/src/database.c +++ b/src/database.c @@ -280,11 +280,11 @@ db_load(void) while (myFgets(buffer, sizeof(buffer), fp) && 0 != strcmp(DIRECTORY_INFO_END, buffer)) { - if (!prefixcmp(buffer, DIRECTORY_MPD_VERSION)) { + if (g_str_has_prefix(buffer, DIRECTORY_MPD_VERSION)) { if (foundVersion) FATAL("already found version in db\n"); foundVersion = 1; - } else if (!prefixcmp(buffer, DIRECTORY_FS_CHARSET)) { + } else if (g_str_has_prefix(buffer, DIRECTORY_FS_CHARSET)) { char *fsCharset; char *tempCharset; diff --git a/src/decoder/mp3_plugin.c b/src/decoder/mp3_plugin.c index 330ba668f..68f786106 100644 --- a/src/decoder/mp3_plugin.c +++ b/src/decoder/mp3_plugin.c @@ -21,6 +21,7 @@ #include "../utils.h" #include "../conf.h" +#include <glib.h> #include <mad.h> #ifdef HAVE_ID3TAG @@ -564,7 +565,7 @@ static int parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) /* This is technically incorrect, since the encoder might not be lame. * But there's no other way to determine if this is a lame tag, and we * wouldn't want to go reading a tag that's not there. */ - if (prefixcmp(lame->encoder, "LAME")) + if (!g_str_has_prefix(lame->encoder, "LAME")) return 0; if (sscanf(lame->encoder+4, "%u.%u", diff --git a/src/directory_save.c b/src/directory_save.c index 7ee5cbb02..352b808cf 100644 --- a/src/directory_save.c +++ b/src/directory_save.c @@ -71,22 +71,22 @@ directory_load(FILE *fp, struct directory *directory) char *name; while (myFgets(buffer, bufferSize, fp) - && prefixcmp(buffer, DIRECTORY_END)) { - if (!prefixcmp(buffer, DIRECTORY_DIR)) { + && !g_str_has_prefix(buffer, DIRECTORY_END)) { + if (g_str_has_prefix(buffer, DIRECTORY_DIR)) { struct directory *subdir; strcpy(key, &(buffer[strlen(DIRECTORY_DIR)])); if (!myFgets(buffer, bufferSize, fp)) FATAL("Error reading db, fgets\n"); /* for compatibility with db's prior to 0.11 */ - if (!prefixcmp(buffer, DIRECTORY_MTIME)) { + if (g_str_has_prefix(buffer, DIRECTORY_MTIME)) { if (!myFgets(buffer, bufferSize, fp)) FATAL("Error reading db, fgets\n"); } - if (prefixcmp(buffer, DIRECTORY_BEGIN)) + if (!g_str_has_prefix(buffer, DIRECTORY_BEGIN)) FATAL("Error reading db at line: %s\n", buffer); name = &(buffer[strlen(DIRECTORY_BEGIN)]); - if (prefixcmp(name, directory->path) != 0) + if (!g_str_has_prefix(name, directory->path) != 0) FATAL("Wrong path in database: '%s' in '%s'\n", name, directory->path); @@ -98,7 +98,7 @@ directory_load(FILE *fp, struct directory *directory) dirvec_add(&directory->children, subdir); } directory_load(fp, subdir); - } else if (!prefixcmp(buffer, SONG_BEGIN)) { + } else if (g_str_has_prefix(buffer, SONG_BEGIN)) { readSongInfoIntoList(fp, &directory->songs, directory); } else { FATAL("Unknown line in db: %s\n", buffer); @@ -21,7 +21,6 @@ #include "path.h" #include "client.h" #include "log.h" -#include "utils.h" #include "list.h" #include "stored_playlist.h" #include "os_compat.h" @@ -92,7 +91,7 @@ int isRemoteUrl(const char *url) while (*urlPrefixes) { count++; - if (!prefixcmp(url, *urlPrefixes)) + if (g_str_has_prefix(url, *urlPrefixes)) return count; urlPrefixes++; } diff --git a/src/main.c b/src/main.c index 77d59a6af..025570f84 100644 --- a/src/main.c +++ b/src/main.c @@ -46,12 +46,13 @@ #include "tag.h" #include "dbUtils.h" #include "../config.h" -#include "utils.h" #include "normalize.h" #include "zeroconf.h" #include "main_notify.h" #include "os_compat.h" +#include <glib.h> + #define SYSTEM_CONFIG_FILE_LOCATION "/etc/mpd.conf" #define USER_CONFIG_FILE_LOCATION "/.mpdconf" @@ -156,7 +157,7 @@ static void parseOptions(int argc, char **argv, Options * options) if (argc > 1) { int i = 1; while (i < argc) { - if (!prefixcmp(argv[i], "--")) { + if (g_str_has_prefix(argv[i], "--")) { if (strcmp(argv[i], "--help") == 0) { usage(argv); exit(EXIT_SUCCESS); diff --git a/src/playlist.c b/src/playlist.c index 0baebc6ea..58db673aa 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -301,7 +301,7 @@ void readPlaylistState(FILE *fp) char buffer[PLAYLIST_BUFFER_SIZE]; while (myFgets(buffer, PLAYLIST_BUFFER_SIZE, fp)) { - if (!prefixcmp(buffer, PLAYLIST_STATE_FILE_STATE)) { + if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_STATE)) { if (strcmp(&(buffer[strlen(PLAYLIST_STATE_FILE_STATE)]), PLAYLIST_STATE_FILE_STATE_PLAY) == 0) { state = PLAYER_STATE_PLAY; @@ -312,24 +312,24 @@ void readPlaylistState(FILE *fp) == 0) { state = PLAYER_STATE_PAUSE; } - } else if (!prefixcmp(buffer, PLAYLIST_STATE_FILE_TIME)) { + } else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_TIME)) { seek_time = atoi(&(buffer[strlen(PLAYLIST_STATE_FILE_TIME)])); } else - if (!prefixcmp(buffer, PLAYLIST_STATE_FILE_REPEAT)) { + if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_REPEAT)) { if (strcmp (&(buffer[strlen(PLAYLIST_STATE_FILE_REPEAT)]), "1") == 0) { setPlaylistRepeatStatus(true); } else setPlaylistRepeatStatus(false); - } else if (!prefixcmp(buffer, PLAYLIST_STATE_FILE_CROSSFADE)) { + } else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_CROSSFADE)) { setPlayerCrossFade(atoi (& (buffer [strlen (PLAYLIST_STATE_FILE_CROSSFADE)]))); - } else if (!prefixcmp(buffer, PLAYLIST_STATE_FILE_RANDOM)) { + } else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_RANDOM)) { if (strcmp (& (buffer @@ -338,15 +338,15 @@ void readPlaylistState(FILE *fp) setPlaylistRandomStatus(true); } else setPlaylistRandomStatus(false); - } else if (!prefixcmp(buffer, PLAYLIST_STATE_FILE_CURRENT)) { + } else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_CURRENT)) { if (strlen(buffer) == strlen(PLAYLIST_STATE_FILE_CURRENT)) state_file_fatal(); current = atoi(&(buffer [strlen (PLAYLIST_STATE_FILE_CURRENT)])); - } else if (!prefixcmp(buffer, - PLAYLIST_STATE_FILE_PLAYLIST_BEGIN)) { + } else if (g_str_has_prefix(buffer, + PLAYLIST_STATE_FILE_PLAYLIST_BEGIN)) { if (state == PLAYER_STATE_STOP) current = -1; loadPlaylistFromStateFile(fp, buffer, state, diff --git a/src/utils.c b/src/utils.c index 57d1f30fa..8d5878723 100644 --- a/src/utils.c +++ b/src/utils.c @@ -261,13 +261,3 @@ void xpthread_cond_destroy(pthread_cond_t *cond) if ((err = pthread_cond_destroy(cond))) FATAL("failed to destroy cond: %s\n", strerror(err)); } - -int prefixcmp(const char *str, const char *prefix) -{ - for (; ; str++, prefix++) - if (!*prefix) - return 0; - else if (*str != *prefix) - return (unsigned char)*prefix - (unsigned char)*str; -} - diff --git a/src/utils.h b/src/utils.h index 5f3b26c5f..09260c0a2 100644 --- a/src/utils.h +++ b/src/utils.h @@ -104,6 +104,4 @@ void xpthread_mutex_destroy(pthread_mutex_t *mutex); void xpthread_cond_destroy(pthread_cond_t *cond); -int prefixcmp(const char *str, const char *prefix); - #endif diff --git a/src/volume.c b/src/volume.c index cca5860e3..8e27dae38 100644 --- a/src/volume.c +++ b/src/volume.c @@ -26,6 +26,8 @@ #include "../config.h" +#include <glib.h> + #ifdef HAVE_OSS #include <sys/soundcard.h> #endif @@ -518,7 +520,7 @@ void read_sw_volume_state(FILE *fp) if (volume_mixerType != VOLUME_MIXER_TYPE_SOFTWARE) return; while (myFgets(buf, sizeof(buf), fp)) { - if (prefixcmp(buf, SW_VOLUME_STATE)) + if (!g_str_has_prefix(buf, SW_VOLUME_STATE)) continue; sv = strtol(buf + strlen(SW_VOLUME_STATE), &end, 10); if (mpd_likely(!*end)) |