]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_dotcmds.c
ebl Modify disk-changer to check if slot contains something before
[bacula/bacula] / bacula / src / dird / ua_dotcmds.c
index 8d41289b8afb6608b4598b6d3be842642701d0f7..ced146c49a8a609127fc46f67291c5a477af26a9 100644 (file)
@@ -1,14 +1,14 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2002-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2002-2008 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
    modify it under the terms of version two of the GNU General Public
-   License as published by the Free Software Foundation plus additions
-   that are listed in the file LICENSE.
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
 
    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -98,7 +98,7 @@ static struct cmdstruct commands[] = {
 /*
  * Execute a command from the UA
  */
-int do_a_dot_command(UAContext *ua, const char *cmd)
+bool do_a_dot_command(UAContext *ua) 
 {
    int i;
    int len;
@@ -108,14 +108,14 @@ int do_a_dot_command(UAContext *ua, const char *cmd)
 
    Dmsg1(1400, "Dot command: %s\n", user->msg);
    if (ua->argc == 0) {
-      return 1;
+      return false;
    }
 
    len = strlen(ua->argk[0]);
    if (len == 1) {
       if (ua->api) user->signal(BNET_CMD_BEGIN);
       if (ua->api) user->signal(BNET_CMD_OK);
-      return 1;                       /* no op */
+      return true;                    /* no op */
    }
    for (i=0; i<comsize; i++) {     /* search for command */
       if (strncasecmp(ua->argk[0],  _(commands[i].key), len) == 0) {
@@ -125,9 +125,10 @@ int do_a_dot_command(UAContext *ua, const char *cmd)
              !acl_access_ok(ua, Command_ACL, ua->argk[0], len)) {
             break;
          }
+         Dmsg1(100, "Cmd: %s\n", ua->cmd);
          ua->gui = true;
          if (ua->api) user->signal(BNET_CMD_BEGIN);
-         ok = (*commands[i].func)(ua, cmd);   /* go execute command */
+         ok = (*commands[i].func)(ua, ua->cmd);   /* go execute command */
          ua->gui = gui;
          found = true;
          break;
@@ -135,11 +136,11 @@ int do_a_dot_command(UAContext *ua, const char *cmd)
    }
    if (!found) {
       pm_strcat(user->msg, _(": is an invalid command.\n"));
-      user->msglen = strlen(user->msg);
-      user->send();
+      ua->error_msg("%s", user->msg);
+      ok = false;
    }
    if (ua->api) user->signal(ok?BNET_CMD_OK:BNET_CMD_FAILED);
-   return 1;
+   return ok;
 }
 
 static bool dot_quit_cmd(UAContext *ua, const char *cmd)
@@ -467,13 +468,17 @@ static int sql_handler(void *ctx, int num_field, char **row)
 
    for (int i=0; num_field--; i++) {
       if (i == 0) {
-         pm_strcpy(rows, row[0]);
+         pm_strcpy(rows, NPRT(row[0]));
       } else {
-         pm_strcat(rows, row[i]);
+         pm_strcat(rows, NPRT(row[i]));
       }
       pm_strcat(rows, "\t");
    }
-   ua->send_msg(rows.c_str());
+   if (!rows.c_str() || !*rows.c_str()) {
+      ua->send_msg("\t");
+   } else {
+      ua->send_msg("%s", rows.c_str());
+   }
    return 0;
 }