Commit 7ec1121c authored by Max Kellermann's avatar Max Kellermann

uri: convert to C++

parent f84e288a
...@@ -99,7 +99,6 @@ mpd_headers = \ ...@@ -99,7 +99,6 @@ mpd_headers = \
src/tag_id3.h \ src/tag_id3.h \
src/tag_rva2.h \ src/tag_rva2.h \
src/tokenizer.h \ src/tokenizer.h \
src/uri.h \
src/utils.h \ src/utils.h \
src/string_util.h \ src/string_util.h \
src/timer.h \ src/timer.h \
...@@ -246,7 +245,6 @@ src_mpd_SOURCES = \ ...@@ -246,7 +245,6 @@ src_mpd_SOURCES = \
src/tokenizer.c \ src/tokenizer.c \
src/TextFile.cxx src/TextFile.hxx \ src/TextFile.cxx src/TextFile.hxx \
src/text_input_stream.c \ src/text_input_stream.c \
src/uri.c \
src/utils.c \ src/utils.c \
src/string_util.c \ src/string_util.c \
src/Volume.cxx src/Volume.hxx \ src/Volume.cxx src/Volume.hxx \
...@@ -292,6 +290,7 @@ endif ...@@ -292,6 +290,7 @@ endif
# Generic utility library # Generic utility library
libutil_a_SOURCES = \ libutil_a_SOURCES = \
src/util/UriUtil.cxx src/util/UriUtil.hxx \
src/util/Manual.hxx \ src/util/Manual.hxx \
src/util/RefCount.hxx \ src/util/RefCount.hxx \
src/util/fifo_buffer.c src/util/fifo_buffer.h \ src/util/fifo_buffer.c src/util/fifo_buffer.h \
...@@ -1088,6 +1087,7 @@ test_run_input_LDADD = \ ...@@ -1088,6 +1087,7 @@ test_run_input_LDADD = \
$(INPUT_LIBS) \ $(INPUT_LIBS) \
$(ARCHIVE_LIBS) \ $(ARCHIVE_LIBS) \
libconf.a \ libconf.a \
libutil.a \
libevent.a \ libevent.a \
libfs.a \ libfs.a \
$(GLIB_LIBS) $(GLIB_LIBS)
...@@ -1096,7 +1096,6 @@ test_run_input_SOURCES = test/run_input.cxx \ ...@@ -1096,7 +1096,6 @@ test_run_input_SOURCES = test/run_input.cxx \
src/IOThread.cxx \ src/IOThread.cxx \
src/tokenizer.c src/utils.c src/string_util.c\ src/tokenizer.c src/utils.c src/string_util.c\
src/Tag.cxx src/TagNames.c src/TagPool.cxx src/TagSave.cxx \ src/Tag.cxx src/TagNames.c src/TagPool.cxx src/TagSave.cxx \
src/uri.c \
src/fd_util.c src/fd_util.c
if ENABLE_ARCHIVE if ENABLE_ARCHIVE
...@@ -1105,6 +1104,7 @@ test_visit_archive_LDADD = \ ...@@ -1105,6 +1104,7 @@ test_visit_archive_LDADD = \
$(INPUT_LIBS) \ $(INPUT_LIBS) \
$(ARCHIVE_LIBS) \ $(ARCHIVE_LIBS) \
libconf.a \ libconf.a \
libutil.a \
libevent.a \ libevent.a \
libfs.a \ libfs.a \
$(GLIB_LIBS) $(GLIB_LIBS)
...@@ -1113,7 +1113,6 @@ test_visit_archive_SOURCES = test/visit_archive.cxx \ ...@@ -1113,7 +1113,6 @@ test_visit_archive_SOURCES = test/visit_archive.cxx \
src/InputStream.cxx \ src/InputStream.cxx \
src/tokenizer.c src/utils.c src/string_util.c \ src/tokenizer.c src/utils.c src/string_util.c \
src/Tag.cxx src/TagNames.c src/TagPool.cxx \ src/Tag.cxx src/TagNames.c src/TagPool.cxx \
src/uri.c \
src/fd_util.c src/fd_util.c
if ENABLE_DESPOTIFY if ENABLE_DESPOTIFY
...@@ -1136,7 +1135,6 @@ test_dump_text_file_SOURCES = test/dump_text_file.cxx \ ...@@ -1136,7 +1135,6 @@ test_dump_text_file_SOURCES = test/dump_text_file.cxx \
src/tokenizer.c src/utils.c src/string_util.c\ src/tokenizer.c src/utils.c src/string_util.c\
src/Tag.cxx src/TagNames.c src/TagPool.cxx \ src/Tag.cxx src/TagNames.c src/TagPool.cxx \
src/text_input_stream.c \ src/text_input_stream.c \
src/uri.c \
src/fd_util.c src/fd_util.c
test_dump_playlist_LDADD = \ test_dump_playlist_LDADD = \
...@@ -1155,7 +1153,6 @@ test_dump_playlist_SOURCES = test/dump_playlist.cxx \ ...@@ -1155,7 +1153,6 @@ test_dump_playlist_SOURCES = test/dump_playlist.cxx \
$(DECODER_SRC) \ $(DECODER_SRC) \
src/IOThread.cxx \ src/IOThread.cxx \
src/tokenizer.c src/utils.c src/string_util.c\ src/tokenizer.c src/utils.c src/string_util.c\
src/uri.c \
src/Song.cxx src/Tag.cxx src/TagNames.c src/TagPool.cxx src/TagSave.cxx \ src/Song.cxx src/Tag.cxx src/TagNames.c src/TagPool.cxx src/TagSave.cxx \
src/tag_handler.c src/TagFile.cxx \ src/tag_handler.c src/TagFile.cxx \
src/audio_check.c src/pcm_buffer.c \ src/audio_check.c src/pcm_buffer.c \
...@@ -1186,7 +1183,6 @@ test_run_decoder_SOURCES = test/run_decoder.cxx \ ...@@ -1186,7 +1183,6 @@ test_run_decoder_SOURCES = test/run_decoder.cxx \
src/tokenizer.c src/utils.c src/string_util.c \ src/tokenizer.c src/utils.c src/string_util.c \
src/Tag.cxx src/TagNames.c src/TagPool.cxx src/tag_handler.c \ src/Tag.cxx src/TagNames.c src/TagPool.cxx src/tag_handler.c \
src/ReplayGainInfo.cxx \ src/ReplayGainInfo.cxx \
src/uri.c \
src/fd_util.c \ src/fd_util.c \
src/audio_check.c \ src/audio_check.c \
src/audio_format.c \ src/audio_format.c \
...@@ -1211,7 +1207,6 @@ test_read_tags_SOURCES = test/read_tags.cxx \ ...@@ -1211,7 +1207,6 @@ test_read_tags_SOURCES = test/read_tags.cxx \
src/tokenizer.c src/utils.c src/string_util.c \ src/tokenizer.c src/utils.c src/string_util.c \
src/Tag.cxx src/TagNames.c src/TagPool.cxx src/tag_handler.c \ src/Tag.cxx src/TagNames.c src/TagPool.cxx src/tag_handler.c \
src/ReplayGainInfo.cxx \ src/ReplayGainInfo.cxx \
src/uri.c \
src/fd_util.c \ src/fd_util.c \
src/audio_check.c \ src/audio_check.c \
$(DECODER_SRC) $(DECODER_SRC)
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "CommandError.hxx" #include "CommandError.hxx"
#include "ClientInternal.hxx" #include "ClientInternal.hxx"
#include "tag.h" #include "tag.h"
#include "uri.h" #include "util/UriUtil.hxx"
#include "SongFilter.hxx" #include "SongFilter.hxx"
#include "protocol/Result.hxx" #include "protocol/Result.hxx"
......
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
#include "tag.h" #include "tag.h"
#include "InputStream.hxx" #include "InputStream.hxx"
#include "DecoderList.hxx" #include "DecoderList.hxx"
#include "util/UriUtil.hxx"
extern "C" { extern "C" {
#include "replay_gain_ape.h" #include "replay_gain_ape.h"
#include "uri.h"
} }
#include <glib.h> #include <glib.h>
......
...@@ -22,10 +22,7 @@ ...@@ -22,10 +22,7 @@
#include "InputRegistry.hxx" #include "InputRegistry.hxx"
#include "InputPlugin.hxx" #include "InputPlugin.hxx"
#include "input/RewindInputPlugin.hxx" #include "input/RewindInputPlugin.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include <glib.h> #include <glib.h>
#include <assert.h> #include <assert.h>
......
...@@ -33,9 +33,9 @@ ...@@ -33,9 +33,9 @@
#include "protocol/Result.hxx" #include "protocol/Result.hxx"
#include "ls.hxx" #include "ls.hxx"
#include "Volume.hxx" #include "Volume.hxx"
#include "util/UriUtil.hxx"
extern "C" { extern "C" {
#include "uri.h"
#include "stats.h" #include "stats.h"
} }
......
...@@ -21,12 +21,9 @@ ...@@ -21,12 +21,9 @@
#include "PlaylistAny.hxx" #include "PlaylistAny.hxx"
#include "PlaylistMapper.hxx" #include "PlaylistMapper.hxx"
#include "PlaylistRegistry.hxx" #include "PlaylistRegistry.hxx"
#include "util/UriUtil.hxx"
#include "input_stream.h" #include "input_stream.h"
extern "C" {
#include "uri.h"
}
#include <assert.h> #include <assert.h>
static struct playlist_provider * static struct playlist_provider *
......
...@@ -32,10 +32,7 @@ ...@@ -32,10 +32,7 @@
#include "protocol/Result.hxx" #include "protocol/Result.hxx"
#include "ls.hxx" #include "ls.hxx"
#include "Playlist.hxx" #include "Playlist.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
......
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
#include "config.h" #include "config.h"
#include "Playlist.hxx" #include "Playlist.hxx"
#include "PlayerControl.hxx" #include "PlayerControl.hxx"
#include "util/UriUtil.hxx"
extern "C" { extern "C" {
#include "uri.h"
#include "song.h" #include "song.h"
} }
......
...@@ -32,10 +32,7 @@ ...@@ -32,10 +32,7 @@
#include "Idle.hxx" #include "Idle.hxx"
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "fs/FileSystem.hxx" #include "fs/FileSystem.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include <assert.h> #include <assert.h>
#include <sys/types.h> #include <sys/types.h>
......
...@@ -23,10 +23,7 @@ ...@@ -23,10 +23,7 @@
#include "PlaylistRegistry.hxx" #include "PlaylistRegistry.hxx"
#include "Mapper.hxx" #include "Mapper.hxx"
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include <assert.h> #include <assert.h>
......
...@@ -32,10 +32,7 @@ ...@@ -32,10 +32,7 @@
#include "playlist/CuePlaylistPlugin.hxx" #include "playlist/CuePlaylistPlugin.hxx"
#include "playlist/EmbeddedCuePlaylistPlugin.hxx" #include "playlist/EmbeddedCuePlaylistPlugin.hxx"
#include "input_stream.h" #include "input_stream.h"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include "string_util.h" #include "string_util.h"
#include "conf.h" #include "conf.h"
......
...@@ -26,10 +26,7 @@ ...@@ -26,10 +26,7 @@
#include "Idle.hxx" #include "Idle.hxx"
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "fs/FileSystem.hxx" #include "fs/FileSystem.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include <glib.h> #include <glib.h>
......
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
#include "ls.hxx" #include "ls.hxx"
#include "tag.h" #include "tag.h"
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "util/UriUtil.hxx"
extern "C" { extern "C" {
#include "song.h" #include "song.h"
#include "uri.h"
} }
#include <glib.h> #include <glib.h>
......
...@@ -31,10 +31,7 @@ ...@@ -31,10 +31,7 @@
#include "protocol/ArgParser.hxx" #include "protocol/ArgParser.hxx"
#include "protocol/Result.hxx" #include "protocol/Result.hxx"
#include "ls.hxx" #include "ls.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include <string.h> #include <string.h>
......
...@@ -25,10 +25,7 @@ ...@@ -25,10 +25,7 @@
#include "DatabasePlugin.hxx" #include "DatabasePlugin.hxx"
#include "DatabaseGlue.hxx" #include "DatabaseGlue.hxx"
#include "TextFile.hxx" #include "TextFile.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include <stdlib.h> #include <stdlib.h>
......
...@@ -25,10 +25,7 @@ ...@@ -25,10 +25,7 @@
#include "TagPrint.hxx" #include "TagPrint.hxx"
#include "Mapper.hxx" #include "Mapper.hxx"
#include "Client.hxx" #include "Client.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include <glib.h> #include <glib.h>
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
extern "C" { extern "C" {
#include "song.h" #include "song.h"
#include "uri.h"
} }
#include "util/UriUtil.hxx"
#include "Directory.hxx" #include "Directory.hxx"
#include "Mapper.hxx" #include "Mapper.hxx"
#include "fs/Path.hxx" #include "fs/Path.hxx"
......
...@@ -19,11 +19,7 @@ ...@@ -19,11 +19,7 @@
#include "config.h" #include "config.h"
#include "TagFile.hxx" #include "TagFile.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include "DecoderList.hxx" #include "DecoderList.hxx"
#include "decoder_plugin.h" #include "decoder_plugin.h"
#include "input_stream.h" #include "input_stream.h"
......
...@@ -34,10 +34,7 @@ ...@@ -34,10 +34,7 @@
#include "conf.h" #include "conf.h"
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "fs/FileSystem.hxx" #include "fs/FileSystem.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include <glib.h> #include <glib.h>
......
...@@ -22,10 +22,7 @@ ...@@ -22,10 +22,7 @@
#include "decoder_api.h" #include "decoder_api.h"
#include "audio_check.h" #include "audio_check.h"
#include "tag_handler.h" #include "tag_handler.h"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include <glib.h> #include <glib.h>
#include <assert.h> #include <assert.h>
......
...@@ -23,10 +23,10 @@ ...@@ -23,10 +23,10 @@
#include "decoder_api.h" #include "decoder_api.h"
#include "InputStream.hxx" #include "InputStream.hxx"
#include "OggCodec.hxx" #include "OggCodec.hxx"
#include "util/UriUtil.hxx"
extern "C" { extern "C" {
#include "audio_check.h" #include "audio_check.h"
#include "uri.h"
} }
#include "tag_handler.h" #include "tag_handler.h"
......
...@@ -19,11 +19,7 @@ ...@@ -19,11 +19,7 @@
#include "config.h" #include "config.h"
#include "ls.hxx" #include "ls.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
}
#include "Client.hxx" #include "Client.hxx"
#include <glib.h> #include <glib.h>
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "PlsPlaylistPlugin.hxx" #include "PlsPlaylistPlugin.hxx"
#include "MemoryPlaylistProvider.hxx" #include "MemoryPlaylistProvider.hxx"
#include "input_stream.h" #include "input_stream.h"
#include "uri.h"
#include "song.h" #include "song.h"
#include "tag.h" #include "tag.h"
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "XspfPlaylistPlugin.hxx" #include "XspfPlaylistPlugin.hxx"
#include "MemoryPlaylistProvider.hxx" #include "MemoryPlaylistProvider.hxx"
#include "input_stream.h" #include "input_stream.h"
#include "uri.h"
#include "tag.h" #include "tag.h"
#include <glib.h> #include <glib.h>
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include "config.h" #include "UriUtil.hxx"
#include "uri.h"
#include <glib.h> #include <glib.h>
...@@ -27,7 +26,7 @@ ...@@ -27,7 +26,7 @@
bool uri_has_scheme(const char *uri) bool uri_has_scheme(const char *uri)
{ {
return strstr(uri, "://") != NULL; return strstr(uri, "://") != nullptr;
} }
/* suffixes should be ascii only characters */ /* suffixes should be ascii only characters */
...@@ -35,13 +34,13 @@ const char * ...@@ -35,13 +34,13 @@ const char *
uri_get_suffix(const char *uri) uri_get_suffix(const char *uri)
{ {
const char *suffix = strrchr(uri, '.'); const char *suffix = strrchr(uri, '.');
if (suffix == NULL) if (suffix == nullptr)
return NULL; return nullptr;
++suffix; ++suffix;
if (strpbrk(suffix, "/\\") != NULL) if (strpbrk(suffix, "/\\") != nullptr)
return NULL; return nullptr;
return suffix; return suffix;
} }
...@@ -58,10 +57,10 @@ verify_uri_segment(const char *p) ...@@ -58,10 +57,10 @@ verify_uri_segment(const char *p)
} }
if (dots <= 2 && (*p == 0 || *p == '/')) if (dots <= 2 && (*p == 0 || *p == '/'))
return NULL; return nullptr;
q = strchr(p + 1, '/'); q = strchr(p + 1, '/');
return q != NULL ? q : ""; return q != nullptr ? q : "";
} }
bool bool
...@@ -69,7 +68,7 @@ uri_safe_local(const char *uri) ...@@ -69,7 +68,7 @@ uri_safe_local(const char *uri)
{ {
while (true) { while (true) {
uri = verify_uri_segment(uri); uri = verify_uri_segment(uri);
if (uri == NULL) if (uri == nullptr)
return false; return false;
if (*uri == 0) if (*uri == 0)
...@@ -93,16 +92,16 @@ uri_remove_auth(const char *uri) ...@@ -93,16 +92,16 @@ uri_remove_auth(const char *uri)
auth = uri + 8; auth = uri + 8;
else else
/* unrecognized URI */ /* unrecognized URI */
return NULL; return nullptr;
slash = strchr(auth, '/'); slash = strchr(auth, '/');
if (slash == NULL) if (slash == nullptr)
slash = auth + strlen(auth); slash = auth + strlen(auth);
at = memchr(auth, '@', slash - auth); at = (const char *)memchr(auth, '@', slash - auth);
if (at == NULL) if (at == nullptr)
/* no auth info present, do nothing */ /* no auth info present, do nothing */
return NULL; return nullptr;
/* duplicate the full URI and then delete the auth /* duplicate the full URI and then delete the auth
information */ information */
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,13 +17,11 @@ ...@@ -17,13 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_URI_H #ifndef MPD_URI_UTIL_HXX
#define MPD_URI_H #define MPD_URI_UTIL_HXX
#include "gcc.h" #include "gcc.h"
#include <stdbool.h>
/** /**
* Checks whether the specified URI has a scheme in the form * Checks whether the specified URI has a scheme in the form
* "scheme://". * "scheme://".
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment