uri: convert to C++

This commit is contained in:
Max Kellermann
2013-04-08 23:30:21 +02:00
parent f84e288ad7
commit 7ec1121cc8
26 changed files with 42 additions and 96 deletions

View File

@@ -26,7 +26,7 @@
#include "CommandError.hxx"
#include "ClientInternal.hxx"
#include "tag.h"
#include "uri.h"
#include "util/UriUtil.hxx"
#include "SongFilter.hxx"
#include "protocol/Result.hxx"

View File

@@ -31,10 +31,10 @@
#include "tag.h"
#include "InputStream.hxx"
#include "DecoderList.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "replay_gain_ape.h"
#include "uri.h"
}
#include <glib.h>

View File

@@ -22,10 +22,7 @@
#include "InputRegistry.hxx"
#include "InputPlugin.hxx"
#include "input/RewindInputPlugin.hxx"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include <glib.h>
#include <assert.h>

View File

@@ -33,9 +33,9 @@
#include "protocol/Result.hxx"
#include "ls.hxx"
#include "Volume.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
#include "stats.h"
}

View File

@@ -21,12 +21,9 @@
#include "PlaylistAny.hxx"
#include "PlaylistMapper.hxx"
#include "PlaylistRegistry.hxx"
#include "util/UriUtil.hxx"
#include "input_stream.h"
extern "C" {
#include "uri.h"
}
#include <assert.h>
static struct playlist_provider *

View File

@@ -32,10 +32,7 @@
#include "protocol/Result.hxx"
#include "ls.hxx"
#include "Playlist.hxx"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include <assert.h>
#include <stdlib.h>

View File

@@ -26,9 +26,9 @@
#include "config.h"
#include "Playlist.hxx"
#include "PlayerControl.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "uri.h"
#include "song.h"
}

View File

@@ -32,10 +32,7 @@
#include "Idle.hxx"
#include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include <assert.h>
#include <sys/types.h>

View File

@@ -23,10 +23,7 @@
#include "PlaylistRegistry.hxx"
#include "Mapper.hxx"
#include "fs/Path.hxx"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include <assert.h>

View File

@@ -32,10 +32,7 @@
#include "playlist/CuePlaylistPlugin.hxx"
#include "playlist/EmbeddedCuePlaylistPlugin.hxx"
#include "input_stream.h"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include "string_util.h"
#include "conf.h"

View File

@@ -26,10 +26,7 @@
#include "Idle.hxx"
#include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include <glib.h>

View File

@@ -25,10 +25,10 @@
#include "ls.hxx"
#include "tag.h"
#include "fs/Path.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "song.h"
#include "uri.h"
}
#include <glib.h>

View File

@@ -31,10 +31,7 @@
#include "protocol/ArgParser.hxx"
#include "protocol/Result.hxx"
#include "ls.hxx"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include <string.h>

View File

@@ -25,10 +25,7 @@
#include "DatabasePlugin.hxx"
#include "DatabaseGlue.hxx"
#include "TextFile.hxx"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include <stdlib.h>

View File

@@ -25,10 +25,7 @@
#include "TagPrint.hxx"
#include "Mapper.hxx"
#include "Client.hxx"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include <glib.h>

View File

@@ -21,9 +21,9 @@
extern "C" {
#include "song.h"
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include "Directory.hxx"
#include "Mapper.hxx"
#include "fs/Path.hxx"

View File

@@ -19,11 +19,7 @@
#include "config.h"
#include "TagFile.hxx"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include "DecoderList.hxx"
#include "decoder_plugin.h"
#include "input_stream.h"

View File

@@ -34,10 +34,7 @@
#include "conf.h"
#include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include <glib.h>

View File

@@ -22,10 +22,7 @@
#include "decoder_api.h"
#include "audio_check.h"
#include "tag_handler.h"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include <glib.h>
#include <assert.h>

View File

@@ -23,10 +23,10 @@
#include "decoder_api.h"
#include "InputStream.hxx"
#include "OggCodec.hxx"
#include "util/UriUtil.hxx"
extern "C" {
#include "audio_check.h"
#include "uri.h"
}
#include "tag_handler.h"

View File

@@ -19,11 +19,7 @@
#include "config.h"
#include "ls.hxx"
extern "C" {
#include "uri.h"
}
#include "util/UriUtil.hxx"
#include "Client.hxx"
#include <glib.h>

View File

@@ -21,7 +21,6 @@
#include "PlsPlaylistPlugin.hxx"
#include "MemoryPlaylistProvider.hxx"
#include "input_stream.h"
#include "uri.h"
#include "song.h"
#include "tag.h"

View File

@@ -21,7 +21,6 @@
#include "XspfPlaylistPlugin.hxx"
#include "MemoryPlaylistProvider.hxx"
#include "input_stream.h"
#include "uri.h"
#include "tag.h"
#include <glib.h>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "uri.h"
#include "UriUtil.hxx"
#include <glib.h>
@@ -27,7 +26,7 @@
bool uri_has_scheme(const char *uri)
{
return strstr(uri, "://") != NULL;
return strstr(uri, "://") != nullptr;
}
/* suffixes should be ascii only characters */
@@ -35,13 +34,13 @@ const char *
uri_get_suffix(const char *uri)
{
const char *suffix = strrchr(uri, '.');
if (suffix == NULL)
return NULL;
if (suffix == nullptr)
return nullptr;
++suffix;
if (strpbrk(suffix, "/\\") != NULL)
return NULL;
if (strpbrk(suffix, "/\\") != nullptr)
return nullptr;
return suffix;
}
@@ -58,10 +57,10 @@ verify_uri_segment(const char *p)
}
if (dots <= 2 && (*p == 0 || *p == '/'))
return NULL;
return nullptr;
q = strchr(p + 1, '/');
return q != NULL ? q : "";
return q != nullptr ? q : "";
}
bool
@@ -69,7 +68,7 @@ uri_safe_local(const char *uri)
{
while (true) {
uri = verify_uri_segment(uri);
if (uri == NULL)
if (uri == nullptr)
return false;
if (*uri == 0)
@@ -93,16 +92,16 @@ uri_remove_auth(const char *uri)
auth = uri + 8;
else
/* unrecognized URI */
return NULL;
return nullptr;
slash = strchr(auth, '/');
if (slash == NULL)
if (slash == nullptr)
slash = auth + strlen(auth);
at = memchr(auth, '@', slash - auth);
if (at == NULL)
at = (const char *)memchr(auth, '@', slash - auth);
if (at == nullptr)
/* no auth info present, do nothing */
return NULL;
return nullptr;
/* duplicate the full URI and then delete the auth
information */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,13 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_URI_H
#define MPD_URI_H
#ifndef MPD_URI_UTIL_HXX
#define MPD_URI_UTIL_HXX
#include "gcc.h"
#include <stdbool.h>
/**
* Checks whether the specified URI has a scheme in the form
* "scheme://".