]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_tree.c
Add full lenght time modifiers + require resource names to be unique
[bacula/bacula] / bacula / src / dird / ua_tree.c
index 67663749b59d78d7d48c84e8edda819ef9840ba6..29db4a832dd91ebddf45b2ea66909b2f23dbd3d5 100644 (file)
@@ -74,6 +74,9 @@ static struct cmdstruct commands[] = {
 void user_select_files_from_tree(TREE_CTX *tree)
 {
    char cwd[2000];
+   /* Get a new context so we don't destroy restore command args */
+   UAContext *ua = new_ua_context(tree->ua->jcr);
+   ua->UA_sock = tree->ua->UA_sock;   /* patch in UA socket */
 
    bsendmsg(tree->ua, _( 
       "\nYou are now entering file selection mode where you add and\n"
@@ -88,20 +91,20 @@ void user_select_files_from_tree(TREE_CTX *tree)
    bsendmsg(tree->ua, _("cwd is: %s\n"), cwd);
    for ( ;; ) {       
       int found, len, stat, i;
-      if (!get_cmd(tree->ua, "$ ")) {
+      if (!get_cmd(ua, "$ ")) {
         break;
       }
-      parse_ua_args(tree->ua);
-      if (tree->ua->argc == 0) {
-        return;
+      parse_ua_args(ua);
+      if (ua->argc == 0) {
+        break;
       }
 
-      len = strlen(tree->ua->argk[0]);
+      len = strlen(ua->argk[0]);
       found = 0;
       stat = 0;
       for (i=0; i<(int)comsize; i++)      /* search for command */
-        if (strncasecmp(tree->ua->argk[0],  _(commands[i].key), len) == 0) {
-           stat = (*commands[i].func)(tree->ua, tree);   /* go execute command */
+        if (strncasecmp(ua->argk[0],  _(commands[i].key), len) == 0) {
+           stat = (*commands[i].func)(ua, tree);   /* go execute command */
            found = 1;
            break;
         }
@@ -113,6 +116,8 @@ void user_select_files_from_tree(TREE_CTX *tree)
         break;
       }
    }
+   ua->UA_sock = NULL;                /* don't release restore socket */
+   free_ua_context(ua);              /* get rid of temp UA context */
 }
 
 
@@ -131,7 +136,7 @@ int insert_tree_handler(void *ctx, int num_fields, char **row)
    int type;
 
    strip_trailing_junk(row[1]);
-   if (*row[1] == 0) {
+   if (*row[1] == 0) {               /* no filename => directory */
       if (*row[0] != '/') {           /* Must be Win32 directory */
         type = TN_DIR_NLS;
       } else {
@@ -140,7 +145,7 @@ int insert_tree_handler(void *ctx, int num_fields, char **row)
    } else {
       type = TN_FILE;
    }
-   bsnprintf(fname, sizeof(fname), "%s%s", row[0]?row[0]:"", row[1]?row[1]:"");
+   bsnprintf(fname, sizeof(fname), "%s%s", row[0], row[1]);
    if (tree->avail_node) {
       node = tree->avail_node;
    } else {
@@ -379,8 +384,8 @@ static int cdcmd(UAContext *ua, TREE_CTX *tree)
    if (!node) {
       /* Try once more if Win32 drive -- make absolute */
       if (ua->argk[1][1] == ':') {  /* win32 drive */
-         strcpy(cwd, "/");
-        strcat(cwd, ua->argk[1]);
+         bstrncpy(cwd, "/", sizeof(cwd));
+        bstrncat(cwd, ua->argk[1], sizeof(cwd));
         node = tree_cwd(cwd, tree->root, tree->node);
       }
       if (!node) {