aboutsummaryrefslogtreecommitdiffstats
path: root/src/ls.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c61
1 files changed, 8 insertions, 53 deletions
diff --git a/src/ls.c b/src/ls.c
index b5cb5cfeb..f0f403f44 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -32,7 +32,7 @@ static const char *remoteUrlPrefixes[] = {
NULL
};
-int printRemoteUrlHandlers(struct client *client)
+void printRemoteUrlHandlers(struct client *client)
{
const char **prefixes = remoteUrlPrefixes;
@@ -40,77 +40,32 @@ int printRemoteUrlHandlers(struct client *client)
client_printf(client, "handler: %s\n", *prefixes);
prefixes++;
}
-
- return 0;
}
-int isValidRemoteUtf8Url(const char *utf8url)
+bool uri_has_scheme(const char *uri)
{
- int ret = 0;
- const char *temp;
-
- switch (isRemoteUrl(utf8url)) {
- case 1:
- ret = 1;
- temp = utf8url;
- while (*temp) {
- if ((*temp >= 'a' && *temp <= 'z') ||
- (*temp >= 'A' && *temp <= 'Z') ||
- (*temp >= '0' && *temp <= '9') ||
- *temp == '$' ||
- *temp == '-' ||
- *temp == '.' ||
- *temp == '+' ||
- *temp == '!' ||
- *temp == '*' ||
- *temp == '\'' ||
- *temp == '(' ||
- *temp == ')' ||
- *temp == ',' ||
- *temp == '%' ||
- *temp == '/' ||
- *temp == ':' ||
- *temp == '?' ||
- *temp == ';' || *temp == '&' || *temp == '=') {
- } else {
- ret = 1;
- break;
- }
- temp++;
- }
- break;
- }
-
- return ret;
+ return strstr(uri, "://") != NULL;
}
-int isRemoteUrl(const char *url)
+bool isRemoteUrl(const char *url)
{
- int count = 0;
const char **urlPrefixes = remoteUrlPrefixes;
while (*urlPrefixes) {
- count++;
if (g_str_has_prefix(url, *urlPrefixes))
- return count;
+ return true;
urlPrefixes++;
}
- return 0;
+ return false;
}
/* suffixes should be ascii only characters */
const char *getSuffix(const char *utf8file)
{
- const char *ret = NULL;
-
- while (*utf8file) {
- if (*utf8file == '.')
- ret = utf8file + 1;
- utf8file++;
- }
+ const char *dot = strrchr(g_basename(utf8file), '.');
- return ret;
+ return dot != NULL ? dot + 1 : NULL;
}
const struct decoder_plugin *