]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - aft.c
audiod: Demote severity level of command errors.
[paraslash.git] / aft.c
diff --git a/aft.c b/aft.c
index 35a53904a33a85ba484830bc43cf46ec1ae1bd98..e0bde7fc78c8365f33aa8e5aae9f751a3dabb751 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -779,18 +779,17 @@ static void write_image_items(struct para_buffer *b, struct afs_info *afsi)
 static void write_filename_items(struct para_buffer *b, const char *path,
                bool basename)
 {
-       char *val;
+       const char *slash;
 
        if (basename) {
                WRITE_STATUS_ITEM(b, SI_basename, "%s\n", path);
                return;
        }
        WRITE_STATUS_ITEM(b, SI_path, "%s\n", path);
-       val = para_basename(path);
-       WRITE_STATUS_ITEM(b, SI_basename, "%s\n", val? val : "");
-       val = para_dirname(path);
-       WRITE_STATUS_ITEM(b, SI_directory, "%s\n", val? val : "");
-       free(val);
+       slash = strrchr(path, '/');
+       WRITE_STATUS_ITEM(b, SI_basename, "%s\n", slash? slash + 1 : path);
+       WRITE_STATUS_ITEM(b, SI_directory, "%.*s\n",
+               slash? (int)(slash - path) : (int)strlen(path), path);
 }
 
 static int print_chunk_table(struct ls_data *d, struct para_buffer *b)
@@ -897,13 +896,13 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts,
                goto out;
        }
        if (opts->mode == LS_MODE_MBOX) {
-               const char *bn = para_basename(d->path);
+               const char *slash = strrchr(d->path, '/');
                para_printf(b,
                        "From foo@localhost %s\n"
                        "Received: from\nTo: bar\nFrom: a\n"
                        "Subject: %s\n\n",
                        last_played_time,
-                       bn? bn : "?");
+                       slash? slash + 1 : "?");
        }
        write_filename_items(b, d->path, lls_opt_given(r_b));
        if (lls_opt_given(r_a))
@@ -1448,7 +1447,7 @@ static int com_ls(struct command_context *cc, struct lls_parse_result *lpr)
                else if (!strcmp(val, "p") || !strcmp(val, "parser-friendly"))
                        opts->mode = LS_MODE_PARSER;
                else {
-                       ret = -E_AFT_SYNTAX;
+                       ret = -ERRNO_TO_PARA_ERROR(EINVAL);
                        goto out;
                }
        }
@@ -1479,7 +1478,7 @@ static int com_ls(struct command_context *cc, struct lls_parse_result *lpr)
                else if (!strcmp(val, "h") || !strcmp(val, "hash"))
                        opts->sorting = LS_SORT_BY_HASH;
                else {
-                       ret = -E_AFT_SYNTAX;
+                       ret = -ERRNO_TO_PARA_ERROR(EINVAL);
                        goto out;
                }
        }