added options for extended list flags and changed version output

Wed, 16 Mar 2016 14:32:55 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 16 Mar 2016 14:32:55 +0100
changeset 213
cd870d5f8659
parent 212
01e80c7cfe96
child 214
7961460e0d9e

added options for extended list flags and changed version output

dav list -e indicates resource locks and the apache executable property

dav/main.c file | annotate | diff | comparison | revisions
dav/optparser.c file | annotate | diff | comparison | revisions
--- a/dav/main.c	Tue Mar 15 16:47:22 2016 +0100
+++ b/dav/main.c	Wed Mar 16 14:32:55 2016 +0100
@@ -69,6 +69,7 @@
     xmlGenericErrorFunc fnc = xmlerrorfnc;
     initGenericErrorDefaultFunc(&fnc);
     ctx = dav_context_new();
+    dav_add_namespace(ctx, "apache", "http://apache.org/dav/props/");
     load_config(ctx);
     printxmlerror = 0;
 #ifdef DO_THE_TEST
@@ -135,11 +136,7 @@
     } else if(!strcasecmp(cmd, "list-repositories")) {
         ret = list_repositories();
     } else if(!strcasecmp(cmd, "version") || !strcasecmp(cmd, "-version") || !strcasecmp(cmd, "--version")) {
-#ifdef DEBUG
-        fprintf(stderr, "dav %s unstable\n", DAV_VERSION);
-#else
         fprintf(stderr, "dav %s\n", DAV_VERSION);
-#endif
     } else {
         print_usage(argv[0]);
     }
@@ -156,7 +153,7 @@
 void print_usage(char *cmd) {
     fprintf(stderr, "Usage: %s command [options] arguments...\n\n", cmd);
     fprintf(stderr, "Commands:\n");
-    fprintf(stderr, "        list [-altpcR] [-u <date>] <url>\n");
+    fprintf(stderr, "        list [-altepcR] [-u <date>] <url>\n");
     fprintf(
             stderr,
             "        get [-pcR] [-o <file>] [-u <date>] <url>\n");
@@ -192,9 +189,11 @@
     fprintf(stderr, "        -a         show all files\n");
     fprintf(stderr, "        -l         print resources in long list format\n");
     fprintf(stderr, "        -t         print content type\n");
+    fprintf(stderr, "        -e         show extended flags\n");
     fprintf(stderr, "        -O         override resources\n");
     fprintf(stderr, "        -L <lock>  specificy lock token\n");
     fprintf(stderr, "        -n <uri>   specify namespace uri\n");
+    fprintf(stderr, "        -N         disable authentication and key input (all commands)\n");
     fprintf(stderr, "        -i         disable cert verification (all commands)\n");
     fprintf(stderr, "        -v         verbose output (all commands)\n");
     fprintf(stderr, "\n");
@@ -368,7 +367,7 @@
     while(ret != 0) {
         ls = dav_query(
                 sn,
-                "select `idav:crypto-name`,`idav:crypto-key`,D:lockdiscovery from %s with depth = %d where lastmodified > %t order by iscollection desc, name",
+                "select `idav:crypto-name`,`idav:crypto-key`,D:lockdiscovery,apache:executable from %s with depth = %d where lastmodified > %t order by iscollection desc, name",
                 path,
                 depth,
                 t);
@@ -385,7 +384,7 @@
         
         // parameters
         void (*print_func)(DavResource*, CmdArgs *);
-        if(cmd_getoption(a, "list")) {
+        if(cmd_getoption(a, "list") || cmd_getoption(a, "extended")) {
             print_func = ls_print_list_elm;
         } else {
             print_func = ls_print_elm;
@@ -506,7 +505,6 @@
     
     char flags[16];
     memset(flags, '-', 15);
-    flags[3] = '\0';
     
     int type_width = 0;
     char *type = res->contenttype;
@@ -522,8 +520,21 @@
     if(keyprop) {
         flags[1] = 'c';
     }
-    if(dav_get_property(res, "D:lockdiscovery")) {
-        flags[2] = 'l';
+    
+    if(cmd_getoption(a, "extended")) {
+        flags[6] = '\0';
+        if(dav_get_property(res, "D:lockdiscovery")) {
+            flags[2] = 'l';
+        }
+        char *executable = dav_get_property_ns(
+                res,
+                "http://apache.org/dav/props/",
+                "executable");
+        if(executable && util_getboolean(executable)) {
+            flags[3] = 'x';
+        }
+    } else {
+        flags[2] = '\0';
     }
     
     if(cmd_getoption(a, "type")) {
--- a/dav/optparser.c	Tue Mar 15 16:47:22 2016 +0100
+++ b/dav/optparser.c	Wed Mar 16 14:32:55 2016 +0100
@@ -109,10 +109,14 @@
                         ucx_map_cstr_put(a->options, "insecure", NOARG);
                         break;
                     }
-                    case 'x': {
+                    case 'N': {
                         ucx_map_cstr_put(a->options, "noinput", NOARG);
                         break;
                     }
+                    case 'e': {
+                        ucx_map_cstr_put(a->options, "extended", NOARG);
+                        break;
+                    }
                     case 'o': {
                         if(!option) {
                             option = "output";

mercurial