+static bool list_nextvol(UAContext *ua)
+{
+ JOB *job;
+ JCR *jcr = ua->jcr;
+ POOL *pool;
+ RUN *run;
+ time_t runtime;
+ bool found = false;
+ MEDIA_DBR mr;
+
+ memset(&mr, 0, sizeof(mr));
+ int i = find_arg_with_value(ua, "job");
+ if (i <= 0) {
+ if ((job = select_job_resource(ua)) == NULL) {
+ return false;
+ }
+ } else {
+ job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
+ if (!job) {
+ Jmsg(jcr, M_ERROR, 0, _("%s is not a job name.\n"), ua->argv[i]);
+ if ((job = select_job_resource(ua)) == NULL) {
+ return false;
+ }
+ }
+ }
+ for (run=NULL; (run = find_next_run(run, job, runtime)); ) {
+ pool = run ? run->pool : NULL;
+ if (!complete_jcr_for_job(jcr, job, pool)) {
+ return false;
+ }
+
+ if (!find_next_volume_for_append(jcr, &mr, 0)) {
+ bsendmsg(ua, _("Could not find next Volume.\n"));
+ } else {
+ bsendmsg(ua, _("The next Volume to be used by Job \"%s\" will be %s\n"),
+ job->hdr.name, mr.VolumeName);
+ found = true;
+ }
+ if (jcr->db && jcr->db != ua->db) {
+ db_close_database(jcr, jcr->db);
+ jcr->db = NULL;
+ }
+ }
+ if (!found) {
+ bsendmsg(ua, _("Could not find next Volume.\n"));
+ return false;
+ }
+ return true;
+}
+
+