From fc2c618ea4b9e100030464038938534037e982dd Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Sun, 23 Aug 2015 11:19:25 +0200 Subject: [PATCH] --list now honours --format --- ocat.c | 17 ++++++++++++++--- storage.c | 1 - 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ocat.c b/ocat.c index aaa698d..c03f2fa 100644 --- a/ocat.c +++ b/ocat.c @@ -186,10 +186,21 @@ int main(int argc, char **argv) fprintf(stderr, "%s: cannot list\n", progname); exit(2); } - js = json_stringify(json, " "); - printf("%s\n", js); + if (otype == JSON) { + js = json_stringify(json, " "); + printf("%s\n", js); + free(js); + } else { + JsonNode *f, *arr; + + if ((arr = json_find_member(json, "results")) != NULL) { // get array + json_foreach(f, arr) { + printf("%s\n", f->string_); + } + } + } + json_delete(json); - free(js); return (0); } diff --git a/storage.c b/storage.c index a67aabc..5841d04 100644 --- a/storage.c +++ b/storage.c @@ -119,7 +119,6 @@ static void ls(char *path, JsonNode *obj) struct dirent *dp; JsonNode *jarr = json_mkarray(); - printf("opendir %s\n", path); if ((dirp = opendir(path)) == NULL) { json_append_member(obj, "error", json_mkstring("Cannot open requested directory")); return;