[
   if test "$withval" != "no"; then
         if test "$withval" = "yes"; then
-                if test -f /usr/local/mysql/include/mysql/mysql.h; then
-                        MYSQL_INCDIR=/usr/local/mysql/include/mysql
-                        if test -f /usr/local/mysql/lib64/mysql/libmysqlclient.a; then
-                                MYSQL_LIBDIR=/usr/local/mysql/lib64/mysql
-                        else
-                                MYSQL_LIBDIR=/usr/local/mysql/lib/mysql
-                        fi
-                        MYSQL_BINDIR=/usr/local/mysql/bin
-                elif test -f /usr/include/mysql/mysql.h; then
-                        MYSQL_INCDIR=/usr/include/mysql
-                        if test -f /usr/lib64/mysql/libmysqlclient.a; then
-                                MYSQL_LIBDIR=/usr/lib64/mysql
-                        else
-                                MYSQL_LIBDIR=/usr/lib/mysql
-                        fi
-                        MYSQL_BINDIR=/usr/bin
-                elif test -f /usr/include/mysql.h; then
-                        MYSQL_INCDIR=/usr/include
-                        if test -f /usr/lib64/libmysqlclient.a; then
-                                MYSQL_LIBDIR=/usr/lib64
-                        else
-                                MYSQL_LIBDIR=/usr/lib
-                        fi
-                        MYSQL_BINDIR=/usr/bin
-                elif test -f /usr/local/include/mysql/mysql.h; then
-                        MYSQL_INCDIR=/usr/local/include/mysql
-                        if test -f /usr/local/lib64/mysql/libmysqlclient.a; then
-                                MYSQL_LIBDIR=/usr/local/lib64/mysql
-                        else
-                                MYSQL_LIBDIR=/usr/local/lib/mysql
-                        fi
-                        MYSQL_BINDIR=/usr/local/bin
-                elif test -f /usr/local/include/mysql.h; then
-                        MYSQL_INCDIR=/usr/local/include
-                        if test -f /usr/local/lib64/libmysqlclient.a; then
-                                MYSQL_LIBDIR=/usr/local/lib64
-                        else
-                                MYSQL_LIBDIR=/usr/local/lib
-                        fi
-                        MYSQL_BINDIR=/usr/local/bin
-                else
-                   AC_MSG_RESULT(no)
-                   AC_MSG_ERROR(Unable to find mysql.h in standard locations)
-                fi
+           if test -f /usr/local/mysql/include/mysql/mysql.h; then
+                   MYSQL_INCDIR=/usr/local/mysql/include/mysql
+                   if test -f /usr/local/mysql/lib64/mysql/libmysqlclient.a; then
+                           MYSQL_LIBDIR=/usr/local/mysql/lib64/mysql
+                   else
+                           MYSQL_LIBDIR=/usr/local/mysql/lib/mysql
+                   fi
+                   MYSQL_BINDIR=/usr/local/mysql/bin
+           elif test -f /usr/include/mysql/mysql.h; then
+                   MYSQL_INCDIR=/usr/include/mysql
+                   if test -f /usr/lib64/mysql/libmysqlclient.a; then
+                           MYSQL_LIBDIR=/usr/lib64/mysql
+                   else
+                           MYSQL_LIBDIR=/usr/lib/mysql
+                   fi
+                   MYSQL_BINDIR=/usr/bin
+           elif test -f /usr/include/mysql.h; then
+                   MYSQL_INCDIR=/usr/include
+                   if test -f /usr/lib64/libmysqlclient.a; then
+                           MYSQL_LIBDIR=/usr/lib64
+                   else
+                           MYSQL_LIBDIR=/usr/lib
+                   fi
+                   MYSQL_BINDIR=/usr/bin
+           elif test -f /usr/local/include/mysql/mysql.h; then
+                   MYSQL_INCDIR=/usr/local/include/mysql
+                   if test -f /usr/local/lib64/mysql/libmysqlclient.a; then
+                           MYSQL_LIBDIR=/usr/local/lib64/mysql
+                   else
+                           MYSQL_LIBDIR=/usr/local/lib/mysql
+                   fi
+                   MYSQL_BINDIR=/usr/local/bin
+           elif test -f /usr/local/include/mysql.h; then
+                   MYSQL_INCDIR=/usr/local/include
+                   if test -f /usr/local/lib64/libmysqlclient.a; then
+                           MYSQL_LIBDIR=/usr/local/lib64
+                   else
+                           MYSQL_LIBDIR=/usr/local/lib
+                   fi
+                   MYSQL_BINDIR=/usr/local/bin
+           else
+              AC_MSG_RESULT(no)
+              AC_MSG_ERROR(Unable to find mysql.h in standard locations)
+           fi
         else
-                if test -f $withval/include/mysql/mysql.h; then
-                        MYSQL_INCDIR=$withval/include/mysql
-                        if test -f $withval/lib64/mysql/libmysqlclient.a; then
-                                MYSQL_LIBDIR=$withval/lib64/mysql
-                        else
-                                MYSQL_LIBDIR=$withval/lib/mysql
-                        fi
-                        MYSQL_BINDIR=$withval/bin
-                elif test -f $withval/include/mysql.h; then
-                        MYSQL_INCDIR=$withval/include
-                        if test -f "$withval/lib64/libmysqlclient.a"; then
-                                MYSQL_LIBDIR=$withval/lib64
-                        else
-                                MYSQL_LIBDIR=$withval/lib
-                        fi
-                        MYSQL_BINDIR=$withval/bin
-                else
-                   AC_MSG_RESULT(no)
-                   AC_MSG_ERROR(Invalid MySQL directory $withval - unable to find mysql.h under $withval)
-                fi
+           if test -f $withval/include/mysql/mysql.h; then
+              MYSQL_INCDIR=$withval/include/mysql
+              if test -f $withval/lib64/mysql/libmysqlclient.a; then
+                 MYSQL_LIBDIR=$withval/lib64/mysql
+              else
+                 MYSQL_LIBDIR=$withval/lib/mysql
+                 # Solaris ...
+                 if test -f $withval/lib/libmysqlclient.so; then
+                    MYSQL_LIBDIR=$withval/lib
+                 fi
+              fi
+              MYSQL_BINDIR=$withval/bin
+           elif test -f $withval/include/mysql.h; then
+              MYSQL_INCDIR=$withval/include
+              if test -f "$withval/lib64/libmysqlclient.a"; then
+                 MYSQL_LIBDIR=$withval/lib64
+              else
+                 MYSQL_LIBDIR=$withval/lib
+              fi
+              MYSQL_BINDIR=$withval/bin
+           else
+              AC_MSG_RESULT(no)
+              AC_MSG_ERROR(Invalid MySQL directory $withval - unable to find mysql.h under $withval)
+           fi
         fi
     SQL_INCLUDE=-I$MYSQL_INCDIR
     if test -f "$MYSQL_LIBDIR/libmysqlclient_r.a"; then
 
       elif test -f $withval/include/postgresql/libpq-fe.h; then
           POSTGRESQL_INCDIR=$withval/include/postgresql
      if test -d $withval/lib64; then
-          POSTGRESQL_LIBDIR=$withval/lib64
+         POSTGRESQL_LIBDIR=$withval/lib64
      else
-          POSTGRESQL_LIBDIR=$withval/lib
+         POSTGRESQL_LIBDIR=$withval/lib
      fi
           POSTGRESQL_BINDIR=$withval/bin
       else
 
   if test "$withval" != "no"; then
         if test "$withval" = "yes"; then
-                if test -f /usr/local/mysql/include/mysql/mysql.h; then
-                        MYSQL_INCDIR=/usr/local/mysql/include/mysql
-                        if test -f /usr/local/mysql/lib64/mysql/libmysqlclient.a; then
-                                MYSQL_LIBDIR=/usr/local/mysql/lib64/mysql
-                        else
-                                MYSQL_LIBDIR=/usr/local/mysql/lib/mysql
-                        fi
-                        MYSQL_BINDIR=/usr/local/mysql/bin
-                elif test -f /usr/include/mysql/mysql.h; then
-                        MYSQL_INCDIR=/usr/include/mysql
-                        if test -f /usr/lib64/mysql/libmysqlclient.a; then
-                                MYSQL_LIBDIR=/usr/lib64/mysql
-                        else
-                                MYSQL_LIBDIR=/usr/lib/mysql
-                        fi
-                        MYSQL_BINDIR=/usr/bin
-                elif test -f /usr/include/mysql.h; then
-                        MYSQL_INCDIR=/usr/include
-                        if test -f /usr/lib64/libmysqlclient.a; then
-                                MYSQL_LIBDIR=/usr/lib64
-                        else
-                                MYSQL_LIBDIR=/usr/lib
-                        fi
-                        MYSQL_BINDIR=/usr/bin
-                elif test -f /usr/local/include/mysql/mysql.h; then
-                        MYSQL_INCDIR=/usr/local/include/mysql
-                        if test -f /usr/local/lib64/mysql/libmysqlclient.a; then
-                                MYSQL_LIBDIR=/usr/local/lib64/mysql
-                        else
-                                MYSQL_LIBDIR=/usr/local/lib/mysql
-                        fi
-                        MYSQL_BINDIR=/usr/local/bin
-                elif test -f /usr/local/include/mysql.h; then
-                        MYSQL_INCDIR=/usr/local/include
-                        if test -f /usr/local/lib64/libmysqlclient.a; then
-                                MYSQL_LIBDIR=/usr/local/lib64
-                        else
-                                MYSQL_LIBDIR=/usr/local/lib
-                        fi
-                        MYSQL_BINDIR=/usr/local/bin
-                else
-                   echo "$as_me:$LINENO: result: no" >&5
+           if test -f /usr/local/mysql/include/mysql/mysql.h; then
+                   MYSQL_INCDIR=/usr/local/mysql/include/mysql
+                   if test -f /usr/local/mysql/lib64/mysql/libmysqlclient.a; then
+                           MYSQL_LIBDIR=/usr/local/mysql/lib64/mysql
+                   else
+                           MYSQL_LIBDIR=/usr/local/mysql/lib/mysql
+                   fi
+                   MYSQL_BINDIR=/usr/local/mysql/bin
+           elif test -f /usr/include/mysql/mysql.h; then
+                   MYSQL_INCDIR=/usr/include/mysql
+                   if test -f /usr/lib64/mysql/libmysqlclient.a; then
+                           MYSQL_LIBDIR=/usr/lib64/mysql
+                   else
+                           MYSQL_LIBDIR=/usr/lib/mysql
+                   fi
+                   MYSQL_BINDIR=/usr/bin
+           elif test -f /usr/include/mysql.h; then
+                   MYSQL_INCDIR=/usr/include
+                   if test -f /usr/lib64/libmysqlclient.a; then
+                           MYSQL_LIBDIR=/usr/lib64
+                   else
+                           MYSQL_LIBDIR=/usr/lib
+                   fi
+                   MYSQL_BINDIR=/usr/bin
+           elif test -f /usr/local/include/mysql/mysql.h; then
+                   MYSQL_INCDIR=/usr/local/include/mysql
+                   if test -f /usr/local/lib64/mysql/libmysqlclient.a; then
+                           MYSQL_LIBDIR=/usr/local/lib64/mysql
+                   else
+                           MYSQL_LIBDIR=/usr/local/lib/mysql
+                   fi
+                   MYSQL_BINDIR=/usr/local/bin
+           elif test -f /usr/local/include/mysql.h; then
+                   MYSQL_INCDIR=/usr/local/include
+                   if test -f /usr/local/lib64/libmysqlclient.a; then
+                           MYSQL_LIBDIR=/usr/local/lib64
+                   else
+                           MYSQL_LIBDIR=/usr/local/lib
+                   fi
+                   MYSQL_BINDIR=/usr/local/bin
+           else
+              echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
-                   { { echo "$as_me:$LINENO: error: Unable to find mysql.h in standard locations" >&5
+              { { echo "$as_me:$LINENO: error: Unable to find mysql.h in standard locations" >&5
 echo "$as_me: error: Unable to find mysql.h in standard locations" >&2;}
    { (exit 1); exit 1; }; }
-                fi
+           fi
         else
-                if test -f $withval/include/mysql/mysql.h; then
-                        MYSQL_INCDIR=$withval/include/mysql
-                        if test -f $withval/lib64/mysql/libmysqlclient.a; then
-                                MYSQL_LIBDIR=$withval/lib64/mysql
-                        else
-                                MYSQL_LIBDIR=$withval/lib/mysql
-                        fi
-                        MYSQL_BINDIR=$withval/bin
-                elif test -f $withval/include/mysql.h; then
-                        MYSQL_INCDIR=$withval/include
-                        if test -f "$withval/lib64/libmysqlclient.a"; then
-                                MYSQL_LIBDIR=$withval/lib64
-                        else
-                                MYSQL_LIBDIR=$withval/lib
-                        fi
-                        MYSQL_BINDIR=$withval/bin
-                else
-                   echo "$as_me:$LINENO: result: no" >&5
+           if test -f $withval/include/mysql/mysql.h; then
+              MYSQL_INCDIR=$withval/include/mysql
+              if test -f $withval/lib64/mysql/libmysqlclient.a; then
+                 MYSQL_LIBDIR=$withval/lib64/mysql
+              else
+                 MYSQL_LIBDIR=$withval/lib/mysql
+                 # Solaris ...
+                 if test -f $withval/lib/libmysqlclient.so; then
+                    MYSQL_LIBDIR=$withval/lib
+                 fi
+              fi
+              MYSQL_BINDIR=$withval/bin
+           elif test -f $withval/include/mysql.h; then
+              MYSQL_INCDIR=$withval/include
+              if test -f "$withval/lib64/libmysqlclient.a"; then
+                 MYSQL_LIBDIR=$withval/lib64
+              else
+                 MYSQL_LIBDIR=$withval/lib
+              fi
+              MYSQL_BINDIR=$withval/bin
+           else
+              echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
-                   { { echo "$as_me:$LINENO: error: Invalid MySQL directory $withval - unable to find mysql.h under $withval" >&5
+              { { echo "$as_me:$LINENO: error: Invalid MySQL directory $withval - unable to find mysql.h under $withval" >&5
 echo "$as_me: error: Invalid MySQL directory $withval - unable to find mysql.h under $withval" >&2;}
    { (exit 1); exit 1; }; }
-                fi
+           fi
         fi
     SQL_INCLUDE=-I$MYSQL_INCDIR
-    if test -f $MYSQL_LIBDIR/libmysqlclient_r.a; then
+    if test -f "$MYSQL_LIBDIR/libmysqlclient_r.a"; then
        SQL_LFLAGS="-L$MYSQL_LIBDIR -lmysqlclient_r -lz"
        cat >>confdefs.h <<\_ACEOF
 #define HAVE_THREAD_SAFE_MYSQL 1
 
 
 MTX=@MTX@
 
+# mt status output
+# SunOS     No Additional Sense
+# FreeBSD   Current Driver State: at rest.
+# Linux     ONLINE
+
+OS=`uname`
+case ${OS} in
+  SunOS)
+    ready="No Additional Sense"
+    ;;
+  FreeBSD)
+    ready="Current Driver State: at rest."
+    ;;
+  *)
+    stat="ONLINE"
+  ;;
+esac
+
 #
 # log whats done
 #
 # Note, this is very system dependent, so if you are
 #   not running on Linux, you will probably need to
 #   re-write it, or at least change the grep target.
+#   We've attempted to get the appropriate OS grep targets
+#   in the code at the top of this script.
 #
 wait_for_drive() {
   i=0 
   while [ $i -le 300 ]; do  # Wait max 300 seconds
-    if mt -f $1 status | grep ONLINE  >/dev/null 2>&1; then
+    if mt -f $1 status | grep ${ready} >/dev/null 2>&1; then
       break
     fi
     debug "Device $1 - not ready, retrying..."
 
 #
 # shell script to create Bacula SQLite tables
 
-bindir=@SQL_BINDIR@
-cd @working_dir@
-sqlite=@DB_NAME@
-
-${bindir}/${sqlite} $* bacula.db <<END-OF-DATA
-END-OF-DATA
+touch @working_dir@/bacula.db
 exit 0
 
 #!/bin/sh
 #
-# shell script to Delete the SQLite Bacula database (same as deleting 
-#  the tables)
+# shell script to Delete the SQLite tables, we simply delete and recreate
+#  the database.
 #
 
 rm -f @working_dir@/bacula.db
+touch @working_dir@/bacula.db
 
 FILE *con_fd = NULL;                  /* Console file descriptor */
 brwlock_t con_lock;                   /* Console lock structure */
 
-static char *catalog_db = NULL;              /* database type */
+static char *catalog_db = NULL;       /* database type */
 
 const char *host_os = HOST_OS;
 const char *distname = DISTNAME;
    term_last_jobs_list();
 }
 
-
+static bool open_dest_file(JCR *jcr, DEST *d, const char *mode) 
+{
+   d->fd = fopen(d->where, mode);
+   if (!d->fd) {
+      berrno be;
+      d->fd = stdout;
+      Qmsg2(jcr, M_ERROR, 0, _("fopen %s failed: ERR=%s\n"), d->where,
+            be.strerror());
+      d->fd = NULL;
+      return false;
+   }
+   return true;
+}
 
 /*
  * Handle sending the message to the appropriate place
     int len, dtlen;
     MSGS *msgs;
     BPIPE *bpipe;
+    char *mode;
 
     Dmsg2(850, "Enter dispatch_msg type=%d msg=%s", type, msg);
 
                 }
                 fputs(msg, d->fd);
                 break;
+             case MD_APPEND:
+                Dmsg1(850, "APPEND for following msg: %s", msg);
+                mode = "ab";
+                goto send_to_file;
              case MD_FILE:
                 Dmsg1(850, "FILE for following msg: %s", msg);
-                if (!d->fd) {
-                   d->fd = fopen(d->where, "w+b");
-                   if (!d->fd) {
-                      berrno be;
-                      d->fd = stdout;
-                      Qmsg2(jcr, M_ERROR, 0, _("fopen %s failed: ERR=%s\n"), d->where,
-                            be.strerror());
-                      d->fd = NULL;
-                      break;
-                   }
+                mode = "w+b";
+send_to_file:
+                if (!d->fd && !open_dest_file(jcr, d, mode)) {
+                   break;
                 }
                 fputs(dt, d->fd);
                 fputs(msg, d->fd);
-                break;
-             case MD_APPEND:
-                Dmsg1(850, "APPEND for following msg: %s", msg);
-                if (!d->fd) {
-                   d->fd = fopen(d->where, "ab");
-                   if (!d->fd) {
-                      berrno be;
-                      d->fd = stdout;
-                      Qmsg2(jcr, M_ERROR, 0, _("fopen %s failed: ERR=%s\n"), d->where,
-                            be.strerror());
-                      d->fd = NULL;
-                      break;
+                /* On error, we close and reopen to handle log rotation */
+                if (ferror(d->fd)) {
+                   fclose(d->fd);
+                   if (open_dest_file(jcr, d, mode)) {
+                      fputs(dt, d->fd);
+                      fputs(msg, d->fd);
                    }
                 }
-                fputs(dt, d->fd);
-                fputs(msg, d->fd);
                 break;
              case MD_DIRECTOR:
                 Dmsg1(850, "DIRECTOR for following msg: %s", msg);
 
               _("3304 Issuing autochanger \"load slot %d, drive %d\" command.\n"),
               slot, drive);
          dcr->VolCatInfo.Slot = slot;    /* slot to be loaded */
-         changer = edit_device_codes(dcr, changer, 
-                      dcr->device->changer_command, "load");
+         changer = edit_device_codes(dcr, changer, dcr->device->changer_command, "load");
          dev->close();
          Dmsg1(200, "Run program=%s\n", changer);
          status = run_program(changer, timeout, NULL);
 {
    JCR *jcr = dcr->jcr;
    DEVICE *dev = dcr->dev;
-   POOLMEM *changer, *results;
    int status, loaded;
    uint32_t timeout = dcr->device->max_changer_wait;
    int drive = dcr->dev->drive_index;
+   POOL_MEM results(PM_MESSAGE);
+   POOLMEM *changer;
 
    if (!dev->is_autochanger()) {
       return -1;
       return dev->Slot;
    }
 
-   results = get_pool_memory(PM_MESSAGE);
-   changer = get_pool_memory(PM_FNAME);
-
-
    /* Find out what is loaded, zero means device is unloaded */
+   changer = get_pool_memory(PM_FNAME);
    lock_changer(dcr);
    Jmsg(jcr, M_INFO, 0, _("3301 Issuing autochanger \"loaded? drive %d\" command.\n"),
         drive);
    changer = edit_device_codes(dcr, changer, dcr->device->changer_command, "loaded");
-   *results = 0;
+   *results.c_str() = 0;
    Dmsg1(100, "Run program=%s\n", changer);
-   status = run_program(changer, timeout, results);
-   Dmsg3(100, "run_prog: %s stat=%d result=%s\n", changer, status, results);
+   status = run_program_full_output(changer, timeout, results.c_str());
+   Dmsg3(100, "run_prog: %s stat=%d result=%s\n", changer, status, results.c_str());
    if (status == 0) {
-      loaded = str_to_int32(results);
+      loaded = str_to_int32(results.c_str());
       if (loaded > 0) {
          Jmsg(jcr, M_INFO, 0, _("3302 Autochanger \"loaded? drive %d\", result is Slot %d.\n"),
               drive, loaded);
    } else {
       berrno be;
       be.set_errno(status);
-      Jmsg(jcr, M_INFO, 0, _("3991 Bad autochanger \"loaded? drive %d\" command: ERR=%s.\n"),
-           drive, be.strerror());
+      Jmsg(jcr, M_INFO, 0, _("3991 Bad autochanger \"loaded? drive %d\" command: "
+           "ERR=%s.\nResults=%s\n"), drive, be.strerror(), results.c_str());
       loaded = -1;              /* force unload */
    }
    unlock_changer(dcr);
    free_pool_memory(changer);
-   free_pool_memory(results);
    return loaded;
 }
 
    }
 
    if (loaded > 0) {
+      POOL_MEM results(PM_MESSAGE);
       POOLMEM *changer = get_pool_memory(PM_FNAME);
       lock_changer(dcr);
       Jmsg(jcr, M_INFO, 0,
                    dcr->device->changer_command, "unload");
       dev->close();
       Dmsg1(100, "Run program=%s\n", changer);
-      int stat = run_program(changer, timeout, NULL);
+      *results.c_str() = 0;
+      int stat = run_program_full_output(changer, timeout, results.c_str());
       dcr->VolCatInfo.Slot = slot;
       if (stat != 0) {
          berrno be;
          be.set_errno(stat);
-         Jmsg(jcr, M_INFO, 0, _("3995 Bad autochanger \"unload slot %d, drive %d\": ERR=%s.\n"),
-                 slot, dev->drive_index, be.strerror());
+         Jmsg(jcr, M_INFO, 0, _("3995 Bad autochanger \"unload slot %d, drive %d\": "
+              "ERR=%s\nResults=%s\n"),
+                 loaded, dev->drive_index, be.strerror(), results.c_str());
          ok = false;
          dev->Slot = -1;           /* unknown */
       } else {
 
    }
 
    free_restore_volume_list(jcr);
+   dev->close();
    set_volume_name("TestVolume2", 2);
    jcr->bsr = NULL;
    create_restore_volume_list(jcr);
-   dev->close();
    if (!acquire_device_for_read(dcr)) {
       Pmsg2(0, _("Cannot open Dev=%s, Vol=%s\n"), dev->print_name(), dcr->VolumeName);
       return false;
 
 *     Version $Id$
 */
 /*
-   Copyright (C) 2004 Kern Sibbald and John Walker
+   Copyright (C) 2004-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
-   You should have received a copy of the GNU General Public
-   License along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
-
-*/
+ */
 
 #include "bacula.h"
 #include "tray_conf.h"
 
  */
 
 #undef  VERSION
-#define VERSION "1.39.24"
-#define BDATE   "02 October 2006"
-#define LSMDATE "02Oct06"
+#define VERSION "1.39.25"
+#define BDATE   "07 October 2006"
+#define LSMDATE "07Oct06"
 #define BYEAR "2006"       /* year for copyright messages in progs */
 
 /* Debug flags */
 
 
          if (WideCharToMultiByte(CP_UTF8,0,m_szShadowCopyName[nDriveIndex],-1,szShadowPath,nBuflen-1,NULL,NULL)) {
             nBuflen -= (int)strlen(szShadowPath);
-            strncat(szShadowPath, szFilePath+2, nBuflen);
+            bstrncat(szShadowPath, szFilePath+2, nBuflen);
             return TRUE;
          }
       }
    }
    
-   strncpy(szShadowPath,  szFilePath, nBuflen);
+   bstrncpy(szShadowPath, szFilePath, nBuflen);
    errno = EINVAL;
    return FALSE;   
 }
       }
    }
    
-   wcsncpy(szShadowPath,  szFilePath, nBuflen);
+   wcsncpy(szShadowPath, szFilePath, nBuflen);
    errno = EINVAL;
    return FALSE;   
 }
 
 const size_t VSSClient::GetWriterCount()
 {
-   alist* pV = (alist*) m_pAlistWriterInfoText;
+   alist* pV = (alist*)m_pAlistWriterInfoText;
    return pV->size();
 }
 
 const char* VSSClient::GetWriterInfo(int nIndex)
 {
-   alist* pV = (alist*) m_pAlistWriterInfoText;
-   return (char*) pV->get(nIndex);
+   alist* pV = (alist*)m_pAlistWriterInfoText;
+   return (char*)pV->get(nIndex);
 }
 
 
 const int VSSClient::GetWriterState(int nIndex)
 {
-   alist* pV = (alist*) m_pAlistWriterState;   
-   return (int) pV->get(nIndex);
+   alist* pV = (alist*)m_pAlistWriterState;   
+   return (int)pV->get(nIndex);
 }
 
 void VSSClient::AppendWriterInfo(int nState, const char* pszInfo)
    alist* pT = (alist*) m_pAlistWriterInfoText;
    alist* pS = (alist*) m_pAlistWriterState;
 
-   pT->push (bstrdup(pszInfo));
-   pS->push ((void*) nState);   
+   pT->push(bstrdup(pszInfo));
+   pS->push((void*)nState);   
 }
 
 void VSSClient::DestroyWriterInfo()
 {
-   alist* pT = (alist*) m_pAlistWriterInfoText;
-   alist* pS = (alist*) m_pAlistWriterState;
+   alist* pT = (alist*)m_pAlistWriterInfoText;
+   alist* pS = (alist*)m_pAlistWriterState;
 
    while (!pT->empty())
-      free (pT->pop());
+      free(pT->pop());
 
    while (!pS->empty())
       pS->pop();      
 
       szDrive[0] = szDriveLetters[i];
       volume = GetUniqueVolumeNameForPath(szDrive);
       // store uniquevolumname
-      if (SUCCEEDED(pVss->AddToSnapshotSet((LPWSTR)volume.c_str(), GUID_NULL, &pid)))
+      if (SUCCEEDED(pVss->AddToSnapshotSet((LPWSTR)volume.c_str(), GUID_NULL, &pid))) {
          wcsncpy (m_wszUniqueVolumeName[szDriveLetters[i]-'A'], (LPWSTR) volume.c_str(), MAX_PATH);
-      else
-      {            
+      } else {            
          szDriveLetters[i] = tolower (szDriveLetters[i]);               
       }
    }
 
    /* PrepareForBackup */
    if (FAILED(pVss->PrepareForBackup(&pAsync1.p))) {      
+      errno = b_errno_win32;
       return FALSE;   
    }
    
 
    /* get latest info about writer status */
    if (!CheckWriterStatus()) {
+      errno = b_errno_win32;
       return FALSE;
    }
 
    /* DoSnapShotSet */   
    if (FAILED(pVss->DoSnapshotSet(&pAsync2.p))) {      
+      errno = b_errno_win32;
       return FALSE;   
    }
 
         /* store text info */
         char str[1000];
         char szBuf[200];        
-        strcpy(str, "\"");
+        bstrncpy(str, "\"", sizeof(str));
         wchar_2_UTF8(szBuf, bstrWriterName.p, sizeof(szBuf));
-        strcat(str, szBuf);
-        strcat(str, "\", State: 0x");
+        bstrncat(str, szBuf, sizeof(str));
+        bstrncat(str, "\", State: 0x");
         itoa(eWriterStatus, szBuf, sizeof(szBuf));
-        strcat(str, szBuf);
-        strcat(str, " (");
+        bstrncat(str, szBuf, sizeof(str));
+        bstrncat(str, " (", sizeof(str));
         wchar_2_UTF8(szBuf, GetStringFromWriterStatus(eWriterStatus), sizeof(szBuf));
-        strcat(str, szBuf);
-        strcat(str, ")");
+        bstrncat(str, szBuf, sizeof(str));
+        bstrncat(str, ")", sizeof(str));
 
         AppendWriterInfo(nState, (const char *)str);     
     }
 
               Technical notes on version 1.39  
 
 General:
+07Oct06
+kes  Begin work on new GUI "console".
+kes  Make configure look in non-standard MySQL library directory 
+     for Solaris.
+kes  Make mtx-changer automatically configure the autochanger wait
+     procedure for Solaris, FreeBSD, and Linux.  Previously, only Linux
+     was implemented.
+kes  Correct drop_sqlite_tables.in script to not delete the database.
+kes  When writing to a log file, close and reopen the file descriptor
+     if there is an error writing the file.
+kes  Modify the autochanger loaded?, load, and unload commands to print
+     the full text of any mtx output if there is an error.  Helps to
+     ease diagnosis of autochanger problems.
+kes  Correct a few Win32 errno returns in the VSS code so that hopefully
+     a resonable Win32 error message will be printed.
+kes  Convert a few strcat()... to bstrncat() in the Win32 code.
+
+Version 1.39.24 released:
 02Oct06
 kes  Apply dvd find volume patch from Richard Mortimer.
 kes  Eliminate the dvd specific mount routines using only the
      dev->mount/unmount.
 kes  Make update_free_space a method of DEVICE and rename 
      update_freespace.
-01Sep06
+01Oct06
 kes  Require a messages command acl to be able to receive messages
      in a console.
 kes  Add console, system, and scan job types in util.c.