#define DEFAULT_CONFIGDIR "C:\\Documents and Settings\\All Users\\Application Data\\Bacula"
 
 inline bool IsPathSeparator(int ch) { return ch == '/' || ch == '\\'; }
-inline char *first_path_separator(char *path) { return strpbrk(path, ":/\\"); }
-inline const char *first_path_separator(const char *path) { return strpbrk(path, ":/\\"); }
+inline char *first_path_separator(char *path) { return strpbrk(path, "/\\"); }
+inline const char *first_path_separator(const char *path) { return strpbrk(path, "/\\"); }
 
 #else
 /* Define Winsock functions if we aren't on Windows */
 
    int stat;
 
    if (mdb->sqlite_errmsg) {
+#ifdef HAVE_SQLITE3
+      sqlite3_free(mdb->sqlite_errmsg);
+#else
       actuallyfree(mdb->sqlite_errmsg);
+#endif
       mdb->sqlite_errmsg = NULL;
    }
    stat = sqlite_get_table(mdb->db, (char *)cmd, &mdb->result, &mdb->nrow, &mdb->ncolumn,
 
     }
 
     /* Return a bit map of permissions set. */
-    if (enable_priv(jcr, hToken, SE_SECURITY_NAME, ignore_errors)) {
-       stat |= 1<<0;
-    }
     if (enable_priv(jcr, hToken, SE_BACKUP_NAME, ignore_errors)) {
        stat |= 1<<1;
     }
     if (enable_priv(jcr, hToken, SE_RESTORE_NAME, ignore_errors)) {
        stat |= 1<<2;
     }
+#if 0
+    if (enable_priv(jcr, hToken, SE_SECURITY_NAME, ignore_errors)) {
+       stat |= 1<<0;
+    }
     if (enable_priv(jcr, hToken, SE_TAKE_OWNERSHIP_NAME, ignore_errors)) {
        stat |= 1<<3;
     }
     if (enable_priv(jcr, hToken, SE_CREATE_PERMANENT_NAME, ignore_errors)) {
        stat |= 1<<10;
     }
+#endif
     if (stat) {
        stat |= 1<<9;
     }
 
  */
 TREE_NODE *tree_cwd(char *path, TREE_ROOT *root, TREE_NODE *node)
 {
-   if (strcmp(path, ".") == 0) {
+   if (path[0] == '.' && path[1] == '\0') {
       return node;
    }
    /* Handle relative path */
-   if (strncmp(path, "..", 2) == 0 && (path[2] == '/' || path[2] == 0)) {
+   if (path[0] == '.' && path[1] == '.' && (IsPathSeparator(path[2]) || path[2] == '\0')) {
       TREE_NODE *parent = node->parent ? node->parent : node;
       if (path[2] == 0) { 
          return parent;
 
 static void do_extract(char *devname)
 {
    struct stat statp;
+
+   enable_backup_privileges(NULL, 1);
+
    jcr = setup_jcr("bextract", devname, bsr, VolumeName, 1); /* acquire for read */
    if (!jcr) {
       exit(1);
 
    my_name_is(argc, argv, "bscan");
    init_msg(NULL, NULL);
 
+   OSDependentInit();
 
    while ((ch = getopt(argc, argv, "b:c:d:h:mn:pP:rsSu:vV:w:?")) != -1) {
       switch (ch) {
 
          /*
           * If we have a digest stream, we check to see if we have 
           *  finished the current bsr, and if so, repositioning will
-          *  be truned on.
+          *  be turned on.
           */
          if (crypto_digest_stream_type(rec->Stream) != CRYPTO_DIGEST_NONE) {
             Dmsg3(dbglvl, "Have digest FI=%u before bsr check pos %u:%u\n", rec->FileIndex,
 
 
 extern "C" {
 
-#include        <glib-object.h>
+#include <glib-object.h>
 
 
 #ifdef G_ENABLE_DEBUG
 
 #ifndef ___egg_marshal_MARSHAL_H__
 #define ___egg_marshal_MARSHAL_H__
 
-#include        <glib-object.h>
+#include <glib-object.h>
 
 G_BEGIN_DECLS
 
 
 #if HAVE_GTK_2_4
    GtkWidget* about = gtk_message_dialog_new_with_markup(GTK_WINDOW(window),GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
       "<span size='x-large' weight='bold'>%s</span>\n\n"
+      PROG_COPYRIGHT
       "%s"
       "\n<small>%s: %s (%s) %s %s %s</small>",
       _("Bacula Tray Monitor"),
-      PROG_COPYRIGHT
-        "Written by Nicolas Boichat\n"),
-      _("Version:"),
-      VERSION, BDATE, HOST_OS, DISTNAME, DISTVER, 2004);
+        2004,
+      _("Written by Nicolas Boichat\n"),
+      _("Version"),
+      VERSION, BDATE, HOST_OS, DISTNAME, DISTVER);
 #else
    GtkWidget* about = gtk_message_dialog_new(GTK_WINDOW(window),GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,   
       "%s\n\n"
+      PROG_COPYRIGHT
       "%s"
-      "\n%s %s (%s) %s %s %s",
+      "\n%s: %s (%s) %s %s %s",
       _("Bacula Tray Monitor"),
-      PROG_COPYRIGHT
-        "Written by Nicolas Boichat\n"),
-      _("Version:"),
-      BYEAR, VERSION, BDATE, HOST_OS, DISTNAME, 2004);
+        2004,
+      _("Written by Nicolas Boichat\n"),
+      _("Version"),
+      VERSION, BDATE, HOST_OS, DISTNAME, DISTVER);
 #endif
    gtk_dialog_run(GTK_DIALOG(about));
    gtk_widget_destroy(about);
 
 MTX|http://superb-west.dl.sourceforge.net/sourceforge/mtx/mtx-1.3.9.tar.gz
 MT|ftp://ftp.ibiblio.org/pub/linux/system/backup/mt-st-0.9b.tar.gz
 SED|ftp://mirrors.kernel.org/gnu/sed/sed-4.1.5.tar.gz
+SQLITE|http://www.sqlite.org/sqlite-3.3.8.tar.gz
 
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{825DFFD0-4747-43CA-8326-529655E31935}"
        ProjectSection(SolutionItems) = preProject
                build-depkgs-mingw32 = build-depkgs-mingw32
-               build-depkgs-msvc.cmd = build-depkgs-msvc.cmd
                build-msvc.cmd = build-msvc.cmd
                build-win32-cross-tools = build-win32-cross-tools
-               ..\..\autoconf\bacula-macros\db.m4 = ..\..\autoconf\bacula-macros\db.m4
                External-mingw32 = External-mingw32
-               External-msvc = External-msvc
-               ..\..\autoconf\bacula-macros\largefiles.m4 = ..\..\autoconf\bacula-macros\largefiles.m4
-               ..\..\autoconf\bacula-macros\os.m4 = ..\..\autoconf\bacula-macros\os.m4
                README.mingw32 = README.mingw32
                README.vc8 = README.vc8
                README.win32 = README.win32
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scsilist", "tools\scsilist\scsilist.vcproj", "{56D8C233-610E-4EE4-A73A-72CEF1C6A33A}"
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cats_bdb", "cats\cats_bdb\cats_bdb.vcproj", "{1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}"
-       ProjectSection(ProjectDependencies) = postProject
-               {2D729599-C008-4154-BCCB-53E6A260F220} = {2D729599-C008-4154-BCCB-53E6A260F220}
-       EndProjectSection
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "installer", "installer\installer.vcproj", "{6D1B0964-FB32-4916-A61C-49D7F715EAD8}"
        ProjectSection(ProjectDependencies) = postProject
                {A0F65E06-9F18-40AC-81F6-A080852F1104} = {A0F65E06-9F18-40AC-81F6-A080852F1104}
                {85696E20-777A-41F6-BC00-2E7AB375B171} = {85696E20-777A-41F6-BC00-2E7AB375B171}
                {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F} = {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}
                {56D8C233-610E-4EE4-A73A-72CEF1C6A33A} = {56D8C233-610E-4EE4-A73A-72CEF1C6A33A}
+               {23BFE838-5682-4F39-969F-0B40366D4D98} = {23BFE838-5682-4F39-969F-0B40366D4D98}
                {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC} = {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC}
                {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} = {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}
                {F8AF7D74-2918-422B-A7B6-4D98566B7160} = {F8AF7D74-2918-422B-A7B6-4D98566B7160}
                {8B79A2B5-8889-43D4-9B92-9AE8A6F00413} = {8B79A2B5-8889-43D4-9B92-9AE8A6F00413}
                {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B} = {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}
                {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF} = {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}
-               {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C} = {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}
                {56EADEDB-FBED-4758-8B54-7B0B47ABDABF} = {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}
                {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E} = {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}
                {496415E0-AF44-4AD8-8C99-91B837DDF469} = {496415E0-AF44-4AD8-8C99-91B837DDF469}
                {2D729599-C008-4154-BCCB-53E6A260F220} = {2D729599-C008-4154-BCCB-53E6A260F220}
        EndProjectSection
 EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scripts", "Scripts", "{40CADEE4-8D53-4157-AA36-B256F4934FC3}"
+       ProjectSection(SolutionItems) = preProject
+               scripts\disk-changer.cmd = scripts\disk-changer.cmd
+               scripts\mtx-changer.cmd = scripts\mtx-changer.cmd
+       EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cats_sqlite", "cats\cats_sqlite\cats_sqlite.vcproj", "{23BFE838-5682-4F39-969F-0B40366D4D98}"
+       ProjectSection(ProjectDependencies) = postProject
+               {2D729599-C008-4154-BCCB-53E6A260F220} = {2D729599-C008-4154-BCCB-53E6A260F220}
+       EndProjectSection
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
-               Debug|Mixed Platforms = Debug|Mixed Platforms
                Debug|Win32 = Debug|Win32
                Release|Any CPU = Release|Any CPU
-               Release|Mixed Platforms = Release|Mixed Platforms
                Release|Win32 = Release|Win32
        EndGlobalSection
        GlobalSection(ProjectConfigurationPlatforms) = postSolution
                {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Debug|Win32.ActiveCfg = Debug|Win32
                {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Debug|Win32.Build.0 = Debug|Win32
                {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Release|Any CPU.ActiveCfg = Release|Win32
-               {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Release|Win32.ActiveCfg = Release|Win32
                {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Release|Win32.Build.0 = Release|Win32
                {A0F65E06-9F18-40AC-81F6-A080852F1104}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {A0F65E06-9F18-40AC-81F6-A080852F1104}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {A0F65E06-9F18-40AC-81F6-A080852F1104}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {A0F65E06-9F18-40AC-81F6-A080852F1104}.Debug|Win32.ActiveCfg = Debug|Win32
                {A0F65E06-9F18-40AC-81F6-A080852F1104}.Debug|Win32.Build.0 = Debug|Win32
                {A0F65E06-9F18-40AC-81F6-A080852F1104}.Release|Any CPU.ActiveCfg = Release|Win32
-               {A0F65E06-9F18-40AC-81F6-A080852F1104}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {A0F65E06-9F18-40AC-81F6-A080852F1104}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {A0F65E06-9F18-40AC-81F6-A080852F1104}.Release|Win32.ActiveCfg = Release|Win32
                {A0F65E06-9F18-40AC-81F6-A080852F1104}.Release|Win32.Build.0 = Release|Win32
                {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Debug|Win32.ActiveCfg = Debug|Win32
                {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Debug|Win32.Build.0 = Debug|Win32
                {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Release|Any CPU.ActiveCfg = Release|Win32
-               {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Release|Win32.ActiveCfg = Release|Win32
                {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Release|Win32.Build.0 = Release|Win32
                {374BF775-AF68-4A88-814A-48F692DFFE5A}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {374BF775-AF68-4A88-814A-48F692DFFE5A}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {374BF775-AF68-4A88-814A-48F692DFFE5A}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {374BF775-AF68-4A88-814A-48F692DFFE5A}.Debug|Win32.ActiveCfg = Debug|Win32
                {374BF775-AF68-4A88-814A-48F692DFFE5A}.Debug|Win32.Build.0 = Debug|Win32
                {374BF775-AF68-4A88-814A-48F692DFFE5A}.Release|Any CPU.ActiveCfg = Release|Win32
-               {374BF775-AF68-4A88-814A-48F692DFFE5A}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {374BF775-AF68-4A88-814A-48F692DFFE5A}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {374BF775-AF68-4A88-814A-48F692DFFE5A}.Release|Win32.ActiveCfg = Release|Win32
                {374BF775-AF68-4A88-814A-48F692DFFE5A}.Release|Win32.Build.0 = Release|Win32
                {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Debug|Win32.ActiveCfg = Debug|Win32
                {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Debug|Win32.Build.0 = Debug|Win32
                {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Release|Any CPU.ActiveCfg = Release|Win32
-               {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Release|Win32.ActiveCfg = Release|Win32
                {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Release|Win32.Build.0 = Release|Win32
                {558838F9-D792-4F56-AAB2-99C03687C5FF}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {558838F9-D792-4F56-AAB2-99C03687C5FF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {558838F9-D792-4F56-AAB2-99C03687C5FF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {558838F9-D792-4F56-AAB2-99C03687C5FF}.Debug|Win32.ActiveCfg = Debug|Win32
                {558838F9-D792-4F56-AAB2-99C03687C5FF}.Debug|Win32.Build.0 = Debug|Win32
                {558838F9-D792-4F56-AAB2-99C03687C5FF}.Release|Any CPU.ActiveCfg = Release|Win32
-               {558838F9-D792-4F56-AAB2-99C03687C5FF}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {558838F9-D792-4F56-AAB2-99C03687C5FF}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {558838F9-D792-4F56-AAB2-99C03687C5FF}.Release|Win32.ActiveCfg = Release|Win32
                {558838F9-D792-4F56-AAB2-99C03687C5FF}.Release|Win32.Build.0 = Release|Win32
                {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Debug|Win32.ActiveCfg = Debug|Win32
                {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Debug|Win32.Build.0 = Debug|Win32
                {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Release|Any CPU.ActiveCfg = Release|Win32
-               {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Release|Win32.ActiveCfg = Release|Win32
                {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Release|Win32.Build.0 = Release|Win32
                {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Debug|Win32.ActiveCfg = Debug|Win32
                {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Debug|Win32.Build.0 = Debug|Win32
                {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Release|Any CPU.ActiveCfg = Release|Win32
-               {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Release|Win32.ActiveCfg = Release|Win32
                {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Release|Win32.Build.0 = Release|Win32
                {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Debug|Win32.ActiveCfg = Debug|Win32
                {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Debug|Win32.Build.0 = Debug|Win32
                {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Release|Any CPU.ActiveCfg = Release|Win32
-               {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Release|Win32.ActiveCfg = Release|Win32
                {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Release|Win32.Build.0 = Release|Win32
                {F5F063F8-11A1-475A-82E2-19759BB40B25}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {F5F063F8-11A1-475A-82E2-19759BB40B25}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {F5F063F8-11A1-475A-82E2-19759BB40B25}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {F5F063F8-11A1-475A-82E2-19759BB40B25}.Debug|Win32.ActiveCfg = Debug|Win32
                {F5F063F8-11A1-475A-82E2-19759BB40B25}.Debug|Win32.Build.0 = Debug|Win32
                {F5F063F8-11A1-475A-82E2-19759BB40B25}.Release|Any CPU.ActiveCfg = Release|Win32
-               {F5F063F8-11A1-475A-82E2-19759BB40B25}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {F5F063F8-11A1-475A-82E2-19759BB40B25}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {F5F063F8-11A1-475A-82E2-19759BB40B25}.Release|Win32.ActiveCfg = Release|Win32
                {F5F063F8-11A1-475A-82E2-19759BB40B25}.Release|Win32.Build.0 = Release|Win32
                {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Debug|Win32.ActiveCfg = Debug|Win32
                {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Debug|Win32.Build.0 = Debug|Win32
                {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Release|Any CPU.ActiveCfg = Release|Win32
-               {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Release|Win32.ActiveCfg = Release|Win32
                {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Release|Win32.Build.0 = Release|Win32
                {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Debug|Win32.ActiveCfg = Debug|Win32
                {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Debug|Win32.Build.0 = Debug|Win32
                {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Release|Any CPU.ActiveCfg = Release|Win32
-               {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Release|Win32.ActiveCfg = Release|Win32
                {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Release|Win32.Build.0 = Release|Win32
                {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Debug|Win32.ActiveCfg = Debug|Win32
                {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Debug|Win32.Build.0 = Debug|Win32
                {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Release|Any CPU.ActiveCfg = Release|Win32
-               {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Release|Win32.ActiveCfg = Release|Win32
                {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Release|Win32.Build.0 = Release|Win32
                {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Debug|Win32.ActiveCfg = Debug|Win32
                {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Debug|Win32.Build.0 = Debug|Win32
                {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Release|Any CPU.ActiveCfg = Release|Win32
-               {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Release|Win32.ActiveCfg = Release|Win32
                {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Release|Win32.Build.0 = Release|Win32
                {496415E0-AF44-4AD8-8C99-91B837DDF469}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {496415E0-AF44-4AD8-8C99-91B837DDF469}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {496415E0-AF44-4AD8-8C99-91B837DDF469}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {496415E0-AF44-4AD8-8C99-91B837DDF469}.Debug|Win32.ActiveCfg = Debug|Win32
                {496415E0-AF44-4AD8-8C99-91B837DDF469}.Debug|Win32.Build.0 = Debug|Win32
                {496415E0-AF44-4AD8-8C99-91B837DDF469}.Release|Any CPU.ActiveCfg = Release|Win32
-               {496415E0-AF44-4AD8-8C99-91B837DDF469}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {496415E0-AF44-4AD8-8C99-91B837DDF469}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {496415E0-AF44-4AD8-8C99-91B837DDF469}.Release|Win32.ActiveCfg = Release|Win32
                {496415E0-AF44-4AD8-8C99-91B837DDF469}.Release|Win32.Build.0 = Release|Win32
                {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Debug|Win32.ActiveCfg = Debug|Win32
                {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Debug|Win32.Build.0 = Debug|Win32
                {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Release|Any CPU.ActiveCfg = Release|Win32
-               {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Release|Win32.ActiveCfg = Release|Win32
                {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Release|Win32.Build.0 = Release|Win32
                {208D3989-794B-47A2-9D04-D7AEE1524078}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {208D3989-794B-47A2-9D04-D7AEE1524078}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {208D3989-794B-47A2-9D04-D7AEE1524078}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {208D3989-794B-47A2-9D04-D7AEE1524078}.Debug|Win32.ActiveCfg = Debug|Win32
                {208D3989-794B-47A2-9D04-D7AEE1524078}.Release|Any CPU.ActiveCfg = Release|Win32
-               {208D3989-794B-47A2-9D04-D7AEE1524078}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
                {208D3989-794B-47A2-9D04-D7AEE1524078}.Release|Win32.ActiveCfg = Release|Win32
                {2D729599-C008-4154-BCCB-53E6A260F220}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {2D729599-C008-4154-BCCB-53E6A260F220}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {2D729599-C008-4154-BCCB-53E6A260F220}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {2D729599-C008-4154-BCCB-53E6A260F220}.Debug|Win32.ActiveCfg = Debug|Win32
                {2D729599-C008-4154-BCCB-53E6A260F220}.Debug|Win32.Build.0 = Debug|Win32
                {2D729599-C008-4154-BCCB-53E6A260F220}.Release|Any CPU.ActiveCfg = Release|Win32
-               {2D729599-C008-4154-BCCB-53E6A260F220}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {2D729599-C008-4154-BCCB-53E6A260F220}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {2D729599-C008-4154-BCCB-53E6A260F220}.Release|Win32.ActiveCfg = Release|Win32
                {2D729599-C008-4154-BCCB-53E6A260F220}.Release|Win32.Build.0 = Release|Win32
                {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC}.Debug|Win32.ActiveCfg = Debug|Win32
                {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC}.Debug|Win32.Build.0 = Debug|Win32
                {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC}.Release|Any CPU.ActiveCfg = Release|Win32
-               {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC}.Release|Win32.ActiveCfg = Release|Win32
                {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC}.Release|Win32.Build.0 = Release|Win32
                {8B79A2B5-8889-43D4-9B92-9AE8A6F00413}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {8B79A2B5-8889-43D4-9B92-9AE8A6F00413}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {8B79A2B5-8889-43D4-9B92-9AE8A6F00413}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {8B79A2B5-8889-43D4-9B92-9AE8A6F00413}.Debug|Win32.ActiveCfg = Debug|Win32
                {8B79A2B5-8889-43D4-9B92-9AE8A6F00413}.Debug|Win32.Build.0 = Debug|Win32
                {8B79A2B5-8889-43D4-9B92-9AE8A6F00413}.Release|Any CPU.ActiveCfg = Release|Win32
-               {8B79A2B5-8889-43D4-9B92-9AE8A6F00413}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {8B79A2B5-8889-43D4-9B92-9AE8A6F00413}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {8B79A2B5-8889-43D4-9B92-9AE8A6F00413}.Release|Win32.ActiveCfg = Release|Win32
                {8B79A2B5-8889-43D4-9B92-9AE8A6F00413}.Release|Win32.Build.0 = Release|Win32
                {85696E20-777A-41F6-BC00-2E7AB375B171}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {85696E20-777A-41F6-BC00-2E7AB375B171}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {85696E20-777A-41F6-BC00-2E7AB375B171}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {85696E20-777A-41F6-BC00-2E7AB375B171}.Debug|Win32.ActiveCfg = Debug|Win32
                {85696E20-777A-41F6-BC00-2E7AB375B171}.Debug|Win32.Build.0 = Debug|Win32
                {85696E20-777A-41F6-BC00-2E7AB375B171}.Release|Any CPU.ActiveCfg = Release|Win32
-               {85696E20-777A-41F6-BC00-2E7AB375B171}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {85696E20-777A-41F6-BC00-2E7AB375B171}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {85696E20-777A-41F6-BC00-2E7AB375B171}.Release|Win32.ActiveCfg = Release|Win32
                {85696E20-777A-41F6-BC00-2E7AB375B171}.Release|Win32.Build.0 = Release|Win32
                {2FB961E5-213C-4475-8CB3-72F904D40752}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {2FB961E5-213C-4475-8CB3-72F904D40752}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {2FB961E5-213C-4475-8CB3-72F904D40752}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {2FB961E5-213C-4475-8CB3-72F904D40752}.Debug|Win32.ActiveCfg = Debug|Win32
                {2FB961E5-213C-4475-8CB3-72F904D40752}.Debug|Win32.Build.0 = Debug|Win32
                {2FB961E5-213C-4475-8CB3-72F904D40752}.Release|Any CPU.ActiveCfg = Release|Win32
-               {2FB961E5-213C-4475-8CB3-72F904D40752}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {2FB961E5-213C-4475-8CB3-72F904D40752}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {2FB961E5-213C-4475-8CB3-72F904D40752}.Release|Win32.ActiveCfg = Release|Win32
                {2FB961E5-213C-4475-8CB3-72F904D40752}.Release|Win32.Build.0 = Release|Win32
                {56D8C233-610E-4EE4-A73A-72CEF1C6A33A}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {56D8C233-610E-4EE4-A73A-72CEF1C6A33A}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {56D8C233-610E-4EE4-A73A-72CEF1C6A33A}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {56D8C233-610E-4EE4-A73A-72CEF1C6A33A}.Debug|Win32.ActiveCfg = Debug|Win32
                {56D8C233-610E-4EE4-A73A-72CEF1C6A33A}.Debug|Win32.Build.0 = Debug|Win32
                {56D8C233-610E-4EE4-A73A-72CEF1C6A33A}.Release|Any CPU.ActiveCfg = Release|Win32
-               {56D8C233-610E-4EE4-A73A-72CEF1C6A33A}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {56D8C233-610E-4EE4-A73A-72CEF1C6A33A}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {56D8C233-610E-4EE4-A73A-72CEF1C6A33A}.Release|Win32.ActiveCfg = Release|Win32
                {56D8C233-610E-4EE4-A73A-72CEF1C6A33A}.Release|Win32.Build.0 = Release|Win32
-               {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}.Debug|Mixed Platforms.Build.0 = Debug|Win32
-               {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}.Debug|Win32.ActiveCfg = Debug|Win32
-               {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}.Debug|Win32.Build.0 = Debug|Win32
-               {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}.Release|Any CPU.ActiveCfg = Release|Win32
-               {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}.Release|Mixed Platforms.Build.0 = Debug|Win32
-               {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}.Release|Win32.ActiveCfg = Release|Win32
-               {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}.Release|Win32.Build.0 = Release|Win32
                {6D1B0964-FB32-4916-A61C-49D7F715EAD8}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {6D1B0964-FB32-4916-A61C-49D7F715EAD8}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {6D1B0964-FB32-4916-A61C-49D7F715EAD8}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {6D1B0964-FB32-4916-A61C-49D7F715EAD8}.Debug|Win32.ActiveCfg = Debug|Win32
                {6D1B0964-FB32-4916-A61C-49D7F715EAD8}.Debug|Win32.Build.0 = Debug|Win32
                {6D1B0964-FB32-4916-A61C-49D7F715EAD8}.Release|Any CPU.ActiveCfg = Release|Win32
-               {6D1B0964-FB32-4916-A61C-49D7F715EAD8}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {6D1B0964-FB32-4916-A61C-49D7F715EAD8}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {6D1B0964-FB32-4916-A61C-49D7F715EAD8}.Release|Win32.ActiveCfg = Release|Win32
                {6D1B0964-FB32-4916-A61C-49D7F715EAD8}.Release|Win32.Build.0 = Release|Win32
                {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Debug|Win32.ActiveCfg = Debug|Win32
                {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Debug|Win32.Build.0 = Debug|Win32
                {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Release|Any CPU.ActiveCfg = Release|Win32
-               {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Release|Win32.ActiveCfg = Release|Win32
                {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Release|Win32.Build.0 = Release|Win32
                {AB67F297-8491-4515-8E52-BFF5340EC242}.Debug|Any CPU.ActiveCfg = Debug|Win32
-               {AB67F297-8491-4515-8E52-BFF5340EC242}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-               {AB67F297-8491-4515-8E52-BFF5340EC242}.Debug|Mixed Platforms.Build.0 = Debug|Win32
                {AB67F297-8491-4515-8E52-BFF5340EC242}.Debug|Win32.ActiveCfg = Debug|Win32
                {AB67F297-8491-4515-8E52-BFF5340EC242}.Debug|Win32.Build.0 = Debug|Win32
                {AB67F297-8491-4515-8E52-BFF5340EC242}.Release|Any CPU.ActiveCfg = Release|Win32
-               {AB67F297-8491-4515-8E52-BFF5340EC242}.Release|Mixed Platforms.ActiveCfg = Debug|Win32
-               {AB67F297-8491-4515-8E52-BFF5340EC242}.Release|Mixed Platforms.Build.0 = Debug|Win32
                {AB67F297-8491-4515-8E52-BFF5340EC242}.Release|Win32.ActiveCfg = Release|Win32
                {AB67F297-8491-4515-8E52-BFF5340EC242}.Release|Win32.Build.0 = Release|Win32
+               {23BFE838-5682-4F39-969F-0B40366D4D98}.Debug|Any CPU.ActiveCfg = Debug|Win32
+               {23BFE838-5682-4F39-969F-0B40366D4D98}.Debug|Win32.ActiveCfg = Debug|Win32
+               {23BFE838-5682-4F39-969F-0B40366D4D98}.Debug|Win32.Build.0 = Debug|Win32
+               {23BFE838-5682-4F39-969F-0B40366D4D98}.Release|Any CPU.ActiveCfg = Release|Win32
+               {23BFE838-5682-4F39-969F-0B40366D4D98}.Release|Win32.ActiveCfg = Release|Win32
+               {23BFE838-5682-4F39-969F-0B40366D4D98}.Release|Win32.Build.0 = Release|Win32
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
                {B52BD53B-0E57-4E9A-A601-8E8171BA1CFC} = {0377E151-3352-487B-A5CF-24BCDC9EC43F}
                {8B79A2B5-8889-43D4-9B92-9AE8A6F00413} = {0377E151-3352-487B-A5CF-24BCDC9EC43F}
                {2FB961E5-213C-4475-8CB3-72F904D40752} = {0377E151-3352-487B-A5CF-24BCDC9EC43F}
-               {1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C} = {0377E151-3352-487B-A5CF-24BCDC9EC43F}
+               {23BFE838-5682-4F39-969F-0B40366D4D98} = {0377E151-3352-487B-A5CF-24BCDC9EC43F}
                {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA} = {B9099DDA-18C9-4DE0-AECB-5D8139EA619F}
                {F5F063F8-11A1-475A-82E2-19759BB40B25} = {B9099DDA-18C9-4DE0-AECB-5D8139EA619F}
                {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B} = {B9099DDA-18C9-4DE0-AECB-5D8139EA619F}
                {C8301485-CFD1-43D4-827C-8EA050C8E256} = {825DFFD0-4747-43CA-8326-529655E31935}
+               {40CADEE4-8D53-4157-AA36-B256F4934FC3} = {825DFFD0-4747-43CA-8326-529655E31935}
                {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA} = {37F903FE-3474-4C93-AD5B-987CB6A92E62}
                {F8AF7D74-2918-422B-A7B6-4D98566B7160} = {37F903FE-3474-4C93-AD5B-987CB6A92E62}
                {56EADEDB-FBED-4758-8B54-7B0B47ABDABF} = {37F903FE-3474-4C93-AD5B-987CB6A92E62}
 
        CALL :process_pthreads
        CALL :process_openssl
        CALL :process_mysql
-REM    CALL :process_sqlite
+       CALL :process_sqlite
        CALL :process_postgreSQL
        CALL :process_wx
 REM    CALL :process_scons
 
 :process_sqlite
        CALL :get_source %URL_SQLITE% %DIR_SQLITE% %MKD_SQLITE%
-       CALL :get_source %URL_SQLITE_WINSRC% %DIR_SQLITE_WINSRC% %MKD_SQLITE_WINSRC%
-REM    ECHO Patching SQLite
-REM    COPY /Y nul patch.log
-REM    do_patch sqlite.patch
+       IF ERRORLEVEL 2 GOTO :sqlite_error
+       IF ERRORLEVEL 1 GOTO :sqlite_skip_patch
+       ECHO Patching SQLite
+       COPY /Y nul patch.log
+       CALL :do_patch sqlite_msc.patch
+:sqlite_skip_patch
        ECHO Configuring SQLite
        IF NOT EXIST bld/nul MKDIR bld
        CD bld
        ECHO Building SQLite
        COPY /Y nul make.log
-       do_make ../Makefile.mingw32 CROSSTOOLS=%BIN_DIR% TLIBS="-L%DEPPKG_DIR%/lib" TCL_FLAGS="-I%DEPPKG_DIR%/include" clean all
+       CALL :do_nmake ../Makefile.msvc clean all
        ECHO Installing SQLite
-       cp -p sqlite3.exe %DEPPKG_DIR%/bin
-       cp -p libsqlite3.a %DEPPKG_DIR%/lib
-       cp -p sqlite3.h %DEPPKG_DIR%/include
+       COPY sqlite3.exe %DEPPKG_DIR%\bin
+       COPY sqlite3.lib %DEPPKG_DIR%\lib
+       COPY sqlite3.h %DEPPKG_DIR%\include
        EXIT /B 0
+:sqlite_error
+       ECHO Unable to download sqlite source from %URL_SQLITE%
+       EXIT /B 1
 
 :process_wx
        CALL :get_source %URL_WX% %DIR_WX% %MKD_WX%
 
+++ /dev/null
-REM build release if cygwin make not available.
-
-cd zlib
-nmake /f win32\Makefile.msc
-cd ..
-cd pthreads
-nmake VCE
-cd ..
-cd baculafd
-nmake CFG="baculafd - Win32 Release" /f baculafd.mak
-cd ..
-makensis winbacula.nsi
 
 
 # Files files in src/lib
 
-BDB_OBJS = \
-       bdb.o \
-       bdb_create.o \
-       bdb_delete.o \
-       bdb_find.o \
-       bdb_get.o \
-       bdb_list.o \
-       bdb_update.o \
-
 SQL_OBJS = \
        sql.o \
        sql_cmds.o \
 
 .PHONY: all clean
 
-all: $(LIBDIR)/libcats.a $(BINDIR)/cats_mysql.dll $(BINDIR)/cats_pgsql.dll $(BINDIR)/cats_bdb.dll
+all: $(LIBDIR)/libcats.a $(BINDIR)/cats_mysql.dll $(BINDIR)/cats_pgsql.dll $(BINDIR)/cats_sqlite.dll
 
 clean:
        @echo "Cleaning `pwd`"
        $(call clean_obj,$(addprefix $(OBJDIR)/cats_mysql/,mysql.o $(SQL_OBJS)))
        $(call clean_obj,$(addprefix $(OBJDIR)/cats_pgsql/,postgresql.o $(SQL_OBJS)))
-       $(call clean_obj,$(addprefix $(OBJDIR)/cats_bdb/,sql_cmds.o $(BDB_OBJS)))
+       $(call clean_obj,$(addprefix $(OBJDIR)/cats_sqlite/,sqlite.o $(SQL_OBJS)))
        $(call clean_exe,$(BINDIR)/cats_mysql.dll)
        $(call clean_exe,$(BINDIR)/cats_pgsql.dll)
-       $(call clean_exe,$(BINDIR)/cats_bdb.dll)
+       $(call clean_exe,$(BINDIR)/cats_sqlite.dll)
        $(ECHO_CMD)rm -f $(OBJDIR)/libcats.exp $(LIBDIR)/libcats.a
 
 $(LIBDIR)/libcats.a $(OBJDIR)/libcats.exp: bacula_cats.def
        $(call checkdir,$@)
        $(ECHO_CMD)$(CXX) $(LDFLAGS) -mdll -mwindows $^ $(LIBS_POSTGRESQL) $(LIBS_DLL) -o $@
 
-$(BINDIR)/cats_bdb.dll: $(addprefix $(OBJDIR)/cats_bdb/,sql_cmds.o $(BDB_OBJS)) $(OBJDIR)/libcats.exp
+$(BINDIR)/cats_sqlite.dll: $(addprefix $(OBJDIR)/cats_sqlite/,sqlite.o $(SQL_OBJS)) $(OBJDIR)/libcats.exp
        @echo "Linking $@"
        $(call checkdir,$@)
-       $(ECHO_CMD)$(CXX) $(LDFLAGS) -mdll -mwindows $^ $(LIBS_DLL) -o $@
+       $(ECHO_CMD)$(CXX) $(LDFLAGS) -mdll -mwindows $^ $(LIBS_SQLITE) $(LIBS_DLL) -o $@
 
 #
 # Rules for generating from ../cats
 
 $(eval $(call Link_Dll,cats_pgsql,POSTGRESQL))
 
-$(eval $(call Link_Dll,cats_bdb,BACULA_DB))
+$(eval $(call Link_Dll,cats_sqlite,SQLITE3))
 
 
                        <File
                                RelativePath=".\bacula_cats.def"
                                >
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                               </FileConfiguration>
                        </File>
                </Filter>
                <Filter
                        UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
                        >
                </Filter>
+               <Filter
+                       Name="Script Files"
+                       >
+                       <File
+                               RelativePath="..\delete_catalog_backup.cmd"
+                               >
+                       </File>
+               </Filter>
        </Files>
        <Globals>
        </Globals>
 
+++ /dev/null
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-       ProjectType="Visual C++"
-       Version="8.00"
-       Name="cats_bdb"
-       ProjectGUID="{1E6FC8D7-0A08-461A-B9AB-FD3CC5DC0B9C}"
-       RootNamespace="cats_bdb"
-       >
-       <Platforms>
-               <Platform
-                       Name="Win32"
-               />
-       </Platforms>
-       <ToolFiles>
-       </ToolFiles>
-       <Configurations>
-               <Configuration
-                       Name="Debug|Win32"
-                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-                       IntermediateDirectory="$(ConfigurationName)"
-                       ConfigurationType="2"
-                       CharacterSet="2"
-                       >
-                       <Tool
-                               Name="VCPreBuildEventTool"
-                       />
-                       <Tool
-                               Name="VCCustomBuildTool"
-                       />
-                       <Tool
-                               Name="VCXMLDataGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCWebServiceProxyGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCMIDLTool"
-                       />
-                       <Tool
-                               Name="VCCLCompilerTool"
-                               Optimization="0"
-                               AdditionalIncludeDirectories="../../compat;../../../../../depkgs-msvc/include;../../.."
-                               PreprocessorDefinitions="_DEBUG;_LIB;HAVE_WIN32;HAVE_BACULA_DB;USING_DLL;BUILDING_CATS;_USE_32BIT_TIME_T;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
-                               MinimalRebuild="true"
-                               BasicRuntimeChecks="3"
-                               RuntimeLibrary="3"
-                               UsePrecompiledHeader="0"
-                               WarningLevel="3"
-                               Detect64BitPortabilityProblems="false"
-                               DebugInformationFormat="4"
-                       />
-                       <Tool
-                               Name="VCManagedResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCPreLinkEventTool"
-                       />
-                       <Tool
-                               Name="VCLinkerTool"
-                               AdditionalDependencies="bacula_cats.exp"
-                               AdditionalLibraryDirectories="../../../../../depkgs-msvc/lib;../../$(ConfigurationName)"
-                               GenerateDebugInformation="true"
-                               SubSystem="2"
-                               TargetMachine="1"
-                       />
-                       <Tool
-                               Name="VCALinkTool"
-                       />
-                       <Tool
-                               Name="VCManifestTool"
-                       />
-                       <Tool
-                               Name="VCXDCMakeTool"
-                       />
-                       <Tool
-                               Name="VCBscMakeTool"
-                       />
-                       <Tool
-                               Name="VCFxCopTool"
-                       />
-                       <Tool
-                               Name="VCAppVerifierTool"
-                       />
-                       <Tool
-                               Name="VCWebDeploymentTool"
-                       />
-                       <Tool
-                               Name="VCPostBuildEventTool"
-                       />
-               </Configuration>
-               <Configuration
-                       Name="Release|Win32"
-                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-                       IntermediateDirectory="$(ConfigurationName)"
-                       ConfigurationType="2"
-                       CharacterSet="2"
-                       WholeProgramOptimization="1"
-                       >
-                       <Tool
-                               Name="VCPreBuildEventTool"
-                       />
-                       <Tool
-                               Name="VCCustomBuildTool"
-                       />
-                       <Tool
-                               Name="VCXMLDataGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCWebServiceProxyGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCMIDLTool"
-                       />
-                       <Tool
-                               Name="VCCLCompilerTool"
-                               AdditionalIncludeDirectories="../../compat;../../../../../depkgs-msvc/include;../../.."
-                               PreprocessorDefinitions="NDEBUG;_LIB;HAVE_WIN32;HAVE_BACULA_DB;USING_DLL;BUILDING_CATS;_USE_32BIT_TIME_T;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
-                               RuntimeLibrary="2"
-                               UsePrecompiledHeader="0"
-                               WarningLevel="3"
-                               Detect64BitPortabilityProblems="false"
-                               DebugInformationFormat="3"
-                       />
-                       <Tool
-                               Name="VCManagedResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCPreLinkEventTool"
-                       />
-                       <Tool
-                               Name="VCLinkerTool"
-                               AdditionalDependencies="bacula_cats.exp"
-                               AdditionalLibraryDirectories="../../../../../depkgs-msvc/lib;../../$(ConfigurationName)"
-                               GenerateDebugInformation="true"
-                               SubSystem="2"
-                               OptimizeReferences="2"
-                               EnableCOMDATFolding="2"
-                               TargetMachine="1"
-                       />
-                       <Tool
-                               Name="VCALinkTool"
-                       />
-                       <Tool
-                               Name="VCManifestTool"
-                       />
-                       <Tool
-                               Name="VCXDCMakeTool"
-                       />
-                       <Tool
-                               Name="VCBscMakeTool"
-                       />
-                       <Tool
-                               Name="VCFxCopTool"
-                       />
-                       <Tool
-                               Name="VCAppVerifierTool"
-                       />
-                       <Tool
-                               Name="VCWebDeploymentTool"
-                       />
-                       <Tool
-                               Name="VCPostBuildEventTool"
-                       />
-               </Configuration>
-       </Configurations>
-       <References>
-       </References>
-       <Files>
-               <Filter
-                       Name="Source Files"
-                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-                       >
-                       <File
-                               RelativePath="..\..\..\cats\bdb.c"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\..\cats\bdb_create.c"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\..\cats\bdb_delete.c"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\..\cats\bdb_find.c"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\..\cats\bdb_get.c"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\..\cats\bdb_list.c"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\..\cats\bdb_update.c"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\..\cats\sql_cmds.c"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               CompileAs="2"
-                                       />
-                               </FileConfiguration>
-                       </File>
-               </Filter>
-               <Filter
-                       Name="Header Files"
-                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
-                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-                       >
-                       <File
-                               RelativePath="..\..\..\cats\cats.h"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\..\cats\protos.h"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\..\cats\sql_cmds.h"
-                               >
-                       </File>
-               </Filter>
-               <Filter
-                       Name="Resource Files"
-                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
-                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
-                       >
-               </Filter>
-       </Files>
-       <Globals>
-       </Globals>
-</VisualStudioProject>
 
                        UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
                        >
                </Filter>
+               <Filter
+                       Name="Script Files"
+                       >
+                       <File
+                               RelativePath="..\create_mysql_database.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\drop_mysql_database.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\drop_mysql_tables.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\drop_mysql_tables.sql"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\grant_mysql_privileges.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\grant_mysql_privileges.sql"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\make_mysql_catalog_backup.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\make_mysql_tables.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\make_mysql_tables.sql"
+                               >
+                       </File>
+               </Filter>
        </Files>
        <Globals>
        </Globals>
 
                        UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
                        >
                </Filter>
+               <Filter
+                       Name="Script Files"
+                       >
+                       <File
+                               RelativePath="..\create_postgresql_database.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\create_postgresql_database.sql"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\drop_postgresql_database.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\drop_postgresql_tables.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\drop_postgresql_tables.sql"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\grant_postgresql_privileges.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\grant_postgresql_privileges.sql"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\make_postgresql_catalog_backup.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\make_postgresql_tables.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\make_postgresql_tables.sql"
+                               >
+                       </File>
+               </Filter>
        </Files>
        <Globals>
        </Globals>
 
--- /dev/null
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="cats_sqlite"
+       ProjectGUID="{23BFE838-5682-4F39-969F-0B40366D4D98}"
+       RootNamespace="cats_sqlite"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="2"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="../../compat;../../../../../depkgs-msvc/include;../../.."
+                               PreprocessorDefinitions="_DEBUG;_LIB;HAVE_WIN32;HAVE_SQLITE3;USING_DLL;BUILDING_CATS;_USE_32BIT_TIME_T;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="false"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="sqlite3.lib bacula_cats.exp"
+                               AdditionalLibraryDirectories="../../../../../depkgs-msvc/lib;../../$(ConfigurationName)"
+                               IgnoreDefaultLibraryNames="msvcrt"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="2"
+                       CharacterSet="2"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="../../compat;../../../../../depkgs-msvc/include;../../.."
+                               PreprocessorDefinitions="NDEBUG;_LIB;HAVE_WIN32;HAVE_SQLITE3;USING_DLL;BUILDING_CATS;_USE_32BIT_TIME_T;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
+                               RuntimeLibrary="2"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="false"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="sqlite3.lib bacula_cats.exp"
+                               AdditionalLibraryDirectories=""../../../../../depkgs-msvc/lib";"../../$(ConfigurationName)""
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+                       >
+                       <File
+                               RelativePath="..\..\..\cats\sql.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\cats\sql_cmds.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\cats\sql_create.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\cats\sql_delete.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\cats\sql_find.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\cats\sql_get.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\cats\sql_list.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\cats\sql_update.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\cats\sqlite.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+                       >
+                       <File
+                               RelativePath="..\..\..\cats\cats.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\cats\protos.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\cats\sql_cmds.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+                       >
+               </Filter>
+               <Filter
+                       Name="Script Files"
+                       >
+                       <File
+                               RelativePath="..\create_sqlite3_database.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\drop_sqlite3_database.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\drop_sqlite3_tables.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\grant_sqlite3_privileges.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\make_sqlite3_catalog_backup.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\make_sqlite3_tables.cmd"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\make_sqlite3_tables.sql"
+                               >
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
 
+++ /dev/null
-rem \r
-rem  shell script to create Bacula database(s)\r
-rem \r
-rem   Nothing to do \r
 
-@echo off\r
-rem\r
-rem Script to create Bacula database(s)\r
-rem\r
+@ECHO off\r
+REM\r
+REM Script to create Bacula database(s)\r
+REM\r
 \r
-"%SQL_BINDIR%\mysql" %* -e "CREATE DATABASE bacula;"\r
-set RESULT=%ERRORLEVEL%\r
-if %RESULT% GTR 0 goto :ERROR\r
-echo "Creation of bacula database succeeded."\r
-exit /b 0\r
+"@SQL_BINDIR@\mysql" %* -e "CREATE DATABASE bacula;"\r
+SET RESULT=%ERRORLEVEL%\r
+IF %RESULT% GTR 0 GOTO :ERROR\r
+ECHO Creation of bacula database succeeded.\r
+EXIT /b 0\r
 \r
 :ERROR\r
-echo "Creation of bacula database failed."\r
-exit /b %RESULT%\r
+ECHO Creation of bacula database failed.\r
+EXIT /b %RESULT%\r
 
-rem \r
-rem  shell script to create Bacula database(s)\r
-rem \r
+@ECHO off\r
+REM\r
+REM  Script to create Bacula database(s)\r
+REM\r
 \r
-bindir=@SQL_BINDIR@\r
+REM use SQL_ASCII to be able to put any filename into\r
+REM  the database even those created with unusual character sets\r
+SET ENCODING=ENCODING 'SQL_ASCII'\r
 \r
-rem use SQL_ASCII to be able to put any filename into\r
-rem  the database even those created with unusual character sets\r
-ENCODING="ENCODING 'SQL_ASCII'"\r
-rem use UTF8 if you are using standard Unix/Linux LANG specifications\r
-rem  that use UTF8 -- this is normally the default and *should* be\r
-rem  your standard.  Bacula consoles work correctly *only* with UTF8.\r
-rem ENCODING="ENCODING 'UTF8'"\r
-     \r
-$bindir/psql -f create_postgresql_database.sql -d template1 $*\r
-if ERRORLEVEL 1 GOTO :ERROR\r
-echo "Creation of bacula database succeeded."\r
+REM use UTF8 if you are using standard Unix/Linux LANG specifications\r
+REM  that use UTF8 -- this is normally the default and *should* be\r
+REM  your standard.  Bacula consoles work correctly *only* with UTF8.\r
+REM SET ENCODING=ENCODING 'UTF8'\r
+\r
+"@SQL_BINDIR@\psql" -f "@bin_dir_cmd@\create_postgresql_database.sql" -d template1 %*\r
+IF ERRORLEVEL 1 GOTO :ERROR\r
+ECHO Creation of bacula database succeeded.\r
 EXIT /b 0\r
 GOTO :EOF\r
 \r
 :ERROR\r
-echo "Creation of bacula database failed."\r
+ECHO Creation of bacula database failed.\r
 EXIT /b 1\r
 
-rem\r
-rem This script deletes a catalog dump\r
-rem\r
-del /f "@working_dir_cmd@\bacula.sql"\r
+REM\r
+REM This script deletes a catalog dump\r
+REM\r
+DEL /f "@working_dir_cmd@\bacula.sql"\r
+EXIT /b 0\r
 
+++ /dev/null
-rem\r
-rem \r
-rem  shell script to drop Bacula database(s)\r
-rem \r
-rem   Nothing to do \r
 
+++ /dev/null
-rem \r
-rem  shell script to Delete the Bacula database (same as deleting \r
-rem   the tables)\r
-rem \r
-\r
-del /f @working_dir@/control.db\r
-del /f @working_dir@/jobs.db\r
-del /f @working_dir@/pools.db\r
-del /f @working_dir@/media.db\r
-del /f @working_dir@/jobmedia.db\r
-del /f @working_dir@/client.db\r
-del /f @working_dir@/fileset.db\r
 
-rem\r
-rem shell script to drop Bacula database(s)\r
-rem\r
+@ECHO off\r
+REM\r
+REM Script to drop Bacula database(s)\r
+REM\r
 \r
-"%SQL_BINDIR%/mysql" %* -f -e "DROP DATABASE bacula;"\r
-set RESULT=%ERRORLEVEL%\r
-if %RESULT% GTR 0 goto :ERROR\r
-echo "Drop of bacula database succeeded."\r
-exit /b 0\r
+"@SQL_BINDIR@\mysql" %* -f -e "DROP DATABASE bacula;"\r
+SET RESULT=%ERRORLEVEL%\r
+IF %RESULT% GTR 0 GOTO :ERROR\r
+ECHO Drop of bacula database succeeded.\r
+EXIT /b 0\r
 \r
 :ERROR\r
-echo "Drop of bacula database failed."\r
-exit /b %RESULT%\r
+ECHO Drop of bacula database failed.\r
+EXIT /b %RESULT%\r
 
-@echo off\r
-rem\r
-rem Script to delete Bacula tables for MySQL\r
-rem\r
+@ECHO off\r
+REM\r
+REM Script to delete Bacula tables for MySQL\r
+REM\r
 \r
-"%SQL_BINDIR%/mysql" %* < drop_mysql_tables.sql\r
-set RESULT=%ERRORLEVEL%\r
-if %RESULT% GTR 0 goto :ERROR\r
-echo "Deletion of Bacula MySQL tables succeeded."\r
-exit /b 0\r
+"@SQL_BINDIR@\mysql" %* < "@bin_dir_cmd@\drop_mysql_tables.sql"\r
+SET RESULT=%ERRORLEVEL%\r
+IF %RESULT% GTR 0 goto :ERROR\r
+ECHO Deletion of Bacula MySQL tables succeeded.\r
+EXIT /b 0\r
 \r
 :ERROR\r
-echo "Deletion of Bacula MySQL tables failed."\r
-exit /b %RESULT%\r
+ECHO Deletion of Bacula MySQL tables failed.\r
+EXIT /b %RESULT%\r
 
-rem \r
-rem  shell script to drop Bacula database(s)\r
-rem \r
+@ECHO off\r
+REM\r
+REM  Script to drop Bacula database(s)\r
+REM\r
 \r
-bindir=@SQL_BINDIR@\r
-\r
-$bindir/dropdb bacula\r
-if ERRORLEVEL 1 GOTO :ERROR\r
-echo "Drop of bacula database succeeded."\r
+"@SQL_BINDIR@\dropdb" %* bacula\r
+IF ERRORLEVEL 1 GOTO :ERROR\r
+ECHO Drop of bacula database succeeded.\r
 EXIT /b 0\r
 GOTO :EOF\r
 \r
 :ERROR\r
-echo "Drop of bacula database failed."\r
+ECHO Drop of bacula database failed.\r
 EXIT /b 1\r
 
-rem \r
-rem  shell script to delete Bacula tables for PostgreSQL\r
-rem\r
+@ECHO off\r
+REM\r
+REM  Script to delete Bacula tables for PostgreSQL\r
+REM\r
 \r
-bindir=@SQL_BINDIR@\r
-\r
-$bindir/psql -f drop_postgresql_tables.sql -d bacula $*\r
-if ERRORLEVEL 1 GOTO :ERROR\r
-echo "Deletion of Bacula PostgreSQL tables succeeded."\r
+"@SQL_BINDIR@\psql" -f "@bin_dir_cmd@\drop_postgresql_tables.sql" -d bacula %*\r
+IF ERRORLEVEL 1 GOTO :ERROR\r
+ECHO Deletion of Bacula PostgreSQL tables succeeded.\r
 EXIT /b 0\r
 GOTO :EOF\r
 \r
 :ERROR\r
-echo "Deletion of Bacula PostgreSQL tables failed."\r
+ECHO Deletion of Bacula PostgreSQL tables failed.\r
 EXIT /b 1\r
 
+++ /dev/null
-#!/bin/sh
-#
-# Shell script to fix PostgreSQL tables in version 8
-#
-echo " "
-echo "This script will fix a Bacula PostgreSQL database version 8"
-echo "Depending on the size of your database,"
-echo "this script may take several minutes to run."
-echo " "
-#
-# Set the following to the path to psql.
-bindir=****EDIT-ME to be the path to psql****
-
-if $bindir/psql $* -f - <<END-OF-DATA
-\c bacula
-
-begin;
-
-alter table media rename column endblock to endblock_old;
-alter table media add column endblock bigint;
-update media set endblock = endblock_old;
-alter table media alter column endblock set not null;
-alter table media drop column endblock_old;
-
-commit;
-
-vacuum;
-
-END-OF-DATA
-then
-   echo "Update of Bacula PostgreSQL tables succeeded."
-else
-   echo "Update of Bacula PostgreSQL tables failed."
-fi
-exit 0
 
+++ /dev/null
-rem \r
-rem  Shell script to fix PostgreSQL tables in version 8\r
-rem \r
-\r
-echo " "\r
-echo "This script will fix a Bacula PostgreSQL database version 8"\r
-echo "Depending on the size of your database,"\r
-echo "this script may take several minutes to run."\r
-echo " "\r
-#\r
-# Set the following to the path to psql.\r
-bindir=****EDIT-ME to be the path to psql****\r
-\r
-$bindir/psql $* -f fix_postgresql_tables.sql\r
-if ERRORLEVEL 1 GOTO :ERROR\r
-echo "Update of Bacula PostgreSQL tables succeeded."\r
-EXIT /b 0\r
-GOTO :EOF\r
-\r
-:ERROR\r
-echo "Update of Bacula PostgreSQL tables failed."\r
-EXIT /b 1\r
 
+++ /dev/null
-\c bacula\r
-\r
-begin;\r
-\r
-alter table media rename column endblock to endblock_old;\r
-alter table media add column endblock bigint;\r
-update media set endblock = endblock_old;\r
-alter table media alter column endblock set not null;\r
-alter table media drop column endblock_old;\r
-\r
-commit;\r
-\r
-vacuum;\r
 
-@echo off\r
-rem\r
-rem Script to grant privileges to the bacula database\r
-rem\r
+@ECHO off\r
+REM\r
+REM Script to grant privileges to the bacula database\r
+REM\r
 \r
-"%SQL_BINDIR%\mysql" -u root -f %* < grant_mysql_privileges.sql\r
-set RESULT=%ERRORLEVEL%\r
-if %RESULT% GTR 0 goto :ERROR\r
-echo "Privileges for bacula granted."\r
-exit /b 0\r
+"@SQL_BINDIR@\mysql" -u root -f %* < "@bin_dir_cmd@\grant_mysql_privileges.sql"\r
+SET RESULT=%ERRORLEVEL%\r
+IF %RESULT% GTR 0 GOTO :ERROR\r
+ECHO Privileges for bacula granted.\r
+EXIT /b 0\r
 \r
 :ERROR\r
-echo "Error creating privileges."\r
-exit /b %RESULT%\r
+ECHO Error creating privileges.\r
+EXIT /b %RESULT%\r
 
-rem \r
-rem  shell script to grant privileges to the bacula database\r
-rem \r
+@ECHO off\r
+REM\r
+REM  Script to grant privileges to the bacula database\r
+REM\r
 USER=bacula\r
-bindir=@SQL_BINDIR@\r
 \r
-$bindir/psql -f grant_postgresql_privileges.sql -d bacula $*\r
-if ERRORLEVEL 1 GOTO :ERROR\r
-echo "Error creating privileges."\r
+"@SQL_BINDIR@\psql" -f "@bin_dir_cmd@\grant_postgresql_privileges.sql" -d bacula %*\r
+IF ERRORLEVEL 1 GOTO :ERROR\r
+ECHO Error creating privileges.\r
 EXIT /b 0\r
 GOTO :EOF\r
 \r
 :ERROR\r
-echo "Drop of bacula database failed."\r
+ECHO Drop of bacula database failed.\r
 EXIT /b 1\r
 
+++ /dev/null
-rem \r
-rem  shell script to create Bacula tables\r
-rem \r
-rem  Nothing to do -- created by Bacula\r
-rem \r
 
+++ /dev/null
-@echo off\r
-rem \r
-rem  This script dumps your Bacula catalog in ASCII format\r
-rem  It works for MySQL, SQLite, and PostgreSQL\r
-rem \r
-rem   %1 is the name of the database to be backed up and the name\r
-rem      of the output file (default = bacula\r
-rem   %2 is the user name with which to access the database\r
-rem      (default = bacula).\r
-rem   %3 is the password with which to access the database or "" if no password\r
-rem      (default "")\r
-rem \r
-rem \r
-@echo on\r
-\r
-cd @working_dir_cmd@\r
-del /f bacula.sql 2>nul\r
-\r
-set MYSQLPASSWORD=\r
-\r
-if not "%3"=="" set MYSQLPASSWORD=--password=%3\r
-"@SQL_BINDIR@\mysqldump" -u %2 %MYSQLPASSWORD% -f --opt %1 >%1.sql\r
-\r
-@echo off\r
-rem \r
-rem   To read back a MySQL database use: \r
-rem      cd @working_dir_cmd@\r
-rem      rd /s /q @SQL_BINDIR@\..\data\bacula\r
-rem      mysql < bacula.sql\r
-rem \r
-rem   To read back a SQLite database use:\r
-rem      cd @working_dir_cmd@\r
-rem      del /f bacula.db\r
-rem      sqlite bacula.db < bacula.sql\r
-rem \r
-rem   To read back a PostgreSQL database use:\r
-rem      cd @working_dir_cmd@\r
-rem      dropdb bacula\r
-rem      createdb bacula\r
-rem      psql bacula < bacula.sql\r
-rem \r
 
-@echo off\r
-rem\r
-rem Script to create Bacula MySQL tables\r
-rem\r
+@ECHO off\r
+REM\r
+REM Script to create Bacula MySQL tables\r
+REM\r
 \r
-"%SQL_BINDIR%\mysql" -f %* < make_mysql_tables.sql\r
-set RESULT=%ERRORLEVEL%\r
-if %RESULT% GTR 0 goto :ERROR\r
-echo "Creation of Bacula MySQL tables succeeded."\r
-exit /b 0\r
+"@SQL_BINDIR@\mysql" -f %* < "@bin_dir_cmd@\make_mysql_tables.sql"\r
+SET RESULT=%ERRORLEVEL%\r
+IF %RESULT% GTR 0 GOTO :ERROR\r
+ECHO Creation of Bacula MySQL tables succeeded.\r
+EXIT /b 0\r
 \r
 :ERROR\r
-echo "Creation of Bacula MySQL tables failed."\r
-exit /b %RESULT%\r
+ECHO Creation of Bacula MySQL tables failed.\r
+EXIT /b %RESULT%\r
 
-rem \r
-rem  shell script to create Bacula PostgreSQL tables\r
-rem \r
-bindir=@SQL_BINDIR@\r
+@ECHO off\r
+REM\r
+REM  Script to create Bacula PostgreSQL tables\r
+REM\r
 \r
-$bindir/psql -f make_postgresql_tables.sql -d bacula $*\r
-if ERRORLEVEL 1 GOTO :ERROR\r
-echo "Creation of Bacula PostgreSQL tables succeeded."\r
+"@SQL_BINDIR@\psql" -f "@bin_dir_cmd@\make_postgresql_tables.sql" -d bacula %*\r
+IF ERRORLEVEL 1 GOTO :ERROR\r
+ECHO Creation of Bacula PostgreSQL tables succeeded.\r
 EXIT /b 0\r
 GOTO :EOF\r
 \r
 :ERROR\r
-echo "Creation of Bacula PostgreSQL tables failed."\r
+ECHO Creation of Bacula PostgreSQL tables failed.\r
 EXIT /b 1\r
 
+++ /dev/null
-rem \r
-rem  Shell script to update bdb tables\r
-rem  Nothing to do here.\r
-rem \r
 
+++ /dev/null
-@echo off\r
-rem\r
-rem Script to update MySQL tables from version 1.38 to 1.39\r
-rem\r
-echo.\r
-echo This script will update a Bacula MySQL database from version 9 to 10\r
-echo Depending on the size of your database,\r
-echo this script may take several minutes to run.\r
-echo.\r
-\r
-"%SQL_BINDIR%\mysql" %* -f -u bacula bacula < update_mysql_tables.sql\r
-set RESULT=%ERRORLEVEL%\r
-if %RESULT% GTR 0 goto :ERROR\r
-echo "Update of Bacula MySQL tables succeeded."\r
-exit /b 0\r
-\r
-:ERROR\r
-echo Update of Bacula MySQL tables failed.\r
-exit /b %RESULT%\r
 
+++ /dev/null
-USE bacula;\r
-\r
-DROP TABLE IF EXISTS MAC;\r
-DROP TABLE IF EXISTS Log;\r
-DROP TABLE IF EXISTS Location;\r
-DROP TABLE IF EXISTS LocationLog;\r
-\r
-CREATE TABLE Log (\r
-   LogId INTEGER UNSIGNED AUTO_INCREMENT,\r
-   JobId INTEGER UNSIGNED DEFAULT 0 REFERENCES Job,\r
-   Time DATETIME DEFAULT 0,\r
-   LogText BLOB NOT NULL,\r
-   PRIMARY KEY(LogId),\r
-   INDEX (JobId)\r
-   );\r
-\r
-CREATE TABLE Location (\r
-   LocationId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,\r
-   Location TINYBLOB NOT NULL,\r
-   Cost INTEGER DEFAULT 0,\r
-   Enabled TINYINT,\r
-   PRIMARY KEY(LocationId)\r
-   );\r
-\r
-CREATE TABLE LocationLog (\r
-   LocLogId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,\r
-   Date DATETIME DEFAULT 0,\r
-   Comment BLOB,\r
-   MediaId INTEGER UNSIGNED DEFAULT 0 REFERENCES Media,\r
-   LocationId INTEGER UNSIGNED DEFAULT 0 REFERENCES Location,\r
-   NewVolStatus ENUM('Full', 'Archive', 'Append', 'Recycle', 'Purged',\r
-    'Read-Only', 'Disabled', 'Error', 'Busy', 'Used', 'Cleaning') NOT NULL,\r
-   NewEnabled TINYINT,\r
-   PRIMARY KEY(LocLogId)\r
-);\r
-\r
-ALTER TABLE Media ADD COLUMN MediaTypeId INTEGER UNSIGNED DEFAULT 0 REFERENCES MediaType;\r
-ALTER TABLE Media ADD COLUMN DeviceId INTEGER UNSIGNED DEFAULT 0 REFERENCES Device;\r
-ALTER TABLE Media ADD COLUMN LocationId INTEGER UNSIGNED DEFAULT 0 REFERENCES Location;\r
-ALTER TABLE Media ADD COLUMN RecycleCount INTEGER UNSIGNED DEFAULT 0;\r
-ALTER TABLE Media ADD COLUMN InitialWrite DATETIME DEFAULT 0;\r
-ALTER TABLE Media ADD COLUMN ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool;\r
-ALTER TABLE Media ADD COLUMN RecyclePoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool;\r
-ALTER TABLE Media ADD COLUMN Enabled TINYINT DEFAULT 1;\r
-ALTER TABLE Media ADD COLUMN Comment BLOB;\r
-\r
-ALTER TABLE JobMedia DROP COLUMN Stripe;\r
-\r
-ALTER TABLE Job ADD COLUMN PriorJobId INTEGER UNSIGNED DEFAULT 0 REFERENCES Job;\r
-ALTER TABLE Job ADD COLUMN RealEndTime DATETIME DEFAULT 0;\r
-\r
-\r
-\r
-DELETE FROM Version;\r
-INSERT INTO Version (VersionId) VALUES (10);\r
 
+++ /dev/null
-rem \r
-rem  Shell script to update PostgreSQL tables from version 1.38 to 1.39\r
-rem \r
-\r
-echo " "\r
-echo "This script will update a Bacula PostgreSQL database from version 9 to 10"\r
-echo " which is needed to convert from Bacula version 1.38.x to 1.39.x or higher"\r
-echo "Depending on the size of your database,"\r
-echo "this script may take several minutes to run."\r
-echo " "\r
-bindir=@SQL_BINDIR@\r
-\r
-$bindir/psql -f update_postgresql_tables.sql -d bacula $*\r
-if ERRORLEVEL 1 GOTO :ERROR\r
-echo "Update of Bacula PostgreSQL tables succeeded."\r
-EXIT /b 0\r
-GOTO :EOF\r
-\r
-:ERROR\r
-echo "Update of Bacula PostgreSQL tables failed."\r
-EXIT /b 1\r
 
+++ /dev/null
-ALTER TABLE media ADD COLUMN DeviceId integer;\r
-UPDATE media SET DeviceId=0;\r
-ALTER TABLE media ADD COLUMN MediaTypeId integer;\r
-UPDATE media SET MediaTypeId=0;\r
-ALTER TABLE media ADD COLUMN LocationId integer;\r
-UPDATE media SET LocationId=0;\r
-ALTER TABLE media ADD COLUMN RecycleCount integer;\r
-UPDATE media SET RecycleCount=0;\r
-ALTER TABLE media ADD COLUMN InitialWrite timestamp without time zone;\r
-ALTER TABLE media ADD COLUMN scratchpoolid integer;\r
-UPDATE media SET scratchpoolid=0;\r
-ALTER TABLE media ADD COLUMN recyclepoolid integer;\r
-UPDATE media SET recyclepoolid=0;\r
-ALTER TABLE media ADD COLUMN enabled integer;\r
-UPDATE media SET enabled=1;\r
-ALTER TABLE media ADD COLUMN Comment TEXT;\r
-\r
-ALTER TABLE job ADD COLUMN RealEndTime timestamp without time zone;\r
-ALTER TABLE job ADD COLUMN PriorJobId integer;\r
-UPDATE job SET PriorJobId=0;\r
-\r
-ALTER TABLE jobmedia DROP COLUMN Stripe;\r
-\r
-CREATE TABLE Location (\r
-   LocationId SERIAL NOT NULL,\r
-   Location TEXT NOT NULL,\r
-   Cost integer default 0,\r
-   Enabled integer,\r
-   PRIMARY KEY (LocationId)\r
-);\r
-\r
-CREATE TABLE LocationLog (\r
-   LocLogId SERIAL NOT NULL,\r
-   Date timestamp   without time zone,\r
-   Comment TEXT NOT NULL,\r
-   MediaId INTEGER DEFAULT 0,\r
-   LocationId INTEGER DEFAULT 0,\r
-   newvolstatus text not null\r
-       check (newvolstatus in ('Full','Archive','Append',\r
-             'Recycle','Purged','Read-Only','Disabled',\r
-             'Error','Busy','Used','Cleaning','Scratch')),\r
-   newenabled smallint,\r
-   PRIMARY KEY(LocLogId)\r
-);\r
-\r
-\r
-CREATE TABLE Log\r
-(\r
-    LogId            serial      not null,\r
-    JobId            integer     not null,\r
-    Time             timestamp   without time zone,\r
-    LogText          text        not null,\r
-    primary key (LogId)\r
-);\r
-create index log_name_idx on Log (JobId);\r
-\r
-\r
-DELETE FROM version;\r
-INSERT INTO version (versionId) VALUES (10);\r
-\r
-vacuum;\r
 
    }
 
    *pargs = NULL;
+   *pexe = NULL;
 
    /* 
     * Scan command line looking for path separators (/ and \\) and the 
             if (GetFileAttributes(pPathname) != INVALID_FILE_ATTRIBUTES) {
                break;
             }
+            pPathname[dwBasePathLength] = '\0';
          }
       }
    } else if (!bHasPathSeparators) {
       /* There are no path separators, search in the standard locations */
       dwAltNameLength = SearchPath(NULL, pPathname, NULL, MAX_PATHLENGTH, pAltPathname, NULL);
-      if (dwAltNameLength == 0 || dwAltNameLength > MAX_PATHLENGTH) {
-         return false;
+      if (dwAltNameLength > 0 && dwAltNameLength < MAX_PATHLENGTH) {
+         memcpy(pPathname, pAltPathname, dwAltNameLength);
+         pPathname[dwAltNameLength] = '\0';
       }
-
-      memcpy(pPathname, pAltPathname, dwAltNameLength);
-      pPathname[dwAltNameLength] = '\0';
    }
 
    if (strchr(pPathname, ' ') != NULL) {
 
       if (dwAltNameLength > 0 && dwAltNameLength <= MAX_PATHLENGTH) {
          *pexe = (char *)malloc(dwAltNameLength + 1);
-         if (*pexe != NULL) {
-            memcpy(*pexe, pAltPathname, dwAltNameLength + 1);
-         } else {
+         if (*pexe == NULL) {
             return false;
          }
-      } else {
-         return false;
+         memcpy(*pexe, pAltPathname, dwAltNameLength + 1);
       }
-   } else {
+   }
+
+   if (*pexe == NULL) {
       DWORD dwPathnameLength = strlen(pPathname);
       *pexe = (char *)malloc(dwPathnameLength + 1);
-      if (*pexe != NULL) {
-         memcpy(*pexe, pPathname, dwPathnameLength + 1);
-      } else {
+      if (*pexe == NULL) {
          return false;
       }
+      memcpy(*pexe, pPathname, dwPathnameLength + 1);
    }
 
    return true;
    // setup new process to use supplied handles for stdin,stdout,stderr
    // if supplied handles are not used the send a copy of our STD_HANDLE
    // as appropriate
-   siStartInfo.dwFlags = STARTF_USESTDHANDLES;
+   siStartInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
+   siStartInfo.wShowWindow = SW_SHOWMINNOACTIVE;
 
    if (in != INVALID_HANDLE_VALUE)
       siStartInfo.hStdInput = in;
 
                                LinkIncremental="0"\r
                                SuppressStartupBanner="true"\r
                                AdditionalLibraryDirectories=""../../../../depkgs-msvc/lib";"$(SolutionDir)$(ConfigurationName)""\r
+                               IgnoreDefaultLibraryNames="msvcrt"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                TargetMachine="1"\r
 
                                LinkIncremental="0"\r
                                SuppressStartupBanner="true"\r
                                AdditionalLibraryDirectories="../../../../depkgs-msvc/lib"\r
+                               IgnoreDefaultLibraryNames="msvcrt"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                TargetMachine="1"\r
 
    pthread_t tid;
    DWORD dwCharsWritten;
 
-   InitWinAPIWrapper();
+   OSDependentInit();
 
    /* If no arguments were given then just run */
    if (p_AttachConsole == NULL || !p_AttachConsole(ATTACH_PARENT_PROCESS)) {
 
     IntOp $R7 $R7 - 2
     IntOp $R8 $R8 + 2
 
+    ${If} $ConfigDirectorDB = 0
+      ${If} $MySQLPath != ""
+        StrCpy $ConfigDirectorDB 1
+      ${ElseIf} $PostgreSQLPath != ""
+        StrCpy $ConfigDirectorDB 2
+      ${Else}
+        StrCpy $ConfigDirectorDB 3
+      ${EndIf}
+    ${EndIf}
+
     ${If} $ConfigDirectorDB = 1
       StrCpy $R9 1
     ${Else}
 
     FileWrite $R5 '[Field $R6]$\r$\nType="RadioButton"$\r$\nState=$R9$\r$\nText="Sqlite"$\r$\nFlags="NOTABSTOP"$\r$\nLeft=150$\r$\nTop=$R7$\r$\nRight=182$\r$\nBottom=$R8$\r$\n$\r$\n'
 
-    IntOp $R6 $R6 + 1
-
-    ${If} $ConfigDirectorDB = 4
-      StrCpy $R9 1
-    ${Else}
-      StrCpy $R9 0
-    ${EndIf}
-
-    FileWrite $R5 '[Field $R6]$\r$\nType="RadioButton"$\r$\nState=$R9$\r$\nText="Builtin"$\r$\nFlags="NOTABSTOP"$\r$\nLeft=186$\r$\nTop=$R7$\r$\nRight=222$\r$\nBottom=$R8$\r$\n$\r$\n'
-
     IntOp $R6 $R6 + 1
     IntOp $R7 $R7 + 12
 
       StrCpy $ConfigDirectorDB 3
     ${Endif}
     IntOp $R6 $R6 + 1
-    !insertmacro MUI_INSTALLOPTIONS_READ $R5 "ConfigPage2.ini" "Field $R6" "State"
-    ${If} $R5 = 1
-      StrCpy $ConfigDirectorDB 4
-    ${Endif}
-    IntOp $R6 $R6 + 1
 
     ${If} $AutomaticInstall = 0
       !insertmacro MUI_INSTALLOPTIONS_READ $ConfigDirectorInstallService "ConfigPage2.ini" "Field $R6" "State"
 
       WriteINIStr "$PLUGINSDIR\InstallType.ini" "Field 1" "Text" "A previous installation has been found in $OldInstallDir.  Please choose the installation type for any additional components you select."
       WriteINIStr "$PLUGINSDIR\InstallType.ini" "Field 5" "Text" "The configuration files for additional components will be generated using defaults applicable to most installations."
       WriteINIStr "$PLUGINSDIR\InstallType.ini" "Field 6" "Text" "The configuration defaults for additional components will be displayed and you will be given the chance to make changes before the configuration files are written."
+
+      ReadRegDWORD $ConfigDirectorDB HKLM Software\Bacula Database
+
+      ${If} $ConfigDirectorDB = 0
+        IntOp $R0 $PreviousComponents & ${ComponentDirector}
+        ${If} $R0 <> 0
+          StrCpy $ConfigDirectorDB 1
+        ${EndIf}
+      ${EndIf}
     ${Else}
       ; Processing Upgrade - Get Install Directory
       ${StrRep} $R0 $R0 '"' ''
 
 DEFINES := \
        -DVERSION=$(VERSION) \
        -DOUT_DIR=..\\release \
-       -DDOC_DIR=$(DOCDIR) \
+       -DSRC_DIR=release \
        -DBUILD_TOOLS=MinGW \
-       -DMINGW_BIN=$(MINGW_BIN) \
-       -DDEPKGS_BIN=. \
-       -DBACULA_BIN=. \
-       -DCATS_DIR=..\\cats \
-       -DSCRIPT_DIR=..\\scripts
 
 INSTALL_EXE := ../release/winbacula-$(VERSION).exe
 
        bacula.dll \
        cats_mysql.dll \
        cats_pgsql.dll \
-       cats_bdb.dll \
+       cats_sqlite.dll \
        bacula-dir.exe \
        bacula-fd.exe \
        bacula-sd.exe \
        pthreadGCE.dll \
        ssleay32.dll \
        zlib1.dll \
+       sqlite3.exe \
        openssl.exe \
        loaderinfo.exe \
        mt.exe \
 NONGCC_LIBRARIES := \
        libpq.dll
 
-SCRIPTS := \
-       ../scripts/mtx-changer.cmd \
-       ../cats/create_bdb_database.cmd \
-       ../cats/drop_bdb_database.cmd \
-       ../cats/make_bdb_tables.cmd \
-       ../cats/drop_bdb_tables.cmd \
-       ../cats/update_bdb_tables.cmd \
-       ../cats/grant_bdb_privileges.cmd \
-       ../cats/create_mysql_database.cmd \
-       ../cats/drop_mysql_database.cmd \
-       ../cats/make_mysql_tables.cmd \
-       ../cats/make_mysql_tables.sql \
-       ../cats/drop_mysql_tables.cmd \
-       ../cats/drop_mysql_tables.sql \
-       ../cats/update_mysql_tables.cmd \
-       ../cats/update_mysql_tables.sql \
-       ../cats/grant_mysql_privileges.cmd \
-       ../cats/grant_mysql_privileges.sql \
-       ../cats/create_postgresql_database.cmd \
-       ../cats/drop_postgresql_database.cmd \
-       ../cats/make_postgresql_tables.cmd \
-       ../cats/make_postgresql_tables.sql \
-       ../cats/drop_postgresql_tables.cmd \
-       ../cats/drop_postgresql_tables.sql \
-       ../cats/update_postgresql_tables.cmd \
-       ../cats/update_postgresql_tables.sql \
-       ../cats/grant_postgresql_privileges.cmd \
-       ../cats/grant_postgresql_privileges.sql \
-       ../cats/make_catalog_backup.cmd \
-       ../cats/delete_catalog_backup.cmd
+MINGW_BINARIES := \
+       mingwm10.dll
+
+SCRIPT_FILES := \
+       mtx-changer.cmd
+
+CAT_FILES := \
+       create_mysql_database.cmd \
+       drop_mysql_database.cmd \
+       make_mysql_tables.cmd \
+       make_mysql_tables.sql \
+       drop_mysql_tables.cmd \
+       drop_mysql_tables.sql \
+       grant_mysql_privileges.cmd \
+       grant_mysql_privileges.sql \
+       make_mysql_catalog_backup.cmd \
+       create_postgresql_database.cmd \
+       drop_postgresql_database.cmd \
+       make_postgresql_tables.cmd \
+       make_postgresql_tables.sql \
+       drop_postgresql_tables.cmd \
+       drop_postgresql_tables.sql \
+       grant_postgresql_privileges.cmd \
+       grant_postgresql_privileges.sql \
+       make_postgresql_catalog_backup.cmd \
+       create_sqlite3_database.cmd \
+       drop_sqlite3_database.cmd \
+       make_sqlite3_tables.cmd \
+       drop_sqlite3_tables.cmd \
+       grant_sqlite3_privileges.cmd \
+       make_sqlite3_catalog_backup.cmd \
+       delete_catalog_backup.cmd
 
 DIRD_FILES := \
        query.sql
 SSL_FILES := \
        openssl.cnf
 
+DOC_FILES := \
+       manual/bacula.pdf \
+       manual/bacula/*.html \
+       manual/bacula/*.png  \
+       manual/bacula/*.css
+
 ##########################################################################
 
 # Targets
 
 clean:
        @echo "Cleaning `pwd`"
-       $(CMD_ECHO)-rm -f $(INSTALL_EXE) $(BACULA_BINARIES) $(DEPKGS_BINARIES) $(NONGCC_BINARIES) $(NONGCC_LIBRARIES) $(SSL_FILES) $(DIRD_FILES)
-       $(CMD_ECHO)-rm -f $(BACULA_BINARIES) $(addsuffix .dbg,$(basename $(BACULA_BINARIES)))
-       $(CMD_ECHO)-rm -f $(DEPKGS_BINARIES) $(addsuffix .dbg,$(basename $(DEPKGS_BINARIES)))
-       $(CMD_ECHO)-rm -f *.exe
+       $(CMD_ECHO)-rm -f $(INSTALL_EXE)
+       $(CMD_ECHO)-rm -rf release
 
 #
 # Rules
 #
 
 define Convert_Binary
-$$(notdir $(1)): $(1)
+release/$$(notdir $(1)): $(1)
+       $$(call checkdir,$$@)
        $(ECHO_CMD)cp -f $$^ $$@ ; \
        $(STAB2CV) $$@
 endef
 
 define Copy_Binary
-$$(notdir $(1)): $(1)
+release/$$(notdir $(1)): $(1)
+       $$(call checkdir,$$@)
        $(ECHO_CMD)cp -f $$^ $$@
 endef
 
+define Copy_Docs
+release/$(1): $(DOCDIR)/$(1)
+       $$(call checkdir,$$@)
+       $(ECHO_CMD)cp -f $$^ $$(dir $$@)
+endef
+
 $(foreach file,$(addprefix $(DEPKGS)/bin/, $(DEPKGS_BINARIES)),$(eval $(call Convert_Binary,$(file))))
 
 $(foreach file,$(addprefix $(DEPKGS)/bin/, $(NONGCC_BINARIES)),$(eval $(call Copy_Binary,$(file))))
 
 $(foreach file,$(addprefix $(BINDIR)/, $(BACULA_BINARIES)),$(eval $(call Convert_Binary,$(file))))
 
+$(foreach file,$(addprefix $(MINGW_DLLDIR)/, $(MINGW_BINARIES)),$(eval $(call Copy_Binary,$(file))))
+
 $(foreach file,$(addprefix $(DEPKGS)/ssl/, $(SSL_FILES)),$(eval $(call Copy_Binary,$(file))))
 
+$(foreach file,$(addprefix ../scripts/, $(SCRIPT_FILES)),$(eval $(call Copy_Binary,$(file))))
+
+$(foreach file,$(addprefix ../cats/, $(CAT_FILES)),$(eval $(call Copy_Binary,$(file))))
+
 $(foreach file,$(addprefix ../../dird/, $(DIRD_FILES)),$(eval $(call Copy_Binary,$(file))))
 
-$(INSTALL_EXE): winbacula.nsi $(BACULA_BINARIES) $(SCRIPTS) $(DEPKGS_BINARIES) $(NONGCC_BINARIES) $(NONGCC_LIBRARIES) $(SSL_FILES) $(DIRD_FILES)
+$(foreach file,$(DOC_FILES),$(eval $(call Copy_Docs,$(file))))
+
+$(INSTALL_EXE): winbacula.nsi $(addprefix release/,$(BACULA_BINARIES) $(SCRIPT_FILES) $(CAT_FILES) $(DEPKGS_BINARIES) $(NONGCC_BINARIES) $(NONGCC_LIBRARIES) $(MINGW_BINARIES) $(SSL_FILES) $(DIRD_FILES) $(DOC_FILES))
        NSISDIR=$(NSIS_DIR) \
        $(NSIS_DIR)/makensis -V3 $(DEFINES) winbacula.nsi
 
 
 #    directory to give a reasonable FileSet to backup to
 #    disk storage during initial testing.
 #
-    File = "C:/Program Files/Bacula"
+    File = "@BUILD_DIR@"
   }
 
 #
 
 Device {
   Name = FileStorage
   Media Type = File
-  Archive Device = "C:\\Temp"
+  Archive Device = "C:\\Tmp"
   LabelMedia = yes                   # lets Bacula label unlabeled media
   Random Access = Yes
   AutomaticMount = yes               # when device opened, read it
 
 @ECHO OFF
 SETLOCAL
-PATH ..\..\..\..\depkgs-msvc\nsis;..\..\..\..\depkgs-msvc\tools;%PATH%
+
+SET CWD=%CD%
+CD %1..\..\..
+SET TOP_DIR=%CD%
+CD %CWD%
+SET DEPKG_DIR=%TOP_DIR%\depkgs-msvc
+SET DOCS_DIR=%TOP_DIR%\docs\manual
+
+SET BACULA_DLLS=bacula.dll cats_mysql.dll cats_pgsql.dll cats_sqlite.dll
+SET BACULA_EXES=bacula-dir.exe bacula-fd.exe bacula-sd.exe bconsole.exe wx-console.exe
+SET BACULA_TOOLS=bcopy.exe bextract.exe bls.exe bscan.exe bsleep.exe bsmtp.exe btape.exe dbcheck.exe scsilist.exe
+
+SET DEP_DLLS=libeay32.dll pthreadVCE.dll ssleay32.dll zlib1.dll zlib1.dll.manifest wxbase270_vc_bacula.dll wxmsw270_core_vc_bacula.dll libmysql.dll libpq.dll comerr32.dll libintl-2.dll libiconv-2.dll krb5_32.dll
+SET DEP_EXES=openssl.exe loaderinfo.exe mt.exe mtx.exe scsitape.exe sed.exe tapeinfo.exe sqlite3.exe sqlite3.exe.manifest
+
+SET SCRIPTS=mtx-changer.cmd 
+SET CATS_MYSQL_CMD=create_mysql_database.cmd drop_mysql_database.cmd make_mysql_tables.cmd drop_mysql_tables.cmd grant_mysql_privileges.cmd
+SET CATS_MYSQL_SQL=make_mysql_tables.sql drop_mysql_tables.sql grant_mysql_privileges.sql
+SET CATS_PGSQL_CMD=create_postgresql_database.cmd drop_postgresql_database.cmd make_postgresql_tables.cmd drop_postgresql_tables.cmd grant_postgresql_privileges.cmd
+SET CATS_PGSQL_SQL=make_postgresql_tables.sql drop_postgresql_tables.sql grant_postgresql_privileges.sql
+SET CATS_SQLITE_CMD=create_sqlite3_database.cmd drop_sqlite3_database.cmd make_sqlite3_tables.cmd drop_sqlite3_tables.cmd grant_sqlite3_privileges.cmd
+SET CATS_SQLITE_SQL=make_sqlite3_tables.sql
+SET CATS_CATALOG=make_mysql_catalog_backup.cmd make_postgresql_catalog_backup.cmd make_sqlite3_catalog_backup.cmd delete_catalog_backup.cmd
+SET DIRD_FILES=query.sql
+SET SSL_FILES=openssl.cnf
+
+SET DOC_PDF_FILES=%DOCS_DIR%\bacula.pdf %DOCS_DIR%\bacula\*.html %DOCS_DIR%\bacula\*.png %DOCS_DIR%\bacula\*.css
+SET DOC_HTML_FILES=%DOCS_DIR%\bacula\*.html %DOCS_DIR%\bacula\*.png %DOCS_DIR%\bacula\*.css
+
+FOR %%i in ( %BACULA_DLLS% )     DO COPY %1%2\%%i %1installer\%2
+FOR %%i in ( %BACULA_EXES% )     DO COPY %1%2\%%i %1installer\%2
+FOR %%i in ( %BACULA_TOOLS% )    DO COPY %1%2\%%i %1installer\%2
+
+FOR %%i in ( %DEP_DLLS% )        DO COPY %DEPKG_DIR%\bin\%%i %1installer\%2
+FOR %%i in ( %DEP_EXES% )        DO COPY %DEPKG_DIR%\bin\%%i %1installer\%2
+
+FOR %%i in ( %SCRIPTS% )         DO COPY %1scripts\%%i %1installer\%2
+FOR %%i in ( %CATS_MYSQL_CMD% )  DO COPY %1cats\%%i %1installer\%2
+FOR %%i in ( %CATS_MYSQL_SQL% )  DO COPY %1cats\%%i %1installer\%2
+FOR %%i in ( %CATS_PGSQL_CMD% )  DO COPY %1cats\%%i %1installer\%2
+FOR %%i in ( %CATS_PGSQL_SQL% )  DO COPY %1cats\%%i %1installer\%2
+FOR %%i in ( %CATS_SQLITE_CMD% ) DO COPY %1cats\%%i %1installer\%2
+FOR %%i in ( %CATS_SQLITE_SQL% ) DO COPY %1cats\%%i %1installer\%2
+
+FOR %%i in ( %CATS_CATALOG% )    DO COPY %1cats\%%i %1installer\%2
+
+FOR %%i in ( %DIRD_FILES% )      DO COPY %1..\dird\%%i %1installer\%2
+FOR %%i in ( %SSL_FILES% )       DO COPY %DEPKG_DIR%\%%i %1installer\%2
+
+IF NOT EXIST %1installer\%2\manual MKDIR %1installer\%2\manual
+FOR %%i in ( %DOC_PDF_FILES% )   DO COPY %%i %1installer\%2\manual
+
+IF NOT EXIST %1installer\%2\manual\bacula MKDIR %1installer\%2\manual\bacula
+FOR %%i in ( %DOC_HTML_FILES% )  DO COPY %%i %1installer\%2\manual\bacula
+
+COPY %4\x86\Microsoft.VC80.CRT\msvcm80.dll %1installer\%2
+COPY %4\x86\Microsoft.VC80.CRT\msvcp80.dll %1installer\%2
+COPY %4\x86\Microsoft.VC80.CRT\msvcr80.dll %1installer\%2
+COPY %4\x86\Microsoft.VC80.CRT\Microsoft.VC80.CRT.manifest %1installer\%2
+COPY %4\Debug_NonRedist\x86\Microsoft.VC80.DebugCRT\msvcm80d.dll %1installer\%2
+COPY %4\Debug_NonRedist\x86\Microsoft.VC80.DebugCRT\msvcp80d.dll %1installer\%2
+COPY %4\Debug_NonRedist\x86\Microsoft.VC80.DebugCRT\msvcr80d.dll %1installer\%2
+COPY %4\Debug_NonRedist\x86\Microsoft.VC80.DebugCRT\Microsoft.VC80.DebugCRT.manifest %1installer\%2
+
+PATH %DEPKG_DIR%\nsis;%DEPKG_DIR%\tools;%PATH%
+
 FOR /F %%i IN ( 'sed -ne "s/.*[ \t]VERSION[ \t][ \t]*\x22\(.*\)\x22/\1/p" ^< ..\..\version.h' ) DO @SET VERSION=%%i 
-makensis /V3 /DVERSION=%VERSION% /DOUT_DIR=%1%2 /DDOC_DIR=..\..\..\..\docs /DBUILD_TOOLS=%3 /DVC_REDIST_DIR=%4 /DDEPKGS_BIN=..\..\..\..\depkgs-msvc\bin /DBACULA_BIN=..\%2 /DCATS_DIR=..\cats /DSCRIPT_DIR=..\scripts winbacula.nsi
+makensis /V3 /DVERSION=%VERSION% /DSRC_DIR=%1installer\%2 /DOUT_DIR=%1%2 /DBUILD_TOOLS=%3 winbacula.nsi
 EXIT /B %ERRORLEVEL%
-ENDLOCAL
 
 ;
 ; Command line options:
 ;
-; /cygwin     -  do cygwin install into c:\cygwin\bacula
 ; /service    - 
 ; /start
 
 ;
 ; Global Variables
 ;
-Var OptCygwin
 Var OptService
 Var OptStart
 Var OptSilent
 
 Var CommonFilesDone
-Var DatabaseDone
 
 Var OsIsNT
 
 Var LocalDirectorPassword
 Var LocalHostAddress
 
+Var MySQLPath
+Var MySQLVersion
+Var PostgreSQLPath
+Var PostgreSQLVersion
+
 Var AutomaticInstall
 Var InstallType
 !define NewInstall      0
   Push $R1
 
   ; Process Command Line Options
-  StrCpy $OptCygwin 0
   StrCpy $OptService 1
   StrCpy $OptStart 1
   StrCpy $OptSilent 0
   StrCpy $CommonFilesDone 0
-  StrCpy $DatabaseDone 0
   StrCpy $OsIsNT 0
   StrCpy $AutomaticInstall 0
   StrCpy $InstallType ${NewInstall}
   StrCpy $OldInstallDir ""
   StrCpy $PreviousComponents 0
   StrCpy $NewComponents 0
+  StrCpy $MySQLPath ""
+  StrCpy $MySQLVersion ""
+  StrCpy $PostgreSQLPath ""
+  StrCpy $PostgreSQLVersion ""
 
   ${GetParameters} $R0
 
-  ClearErrors
-  ${GetOptions} $R0 "/cygwin" $R1
-  IfErrors +2
-    StrCpy $OptCygwin 1
-
   ClearErrors
   ${GetOptions} $R0 "/noservice" $R1
   IfErrors +2
   IfSilent 0 +2
     StrCpy $OptSilent 1
 
-  ${If} $OptCygwin = 1
-    StrCpy $INSTDIR "C:\cygwin\bacula"
-  ${EndIf}
-
   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
   ${If} $R0 != ""
     StrCpy $OsIsNT 1
   Call GetUserName
   Pop $ConfigDirectorMailAddress
 
+  Call FindDatabaseApps
+
   ; Configuration Defaults
 
-  StrCpy $ConfigClientName              "$HostName-fd"
-  StrCpy $ConfigClientPort              "9102"
-  StrCpy $ConfigClientMaxJobs           "2"
+  StrCpy $ConfigClientName               "$HostName-fd"
+  StrCpy $ConfigClientPort               9102
+  StrCpy $ConfigClientMaxJobs            2
   ;StrCpy $ConfigClientPassword
-  StrCpy $ConfigClientInstallService    "$OptService"
-  StrCpy $ConfigClientStartService      "$OptStart"
+  StrCpy $ConfigClientInstallService     "$OptService"
+  StrCpy $ConfigClientStartService       "$OptStart"
 
-  StrCpy $ConfigStorageName             "$HostName-sd"
-  StrCpy $ConfigStoragePort             "9103"
-  StrCpy $ConfigStorageMaxJobs          "10"
+  StrCpy $ConfigStorageName              "$HostName-sd"
+  StrCpy $ConfigStoragePort              9103
+  StrCpy $ConfigStorageMaxJobs           10
   ;StrCpy $ConfigStoragePassword
-  StrCpy $ConfigStorageInstallService   "$OptService"
-  StrCpy $ConfigStorageStartService     "$OptStart"
+  StrCpy $ConfigStorageInstallService    "$OptService"
+  StrCpy $ConfigStorageStartService      "$OptStart"
 
   ;StrCpy $ConfigDirectorName            "$HostName-dir"
-  StrCpy $ConfigDirectorPort            "9101"
-  StrCpy $ConfigDirectorMaxJobs         "1"
+  StrCpy $ConfigDirectorPort             9101
+  StrCpy $ConfigDirectorMaxJobs          1
   ;StrCpy $ConfigDirectorPassword
-  StrCpy $ConfigDirectorDB              "1"
-  StrCpy $ConfigDirectorInstallService  "$OptService"
-  StrCpy $ConfigDirectorStartService    "$OptStart"
+  StrCpy $ConfigDirectorDB               0
+  StrCpy $ConfigDirectorInstallService   "$OptService"
+  StrCpy $ConfigDirectorStartService     "$OptStart"
 
-  StrCpy $ConfigMonitorName            "$HostName-mon"
+  StrCpy $ConfigMonitorName              "$HostName-mon"
   ;StrCpy $ConfigMonitorPassword
 
   InitPluginsDir
-  File "/oname=$PLUGINSDIR\openssl.exe"  "${DEPKGS_BIN}\openssl.exe"
-  File "/oname=$PLUGINSDIR\libeay32.dll" "${DEPKGS_BIN}\libeay32.dll"
-  File "/oname=$PLUGINSDIR\ssleay32.dll" "${DEPKGS_BIN}\ssleay32.dll"
-  File "/oname=$PLUGINSDIR\sed.exe" "${DEPKGS_BIN}\sed.exe"
+  File "/oname=$PLUGINSDIR\openssl.exe"  "${SRC_DIR}\openssl.exe"
+  File "/oname=$PLUGINSDIR\libeay32.dll" "${SRC_DIR}\libeay32.dll"
+  File "/oname=$PLUGINSDIR\ssleay32.dll" "${SRC_DIR}\ssleay32.dll"
+  File "/oname=$PLUGINSDIR\sed.exe"      "${SRC_DIR}\sed.exe"
 
   !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "InstallType.ini"
   !InsertMacro MUI_INSTALLOPTIONS_EXTRACT "WriteTemplates.ini"
 
     SetOutPath "$INSTDIR\bin"
 !if "${BUILD_TOOLS}" == "VC8"
-    File "${VC_REDIST_DIR}\x86\Microsoft.VC80.CRT\msvcm80.dll"
-    File "${VC_REDIST_DIR}\x86\Microsoft.VC80.CRT\msvcp80.dll"
-    File "${VC_REDIST_DIR}\x86\Microsoft.VC80.CRT\msvcr80.dll"
-    File "${VC_REDIST_DIR}\x86\Microsoft.VC80.CRT\Microsoft.VC80.CRT.manifest"
-    File "${DEPKGS_BIN}\pthreadVCE.dll"
+    File "${SRC_DIR}\msvcm80.dll"
+    File "${SRC_DIR}\msvcp80.dll"
+    File "${SRC_DIR}\msvcr80.dll"
+    File "${SRC_DIR}\Microsoft.VC80.CRT.manifest"
+    File "${SRC_DIR}\pthreadVCE.dll"
 !endif
 !if "${BUILD_TOOLS}" == "VC8_DEBUG"
-    File "${VC_REDIST_DIR}\x86\Microsoft.VC80.CRT\msvcm80.dll"
-    File "${VC_REDIST_DIR}\x86\Microsoft.VC80.CRT\msvcp80.dll"
-    File "${VC_REDIST_DIR}\x86\Microsoft.VC80.CRT\msvcr80.dll"
-    File "${VC_REDIST_DIR}\x86\Microsoft.VC80.CRT\Microsoft.VC80.CRT.manifest"
-    File "${VC_REDIST_DIR}\Debug_NonRedist\x86\Microsoft.VC80.DebugCRT\msvcm80d.dll"
-    File "${VC_REDIST_DIR}\Debug_NonRedist\x86\Microsoft.VC80.DebugCRT\msvcp80d.dll"
-    File "${VC_REDIST_DIR}\Debug_NonRedist\x86\Microsoft.VC80.DebugCRT\msvcr80d.dll"
-    File "${VC_REDIST_DIR}\Debug_NonRedist\x86\Microsoft.VC80.DebugCRT\Microsoft.VC80.DebugCRT.manifest"
-    File "${DEPKGS_BIN}\pthreadVCE.dll"
+    File "${SRC_DIR}\msvcm80.dll"
+    File "${SRC_DIR}\msvcp80.dll"
+    File "${SRC_DIR}\msvcr80.dll"
+    File "${SRC_DIR}\Microsoft.VC80.CRT.manifest"
+    File "${SRC_DIR}\msvcm80d.dll"
+    File "${SRC_DIR}\msvcp80d.dll"
+    File "${SRC_DIR}\msvcr80d.dll"
+    File "${SRC_DIR}\Microsoft.VC80.DebugCRT.manifest"
+    File "${SRC_DIR}\pthreadVCE.dll"
 !endif
 !if "${BUILD_TOOLS}" == "MinGW"
-    File "${MINGW_BIN}\..\mingw32\bin\mingwm10.dll"
-    File "${DEPKGS_BIN}\pthreadGCE.dll"
+    File "${SRC_DIR}\mingwm10.dll"
+    File "${SRC_DIR}\pthreadGCE.dll"
 !endif
-    File "${DEPKGS_BIN}\libeay32.dll"
-    File "${DEPKGS_BIN}\ssleay32.dll"
-    File "${DEPKGS_BIN}\zlib1.dll"
+    File "${SRC_DIR}\libeay32.dll"
+    File "${SRC_DIR}\ssleay32.dll"
+    File "${SRC_DIR}\zlib1.dll"
 !if "${BUILD_TOOLS}" == "VC8"
-    File "${DEPKGS_BIN}\zlib1.dll.manifest"
-    File "/oname=$INSTDIR\openssl.cnf" "${DEPKGS_BIN}\..\openssl.cnf"
+    File "${SRC_DIR}\zlib1.dll.manifest"
 !endif
 !If "${BUILD_TOOLS}" == "VC8_DEBUG"
-    File "${DEPKGS_BIN}\zlib1.dll.manifest"
-    File "/oname=$INSTDIR\openssl.cnf" "${DEPKGS_BIN}\..\openssl.cnf"
-!endif
-!if "${BUILD_TOOLS}" == "MinGW"
-    File "/oname=$INSTDIR\openssl.cnf" "${DEPKGS_BIN}\openssl.cnf"
+    File "${SRC_DIR}\zlib1.dll.manifest"
 !endif
-    File "${DEPKGS_BIN}\openssl.exe"
-    File "${BACULA_BIN}\bsleep.exe"
-    File "${BACULA_BIN}\bsmtp.exe"
-    File "${BACULA_BIN}\bacula.dll"
+    File "/oname=$INSTDIR\openssl.cnf" "${SRC_DIR}\openssl.cnf"
+    File "${SRC_DIR}\openssl.exe"
+    File "${SRC_DIR}\bsleep.exe"
+    File "${SRC_DIR}\bsmtp.exe"
+    File "${SRC_DIR}\bacula.dll"
 
     CreateShortCut "$SMPROGRAMS\Bacula\Documentation\View Readme.lnk" "write.exe" '"$INSTDIR\Readme.txt"'
 
   ${EndIf}
 FunctionEnd
 
-Function InstallDatabase
-  SetOutPath "$INSTDIR\bin"
-
-  ${If} $DatabaseDone = 0
-    ${If} $ConfigDirectorDB = 1
-      File /oname=bacula_cats.dll "${BACULA_BIN}\cats_mysql.dll"
-      File "${DEPKGS_BIN}\libmysql.dll"
-    ${ElseIf} $ConfigDirectorDB = 2
-      File /oname=bacula_cats.dll "${BACULA_BIN}\cats_pgsql.dll"
-      File "${DEPKGS_BIN}\libpq.dll"
-!if "${BUILD_TOOLS}" == "VC8"
-      File "${DEPKGS_BIN}\comerr32.dll"
-      File "${DEPKGS_BIN}\libintl-2.dll"
-      File "${DEPKGS_BIN}\libiconv-2.dll"
-      File "${DEPKGS_BIN}\krb5_32.dll"
-!endif
-!If "${BUILD_TOOLS}" == "VC8_DEBUG"
-      File "${DEPKGS_BIN}\comerr32.dll"
-      File "${DEPKGS_BIN}\libintl-2.dll"
-      File "${DEPKGS_BIN}\libiconv-2.dll"
-      File "${DEPKGS_BIN}\krb5_32.dll"
-!endif
-    ${ElseIf} $ConfigDirectorDB = 4
-      File /oname=bacula_cats.dll "${BACULA_BIN}\cats_bdb.dll"
-    ${EndIf}
-
-    StrCpy $DatabaseDone 1
+Section "-Initialize"
+  ${If} $MySQLPath != ""
+    DetailPrint "Found MySQL (version $MySQLVersion)"
+  ${EndIf}
+  ${If} $PostgreSQLPath != ""
+    DetailPrint "Found PostgreSQL (version $PostgreSQLVersion)"
   ${EndIf}
-FunctionEnd
 
-Section "-Initialize"
   WriteRegStr   HKLM Software\Bacula InstallLocation "$INSTDIR"
 
   Call GetSelectedComponents
   Pop $R2
   WriteRegDWORD HKLM Software\Bacula Components $R2
 
+  WriteRegDWORD HKLM Software\Bacula Database $ConfigDirectorDB
+
   ; remove start menu items
   SetShellVarContext all
 
   ${StrRep} $R2 "$INSTDIR\bin" "\" "\\"
   FileWrite $R1 's;@bin_dir_cmd@;$R2;$\r$\n'
 
+  ${StrRep} $R2 "$INSTDIR" "\" "/"
+  FileWrite $R1 "s;@BUILD_DIR@;$R2;$\r$\n"
+
   Call IsDirectorSelected
   Pop $R2
   ${If} $R2 = 1
     FileWrite $R1 "s;@monitor_password@;$ConfigMonitorPassword;$\r$\n"
   ${EndIf}
 
+  ${If} $ConfigDirectorDB = 1
+    ${If} $MySQLPath != ""
+      ${StrRep} $R2 "$MySQLPath\bin" "\" "\\"
+      FileWrite $R1 "s;@SQL_BINDIR@;$R2;$\r$\n"
+    ${EndIf}
+  ${ElseIf} $ConfigDirectorDB = 2
+    ${If} $PostgreSQLPath != ""
+      ${StrRep} $R2 "$PostgreSQLPath\bin" "\" "\\"
+      FileWrite $R1 "s;@SQL_BINDIR@;$R2;$\r$\n"
+    ${EndIf}
+  ${EndIf}
+
   FileClose $R1
 
   ${If} $InstallType = ${MigrateInstall}
 
   SetOutPath "$INSTDIR\bin"
 
-  File "${BACULA_BIN}\bacula-fd.exe"
+  File "${SRC_DIR}\bacula-fd.exe"
 
   ${If} $InstallType = ${MigrateInstall}
   ${AndIf} ${FileExists} "$OldInstallDir\bin\bacula-fd.conf"
     CopyFiles "$OldInstallDir\bin\bacula-fd.conf" "$APPDATA\Bacula"
     nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\migrate.sed" -i.bak "$APPDATA\Bacula\bacula-fd.conf"'
   ${Else}
-    ${Unless} ${FileExists} "$APPDATA\Bacula\bacula-fd.conf"
-      File "/oname=$PLUGINSDIR\bacula-fd.conf.in" "bacula-fd.conf.in"
-
-      nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\bacula-fd.conf.in"'
-      CopyFiles "$PLUGINSDIR\bacula-fd.conf.in" "$APPDATA\Bacula\bacula-fd.conf"
-    ${EndUnless}
-  ${EndIf}
+    File "/oname=$PLUGINSDIR\bacula-fd.conf" "bacula-fd.conf.in"
 
-  ${If} $OsIsNT = 1
-    nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$R1" /G SYSTEM:F Administrators:F'
+    StrCpy $0 "$APPDATA\Bacula"
+    StrCpy $1 bacula-fd.conf
+    Call ConfigEditAndCopy
   ${EndIf}
 
   StrCpy $0 bacula-fd
 
   SetOutPath "$INSTDIR\bin"
 
-  File "${DEPKGS_BIN}\loaderinfo.exe"
-  File "${DEPKGS_BIN}\mt.exe"
-  File "${DEPKGS_BIN}\mtx.exe"
-  File "${DEPKGS_BIN}\scsitape.exe"
-  File "${DEPKGS_BIN}\tapeinfo.exe"
-  File "${BACULA_BIN}\bacula-sd.exe"
-  File "${BACULA_BIN}\bcopy.exe"
-  File "${BACULA_BIN}\bextract.exe"
-  File "${BACULA_BIN}\bls.exe"
-  File "${BACULA_BIN}\bscan.exe"
-  File "${BACULA_BIN}\btape.exe"
-  File "${BACULA_BIN}\scsilist.exe"
-
-  ${Unless} ${FileExists} "${BACULA_BIN}\mtx-changer.cmd"
-    File "/oname=$PLUGINSDIR\mtx-changer.cmd" "${SCRIPT_DIR}\mtx-changer.cmd"
-
-    nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\mtx-changer.cmd"'
-    CopyFiles "$PLUGINSDIR\mtx-changer.cmd" "$INSTDIR\bin\mtx-changer.cmd"
-  ${EndUnless}
-
-  ${Unless} ${FileExists} "$APPDATA\Bacula\bacula-sd.conf"
-    File "/oname=$PLUGINSDIR\bacula-sd.conf.in" "bacula-sd.conf.in"
-
-    nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\bacula-sd.conf.in"'
-    CopyFiles "$PLUGINSDIR\bacula-sd.conf.in" "$APPDATA\Bacula\bacula-sd.conf"
-  ${EndUnless}
+  File "${SRC_DIR}\loaderinfo.exe"
+  File "${SRC_DIR}\mt.exe"
+  File "${SRC_DIR}\mtx.exe"
+  File "${SRC_DIR}\scsitape.exe"
+  File "${SRC_DIR}\tapeinfo.exe"
+  File "${SRC_DIR}\bacula-sd.exe"
+  File "${SRC_DIR}\bcopy.exe"
+  File "${SRC_DIR}\bextract.exe"
+  File "${SRC_DIR}\bls.exe"
+  File "${SRC_DIR}\bscan.exe"
+  File "${SRC_DIR}\btape.exe"
+  File "${SRC_DIR}\scsilist.exe"
 
-  ${If} $OsIsNT = 1
-    nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$R1" /G SYSTEM:F Administrators:F'
-  ${EndIf}
+  File "/oname=$PLUGINSDIR\mtx-changer.cmd" "${SRC_DIR}\mtx-changer.cmd"
+
+  StrCpy $0 "$INSTDIR\bin"
+  StrCpy $1 mtx-changer.cmd
+  Call ConfigEditAndCopy
+
+  File "/oname=$PLUGINSDIR\bacula-sd.conf" "bacula-sd.conf.in"
+
+  StrCpy $0 "$APPDATA\Bacula"
+  StrCpy $1 bacula-sd.conf
+  Call ConfigEditAndCopy
 
   StrCpy $0 bacula-sd
   StrCpy $1 "Storage Service"
 
   SetOutPath "$INSTDIR\bin"
 
-  Call InstallDatabase
-  File "${BACULA_BIN}\bacula-dir.exe"
-  File "${BACULA_BIN}\dbcheck.exe"
-
   ${If} $ConfigDirectorDB = 1
-    File /oname=create_database.cmd ${CATS_DIR}\create_mysql_database.cmd
-    File /oname=drop_database.cmd ${CATS_DIR}\drop_mysql_database.cmd
-    File /oname=make_tables.cmd ${CATS_DIR}\make_mysql_tables.cmd
-    File ${CATS_DIR}\make_mysql_tables.sql
-    File /oname=drop_tables.cmd ${CATS_DIR}\drop_mysql_tables.cmd
-    File ${CATS_DIR}\drop_mysql_tables.sql
-    File /oname=update_tables.cmd ${CATS_DIR}\update_mysql_tables.cmd
-    File ${CATS_DIR}\update_mysql_tables.sql
-    File /oname=grant_privileges.cmd ${CATS_DIR}\grant_mysql_privileges.cmd
-    File ${CATS_DIR}\grant_mysql_privileges.sql
+    File /oname=bacula_cats.dll "${SRC_DIR}\cats_mysql.dll"
+    File "${SRC_DIR}\libmysql.dll"
+    File /oname=$PLUGINSDIR\create_database.cmd ${SRC_DIR}\create_mysql_database.cmd
+    File /oname=$PLUGINSDIR\drop_database.cmd ${SRC_DIR}\drop_mysql_database.cmd
+    File /oname=$PLUGINSDIR\make_tables.cmd ${SRC_DIR}\make_mysql_tables.cmd
+    File ${SRC_DIR}\make_mysql_tables.sql
+    File /oname=$PLUGINSDIR\drop_tables.cmd ${SRC_DIR}\drop_mysql_tables.cmd
+    File ${SRC_DIR}\drop_mysql_tables.sql
+    File /oname=$PLUGINSDIR\grant_privileges.cmd ${SRC_DIR}\grant_mysql_privileges.cmd
+    File ${SRC_DIR}\grant_mysql_privileges.sql
+    File /oname=$PLUGINSDIR\make_catalog_backup.cmd ${SRC_DIR}\make_mysql_catalog_backup.cmd
   ${ElseIf} $ConfigDirectorDB = 2
-    File /oname=create_database.cmd ${CATS_DIR}\create_postgresql_database.cmd
-    File /oname=drop_database.cmd ${CATS_DIR}\drop_postgresql_database.cmd
-    File /oname=make_tables.cmd ${CATS_DIR}\make_postgresql_tables.cmd
-    File ${CATS_DIR}\make_postgresql_tables.sql
-    File /oname=drop_tables.cmd ${CATS_DIR}\drop_postgresql_tables.cmd
-    File ${CATS_DIR}\drop_postgresql_tables.sql
-    File /oname=update_tables.cmd ${CATS_DIR}\update_postgresql_tables.cmd
-    File ${CATS_DIR}\update_postgresql_tables.sql
-    File /oname=grant_privileges.cmd ${CATS_DIR}\grant_postgresql_privileges.cmd
-    File ${CATS_DIR}\grant_postgresql_privileges.sql
-  ${ElseIf} $ConfigDirectorDB = 4
-    File /oname=create_database.cmd ${CATS_DIR}\create_bdb_database.cmd
-    File /oname=drop_database.cmd ${CATS_DIR}\drop_bdb_database.cmd
-    File /oname=make_tables.cmd ${CATS_DIR}\make_bdb_tables.cmd
-    File /oname=drop_tables.cmd ${CATS_DIR}\drop_bdb_tables.cmd
-    File /oname=update_tables.cmd ${CATS_DIR}\update_bdb_tables.cmd
-    File /oname=grant_privileges.cmd ${CATS_DIR}\grant_bdb_privileges.cmd
+    File /oname=bacula_cats.dll "${SRC_DIR}\cats_pgsql.dll"
+    File "${SRC_DIR}\libpq.dll"
+!if "${BUILD_TOOLS}" == "VC8"
+    File "${SRC_DIR}\comerr32.dll"
+    File "${SRC_DIR}\libintl-2.dll"
+    File "${SRC_DIR}\libiconv-2.dll"
+    File "${SRC_DIR}\krb5_32.dll"
+!endif
+!If "${BUILD_TOOLS}" == "VC8_DEBUG"
+    File "${SRC_DIR}\comerr32.dll"
+    File "${SRC_DIR}\libintl-2.dll"
+    File "${SRC_DIR}\libiconv-2.dll"
+    File "${SRC_DIR}\krb5_32.dll"
+!endif
+    File /oname=$PLUGINSDIR\create_database.cmd ${SRC_DIR}\create_postgresql_database.cmd
+    File /oname=$PLUGINSDIR\drop_database.cmd ${SRC_DIR}\drop_postgresql_database.cmd
+    File /oname=$PLUGINSDIR\make_tables.cmd ${SRC_DIR}\make_postgresql_tables.cmd
+    File ${SRC_DIR}\make_postgresql_tables.sql
+    File /oname=$PLUGINSDIR\drop_tables.cmd ${SRC_DIR}\drop_postgresql_tables.cmd
+    File ${SRC_DIR}\drop_postgresql_tables.sql
+    File /oname=$PLUGINSDIR\grant_privileges.cmd ${SRC_DIR}\grant_postgresql_privileges.cmd
+    File ${SRC_DIR}\grant_postgresql_privileges.sql
+    File /oname=$PLUGINSDIR\make_catalog_backup.cmd ${SRC_DIR}\make_postgresql_catalog_backup.cmd
+  ${ElseIf} $ConfigDirectorDB = 3
+    File "${SRC_DIR}\sqlite3.exe"
+!if "${BUILD_TOOLS}" == "VC8"
+    File "${SRC_DIR}\sqlite3.exe.manifest"
+!endif
+!If "${BUILD_TOOLS}" == "VC8_DEBUG"
+    File "${SRC_DIR}\sqlite3.exe.manifest"
+!endif
+    File /oname=bacula_cats.dll "${SRC_DIR}\cats_sqlite.dll"
+    File /oname=$PLUGINSDIR\create_database.cmd ${SRC_DIR}\create_sqlite3_database.cmd
+    File /oname=$PLUGINSDIR\drop_database.cmd ${SRC_DIR}\drop_sqlite3_database.cmd
+    File /oname=$PLUGINSDIR\make_tables.cmd ${SRC_DIR}\make_sqlite3_tables.cmd
+    File /oname=$PLUGINSDIR\drop_tables.cmd ${SRC_DIR}\drop_sqlite3_tables.cmd
+    File /oname=$PLUGINSDIR\grant_privileges.cmd ${SRC_DIR}\grant_sqlite3_privileges.cmd
+    File /oname=$PLUGINSDIR\make_catalog_backup.cmd ${SRC_DIR}\make_sqlite3_catalog_backup.cmd
   ${EndIf}
-  ${Unless} ${FileExists} "$INSTDIR\bin\make_catalog_backup.cmd"
-    File "/oname=$PLUGINSDIR\make_catalog_backup.cmd" "${CATS_DIR}\make_catalog_backup.cmd"
-    nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\make_catalog_backup.cmd"'
-    CopyFiles "$PLUGINSDIR\make_catalog_backup.cmd" "$INSTDIR\bin\make_catalog_backup.cmd"
-  ${EndUnless}
-  ${Unless} ${FileExists} "$INSTDIR\bin\delete_catalog_backup.cmd"
-    File "/oname=$PLUGINSDIR\delete_catalog_backup.cmd" "${CATS_DIR}\delete_catalog_backup.cmd"
-    nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\delete_catalog_backup.cmd"'
-    CopyFiles "$PLUGINSDIR\delete_catalog_backup.cmd" "$INSTDIR\bin\delete_catalog_backup.cmd"
-  ${EndUnless}
-  File "query.sql"
-
-  ${Unless} ${FileExists} "$APPDATA\Bacula\bacula-dir.conf"
-    File "/oname=$PLUGINSDIR\bacula-dir.conf.in" "bacula-dir.conf.in"
-    nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\bacula-dir.conf.in"'
-    CopyFiles "$PLUGINSDIR\bacula-dir.conf.in" "$APPDATA\Bacula\bacula-dir.conf"
-  ${EndUnless}
 
-  ${If} $OsIsNT = 1
-    nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$R1" /G SYSTEM:F Administrators:F'
-  ${EndIf}
+  File "${SRC_DIR}\bacula-dir.exe"
+  File "${SRC_DIR}\dbcheck.exe"
+
+  File "/oname=$PLUGINSDIR\delete_catalog_backup.cmd" "${SRC_DIR}\delete_catalog_backup.cmd"
+
+  StrCpy $0 "$INSTDIR\bin"
+  
+  StrCpy $1 create_database.cmd
+  Call ConfigEditAndCopy
+
+  StrCpy $1 drop_database.cmd
+  Call ConfigEditAndCopy
+
+  StrCpy $1 make_tables.cmd
+  Call ConfigEditAndCopy
+
+  StrCpy $1 drop_tables.cmd
+  Call ConfigEditAndCopy
+
+  StrCpy $1 grant_privileges.cmd
+  Call ConfigEditAndCopy
+
+  StrCpy $1 make_catalog_backup.cmd
+  Call ConfigEditAndCopy
+
+  StrCpy $1 delete_catalog_backup.cmd
+  Call ConfigEditAndCopy
+
+  File "${SRC_DIR}\query.sql"
+
+  File "/oname=$PLUGINSDIR\bacula-dir.conf" "bacula-dir.conf.in"
+
+  StrCpy $0 "$APPDATA\Bacula"
+  StrCpy $1 bacula-dir.conf
+  Call ConfigEditAndCopy
 
   StrCpy $0 bacula-dir
   StrCpy $1 "Director Service"
 
   SetOutPath "$INSTDIR\bin"
 
-  File "${BACULA_BIN}\bconsole.exe"
+  File "${SRC_DIR}\bconsole.exe"
   Call InstallCommonFiles
 
   ${If} $InstallType = ${MigrateInstall}
   ${AndIf} ${FileExists} "$OldInstallDir\bin\bconsole.conf"
     CopyFiles "$OldInstallDir\bin\bconsole.conf" "$APPDATA\Bacula"
   ${Else}
-    ${Unless} ${FileExists} "$APPDATA\Bacula\bconsole.conf"
-      File "/oname=$PLUGINSDIR\bconsole.conf.in" "bconsole.conf.in"
-      nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\bconsole.conf.in"'
-      CopyFiles "$PLUGINSDIR\bconsole.conf.in" "$APPDATA\Bacula\bconsole.conf"
-    ${EndUnless}
-  ${EndIf}
-
-  ${If} $OsIsNT = 1
-    nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$R1" /G SYSTEM:F Administrators:F'
+    File "/oname=$PLUGINSDIR\bconsole.conf" "bconsole.conf.in"
+    StrCpy $0 "$APPDATA\Bacula"
+    StrCpy $1 bconsole.conf
+    Call ConfigEditAndCopy
   ${EndIf}
 
   CreateShortCut "$SMPROGRAMS\Bacula\bconsole.lnk" "$INSTDIR\bin\bconsole.exe" '-c "$APPDATA\Bacula\bconsole.conf"' "$INSTDIR\bin\bconsole.exe" 0
 
   Call InstallCommonFiles
 !if "${BUILD_TOOLS}" == "VC8"
-  File "${DEPKGS_BIN}\wxbase270_vc_bacula.dll"
-  File "${DEPKGS_BIN}\wxmsw270_core_vc_bacula.dll"
+  File "${SRC_DIR}\wxbase270_vc_bacula.dll"
+  File "${SRC_DIR}\wxmsw270_core_vc_bacula.dll"
 !endif
 !If "${BUILD_TOOLS}" == "VC8_DEBUG"
-  File "${DEPKGS_BIN}\wxbase270_vc_bacula.dll"
-  File "${DEPKGS_BIN}\wxmsw270_core_vc_bacula.dll"
+  File "${SRC_DIR}\wxbase270_vc_bacula.dll"
+  File "${SRC_DIR}\wxmsw270_core_vc_bacula.dll"
 !endif
 !if "${BUILD_TOOLS}" == "MinGW"
-  File "${DEPKGS_BIN}\wxbase26_gcc_bacula.dll"
-  File "${DEPKGS_BIN}\wxmsw26_core_gcc_bacula.dll"
+  File "${SRC_DIR}\wxbase26_gcc_bacula.dll"
+  File "${SRC_DIR}\wxmsw26_core_gcc_bacula.dll"
 !endif
 
-  File "${BACULA_BIN}\wx-console.exe"
+  File "${SRC_DIR}\wx-console.exe"
 
   ${If} $InstallType = ${MigrateInstall}
   ${AndIf} ${FileExists} "$OldInstallDir\bin\wx-console.conf"
     CopyFiles "$OldInstallDir\bin\wx-console.conf" "$APPDATA\Bacula"
   ${Else}
-    ${Unless} ${FileExists} "$APPDATA\Bacula\wx-console.conf"
-      File "/oname=$PLUGINSDIR\wx-console.conf.in" "wx-console.conf.in"
-      nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\wx-console.conf.in"'
-      CopyFiles "$PLUGINSDIR\wx-console.conf.in" "$APPDATA\Bacula\wx-console.conf"
-    ${EndUnless}
-  ${EndIf}
-
-  ${If} $OsIsNT = 1
-    nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$R1" /G SYSTEM:F Administrators:F'
+    File "/oname=$PLUGINSDIR\wx-console.conf" "wx-console.conf.in"
+    StrCpy $0 "$APPDATA\Bacula"
+    StrCpy $1 wx-console.conf
+    Call ConfigEditAndCopy
   ${EndIf}
 
   ; Create Start Menu entry
   SetOutPath "$INSTDIR\doc"
   CreateDirectory "$INSTDIR\doc"
 
-  File "${DOC_DIR}\manual\bacula.pdf"
+  File "${SRC_DIR}\manual\bacula.pdf"
   CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Manual.lnk" '"$INSTDIR\doc\bacula.pdf"'
 SectionEnd
 
   SetOutPath "$INSTDIR\doc"
   CreateDirectory "$INSTDIR\doc"
 
-  File "${DOC_DIR}\manual\bacula\*.html"
-  File "${DOC_DIR}\manual\bacula\*.png"
-  File "${DOC_DIR}\manual\bacula\*.css"
+  File "${SRC_DIR}\manual\bacula\*.html"
+  File "${SRC_DIR}\manual\bacula\*.png"
+  File "${SRC_DIR}\manual\bacula\*.css"
   CreateShortCut "$SMPROGRAMS\Bacula\Documentation\Manual (HTML).lnk" '"$INSTDIR\doc\bacula.html"'
 SectionEnd
 
 SectionGroupEnd
 
-Section "-Write Uninstaller"
+Section "-Finish"
   Push $R0
+
+  ${If} $OsIsNT = 1
+    nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$INSTDIR" /T /G SYSTEM:F Administrators:F'
+    nsExec::ExecToLog 'cmd.exe /C echo Y|cacls "$APPDATA\Bacula" /T /G SYSTEM:F Administrators:F'
+  ${EndIf}
+
   ; Write the uninstall keys for Windows & create Start Menu entry
   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayName" "Bacula"
   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "InstallLocation" "$INSTDIR"
   Exch $R0
 FunctionEnd
 
+Function ConfigEditAndCopy
+  Push $R1
+
+  ${If} ${FileExists} "$0\$1"
+    StrCpy $R1 ".new"
+  ${Else}
+    StrCpy $R1 ""
+  ${EndIf}
+
+  nsExec::ExecToLog '$PLUGINSDIR\sed.exe -f "$PLUGINSDIR\config.sed" -i.bak "$PLUGINSDIR\$1"'
+  CopyFiles "$PLUGINSDIR\$1" "$0\$1$R1"
+
+  Pop $R1
+FunctionEnd
+
+Function FindDatabaseApps
+  Push $R1
+
+  ReadRegStr $0 HKLM "Software\MySQL AB\MySQL Server 5.0" "Location"
+
+  ${If} $0 != ""
+    Call RemoveTrailingSlash
+    StrCpy $MySQLPath $0
+    ReadRegStr $0 HKLM "Software\MySQL AB\MySQL Server 5.0" "Version"
+    StrCpy $MySQLVersion $0
+  ${EndIf}
+
+  EnumRegKey $R1 HKLM "Software\PostgreSQL\Installations" 0
+  ${If} $R1 != ""
+    ReadRegStr $0 HKLM "Software\PostgreSQL\Installations\$R1" "Base Directory"
+    Call RemoveTrailingSlash
+    StrCpy $PostgreSQLPath $0
+    ReadRegStr $0 HKLM "Software\PostgreSQL\Installations\$R1" "Version"
+    StrCpy $PostgreSQLVersion $0
+  ${EndIf}
+
+  Pop $R1
+FunctionEnd
+
+Function RemoveTrailingSlash
+  Push $R1
+  StrCpy $R1 $0 "" -1
+  ${If} $R1 == "\"
+    StrCpy $0 $0 -1
+  ${EndIf}
+  Pop $R1
+FunctionEnd
+
 Function IsDirectorSelected
   Push $R0
   SectionGetFlags ${SecDirectorDaemon} $R0
 FunctionEnd
 
 Function PageComponentsShow
-  ${If} $OsIsNT != 1
+  ${If} $OsIsNT <> 1
     Call DisableServerSections
   ${EndIf}
 
 
                                        />\r
                                </FileConfiguration>\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\lib\alloc.c"\r
-                               >\r
-                               <FileConfiguration\r
-                                       Name="Debug|Win32"\r
-                                       >\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"\r
-                                               CompileAs="2"\r
-                                       />\r
-                               </FileConfiguration>\r
-                               <FileConfiguration\r
-                                       Name="Release|Win32"\r
-                                       >\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"\r
-                                               CompileAs="2"\r
-                                       />\r
-                               </FileConfiguration>\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\lib\attr.c"\r
                                >\r
                                        />\r
                                </FileConfiguration>\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\lib\semlock.c"\r
-                               >\r
-                               <FileConfiguration\r
-                                       Name="Debug|Win32"\r
-                                       >\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"\r
-                                               CompileAs="2"\r
-                                       />\r
-                               </FileConfiguration>\r
-                               <FileConfiguration\r
-                                       Name="Release|Win32"\r
-                                       >\r
-                                       <Tool\r
-                                               Name="VCCLCompilerTool"\r
-                                               CompileAs="2"\r
-                                       />\r
-                               </FileConfiguration>\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\lib\serial.c"\r
                                >\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\findlib\protos.h"\r
+                               RelativePath="..\..\lib\protos.h"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\lib\protos.h"\r
+                               RelativePath="..\..\findlib\protos.h"\r
                                >\r
                        </File>\r
                        <File\r
                                RelativePath="..\compat\sched.h"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\lib\semlock.h"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\lib\serial.h"\r
                                >\r
 
 ?get@alist@@QAEPAXH@Z
 ?destroy@alist@@QAEXXZ
  
-; alloc.obj 
- 
 ; attr.obj 
 ?new_attr@@YAPAUATTR@@XZ
 ?free_attr@@YAXPAUATTR@@@Z
 ?free_msgs_res@@YAXPAUMSGS@@@Z
 ?term_msg@@YAXXZ
 ?dispatch_message@@YAXPAVJCR@@HJPAD@Z
-??0POOL_MEM@@QAE@H@Z
-??1POOL_MEM@@QAE@XZ
 ?c_str@POOL_MEM@@QBEPADXZ
 ?d_msg@@YAXPBDHH0ZZ
 ?get_basename@@YAPBDPBD@Z
 ?parse_args@@YAHPADPAPADPAH11H@Z
 ?bsscanf@@YAHPBD0ZZ
  
-; semlock.obj 
- 
 ; serial.obj 
 ?serial_int32@@YAXQAPAEJ@Z
 ?serial_uint32@@YAXQAPAEI@Z
 
 REM    you will have the following input to this script:
 REM
 REM  Bacula will always call with all the following arguments, even though
-REM    in come cases, not all are used.
+REM    in some cases, not all are used.
 REM
 REM  mtx-changer "changer-device" "command" "slot" "archive-device" "drive-index"
 REM                     %1           %2       %3          %4             %5
 SET dbgfile="%working_dir%\mtx.log"
 
 REM to turn on logging, uncomment the following line
-REM findstr xxx <nul >>"%working_dir%\mtx.log"
+REM copy nul "%working_dir%\mtx.log"
 
 REM
 REM check parameter count on commandline
 
                                LinkIncremental="0"
                                SuppressStartupBanner="true"
                                AdditionalLibraryDirectories="../../../../../depkgs-msvc/lib"
+                               IgnoreDefaultLibraryNames="msvcrt"
                                GenerateDebugInformation="true"
                                SubSystem="2"
                                TargetMachine="1"
 
                                RuntimeLibrary="3"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="false"\r
                                SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="false"\r
                                DebugInformationFormat="4"\r
                        />\r
                        <Tool\r
                                AdditionalDependencies="wsock32.lib zlib.lib pthreadVCE.lib atlsd.lib"\r
                                LinkIncremental="0"\r
                                AdditionalLibraryDirectories="../../../../../depkgs-msvc/lib"\r
+                               IgnoreDefaultLibraryNames="msvcrt"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="1"\r
                                TargetMachine="1"\r
                                UsePrecompiledHeader="0"\r
                                BrowseInformation="1"\r
                                WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="false"\r
                                SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="false"\r
                                DebugInformationFormat="3"\r
                        />\r
                        <Tool\r