diff options
author | Max Kellermann <max@duempel.org> | 2010-12-23 16:13:11 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2010-12-23 16:23:04 +0100 |
commit | 0958ed584431ac09e676dd51925e56142416e7c2 (patch) | |
tree | 59f9b185d8381368f7bb8a9ae5beb595914c13dd | |
parent | e3cba18532a24bf20a4174070159eef647057464 (diff) | |
download | mpd-0958ed584431ac09e676dd51925e56142416e7c2.tar.gz mpd-0958ed584431ac09e676dd51925e56142416e7c2.tar.xz mpd-0958ed584431ac09e676dd51925e56142416e7c2.zip |
utils: move string_array_contains() to string_util.c
-rw-r--r-- | Makefile.am | 20 | ||||
-rw-r--r-- | src/archive_list.c | 2 | ||||
-rw-r--r-- | src/conf.c | 1 | ||||
-rw-r--r-- | src/decoder_plugin.c | 2 | ||||
-rw-r--r-- | src/playlist_list.c | 2 | ||||
-rw-r--r-- | src/string_util.c | 38 | ||||
-rw-r--r-- | src/string_util.h | 36 | ||||
-rw-r--r-- | src/utils.c | 13 | ||||
-rw-r--r-- | src/utils.h | 11 |
9 files changed, 89 insertions, 36 deletions
diff --git a/Makefile.am b/Makefile.am index 7a65ab890..d3eee4504 100644 --- a/Makefile.am +++ b/Makefile.am @@ -214,6 +214,7 @@ mpd_headers = \ src/strset.h \ src/uri.h \ src/utils.h \ + src/string_util.h \ src/volume.h \ src/zeroconf.h src/zeroconf-internal.h \ src/locate.h \ @@ -347,6 +348,7 @@ src_mpd_SOURCES = \ src/strset.c \ src/uri.c \ src/utils.c \ + src/string_util.c \ src/volume.c \ src/locate.c \ src/stored_playlist.c \ @@ -854,7 +856,7 @@ test_read_conf_CPPFLAGS = $(AM_CPPFLAGS) \ test_read_conf_LDADD = $(MPD_LIBS) \ $(GLIB_LIBS) test_read_conf_SOURCES = test/read_conf.c \ - src/conf.c src/tokenizer.c src/utils.c + src/conf.c src/tokenizer.c src/utils.c src/string_util.c test_run_input_CPPFLAGS = $(AM_CPPFLAGS) \ $(ARCHIVE_CFLAGS) \ @@ -864,7 +866,7 @@ test_run_input_LDADD = $(MPD_LIBS) \ $(INPUT_LIBS) \ $(GLIB_LIBS) test_run_input_SOURCES = test/run_input.c \ - src/conf.c src/tokenizer.c src/utils.c \ + src/conf.c src/tokenizer.c src/utils.c src/string_util.c\ src/tag.c src/tag_pool.c src/tag_save.c \ src/fd_util.c \ $(ARCHIVE_SRC) \ @@ -882,7 +884,7 @@ test_dump_playlist_LDADD = $(MPD_LIBS) \ $(INPUT_LIBS) \ $(GLIB_LIBS) test_dump_playlist_SOURCES = test/dump_playlist.c \ - src/conf.c src/tokenizer.c src/utils.c \ + src/conf.c src/tokenizer.c src/utils.c src/string_util.c\ src/uri.c \ src/song.c src/tag.c src/tag_pool.c src/tag_save.c \ src/text_input_stream.c src/fifo_buffer.c \ @@ -911,7 +913,7 @@ test_run_decoder_LDADD = $(MPD_LIBS) \ $(INPUT_LIBS) $(DECODER_LIBS) \ $(GLIB_LIBS) test_run_decoder_SOURCES = test/run_decoder.c \ - src/conf.c src/tokenizer.c src/utils.c src/log.c \ + src/conf.c src/tokenizer.c src/utils.c src/string_util.c src/log.c \ src/tag.c src/tag_pool.c \ src/replay_gain_info.c \ src/uri.c \ @@ -934,7 +936,7 @@ test_read_tags_LDADD = $(MPD_LIBS) \ $(INPUT_LIBS) $(DECODER_LIBS) \ $(GLIB_LIBS) test_read_tags_SOURCES = test/read_tags.c \ - src/conf.c src/tokenizer.c src/utils.c src/log.c \ + src/conf.c src/tokenizer.c src/utils.c src/string_util.c src/log.c \ src/tag.c src/tag_pool.c \ src/replay_gain_info.c \ src/uri.c \ @@ -953,7 +955,7 @@ test_run_filter_LDADD = $(MPD_LIBS) \ test_run_filter_SOURCES = test/run_filter.c \ src/filter_plugin.c \ src/filter_registry.c \ - src/conf.c src/tokenizer.c src/utils.c \ + src/conf.c src/tokenizer.c src/utils.c src/string_util.c \ src/pcm_volume.c src/pcm_convert.c src/pcm_byteswap.c \ src/pcm_format.c src/pcm_channels.c src/pcm_dither.c \ src/pcm_pack.c \ @@ -974,7 +976,7 @@ if ENABLE_ENCODER noinst_PROGRAMS += test/run_encoder test_run_encoder_SOURCES = test/run_encoder.c \ src/conf.c src/tokenizer.c \ - src/utils.c \ + src/utils.c src/string_util.c \ src/tag.c src/tag_pool.c \ src/audio_check.c \ src/audio_format.c \ @@ -1030,7 +1032,7 @@ test_run_output_LDADD = $(MPD_LIBS) \ $(OUTPUT_LIBS) \ $(GLIB_LIBS) test_run_output_SOURCES = test/run_output.c \ - src/conf.c src/tokenizer.c src/utils.c src/log.c \ + src/conf.c src/tokenizer.c src/utils.c src/string_util.c src/log.c \ src/audio_check.c \ src/audio_format.c \ src/audio_parser.c \ @@ -1066,7 +1068,7 @@ test_read_mixer_LDADD = $(MPD_LIBS) \ $(OUTPUT_LIBS) \ $(GLIB_LIBS) test_read_mixer_SOURCES = test/read_mixer.c \ - src/conf.c src/tokenizer.c src/utils.c src/log.c \ + src/conf.c src/tokenizer.c src/utils.c src/string_util.c src/log.c \ src/mixer_control.c src/mixer_api.c \ src/filter_plugin.c \ src/filter/volume_filter_plugin.c \ diff --git a/src/archive_list.c b/src/archive_list.c index 2656726b5..648f68575 100644 --- a/src/archive_list.c +++ b/src/archive_list.c @@ -20,7 +20,7 @@ #include "config.h" #include "archive_list.h" #include "archive_plugin.h" -#include "utils.h" +#include "string_util.h" #include "archive/bz2_archive_plugin.h" #include "archive/iso9660_archive_plugin.h" #include "archive/zzip_archive_plugin.h" diff --git a/src/conf.c b/src/conf.c index 705942085..3310da17e 100644 --- a/src/conf.c +++ b/src/conf.c @@ -20,6 +20,7 @@ #include "config.h" #include "conf.h" #include "utils.h" +#include "string_util.h" #include "tokenizer.h" #include "path.h" #include "glib_compat.h" diff --git a/src/decoder_plugin.c b/src/decoder_plugin.c index 062dad364..62f85a645 100644 --- a/src/decoder_plugin.c +++ b/src/decoder_plugin.c @@ -19,7 +19,7 @@ #include "config.h" #include "decoder_plugin.h" -#include "utils.h" +#include "string_util.h" #include <assert.h> diff --git a/src/playlist_list.c b/src/playlist_list.c index 019654bfc..02d650c05 100644 --- a/src/playlist_list.c +++ b/src/playlist_list.c @@ -31,7 +31,7 @@ #include "playlist/flac_playlist_plugin.h" #include "input_stream.h" #include "uri.h" -#include "utils.h" +#include "string_util.h" #include "conf.h" #include "glib_compat.h" #include "mpd_error.h" diff --git a/src/string_util.c b/src/string_util.c new file mode 100644 index 000000000..b93292854 --- /dev/null +++ b/src/string_util.c @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2003-2010 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include "string_util.h" + +#include <glib.h> + +#include <assert.h> + +bool +string_array_contains(const char *const* haystack, const char *needle) +{ + assert(haystack != NULL); + assert(needle != NULL); + + for (; *haystack != NULL; ++haystack) + if (g_ascii_strcasecmp(*haystack, needle) == 0) + return true; + + return false; +} diff --git a/src/string_util.h b/src/string_util.h new file mode 100644 index 000000000..df8ceeef3 --- /dev/null +++ b/src/string_util.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2003-2010 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_STRING_UTIL_H +#define MPD_STRING_UTIL_H + +#include <stdbool.h> + +/** + * Checks whether a string array contains the specified string. + * + * @param haystack a NULL terminated list of strings + * @param needle the string to search for; the comparison is + * case-insensitive for ASCII characters + * @return true if found + */ +bool +string_array_contains(const char *const* haystack, const char *needle); + +#endif diff --git a/src/utils.c b/src/utils.c index 53494cc5d..39f4fe4d1 100644 --- a/src/utils.c +++ b/src/utils.c @@ -101,16 +101,3 @@ char *parsePath(char *path) } #endif } - -bool -string_array_contains(const char *const* haystack, const char *needle) -{ - assert(haystack != NULL); - assert(needle != NULL); - - for (; *haystack != NULL; ++haystack) - if (g_ascii_strcasecmp(*haystack, needle) == 0) - return true; - - return false; -} diff --git a/src/utils.h b/src/utils.h index 629056637..3941643dc 100644 --- a/src/utils.h +++ b/src/utils.h @@ -33,15 +33,4 @@ char *parsePath(char *path); -/** - * Checks whether a string array contains the specified string. - * - * @param haystack a NULL terminated list of strings - * @param needle the string to search for; the comparison is - * case-insensitive for ASCII characters - * @return true if found - */ -bool -string_array_contains(const char *const* haystack, const char *needle); - #endif |