-2003-10-15 Version 1.32b 20Oct03 Beta
+2003-10-15 Version 1.32c 22Oct03 Beta
+23Oct03
+- Correct a typo in configure.in when configuring GNOME.
+- In doing a "status dir" make it loop over all the run
+  commands in the Schedule rather than doing on the first one.
+- Close all unused file descriptors in bpipe.c otherwise if
+  a daemon is started, it will keep our TCP/IP port open.
 22Oct03
 - Print block read error (checksum, I/O, BB01, ...) once then
   the number found at the end of the reading.
 
 - Implemented VerifyJob record that tells Verify which
   job to verify (JobId not required).
 - First cut Verify Disk to Catalog
+- Fix "status dir" to examine all run commands in sched.
+- Close unused file descriptors in bpipe.c
 
 Most Significant Changes since 1.32a:
 - Improve forward space file/block during restore, many
 
   pkg=$?
   if test $pkg = 0; then
      GNOME_INCLUDEDIR=`pkg-config --cflags-only-I libgnomeui-2.0`
-     GNOMEUI_LIBS=`pkg-config --libs-only-other libgnomeui-2.0`
+     GNOMEUI_LIBS=`pkg-config --libs-only libgnomeui-2.0`
      GNOME_LIBDIR=`pkg-config --libs libgnomeui-2.0`
      GNOME_LIBS=`pkg-config --libs-only-l libgnomeui-2.0`
      AC_SUBST(GNOME_INCLUDEDIR)
 
   pkg=$?
   if test $pkg = 0; then
      GNOME_INCLUDEDIR=`pkg-config --cflags-only-I libgnomeui-2.0`
-     GNOMEUI_LIBS=`pkg-config --libs-only-other libgnomeui-2.0`
+     GNOMEUI_LIBS=`pkg-config --libs-only libgnomeui-2.0`
      GNOME_LIBDIR=`pkg-config --libs libgnomeui-2.0`
      GNOME_LIBS=`pkg-config --libs-only-l libgnomeui-2.0`
 
 
 - Document verify_disk_to_catalog
                 
 For 1.32c
-- If last Full back is purged and an Incremental or Differential remains,
-  Bacula does not promote the Incremental to a Full.
-- Finish implementation of Verify=DiskToCatalog
 - Add VerifyJob to "run" summary (yes/mod/no) prompt.
 
 For 1.33
+- Finish implementation of Verify=DiskToCatalog
+- Change console to bconsole.
+- Change smtp to bsmtp.
 - Add device name to "Current Volume not acceptable because ..."
 - Make sure that Bacula rechecks the tape after the 20 min wait.
 - Set IO_NOWAIT on Bacula TCP/IP packets.
 - Figure out a way to move Volumes from one pool to another.
 - Implement a RunAfterFailedJob
 - Limit the number of block checksum/header BB01, ... errors printed.
+- If last Full back is purged and an Incremental or Differential remains,
+  Bacula does not promote the Incremental to a Full.
 
 
 
 /* fd_cmds.c */
 extern int connect_to_file_daemon(JCR *jcr, int retry_interval,
-                                  int max_retry_time, int verbose);
+                                 int max_retry_time, int verbose);
 extern int send_include_list(JCR *jcr);
 extern int send_exclude_list(JCR *jcr);
 extern int send_bootstrap_file(JCR *jcr);
 extern int get_attributes_and_put_in_catalog(JCR *jcr);
 extern int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId);
 extern int put_file_into_catalog(JCR *jcr, long file_index, char *fname, 
-                          char *link, char *attr, int stream);
+                         char *link, char *attr, int stream);
 extern void get_level_since_time(JCR *jcr, char *since, int since_len);
 extern int send_run_before_and_after_commands(JCR *jcr);
 
 
 /* msgchan.c */
 extern int connect_to_storage_daemon(JCR *jcr, int retry_interval,    
-                              int max_retry_time, int verbose);
+                             int max_retry_time, int verbose);
 extern int start_storage_daemon_job(JCR *jcr);
 extern int start_storage_daemon_message_thread(JCR *jcr);
 extern int bget_dirmsg(BSOCK *bs);
 /* ua_output.c */
 void prtit(void *ctx, char *msg);
 int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool);
-RUN *find_next_run(JOB *job, time_t &runtime);
+RUN *find_next_run(RUN *run, JOB *job, time_t &runtime);
 
 /* ua_server.c */
 void bsendmsg(void *sock, char *fmt, ...);
 void free_ua_context(UAContext *ua);
 
 /* ua_select.c */
-STORE   *select_storage_resource(UAContext *ua);
-JOB     *select_job_resource(UAContext *ua);
-JOB     *select_restore_job_resource(UAContext *ua);
-CLIENT  *select_client_resource(UAContext *ua);
+STORE  *select_storage_resource(UAContext *ua);
+JOB    *select_job_resource(UAContext *ua);
+JOB    *select_restore_job_resource(UAContext *ua);
+CLIENT *select_client_resource(UAContext *ua);
 FILESET *select_fileset_resource(UAContext *ua);
-int     select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr);
-int     select_media_dbr(UAContext *ua, MEDIA_DBR *mr);
-int     select_pool_dbr(UAContext *ua, POOL_DBR *pr);
-int     select_client_dbr(UAContext *ua, CLIENT_DBR *cr);
-
-void    start_prompt(UAContext *ua, char *msg);
-void    add_prompt(UAContext *ua, char *prompt);
-int     do_prompt(UAContext *ua, char *automsg, char *msg, char *prompt, int max_prompt);
-CAT    *get_catalog_resource(UAContext *ua);           
+int    select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr);
+int    select_media_dbr(UAContext *ua, MEDIA_DBR *mr);
+int    select_pool_dbr(UAContext *ua, POOL_DBR *pr);
+int    select_client_dbr(UAContext *ua, CLIENT_DBR *cr);
+
+void   start_prompt(UAContext *ua, char *msg);
+void   add_prompt(UAContext *ua, char *prompt);
+int    do_prompt(UAContext *ua, char *automsg, char *msg, char *prompt, int max_prompt);
+CAT    *get_catalog_resource(UAContext *ua);          
 STORE  *get_storage_resource(UAContext *ua, int use_default);
-int     get_media_type(UAContext *ua, char *MediaType, int max_media);
-int     get_pool_dbr(UAContext *ua, POOL_DBR *pr);
-int     get_client_dbr(UAContext *ua, CLIENT_DBR *cr);
+int    get_media_type(UAContext *ua, char *MediaType, int max_media);
+int    get_pool_dbr(UAContext *ua, POOL_DBR *pr);
+int    get_client_dbr(UAContext *ua, CLIENT_DBR *cr);
 POOL   *get_pool_resource(UAContext *ua);
 POOL   *select_pool_resource(UAContext *ua);
 CLIENT *get_client_resource(UAContext *ua);
-int     get_job_dbr(UAContext *ua, JOB_DBR *jr);
+int    get_job_dbr(UAContext *ua, JOB_DBR *jr);
 
 int find_arg_keyword(UAContext *ua, char **list);
 int find_arg(UAContext *ua, char *keyword);
 
               }
            }
         }
-        run = find_next_run(job, runtime);
-        pool = run ? run->pool : NULL;
-        if (!complete_jcr_for_job(jcr, job, pool)) {
-           return 1;
-        }
-          
-        if (!find_next_volume_for_append(jcr, &mr, 0)) {
-            bsendmsg(ua, "Could not find next Volume\n");
-           db_close_database(jcr, jcr->db);
-           jcr->db = NULL;
-           return 1;
-        } else {
-            bsendmsg(ua, "The next Volume to be used by Job \"%s\" will be %s\n", 
-              job->hdr.name, mr.VolumeName);
+        for (run=NULL; (run = find_next_run(run, job, runtime)); ) {
+           pool = run ? run->pool : NULL;
+           if (!complete_jcr_for_job(jcr, job, pool)) {
+              return 1;
+           }
+             
+           if (!find_next_volume_for_append(jcr, &mr, 0)) {
+               bsendmsg(ua, "Could not find next Volume\n");
+              db_close_database(jcr, jcr->db);
+              jcr->db = NULL;
+              return 1;
+           } else {
+               bsendmsg(ua, "The next Volume to be used by Job \"%s\" will be %s\n", 
+                 job->hdr.name, mr.VolumeName);
+           }
         }
         db_close_database(jcr, jcr->db);
         jcr->db = NULL;
  * For a given job, we examine all his run records
  *  to see if it is scheduled today or tomorrow.
  */
-RUN *find_next_run(JOB *job, time_t &runtime)
+RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
 {
    time_t now, tomorrow;
-   RUN *run;
    SCHED *sched;
    struct tm tm;
    int mday, wday, month, wpos, tmday, twday, tmonth, twpos, i, hour;
    tmonth = tm.tm_mon;
    twpos  = (tm.tm_mday - 1) / 7;
 
-   for (run=sched->run; run; run=run->next) {
+   if (run == NULL) {
+      run = sched->run;
+   } else {
+      run = run->next;
+   }
+   if (run) {
       /* 
        * Find runs in next 24 hours
        */
 
    /* Loop through all jobs */
    LockRes();
    for (job=NULL; (job=(JOB *)GetNextRes(R_JOB, (RES *)job)); ) {
-      level = job->level;   
-      run = find_next_run(job, runtime);
-      if (!run) {
-        continue;
-      }
-      if (run->level) {
-        level = run->level;
-      }
-      if (!hdr_printed) {
-        hdr_printed = true;
-        prt_runhdr(ua);
+      for (run=NULL; (run = find_next_run(run, job, runtime)); ) {
+        level = job->level;   
+        if (run->level) {
+           level = run->level;
+        }
+        if (!hdr_printed) {
+           hdr_printed = true;
+           prt_runhdr(ua);
+        }
+        prt_runtime(ua, job, level, runtime, run->pool);
       }
-      prt_runtime(ua, job, level, runtime, run->pool);
 
    } /* end for loop over resources */
    UnlockRes();
 
         dup2(readp[1], 1);           /* dup our read to his stdout */
         dup2(readp[1], 2);           /*   and his stderr */
       }
+      for (int i=3; i<=32; i++) {     /* close any open file descriptors */
+        close(i);
+      }
       execvp(bargv[0], bargv);       /* call the program */
       exit(errno);                    /* shouldn't get here */
 
 
 #undef  VERSION
 #define VERSION "1.32c"
 #define VSTRING "1"
-#define BDATE   "20 Oct 2003"
-#define LSMDATE "20Oct03"
+#define BDATE   "22 Oct 2003"
+#define LSMDATE "22Oct03"
 
 /* Debug flags */
 #undef  DEBUG