]> git.sur5r.net Git - bacula/bacula/commitdiff
- Add a .dir command that separates arguments with commas. It
authorKern Sibbald <kern@sibbald.com>
Wed, 12 Oct 2005 15:36:56 +0000 (15:36 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 12 Oct 2005 15:36:56 +0000 (15:36 +0000)
  is intended to be used in the tree routines to get a
  machine readable output for GUIs like wx-console.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2435 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/kes-1.37
bacula/src/dird/ua_tree.c

index a74f4dfd4fba07019456e462effda4332c03129e..a364ff937d933d24359cc9a0eeb22ff23eb18844 100644 (file)
@@ -50,6 +50,7 @@ Document:
 - Does WildFile match against full name?  Doc.
 
 For 1.39:
+  of column positions in wx-console.
 - Close STDOUT if debug_level == 0
 - Add recycle event.
 - Add scratch pool event.
@@ -1494,4 +1495,5 @@ Block Position: 0
   chaos.
 - Run the regression scripts on Solaris and FreeBSD
 -  Figure out how to package gui, and rescue programs.
+- Add a .dir command to restore tree code to eliminate the problem
 
index d7279c2f0684ef9b0587f54aae838f5046152fb8..8cd59c918aea77c72dcedba76abbb065e4e434fb 100644 (file)
@@ -5,6 +5,9 @@ General:
 
 Changes to 1.37.41:
 12Oct05
+- Add a .dir command that separates arguments with commas. It
+  is intended to be used in the tree routines to get a 
+  machine readable output for GUIs like wx-console.
 - Make configure set dvd-handler to have execute permission.
 - Install dvd-handler as is done for other dvd-xxx scripts.
 - In block.c call dvd_write_part() to write last part rather
index ed999b7991ca9ada15aa6abfb746a73b961c8814..ed9c3364fe59db849f4b2bb2ebc5750569662eee 100644 (file)
@@ -42,6 +42,7 @@ static int findcmd(UAContext *ua, TREE_CTX *tree);
 static int lscmd(UAContext *ua, TREE_CTX *tree);
 static int lsmarkcmd(UAContext *ua, TREE_CTX *tree);
 static int dircmd(UAContext *ua, TREE_CTX *tree);
+static int dot_dircmd(UAContext *ua, TREE_CTX *tree);
 static int estimatecmd(UAContext *ua, TREE_CTX *tree);
 static int helpcmd(UAContext *ua, TREE_CTX *tree);
 static int cdcmd(UAContext *ua, TREE_CTX *tree);
@@ -57,6 +58,7 @@ static struct cmdstruct commands[] = {
  { N_("cd"),         cdcmd,        _("change current directory")},
  { N_("count"),      countcmd,     _("count marked files in and below the cd")},
  { N_("dir"),        dircmd,       _("long list current directory, wildcards allowed")},
+ { N_(".dir"),       dot_dircmd,   _("long list current directory, wildcards allowed")},
  { N_("done"),       donecmd,      _("leave file selection mode")},
  { N_("estimate"),   estimatecmd,  _("estimate restore size")},
  { N_("exit"),       donecmd,      _("same as done command")},
@@ -64,7 +66,7 @@ static struct cmdstruct commands[] = {
  { N_("help"),       helpcmd,      _("print help")},
  { N_("ls"),         lscmd,        _("list current directory, wildcards allowed")},
  { N_("lsmark"),     lsmarkcmd,    _("list the marked files in and below the cd")},
- { N_("mark"),       markcmd,      _("mark dir/file to be restored recursively in dirs")},
+ { N_("mark"),       markcmd,      _("mark dir/file to be restored recursively, wildcards allowed")},
  { N_("markdir"),    markdircmd,   _("mark directory name to be restored (no files)")},
  { N_("pwd"),        pwdcmd,       _("print current working directory")},
  { N_("unmark"),     unmarkcmd,    _("unmark dir/file to be restored recursively in dir")},
@@ -461,7 +463,9 @@ extern char *getgroup(gid_t gid, char *name, int len);
 /*
  * This is actually the long form used for "dir"
  */
-static void ls_output(char *buf, const char *fname, const char *tag, struct stat *statp)
+static void ls_output(char *buf, const char *fname, const char *tag, 
+                      struct stat *statp, bool dot_cmd) 
+                    
 {
    char *p;
    const char *f;
@@ -470,27 +474,41 @@ static void ls_output(char *buf, const char *fname, const char *tag, struct stat
    int n;
 
    p = encode_mode(statp->st_mode, buf);
-   n = sprintf(p, "  %2d ", (uint32_t)statp->st_nlink);
-   p += n;
-   n = sprintf(p, "%-8.8s %-8.8s", getuser(statp->st_uid, en1, sizeof(en1)),
-               getgroup(statp->st_gid, en2, sizeof(en2)));
-   p += n;
-   n = sprintf(p, "%10.10s  ", edit_uint64(statp->st_size, ec1));
-   p += n;
-   p = encode_time(statp->st_ctime, p);
-   *p++ = ' ';
-   *p++ = *tag;
+   if (dot_cmd) {
+      *p++ = ',';
+      n = sprintf(p, "%d,", (uint32_t)statp->st_nlink);
+      p += n;
+      n = sprintf(p, "%s,%s,", getuser(statp->st_uid, en1, sizeof(en1)),
+                  getgroup(statp->st_gid, en2, sizeof(en2)));
+      p += n;
+      n = sprintf(p, "%s,", edit_uint64(statp->st_size, ec1));
+      p += n;
+      p = encode_time(statp->st_ctime, p);
+      *p++ = ',';
+      *p++ = *tag;
+      *p++ = ',';
+   } else {
+      n = sprintf(p, "  %2d ", (uint32_t)statp->st_nlink);
+      p += n;
+      n = sprintf(p, "%-8.8s %-8.8s", getuser(statp->st_uid, en1, sizeof(en1)),
+                  getgroup(statp->st_gid, en2, sizeof(en2)));
+      p += n;
+      n = sprintf(p, "%10.10s  ", edit_uint64(statp->st_size, ec1));
+      p += n;
+      p = encode_time(statp->st_ctime, p);
+      *p++ = ' ';
+      *p++ = *tag;
+   }
    for (f=fname; *f; ) {
       *p++ = *f++;
    }
    *p = 0;
 }
 
-
 /*
  * Like ls command, but give more detail on each file
  */
-static int dircmd(UAContext *ua, TREE_CTX *tree)
+static int do_dircmd(UAContext *ua, TREE_CTX *tree, bool dot_cmd)
 {
    TREE_NODE *node;
    FILE_DBR fdbr;
@@ -540,13 +558,23 @@ static int dircmd(UAContext *ua, TREE_CTX *tree)
             /* Something went wrong getting attributes -- print name */
             memset(&statp, 0, sizeof(statp));
          }
-         ls_output(buf, cwd, tag, &statp);
+         ls_output(buf, cwd, tag, &statp, dot_cmd);
          bsendmsg(ua, "%s\n", buf);
       }
    }
    return 1;
 }
 
+int dot_dircmd(UAContext *ua, TREE_CTX *tree)
+{
+   return do_dircmd(ua, tree, true/*dot command*/);
+}
+
+static int dircmd(UAContext *ua, TREE_CTX *tree)
+{
+   return do_dircmd(ua, tree, false/*not dot command*/);
+}
+
 
 static int estimatecmd(UAContext *ua, TREE_CTX *tree)
 {
@@ -593,7 +621,10 @@ static int helpcmd(UAContext *ua, TREE_CTX *tree)
 
    bsendmsg(ua, _("  Command    Description\n  =======    ===========\n"));
    for (i=0; i<comsize; i++) {
-      bsendmsg(ua, "  %-10s %s\n", _(commands[i].key), _(commands[i].help));
+      /* List only non-dot commands */
+      if (commands[i].key[0] != '.') {
+         bsendmsg(ua, "  %-10s %s\n", _(commands[i].key), _(commands[i].help));
+      }
    }
    bsendmsg(ua, "\n");
    return 1;