ls: renamed functions, no CamelCase
This commit is contained in:
parent
6a008b52d1
commit
45597cc571
@ -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;
|
||||
|
@ -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);
|
||||
|
11
src/ls.c
11
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), '.');
|
||||
|
||||
|
18
src/ls.h
18
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);
|
||||
|
||||
void printRemoteUrlHandlers(struct client *client);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
const char *uri_get_suffix(const char *utf8file);
|
||||
|
||||
#endif
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user