]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_output.c
23Aug07
[bacula/bacula] / bacula / src / dird / ua_output.c
index 72a4ef9ed0691b60fc6ea4bdeb038c67b6f783bd..8bf7178d22bddc43a28989b8b3fab1d13d29df42 100644 (file)
@@ -7,8 +7,8 @@
    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
@@ -70,7 +70,7 @@ int autodisplay_cmd(UAContext *ua, const char *cmd)
       ua->auto_display_messages = false;
       break;
    default:
-      bsendmsg(ua, _("ON or OFF keyword missing.\n"));
+      ua->error_msg(_("ON or OFF keyword missing.\n"));
       break;
    }
    return 1;
@@ -94,7 +94,7 @@ int gui_cmd(UAContext *ua, const char *cmd)
       ua->jcr->gui = ua->gui = false;
       break;
    default:
-      bsendmsg(ua, _("ON or OFF keyword missing.\n"));
+      ua->error_msg(_("ON or OFF keyword missing.\n"));
       break;
    }
    return 1;
@@ -182,16 +182,16 @@ int show_cmd(UAContext *ua, const char *cmd)
          }
          break;
       case -2:
-         bsendmsg(ua, _("Keywords for the show command are:\n"));
+         ua->send_msg(_("Keywords for the show command are:\n"));
          for (j=0; reses[j].res_name; j++) {
-            bsendmsg(ua, "%s\n", _(reses[j].res_name));
+            ua->error_msg("%s\n", _(reses[j].res_name));
          }
          goto bail_out;
       case -3:
-         bsendmsg(ua, _("%s resource %s not found.\n"), res_name, ua->argv[i]);
+         ua->error_msg(_("%s resource %s not found.\n"), res_name, ua->argv[i]);
          goto bail_out;
       case 0:
-         bsendmsg(ua, _("Resource %s not found\n"), res_name);
+         ua->error_msg(_("Resource %s not found\n"), res_name);
          goto bail_out;
       default:
          dump_resource(recurse?type:-type, res, bsendmsg, ua);
@@ -259,7 +259,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
    Dmsg1(20, "list: %s\n", cmd);
 
    if (!ua->db) {
-      bsendmsg(ua, _("Hey! DB is NULL\n"));
+      ua->error_msg(_("Hey! DB is NULL\n"));
    }
 
    /* Scan arguments looking for things to do */
@@ -373,7 +373,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
             }
             VolumeName = get_pool_memory(PM_FNAME);
             n = db_get_job_volume_names(ua->jcr, ua->db, jobid, &VolumeName);
-            bsendmsg(ua, _("Jobid %d used %d Volume(s): %s\n"), jobid, n, VolumeName);
+            ua->send_msg(_("Jobid %d used %d Volume(s): %s\n"), jobid, n, VolumeName);
             free_pool_memory(VolumeName);
             done = true;
          }
@@ -391,7 +391,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
             for (i=1; i<ua->argc; i++) {
                if (strcasecmp(ua->argk[i], NT_("pool")) == 0) {
                   if (!get_pool_dbr(ua, &pr)) {
-                     bsendmsg(ua, _("No Pool specified.\n"));
+                     ua->error_msg(_("No Pool specified.\n"));
                      return 1;
                   }
                   mr.PoolId = pr.PoolId;
@@ -402,7 +402,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
 
             /* List Volumes in all pools */
             if (!db_get_pool_ids(ua->jcr, ua->db, &num_pools, &ids)) {
-               bsendmsg(ua, _("Error obtaining pool ids. ERR=%s\n"),
+               ua->error_msg(_("Error obtaining pool ids. ERR=%s\n"),
                         db_strerror(ua->db));
                return 1;
             }
@@ -412,7 +412,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
             for (i=0; i < num_pools; i++) {
                pr.PoolId = ids[i];
                if (db_get_pool_record(ua->jcr, ua->db, &pr)) {
-                  bsendmsg(ua, _("Pool: %s\n"), pr.Name);
+                  ua->send_msg(_("Pool: %s\n"), pr.Name);
                }
                mr.PoolId = ids[i];
                db_list_media_records(ua->jcr, ua->db, &mr, prtit, ua, llist);
@@ -428,7 +428,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
          if (j >= 0) {
             n = atoi(ua->argv[j]);
             if ((n < 0) || (n > 50)) {
-              bsendmsg(ua, _("Ignoring invalid value for days. Max is 50.\n"));
+              ua->warning_msg(_("Ignoring invalid value for days. Max is 50.\n"));
               n = 1;
             }
          }
@@ -437,7 +437,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
                  || strcasecmp(ua->argk[i], NT_("days")) == 0) {
          /* Ignore it */
       } else {
-         bsendmsg(ua, _("Unknown list keyword: %s\n"), NPRT(ua->argk[i]));
+         ua->error_msg(_("Unknown list keyword: %s\n"), NPRT(ua->argk[i]));
       }
    }
    return 1;
@@ -473,6 +473,10 @@ static bool list_nextvol(UAContext *ua, int ndays)
       if (!complete_jcr_for_job(jcr, job, run->pool)) {
          return false;
       }
+      if (!jcr->jr.PoolId) {
+         ua->error_msg(_("Could not Pool Job %s\n"), job->name());
+         continue;
+      }
       memset(&pr, 0, sizeof(pr));
       pr.PoolId = jcr->jr.PoolId;
       if (!db_get_pool_record(ua->jcr, ua->db, &pr)) {
@@ -481,13 +485,13 @@ static bool list_nextvol(UAContext *ua, int ndays)
       mr.PoolId = jcr->jr.PoolId;
       get_job_storage(&store, job, run);
       mr.StorageId = store.store->StorageId;
-      if (!find_next_volume_for_append(jcr, &mr, 1, false/*no create*/)) {
-         bsendmsg(ua, _("Could not find next Volume for Job %s (%s, %s).\n"),
-            job->hdr.name, pr.Name, level_to_str(run->level));
+      if (!find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_prune)) {
+         ua->error_msg(_("Could not find next Volume for Job %s (Pool=%s, Level=%s).\n"),
+            job->name(), pr.Name, level_to_str(run->level));
       } else {
-         bsendmsg(ua,
-            _("The next Volume to be used by Job \"%s\" (%s, %s) will be %s\n"),
-            job->hdr.name, pr.Name, level_to_str(run->level), mr.VolumeName);
+         ua->send_msg(
+            _("The next Volume to be used by Job \"%s\" (Pool=%s, Level=%s) will be %s\n"),
+            job->name(), pr.Name, level_to_str(run->level), mr.VolumeName);
          found = true;
       }
       if (jcr->db && jcr->db != ua->db) {
@@ -496,7 +500,7 @@ static bool list_nextvol(UAContext *ua, int ndays)
       }
    }
    if (!found) {
-      bsendmsg(ua, _("Could not find next Volume for Job %s.\n"),
+      ua->error_msg(_("Could not find next Volume for Job %s.\n"),
          job->hdr.name);
       return false;
    }
@@ -610,9 +614,12 @@ bool complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool)
       jcr->pool = pool;               /* override */
    }
    if (jcr->db) {
+      Dmsg0(100, "complete_jcr close db\n");
       db_close_database(jcr, jcr->db);
       jcr->db = NULL;
    }
+
+   Dmsg0(100, "complete_jcr open db\n");
    jcr->db = jcr->db=db_init_database(jcr, jcr->catalog->db_name, jcr->catalog->db_user,
                       jcr->catalog->db_password, jcr->catalog->db_address,
                       jcr->catalog->db_port, jcr->catalog->db_socket,
@@ -718,11 +725,12 @@ void bmsg(UAContext *ua, const char *fmt, va_list arg_ptr)
 {
    BSOCK *bs = ua->UA_sock;
    int maxlen, len;
-   POOLMEM *msg;
+   POOLMEM *msg = NULL;
 
    if (bs) {
       msg = bs->msg;
-   } else {
+   }
+   if (!msg) {
       msg = get_pool_memory(PM_EMSG);
    }
 
@@ -778,8 +786,9 @@ void UAContext::error_msg(const char *fmt, ...)
 {
    BSOCK *bs = UA_sock;
    va_list arg_ptr;
-   va_start(arg_ptr, fmt);
+
    if (bs && api) bs->signal(BNET_ERROR_MSG);
+   va_start(arg_ptr, fmt);
    bmsg(this, fmt, arg_ptr);
    va_end(arg_ptr);
 }
@@ -793,8 +802,9 @@ void UAContext::warning_msg(const char *fmt, ...)
 {
    BSOCK *bs = UA_sock;
    va_list arg_ptr;
-   va_start(arg_ptr, fmt);
+
    if (bs && api) bs->signal(BNET_WARNING_MSG);
+   va_start(arg_ptr, fmt);
    bmsg(this, fmt, arg_ptr);
    va_end(arg_ptr);
 }
@@ -807,8 +817,9 @@ void UAContext::info_msg(const char *fmt, ...)
 {
    BSOCK *bs = UA_sock;
    va_list arg_ptr;
-   va_start(arg_ptr, fmt);
+
    if (bs && api) bs->signal(BNET_INFO_MSG);
+   va_start(arg_ptr, fmt);
    bmsg(this, fmt, arg_ptr);
    va_end(arg_ptr);
 }