ls: moved generic URI utilities to uri.c

"ls" is a bad name for a library which parses URIs.  We'll move the
rest of the "ls" library later.
This commit is contained in:
Max Kellermann 2009-02-25 16:44:06 +01:00
parent 7957fefc91
commit 6823217697
14 changed files with 82 additions and 29 deletions

View File

@ -143,6 +143,7 @@ mpd_headers = \
src/tag_print.h \
src/tag_save.h \
src/strset.h \
src/uri.h \
src/utils.h \
src/volume.h \
src/zeroconf.h src/zeroconf-internal.h \
@ -236,6 +237,7 @@ src_mpd_SOURCES = \
src/tag_print.c \
src/tag_save.c \
src/strset.c \
src/uri.c \
src/utils.c \
src/volume.c \
src/locate.c \

View File

@ -23,6 +23,7 @@
#include "playlist_save.h"
#include "queue_print.h"
#include "ls.h"
#include "uri.h"
#include "directory.h"
#include "directory_print.h"
#include "database.h"

View File

@ -20,7 +20,7 @@
#include "_ogg_common.h"
#include "config.h"
#include "ls.h"
#include "uri.h"
#ifndef HAVE_TREMOR
#include <vorbis/vorbisfile.h>

View File

@ -30,7 +30,7 @@
#include "mapper.h"
#include "path.h"
#include "log.h"
#include "ls.h"
#include "uri.h"
#include <glib.h>

View File

@ -17,6 +17,7 @@
*/
#include "ls.h"
#include "uri.h"
#include "client.h"
#include "config.h"
@ -46,11 +47,6 @@ void print_supported_uri_schemes(struct client *client)
}
}
bool uri_has_scheme(const char *uri)
{
return strstr(uri, "://") != NULL;
}
bool uri_supported_scheme(const char *uri)
{
const char **urlPrefixes = remoteUrlPrefixes;
@ -65,11 +61,3 @@ bool uri_supported_scheme(const char *uri)
return false;
}
/* suffixes should be ascii only characters */
const char *uri_get_suffix(const char *utf8file)
{
const char *dot = strrchr(g_basename(utf8file), '.');
return dot != NULL ? dot + 1 : NULL;
}

View File

@ -23,12 +23,6 @@
struct client;
/**
* Checks whether the specified URI has a schema in the form
* "scheme://".
*/
bool uri_has_scheme(const char *uri);
/**
* Checks whether the scheme of the specified URI is supported by MPD.
* It is not allowed to pass an URI without a scheme, check with
@ -42,6 +36,4 @@ bool uri_supported_scheme(const char *url);
*/
void print_supported_uri_schemes(struct client *client);
const char *uri_get_suffix(const char *utf8file);
#endif

View File

@ -25,7 +25,7 @@
#include "playlist_internal.h"
#include "player_control.h"
#include "database.h"
#include "ls.h"
#include "uri.h"
#include "song.h"
#include "idle.h"

View File

@ -21,7 +21,7 @@
#include "song.h"
#include "mapper.h"
#include "path.h"
#include "ls.h"
#include "uri.h"
#include "database.h"
#include "idle.h"

View File

@ -19,7 +19,7 @@
#include "queue_save.h"
#include "queue.h"
#include "song.h"
#include "ls.h"
#include "uri.h"
#include "database.h"
#include <stdlib.h>

View File

@ -17,7 +17,7 @@
*/
#include "song.h"
#include "ls.h"
#include "uri.h"
#include "directory.h"
#include "mapper.h"
#include "decoder_list.h"

View File

@ -21,7 +21,7 @@
#include "song.h"
#include "mapper.h"
#include "path.h"
#include "ls.h"
#include "uri.h"
#include "database.h"
#include "idle.h"
#include "conf.h"

View File

@ -21,7 +21,7 @@
#include "database.h"
#include "directory.h"
#include "song.h"
#include "ls.h"
#include "uri.h"
#include "mapper.h"
#include "path.h"
#include "decoder_list.h"

37
src/uri.c Normal file
View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2003-2009 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "uri.h"
#include <glib.h>
#include <string.h>
bool uri_has_scheme(const char *uri)
{
return strstr(uri, "://") != NULL;
}
/* suffixes should be ascii only characters */
const char *
uri_get_suffix(const char *uri)
{
const char *dot = strrchr(g_basename(uri), '.');
return dot != NULL ? dot + 1 : NULL;
}

33
src/uri.h Normal file
View File

@ -0,0 +1,33 @@
/*
* Copyright (C) 2003-2009 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MPD_URI_H
#define MPD_URI_H
#include <stdbool.h>
/**
* Checks whether the specified URI has a schema in the form
* "scheme://".
*/
bool uri_has_scheme(const char *uri);
const char *
uri_get_suffix(const char *uri);
#endif