aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-04 17:46:42 +0100
committerMax Kellermann <max@duempel.org>2009-01-04 17:46:42 +0100
commit45597cc57171484bd59a4ad8f64434090835f93b (patch)
treec2893a1aa9e714f2e71de919bf8ad9572ec4c252 /src
parent6a008b52d1004f56182911f2a635136d0d097918 (diff)
ls: renamed functions, no CamelCase
Diffstat (limited to 'src')
-rw-r--r--src/command.c8
-rw-r--r--src/decoder_thread.c4
-rw-r--r--src/ls.c11
-rw-r--r--src/ls.h18
-rw-r--r--src/song.c4
-rw-r--r--src/update.c2
6 files changed, 29 insertions, 18 deletions
diff --git a/src/command.c b/src/command.c
index 1d0f14da..19aeaba3 100644
--- a/src/command.c
+++ b/src/command.c
@@ -285,7 +285,7 @@ handle_urlhandlers(struct client *client,
{
if (client_get_uid(client) > 0)
client_puts(client, "handler: file://\n");
- printRemoteUrlHandlers(client);
+ print_supported_uri_schemes(client);
return COMMAND_RETURN_OK;
}
@@ -462,7 +462,7 @@ handle_add(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
}
if (uri_has_scheme(uri)) {
- if (!isRemoteUrl(uri)) {
+ if (!uri_supported_scheme(uri)) {
command_error(client, ACK_ERROR_NO_EXIST,
"unsupported URI scheme");
return COMMAND_RETURN_ERROR;
@@ -497,7 +497,7 @@ handle_addid(struct client *client, int argc, char *argv[])
&added_id);
#endif
} else {
- if (uri_has_scheme(uri) && !isRemoteUrl(uri)) {
+ if (uri_has_scheme(uri) && !uri_supported_scheme(uri)) {
command_error(client, ACK_ERROR_NO_EXIST,
"unsupported URI scheme");
return COMMAND_RETURN_ERROR;
@@ -1258,7 +1258,7 @@ handle_playlistadd(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
enum playlist_result result;
if (uri_has_scheme(uri)) {
- if (!isRemoteUrl(uri)) {
+ if (!uri_supported_scheme(uri)) {
command_error(client, ACK_ERROR_NO_EXIST,
"unsupported URI scheme");
return COMMAND_RETURN_ERROR;
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index e6e52176..061048d9 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -142,7 +142,7 @@ static void decoder_run_song(const struct song *song, const char *uri)
/* if that fails, try suffix matching the URL: */
if (plugin == NULL) {
- const char *s = getSuffix(uri);
+ const char *s = uri_get_suffix(uri);
next = 0;
while ((plugin = decoder_plugin_from_suffix(s, next++))) {
if (plugin->stream_decode == NULL)
@@ -169,7 +169,7 @@ static void decoder_run_song(const struct song *song, const char *uri)
}
} else {
unsigned int next = 0;
- const char *s = getSuffix(uri);
+ const char *s = uri_get_suffix(uri);
while ((plugin = decoder_plugin_from_suffix(s, next++))) {
if (plugin->file_decode != NULL) {
input_stream_close(&input_stream);
diff --git a/src/ls.c b/src/ls.c
index 5be3f7b7..039695d2 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -20,6 +20,7 @@
#include "client.h"
#include "config.h"
+#include <assert.h>
#include <string.h>
static const char *remoteUrlPrefixes[] = {
@@ -29,7 +30,7 @@ static const char *remoteUrlPrefixes[] = {
NULL
};
-void printRemoteUrlHandlers(struct client *client)
+void print_supported_uri_schemes(struct client *client)
{
const char **prefixes = remoteUrlPrefixes;
@@ -44,12 +45,14 @@ bool uri_has_scheme(const char *uri)
return strstr(uri, "://") != NULL;
}
-bool isRemoteUrl(const char *url)
+bool uri_supported_scheme(const char *uri)
{
const char **urlPrefixes = remoteUrlPrefixes;
+ assert(uri_has_scheme(uri));
+
while (*urlPrefixes) {
- if (g_str_has_prefix(url, *urlPrefixes))
+ if (g_str_has_prefix(uri, *urlPrefixes))
return true;
urlPrefixes++;
}
@@ -58,7 +61,7 @@ bool isRemoteUrl(const char *url)
}
/* suffixes should be ascii only characters */
-const char *getSuffix(const char *utf8file)
+const char *uri_get_suffix(const char *utf8file)
{
const char *dot = strrchr(g_basename(utf8file), '.');
diff --git a/src/ls.h b/src/ls.h
index 62777d9e..82a77ec1 100644
--- a/src/ls.h
+++ b/src/ls.h
@@ -21,19 +21,27 @@
#include <stdbool.h>
-struct stat;
struct client;
-const char *getSuffix(const char *utf8file);
-
/**
* Checks whether the specified URI has a schema in the form
* "scheme://".
*/
bool uri_has_scheme(const char *uri);
-bool isRemoteUrl(const char *url);
+/**
+ * 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
+ * uri_has_scheme() first.
+ */
+bool uri_supported_scheme(const char *url);
+
+/**
+ * Send a list of supported URI schemes to the client. This is the
+ * response to the "urlhandlers" command.
+ */
+void print_supported_uri_schemes(struct client *client);
-void printRemoteUrlHandlers(struct client *client);
+const char *uri_get_suffix(const char *utf8file);
#endif
diff --git a/src/song.c b/src/song.c
index e89b2ac8..f5685389 100644
--- a/src/song.c
+++ b/src/song.c
@@ -110,7 +110,7 @@ song_file_update(struct song *song)
/* check if there's a suffix and a plugin */
- suffix = getSuffix(song->url);
+ suffix = uri_get_suffix(song->url);
if (suffix == NULL)
return false;
@@ -156,7 +156,7 @@ song_file_update_inarchive(struct song *song)
/* check if there's a suffix and a plugin */
- suffix = getSuffix(song->url);
+ suffix = uri_get_suffix(song->url);
if (suffix == NULL)
return false;
diff --git a/src/update.c b/src/update.c
index 72fee394..daf658e6 100644
--- a/src/update.c
+++ b/src/update.c
@@ -346,7 +346,7 @@ static void
update_regular_file(struct directory *directory,
const char *name, const struct stat *st)
{
- const char *suffix = getSuffix(name);
+ const char *suffix = uri_get_suffix(name);
if (suffix == NULL)
return;