]> git.sur5r.net Git - bacula/bacula/commitdiff
Add all the new files from the Windows branch.
authorRobert Nelson <robertn@the-nelsons.org>
Fri, 30 Jun 2006 04:14:19 +0000 (04:14 +0000)
committerRobert Nelson <robertn@the-nelsons.org>
Fri, 30 Jun 2006 04:14:19 +0000 (04:14 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3095 91ce42f0-d328-0410-95d8-f526ca767f89

54 files changed:
bacula/src/win32/cats/Makefile [new file with mode: 0644]
bacula/src/win32/cats/cats.vcproj [new file with mode: 0644]
bacula/src/win32/cats/create_mysql_database.cmd [new file with mode: 0644]
bacula/src/win32/cats/delete_catalog_backup.cmd [new file with mode: 0644]
bacula/src/win32/cats/drop_mysql_database.cmd [new file with mode: 0644]
bacula/src/win32/cats/drop_mysql_tables.cmd [new file with mode: 0644]
bacula/src/win32/cats/drop_mysql_tables.sql [new file with mode: 0644]
bacula/src/win32/cats/grant_mysql_privileges.cmd [new file with mode: 0644]
bacula/src/win32/cats/grant_mysql_privileges.sql [new file with mode: 0644]
bacula/src/win32/cats/make_catalog_backup.cmd [new file with mode: 0644]
bacula/src/win32/cats/make_mysql_tables.cmd [new file with mode: 0644]
bacula/src/win32/cats/make_mysql_tables.sql [new file with mode: 0644]
bacula/src/win32/cats/update_mysql_tables.cmd [new file with mode: 0644]
bacula/src/win32/cats/update_mysql_tables.sql [new file with mode: 0644]
bacula/src/win32/dird/Makefile [new file with mode: 0644]
bacula/src/win32/dird/dird.vcproj [new file with mode: 0644]
bacula/src/win32/dird/winbacula.h [new file with mode: 0644]
bacula/src/win32/dird/winmain.cpp [new file with mode: 0644]
bacula/src/win32/dird/winservice.cpp [new file with mode: 0644]
bacula/src/win32/dird/winservice.h [new file with mode: 0644]
bacula/src/win32/dll/Makefile [new file with mode: 0644]
bacula/src/win32/dll/bacula.def [new file with mode: 0644]
bacula/src/win32/libbac/Makefile [new file with mode: 0644]
bacula/src/win32/libbac/libbac.vcproj [new file with mode: 0644]
bacula/src/win32/libfind/Makefile [new file with mode: 0644]
bacula/src/win32/libfind/libfind.vcproj [new file with mode: 0644]
bacula/src/win32/libwin32/bacula.bmp [new file with mode: 0644]
bacula/src/win32/libwin32/bacula.ico [new file with mode: 0644]
bacula/src/win32/libwin32/bacula.rc [new file with mode: 0644]
bacula/src/win32/libwin32/error.ico [new file with mode: 0644]
bacula/src/win32/libwin32/idle.ico [new file with mode: 0644]
bacula/src/win32/libwin32/libwin32.vcproj [new file with mode: 0644]
bacula/src/win32/libwin32/popup.c [new file with mode: 0644]
bacula/src/win32/libwin32/running.ico [new file with mode: 0644]
bacula/src/win32/libwin32/saving.ico [new file with mode: 0644]
bacula/src/win32/libwin32/warn.ico [new file with mode: 0644]
bacula/src/win32/libwin32/winabout.cpp [new file with mode: 0644]
bacula/src/win32/libwin32/winabout.h [new file with mode: 0644]
bacula/src/win32/libwin32/winbacula.h [new file with mode: 0644]
bacula/src/win32/libwin32/winevents.cpp [new file with mode: 0644]
bacula/src/win32/libwin32/winevents.h [new file with mode: 0644]
bacula/src/win32/libwin32/winres.h [new file with mode: 0644]
bacula/src/win32/libwin32/winres.rc [new file with mode: 0644]
bacula/src/win32/libwin32/winservice.h [new file with mode: 0644]
bacula/src/win32/libwin32/winstat.cpp [new file with mode: 0644]
bacula/src/win32/libwin32/winstat.h [new file with mode: 0644]
bacula/src/win32/libwin32/wintray.cpp [new file with mode: 0644]
bacula/src/win32/libwin32/wintray.h [new file with mode: 0644]
bacula/src/win32/scripts/mtx-changer.cmd.in [new file with mode: 0644]
bacula/src/win32/scripts/sleep.c [new file with mode: 0644]
bacula/src/win32/scripts/sleep.vcproj [new file with mode: 0644]
bacula/src/win32/stored/Makefile [new file with mode: 0644]
bacula/src/win32/stored/mtops.cpp [new file with mode: 0644]
bacula/src/win32/tools/Makefile [new file with mode: 0644]

diff --git a/bacula/src/win32/cats/Makefile b/bacula/src/win32/cats/Makefile
new file mode 100644 (file)
index 0000000..46b71a0
--- /dev/null
@@ -0,0 +1,73 @@
+#
+# Makefile for win32 bacula executables
+# Using MinGW cross-compiler on GNU/Linux
+#  
+#  Written for Bacula by Howard Thomson, April 2006
+# 
+
+include ../Makefile.inc
+
+INCLUDES = \
+       $(INCLUDE_GCC) \
+       $(INCLUDE_MINGW) \
+       $(INCLUDE_PTHREADS) \
+       $(INCLUDE_BACULA) \
+       $(INCLUDE_ZLIB) \
+       $(INCLUDE_VSS) \
+       $(INCLUDE_ICONS) \
+       $(INCLUDE_OPENSSL) \
+       $(INCLUDE_MYSQL)
+
+DEFINES = \
+       -DWIN32 \
+       $(HAVES)
+
+######################################################################
+
+# Files in src/cats
+
+LIB_OBJS = \
+       $(OBJDIR)/bdb.o \
+       $(OBJDIR)/bdb_create.o \
+       $(OBJDIR)/bdb_delete.o \
+       $(OBJDIR)/bdb_find.o \
+       $(OBJDIR)/bdb_get.o \
+       $(OBJDIR)/bdb_list.o \
+       $(OBJDIR)/bdb_update.o \
+       $(OBJDIR)/mysql.o \
+       $(OBJDIR)/postgresql.o \
+       $(OBJDIR)/sql.o \
+       $(OBJDIR)/sql_create.o \
+       $(OBJDIR)/sql_delete.o \
+       $(OBJDIR)/sql_find.o \
+       $(OBJDIR)/sql_get.o \
+       $(OBJDIR)/sql_list.o \
+       $(OBJDIR)/sql_update.o \
+       $(OBJDIR)/sqlite.o
+
+######################################################################
+
+# Targets
+
+.PHONY: all clean
+
+all: $(LIBDIR)/libcats.a
+
+clean:
+       @echo "Cleaning `pwd`"
+       $(ECHO_CMD)rm -f $(OBJDIR)/*.[od] $(LIBDIR)/libcats.a
+
+#
+# Rules
+# 
+
+$(LIBDIR)/libcats.a: $(LIB_OBJS)
+       @echo "Updating archive $@"
+       $(call checkdir,$@)
+       $(ECHO_CMD)$(AR) rs $@ $^ $(LIB_OBJS)
+
+include ../Makefile.rules
+
+ifneq ($(MAKECMDGOALS),clean)
+include $(patsubst %.o,%.d,$(filter-out %.res,$(LIB_OBJS)))
+endif
diff --git a/bacula/src/win32/cats/cats.vcproj b/bacula/src/win32/cats/cats.vcproj
new file mode 100644 (file)
index 0000000..87ab1f2
--- /dev/null
@@ -0,0 +1,519 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="libcats"
+       ProjectGUID="{BAB13141-20F9-4B2D-8C0A-021804ADD077}"
+       RootNamespace="libcats"
+       Keyword="Win32Proj"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="4"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="../compat;../..;&quot;../../../../depkgs-win32/pthreads&quot;;&quot;C:\Program Files\MySQL\MySQL Server 5.0\include&quot;"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_LIB;HAVE_WIN32;HAVE_MYSQL;WIN32_VSS;_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="VCLibrarianTool"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="4"
+                       UseOfATL="1"
+                       CharacterSet="2"
+                       WholeProgramOptimization="0"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="../compat;../..;&quot;../../../../depkgs-win32/pthreads&quot;;&quot;C:\Program Files\MySQL\MySQL Server 5.0\include&quot;"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_LIB;HAVE_WIN32;WIN32_VSS;_USE_32BIT_TIME_T;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
+                               RuntimeLibrary="2"
+                               EnableFunctionLevelLinking="true"
+                               UsePrecompiledHeader="0"
+                               BrowseInformation="1"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="false"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLibrarianTool"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       >
+                       <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\mysql.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\postgresql.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.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"
+                       >
+                       <File
+                               RelativePath="..\..\cats\bdb.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\cats\cats.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\cats\protos.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"
+                       >
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/bacula/src/win32/cats/create_mysql_database.cmd b/bacula/src/win32/cats/create_mysql_database.cmd
new file mode 100644 (file)
index 0000000..138bff3
--- /dev/null
@@ -0,0 +1,13 @@
+rem
+rem Script to create Bacula database(s)
+rem
+
+%SQL_BINDIR%\mysql $* -e "CREATE DATABASE bacula;"
+set RESULT=%ERRORLEVEL%
+if %RESULT% GTR 0 goto :ERROR
+echo "Creation of bacula database succeeded."
+exit /b 0
+
+:ERROR
+echo "Creation of bacula database failed."
+exit /b %RESULT%
diff --git a/bacula/src/win32/cats/delete_catalog_backup.cmd b/bacula/src/win32/cats/delete_catalog_backup.cmd
new file mode 100644 (file)
index 0000000..a3cfcf6
--- /dev/null
@@ -0,0 +1,4 @@
+rem
+rem This script deletes a catalog dump
+rem
+del /f %WORKING_DIR%/bacula.sql
diff --git a/bacula/src/win32/cats/drop_mysql_database.cmd b/bacula/src/win32/cats/drop_mysql_database.cmd
new file mode 100644 (file)
index 0000000..586de2a
--- /dev/null
@@ -0,0 +1,13 @@
+rem
+rem shell script to drop Bacula database(s)
+rem
+
+%SQL_BINDIR%/mysql $* -f -e "DROP DATABASE bacula;"
+set RESULT=%ERRORLEVEL%
+if %RESULT% GTR 0 goto :ERROR
+echo "Drop of bacula database succeeded."
+exit /b 0
+
+:ERROR
+echo "Drop of bacula database failed."
+exit /b %RESULT%
diff --git a/bacula/src/win32/cats/drop_mysql_tables.cmd b/bacula/src/win32/cats/drop_mysql_tables.cmd
new file mode 100644 (file)
index 0000000..fb89739
--- /dev/null
@@ -0,0 +1,13 @@
+rem
+rem Script to delete Bacula tables for MySQL
+rem
+
+if %SQL_BINDIR%/mysql $* < drop_mysql_tables.sql
+set RESULT=%ERRORLEVEL%
+if %RESULT% GTR 0 goto :ERROR
+echo "Deletion of Bacula MySQL tables succeeded."
+exit /b 0
+
+:ERROR
+echo "Deletion of Bacula MySQL tables failed."
+exit /b %RESULT%
diff --git a/bacula/src/win32/cats/drop_mysql_tables.sql b/bacula/src/win32/cats/drop_mysql_tables.sql
new file mode 100644 (file)
index 0000000..cf81c8d
--- /dev/null
@@ -0,0 +1,25 @@
+USE bacula;
+DROP TABLE IF EXISTS Filename;
+DROP TABLE IF EXISTS Path;
+DROP TABLE IF EXISTS LongName;
+DROP TABLE IF EXISTS Device;
+DROP TABLE IF EXISTS Storage;
+DROP TABLE IF EXISTS MediaType;
+DROP TABLE IF EXISTS File;
+DROP TABLE IF EXISTS Client;
+DROP TABLE IF EXISTS Job;
+DROP TABLE IF EXISTS Media;
+DROP TABLE IF EXISTS MAC;
+DROP TABLE IF EXISTS JobMedia;
+DROP TABLE IF EXISTS Pool;
+DROP TABLE IF EXISTS MultiVolume;
+DROP TABLE IF EXISTS FileSave;  
+DROP TABLE IF EXISTS FileSet;  
+DROP TABLE IF EXISTS Version;
+DROP TABLE IF EXISTS Counters;
+DROP TABLE IF EXISTS BaseFiles;
+DROP TABLE IF EXISTS UnsavedFiles;
+DROP TABLE IF EXISTS CDImages;
+DROP TABLE IF EXISTS Status;
+DROP TABLE IF EXISTS MAC;
+DROP TABLE IF EXISTS Location;
diff --git a/bacula/src/win32/cats/grant_mysql_privileges.cmd b/bacula/src/win32/cats/grant_mysql_privileges.cmd
new file mode 100644 (file)
index 0000000..49b99a8
--- /dev/null
@@ -0,0 +1,13 @@
+rem
+rem Script to grant privileges to the bacula database
+rem
+
+%SQL_BINDIR%\mysql $* -u root -f < grant_mysql_privileges.sql
+set RESULT=%ERRORLEVEL%
+if %RESULT% GTR 0 goto :ERROR
+echo "Privileges for bacula granted."
+exit /b 0
+
+:ERROR
+echo "Error creating privileges."
+exit /b %RESULT%
diff --git a/bacula/src/win32/cats/grant_mysql_privileges.sql b/bacula/src/win32/cats/grant_mysql_privileges.sql
new file mode 100644 (file)
index 0000000..043d987
--- /dev/null
@@ -0,0 +1,5 @@
+use mysql
+grant all privileges on bacula.* to bacula@localhost;
+grant all privileges on bacula.* to bacula@"%";
+select * from user;
+flush privileges;
diff --git a/bacula/src/win32/cats/make_catalog_backup.cmd b/bacula/src/win32/cats/make_catalog_backup.cmd
new file mode 100644 (file)
index 0000000..50480bd
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# This script dumps your Bacula catalog in ASCII format
+# It works for MySQL, SQLite, and PostgreSQL
+#
+#  $1 is the name of the database to be backed up and the name
+#     of the output file (default = bacula
+#  $2 is the user name with which to access the database
+#     (default = bacula).
+#  $3 is the password with which to access the database or "" if no password
+#     (default "")
+#
+#
+cd %WORKING_DIR%
+del /f bacula.sql
+
+set MYSQLPASSWORD=
+
+if "%3"!="" set MYSQLPASSWORD=" --password=%3"
+%SQL_BINDIR%/mysqldump -u %2 %MYSQLPASSWORD% -f --opt %1 >%1.sql
+
+#
+#  To read back a MySQL database use: 
+#     cd @working_dir@
+#     rm -f @SQL_BINDIR@/../var/bacula/*
+#     mysql <bacula.sql
+#
+#  To read back a SQLite database use:
+#     cd @working_dir@
+#     rm -f bacula.db
+#     sqlite bacula.db <bacula.sql
+#
+#  To read back a PostgreSQL database use:
+#     cd @working_dir@
+#     dropdb bacula
+#     createdb bacula
+#     psql bacula <bacula.sql
+#
diff --git a/bacula/src/win32/cats/make_mysql_tables.cmd b/bacula/src/win32/cats/make_mysql_tables.cmd
new file mode 100644 (file)
index 0000000..b596901
--- /dev/null
@@ -0,0 +1,13 @@
+rem
+rem Script to create Bacula MySQL tables
+rem
+
+%SQL_BINDIR%\mysql -f < make_mysql_tables.sql
+set RESULT=%ERRORLEVEL%
+if %RESULT% gt 0 goto :ERROR
+echo "Creation of Bacula MySQL tables succeeded."
+exit /b 0
+
+:ERROR
+echo "Creation of Bacula MySQL tables failed."
+exit /b %RESULT%
diff --git a/bacula/src/win32/cats/make_mysql_tables.sql b/bacula/src/win32/cats/make_mysql_tables.sql
new file mode 100644 (file)
index 0000000..dd29eab
--- /dev/null
@@ -0,0 +1,309 @@
+USE bacula;
+--
+-- Note, we use BLOB rather than TEXT because in MySQL,
+--  BLOBs are identical to TEXT except that BLOB is case
+--  sensitive in sorts, which is what we want, and TEXT
+--  is case insensitive.
+--
+CREATE TABLE Filename (
+  FilenameId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+  Name BLOB NOT NULL,
+  PRIMARY KEY(FilenameId),
+  INDEX (Name(255))
+  );
+
+CREATE TABLE Path (
+   PathId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   Path BLOB NOT NULL,
+   PRIMARY KEY(PathId),
+   INDEX (Path(255))
+   );
+
+
+CREATE TABLE File (
+   FileId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   FileIndex INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
+   PathId INTEGER UNSIGNED NOT NULL REFERENCES Path,
+   FilenameId INTEGER UNSIGNED NOT NULL REFERENCES Filename,
+   MarkId INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   LStat TINYBLOB NOT NULL,
+   MD5 TINYBLOB NOT NULL,
+   PRIMARY KEY(FileId),
+   INDEX (JobId),
+   INDEX (JobId, PathId, FilenameId)
+   );
+
+#
+# Possibly add one or more of the following indexes
+#  to the above File table if your Verifies are
+#  too slow.
+#
+#  INDEX (PathId),
+#  INDEX (FilenameId),
+#  INDEX (FilenameId, PathId)
+#  INDEX (JobId),
+#
+
+CREATE TABLE MediaType (
+   MediaTypeId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   MediaType TINYBLOB NOT NULL,
+   ReadOnly TINYINT DEFAULT 0,
+   PRIMARY KEY(MediaTypeId)
+   );
+
+CREATE TABLE Storage (
+   StorageId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   Name TINYBLOB NOT NULL,
+   AutoChanger TINYINT DEFAULT 0,
+   PRIMARY KEY(StorageId)
+   );
+
+CREATE TABLE Device (
+   DeviceId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   Name TINYBLOB NOT NULL,
+   MediaTypeId INTEGER UNSIGNED NOT NULL REFERENCES MediaType,
+   StorageId INTEGER UNSIGNED NOT NULL REFERENCES Storage,
+   DevMounts INTEGER UNSIGNED DEFAULT 0,
+   DevReadBytes BIGINT UNSIGNED DEFAULT 0,
+   DevWriteBytes BIGINT UNSIGNED DEFAULT 0,
+   DevReadBytesSinceCleaning BIGINT UNSIGNED DEFAULT 0,
+   DevWriteBytesSinceCleaning BIGINT UNSIGNED DEFAULT 0,
+   DevReadTime BIGINT UNSIGNED DEFAULT 0,
+   DevWriteTime BIGINT UNSIGNED DEFAULT 0,
+   DevReadTimeSinceCleaning BIGINT UNSIGNED DEFAULT 0,
+   DevWriteTimeSinceCleaning BIGINT UNSIGNED DEFAULT 0,
+   CleaningDate DATETIME DEFAULT 0,
+   CleaningPeriod BIGINT UNSIGNED DEFAULT 0,
+   PRIMARY KEY(DeviceId)
+   );
+
+
+CREATE TABLE Job (
+   JobId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   Job TINYBLOB NOT NULL,
+   Name TINYBLOB NOT NULL,
+   Type BINARY(1) NOT NULL,
+   Level BINARY(1) NOT NULL,
+   ClientId INTEGER NULL REFERENCES Client,
+   JobStatus BINARY(1) NOT NULL,
+   SchedTime DATETIME NOT NULL,
+   StartTime DATETIME NULL,
+   EndTime DATETIME NULL,
+   JobTDate BIGINT UNSIGNED NOT NULL,
+   VolSessionId INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   VolSessionTime INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   JobFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   JobBytes BIGINT UNSIGNED NOT NULL DEFAULT 0,
+   JobErrors INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   JobMissingFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   PoolId INTEGER UNSIGNED NULL REFERENCES Pool,
+   FileSetId INTEGER UNSIGNED NULL REFERENCES FileSet,
+   PurgedFiles TINYINT NOT NULL DEFAULT 0,
+   HasBase TINYINT NOT NULL DEFAULT 0,
+   PRIMARY KEY(JobId),
+   INDEX (Name(128))
+   );
+
+CREATE TABLE MAC (
+   JobId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   OriginalJobId INTEGER UNSIGNED NOT NULL,
+   JobType BINARY(1) NOT NULL,
+   JobLevel BINARY(1) NOT NULL,
+   SchedTime DATETIME NOT NULL,
+   StartTime DATETIME NOT NULL,
+   EndTime DATETIME NOT NULL,
+   JobTDate BIGINT UNSIGNED NOT NULL,
+   PRIMARY KEY(JobId)
+   );
+
+CREATE TABLE Location (
+   LocationId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   Location TINYBLOB NOT NULL,
+   PRIMARY KEY(LocationId)
+   );
+
+# 
+CREATE TABLE FileSet (
+   FileSetId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   FileSet TINYBLOB NOT NULL,
+   MD5 TINYBLOB NOT NULL,
+   CreateTime DATETIME NOT NULL,
+   PRIMARY KEY(FileSetId)
+   );
+
+CREATE TABLE JobMedia (
+   JobMediaId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
+   MediaId INTEGER UNSIGNED NOT NULL REFERENCES Media,
+   FirstIndex INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   LastIndex INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   StartFile INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   EndFile INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   StartBlock INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   EndBlock INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   VolIndex INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   Copy INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   Stripe INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   PRIMARY KEY(JobMediaId),
+   INDEX (JobId, MediaId)
+   );
+
+
+CREATE TABLE Media (
+   MediaId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   VolumeName TINYBLOB NOT NULL,
+   Slot INTEGER NOT NULL DEFAULT 0,
+   PoolId INTEGER UNSIGNED NOT NULL REFERENCES Pool,
+   MediaType TINYBLOB NOT NULL,
+   MediaTypeId INTEGER UNSIGNED NOT NULL REFERENCES MediaType,
+   LabelType TINYINT NOT NULL DEFAULT 0,
+   FirstWritten DATETIME NULL,
+   LastWritten DATETIME NULL,
+   LabelDate DATETIME NULL,
+   VolJobs INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   VolFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   VolBlocks INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   VolMounts INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   VolBytes BIGINT UNSIGNED NOT NULL DEFAULT 0,
+   VolParts INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   VolErrors INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   VolWrites INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   VolCapacityBytes BIGINT UNSIGNED NOT NULL,
+   VolStatus ENUM('Full', 'Archive', 'Append', 'Recycle', 'Purged',
+    'Read-Only', 'Disabled', 'Error', 'Busy', 'Used', 'Cleaning') NOT NULL,
+   Recycle TINYINT NOT NULL DEFAULT 0,
+   VolRetention BIGINT UNSIGNED NOT NULL DEFAULT 0,
+   VolUseDuration BIGINT UNSIGNED NOT NULL DEFAULT 0,
+   MaxVolJobs INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   MaxVolFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   MaxVolBytes BIGINT UNSIGNED NOT NULL DEFAULT 0,
+   InChanger TINYINT NOT NULL DEFAULT 0,
+   StorageId INTEGER UNSIGNED NOT NULL REFERENCES Storage,
+   DeviceId INTEGER UNSIGNED NOT NULL REFERENCES Device,
+   MediaAddressing TINYINT NOT NULL DEFAULT 0,
+   VolReadTime BIGINT UNSIGNED NOT NULL DEFAULT 0,
+   VolWriteTime BIGINT UNSIGNED NOT NULL DEFAULT 0,
+   EndFile INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   EndBlock INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   LocationId INTEGER UNSIGNED NOT NULL REFERENCES Location,
+   RecycleCount INTEGER UNSIGNED DEFAULT 0,
+   InitialWrite DATETIME NULL,
+   ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool,
+   RecyclePoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool,
+   PRIMARY KEY(MediaId),
+   INDEX (PoolId)
+   );
+
+CREATE INDEX inx8 ON Media (PoolId);
+
+
+
+CREATE TABLE Pool (
+   PoolId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   Name TINYBLOB NOT NULL,
+   NumVols INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   MaxVols INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   UseOnce TINYINT NOT NULL,
+   UseCatalog TINYINT NOT NULL,
+   AcceptAnyVolume TINYINT DEFAULT 0,
+   VolRetention BIGINT UNSIGNED NOT NULL,
+   VolUseDuration BIGINT UNSIGNED NOT NULL,
+   MaxVolJobs INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   MaxVolFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
+   MaxVolBytes BIGINT UNSIGNED NOT NULL,
+   AutoPrune TINYINT DEFAULT 0,
+   Recycle TINYINT DEFAULT 0,
+   PoolType ENUM('Backup', 'Copy', 'Cloned', 'Archive', 'Migration', 'Scratch') NOT NULL,
+   LabelType TINYINT NOT NULL DEFAULT 0,
+   LabelFormat TINYBLOB,
+   Enabled TINYINT DEFAULT 1,
+   ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool,
+   RecyclePoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool,
+   NextPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool,
+   MigrationHighBytes BIGINT UNSIGNED DEFAULT 0,
+   MigrationLowBytes BIGINT UNSIGNED DEFAULT 0,
+   MigrationTime BIGINT UNSIGNED DEFAULT 0,
+   UNIQUE (Name(128)),
+   PRIMARY KEY (PoolId)
+   );
+
+
+CREATE TABLE Client (
+   ClientId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   Name TINYBLOB NOT NULL,
+   Uname TINYBLOB NOT NULL,      /* full uname -a of client */
+   AutoPrune TINYINT DEFAULT 0,
+   FileRetention BIGINT UNSIGNED NOT NULL,
+   JobRetention  BIGINT UNSIGNED NOT NULL,
+   UNIQUE (Name(128)),
+   PRIMARY KEY(ClientId)
+   );
+
+CREATE TABLE BaseFiles (
+   BaseId INTEGER UNSIGNED AUTO_INCREMENT,
+   BaseJobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
+   JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
+   FileId INTEGER UNSIGNED NOT NULL REFERENCES File,
+   FileIndex INTEGER UNSIGNED,
+   PRIMARY KEY(BaseId)
+   );
+
+CREATE TABLE UnsavedFiles (
+   UnsavedId INTEGER UNSIGNED AUTO_INCREMENT,
+   JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
+   PathId INTEGER UNSIGNED NOT NULL REFERENCES Path,
+   FilenameId INTEGER UNSIGNED NOT NULL REFERENCES Filename,
+   PRIMARY KEY (UnsavedId)
+   );
+
+
+
+CREATE TABLE Counters (
+   Counter TINYBLOB NOT NULL,
+   MinValue INTEGER,
+   MaxValue INTEGER,
+   CurrentValue INTEGER,
+   WrapCounter TINYBLOB NOT NULL,
+   PRIMARY KEY (Counter(128))
+   );
+
+CREATE TABLE CDImages (
+   MediaId INTEGER UNSIGNED NOT NULL,
+   LastBurn DATETIME NOT NULL,
+   PRIMARY KEY (MediaId)
+   );
+
+CREATE TABLE Status (
+   JobStatus CHAR(1) BINARY NOT NULL,
+   JobStatusLong BLOB, 
+   PRIMARY KEY (JobStatus)
+   );
+
+INSERT INTO Status (JobStatus,JobStatusLong) VALUES
+   ('C', 'Created, not yet running'),
+   ('R', 'Running'),
+   ('B', 'Blocked'),
+   ('T', 'Completed successfully'),
+   ('E', 'Terminated with errors'),
+   ('e', 'Non-fatal error'),
+   ('f', 'Fatal error'),
+   ('D', 'Verify found differences'),
+   ('A', 'Canceled by user'),
+   ('F', 'Waiting for Client'),
+   ('S', 'Waiting for Storage daemon'),
+   ('m', 'Waiting for new media'),
+   ('M', 'Waiting for media mount'),
+   ('s', 'Waiting for storage resource'),
+   ('j', 'Waiting for job resource'),
+   ('c', 'Waiting for client resource'),
+   ('d', 'Waiting on maximum jobs'),
+   ('t', 'Waiting on start time'),
+   ('p', 'Waiting on higher priority jobs');
+
+CREATE TABLE Version (
+   VersionId INTEGER UNSIGNED NOT NULL 
+   );
+
+-- Initialize Version           
+INSERT INTO Version (VersionId) VALUES (9);
diff --git a/bacula/src/win32/cats/update_mysql_tables.cmd b/bacula/src/win32/cats/update_mysql_tables.cmd
new file mode 100644 (file)
index 0000000..e8e7dcd
--- /dev/null
@@ -0,0 +1,18 @@
+rem
+rem Script to update MySQL tables from version 1.38 to 1.39
+rem
+echo " "
+echo "This script will update a Bacula MySQL database from version 9 to 9"
+echo "Depending on the size of your database,"
+echo "this script may take several minutes to run."
+echo " "
+
+if %SQL_BINDIR%/mysql $* -f < update_mysql_tables.sql
+set RESULT=%ERRORLEVEL%
+if %RESULT% GTR 0 goto :ERROR
+echo "Update of Bacula MySQL tables succeeded."
+exit /b 0
+
+:ERROR
+echo "Update of Bacula MySQL tables failed."
+exit /b %RESULT%
diff --git a/bacula/src/win32/cats/update_mysql_tables.sql b/bacula/src/win32/cats/update_mysql_tables.sql
new file mode 100644 (file)
index 0000000..7062010
--- /dev/null
@@ -0,0 +1,32 @@
+USE bacula;
+
+ALTER TABLE Media ADD COLUMN MediaTypeId INTEGER UNSIGNED DEFAULT 0 REFERENCES MediaType;
+ALTER TABLE Media ADD COLUMN DeviceId INTEGER UNSIGNED DEFAULT 0 REFERENCES Device;
+ALTER TABLE Media ADD COLUMN LocationId INTEGER UNSIGNED DEFAULT 0 REFERENCES Location;
+ALTER TABLE Media ADD COLUMN RecycleCount INTEGER UNSIGNED DEFAULT 0;
+ALTER TABLE Media ADD COLUMN InitialWrite DATETIME DEFAULT 0;
+ALTER TABLE Media ADD COLUMN ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool;
+ALTER TABLE Media ADD COLUMN RecyclePoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool;
+
+
+CREATE TABLE MAC (
+   JobId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   OriginalJobId INTEGER UNSIGNED NOT NULL,
+   JobType BINARY(1) NOT NULL,
+   JobLevel BINARY(1) NOT NULL,
+   SchedTime DATETIME NOT NULL,
+   StartTime DATETIME NOT NULL,
+   EndTime DATETIME NOT NULL,
+   JobTDate BIGINT UNSIGNED NOT NULL,
+   PRIMARY KEY(JobId)
+   );
+
+CREATE TABLE Location (
+   LocationId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+   Location TINYBLOB NOT NULL,
+   PRIMARY KEY(LocationId)
+   );
+
+
+DELETE FROM Version;
+INSERT INTO Version (VersionId) VALUES (9);
diff --git a/bacula/src/win32/dird/Makefile b/bacula/src/win32/dird/Makefile
new file mode 100644 (file)
index 0000000..d18850a
--- /dev/null
@@ -0,0 +1,102 @@
+#
+# Makefile for win32 bacula executables
+# Using MinGW cross-compiler on GNU/Linux
+#
+#  Written by Robert Nelson, June 2006
+#
+
+include ../Makefile.inc
+
+INCLUDES = \
+       $(INCLUDE_PTHREADS) \
+       $(INCLUDE_BACULA) \
+       $(INCLUDE_ZLIB) \
+       $(INCLUDE_OPENSSL) \
+       $(INCLUDE_ICONS)
+
+DEFINES = \
+       -DUSING_DLL \
+       $(HAVES)
+
+VPATH = ../../dird
+
+##########################################################################
+
+DIRD_OBJS = \
+       $(OBJDIR)/admin.o \
+       $(OBJDIR)/authenticate.o \
+       $(OBJDIR)/autoprune.o \
+       $(OBJDIR)/backup.o \
+       $(OBJDIR)/bsr.o \
+       $(OBJDIR)/catreq.o \
+       $(OBJDIR)/dird.o \
+       $(OBJDIR)/dird_conf.o \
+       $(OBJDIR)/expand.o \
+       $(OBJDIR)/fd_cmds.o \
+       $(OBJDIR)/getmsg.o \
+       $(OBJDIR)/inc_conf.o \
+       $(OBJDIR)/job.o \
+       $(OBJDIR)/jobq.o \
+       $(OBJDIR)/migrate.o \
+       $(OBJDIR)/mountreq.o \
+       $(OBJDIR)/msgchan.o \
+       $(OBJDIR)/newvol.o \
+       $(OBJDIR)/next_vol.o \
+       $(OBJDIR)/pythondir.o \
+       $(OBJDIR)/recycle.o \
+       $(OBJDIR)/restore.o \
+       $(OBJDIR)/run_conf.o \
+       $(OBJDIR)/scheduler.o \
+       $(OBJDIR)/sql_cmds.o \
+       $(OBJDIR)/ua_acl.o \
+       $(OBJDIR)/ua_cmds.o \
+       $(OBJDIR)/ua_dotcmds.o \
+       $(OBJDIR)/ua_input.o \
+       $(OBJDIR)/ua_label.o \
+       $(OBJDIR)/ua_output.o \
+       $(OBJDIR)/ua_prune.o \
+       $(OBJDIR)/ua_purge.o \
+       $(OBJDIR)/ua_query.o \
+       $(OBJDIR)/ua_restore.o \
+       $(OBJDIR)/ua_run.o \
+       $(OBJDIR)/ua_select.o \
+       $(OBJDIR)/ua_server.o \
+       $(OBJDIR)/ua_status.o \
+       $(OBJDIR)/ua_tree.o \
+       $(OBJDIR)/ua_update.o \
+       $(OBJDIR)/verify.o \
+       $(OBJDIR)/winservice.o \
+       $(OBJDIR)/winmain.o \
+       $(OBJDIR)/winres.res
+
+ALL_OBJS = $(DIRD_OBJS)
+
+
+DIRD_LIBS = \
+       $(LIBS_PTHREADS) \
+       -lwsock32
+
+######################################################################
+
+# Targets
+
+.PHONY: all clean
+
+all: $(BINDIR)/bacula-dir.exe
+
+clean:
+       @echo "Cleaning `pwd`"
+       $(call clean_obj,$(ALL_OBJS))
+       $(call clean_exe,$(BINDIR)/bacula-dir.exe)
+
+#
+# Rules
+#
+
+$(BINDIR)/bacula-dir.exe: $(DIRD_OBJS) $(LIBS_BACULA)
+       $(call link_winapp,$(DIRD_LIBS))
+
+$(OBJDIR)/winres.res: ../libwin32/winres.rc
+       $(WINDRES) $(INCLUDE_ICONS) -O coff $< -o $@
+
+include ../Makefile.rules
diff --git a/bacula/src/win32/dird/dird.vcproj b/bacula/src/win32/dird/dird.vcproj
new file mode 100644 (file)
index 0000000..4981b0d
--- /dev/null
@@ -0,0 +1,1137 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="baculadird"
+       ProjectGUID="{D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}"
+       RootNamespace="baculadird"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+               <ToolFile
+                       RelativePath="..\bacula.rules"
+               />
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory=".\Release"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="..\..\..\..\..\..\Program Files\Microsoft Visual Studio 8\VC\VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       UseOfATL="1"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="Generated Config Files"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Release/baculadird.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="3"
+                               InlineFunctionExpansion="2"
+                               EnableIntrinsicFunctions="true"
+                               AdditionalIncludeDirectories="../compat;../..;&quot;../../../../depkgs-win32/pthreads&quot;;&quot;../../../../depkgs-win32/zlib&quot;;&quot;../../../../depkgs-win32/gettext/include&quot;"
+                               PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;HAVE_WIN32;_USE_32BIT_TIME_T;WIN32_VSS;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
+                               StringPooling="true"
+                               RuntimeLibrary="2"
+                               EnableFunctionLevelLinking="true"
+                               PrecompiledHeaderFile=".\Release/baculadird.pch"
+                               AssemblerListingLocation=".\Release/"
+                               ObjectFile=".\Release/"
+                               ProgramDataBaseFileName=".\Release/"
+                               BrowseInformation="1"
+                               WarningLevel="3"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="NDEBUG"
+                               Culture="1033"
+                               AdditionalIncludeDirectories=""
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="pthreadVCE.lib libmysql.lib zlib.lib wsock32.lib atls.lib"
+                               OutputFile="$(OutDir)\bacula-dir.exe"
+                               LinkIncremental="0"
+                               SuppressStartupBanner="true"
+                               AdditionalLibraryDirectories="&quot;..\..\..\..\depkgs-win32\pthreads\release&quot;;&quot;..\..\..\..\depkgs-win32\zlib\release&quot;;&quot;..\..\..\..\depkgs-win32\gettext\lib&quot;;&quot;%VSSSDK_DIR%\lib\win2003\obj\i386&quot;;&quot;C:\Program Files\MySQL\MySQL Server 5.0\lib\opt&quot;"
+                               IgnoreDefaultLibraryNames=""
+                               DelayLoadDLLs="$(NOINHERIT)"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Release/baculadird.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory=".\Debug"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="..\..\..\..\..\..\Program Files\Microsoft Visual Studio 8\VC\VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="Generated Config Files"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Debug/baculadird.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="../compat;../..;&quot;../../../../depkgs-win32/pthreads&quot;;&quot;../../../../depkgs-win32/zlib&quot;;&quot;../../../../depkgs-win32/gettext/include&quot;"
+                               PreprocessorDefinitions="_DEBUG;_WINMAIN_;PTW32_BUILD;WIN32;_CONSOLE;HAVE_WIN32;_USE_32BIT_TIME_T;WIN32_VSS;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               PrecompiledHeaderFile=".\Debug/baculadird.pch"
+                               AssemblerListingLocation=".\Debug/"
+                               ObjectFile=".\Debug/"
+                               ProgramDataBaseFileName=".\Debug/"
+                               BrowseInformation="1"
+                               WarningLevel="3"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="_DEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="pthreadVCEd.lib zlibd.lib wsock32.lib atlsd.lib libmysql.lib"
+                               OutputFile="$(OutDir)\bacula-dir.exe"
+                               LinkIncremental="0"
+                               SuppressStartupBanner="true"
+                               AdditionalLibraryDirectories="&quot;../../../../depkgs-win32/pthreads/debug&quot;;&quot;../../../../depkgs-win32/zlib/debug&quot;;&quot;../../../../depkgs-win32/gettext/lib&quot;;&quot;C:\Program Files\MySQL\MySQL Server 5.0\lib\opt&quot;"
+                               IgnoreDefaultLibraryNames=""
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Debug/baculadird.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+                       >
+                       <File
+                               RelativePath="..\..\dird\admin.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\authenticate.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\autoprune.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\backup.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\bsr.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\catreq.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\dird.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\dird_conf.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\expand.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\fd_cmds.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\getmsg.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\inc_conf.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\job.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\jobq.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\migrate.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\mountreq.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\msgchan.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\newvol.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\next_vol.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\pythondir.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\recycle.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\restore.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\run_conf.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\scheduler.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\sql_cmds.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_acl.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_cmds.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_dotcmds.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_input.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_label.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_output.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_prune.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_purge.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_query.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_restore.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_run.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_select.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_server.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_status.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_tree.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua_update.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\verify.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath=".\winmain.cpp"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath=".\winservice.cpp"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl"
+                       >
+                       <File
+                               RelativePath="..\..\dird\bsr.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\dird.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\dird_conf.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\jobq.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\protos.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\dird\ua.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\winbacula.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\winservice.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+                       >
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/bacula/src/win32/dird/winbacula.h b/bacula/src/win32/dird/winbacula.h
new file mode 100644 (file)
index 0000000..22c655f
--- /dev/null
@@ -0,0 +1,70 @@
+//  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
+//
+//  This file was part of the VNC system.
+//
+//  The VNC system is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+//  USA.
+//
+// If the source code for the VNC system is not available from the place
+// whence you received this file, check http://www.uk.research.att.com/vnc or contact
+// the authors on vnc@uk.research.att.com for information on obtaining it.
+//
+// This file has been adapted to the Win32 version of Bacula
+// by Kern E. Sibbald.  Many thanks to ATT and James Weatherall,
+// the original author, for providing an excellent template.
+//
+// Copyright (2000) Kern E. Sibbald
+//
+
+
+// Application specific messages
+
+// Message used for system tray notifications
+#define WM_TRAYNOTIFY                           WM_USER+1
+
+// Messages used for the server object to notify windows of things
+#define WM_SRV_CLIENT_CONNECT           WM_USER+2
+#define WM_SRV_CLIENT_AUTHENTICATED     WM_USER+3
+#define WM_SRV_CLIENT_DISCONNECT        WM_USER+4
+
+// Export the application details
+extern HINSTANCE        hAppInstance;
+extern const char       *szAppName;
+extern DWORD            mainthreadId;
+
+extern int BaculaAppMain();
+
+extern void LogErrorMsg(char *msg);
+
+// Standard command-line flag definitions
+const char BaculaRunService[]            = "/service";
+const char BaculaRunServiceHelper[]      = "/servicehelper";
+const char BaculaRunAsUserApp[]          = "/run";
+
+const char BaculaInstallService[]        = "/install";
+const char BaculaRemoveService[]         = "/remove";
+
+const char BaculaShowAbout[]             = "/about";
+const char BaculaShowStatus[]            = "/status";
+const char BaculaShowEvents[]            = "/events";
+const char BaculaKillRunningCopy[]       = "/kill";
+
+const char BaculaShowHelp[]              = "/help";
+
+// Usage string
+const char BaculaUsageText[] = "Bacula [/run] [/kill] [/install] [/remove] [/about] [/status] [/events]\n";
+
+void LogErrorMsg(char *msg, char *fname, int lineno);
+#define log_error_message(msg) LogErrorMsg((msg), __FILE__, __LINE__)
diff --git a/bacula/src/win32/dird/winmain.cpp b/bacula/src/win32/dird/winmain.cpp
new file mode 100644 (file)
index 0000000..dad8094
--- /dev/null
@@ -0,0 +1,339 @@
+/*
+   Copyright (C) 2000-2005 Kern Sibbald
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of
+   the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public
+   License along with this program; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   This file is patterned after the VNC Win32 code by ATT
+  
+*/
+
+
+#include <unistd.h>
+#include <ctype.h>
+#include <bacula.h>
+#include <signal.h>
+#include <pthread.h>
+
+#include "winbacula.h"
+//#include "wintray.h"
+#include "winservice.h"
+
+extern int BaculaMain(int argc, char *argv[]);
+extern void terminate_dird(int sig);
+extern DWORD g_error;
+extern BOOL ReportStatus(DWORD state, DWORD exitcode, DWORD waithint);
+extern void d_msg(const char *, int, int, const char *, ...);
+
+/* Globals */
+HINSTANCE       hAppInstance;
+const char      *szAppName = "Bacula";
+DWORD           mainthreadId;
+
+/* Imported variables */
+extern DWORD    g_servicethread;
+
+#define MAX_COMMAND_ARGS 100
+static char *command_args[MAX_COMMAND_ARGS] = {"bacula-dird", NULL};
+static int num_command_args = 1;
+static pid_t main_pid;
+static pthread_t main_tid;
+
+/*
+ * WinMain parses the command line and either calls the main App
+ * routine or, under NT, the main service routine.
+ */
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
+                   PSTR CmdLine, int iCmdShow)
+{
+   char *szCmdLine = CmdLine;
+   char *wordPtr, *tempPtr;
+   int i, quote;
+
+   /* Save the application instance and main thread id */
+   hAppInstance = hInstance;
+   mainthreadId = GetCurrentThreadId();
+
+   main_pid = getpid();
+   main_tid = pthread_self();
+
+   /*
+    * Funny things happen with the command line if the
+    * execution comes from c:/Program Files/bacula/bacula.exe
+    * We get a command line like: Files/bacula/bacula.exe" options
+    * I.e. someone stops scanning command line on a space, not
+    * realizing that the filename is quoted!!!!!!!!!!
+    * So if first character is not a double quote and
+    * the last character before first space is a double
+    * quote, we throw away the junk.
+    */
+
+   wordPtr = szCmdLine;
+   while (*wordPtr && *wordPtr != ' ')
+      wordPtr++;
+   if (wordPtr > szCmdLine)      /* backup to char before space */
+      wordPtr--;
+   /* if first character is not a quote and last is, junk it */
+   if (*szCmdLine != '"' && *wordPtr == '"') {
+      szCmdLine = wordPtr + 1;
+   }
+// MessageBox(NULL, szCmdLine, "Cmdline", MB_OK);
+
+   /* Build Unix style argc *argv[] */      
+
+   /* Don't NULL command_args[0] !!! */
+   for (i=1;i<MAX_COMMAND_ARGS;i++)
+      command_args[i] = NULL;
+
+   wordPtr = szCmdLine;
+   quote = 0;
+   while  (*wordPtr && (*wordPtr == ' ' || *wordPtr == '\t'))
+      wordPtr++;
+   if (*wordPtr == '\"') {
+      quote = 1;
+      wordPtr++;
+   } else if (*wordPtr == '/') {
+      /* Skip Windows options */
+      while (*wordPtr && (*wordPtr != ' ' && *wordPtr != '\t'))
+         wordPtr++;
+      while  (*wordPtr && (*wordPtr == ' ' || *wordPtr == '\t'))
+         wordPtr++;
+   }
+   if (*wordPtr) {
+      while (*wordPtr && num_command_args < MAX_COMMAND_ARGS) {
+         tempPtr = wordPtr;
+         if (quote) {
+            while (*tempPtr && *tempPtr != '\"')
+            tempPtr++;
+            quote = 0;
+         } else {
+            while (*tempPtr && *tempPtr != ' ')
+            tempPtr++;
+         }
+         if (*tempPtr)
+            *(tempPtr++) = '\0';
+         command_args[num_command_args++] = wordPtr;
+         wordPtr = tempPtr;
+         while (*wordPtr && (*wordPtr == ' ' || *wordPtr == '\t'))
+            wordPtr++;
+         if (*wordPtr == '\"') {
+            quote = 1;
+            wordPtr++;
+         }
+      }
+   }
+
+   /*
+    * Now process Windows command line options
+    *   as defined by ATT
+    *
+    * Make the command-line lowercase and parse it
+    */
+   for (i = 0; i < (int)strlen(szCmdLine); i++) {
+      szCmdLine[i] = tolower(szCmdLine[i]);
+   }
+
+   bool argfound = false;
+   for (i = 0; i < (int)strlen(szCmdLine); i++) {
+      if (szCmdLine[i] <= ' ') {
+         continue;
+      }
+
+      if (szCmdLine[i] == '-') {
+         while (szCmdLine[i] && szCmdLine[i] != ' ') {
+            i++;
+         }
+         continue;
+      }
+
+      argfound = true;
+
+      /* Now check for command-line arguments */
+
+      /* /service helper - probably only needed on win9x */
+      if (strncmp(&szCmdLine[i], BaculaRunServiceHelper, strlen(BaculaRunServiceHelper)) == 0
+          && g_platform_id == VER_PLATFORM_WIN32_NT) {
+         /* exit with result "okay" */
+         return 0;          
+      }
+
+      /* /service start service */
+      if (strncmp(&szCmdLine[i], BaculaRunService, strlen(BaculaRunService)) == 0) {
+         /* Run Bacula as a service */
+         return bacService::BaculaServiceMain();
+      }
+      /* /run  (this is the default if no command line arguments) */
+      if (strncmp(&szCmdLine[i], BaculaRunAsUserApp, strlen(BaculaRunAsUserApp)) == 0) {
+         /* Bacula is being run as a user-level program */
+         return BaculaAppMain();
+      }
+      /* /install */
+      if (strncmp(&szCmdLine[i], BaculaInstallService, strlen(BaculaInstallService)) == 0) {
+         /* Install Bacula as a service */
+         bacService::InstallService();
+         i += strlen(BaculaInstallService);
+         continue;
+      }
+      /* /remove */
+      if (strncmp(&szCmdLine[i], BaculaRemoveService, strlen(BaculaRemoveService)) == 0) {
+         /* Remove the Bacula service */
+         bacService::RemoveService();
+         i += strlen(BaculaRemoveService);
+         continue;
+      }
+
+      /* /about */
+      if (strncmp(&szCmdLine[i], BaculaShowAbout, strlen(BaculaShowAbout)) == 0) {
+         /* Show Bacula's about box */
+         bacService::ShowAboutBox();
+         i += strlen(BaculaShowAbout);
+         continue;
+      }
+
+      /* /status */
+      if (strncmp(&szCmdLine[i], BaculaShowStatus, strlen(BaculaShowStatus)) == 0) {
+         /* Show Bacula's status box */                             
+         bacService::ShowStatus();
+         i += strlen(BaculaShowStatus);
+         continue;
+      }
+
+      /* /kill */
+      if (strncmp(&szCmdLine[i], BaculaKillRunningCopy, strlen(BaculaKillRunningCopy)) == 0) {
+         /* Kill running copy of Bacula */
+         bacService::KillRunningCopy();
+         i += strlen(BaculaKillRunningCopy);
+         continue;
+      }
+
+      /* /help */
+      if (strncmp(&szCmdLine[i], BaculaShowHelp, strlen(BaculaShowHelp)) == 0) {
+         MessageBox(NULL, BaculaUsageText, _("Bacula Usage"), MB_OK|MB_ICONINFORMATION);
+         i += strlen(BaculaShowHelp);
+         continue;
+      }
+      
+      MessageBox(NULL, szCmdLine, _("Bad Command Line Options"), MB_OK);
+
+      /* Show the usage dialog */
+      MessageBox(NULL, BaculaUsageText, _("Bacula Usage"), MB_OK | MB_ICONINFORMATION);
+      break;
+   }
+
+   /* If no arguments were given then just run */
+   if (!argfound) {
+      BaculaAppMain();
+   }
+   return 0;
+}
+
+
+/*
+ * Called as a thread from BaculaAppMain()
+ * Here we handle the Windows messages
+ */
+//DWORD WINAPI Main_Msg_Loop(LPVOID lpwThreadParam)
+void *Main_Msg_Loop(LPVOID lpwThreadParam) 
+{
+   DWORD old_servicethread = g_servicethread;
+
+
+   pthread_detach(pthread_self());
+
+   /* Since we are the only thread with a message loop
+    * mark ourselves as the service thread so that
+    * we can receive all the window events.
+    */
+   g_servicethread = GetCurrentThreadId();
+
+#if 0
+   /* Create tray icon & menu if we're running as an app */
+   bacMenu *menu = new bacMenu();
+   if (menu == NULL) {
+//    log_error_message("Could not create sys tray menu");
+      PostQuitMessage(0);
+   }
+#endif
+
+   /* Now enter the Windows message handling loop until told to quit! */
+   MSG msg;
+   while (GetMessage(&msg, NULL, 0,0) ) {
+      TranslateMessage(&msg);
+      DispatchMessage(&msg);
+   }
+
+#if 0
+   if (menu != NULL) {
+      delete menu;
+   }
+#endif
+
+   if (old_servicethread != 0) { /* started as NT service */
+      /* Mark that we're no longer running */
+      g_servicethread = 0;
+
+      /* Tell the service manager that we've stopped. */
+      ReportStatus(SERVICE_STOPPED, g_error, 0);
+   }  
+   /* Tell main program to go away */
+   terminate_dird(0);
+
+   /* Should not get here */
+   pthread_kill(main_tid, SIGTERM);   /* ask main thread to terminate */
+   sleep(1);
+   kill(main_pid, SIGTERM);           /* ask main thread to terminate */
+   _exit(0);
+}
+
+/*
+ * This is the main routine for Bacula when running as an application
+ * (under Windows 95 or Windows NT)
+ * Under NT, Bacula can also run as a service.  The BaculaServerMain routine,
+ * defined in the bacService header, is used instead when running as a service.
+ */
+int BaculaAppMain()
+{
+ /* DWORD dwThreadID; */
+   pthread_t tid;
+
+   InitWinAPIWrapper();
+
+   WSA_Init();
+
+   /* Set this process to be the last application to be shut down. */
+   if (p_SetProcessShutdownParameters) {
+      p_SetProcessShutdownParameters(0x100, 0);
+   }
+
+#if 0
+   HWND hservwnd = FindWindow(MENU_CLASS_NAME, NULL);
+   if (hservwnd != NULL) {
+      /* We don't allow multiple instances! */
+      MessageBox(NULL, _("Another instance of Bacula is already running"), szAppName, MB_OK);
+      _exit(0);
+   }
+#endif
+
+   /* Create a thread to handle the Windows messages */
+// (void)CreateThread(NULL, 0, Main_Msg_Loop, NULL, 0, &dwThreadID);
+   pthread_create(&tid, NULL,  Main_Msg_Loop, (void *)0);
+
+   /* Call the "real" Bacula */
+   BaculaMain(num_command_args, command_args);
+   PostQuitMessage(0);
+   WSACleanup();
+   _exit(0);
+}
diff --git a/bacula/src/win32/dird/winservice.cpp b/bacula/src/win32/dird/winservice.cpp
new file mode 100644 (file)
index 0000000..604c6db
--- /dev/null
@@ -0,0 +1,761 @@
+//  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
+//
+//  This file was part of the VNC system.
+//
+//  The VNC system is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+//  USA.
+//
+// If the source code for the VNC system is not available from the place 
+// whence you received this file, check http://www.uk.research.att.com/vnc or contact
+// the authors on vnc@uk.research.att.com for information on obtaining it.
+//
+// This file has been adapted to the Win32 version of Bacula
+// by Kern E. Sibbald.  Many thanks to ATT and James Weatherall,
+// the original author, for providing an excellent template.
+//
+// Copyright (2000-2003) Kern E. Sibbald
+//
+
+
+// winService
+
+// Implementation of service-oriented functionality of Bacula
+// I.e. command line options that contact a running version of
+// Bacula and ask it to do something (show about, show status,
+// show events, ...)
+
+
+#include "bacula.h"
+#include "winbacula.h"
+#include "winservice.h"
+//#include "wintray.h"
+
+
+void set_service_description(SC_HANDLE hSCManager, SC_HANDLE hService,
+                             LPSTR lpDesc);
+
+// OS-SPECIFIC ROUTINES
+
+// Create an instance of the bacService class to cause the static fields to be
+// initialised properly
+
+bacService init;
+
+
+bacService::bacService()
+{
+   OSVERSIONINFO osversioninfo;
+   osversioninfo.dwOSVersionInfoSize = sizeof(osversioninfo);
+
+   // Get the current OS version
+   if (!GetVersionEx(&osversioninfo)) {
+      g_platform_id = 0;
+   } else {
+      g_platform_id = osversioninfo.dwPlatformId;
+   }
+}
+
+
+// IsWin95 - returns a BOOL indicating whether the current OS is Win95
+BOOL
+bacService::IsWin95()
+{
+   return (g_platform_id == VER_PLATFORM_WIN32_WINDOWS);
+}
+
+// IsWinNT - returns a bool indicating whether the current OS is WinNT
+BOOL
+bacService::IsWinNT()
+{
+   return (g_platform_id == VER_PLATFORM_WIN32_NT);
+}
+
+// Internal routine to find the  Bacula menu class window and
+// post a message to it!
+
+BOOL
+PostToBacula(UINT message, WPARAM wParam, LPARAM lParam)
+{
+#if 0
+  // Locate the hidden Bacula menu window
+  HWND hservwnd = FindWindow(MENU_CLASS_NAME, NULL);
+  if (hservwnd == NULL) {
+     return FALSE;
+  }
+
+  // Post the message to Bacula
+  PostMessage(hservwnd, message, wParam, lParam);
+#endif
+  return TRUE;
+}
+
+
+// Static routine to show the Properties dialog for a currently-running
+// copy of Bacula, (usually a servicified version.)
+
+BOOL
+bacService::ShowProperties()
+{
+   return TRUE;
+}
+
+// Static routine to show the Default Properties dialog for a currently-running
+// copy of Bacula, (usually a servicified version.)
+
+BOOL
+bacService::ShowDefaultProperties()
+{
+   return TRUE;
+}
+
+// Static routine to show the About dialog for a currently-running
+// copy of Bacula, (usually a servicified version.)
+
+BOOL
+bacService::ShowAboutBox()
+{
+#if 0
+  // Post to the Bacula menu window
+  if (!PostToBacula(MENU_ABOUTBOX_SHOW, 0, 0)) {
+     MessageBox(NULL, _("No existing instance of Bacula could be contacted"), szAppName, MB_ICONEXCLAMATION | MB_OK);
+     return FALSE;
+  }
+#endif
+  return TRUE;
+}
+
+// Static routine to show the Status dialog for a currently-running
+// copy of Bacula, (usually a servicified version.)
+
+BOOL
+bacService::ShowStatus()
+{
+#if 0
+  // Post to the Bacula menu window
+  if (!PostToBacula(MENU_STATUS_SHOW, 0, 0)) {
+     MessageBox(NULL, _("No existing instance of Bacula could be contacted"), szAppName, MB_ICONEXCLAMATION | MB_OK);
+     return FALSE;
+  }
+#endif
+  return TRUE;
+}
+
+// SERVICE-MODE ROUTINES
+
+// Service-mode defines:
+
+// Executable name
+#define BAC_APPNAME            "baculadir"
+
+// Internal service name
+#define BAC_SERVICENAME        "Baculadir"
+
+// Displayed service name
+#define BAC_SERVICEDISPLAYNAME "Bacula Director"
+
+// List other required services 
+#define BAC_DEPENDENCIES __TEXT("tcpip\0afd\0") 
+
+
+// Internal service state
+SERVICE_STATUS          g_srvstatus;       // current status of the service
+SERVICE_STATUS_HANDLE   g_hstatus;
+DWORD                   g_error = 0;
+DWORD                   g_servicethread = 0;
+char*                   g_errortext[256];
+
+
+// Forward defines of internal service functions
+void WINAPI ServiceMain(DWORD argc, char **argv);
+DWORD WINAPI ServiceWorkThread(LPVOID lpwThreadParam);
+void ServiceStop();
+void WINAPI ServiceCtrl(DWORD ctrlcode);
+bool WINAPI CtrlHandler (DWORD ctrltype);
+BOOL ReportStatus(DWORD state, DWORD exitcode, DWORD waithint);
+
+// ROUTINE TO QUERY WHETHER THIS PROCESS IS RUNNING AS A SERVICE OR NOT
+
+BOOL    g_servicemode = FALSE;
+
+BOOL
+bacService::RunningAsService()
+{
+   return g_servicemode;
+}
+
+BOOL
+bacService::KillRunningCopy()
+{
+  while (PostToBacula(WM_CLOSE, 0, 0))
+      {  }
+  return TRUE;
+}
+
+// SERVICE MAIN ROUTINE
+int
+bacService::BaculaServiceMain()
+{
+   // Mark that we are a service
+   g_servicemode = TRUE;
+
+   // How to run as a service depends upon the OS being used
+   switch (g_platform_id) {
+
+   // Windows 95/98/Me
+   case VER_PLATFORM_WIN32_WINDOWS:
+      {
+      // Obtain a handle to the kernel library
+      HINSTANCE kerneldll = LoadLibrary("KERNEL32.DLL");
+      if (kerneldll == NULL) {
+         MessageBox(NULL, _("KERNEL32.DLL not found: Bacula service not started"), 
+             "Bacula Service", MB_OK);
+         break;
+      }
+
+      // And find the RegisterServiceProcess function
+      DWORD (WINAPI *RegisterService)(DWORD, DWORD);
+      RegisterService = (DWORD (WINAPI *)(DWORD, DWORD))
+              GetProcAddress(kerneldll, "RegisterServiceProcess");
+      if (RegisterService == NULL) {
+         MessageBox(NULL, _("Registry service not found: Bacula service not started"),
+            "Bacula Service", MB_OK);
+         log_error_message(_("Registry service not found")); 
+         break;
+      }
+      
+      // Register this process with the OS as a service!
+      RegisterService(0, 1);
+
+      // Run the main program as a service
+      BaculaAppMain();
+
+      // Then remove the service from the system service table
+      RegisterService(0, 0);
+
+      // Free the kernel library
+      FreeLibrary(kerneldll);
+      break;
+      }
+
+
+   // Windows NT, Win2K, WinXP 
+   case VER_PLATFORM_WIN32_NT:
+      {
+      // Create a service entry table
+      SERVICE_TABLE_ENTRY dispatchTable[] = {
+         {BAC_SERVICENAME, (LPSERVICE_MAIN_FUNCTION)ServiceMain},
+         {NULL, NULL}
+      };
+
+      // Call the service control dispatcher with our entry table
+      if (!StartServiceCtrlDispatcher(dispatchTable)) {
+         log_error_message(_("StartServiceCtrlDispatcher failed."));
+      }
+      break;
+      } /* end case */
+   } /* end switch */
+   return 0;
+}
+
+// SERVICE MAIN ROUTINE - NT ONLY !!!
+// NT/Win2K/WinXP ONLY !!!
+void WINAPI ServiceMain(DWORD argc, char **argv)
+{
+    DWORD dwThreadID;
+
+    // Register the service control handler
+    g_hstatus = RegisterServiceCtrlHandler(BAC_SERVICENAME, ServiceCtrl);
+
+    if (g_hstatus == 0) {
+       log_error_message(_("RegisterServiceCtlHandler failed")); 
+       MessageBox(NULL, _("Contact Register Service Handler failure"),
+          "Bacula service", MB_OK);
+       return;
+    }
+
+     // Set up some standard service state values
+    g_srvstatus.dwServiceType = SERVICE_WIN32 | SERVICE_INTERACTIVE_PROCESS;
+    g_srvstatus.dwServiceSpecificExitCode = 0;
+
+        // Give this status to the SCM
+    if (!ReportStatus(
+            SERVICE_START_PENDING,          // Service state
+            NO_ERROR,                       // Exit code type
+            45000)) {                       // Hint as to how long Bacula should have hung before you assume error
+
+        ReportStatus(SERVICE_STOPPED, g_error,  0);
+        log_error_message(_("ReportStatus STOPPED failed 1")); 
+        return;
+    }
+
+        // Now start the service for real
+    (void)CreateThread(NULL, 0, ServiceWorkThread, NULL, 0, &dwThreadID);
+    return;
+}
+
+// SERVICE START ROUTINE - thread that calls BaculaAppMain
+//   NT ONLY !!!!
+DWORD WINAPI ServiceWorkThread(LPVOID lpwThreadParam)
+{
+
+    // Save the current thread identifier
+    g_servicethread = GetCurrentThreadId();
+
+    // report the status to the service control manager.
+    //
+    if (!ReportStatus(
+          SERVICE_RUNNING,       // service state
+          NO_ERROR,              // exit code
+          0)) {                  // wait hint
+       MessageBox(NULL, _("Report Service failure"), "Bacula Service", MB_OK);
+       log_error_message("ReportStatus RUNNING failed"); 
+       return 0;
+    }
+
+    /* Call Bacula main code */
+    BaculaAppMain();
+
+    /* Mark that we're no longer running */
+    g_servicethread = 0;
+
+    /* Tell the service manager that we've stopped */
+    ReportStatus(SERVICE_STOPPED, g_error, 0);
+    return 0;
+}
+
+
+// SERVICE STOP ROUTINE - post a quit message to the relevant thread
+void ServiceStop()
+{
+   // Post a quit message to the main service thread
+   if (g_servicethread != 0) {
+      PostThreadMessage(g_servicethread, WM_QUIT, 0, 0);
+   }
+}
+
+// SERVICE INSTALL ROUTINE
+int
+bacService::InstallService()
+{
+   const int pathlength = 2048;
+   char path[pathlength];
+   char servicecmd[pathlength];
+   int len;
+
+   // Get the filename of this executable
+   if (GetModuleFileName(NULL, path, pathlength-(strlen(BaculaRunService)+2)) == 0) {
+      MessageBox(NULL, _("Unable to install Bacula service"), szAppName, MB_ICONEXCLAMATION | MB_OK);
+      return 0;
+   }
+
+   // Append the service-start flag to the end of the path:
+   if ((int)strlen(path) + 20 + (int)strlen(BaculaRunService) < pathlength) {
+      sprintf(servicecmd, "\"%s\" %s -c \"%s", path, BaculaRunService, path);
+      len = strlen(servicecmd) - 1;
+      for ( ; len > 0; len--) {
+         if (servicecmd[len] == '\\') {
+            servicecmd[len+1] = 0;
+            break;
+         }
+         servicecmd[len] = 0;
+      }
+      strcat(servicecmd, "bacula-dir.conf\"");
+
+   } else {
+      log_error_message(_("Service command length too long")); 
+      MessageBox(NULL, _("Service command length too long. Service not registered."),
+          szAppName, MB_ICONEXCLAMATION | MB_OK);
+      return 0;
+   }
+
+   // How to add the Bacula service depends upon the OS
+   switch (g_platform_id) {
+
+   // Windows 95/98/Me
+   case VER_PLATFORM_WIN32_WINDOWS:
+      // Locate the RunService registry entry
+      HKEY runservices;
+      if (RegCreateKey(HKEY_LOCAL_MACHINE, 
+              "Software\\Microsoft\\Windows\\CurrentVersion\\RunServices",
+              &runservices) != ERROR_SUCCESS) {
+         log_error_message(_("Cannot write System Registry")); 
+         MessageBox(NULL, _("The System Registry could not be updated - the Bacula service was not installed"), szAppName, MB_ICONEXCLAMATION | MB_OK);
+         break;
+      }
+
+      // Attempt to add a Bacula key
+      if (RegSetValueEx(runservices, szAppName, 0, REG_SZ, (unsigned char *)servicecmd, strlen(servicecmd)+1) != ERROR_SUCCESS) {
+         RegCloseKey(runservices);
+         log_error_message(_("Cannot add Bacula key to System Registry")); 
+         MessageBox(NULL, _("The Bacula service could not be installed"), szAppName, MB_ICONEXCLAMATION | MB_OK);
+         break;
+      }
+
+      RegCloseKey(runservices);
+
+      // We have successfully installed the service!
+      MessageBox(NULL,
+              _("The Bacula File service was successfully installed.\n"
+              "The service may be started by double clicking on the\n"
+              "Bacula \"Start\" icon and will be automatically\n"
+              "be run the next time this machine is rebooted. "),
+              szAppName,
+              MB_ICONINFORMATION | MB_OK);
+      break;
+
+   // Windows NT, Win2K, WinXP
+   case VER_PLATFORM_WIN32_NT:
+      SC_HANDLE   hservice;
+      SC_HANDLE   hsrvmanager;
+
+      // Open the default, local Service Control Manager database
+      hsrvmanager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+      if (hsrvmanager == NULL) {
+         log_error_message("OpenSCManager failed"); 
+         MessageBox(NULL,
+            _("The Service Control Manager could not be contacted - the Bacula service was not installed"),
+            szAppName, MB_ICONEXCLAMATION | MB_OK);
+         break;
+      }
+
+      // Create an entry for the Bacula service
+      hservice = CreateService(
+              hsrvmanager,                    // SCManager database
+              BAC_SERVICENAME,                // name of service
+              BAC_SERVICEDISPLAYNAME,         // name to display
+              SERVICE_ALL_ACCESS,             // desired access
+              SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
+                                                                      // service type
+              SERVICE_AUTO_START,             // start type
+              SERVICE_ERROR_NORMAL,           // error control type
+              servicecmd,                     // service's binary
+              NULL,                           // no load ordering group
+              NULL,                           // no tag identifier
+              BAC_DEPENDENCIES,               // dependencies
+              NULL,                           // LocalSystem account
+              NULL);                          // no password
+      if (hservice == NULL) {
+         CloseServiceHandle(hsrvmanager);
+         log_error_message("CreateService failed"); 
+         MessageBox(NULL,
+             _("The Bacula service could not be installed"),
+              szAppName, MB_ICONEXCLAMATION | MB_OK);
+         break;
+      }
+
+      set_service_description(hsrvmanager,hservice, 
+_("Provides file backup and restore services. Bacula -- the network backup solution."));
+
+      CloseServiceHandle(hsrvmanager);
+      CloseServiceHandle(hservice);
+
+      // Everything went fine
+      MessageBox(NULL,
+              _("The Bacula File service was successfully installed.\n"
+              "The service may be started from the Control Panel and will\n"
+              "automatically be run the next time this machine is rebooted."),
+              szAppName,
+              MB_ICONINFORMATION | MB_OK);
+      break;
+   default:
+      log_error_message("Unknown Windows System version"); 
+      MessageBox(NULL, 
+                 _("Unknown Windows operating system.\n"     
+                 "Cannot install Bacula service.\n"),
+                 szAppName, MB_ICONEXCLAMATION | MB_OK);
+       break;     
+   };
+
+   return 0;
+}
+
+
+// SERVICE REMOVE ROUTINE
+int
+bacService::RemoveService()
+{
+   // How to remove the Bacula service depends upon the OS
+   switch (g_platform_id) {
+
+   // Windows 95/98/Me
+   case VER_PLATFORM_WIN32_WINDOWS:
+      // Locate the RunService registry entry
+      HKEY runservices;
+      if (RegOpenKey(HKEY_LOCAL_MACHINE, 
+              "Software\\Microsoft\\Windows\\CurrentVersion\\RunServices",
+              &runservices) != ERROR_SUCCESS) {
+         MessageBox(NULL, 
+            _("Could not find registry entry.\nService probably not registerd - the Bacula service was not removed"), szAppName, MB_ICONEXCLAMATION | MB_OK);
+      } else {
+         // Attempt to delete the Bacula key
+         if (RegDeleteValue(runservices, szAppName) != ERROR_SUCCESS) {
+            RegCloseKey(runservices);
+            MessageBox(NULL, _("Could not delete Registry key.\nThe Bacula service could not be removed"), szAppName, MB_ICONEXCLAMATION | MB_OK);
+         }
+
+         RegCloseKey(runservices);
+         break;
+      }
+
+      // Try to kill any running copy of Bacula
+      if (!KillRunningCopy()) {
+         MessageBox(NULL,
+             _("Bacula could not be contacted, probably not running"),
+             szAppName, MB_ICONEXCLAMATION | MB_OK);
+         break;
+      }
+
+      // We have successfully removed the service!
+      MessageBox(NULL, _("The Bacula service has been removed"), szAppName, MB_ICONINFORMATION | MB_OK);
+      break;
+
+   // Windows NT, Win2K, WinXP
+   case VER_PLATFORM_WIN32_NT:
+      SC_HANDLE   hservice;
+      SC_HANDLE   hsrvmanager;
+
+      // Open the SCM
+      hsrvmanager = OpenSCManager(
+         NULL,                   // machine (NULL == local)
+         NULL,                   // database (NULL == default)
+         SC_MANAGER_ALL_ACCESS   // access required
+         );
+      if (hsrvmanager) {
+         hservice = OpenService(hsrvmanager, BAC_SERVICENAME, SERVICE_ALL_ACCESS);
+         if (hservice != NULL) {
+            SERVICE_STATUS status;
+
+            // Try to stop the Bacula service
+            if (ControlService(hservice, SERVICE_CONTROL_STOP, &status)) {
+               while(QueryServiceStatus(hservice, &status)) {
+                  if (status.dwCurrentState == SERVICE_STOP_PENDING) {
+                     Sleep(1000);
+                  } else {
+                     break;
+                  }
+               }
+
+               if (status.dwCurrentState != SERVICE_STOPPED) {
+                  MessageBox(NULL, _("The Bacula service could not be stopped"), szAppName, MB_ICONEXCLAMATION | MB_OK);
+               }
+            }
+
+            // Now remove the service from the SCM
+            if(DeleteService(hservice)) {
+               MessageBox(NULL, _("The Bacula service has been removed"), szAppName, MB_ICONINFORMATION | MB_OK);
+            } else {
+               MessageBox(NULL, _("The Bacula service could not be removed"), szAppName, MB_ICONEXCLAMATION | MB_OK);
+            }
+
+            CloseServiceHandle(hservice);
+         } else {
+            MessageBox(NULL, _("The Bacula service could not be found"), szAppName, MB_ICONEXCLAMATION | MB_OK);
+         }
+
+         CloseServiceHandle(hsrvmanager);
+      } else {
+         MessageBox(NULL, _("The SCM could not be contacted - the Bacula service was not removed"), szAppName, MB_ICONEXCLAMATION | MB_OK);
+      }
+      break;
+   }
+   return 0;
+}
+
+// USEFUL SERVICE SUPPORT ROUTINES
+
+// Service control routine
+void WINAPI ServiceCtrl(DWORD ctrlcode)
+{
+    // What control code have we been sent?
+    switch(ctrlcode) {
+    case SERVICE_CONTROL_STOP:
+        // STOP : The service must stop
+        g_srvstatus.dwCurrentState = SERVICE_STOP_PENDING;
+        ServiceStop();
+        break;
+
+    case SERVICE_CONTROL_INTERROGATE:
+        // QUERY : Service control manager just wants to know our state
+        break;
+
+     default:
+        // Control code not recognised
+        break;
+    }
+
+    // Tell the control manager what we're up to.
+    ReportStatus(g_srvstatus.dwCurrentState, NO_ERROR, 0);
+}
+
+// Service manager status reporting
+BOOL ReportStatus(DWORD state,
+                  DWORD exitcode,
+                  DWORD waithint)
+{
+    static DWORD checkpoint = 1;
+    BOOL result = TRUE;
+
+    // If we're in the start state then we don't want the control manager
+    // sending us control messages because they'll confuse us.
+    if (state == SERVICE_START_PENDING) {
+       g_srvstatus.dwControlsAccepted = 0;
+    } else {
+       g_srvstatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
+    }
+
+    // Save the new status we've been given
+    g_srvstatus.dwCurrentState = state;
+    g_srvstatus.dwWin32ExitCode = exitcode;
+    g_srvstatus.dwWaitHint = waithint;
+
+    // Update the checkpoint variable to let the SCM know that we
+    // haven't died if requests take a long time
+    if ((state == SERVICE_RUNNING) || (state == SERVICE_STOPPED)) {
+       g_srvstatus.dwCheckPoint = 0;
+    } else {
+       g_srvstatus.dwCheckPoint = checkpoint++;
+    }
+
+    // Tell the SCM our new status
+    if (!(result = SetServiceStatus(g_hstatus, &g_srvstatus))) {
+       log_error_message(_("SetServiceStatus failed"));
+    }
+
+    return result;
+}
+
+// Error reporting
+void LogErrorMsg(char *message, char *fname, int lineno)
+{
+   char        msgbuff[256];
+   HANDLE      heventsrc;
+   char *      strings[32];
+   LPTSTR      msg;
+
+   // Get the error code
+   g_error = GetLastError();
+   FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
+                 FORMAT_MESSAGE_FROM_SYSTEM,
+                 NULL,
+                 g_error,
+                 0,
+                 (LPTSTR)&msg,
+                 0,
+                 NULL);
+
+   // Use event logging to log the error
+   heventsrc = RegisterEventSource(NULL, BAC_SERVICENAME);
+
+   sprintf(msgbuff, _("\n\n%s error: %ld at %s:%d"), 
+      BAC_SERVICENAME, g_error, fname, lineno);
+   strings[0] = msgbuff;
+   strings[1] = message;
+   strings[2] = msg;
+
+   if (heventsrc != NULL) {
+      MessageBeep(MB_OK);
+
+      ReportEvent(
+              heventsrc,              // handle of event source
+              EVENTLOG_ERROR_TYPE,    // event type
+              0,                      // event category
+              0,                      // event ID
+              NULL,                   // current user's SID
+              3,                      // strings in 'strings'
+              0,                      // no bytes of raw data
+              (const char **)strings, // array of error strings
+              NULL);                  // no raw data
+
+      DeregisterEventSource(heventsrc);
+   }
+   LocalFree(msg);
+}
+typedef BOOL  (WINAPI * WinAPI)(SC_HANDLE, DWORD, LPVOID);
+
+void set_service_description(SC_HANDLE hSCManager, SC_HANDLE hService,
+                             LPSTR lpDesc) 
+{ 
+    SC_LOCK sclLock; 
+    LPQUERY_SERVICE_LOCK_STATUS lpqslsBuf; 
+    SERVICE_DESCRIPTION sdBuf;
+    DWORD dwBytesNeeded;
+    WinAPI ChangeServiceDescription;
+    HINSTANCE hLib = LoadLibrary("ADVAPI32.DLL");
+    if (!hLib) {
+       return;
+    }
+    ChangeServiceDescription = (WinAPI)GetProcAddress(hLib,
+       "ChangeServiceConfig2A");
+    FreeLibrary(hLib);
+    if (!ChangeServiceDescription) {
+       return;
+    }
+    
+    // Need to acquire database lock before reconfiguring. 
+    sclLock = LockServiceDatabase(hSCManager); 
+    // If the database cannot be locked, report the details. 
+    if (sclLock == NULL) {
+       // Exit if the database is not locked by another process. 
+       if (GetLastError() != ERROR_SERVICE_DATABASE_LOCKED) {
+          log_error_message("LockServiceDatabase"); 
+          return;
+       }
+       // Allocate a buffer to get details about the lock. 
+       lpqslsBuf = (LPQUERY_SERVICE_LOCK_STATUS)LocalAlloc( 
+            LPTR, sizeof(QUERY_SERVICE_LOCK_STATUS)+256); 
+       if (lpqslsBuf == NULL) {
+          log_error_message("LocalAlloc"); 
+          return;
+       }
+       // Get and print the lock status information. 
+       if (!QueryServiceLockStatus( 
+              hSCManager, 
+              lpqslsBuf, 
+              sizeof(QUERY_SERVICE_LOCK_STATUS)+256, 
+              &dwBytesNeeded)) {
+          log_error_message("QueryServiceLockStatus"); 
+       }
+       if (lpqslsBuf->fIsLocked) {
+          printf(_("Locked by: %s, duration: %ld seconds\n"), 
+                lpqslsBuf->lpLockOwner, 
+                lpqslsBuf->dwLockDuration); 
+       } else {
+          printf(_("No longer locked\n")); 
+       }
+       LocalFree(lpqslsBuf); 
+       log_error_message(_("Could not lock database")); 
+       return;
+    } 
+    // The database is locked, so it is safe to make changes. 
+    sdBuf.lpDescription = lpDesc;
+
+    if (!ChangeServiceDescription(
+         hService,                   // handle to service
+         SERVICE_CONFIG_DESCRIPTION, // change: description
+         &sdBuf) ) {                 // value: new description
+       log_error_message("ChangeServiceConfig2");
+    }
+
+    // Release the database lock. 
+    UnlockServiceDatabase(sclLock); 
+}
diff --git a/bacula/src/win32/dird/winservice.h b/bacula/src/win32/dird/winservice.h
new file mode 100644 (file)
index 0000000..ee8ac6d
--- /dev/null
@@ -0,0 +1,126 @@
+//  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
+//
+//  This file was part of the ups system.
+//
+//  The ups system is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+//  USA.
+//
+// If the source code for the ups system is not available from the place
+// whence you received this file, check http://www.uk.research.att.com/vnc or contact
+// the authors on ups@uk.research.att.com for information on obtaining it.
+//
+// This file has been adapted to the Win32 version of Bacula
+// by Kern E. Sibbald.  Many thanks to ATT and James Weatherall,
+// the original author, for providing an excellent template.
+//
+// Copyright (2000) Kern E. Sibbald
+//
+
+
+// winservice.cpp
+
+// SERVICE-MODE CODE
+
+// This class provides access to service-oriented routines, under both
+// Windows NT and Windows 95.  Some routines only operate under one
+// OS, others operate under any OS.
+
+#if (!defined(_win_bacService))
+#define _win_bacService
+
+// The NT-specific code wrapper class
+class bacService
+{
+public:
+   bacService();
+
+   // SERVICE INSTALL & START FUNCTIONS
+
+   // Routine called by WinMain to cause Bacula to be installed
+   // as a service.
+   static int BaculaServiceMain();
+
+   // Routine to install the Apcupsd service on the local machine
+   static int InstallService();
+
+   // Routine to remove the Apcupsd service from the local machine
+   static int RemoveService();
+
+   // SERVICE SUPPORT FUNCTIONS
+
+   // Routine to establish and return the currently logged in user name
+   static BOOL CurrentUser(char *buffer, UINT size);
+
+   // Routine to post a message to the currently running Apcupsd server
+   // to pass it a handle to the current user
+   static BOOL PostUserHelperMessage();
+   // Routine to process a user helper message
+   static BOOL ProcessUserHelperMessage(WPARAM wParam, LPARAM lParam);
+
+   // Routines to establish which OS we're running on
+   static BOOL IsWin95();
+   static BOOL IsWinNT();
+
+   // Routine to establish whether the current instance is running
+   // as a service or not
+   static BOOL RunningAsService();
+
+   // Routine to kill any other running copy of Apcupsd
+   static BOOL KillRunningCopy();
+
+   // Routine to set the current thread into the given desktop
+   static BOOL SelectHDESK(HDESK newdesktop);
+
+   // Routine to set the current thread into the named desktop,
+   // or the input desktop if no name is given
+   static BOOL SelectDesktop(char *name);
+
+   // Routine to establish whether the current thread desktop is the
+   // current user input one
+   static BOOL InputDesktopSelected();
+
+   // Routine to fake a CtrlAltDel to winlogon when required.
+   // *** This is a nasty little hack...
+   static BOOL SimulateCtrlAltDel();
+
+   // Routine to make any currently running version of Apcupsd show its
+   // Properties dialog, to allow the user to make changes to their settings
+   static BOOL ShowProperties();
+
+   // Routine to make any currently running version of Apcupsd show the
+   // Properties dialog for the default settings, so the user can make changes
+   static BOOL ShowDefaultProperties();
+
+   // Routine to make the an already running copy of Apcupsd bring up its
+   // About box so you can check the version!
+   static BOOL ShowAboutBox();
+
+   // Routine to make the an already running copy of Apcupsd bring up its
+   // Status dialog
+   static BOOL ShowStatus();
+
+   // Routine to make the an already running copy of Apcupsd bring up its
+   // Events dialog
+   static BOOL ShowEvents();
+
+   // Routine to make an already running copy of Apcupsd form an outgoing
+   // connection to a new ups client
+   static BOOL PostAddNewClient(unsigned long ipaddress);
+
+private:
+
+};
+
+#endif
diff --git a/bacula/src/win32/dll/Makefile b/bacula/src/win32/dll/Makefile
new file mode 100644 (file)
index 0000000..d97316a
--- /dev/null
@@ -0,0 +1,182 @@
+#
+# Makefile for win32 bacula executables
+# Using MinGW cross-compiler on GNU/Linux
+#
+#  Written by Robert Nelson, June 2006
+#
+
+include ../Makefile.inc
+
+INCLUDES = \
+       $(INCLUDE_PTHREADS) \
+       $(INCLUDE_BACULA) \
+       $(INCLUDE_ZLIB) \
+       $(INCLUDE_OPENSSL) \
+       $(INCLUDE_MYSQL)
+
+DEFINES = \
+       $(HAVES)
+
+VPATH = ../../cats ../compat ../../findlib ../../lib
+
+######################################################################
+
+# Files files in src/lib
+
+CATS_OBJS = \
+       $(OBJDIR)/bdb.o \
+       $(OBJDIR)/bdb_create.o \
+       $(OBJDIR)/bdb_delete.o \
+       $(OBJDIR)/bdb_find.o \
+       $(OBJDIR)/bdb_get.o \
+       $(OBJDIR)/bdb_list.o \
+       $(OBJDIR)/bdb_update.o \
+       $(OBJDIR)/mysql.o \
+       $(OBJDIR)/postgresql.o \
+       $(OBJDIR)/sql.o \
+       $(OBJDIR)/sql_create.o \
+       $(OBJDIR)/sql_delete.o \
+       $(OBJDIR)/sql_find.o \
+       $(OBJDIR)/sql_get.o \
+       $(OBJDIR)/sql_list.o \
+       $(OBJDIR)/sql_update.o \
+       $(OBJDIR)/sqlite.o
+
+COMPAT_OBJS = \
+       $(OBJDIR)/compat.o \
+       $(OBJDIR)/print.o \
+       $(OBJDIR)/winapi.o
+
+#      $(OBJDIR)/getopt.o \
+
+FIND_OBJS = \
+       $(OBJDIR)/attribs.o \
+       $(OBJDIR)/bfile.o \
+       $(OBJDIR)/create_file.o \
+       $(OBJDIR)/drivetype.o \
+       $(OBJDIR)/enable_priv.o \
+       $(OBJDIR)/find.o \
+       $(OBJDIR)/find_one.o \
+       $(OBJDIR)/fstype.o \
+       $(OBJDIR)/makepath.o \
+       $(OBJDIR)/match.o \
+       $(OBJDIR)/save-cwd.o
+
+LIB_OBJS = \
+       $(OBJDIR)/address_conf.o \
+       $(OBJDIR)/alist.o \
+       $(OBJDIR)/alloc.o \
+       $(OBJDIR)/attr.o \
+       $(OBJDIR)/base64.o \
+       $(OBJDIR)/berrno.o \
+       $(OBJDIR)/bget_msg.o \
+       $(OBJDIR)/bnet.o \
+       $(OBJDIR)/bnet_server.o \
+       $(OBJDIR)/bpipe.o \
+       $(OBJDIR)/bregex.o \
+       $(OBJDIR)/bshm.o \
+       $(OBJDIR)/bsnprintf.o \
+       $(OBJDIR)/bsys.o \
+       $(OBJDIR)/btime.o \
+       $(OBJDIR)/btimers.o \
+       $(OBJDIR)/btree.o \
+       $(OBJDIR)/cram-md5.o \
+       $(OBJDIR)/crc32.o \
+       $(OBJDIR)/crypto.o \
+       $(OBJDIR)/daemon.o \
+       $(OBJDIR)/dlist.o \
+       $(OBJDIR)/edit.o \
+       $(OBJDIR)/enh_fnmatch.o \
+       $(OBJDIR)/fnmatch.o \
+       $(OBJDIR)/hmac.o \
+       $(OBJDIR)/htable.o \
+       $(OBJDIR)/idcache.o \
+       $(OBJDIR)/jcr.o \
+       $(OBJDIR)/lex.o \
+       $(OBJDIR)/md5.o \
+       $(OBJDIR)/mem_pool.o \
+       $(OBJDIR)/message.o \
+       $(OBJDIR)/openssl.o \
+       $(OBJDIR)/pythonlib.o \
+       $(OBJDIR)/queue.o \
+       $(OBJDIR)/runscript.o \
+       $(OBJDIR)/rwlock.o \
+       $(OBJDIR)/scan.o \
+       $(OBJDIR)/semlock.o \
+       $(OBJDIR)/serial.o \
+       $(OBJDIR)/sha1.o \
+       $(OBJDIR)/signal.o \
+       $(OBJDIR)/smartall.o \
+       $(OBJDIR)/tls.o \
+       $(OBJDIR)/tree.o \
+       $(OBJDIR)/util.o \
+       $(OBJDIR)/var.o \
+       $(OBJDIR)/watchdog.o \
+       $(OBJDIR)/workq.o
+
+DLL_OBJS = \
+       $(CATS_OBJS) $(COMPAT_OBJS) $(FIND_OBJS) $(LIB_OBJS)
+
+STATIC_OBJS = \
+       $(OBJDIR)/parse_conf.o \
+       $(OBJDIR)/res.o
+
+ALL_OBJS = \
+       $(DLL_OBJS) $(STATIC_OBJS)
+
+LIBS_DLL = \
+       $(LIBS_SSL) \
+       $(LIBS_CRYPTO) \
+       $(LIBS_SQL) \
+       $(LIBS_PTHREADS) \
+       $(LIBS_ZLIB) \
+       -lwsock32 \
+       -lole32 \
+       -loleaut32 \
+       -luuid
+
+######################################################################
+
+# Targets
+
+.PHONY: all clean
+
+all: $(BINDIR)/bacula.dll $(LIBDIR)/libbacula.a
+
+clean:
+       @echo "Cleaning `pwd`"
+       $(call clean_obj,$(ALL_OBJS))
+       $(call clean_exe,$(BINDIR)/bacula.dll)
+       $(ECHO_CMD)rm -f $(OBJDIR)/bacula.a $(LIBDIR)/libbacula.a
+
+#
+# Rules for generating from ../lib
+#
+
+$(LIBDIR)/libbacula.a: DLL_DEFINE=USING_DLL
+
+$(LIBDIR)/libbacula.a: $(BINDIR)/bacula.dll $(STATIC_OBJS)
+       @echo "Updating archive $@"
+       $(call checkdir,$@)
+       $(ECHO_CMD)cp $(OBJDIR)/bacula.a $@
+       $(ECHO_CMD)$(AR) rsv $@ $(filter %.o,$^)
+
+$(BINDIR)/bacula.dll: DLL_DEFINE=BUILDING_DLL
+
+$(BINDIR)/bacula.dll: $(COMPAT_OBJS) $(DLL_OBJS) bacula.def
+       @echo "Linking $@"
+       $(call checkdir,$@)
+       $(ECHO_CMD)$(CXX) $(LDFLAGS) -mdll -mwindows -Wl,--out-implib,$(OBJDIR)/bacula.a $^ $(LIBS_DLL) -o $@
+       $(makedbg)
+
+include ../Makefile.rules
+
+$(OBJDIR)/%.o: %.c
+       @echo "Compiling $<"
+       $(call checkdir,$@)
+       $(ECHO_CMD)$(CXX) -D$(DLL_DEFINE) $(CFLAGS) -c $< -o $@
+
+$(OBJDIR)/%.o: %.cpp
+       @echo "Compiling $<"
+       $(call checkdir,$@)
+       $(ECHO_CMD)$(CXX) -D$(DLL_DEFINE) $(CFLAGS) -c $< -o $@
diff --git a/bacula/src/win32/dll/bacula.def b/bacula/src/win32/dll/bacula.def
new file mode 100644 (file)
index 0000000..eb48ecf
--- /dev/null
@@ -0,0 +1,638 @@
+LIBRARY bacula.dll
+EXPORTS
+_Z10SHA1UpdateP11SHA1ContextPKhj
+_Z10__snprintfPcjPKcz
+_Z10__vsprintfPcPKcS_
+_Z10_db_unlockPKciP4B_DB
+_Z10add_commasPcS_
+_Z10b_free_jcrPKciP3JCR
+_Z10bnet_closeP5BSOCK
+_Z10bnet_fsendP5BSOCKPKcz
+_Z10bstrftimesPcix
+_Z10bvsnprintfPciPKcS_
+_Z10edit_int64xPc
+_Z10edit_utimexPci
+_Z10find_filesP3JCRP6FF_PKTPFiS2_PvbES3_
+_Z10init_bsockP3JCRiPKcS2_iP8sockaddr
+_Z10isAbsolutePKc
+_Z10my_name_isiPPcPKc
+_Z10open_bpipePciPKc
+_Z10parse_argsPcPS_PiS0_S0_i
+_Z10sem_unlockP13s_semlock_tag
+_Z10sm_reallocPKciPvj
+_Z10term_bsockP5BSOCK
+_Z10var_configP6var_st12var_config_tz
+_Z10var_createPP6var_st
+_Z10var_expandP6var_stPKciPPcPii
+_Z10var_formatP6var_stPPciPKcz
+_Z10workq_initP9workq_tagiPFPvS1_E
+_Z11__vsnprintfPcjPKcS_
+_Z11base64_initv
+_Z11bash_spacesPc
+_Z11bash_spacesR8POOL_MEM
+_Z11bget_handleP5BFILE
+_Z11bmicrosleepll
+_Z11close_bpipeP7s_bpipe
+_Z11close_wpipeP7s_bpipe
+_Z11create_fileP3JCRP4ATTRP5BFILEi
+_Z11date_decodedPjPhS0_
+_Z11date_encodejhh
+_Z11db_strerrorP4B_DB
+_Z11decode_statPcP4statPi
+_Z11edit_uint64yPc
+_Z11encode_modetPc
+_Z11encode_statPcP6FF_PKTi
+_Z11encode_timelPc
+_Z11from_base64PxPc
+_Z11init_cryptov
+_Z11int32_LE2BEPii
+_Z11int64_LE2BEPxx
+_Z11is_a_numberPKc
+_Z11is_buf_zeroPci
+_Z11list_dashesP4B_DBPFvPvPKcES1_
+_Z11list_resultP3JCRP4B_DBPFvPvPKcES3_11e_list_type
+_Z11match_filesP3JCRP6FF_PKTPFiS2_PvbES3_
+_Z11restore_cwdPK9saved_cwdPKcS3_
+_Z11run_programPciS_
+_Z11run_scriptsP3JCRP5alistPKc
+_Z11rwl_destroyP12s_rwlock_tag
+_Z11scan_to_eolP13s_lex_context
+_Z11sem_destroyP13s_semlock_tag
+_Z11sem_trylockP13s_semlock_tag
+_Z11skip_spacesPPc
+_Z11strncasecmpPKcS0_i
+_Z11time_decodedPhS_S_Pf
+_Z11time_encodehhhf
+_Z11tree_relcwdPcP11s_tree_rootP11s_tree_node
+_Z11unlock_jobsv
+_Z11var_destroyP6var_st
+_Z11var_formatvP6var_stPPciPKcS1_
+_Z11win32_cgetsPci
+_Z11win32_chdirPKc
+_Z11win32_fputsPKcP6_iobuf
+_Z11win32_mkdirPKc
+_Z12MD5TransformPjS_
+_Z12UTF8_2_wcharPPcPKc
+_Z12actuallyfreePv
+_Z12add_msg_destP4MSGSiiPcS1_
+_Z12bnet_connectP3JCRiiPKcPcS3_ii
+_Z12bstrftime_ncPcix
+_Z12bstrftime_nyPcix
+_Z12daemon_startv
+_Z12db_sql_queryP4B_DBPKcPFiPviPPcES3_
+_Z12gettimeofdayP7timevalP8timezone
+_Z12init_signalsPFviE
+_Z12is_bnet_stopP5BSOCK
+_Z12jcr_walk_endP3JCR
+_Z12job_end_pushP3JCRPFvS0_PvES1_
+_Z12lex_get_charP13s_lex_context
+_Z12new_watchdogv
+_Z12rem_msg_destP4MSGSiiPc
+_Z12rwl_readlockP12s_rwlock_tag
+_Z12serial_btimePPhx
+_Z12serial_int16PPhs
+_Z12serial_int32PPhi
+_Z12serial_int64PPhx
+_Z12sm_check_rtnPKcib
+_Z12sm_new_ownerPKciPc
+_Z12str_to_int64Pc
+_Z12str_to_utimePc
+_Z12tree_getpathP11s_tree_nodePci
+_Z12var_strerrorP6var_st8var_rc_t
+_Z12var_unescapeP6var_stPKciPcii
+_Z12wchar_2_UTF8PcPKwi
+_Z12win32_getcwdPci
+_Z12win32_unlinkPKc
+_Z12workq_removeP9workq_tagP13workq_ele_tag
+_Z13bin_to_base64PcS_i
+_Z13bnet_get_peerP5BSOCKPci
+_Z13bnet_strerrorP5BSOCK
+_Z13btime_to_unixx
+_Z13cram_md5_authP5BSOCKPci
+_Z13db_next_indexP3JCRP4B_DBPcS3_
+_Z13decode_LinkFIPcP4stat
+_Z13find_one_fileP3JCRP6FF_PKTPFiS2_PvbES3_Pcjb
+_Z13free_msgs_resP4MSGS
+_Z13get_jcr_by_idj
+_Z13is_an_integerPKc
+_Z13is_bnet_errorP5BSOCK
+_Z13is_name_validPcPS_
+_Z13jcr_walk_nextP3JCR
+_Z13lex_get_tokenP13s_lex_contexti
+_Z13lex_open_fileP13s_lex_contextPKcPFvS2_iS0_S2_zE
+_Z13new_runscriptv
+_Z13rwl_writelockP12s_rwlock_tag
+_Z13serial_stringPPhPKc
+_Z13serial_uint16PPht
+_Z13serial_uint32PPhj
+_Z13serial_uint64PPhy
+_Z13sm_get_memoryPKcii
+_Z13stop_watchdogv
+_Z13str_to_uint64Pc
+_Z13term_find_oneP6FF_PKT
+_Z13unbash_spacesPc
+_Z13unbash_spacesR8POOL_MEM
+_Z13workq_destroyP9workq_tag
+_Z14actuallycallocjj
+_Z14actuallymallocj
+_Z14bnet_wait_dataP5BSOCKi
+_Z14btime_to_utimex
+_Z14cleanup_cryptov
+_Z14copy_runscriptP9RUNSCRIPT
+_Z14edit_job_codesP3JCRPcS1_PKc
+_Z14free_addressesP5dlist
+_Z14free_runscriptP9RUNSCRIPT
+_Z14have_win32_apiv
+_Z14jcr_walk_startv
+_Z14lex_close_fileP13s_lex_context
+_Z14lex_tok_to_stri
+_Z14lex_unget_charP13s_lex_context
+_Z14make_tree_pathPcP11s_tree_root
+_Z14rwl_readunlockP12s_rwlock_tag
+_Z14serial_float64PPhd
+_Z14set_attributesP3JCRP4ATTRP5BFILE
+_Z14size_to_uint64PciPy
+_Z14skip_nonspacesPPc
+_Z14start_watchdogv
+_Z14unserial_btimePPh
+_Z14unserial_int16PPh
+_Z14unserial_int32PPh
+_Z15actuallyreallocPvj
+_Z15bnet_tls_clientP11TLS_ContextP5BSOCK
+_Z15bnet_tls_serverP11TLS_ContextP5BSOCKP5alist
+_Z15create_pid_filePcPKci
+_Z15crypto_sign_newv
+_Z15crypto_strerror14crypto_error_t
+_Z15db_get_pool_idsP3JCRP4B_DBPiPPj
+_Z15delete_pid_filePcPKci
+_Z15enh_fnmatch_subPKcS0_ii
+_Z15free_runscriptsP5alist
+_Z15init_find_filesv
+_Z15init_stack_dumpv
+_Z15is_win32_streami
+_Z15job_type_to_stri
+_Z15new_tls_contextPKcS0_S0_S0_PFiPciPKvES3_S0_b
+_Z15print_ls_outputP3JCRP4ATTR
+_Z15read_state_filePcPKci
+_Z15rwl_readtrylockP12s_rwlock_tag
+_Z15rwl_writeunlockP12s_rwlock_tag
+_Z15store_addressesP13s_lex_contextP8RES_ITEMii
+_Z15stream_to_asciii
+_Z15term_find_filesP6FF_PKT
+_Z15tls_bsock_readnP5BSOCKPci
+_Z15unserial_stringPPhPc
+_Z15unserial_uint16PPh
+_Z15unserial_uint32PPh
+_Z15unserial_uint64PPh
+_Z16crypto_sign_freeP9Signature
+_Z16date_time_decodeP9date_timePjPhS2_S2_S2_S2_Pf
+_Z16date_time_encodeP9date_timejhhhhhf
+_Z16db_escape_stringPcS_i
+_Z16db_get_media_idsP3JCRP4B_DBjPiPPj
+_Z16db_init_databaseP3JCRPKcS2_S2_S2_iS2_i
+_Z16db_open_databaseP3JCRP4B_DB
+_Z16dequeue_messagesP3JCR
+_Z16dispatch_messageP3JCRilPc
+_Z16encode_attribsExP3JCRPcP6FF_PKT
+_Z16file_is_excludedP6FF_PKTPKc
+_Z16file_is_includedP6FF_PKTPKc
+_Z16free_tls_contextP11TLS_Context
+_Z16get_current_timeP9date_time
+_Z16init_console_msgPKc
+_Z16insert_tree_nodePcS_iP11s_tree_rootP11s_tree_node
+_Z16job_level_to_stri
+_Z16make_session_keyPcS_i
+_Z16rwl_writetrylockP12s_rwlock_tag
+_Z16set_find_optionsP6FF_PKTil
+_Z16set_win32_backupP5BFILE
+_Z16stop_bsock_timerP10s_btimer_t
+_Z16stop_child_timerP10s_btimer_t
+_Z16tls_bsock_acceptP5BSOCK
+_Z16tls_bsock_writenP5BSOCKPci
+_Z16unserial_float64PPh
+_Z16wchar_win32_pathPKcPw
+_Z16write_state_filePcPKci
+_Z17InitWinAPIWrapperv
+_Z17SetVSSPathConvertPFiPKcPciEPFiPKwPwiE
+_Z17bnet_host2ipaddrsPKciPS0_
+_Z17bnet_set_blockingP5BSOCK
+_Z17bnet_sig_to_asciiP5BSOCK
+_Z17close_memory_poolv
+_Z17cram_md5_get_authP5BSOCKPcPi
+_Z17crypto_cipher_newP14Crypto_SessionbPj
+_Z17crypto_digest_new15crypto_digest_t
+_Z17date_time_compareP9date_timeS0_
+_Z17db_close_databaseP3JCRP4B_DB
+_Z17db_get_client_idsP3JCRP4B_DBPiPPj
+_Z17db_get_job_recordP3JCRP4B_DBP7JOB_DBR
+_Z17db_get_mac_recordP3JCRP4B_DBP7MAC_DBR
+_Z17db_list_sql_queryP3JCRP4B_DBPKcPFvPvS4_ES5_i11e_list_type
+_Z17duration_to_utimePcPx
+_Z17get_current_btimev
+_Z17get_first_addressP5dlistPci
+_Z17job_status_to_stri
+_Z17openssl_save_prngv
+_Z17openssl_seed_prngv
+_Z17register_watchdogP12s_watchdog_t
+_Z17sockaddr_get_portPK8sockaddr
+_Z17sockaddr_to_asciiPK8sockaddrPci
+_Z17start_bsock_timerP5BSOCKj
+_Z17start_child_timerij
+_Z17stop_thread_timerP10s_btimer_t
+_Z17tls_bsock_connectP5BSOCK
+_Z18CreateChildProcessPKcPvS1_S1_
+_Z18bnet_thread_serverP5dlistiP9workq_tagPFPvS3_E
+_Z18crypto_cipher_freeP14Cipher_Context
+_Z18crypto_digest_freeP6Digest
+_Z18crypto_digest_nameP6Digest
+_Z18crypto_keypair_dupP12X509_Keypair
+_Z18crypto_keypair_newv
+_Z18crypto_session_new15crypto_cipher_tP5alist
+_Z18crypto_sign_decodePKvj
+_Z18crypto_sign_encodeP9SignaturePvPj
+_Z18crypto_sign_verifyP9SignatureP12X509_KeypairP6Digest
+_Z18cvt_ftime_to_utimeRK9_FILETIME
+_Z18cvt_utime_to_ftimeRKlR9_FILETIME
+_Z18db_end_transactionP3JCRP4B_DB
+_Z18db_find_last_jobidP3JCRP4B_DBPKcP7JOB_DBR
+_Z18db_get_pool_recordP3JCRP4B_DBP8POOL_DBR
+_Z18db_list_job_totalsP3JCRP4B_DBP7JOB_DBRPFvPvPKcES5_
+_Z18do_shell_expansionPci
+_Z18free_getuser_cachev
+_Z18get_jcr_by_sessionjj
+_Z18get_sql_record_maxP3JCRP4B_DB
+_Z18init_jcr_subsystemv
+_Z18is_portable_backupP5BFILE
+_Z18jobstatus_to_asciiiPci
+_Z18new_tls_connectionP11TLS_Contexti
+_Z18select_data_streamP6FF_PKT
+_Z18set_jcr_job_statusP3JCRi
+_Z18sm_get_pool_memoryPKcii
+_Z18start_thread_timerP10pthread_t_j
+_Z18tls_bsock_shutdownP5BSOCK
+_Z18unix_name_to_win32PPcS_
+_Z19bnet_wait_data_intrP5BSOCKi
+_Z19build_addresses_strP5dlistPci
+_Z19crypto_keypair_freeP12X509_Keypair
+_Z19crypto_session_freeP14Crypto_Session
+_Z19db_find_next_volumeP3JCRP4B_DBibP9MEDIA_DBR
+_Z19db_get_media_recordP3JCRP4B_DBP9MEDIA_DBR
+_Z19db_list_job_recordsP3JCRP4B_DBP7JOB_DBRPFvPvPKcES5_11e_list_type
+_Z19db_mark_file_recordP3JCRP4B_DBjj
+_Z19free_getgroup_cachev
+_Z19free_tls_connectionP14TLS_Connection
+_Z19init_last_jobs_listv
+_Z19lock_last_jobs_listv
+_Z19openssl_post_errorsiPKc
+_Z19read_last_jobs_listiy
+_Z19set_portable_backupP5BFILE
+_Z19sm_free_pool_memoryPKciPc
+_Z19split_path_and_fileP3JCRP4B_DBPKc
+_Z19strip_leading_spacePc
+_Z19strip_trailing_junkPc
+_Z19term_last_jobs_listv
+_Z19unregister_watchdogP12s_watchdog_t
+_Z20bnet_set_buffer_sizeP5BSOCKji
+_Z20bnet_set_nonblockingP5BSOCK
+_Z20check_tables_versionP3JCRP4B_DB
+_Z20crypto_cipher_updateP14Cipher_ContextPKvjS2_Pj
+_Z20crypto_digest_updateP6DigestPKvj
+_Z20db_create_job_recordP3JCRP4B_DBP7JOB_DBR
+_Z20db_create_mac_recordP3JCRP4B_DBP7MAC_DBR
+_Z20db_get_client_recordP3JCRP4B_DBP10CLIENT_DBR
+_Z20db_list_pool_recordsP3JCRP4B_DBP8POOL_DBRPFvPvPKcES5_11e_list_type
+_Z20db_start_transactionP3JCRP4B_DB
+_Z20get_jcr_by_full_namePc
+_Z20make_unique_filenamePPciS_
+_Z20openssl_init_threadsv
+_Z20scan_to_next_not_eolP13s_lex_context
+_Z20store_addresses_portP13s_lex_contextP8RES_ITEMii
+_Z20write_last_jobs_listiy
+_Z21Win32ConvCleanupCachev
+_Z21bnet_despool_to_bsockP5BSOCKPFvlEl
+_Z21bnet_restore_blockingP5BSOCKi
+_Z21crypto_session_decodePKvjP5alistPP14Crypto_Session
+_Z21crypto_session_encodeP14Crypto_SessionPvPj
+_Z21db_create_pool_recordP3JCRP4B_DBP8POOL_DBR
+_Z21db_delete_pool_recordP3JCRP4B_DBP8POOL_DBR
+_Z21db_get_counter_recordP3JCRP4B_DBP11COUNTER_DBR
+_Z21db_get_fileset_recordP3JCRP4B_DBP11FILESET_DBR
+_Z21db_list_files_for_jobP3JCRP4B_DBjPFvPvPKcES3_
+_Z21db_list_media_recordsP3JCRP4B_DBP9MEDIA_DBRPFvPvPKcES5_11e_list_type
+_Z21db_purge_media_recordP3JCRP4B_DBP9MEDIA_DBR
+_Z21db_update_pool_recordP3JCRP4B_DBP8POOL_DBR
+_Z21generate_daemon_eventP3JCRPKc
+_Z21make_wchar_win32_pathPcPi
+_Z21set_working_directoryPc
+_Z21sm_sizeof_pool_memoryPKciPc
+_Z21unlock_last_jobs_listv
+_Z22crypto_cipher_finalizeP14Cipher_ContextPvPj
+_Z22crypto_digest_finalizeP6DigestPvPj
+_Z22crypto_keypair_has_keyPKc
+_Z22crypto_sign_add_signerP9SignatureP6DigestP12X509_Keypair
+_Z22crypto_sign_get_digestP9SignatureP12X509_KeypairPP6Digest
+_Z22db_create_media_recordP3JCRP4B_DBP9MEDIA_DBR
+_Z22db_delete_media_recordP3JCRP4B_DBP9MEDIA_DBR
+_Z22db_find_job_start_timeP3JCRP4B_DBP7JOB_DBRPPc
+_Z22db_list_client_recordsP3JCRP4B_DBPFvPvPKcES3_11e_list_type
+_Z22db_update_media_recordP3JCRP4B_DBP9MEDIA_DBR
+_Z22get_next_included_fileP6FF_PKTP15s_included_file
+_Z22get_win32_drivelettersP6FF_PKTPc
+_Z22init_default_addressesPP5dlisti
+_Z22sm_realloc_pool_memoryPKciPci
+_Z22strip_trailing_newlinePc
+_Z22strip_trailing_slashesPc
+_Z23bnet_stop_thread_serverP10pthread_t_
+_Z23conv_unix_to_win32_pathPKcPcm
+_Z23crypto_keypair_load_keyP12X509_KeypairPKcPFiPciPKvES5_
+_Z23db_create_client_recordP3JCRP4B_DBP10CLIENT_DBR
+_Z23db_create_device_recordP3JCRP4B_DBP10DEVICE_DBR
+_Z23db_get_job_volume_namesP3JCRP4B_DBjPPc
+_Z23db_get_num_pool_recordsP3JCRP4B_DB
+_Z23db_update_client_recordP3JCRP4B_DBP10CLIENT_DBR
+_Z23edit_uint64_with_commasyPc
+_Z23edit_uint64_with_suffixyPc
+_Z23get_jcr_by_partial_namePc
+_Z23init_python_interpreterPKcS0_S0_
+_Z23openssl_cleanup_threadsv
+_Z23print_memory_pool_statsv
+_Z23run_program_full_outputPciS_
+_Z23split_path_and_filenamePKcPPcPiS2_S3_
+_Z23store_addresses_addressP13s_lex_contextP8RES_ITEMii
+_Z23term_python_interpreterv
+_Z24build_attr_output_fnamesP3JCRP4ATTR
+_Z24crypto_keypair_load_certP12X509_KeypairPKc
+_Z24db_create_counter_recordP3JCRP4B_DBP11COUNTER_DBR
+_Z24db_create_fileset_recordP3JCRP4B_DBP11FILESET_DBR
+_Z24db_create_storage_recordP3JCRP4B_DBP11STORAGE_DBR
+_Z24db_find_failed_job_sinceP3JCRP4B_DBP7JOB_DBRPcRi
+_Z24db_get_num_media_recordsP3JCRP4B_DB
+_Z24db_list_jobmedia_recordsP3JCRP4B_DBjPFvPvPKcES3_11e_list_type
+_Z24db_make_inchanger_uniqueP3JCRP4B_DBP9MEDIA_DBR
+_Z24db_update_counter_recordP3JCRP4B_DBP11COUNTER_DBR
+_Z24db_update_job_end_recordP3JCRP4B_DBP7JOB_DBR
+_Z24db_update_media_defaultsP3JCRP4B_DBP9MEDIA_DBR
+_Z24db_update_storage_recordP3JCRP4B_DBP11STORAGE_DBR
+_Z24enable_backup_privilegesP3JCRi
+_Z24get_first_port_net_orderP5dlist
+_Z24unpack_attributes_recordP3JCRiPcP4ATTR
+_Z25add_fname_to_exclude_listP6FF_PKTPKc
+_Z25add_fname_to_include_listP6FF_PKTiPKc
+_Z25crypto_digest_stream_typei
+_Z25db_create_jobmedia_recordP3JCRP4B_DBP12JOBMEDIA_DBR
+_Z25get_first_port_host_orderP5dlist
+_Z25sm_check_pool_memory_sizePKciPci
+_Z25tls_postconnect_verify_cnP14TLS_ConnectionP5alist
+_Z26db_create_mediatype_recordP3JCRP4B_DBP13MEDIATYPE_DBR
+_Z26db_update_job_start_recordP3JCRP4B_DBP7JOB_DBR
+_Z26processWin32BackupAPIBlockP5BFILEPvl
+_Z26term_include_exclude_filesP6FF_PKT
+_Z27crypto_default_pem_callbackPciPKv
+_Z27garbage_collect_memory_poolv
+_Z27is_restore_stream_supportedi
+_Z27sockaddr_get_port_net_orderPK8sockaddr
+_Z27tls_postconnect_verify_hostP14TLS_ConnectionPKc
+_Z28bnet_suppress_error_messagesP5BSOCKb
+_Z28db_add_digest_to_file_recordP3JCRP4B_DBjPci
+_Z28db_get_job_volume_parametersP3JCRP4B_DBjPP10VOL_PARAMS
+_Z28make_win32_path_UTF8_2_wcharPPcPKcPi
+_Z29db_get_file_attributes_recordP3JCRP4B_DBPcP7JOB_DBRP8FILE_DBR
+_Z29lex_set_default_error_handlerP13s_lex_context
+_Z2_pPP16pthread_mutex_t_
+_Z2_vPP16pthread_mutex_t_
+_Z32db_create_file_attributes_recordP3JCRP4B_DBP8ATTR_DBR
+_Z32lex_set_error_handler_error_typeP13s_lex_contexti
+_Z4JmsgP3JCRilPKcz
+_Z4MmsgPPcPKcz
+_Z4MmsgR8POOL_MEMPKcz
+_Z4MmsgRPcPKcz
+_Z4QmsgP3JCRilPKcz
+_Z4doprPcjPKcS_PFvS_PjjiE
+_Z4dropPcS_
+_Z4forkv
+_Z4killii
+_Z4pipePi
+_Z4plugIjEvRT_y
+_Z4plugIlEvRT_y
+_Z4plugImEvRT_y
+_Z4plugIsEvRT_y
+_Z4plugItEvRT_y
+_Z4plugIyEvRT_y
+_Z4statPKcP4stat
+_Z5binitP5BFILE
+_Z5bopenP5BFILEPKcit
+_Z5breadP5BFILEPvj
+_Z5chmodPKct
+_Z5chownPKcjj
+_Z5d_msgPKciiS0_z
+_Z5e_msgPKciiiS0_z
+_Z5fcntlii
+_Z5fcntliil
+_Z5fstatiP4stat
+_Z5j_msgPKciP3JCRilS0_z
+_Z5lcasePc
+_Z5lstatPKcP4stat
+_Z5m_msgPKciPPcS0_z
+_Z5m_msgPKciRPcS0_z
+_Z5p_msgPKciiS0_z
+_Z5q_msgPKciP3JCRilS0_z
+_Z5qnextP7b_queueS0_
+_Z5sleepi
+_Z5t_msgPKciiS0_z
+_Z6bcloseP5BFILE
+_Z6bcrc32Phi
+_Z6bfgetsPciP6_iobuf
+_Z6blseekP5BFILEli
+_Z6bwriteP5BFILEPvj
+_Z6execvpPKcPPc
+_Z6fstypePKcPci
+_Z6lchownPKcjj
+_Z6randomv
+_Z6tm_womii
+_Z6tm_woyl
+_Z7MD5InitP10MD5Context
+_Z7QueryDBPKciP3JCRP4B_DBPc
+_Z7bcallocjj
+_Z7bsscanfPKcS0_z
+_Z7bstrcmpPKcS0_
+_Z7cstrlenPKc
+_Z7fstrschPKcS0_
+_Z7geteuidv
+_Z7getuserjPci
+_Z7new_jcriPFvP3JCRE
+_Z7opendirPKc
+_Z7openlogPKcii
+_Z7qdchainP7b_queue
+_Z7qinsertP7b_queueS0_
+_Z7qremoveP7b_queue
+_Z7sm_dumpb
+_Z7sm_freePKciPv
+_Z7srandomj
+_Z7waitpidiPii
+_Z8DeleteDBPKciP3JCRP4B_DBPc
+_Z8InsertDBPKciP3JCRP4B_DBPc
+_Z8MD5FinalPhP10MD5Context
+_Z8SHA1InitP11SHA1Context
+_Z8UpdateDBPKciP3JCRP4B_DBPc
+_Z8WSA_Initv
+_Z8_db_lockPKciP4B_DB
+_Z8b_mallocPKcij
+_Z8bget_msgP5BSOCK
+_Z8bnet_sigP5BSOCKi
+_Z8breallocPvj
+_Z8bstrncatPcPKci
+_Z8bstrncatPcR8POOL_MEMi
+_Z8bstrncpyPcPKci
+_Z8bstrncpyPcR8POOL_MEMi
+_Z8closedirPv
+_Z8closelogv
+_Z8free_cwdP9saved_cwd
+_Z8getArgv0PKc
+_Z8getgrgidj
+_Z8getgroupjPci
+_Z8getpwuidj
+_Z8hmac_md5PhiS_iS_
+_Z8init_msgP3JCRP4MSGS
+_Z8is_bopenP5BFILE
+_Z8new_attrv
+_Z8new_treei
+_Z8next_argPPc
+_Z8pathconfPKci
+_Z8readlinkPKcPci
+_Z8rwl_initP12s_rwlock_tag
+_Z8save_cwdP9saved_cwd
+_Z8sem_initP13s_semlock_tagi
+_Z8sem_lockP13s_semlock_tag
+_Z8set_progP5BFILEPcP3JCR
+_Z8sm_checkPKcib
+_Z8term_msgv
+_Z8tree_cwdPcP11s_tree_rootP11s_tree_node
+_Z9ErrorExitPKc
+_Z9MD5UpdateP10MD5ContextPhj
+_Z9SHA1FinalP11SHA1ContextPh
+_Z9__sprintfPcPKcz
+_Z9bnet_recvP5BSOCK
+_Z9bnet_sendP5BSOCK
+_Z9bsnprintfPciPKcz
+_Z9bstrerroriPcj
+_Z9bstrftimePcix
+_Z9bstrutimePcix
+_Z9close_msgP3JCR
+_Z9drivetypePKcPci
+_Z9dup_bsockP5BSOCK
+_Z9free_attrP4ATTR
+_Z9free_treeP11s_tree_root
+_Z9get_tracev
+_Z9inet_atonPKcP7in_addr
+_Z9lock_jobsv
+_Z9make_pathP3JCRPKciijjiPc
+_Z9nanosleepPK8timespecPS_
+_Z9pm_strcatPPcPKc
+_Z9pm_strcatR8POOL_MEMPKc
+_Z9pm_strcatRPcPKc
+_Z9pm_strcatRPcR8POOL_MEM
+_Z9pm_strcpyPPcPKc
+_Z9pm_strcpyR8POOL_MEMPKc
+_Z9pm_strcpyRPcPKc
+_Z9pm_strcpyRPcR8POOL_MEM
+_Z9readdir_rPvP6direntPS1_
+_Z9set_tracei
+_Z9sm_callocPKcijj
+_Z9sm_mallocPKcij
+_Z9sm_statici
+_Z9tm_decodeP9date_timeP2tm
+_Z9tm_encodeP9date_timeP2tm
+_Z9to_base64xPc
+_Z9win_errorP3JCRPcS1_
+_Z9win_errorP3JCRPcm
+_Z9workq_addP9workq_tagPvPP13workq_ele_tagi
+_ZN5alist3getEi
+_ZN5alist4lastEv
+_ZN5alist4nextEv
+_ZN5alist4prevEv
+_ZN5alist5firstEv
+_ZN5alist6appendEPv
+_ZN5alist6removeEi
+_ZN5alist7destroyEv
+_ZN5alist7prependEPv
+_ZN5alist9grow_listEv
+_ZN5btree11left_rotateEP5bnode
+_ZN5btree12right_rotateEP5bnode
+_ZN5btree3anyEP5bnode
+_ZN5btree4nextEP5bnode
+_ZN5btree5firstEv
+_ZN5btree6insertEP5bnodePFiS1_S1_E
+_ZN5btree6removeEP5bnode
+_ZN5btree6searchEP5bnodePFiS1_S1_E
+_ZN5btree7destroyEv
+_ZN5dlist12insert_afterEPvS0_
+_ZN5dlist13binary_insertEPvPFiS0_S0_E
+_ZN5dlist13binary_searchEPvPFiS0_S0_E
+_ZN5dlist13insert_beforeEPvS0_
+_ZN5dlist22binary_insert_multipleEPvPFiS0_S0_E
+_ZN5dlist6appendEPv
+_ZN5dlist6removeEPv
+_ZN5dlist7destroyEv
+_ZN5dlist7prependEPv
+_ZN6IPADDR11get_addressEPci
+_ZN6IPADDR12get_sockaddrEv
+_ZN6IPADDR12set_addr_anyEv
+_ZN6IPADDR12set_port_netEt
+_ZN6IPADDR16get_sockaddr_lenEv
+_ZN6IPADDR17build_address_strEPci
+_ZN6IPADDR8set_typeENS_6i_typeE
+_ZN6IPADDR9copy_addrEPS_
+_ZN6IPADDR9set_addr4EP7in_addr
+_ZN6IPADDRC1ERKS_
+_ZN6IPADDRC1Ei
+_ZN6IPADDRC2ERKS_
+_ZN6IPADDRC2Ei
+_ZN6berrno20format_win32_messageEv
+_ZN6berrno8strerrorEv
+_ZN6htable10grow_tableEv
+_ZN6htable10hash_indexEPc
+_ZN6htable4initEPvS0_i
+_ZN6htable4nextEv
+_ZN6htable4sizeEv
+_ZN6htable5firstEv
+_ZN6htable5statsEv
+_ZN6htable6insertEPcPv
+_ZN6htable6lookupEPc
+_ZN6htable7destroyEv
+_ZN6htableC1EPvS0_i
+_ZN6htableC2EPvS0_i
+_ZN6winverC1Ev
+_ZN6winverC2Ev
+_ZN8POOL_MEM10realloc_pmEi
+_ZN8POOL_MEM6strcatEPKc
+_ZN8POOL_MEM6strcpyEPKc
+_ZN8POOL_MEM8max_sizeEv
+_ZN9RUNSCRIPT10set_targetEPKc
+_ZN9RUNSCRIPT11set_commandEPKc
+_ZN9RUNSCRIPT13reset_defaultEb
+_ZN9RUNSCRIPT3runEP3JCRPKc
+_ZN9RUNSCRIPT5debugEv
+_ZN9RUNSCRIPT8is_localEv
+_ZNK5dlist4nextEPKv
+_ZNK5dlist4prevEPKv
+_ZNK6IPADDR10get_familyEv
+_ZNK6IPADDR18get_port_net_orderEv
+_ZNK6IPADDR8get_typeEv
+b_re_compile_fastmap
+b_re_compile_initialize
+b_re_compile_pattern
+b_re_match
+b_re_search
+b_re_set_syntax
+b_regcomp
+b_regerror
+b_regexec
+b_regfree
+enh_fnmatch
+fnmatch
+syslog
+timeout_handler
+umask
+utime
+watchdog_thread
+workq_server
diff --git a/bacula/src/win32/libbac/Makefile b/bacula/src/win32/libbac/Makefile
new file mode 100644 (file)
index 0000000..48763f4
--- /dev/null
@@ -0,0 +1,110 @@
+#
+# Makefile for win32 bacula executables
+# Using MinGW cross-compiler on GNU/Linux
+#  
+#  Written for Bacula by Howard Thomson, April 2006
+# 
+
+include ../Makefile.inc
+
+INCLUDES = \
+       $(INCLUDE_GCC) \
+       $(INCLUDE_MINGW) \
+       $(INCLUDE_PTHREADS) \
+       $(INCLUDE_BACULA) \
+       $(INCLUDE_ZLIB) \
+       $(INCLUDE_VSS) \
+       $(INCLUDE_ICONS) \
+       $(INCLUDE_OPENSSL)
+
+DEFINES = \
+       -DWIN32 \
+       $(HAVES)
+
+######################################################################
+
+# Files files in src/lib
+
+LIB_OBJS = \
+       $(OBJDIR)/address_conf.o \
+       $(OBJDIR)/alist.o \
+       $(OBJDIR)/alloc.o \
+       $(OBJDIR)/attr.o \
+       $(OBJDIR)/base64.o \
+       $(OBJDIR)/berrno.o \
+       $(OBJDIR)/bget_msg.o \
+       $(OBJDIR)/bnet.o \
+       $(OBJDIR)/bnet_server.o \
+       $(OBJDIR)/bpipe.o \
+       $(OBJDIR)/bregex.o \
+       $(OBJDIR)/bshm.o \
+       $(OBJDIR)/bsnprintf.o \
+       $(OBJDIR)/bsys.o \
+       $(OBJDIR)/btime.o \
+       $(OBJDIR)/btimers.o \
+       $(OBJDIR)/btree.o \
+       $(OBJDIR)/cram-md5.o \
+       $(OBJDIR)/crc32.o \
+       $(OBJDIR)/crypto.o \
+       $(OBJDIR)/daemon.o \
+       $(OBJDIR)/dlist.o \
+       $(OBJDIR)/edit.o \
+       $(OBJDIR)/enh_fnmatch.o \
+       $(OBJDIR)/fnmatch.o \
+       $(OBJDIR)/hmac.o \
+       $(OBJDIR)/htable.o \
+       $(OBJDIR)/idcache.o \
+       $(OBJDIR)/jcr.o \
+       $(OBJDIR)/lex.o \
+       $(OBJDIR)/md5.o \
+       $(OBJDIR)/mem_pool.o \
+       $(OBJDIR)/message.o \
+       $(OBJDIR)/openssl.o \
+       $(OBJDIR)/parse_conf.o \
+       $(OBJDIR)/pythonlib.o \
+       $(OBJDIR)/queue.o \
+       $(OBJDIR)/res.o \
+       $(OBJDIR)/runscript.o \
+       $(OBJDIR)/rwlock.o \
+       $(OBJDIR)/scan.o \
+       $(OBJDIR)/semlock.o \
+       $(OBJDIR)/serial.o \
+       $(OBJDIR)/sha1.o \
+       $(OBJDIR)/signal.o \
+       $(OBJDIR)/smartall.o \
+       $(OBJDIR)/tls.o \
+       $(OBJDIR)/tree.o \
+       $(OBJDIR)/util.o \
+       $(OBJDIR)/var.o \
+       $(OBJDIR)/watchdog.o \
+       $(OBJDIR)/winapi.o \
+       $(OBJDIR)/workq.o
+
+#      $(LIBDIR)/events.o
+
+######################################################################
+
+# Targets
+
+.PHONY: all clean
+
+all: $(LIBDIR)/libbac.a
+
+clean:
+       @echo "Cleaning `pwd`"
+       $(ECHO_CMD)rm -f $(OBJDIR)/*.[od] $(LIBDIR)/libbac.a
+
+#
+# Rules
+# 
+
+$(LIBDIR)/libbac.a: $(LIB_OBJS)
+       @echo "Updating archive $@"
+       $(call checkdir,$@)
+       $(ECHO_CMD)$(AR) rs $@ $^
+
+include ../Makefile.rules
+
+ifneq ($(MAKECMDGOALS),clean)
+include $(patsubst %.o,%.d,$(filter-out %.res,$(LIB_OBJS)))
+endif
diff --git a/bacula/src/win32/libbac/libbac.vcproj b/bacula/src/win32/libbac/libbac.vcproj
new file mode 100644 (file)
index 0000000..a7be788
--- /dev/null
@@ -0,0 +1,1339 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="libbac"
+       ProjectGUID="{374BF775-AF68-4A88-814A-48F692DFFE5A}"
+       RootNamespace="libbac"
+       Keyword="Win32Proj"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="4"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="../compat;../..;&quot;../../../../depkgs-win32/pthreads&quot;"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_LIB;HAVE_WIN32;WIN32_VSS;_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="VCLibrarianTool"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="4"
+                       UseOfATL="1"
+                       CharacterSet="2"
+                       WholeProgramOptimization="0"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="../compat;../..;&quot;../../../../depkgs-win32/pthreads&quot;"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_LIB;HAVE_WIN32;WIN32_VSS;_USE_32BIT_TIME_T;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
+                               RuntimeLibrary="2"
+                               EnableFunctionLevelLinking="true"
+                               UsePrecompiledHeader="0"
+                               BrowseInformation="1"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="false"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLibrarianTool"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       >
+                       <File
+                               RelativePath="..\..\lib\address_conf.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\alist.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\alloc.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\attr.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\base64.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\berrno.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bget_msg.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bnet.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bnet_server.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bpipe.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bregex.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bshm.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bsys.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\btime.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\btimers.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\cram-md5.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\crc32.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\crypto.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\daemon.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\dlist.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\edit.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\enh_fnmatch.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\fnmatch.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\hmac.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\htable.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\idcache.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\jcr.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\lex.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\md5.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\mem_pool.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\message.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\parse_conf.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\pythonlib.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\queue.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\res.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\runscript.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\rwlock.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\scan.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\semlock.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\serial.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\sha1.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\signal.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\smartall.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\tls.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\tree.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\util.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\var.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\watchdog.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\winapi.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\workq.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"
+                       >
+                       <File
+                               RelativePath="..\..\lib\address_conf.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\alist.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\attr.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\base64.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\berrno.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bits.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bpipe.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bregex.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bsd_queue.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bshm.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\bsock.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\btime.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\btimers.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\btree.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\crypto.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\dlist.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\enh_fnmatch.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\fnmatch.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\getopt.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\htable.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\lex.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\lib.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\md5.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\mem_pool.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\message.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\openssl.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\parse_conf.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\protos.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\queue.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\runscript.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\rwlock.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\semlock.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\serial.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\sha1.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\smartall.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\tcpd.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\tls.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\tree.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\var.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\waitq.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\watchdog.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\winapi.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\lib\workq.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"
+                       >
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/bacula/src/win32/libfind/Makefile b/bacula/src/win32/libfind/Makefile
new file mode 100644 (file)
index 0000000..8f36f4e
--- /dev/null
@@ -0,0 +1,66 @@
+#
+# Makefile for win32 bacula executables
+# Using MinGW cross-compiler on GNU/Linux
+#  
+#  Written for Bacula by Howard Thomson, April 2006
+# 
+
+include ../Makefile.inc
+
+INCLUDES = \
+       $(INCLUDE_GCC) \
+       $(INCLUDE_MINGW) \
+       $(INCLUDE_PTHREADS) \
+       $(INCLUDE_BACULA) \
+       $(INCLUDE_ZLIB) \
+       $(INCLUDE_VSS) \
+       $(INCLUDE_ICONS) \
+       $(INCLUDE_OPENSSL)
+
+DEFINES = \
+       -DWIN32 \
+       $(HAVES)
+
+######################################################################
+
+# Files files in src/lib
+
+LIB_OBJS = \
+       $(OBJDIR)/attribs.o \
+       $(OBJDIR)/bfile.o \
+       $(OBJDIR)/create_file.o \
+       $(OBJDIR)/drivetype.o \
+       $(OBJDIR)/enable_priv.o \
+       $(OBJDIR)/find.o \
+       $(OBJDIR)/find_one.o \
+       $(OBJDIR)/fstype.o \
+       $(OBJDIR)/makepath.o \
+       $(OBJDIR)/match.o \
+       $(OBJDIR)/save-cwd.o
+
+######################################################################
+
+# Targets
+
+.PHONY: all clean
+
+all: $(LIBDIR)/libfind.a
+
+clean:
+       @echo "Cleaning `pwd`"
+       $(ECHO_CMD)rm -f $(OBJDIR)/*.[od] $(LIBDIR)/libfind.a
+
+#
+# Rules for generating from ../lib
+# 
+
+$(LIBDIR)/libfind.a: $(LIB_OBJS)
+       @echo "Updating archive $@"
+       $(call checkdir,$@)
+       $(ECHO_CMD)$(AR) rs $@ $^
+
+include ../Makefile.rules
+
+ifneq ($(MAKECMDGOALS),clean)
+include $(patsubst %.o,%.d,$(filter-out %.res,$(LIB_OBJS)))
+endif
diff --git a/bacula/src/win32/libfind/libfind.vcproj b/bacula/src/win32/libfind/libfind.vcproj
new file mode 100644 (file)
index 0000000..54b51ef
--- /dev/null
@@ -0,0 +1,406 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="libfind"
+       ProjectGUID="{05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F}"
+       RootNamespace="libfind"
+       Keyword="Win32Proj"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="4"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="../compat;../..;&quot;../../../../depkgs-win32/pthreads&quot;"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_LIB;HAVE_WIN32;_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="VCLibrarianTool"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="4"
+                       CharacterSet="2"
+                       WholeProgramOptimization="0"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="../compat;../..;&quot;../../../../depkgs-win32/pthreads&quot;"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_LIB;HAVE_WIN32;_USE_32BIT_TIME_T;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
+                               RuntimeLibrary="2"
+                               EnableFunctionLevelLinking="true"
+                               UsePrecompiledHeader="0"
+                               BrowseInformation="1"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="false"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLibrarianTool"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       >
+                       <File
+                               RelativePath="..\..\findlib\attribs.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\findlib\bfile.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\findlib\create_file.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\findlib\drivetype.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\findlib\enable_priv.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\findlib\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="..\..\findlib\find_one.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\findlib\fstype.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\findlib\makepath.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\findlib\match.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               CompileAs="2"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\findlib\save-cwd.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"
+                       >
+                       <File
+                               RelativePath="..\..\findlib\bfile.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\findlib\find.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\findlib\protos.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\findlib\save-cwd.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"
+                       >
+               </Filter>
+               <File
+                       RelativePath=".\ReadMe.txt"
+                       >
+               </File>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/bacula/src/win32/libwin32/bacula.bmp b/bacula/src/win32/libwin32/bacula.bmp
new file mode 100644 (file)
index 0000000..a31eb16
Binary files /dev/null and b/bacula/src/win32/libwin32/bacula.bmp differ
diff --git a/bacula/src/win32/libwin32/bacula.ico b/bacula/src/win32/libwin32/bacula.ico
new file mode 100644 (file)
index 0000000..f6d50bf
Binary files /dev/null and b/bacula/src/win32/libwin32/bacula.ico differ
diff --git a/bacula/src/win32/libwin32/bacula.rc b/bacula/src/win32/libwin32/bacula.rc
new file mode 100644 (file)
index 0000000..5849beb
--- /dev/null
@@ -0,0 +1 @@
+1 ICON  "apcupsd.ico"
diff --git a/bacula/src/win32/libwin32/error.ico b/bacula/src/win32/libwin32/error.ico
new file mode 100644 (file)
index 0000000..a8f85f1
Binary files /dev/null and b/bacula/src/win32/libwin32/error.ico differ
diff --git a/bacula/src/win32/libwin32/idle.ico b/bacula/src/win32/libwin32/idle.ico
new file mode 100644 (file)
index 0000000..ce5315f
Binary files /dev/null and b/bacula/src/win32/libwin32/idle.ico differ
diff --git a/bacula/src/win32/libwin32/libwin32.vcproj b/bacula/src/win32/libwin32/libwin32.vcproj
new file mode 100644 (file)
index 0000000..5382b70
--- /dev/null
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="libwin32"
+       ProjectGUID="{79C9F7C0-1DFE-4526-9F4F-1608E4549D24}"
+       RootNamespace="libwin32"
+       Keyword="Win32Proj"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="4"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="../compat;../..;&quot;../../../../depkgs-win32/pthreads&quot;"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_LIB;HAVE_WIN32;WIN32_VSS;_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="VCLibrarianTool"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="4"
+                       UseOfATL="1"
+                       CharacterSet="2"
+                       WholeProgramOptimization="0"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="../compat;../..;&quot;../../../../depkgs-win32/pthreads&quot;"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_LIB;HAVE_WIN32;WIN32_VSS;_USE_32BIT_TIME_T;_WIN32_WINNT=0x0500;_CRT_SECURE_NO_DEPRECATE"
+                               RuntimeLibrary="2"
+                               EnableFunctionLevelLinking="true"
+                               UsePrecompiledHeader="0"
+                               BrowseInformation="1"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="false"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLibrarianTool"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       >
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       >
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+                       >
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/bacula/src/win32/libwin32/popup.c b/bacula/src/win32/libwin32/popup.c
new file mode 100644 (file)
index 0000000..e3e3420
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Dumb Windows program to put up a message box
+ * containing the command line.  Any leading and
+ * trailing quotes are stripped.
+ *
+ *  Kern E. Sibbald
+ *   July MM
+ */
+#include "windows.h"
+
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
+                  PSTR szCmdLine, int iCmdShow)
+{
+   int len = strlen(szCmdLine);
+   char *msg, *wordPtr;
+
+   // Funny things happen with the command line if the
+   // execution comes from c:/Program Files/apcupsd/apcupsd.exe
+   // We get a command line like: Files/apcupsd/apcupsd.exe" options
+   // I.e. someone stops scanning command line on a space, not
+   // realizing that the filename is quoted!!!!!!!!!!
+   // So if first character is not a double quote and
+   // the last character before first space is a double
+   // quote, we throw away the junk.
+   wordPtr = szCmdLine;
+   while (*wordPtr && *wordPtr != ' ')
+      wordPtr++;
+   if (wordPtr > szCmdLine)     // backup to char before space
+      wordPtr--;
+   // if first character is not a quote and last is, junk it
+   if (*szCmdLine != '"' && *wordPtr == '"') {
+      wordPtr++;
+      while (*wordPtr && *wordPtr == ' ')
+        wordPtr++;              /* strip leading spaces */
+      szCmdLine = wordPtr;
+      len = strlen(szCmdLine);
+   }
+
+   msg = szCmdLine;
+   if (*szCmdLine == '"' && len > 0 && szCmdLine[len-1] == '"') {
+      msg = szCmdLine + 1;
+      szCmdLine[len-1] = 0;
+   }
+   MessageBox(NULL, msg, "Apcupsd message", MB_OK);
+   return 0;
+}
diff --git a/bacula/src/win32/libwin32/running.ico b/bacula/src/win32/libwin32/running.ico
new file mode 100644 (file)
index 0000000..32dc42c
Binary files /dev/null and b/bacula/src/win32/libwin32/running.ico differ
diff --git a/bacula/src/win32/libwin32/saving.ico b/bacula/src/win32/libwin32/saving.ico
new file mode 100644 (file)
index 0000000..f6d50bf
Binary files /dev/null and b/bacula/src/win32/libwin32/saving.ico differ
diff --git a/bacula/src/win32/libwin32/warn.ico b/bacula/src/win32/libwin32/warn.ico
new file mode 100644 (file)
index 0000000..26e1d39
Binary files /dev/null and b/bacula/src/win32/libwin32/warn.ico differ
diff --git a/bacula/src/win32/libwin32/winabout.cpp b/bacula/src/win32/libwin32/winabout.cpp
new file mode 100644 (file)
index 0000000..5fbccae
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+   Copyright (C) 2000-2004 Kern Sibbald and John Walker
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of
+   the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public
+   License along with this program; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   This file is patterned after the VNC Win32 code by ATT
+  
+   Kern E. Sibbald, 2000
+*/
+
+#include "bacula.h"
+#include "winbacula.h"
+#include "winabout.h"
+#include "winres.h"
+
+bacAbout::bacAbout()
+{
+   visible = false;
+}
+
+bacAbout::~bacAbout() { };
+
+void bacAbout::Show(BOOL show)
+{
+   if (show && !visible) {
+      DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_ABOUT), NULL,
+         (DLGPROC)DialogProc, (LONG)this);
+   }
+}
+
+
+BOOL CALLBACK
+bacAbout::DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
+{
+   /* Get the dialog class pointer from USERDATA */
+   bacAbout *_this;
+
+   switch (uMsg) {
+   case WM_INITDIALOG:
+      /* save the dialog class pointer */
+      SetWindowLong(hwnd, GWL_USERDATA, lParam);
+      _this = (bacAbout *)lParam;
+
+      /* Show the dialog */
+      SetForegroundWindow(hwnd);
+      _this->visible = true;
+      return TRUE;
+
+   case WM_COMMAND:
+      switch (LOWORD(wParam)) {
+      case IDCANCEL:
+      case IDOK:
+         EndDialog(hwnd, TRUE);
+         _this = (bacAbout *)GetWindowLong(hwnd, GWL_USERDATA);
+         _this->visible = false;
+         return TRUE;
+      }
+      break;
+
+   case WM_DESTROY:
+      EndDialog(hwnd, FALSE);
+      _this = (bacAbout *)GetWindowLong(hwnd, GWL_USERDATA);
+      _this->visible = false;
+      return TRUE;
+   }
+   return 0;
+}
diff --git a/bacula/src/win32/libwin32/winabout.h b/bacula/src/win32/libwin32/winabout.h
new file mode 100644 (file)
index 0000000..46a6e94
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+   Copyright (C) 2000-2004 Kern Sibbald and John Walker
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of
+   the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public
+   License along with this program; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   This file was inspired by the VNC Win32 code by ATT
+
+   Kern E. Sibbald, 2000
+*/
+
+
+/* Object implementing the About dialog for Bacula */
+
+class bacAbout;
+
+#ifndef _WINABOUT_H_
+#define _WINABOUT_H_ 1
+
+/* Define the bacAbout class */
+class bacAbout
+{
+public:
+   bacAbout();
+  ~bacAbout();
+
+   /* The dialog box window proc */
+   static BOOL CALLBACK DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+   void Show(BOOL show);
+
+   /* Object local storage */
+   bool visible;
+};
+
+#endif
diff --git a/bacula/src/win32/libwin32/winbacula.h b/bacula/src/win32/libwin32/winbacula.h
new file mode 100644 (file)
index 0000000..0bf1243
--- /dev/null
@@ -0,0 +1,73 @@
+//  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
+//
+//  This file was part of the VNC system.
+//
+//  The VNC system is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+//  USA.
+//
+// If the source code for the VNC system is not available from the place
+// whence you received this file, check http://www.uk.research.att.com/vnc or contact
+// the authors on vnc@uk.research.att.com for information on obtaining it.
+//
+// This file has been adapted to the Win32 version of Bacula
+// by Kern E. Sibbald.  Many thanks to ATT and James Weatherall,
+// the original author, for providing an excellent template.
+//
+// Copyright (2000) Kern E. Sibbald
+//
+
+
+// WinUPS header file
+
+// Application specific messages
+
+// Message used for system tray notifications
+#define WM_TRAYNOTIFY                           WM_USER+1
+
+// Messages used for the server object to notify windows of things
+#define WM_SRV_CLIENT_CONNECT           WM_USER+2
+#define WM_SRV_CLIENT_AUTHENTICATED     WM_USER+3
+#define WM_SRV_CLIENT_DISCONNECT        WM_USER+4
+
+// Export the application details
+extern HINSTANCE        hAppInstance;
+extern const char       *szAppName;
+extern DWORD            mainthreadId;
+
+// Main Bacula server routine
+extern int BaculaAppMain();
+
+extern void LogErrorMsg(char *msg);
+
+// Standard command-line flag definitions
+const char BaculaRunService[]            = "/service";
+const char BaculaRunServiceHelper[]      = "/servicehelper";
+const char BaculaRunAsUserApp[]          = "/run";
+
+const char BaculaInstallService[]        = "/install";
+const char BaculaRemoveService[]         = "/remove";
+
+const char BaculaShowAbout[]             = "/about";
+const char BaculaShowStatus[]            = "/status";
+const char BaculaShowEvents[]            = "/events";
+const char BaculaKillRunningCopy[]       = "/kill";
+
+const char BaculaShowHelp[]              = "/help";
+
+// Usage string
+const char BaculaUsageText[] = "Bacula [/run] [/kill] [/install] [/remove] [/about] [/status] [/events]\n";
+
+void LogErrorMsg(char *msg, char *fname, int lineno);
+#define log_error_message(msg) LogErrorMsg((msg), __FILE__, __LINE__)
diff --git a/bacula/src/win32/libwin32/winevents.cpp b/bacula/src/win32/libwin32/winevents.cpp
new file mode 100644 (file)
index 0000000..50edd0a
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+   Copyright (C) 2000-2003 Kern Sibbald and John Walker
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of
+   the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public
+   License along with this program; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   This file is patterned after the VNC Win32 code by ATT
+  
+   Copyright (2000) Kern E. Sibbald
+*/
+
+
+/* Code for the Events dialogue */
+
+#include "bacula.h"
+#include "winbacula.h"
+#include "winevents.h"
+#include "winres.h"
+
+extern "C" void FillEventsBox(HWND hwnd, int id_list);
+
+bacEvents::bacEvents()
+{
+   visible = FALSE;
+}
+
+bacEvents::~bacEvents()
+{
+}
+
+/* Show the dialogue box */
+void
+bacEvents::Show(BOOL show)
+{
+   if (show && !visible) {
+      DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_EVENTS), NULL,
+         (DLGPROC)DialogProc, (LONG)this);
+   }
+}
+
+
+BOOL CALLBACK
+bacEvents::DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+   /* The dialog-box this pointer is in USERDATA */
+   bacEvents *_this = (bacEvents *)GetWindowLong(hwnd, GWL_USERDATA);
+
+   switch (uMsg) {
+   case WM_INITDIALOG:
+      /* Retrieve the Dialog box parameter */
+      SetWindowLong(hwnd, GWL_USERDATA, lParam);
+      _this = (bacEvents *)lParam;
+
+      /* Show the dialog */
+      SetForegroundWindow(hwnd);
+      _this->visible = TRUE;
+      return TRUE;
+
+   case WM_COMMAND:
+      switch (LOWORD(wParam)) {
+      case IDCANCEL:
+      case IDOK:
+         EndDialog(hwnd, TRUE);
+         _this->visible = FALSE;
+         return TRUE;
+      }
+      break;
+
+   case WM_DESTROY:
+      EndDialog(hwnd, FALSE);
+      _this->visible = FALSE;
+      return TRUE;
+   }
+   return 0;
+}
diff --git a/bacula/src/win32/libwin32/winevents.h b/bacula/src/win32/libwin32/winevents.h
new file mode 100644 (file)
index 0000000..a28d66e
--- /dev/null
@@ -0,0 +1,44 @@
+/* Object implementing the Events dialog for Bacula */
+/*
+   Copyright (C) 2000-2003 Kern Sibbald and John Walker
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of
+   the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public
+   License along with this program; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+ */
+
+
+class bacEvents;
+
+#ifndef _win_bacEVENTS
+#define _win_bacEVENTS 1
+
+/* Define the bacEvents class */
+class bacEvents
+{
+public:
+   bacEvents();
+   ~bacEvents();
+
+   /* The dialog box window proc */
+   static BOOL CALLBACK DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+   void Show(BOOL show);
+
+   /* Object local storage */
+   BOOL visible;
+};
+
+#endif
diff --git a/bacula/src/win32/libwin32/winres.h b/bacula/src/win32/libwin32/winres.h
new file mode 100644 (file)
index 0000000..66a84c1
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Included by bacula.rc
+ */
+
+/* Icon definitions */
+#define IDI_BACULA                      100
+#define IDI_IDLE                        101
+#define IDI_RUNNING                     102
+#define IDI_JOB_ERROR                   103
+#define IDI_JOB_WARNING                 104
+#define IDR_TRAYMENU                    105
+#define IDB_BACULABMP                   106
+
+#define IDC_LIST                        1000
+#define IDC_NONYET_LABEL                1006
+#define IDC_UPDATE_BORDER               1010
+#define IDC_APCUPSDBMP                  1016
+#define IDC_VERSION                     1017
+#define IDC_NAME                        1018
+#define IDC_EMAIL                       1019
+#define IDC_WWW                         1022
+#define IDC_COPYRIGHT                   1023
+#define IDACCEPT                        1030
+#define IDREJECT                        1031
+#define IDC_STATIC_TEXT1                1032
+#define IDC_ACCEPT_IP                   1033
+#define IDC_STATIC_TEXT                 1034
+#define IDC_ACCEPT_TIMEOUT              1035
+#define IDC_TRADEMARK                   1036
+
+
+#define ID_PROPERTIES                   40001
+#define ID_CLOSE                        40002
+#define ID_KILLCLIENTS                  40003
+#define ID_ABOUT                        40004
+#define ID_STATUS                       40005
+#define ID_DEFAULT_PROPERTIES           40006
+#define ID_EVENTS                       40007
+
+/* Dialog definitions */
+#define IDD_PROPERTIES                  200
+#define IDD_ABOUT                       201
+#define IDD_STATUS                      202
+#define IDD_EVENTS                      203
+
+
diff --git a/bacula/src/win32/libwin32/winres.rc b/bacula/src/win32/libwin32/winres.rc
new file mode 100644 (file)
index 0000000..8e6dbb7
--- /dev/null
@@ -0,0 +1,181 @@
+#include <winuser.h>
+#include <winver.h>
+#include "winres.h"
+#include "../../version.h"
+
+/* NB: Internationalization of this file will require some work... */
+#define N_(s) s
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icons
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_BACULA              ICON    DISCARDABLE     "bacula.ico"
+IDI_IDLE                ICON    DISCARDABLE     "idle.ico"
+IDI_RUNNING             ICON    DISCARDABLE     "running.ico"
+IDI_JOB_ERROR           ICON    DISCARDABLE     "error.ico"
+IDI_JOB_WARNING         ICON    DISCARDABLE     "warn.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_TRAYMENU MENU DISCARDABLE
+BEGIN
+    POPUP "tray"
+    BEGIN
+        MENUITEM N_("&Status"),                     ID_STATUS
+        MENUITEM N_("&Events"),                     ID_EVENTS
+#ifdef properties_implemented
+        MENUITEM N_("&Properties"),                 ID_PROPERTIES
+#endif
+        MENUITEM SEPARATOR
+        MENUITEM N_("&About Bacula"),               ID_ABOUT
+        MENUITEM SEPARATOR
+        MENUITEM N_("&Close Bacula"),               ID_CLOSE
+    END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,1,0,0
+ PRODUCTVERSION 1,1,0,0
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0 //
+#endif
+ FILEOS VOS_NT_WINDOWS32
+ FILETYPE VFT_APP
+ FILESUBTYPE 0
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904E0" // Lang=US English, CharSet=Windows Multiligual
+        BEGIN
+            VALUE "Comments", "by Kern Sibbald\0"
+            VALUE "CompanyName", "            \0"
+            VALUE "FileDescription", "Bacula File daemon for Win32\0"
+            VALUE "FileVersion", VERSION "\0"
+            VALUE "InternalName", "Bacula\0"
+            VALUE "LegalCopyright", "Copyright Kern Sibbald, 1999-2006\0"
+            VALUE "LegalTrademarks", "Licensed under GNU GPL 2.0\0"
+            VALUE "OriginalFilename", "filed.exe\0"
+            VALUE "PrivateBuild", "\0"
+            VALUE "ProductName", "Bacula - Win32 Version\0"
+            VALUE "ProductVersion", VERSION
+            VALUE "SpecialBuild", "\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1252 // US English, Multilingual
+    END
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_BACULABMP           BITMAP  DISCARDABLE     "bacula.bmp"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+    IDI_BACULA              "Bacula"
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Properties Dialog
+//
+#ifdef properties_implemented
+
+IDD_PROPERTIES DIALOG DISCARDABLE  0, 0, 221, 204
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP |
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Bacula Properties"
+FONT 8, "MS Sans Serif"
+BEGIN
+    PUSHBUTTON      N_("&Cancel"),IDCANCEL,165,25,51,15
+    DEFPUSHBUTTON   N_("&OK"),IDOK,165,5,51,15
+    LTEXT           "No Properites yet",IDC_NONYET_LABEL,19,30,56,15,
+                    SS_CENTERIMAGE
+END
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// About Dialog
+//
+
+IDD_ABOUT DIALOG DISCARDABLE  0, 0, 250, 145
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "About Bacula"
+FONT 8, "MS Sans Serif"
+BEGIN
+    DEFPUSHBUTTON   "OK",IDOK,190,120,50,15
+//  CONTROL         "\3", IDC_BACULABMP,"Static",SS_ICON | SS_CENTERIMAGE |
+//                  SS_SUNKEN,7,5,73,65
+#ifndef HAVE_MINGW
+    CONTROL         IDB_BACULABMP,IDB_BACULABMP,"Static",SS_BITMAP|SS_SUNKEN,7,5,32,32
+#endif
+
+    LTEXT           N_("      by Kern Sibbald"),IDC_NAME,134,38,78,10
+    LTEXT           N_("For more information, see:"),-1,115,60,100,10
+    LTEXT           "         www.bacula.org",IDC_WWW,115,70,100,10
+//    LTEXT           "                 ",-1,69,81,100,10
+//    LTEXT           "                 ",-1,90,70,100,10
+    LTEXT           "Copyright (C) 1999-2006, Kern Sibbald",IDC_COPYRIGHT,7,120,175,10
+    LTEXT           N_("Licensed under GNU GPL 2.0."),IDC_TRADEMARK,7,130,175,10
+    RTEXT           N_("Build Date:"),-1,108,24,42,8
+    RTEXT           N_("Bacula Version:"),-1,100,9,50,8
+    LTEXT           VERSION,IDC_VERSION,159,10,65,8
+    LTEXT           BDATE,-1,159,24,65,10
+
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Status Dialog
+//
+
+IDD_STATUS DIALOG DISCARDABLE  0, 0, 411, 244
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP |
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION N_("Bacula Status")
+FONT 8, "Courier New"
+BEGIN
+    DEFPUSHBUTTON   "&OK",IDOK,355,5,51,15
+    LISTBOX         IDC_LIST, 2, 2, 350, 240, WS_VSCROLL | WS_HSCROLL | WS_BORDER
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Events Dialog
+//
+
+IDD_EVENTS DIALOG DISCARDABLE  0, 0, 411, 204
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP |
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION N_("Bacula Events")
+FONT 8, "Courier New"
+BEGIN
+    DEFPUSHBUTTON   "&OK",IDOK,355,5,51,15
+    LISTBOX         IDC_LIST, 2, 2, 350, 200, WS_VSCROLL | WS_HSCROLL | WS_BORDER
+END
diff --git a/bacula/src/win32/libwin32/winservice.h b/bacula/src/win32/libwin32/winservice.h
new file mode 100644 (file)
index 0000000..157dea3
--- /dev/null
@@ -0,0 +1,125 @@
+//  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
+//
+//  This file was part of the ups system.
+//
+//  The ups system is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+//  USA.
+//
+// If the source code for the ups system is not available from the place
+// whence you received this file, check http://www.uk.research.att.com/vnc or contact
+// the authors on ups@uk.research.att.com for information on obtaining it.
+//
+// This file has been adapted to the Win32 version of Bacula
+// by Kern E. Sibbald.  Many thanks to ATT and James Weatherall,
+// the original author, for providing an excellent template.
+//
+// Copyright (C) 2000-2006 Kern E. Sibbald
+//
+
+
+// winservice.cpp
+
+// SERVICE-MODE CODE
+
+// This class provides access to service-oriented routines, under both
+// Windows NT and Windows 95.  Some routines only operate under one
+// OS, others operate under any OS.
+
+class bacService;
+
+#if (!defined(_win_bacService))
+#define _win_bacService
+
+// The NT-specific code wrapper class
+class bacService
+{
+public:
+        bacService();
+
+   // SERVICE INSTALL & START FUNCTIONS
+
+   // Routine called by WinMain to cause Bacula to be installed
+   // as a service.
+   static int BaculaServiceMain();
+
+   // Routine to install the Apcupsd service on the local machine
+   static int InstallService();
+
+   // Routine to remove the Apcupsd service from the local machine
+   static int RemoveService();
+
+   // SERVICE SUPPORT FUNCTIONS
+
+   // Routine to establish and return the currently logged in user name
+   static BOOL CurrentUser(char *buffer, UINT size);
+
+   // Routine to post a message to the currently running Apcupsd server
+   // to pass it a handle to the current user
+   static BOOL PostUserHelperMessage();
+   // Routine to process a user helper message
+   static BOOL ProcessUserHelperMessage(WPARAM wParam, LPARAM lParam);
+
+   // Routines to establish which OS we're running on
+   static BOOL IsWin95();
+   static BOOL IsWinNT();
+
+   // Routine to establish whether the current instance is running
+   // as a service or not
+   static BOOL RunningAsService();
+
+   // Routine to kill any other running copy of Apcupsd
+   static BOOL KillRunningCopy();
+
+   // Routine to set the current thread into the given desktop
+   static BOOL SelectHDESK(HDESK newdesktop);
+
+   // Routine to set the current thread into the named desktop,
+   // or the input desktop if no name is given
+   static BOOL SelectDesktop(char *name);
+
+   // Routine to establish whether the current thread desktop is the
+   // current user input one
+   static BOOL InputDesktopSelected();
+
+   // Routine to fake a CtrlAltDel to winlogon when required.
+   // *** This is a nasty little hack...
+   static BOOL SimulateCtrlAltDel();
+
+   // Routine to make any currently running version of Apcupsd show its
+   // Properties dialog, to allow the user to make changes to their settings
+   static BOOL ShowProperties();
+
+   // Routine to make any currently running version of Apcupsd show the
+   // Properties dialog for the default settings, so the user can make changes
+   static BOOL ShowDefaultProperties();
+
+   // Routine to make the an already running copy of Apcupsd bring up its
+   // About box so you can check the version!
+   static BOOL ShowAboutBox();
+
+   // Routine to make the an already running copy of Apcupsd bring up its
+   // Status dialog
+   static BOOL ShowStatus();
+
+   // Routine to make the an already running copy of Apcupsd bring up its
+   // Events dialog
+   static BOOL ShowEvents();
+
+   // Routine to make an already running copy of Apcupsd form an outgoing
+   // connection to a new ups client
+   static BOOL PostAddNewClient(unsigned long ipaddress);
+};
+
+#endif
diff --git a/bacula/src/win32/libwin32/winstat.cpp b/bacula/src/win32/libwin32/winstat.cpp
new file mode 100644 (file)
index 0000000..45e3c41
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Bacula File daemon Status Dialog box
+ *
+ *  Inspired from the VNC code by ATT.
+ *
+ * Copyright (2000) Kern E. Sibbald
+ *
+ */
+/*
+   Copyright (C) 2000-2003 Kern Sibbald and John Walker
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2
+   of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include "bacula.h"
+#include "winbacula.h"
+#include "winstat.h"
+#include "winres.h"
+
+extern void FillStatusBox(HWND hwnd, int id_list);
+
+bacStatus::bacStatus()
+{
+   visible = FALSE;
+}
+
+bacStatus::~bacStatus()
+{
+}
+
+
+/* Dialog box handling functions */
+void
+bacStatus::Show(BOOL show)
+{
+   if (show && !visible) {
+      DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_STATUS), NULL,
+          (DLGPROC)DialogProc, (LONG)this);
+   }
+}
+
+BOOL CALLBACK
+bacStatus::DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+   /* Get class pointer from user data */
+   bacStatus *_this = (bacStatus *)GetWindowLong(hwnd, GWL_USERDATA);
+
+   switch (uMsg) {
+   case WM_INITDIALOG:
+      /* Set class pointer in user data */
+      SetWindowLong(hwnd, GWL_USERDATA, lParam);
+      _this = (bacStatus *)lParam;
+
+      /* show the dialog */
+      SetForegroundWindow(hwnd);
+
+      /* Update every 5 seconds */
+      SetTimer(hwnd, 1, 5000, NULL); 
+      _this->visible = TRUE;
+      FillStatusBox(hwnd, IDC_LIST);
+      return TRUE;
+
+   case WM_TIMER:
+      FillStatusBox(hwnd, IDC_LIST);
+      return TRUE;
+
+   case WM_COMMAND:
+      switch (LOWORD(wParam)) {
+      case IDCANCEL:
+      case IDOK:
+         KillTimer(hwnd, 1);
+         EndDialog(hwnd, TRUE);
+         _this->visible = FALSE;
+         return TRUE;
+      }
+      break;
+
+   case WM_DESTROY:
+      KillTimer(hwnd, 1);
+      EndDialog(hwnd, FALSE);
+      _this->visible = FALSE;
+      return TRUE;
+   }
+   return 0;
+}
diff --git a/bacula/src/win32/libwin32/winstat.h b/bacula/src/win32/libwin32/winstat.h
new file mode 100644 (file)
index 0000000..3486a00
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Bacula Status Dialog header file
+ *
+ */
+/*
+   Copyright (C) 2000-2003 Kern Sibbald and John Walker
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of
+   the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public
+   License along with this program; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+ */
+
+
+class bacStatus;
+
+#ifndef _WINSTAT_H_
+#define _WINSTAT_H_
+
+class bacStatus
+{
+public:
+   bacStatus();
+   ~bacStatus();
+
+   /* The Windows callback routine */
+   static BOOL CALLBACK DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+   void Show(BOOL show);
+
+   BOOL visible;
+};
+
+#endif
diff --git a/bacula/src/win32/libwin32/wintray.cpp b/bacula/src/win32/libwin32/wintray.cpp
new file mode 100644 (file)
index 0000000..ee866f4
--- /dev/null
@@ -0,0 +1,353 @@
+//  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
+//
+//  This file was part of the vnc system.
+//
+//  The vnc system is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+//  USA.
+//
+// If the source code for the vnc system is not available from the place 
+// whence you received this file, check http://www.uk.research.att.com/vnc or contact
+// the authors on vnc@uk.research.att.com for information on obtaining it.
+//
+// This file has been adapted to the Win32 version of Bacula
+// by Kern E. Sibbald.  Many thanks to ATT and James Weatherall,
+// the original author, for providing an excellent template.
+//
+// Copyright 2000-2004, Kern E. Sibbald
+//
+
+
+
+// Tray
+
+// Implementation of a system tray icon & menu for Bacula
+
+#include "bacula.h"
+#include "jcr.h"
+#include "winbacula.h"
+#include "winservice.h"
+#include "winres.h"
+#include "wintray.h"
+
+// Constants
+#ifdef properties_implemented
+const UINT MENU_PROPERTIES_SHOW = RegisterWindowMessage("Bacula.Properties.User.Show");
+const UINT MENU_DEFAULT_PROPERTIES_SHOW = RegisterWindowMessage("Bacula.Properties.Default.Show");
+#endif
+const UINT MENU_ABOUTBOX_SHOW = RegisterWindowMessage("Bacula.AboutBox.Show");
+const UINT MENU_STATUS_SHOW = RegisterWindowMessage("Bacula.Status.Show");
+const UINT MENU_EVENTS_SHOW = RegisterWindowMessage("Bacula.Events.Show");
+const UINT MENU_SERVICEHELPER_MSG = RegisterWindowMessage("Bacula.ServiceHelper.Message");
+const UINT MENU_ADD_CLIENT_MSG = RegisterWindowMessage("Bacula.AddClient.Message");
+const char *MENU_CLASS_NAME = "BaculaFD Tray Icon";
+
+extern void terminate_filed(int sig);
+extern char *bac_status(char *buf, int buf_len);
+extern int bacstat;
+
+// Implementation
+
+bacMenu::bacMenu()
+{
+   // Create a dummy window to handle tray icon messages
+   WNDCLASSEX wndclass;
+
+   wndclass.cbSize                 = sizeof(wndclass);
+   wndclass.style                  = 0;
+   wndclass.lpfnWndProc    = bacMenu::WndProc;
+   wndclass.cbClsExtra             = 0;
+   wndclass.cbWndExtra             = 0;
+   wndclass.hInstance              = hAppInstance;
+   wndclass.hIcon                  = LoadIcon(NULL, IDI_APPLICATION);
+   wndclass.hCursor                = LoadCursor(NULL, IDC_ARROW);
+   wndclass.hbrBackground  = (HBRUSH) GetStockObject(WHITE_BRUSH);
+   wndclass.lpszMenuName   = (const char *) NULL;
+   wndclass.lpszClassName  = MENU_CLASS_NAME;
+   wndclass.hIconSm                = LoadIcon(NULL, IDI_APPLICATION);
+
+   RegisterClassEx(&wndclass);
+
+   m_hwnd = CreateWindow(MENU_CLASS_NAME,
+                           MENU_CLASS_NAME,
+                           WS_OVERLAPPEDWINDOW,
+                           CW_USEDEFAULT,
+                           CW_USEDEFAULT,
+                           200, 200,
+                           NULL,
+                           NULL,
+                           hAppInstance,
+                           NULL);
+   if (m_hwnd == NULL) {
+      PostQuitMessage(0);
+      return;
+   }
+
+   // record which client created this window
+   SetWindowLong(m_hwnd, GWL_USERDATA, (LONG) this);
+
+   // Timer to trigger icon updating
+   SetTimer(m_hwnd, 1, 5000, NULL);
+
+   // Load the icons for the tray
+   m_idle_icon    = LoadIcon(hAppInstance, MAKEINTRESOURCE(IDI_IDLE));
+   m_running_icon = LoadIcon(hAppInstance, MAKEINTRESOURCE(IDI_RUNNING));
+   m_error_icon   = LoadIcon(hAppInstance, MAKEINTRESOURCE(IDI_JOB_ERROR));
+   m_warn_icon    = LoadIcon(hAppInstance, MAKEINTRESOURCE(IDI_JOB_WARNING));
+
+   // Load the popup menu
+   m_hmenu = LoadMenu(hAppInstance, MAKEINTRESOURCE(IDR_TRAYMENU));
+
+   // Install the tray icon!
+   AddTrayIcon();
+}
+
+bacMenu::~bacMenu()
+{
+   // Remove the tray icon
+   SendTrayMsg(NIM_DELETE, 0);
+        
+   // Destroy the loaded menu
+   if (m_hmenu != NULL)
+      DestroyMenu(m_hmenu);
+}
+
+void
+bacMenu::AddTrayIcon()
+{
+   SendTrayMsg(NIM_ADD, bacstat);
+}
+
+void
+bacMenu::DelTrayIcon()
+{
+   SendTrayMsg(NIM_DELETE, 0);
+}
+
+
+void
+bacMenu::UpdateTrayIcon(int bacstat)
+{
+   (void *)bac_status(NULL, 0);
+   SendTrayMsg(NIM_MODIFY, bacstat);
+}
+
+void
+bacMenu::SendTrayMsg(DWORD msg, int bacstat)
+{
+   struct s_last_job *job;
+   
+   // Create the tray icon message
+   m_nid.hWnd = m_hwnd;
+   m_nid.cbSize = sizeof(m_nid);
+   m_nid.uID = IDI_BACULA;                  // never changes after construction
+   switch (bacstat) {
+   case 0:
+      m_nid.hIcon = m_idle_icon;
+      break;
+   case JS_Running:
+      m_nid.hIcon = m_running_icon;
+      break;
+   case JS_ErrorTerminated:
+      m_nid.hIcon = m_error_icon;
+      break;
+   default:
+      if (last_jobs->size() > 0) {
+         job = (struct s_last_job *)last_jobs->last();
+         if (job->Errors) {
+            m_nid.hIcon = m_warn_icon;
+         } else {
+            m_nid.hIcon = m_idle_icon;
+         }
+      } else {
+         m_nid.hIcon = m_idle_icon;
+      }
+      break;
+   }
+
+   m_nid.uFlags = NIF_ICON | NIF_MESSAGE;
+   m_nid.uCallbackMessage = WM_TRAYNOTIFY;
+
+
+   // Use resource string as tip if there is one
+   if (LoadString(hAppInstance, IDI_BACULA, m_nid.szTip, sizeof(m_nid.szTip))) {
+       m_nid.uFlags |= NIF_TIP;
+   }
+
+   // Try to add the Bacula status to the tip string, if possible
+   if (m_nid.uFlags & NIF_TIP) {
+       bac_status(m_nid.szTip, sizeof(m_nid.szTip));
+   }
+
+   // Send the message
+   if (Shell_NotifyIcon(msg, &m_nid)) {
+      EnableMenuItem(m_hmenu, ID_CLOSE, MF_ENABLED);
+   } else {
+      if (!bacService::RunningAsService()) {
+         if (msg == NIM_ADD) {
+            // The tray icon couldn't be created, so use the Properties dialog
+            // as the main program window
+         // removed because it causes quit when not running as a
+         // service in use with BartPe.
+         // PostQuitMessage(0);
+         }
+      }
+   }
+}
+
+// Process window messages
+LRESULT CALLBACK bacMenu::WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
+{
+   // This is a static method, so we don't know which instantiation we're 
+   // dealing with. We use Allen Hadden's (ahadden@taratec.com) suggestion 
+   // from a newsgroup to get the pseudo-this.
+   bacMenu *_this = (bacMenu *) GetWindowLong(hwnd, GWL_USERDATA);
+
+   switch (iMsg) {
+
+   // Every five seconds, a timer message causes the icon to update
+   case WM_TIMER:
+      // *** HACK for running servicified
+      if (bacService::RunningAsService()) {
+          // Attempt to add the icon if it's not already there
+          _this->AddTrayIcon();
+      }
+
+      // Update the icon
+      _this->UpdateTrayIcon(bacstat);
+     break;
+
+   // STANDARD MESSAGE HANDLING
+   case WM_CREATE:
+      return 0;
+
+   case WM_COMMAND:
+      // User has clicked an item on the tray menu
+      switch (LOWORD(wParam)) {
+      case ID_STATUS:
+         // Show the status dialog
+         _this->m_status.Show(TRUE);
+         _this->UpdateTrayIcon(bacstat);
+         break;
+
+      case ID_EVENTS:
+         // Show the Events dialog
+         _this->m_events.Show(TRUE);
+         _this->UpdateTrayIcon(bacstat);
+         break;
+
+
+      case ID_KILLCLIENTS:
+         // Disconnect all currently connected clients
+         break;
+
+      case ID_ABOUT:
+         // Show the About box
+         _this->m_about.Show(TRUE);
+         break;
+
+      case ID_CLOSE:
+         // User selected Close from the tray menu
+         PostMessage(hwnd, WM_CLOSE, 0, 0);
+         break;
+
+      }
+      return 0;
+
+   case WM_TRAYNOTIFY:
+      // User has clicked on the tray icon or the menu
+      {
+         // Get the submenu to use as a pop-up menu
+         HMENU submenu = GetSubMenu(_this->m_hmenu, 0);
+
+         // What event are we responding to, RMB click?
+         if (lParam==WM_RBUTTONUP) {
+            if (submenu == NULL) {
+                    return 0;
+            }
+
+            // Make the first menu item the default (bold font)
+            SetMenuDefaultItem(submenu, 0, TRUE);
+            
+            // Get the current cursor position, to display the menu at
+            POINT mouse;
+            GetCursorPos(&mouse);
+
+            // There's a "bug"
+            // (Microsoft calls it a feature) in Windows 95 that requires calling
+            // SetForegroundWindow. To find out more, search for Q135788 in MSDN.
+            //
+            SetForegroundWindow(_this->m_nid.hWnd);
+
+            // Display the menu at the desired position
+            TrackPopupMenu(submenu,
+                            0, mouse.x, mouse.y, 0,
+                            _this->m_nid.hWnd, NULL);
+
+            return 0;
+         }
+         
+         // Or was there a LMB double click?
+         if (lParam==WM_LBUTTONDBLCLK) {
+             // double click: execute first menu item
+             SendMessage(_this->m_nid.hWnd,
+                         WM_COMMAND, 
+                         GetMenuItemID(submenu, 0),
+                         0);
+         }
+
+         return 0;
+      }
+
+   case WM_CLOSE:
+      terminate_filed(0);
+      break;
+
+   case WM_DESTROY:
+      // The user wants Bacula to quit cleanly...
+      PostQuitMessage(0);
+      return 0;
+
+   case WM_QUERYENDSESSION:
+      // Are we running as a system service?
+      // Or is the system shutting down (in which case we should check anyway!)
+      if ((!bacService::RunningAsService()) || (lParam == 0)) {
+         // No, so we are about to be killed
+
+         // If there are remote connections then we should verify
+         // that the user is happy about killing them.
+
+         // Finally, post a quit message, just in case
+         PostQuitMessage(0);
+         return TRUE;
+      }
+      return TRUE;
+
+   
+   default:
+      if (iMsg == MENU_ABOUTBOX_SHOW) {
+         // External request to show our About dialog
+         PostMessage(hwnd, WM_COMMAND, MAKELONG(ID_ABOUT, 0), 0);
+         return 0;
+      }
+      if (iMsg == MENU_STATUS_SHOW) {
+         // External request to show our status
+         PostMessage(hwnd, WM_COMMAND, MAKELONG(ID_STATUS, 0), 0);
+         return 0;
+      }
+   }
+
+   // Message not recognised
+   return DefWindowProc(hwnd, iMsg, wParam, lParam);
+}
diff --git a/bacula/src/win32/libwin32/wintray.h b/bacula/src/win32/libwin32/wintray.h
new file mode 100644 (file)
index 0000000..e2f7181
--- /dev/null
@@ -0,0 +1,93 @@
+//  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
+//
+//  This file was part of the VNC system.
+//
+//  The VNC system is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+//  USA.
+//
+// If the source code for the VNC system is not available from the place
+// whence you received this file, check http://www.uk.research.att.com/vnc or contact
+// the authors on vnc@uk.research.att.com for information on obtaining it.
+//
+// This file has been adapted to the Win32 version of Bacula
+// by Kern E. Sibbald.  Many thanks to ATT and James Weatherall,
+// the original author, for providing an excellent template.
+//
+// Copyright (2000) Kern E. Sibbald
+//
+
+
+
+// winMenu
+
+// This class handles creation of a system-tray icon & menu
+
+class bacMenu;
+
+#if (!defined(_win_bacMENU))
+#define _win_bacMENU
+
+#include "winabout.h"
+#include "winstat.h"
+#include "winevents.h"
+
+// Constants
+extern const UINT MENU_ABOUTBOX_SHOW;
+extern const UINT MENU_STATUS_SHOW;
+extern const UINT MENU_EVENTS_SHOW;
+extern const UINT MENU_SERVICEHELPER_MSG;
+extern const UINT MENU_ADD_CLIENT_MSG;
+extern const char *MENU_CLASS_NAME;
+
+// The tray menu class itself
+class bacMenu
+{
+public:
+   bacMenu();
+   ~bacMenu();
+protected:
+   // Tray icon handling
+   void AddTrayIcon();
+   void DelTrayIcon();
+   void UpdateTrayIcon(int battstat);
+   void SendTrayMsg(DWORD msg, int battstat);
+
+   // Message handler for the tray window
+   static LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
+
+   // Fields
+protected:
+
+   // About dialog for this server
+   bacAbout  m_about;
+
+   // Status dialog for this server
+   bacStatus m_status;
+
+   bacEvents m_events;
+
+   HWND  m_hwnd;
+   HMENU m_hmenu;
+   NOTIFYICONDATA m_nid;
+
+   // The icon handles
+   HICON m_idle_icon;
+   HICON m_running_icon;
+   HICON m_error_icon;
+   HICON m_warn_icon;
+};
+
+
+#endif
diff --git a/bacula/src/win32/scripts/mtx-changer.cmd.in b/bacula/src/win32/scripts/mtx-changer.cmd.in
new file mode 100644 (file)
index 0000000..323d733
--- /dev/null
@@ -0,0 +1,194 @@
+@echo off
+REM
+REM
+REM Bacula interface to mtx autoloader
+REM
+REM  $Id$
+REM
+REM  If you set in your Device resource
+REM
+REM  Changer Command = "path-to-this-script/mtx-changer %c %o %S %a %d"
+REM    you will have the following input to this script:
+REM
+REM  So Bacula will always call with all the following arguments, even though
+REM    in come cases, not all are used.
+REM
+REM  mtx-changer "changer-device" "command" "slot" "archive-device" "drive-index"
+REM               $1              $2       $3        $4               $5
+REM
+REM  for example:
+REM
+REM  mtx-changer /dev/sg0 load 1 /dev/nst0 0 (on a Linux system)
+REM 
+REM  will request to load the first cartidge into drive 0, where
+REM   the SCSI control channel is /dev/sg0, and the read/write device
+REM   is /dev/nst0.
+REM
+REM  If you need to an offline, refer to the drive as $4
+REM    e.g.   mt -f $4 offline
+REM
+REM  Many changers need an offline after the unload. Also many
+REM   changers need a sleep 60 after the mtx load.
+REM
+REM  N.B. If you change the script, take care to return either 
+REM   the mtx exit code or a 0. If the script exits with a non-zero
+REM   exit code, Bacula will assume the request failed.
+REM
+
+SET MTX=@MTX@
+SET MT=@MT@
+SET working_dir=@working_dir@
+
+SET dbgfile=%working_dir%\mtx.log
+
+REM to turn on logging, uncomment the following line
+REM findstr xxx <nul >>%working_dir%\mtx.log
+
+REM
+REM check parameter count on commandline
+REM
+REM Check for special cases where only 2 arguments are needed, 
+REM  all others are a minimum of 5
+REM
+IF "%1" EQU "" goto :param_count_invalid
+IF "%2" EQU "" goto :param_count_invalid
+IF "%2" EQU "list" goto :param_count_valid
+IF "%2" EQU "slots" goto :param_count_valid
+IF "%3" EQU "" goto :param_count_invalid
+IF "%4" EQU "" goto :param_count_invalid
+IF "%5" EQU "" goto :param_count_invalid
+GOTO :param_count_valid
+
+:param_count_invalid
+   echo Insufficient number of arguments given.
+   IF "%2" EQU "" (
+      echo   At least two arguments must be specified.
+   ) else echo   Command expected 5 arguments.
+:usage
+   ECHO.
+   ECHO usage: mtx-changer ctl-device command [slot archive-device drive-index]
+   ECHO        Valid commands are: unload, load, list, loaded, and slots.
+   EXIT /B 1
+
+:param_count_valid
+
+REM Setup arguments
+SET ctl=%1
+SET cmd=%2
+SET slot=%3
+SET device=%4
+SET drive=%5
+
+CALL :debug "Parms: %ctl% %cmd% %slot% %device% %drive%"
+
+IF "%cmd%" NEQ "unload" goto :cmdLoad
+   CALL :debug "Doing mtx -f %ctl% unload %slot% %drive%"
+   %MT% -f %device% offline
+   %MTX% -f %ctl% unload %slot% %drive%
+   EXIT /B %ERRORLEVEL%
+
+:cmdLoad
+IF "%cmd%" NEQ "load" goto :cmdList
+   CALL :debug "Doing mtx -f %ctl% load %slot% %drive%"
+   %MTX% -f %ctl% load %slot% %drive%
+   SET rtn=%ERRORLEVEL%
+   %MT% -f %device% load
+   CALL :wait_for_drive %device%
+   EXIT /B %rtn%
+
+:cmdList
+IF "%cmd%" NEQ "list" goto :cmdLoaded
+   CALL :debug "Doing mtx -f %ctl% -- to list volumes"
+   CALL :make_temp_file
+   IF ERRORLEVEL 1 GOTO :EOF
+REM Enable the following if you are using barcodes and need an inventory
+REM   %MTX% -f %ctl% inventory
+   %MTX% -f %ctl% status >%TMPFILE%
+   SET rtn=%ERRORLEVEL%
+   FOR /F "usebackq tokens=3,6 delims==: " %%i in ( `findstr /R /C:" *Storage Element [0-9]*:.*Full" %TMPFILE%` ) do echo %%i:%%j
+   FOR /F "usebackq tokens=7,10" %%i in ( `findstr /R /C:"^Data Transfer Element [0-9]*:Full (Storage Element [0-9]" %TMPFILE%` ) do echo %%i:%%j
+   DEL /F "%TMPFILE%" >nul 2>&1
+REM
+REM If you have a VXA PacketLoader and the above does not work, try
+REM  turning it off and enabling the following line.
+REM   %MTX% -f %ctl% status | grep " *Storage Element [0-9]*:.*Full" | sed "s/*Storage Element //" | sed "s/Full :VolumeTag=//"
+   EXIT /B %rtn%
+
+:cmdLoaded
+IF "%cmd%" NEQ "loaded" goto :cmdSlots
+   CALL :debug "Doing mtx -f %ctl% %drive% -- to find what is loaded"
+   CALL :make_temp_file
+   %MTX% -f %ctl% status >%TMPFILE%
+   SET rtn=%ERRORLEVEL%
+   FOR /F "usebackq tokens=7" %%i in ( `findstr /R /C:"^Data Transfer Element %drive%:Full" %TMPFILE%` ) do echo %%i
+   findstr /R /C:"^Data Transfer Element %drive%:Empty" %TMPFILE% >nul && echo 0
+   DEL /F "%TMPFILE%" >nul 2>&1
+   EXIT /B %rtn%
+
+:cmdSlots
+IF "%cmd%" NEQ "slots" goto :cmdUnknown
+   CALL :debug "Doing mtx -f %ctl% -- to get count of slots"
+   CALL :make_temp_file
+   %MTX% -f %ctl% status >%TMPFILE%
+   SET rtn=%ERRORLEVEL%
+   FOR /F "usebackq tokens=5" %%i in ( `findstr /R /C:" *Storage Changer" %TMPFILE%` ) do echo %%i
+   DEL /F "%TMPFILE%" >nul 2>&1
+   EXIT /B %rtn%
+
+:cmdUnknown
+   ECHO '%cmd%' is an invalid command.
+   GOTO :usage
+
+REM
+REM log whats done
+REM
+:debug
+   IF NOT EXIST "%dbgfile%" GOTO :EOF
+   FOR /F "usebackq tokens=2-4,5-7 delims=/:. " %%i in ( '%DATE% %TIME%' ) do SET TIMESTAMP=%%k%%i%%j-%%l:%%m:%%n
+   ECHO %TIMESTAMP% %*>> %dbgfile%
+   GOTO :EOF
+
+REM
+REM Create a temporary file
+REM
+:make_temp_file
+   REM SET TMPFILE=%working_dir%\mtx.tmp
+   SET TMPFILE=c:\bacula.test\working\mtx.tmp
+   IF EXIST "%TMPFILE%" (
+      ECHO Temp file security problem on: %TMPFILE%
+      EXIT /B 1
+   )
+   GOTO :EOF
+
+REM
+REM The purpose of this function to wait a maximum 
+REM   time for the drive. It will
+REM   return as soon as the drive is ready, or after
+REM   waiting a maximum of 300 seconds.
+REM Note, this is very system dependent, so if you are
+REM   not running on Linux, you will probably need to
+REM   re-write it, or at least change the grep target.
+REM
+:wait_for_drive
+   FOR /L %%i IN ( 1, 1, 300 ) DO (
+      %MT% -f %1 status | findstr ONLINE >NUL 2>&1
+      IF %ERRORLEVEL%==0 GOTO :EOF
+      CALL :debug "Device %1 - not ready, retrying..."
+      CALL :sleep 1
+   )
+   CALL :debug "Device %1 - not ready, timed out..."
+   GOTO :EOF
+
+:sleep
+   CALL :get_secs
+   SET start_time=%ERRORLEVEL%
+   SET /A end_time=100*%1+start_time
+:sleep_wait
+   CALL :get_secs
+   IF %ERRORLEVEL% LSS %start_time% GOTO :sleep
+   IF %ERRORLEVEL% LSS %end_time% GOTO :sleep_wait
+   GOTO :EOF
+
+:get_secs
+   FOR /F "tokens=3,4 delims=:. " %%i IN ( "%TIME%" ) do SET /A "secs= ( 1%%i %% 100 ) * 100 + ( 1%%j %% 100 )"
+   EXIT /B %secs%
diff --git a/bacula/src/win32/scripts/sleep.c b/bacula/src/win32/scripts/sleep.c
new file mode 100644 (file)
index 0000000..5e72de5
--- /dev/null
@@ -0,0 +1,23 @@
+#include <windows.h>
+#include <stdio.h>
+
+int
+main(int argc, const char ** argv)
+{
+   int   nsecs;
+
+   if (argc != 2)
+   {
+      fputs("usage: sleep <n>\n    n = number of seconds\n", stderr);
+      exit(1);
+   }
+
+   if (sscanf(argv[1], "%d", &nsecs) != 1)
+   {
+      fputs("sleep: incorrect argument, must be number of seconds to sleep\n", stderr);
+      exit(1);
+   }
+
+   Sleep(nsecs * 1000);
+   exit(0);
+}
diff --git a/bacula/src/win32/scripts/sleep.vcproj b/bacula/src/win32/scripts/sleep.vcproj
new file mode 100644 (file)
index 0000000..ee91d82
--- /dev/null
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="sleep"
+       ProjectGUID="{0F56AEB0-14DA-4A80-8962-1F85A17339D0}"
+       RootNamespace="sleep"
+       Keyword="Win32Proj"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="1"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="2"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="true"
+                               DebugInformationFormat="4"
+                               DisableSpecificWarnings="4996"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               LinkIncremental="2"
+                               GenerateDebugInformation="true"
+                               SubSystem="1"
+                               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="1"
+                       CharacterSet="2"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+                               RuntimeLibrary="0"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="true"
+                               DebugInformationFormat="3"
+                               DisableSpecificWarnings="4996"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="true"
+                               SubSystem="1"
+                               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=".\sleep.c"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+                       >
+               </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>
diff --git a/bacula/src/win32/stored/Makefile b/bacula/src/win32/stored/Makefile
new file mode 100644 (file)
index 0000000..a16e65f
--- /dev/null
@@ -0,0 +1,148 @@
+#
+# Makefile for win32 bacula executables
+# Using MinGW cross-compiler on GNU/Linux
+#
+#  Written by Robert Nelson, June 2006
+#
+
+# Configuration
+
+include ../Makefile.inc
+
+INCLUDES = \
+       -I../../stored \
+       $(INCLUDE_DDK) \
+       $(INCLUDE_PTHREADS) \
+       $(INCLUDE_BACULA) \
+       $(INCLUDE_ZLIB) \
+       $(INCLUDE_OPENSSL) \
+       $(INCLUDE_ICONS)
+
+DEFINES = \
+       -DUSING_DLL \
+       $(HAVES)
+
+VPATH = ../../stored baculasd
+
+##########################################################################
+
+COMMON_OBJS = \
+       $(OBJDIR)/acquire.o \
+       $(OBJDIR)/ansi_label.o \
+       $(OBJDIR)/autochanger.o \
+       $(OBJDIR)/block.o \
+       $(OBJDIR)/butil.o \
+       $(OBJDIR)/dev.o \
+       $(OBJDIR)/device.o \
+       $(OBJDIR)/dvd.o \
+       $(OBJDIR)/ebcdic.o \
+       $(OBJDIR)/label.o \
+       $(OBJDIR)/match_bsr.o \
+       $(OBJDIR)/mount.o \
+       $(OBJDIR)/parse_bsr.o \
+       $(OBJDIR)/read_record.o \
+       $(OBJDIR)/record.o \
+       $(OBJDIR)/reserve.o \
+       $(OBJDIR)/scan.o \
+       $(OBJDIR)/spool.o \
+       $(OBJDIR)/stored_conf.o \
+       $(OBJDIR)/wait.o \
+       $(OBJDIR)/mtops.o
+
+# bacula-sd
+SD_OBJS = \
+       $(OBJDIR)/stored.o \
+       $(OBJDIR)/append.o \
+       $(OBJDIR)/askdir.o \
+       $(OBJDIR)/authenticate.o \
+       $(OBJDIR)/dircmd.o \
+       $(OBJDIR)/fd_cmds.o \
+       $(OBJDIR)/job.o \
+       $(OBJDIR)/mac.o \
+       $(OBJDIR)/pythonsd.o \
+       $(OBJDIR)/read.o \
+       $(OBJDIR)/status.o
+
+# bextract
+BEXTRACT_OBJS = \
+       $(OBJDIR)/bextract.o \
+       $(OBJDIR)/pythonsd.o
+
+OBJS_WIN = \
+       $(OBJDIR)/winabout.o \
+       $(OBJDIR)/winevents.o \
+       $(OBJDIR)/winservice.o \
+       $(OBJDIR)/winstat.o \
+       $(OBJDIR)/wintray.o \
+       $(OBJDIR)/winmain.o \
+       $(OBJDIR)/winres.res
+
+ALL_OBJS = \
+       $(COMMON_OBJS) \
+       $(SD_OBJS) \
+       $(BEXTRACT_OBJS) \
+       $(OBJS_WIN) \
+       $(OBJDIR)/bcopy.o \
+       $(OBJDIR)/bls.o \
+       $(OBJDIR)/btape.o \
+       $(OBJDIR)/bscan.o
+
+LIBS_STORED = \
+       $(LIBS_PTHREADS) \
+       -lwsock32
+
+######################################################################
+
+# Targets
+
+.PHONY: all clean
+
+all:   $(BINDIR)/bacula-sd.exe $(BINDIR)/bcopy.exe $(BINDIR)/bextract.exe \
+       $(BINDIR)/bls.exe $(BINDIR)/bscan.exe $(BINDIR)/btape.exe
+
+clean:
+       @echo "Cleaning `pwd`"
+       $(call clean_obj,$(ALL_OBJS))
+       $(call clean_exe,$(BINDIR)/bacula-sd.exe)
+       $(call clean_exe,$(BINDIR)/bcopy.exe)
+       $(call clean_exe,$(BINDIR)/bextract.exe)
+       $(call clean_exe,$(BINDIR)/bls.exe)
+       $(call clean_exe,$(BINDIR)/bscan.exe)
+       $(call clean_exe,$(BINDIR)/btape.exe)
+
+realclean: clean
+       rm -f tags bacula-sd.conf
+
+#
+# Rules
+#
+
+$(BINDIR)/bacula-sd.exe: $(SD_OBJS) $(COMMON_OBJS) $(OBJS_WIN) $(LIBS_BACULA)
+       $(call link_winapp,$(LIBS_STORED))
+
+$(BINDIR)/btape.exe: $(OBJDIR)/btape.o $(COMMON_OBJS) $(LIBS_BACULA)
+       $(call link_conapp,$(LIBS_STORED))
+
+$(BINDIR)/bls.exe: $(OBJDIR)/bls.o $(COMMON_OBJS) $(LIBS_BACULA)
+       $(call link_conapp,$(LIBS_STORED))
+
+$(BINDIR)/bextract.exe: $(BEXTRACT_OBJS) $(COMMON_OBJS) $(LIBS_BACULA)
+       $(call link_conapp,$(LIBS_STORED) $(LIBS_ZLIB))
+
+$(BINDIR)/bscan.exe: $(OBJDIR)/bscan.o $(COMMON_OBJS) $(LIBS_BACULA)
+       $(call link_conapp,$(LIBS_STORED))
+
+$(BINDIR)/bcopy.exe: $(OBJDIR)/bcopy.o $(COMMON_OBJS) $(LIBS_BACULA)
+       $(call link_conapp,$(LIBS_STORED))
+
+$(OBJDIR)/mtops.o: mtops.cpp
+       @echo "Compiling $@"
+       $(call checkdir,$@)
+       $(ECHO_CMD)$(CXX) $(CFLAGS) $(INCLUDE_DDK) -I../../stored -c $< -o $@
+
+$(OBJDIR)/winres.res:    ../libwin32/winres.rc
+       @echo "Compiling $@"
+       $(call checkdir,$@)
+       $(ECHO_CMD)$(WINDRES) $(INCLUDE_ICONS) -O coff $< -o $@
+
+include ../Makefile.rules
diff --git a/bacula/src/win32/stored/mtops.cpp b/bacula/src/win32/stored/mtops.cpp
new file mode 100644 (file)
index 0000000..f9bf3f4
--- /dev/null
@@ -0,0 +1,1147 @@
+/*
+ * mtops.cpp - Emulate the Linux st (scsi tape) driver on Microsoft Windows.
+ *
+ * Author: Robert Nelson, May, 2006 <robertn@the-nelsons.org>
+ *
+ * Version $Id$
+ *
+ * Copyright (C) 2006 Kern Sibbald
+ *
+ * This file was contributed to the Bacula project by Robert Nelson.
+ *
+ * Robert Nelson has been granted a perpetual, worldwide,
+ * non-exclusive, no-charge, royalty-free, irrevocable copyright
+ * license to reproduce, prepare derivative works of, publicly
+ * display, publicly perform, sublicense, and distribute the original
+ * work contributed by Robert Nelson to the Bacula project in source 
+ * or object form.
+ *
+ * If you wish to license contributions from Robert Nelson
+ * under an alternate open source license please contact
+ * Robert Nelson <robertn@the-nelsons.org>.
+ */
+/*
+   Copyright (C) 2006 Kern Sibbald
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
+
+ */
+
+#include <stdarg.h>
+#include <stddef.h>
+
+#include "bacula.h"                   /* pull in global headers */
+#include "stored.h"                   /* pull in Storage Deamon headers */
+
+#include "sys/mtio.h"
+#include <ntddstor.h>
+#include <ntddscsi.h>
+
+//
+// SCSI bus status codes.
+//
+
+#define SCSISTAT_GOOD                  0x00
+#define SCSISTAT_CHECK_CONDITION       0x02
+#define SCSISTAT_CONDITION_MET         0x04
+#define SCSISTAT_BUSY                  0x08
+#define SCSISTAT_INTERMEDIATE          0x10
+#define SCSISTAT_INTERMEDIATE_COND_MET 0x14
+#define SCSISTAT_RESERVATION_CONFLICT  0x18
+#define SCSISTAT_COMMAND_TERMINATED    0x22
+#define SCSISTAT_QUEUE_FULL            0x28
+
+/* Forward referenced functions */
+
+extern char my_name[];
+extern int debug_level;
+
+inline   SHORT  Read16BitSigned(const unsigned char *pValue)
+{
+   return (SHORT)(((USHORT)pValue[0] << 8) | (USHORT)pValue[1]);
+}
+
+inline   USHORT  Read16BitUnsigned(const unsigned char *pValue)
+{
+   return (((USHORT)pValue[0] << 8) | (USHORT)pValue[1]);
+}
+
+inline   LONG  Read24BitSigned(const unsigned char *pValue)
+{
+   return ((LONG)(((ULONG)pValue[0] << 16) | ((ULONG)pValue[1] << 8) |
+                   (ULONG)pValue[2])) << 8 >> 8;
+}
+
+inline   ULONG  Read24BitUnsigned(const unsigned char *pValue)
+{
+   return ((ULONG)pValue[0] << 16) | ((ULONG)pValue[1] << 8) | (ULONG)pValue[2];
+}
+
+inline   LONG  Read32BitSigned(const unsigned char *pValue)
+{
+   return (LONG)(((ULONG)pValue[0] << 24) | ((ULONG)pValue[1] << 16) |
+                 ((ULONG)pValue[2] << 8) |   (ULONG)pValue[3]);
+}
+
+inline   ULONG  Read32BitUnsigned(const unsigned char *pValue)
+{
+   return (((ULONG)pValue[0] << 24) | ((ULONG)pValue[1] << 16) |
+           ((ULONG)pValue[2] << 8) | (ULONG)pValue[3]);
+}
+
+inline   LONGLONG  Read64BitSigned(const unsigned char *pValue)
+{
+   return (LONGLONG)(((ULONGLONG)pValue[0] << 56) | ((ULONGLONG)pValue[1] << 48) |
+                     ((ULONGLONG)pValue[2] << 40) | ((ULONGLONG)pValue[3] << 32) |
+                     ((ULONGLONG)pValue[4] << 24) | ((ULONGLONG)pValue[5] << 16) |
+                     ((ULONGLONG)pValue[6] <<  8) |  (ULONGLONG)pValue[7]);
+}
+
+inline   ULONGLONG  Read64BitUnsigned(const unsigned char *pValue)
+{
+   return (LONGLONG)(((ULONGLONG)pValue[0] << 56) | ((ULONGLONG)pValue[1] << 48) |
+                     ((ULONGLONG)pValue[2] << 40) | ((ULONGLONG)pValue[3] << 32) |
+                     ((ULONGLONG)pValue[4] << 24) | ((ULONGLONG)pValue[5] << 16) |
+                     ((ULONGLONG)pValue[6] <<  8) | (ULONGLONG)pValue[7]);
+}
+
+typedef  struct   _TAPE_POSITION_INFO
+{
+   UCHAR       AtPartitionStart:1;
+   UCHAR       AtPartitionEnd:1;
+   UCHAR       PartitionBlockValid:1;
+   UCHAR       FileSetValid:1;
+   UCHAR       :4;
+   UCHAR       Reserved1[3];
+   ULONG       Partition;
+   ULONGLONG   BlockNumber;
+   ULONGLONG   FileNumber;
+   ULONGLONG   SetNumber;
+}  TAPE_POSITION_INFO, *PTAPE_POSITION_INFO;
+
+typedef  struct   _TAPE_HANDLE_INFO
+{
+   HANDLE      OSHandle;
+   bool        bEOD;
+   bool        bEOF;
+   bool        bEOT;
+   bool        bBlockValid;
+   ULONG       FeaturesLow;
+   ULONG       FeaturesHigh;
+   ULONG       ulFile;
+   ULONGLONG   ullFileStart;
+
+}  TAPE_HANDLE_INFO, *PTAPE_HANDLE_INFO;
+
+TAPE_HANDLE_INFO TapeHandleTable[] =
+{
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE },
+   { INVALID_HANDLE_VALUE }
+};
+
+#define  NUMBER_HANDLE_ENTRIES      (sizeof(TapeHandleTable) / sizeof(TapeHandleTable[0]))
+
+DWORD GetTapePositionInfo(HANDLE hDevice, PTAPE_POSITION_INFO TapePositionInfo);
+DWORD GetDensityBlockSize(HANDLE hDevice, DWORD *pdwDensity, DWORD *pdwBlockSize);
+
+int tape_get(int fd, struct mtget *mt_get);
+int tape_op(int fd, struct mtop *mt_com);
+int tape_pos(int fd, struct mtpos *mt_pos);
+
+int
+tape_open(const char *file, int flags, int mode)
+{
+   HANDLE hDevice = INVALID_HANDLE_VALUE;
+   char szDeviceName[256] = "\\\\.\\";
+   int  idxFile;
+   DWORD dwResult;
+
+   for (idxFile = 0; idxFile < (int)NUMBER_HANDLE_ENTRIES; idxFile++) {
+      if (TapeHandleTable[idxFile].OSHandle == INVALID_HANDLE_VALUE) {
+         break;
+      }
+   }
+
+   if (idxFile >= (int)NUMBER_HANDLE_ENTRIES) {
+      return EMFILE;
+   }
+
+   memset(&TapeHandleTable[idxFile], 0, sizeof(TapeHandleTable[idxFile]));
+
+   if (file[0] != '\\' && file[0] != '/') {
+       bstrncpy(&szDeviceName[4], file, sizeof(szDeviceName) - 4);
+   } else {
+       bstrncpy(&szDeviceName[0], file, sizeof(szDeviceName));
+   }
+
+   hDevice = CreateFile(szDeviceName, FILE_ALL_ACCESS, 0, NULL, OPEN_EXISTING, 0, NULL);
+
+   if (hDevice != INVALID_HANDLE_VALUE) {
+      PTAPE_HANDLE_INFO    pHandleInfo = &TapeHandleTable[idxFile];
+
+      memset(pHandleInfo, 0, sizeof(*pHandleInfo));
+
+      pHandleInfo->OSHandle = hDevice;
+
+      TAPE_GET_DRIVE_PARAMETERS  TapeDriveParameters;
+      DWORD    dwSize = sizeof(TapeDriveParameters);
+
+      dwResult = GetTapeParameters(pHandleInfo->OSHandle, GET_TAPE_DRIVE_INFORMATION, &dwSize, &TapeDriveParameters);
+      if (dwResult == NO_ERROR) {
+         pHandleInfo->FeaturesLow = TapeDriveParameters.FeaturesLow;
+         pHandleInfo->FeaturesHigh = TapeDriveParameters.FeaturesHigh;
+      }
+
+      TAPE_POSITION_INFO TapePositionInfo;
+
+      dwResult =  GetTapePositionInfo(pHandleInfo->OSHandle, &TapePositionInfo);
+
+      if (dwResult == NO_ERROR) {
+         if (TapePositionInfo.AtPartitionStart || TapePositionInfo.AtPartitionEnd ||
+             (TapePositionInfo.PartitionBlockValid && TapePositionInfo.BlockNumber == 0)) {
+            pHandleInfo->ulFile = 0;
+            pHandleInfo->bBlockValid = true;
+            pHandleInfo->ullFileStart = 0;
+         } else if (TapePositionInfo.FileSetValid) {
+            pHandleInfo->ulFile = (ULONG)TapePositionInfo.FileNumber;
+         }
+      }
+   } else {
+      DWORD dwError = GetLastError();
+
+      switch (dwError) {
+      case ERROR_FILE_NOT_FOUND:
+      case ERROR_PATH_NOT_FOUND:
+         errno = ENOENT;
+         break;
+
+      case ERROR_TOO_MANY_OPEN_FILES:
+         errno = EMFILE;
+         break;
+
+      default:
+      case ERROR_ACCESS_DENIED:
+      case ERROR_SHARING_VIOLATION:
+      case ERROR_LOCK_VIOLATION:
+      case ERROR_INVALID_NAME:
+         errno = EACCES;
+         break;
+
+      case ERROR_FILE_EXISTS:
+         errno = EEXIST;
+         break;
+
+      case ERROR_INVALID_PARAMETER:
+         errno = EINVAL;
+         break;
+      }
+
+      return(int) -1;
+   }
+
+   return (int)idxFile + 3;
+}
+
+int
+tape_read(int fd, void *buffer, unsigned int count)
+{
+   if (buffer == NULL) {
+      errno = EINVAL;
+      return -1;
+   }
+
+   if (fd < 3 || fd >= (int)(NUMBER_HANDLE_ENTRIES + 3) || 
+       TapeHandleTable[fd - 3].OSHandle == INVALID_HANDLE_VALUE)
+   {
+      errno = EBADF;
+      return -1;
+   }
+
+   PTAPE_HANDLE_INFO    pHandleInfo = &TapeHandleTable[fd - 3];
+
+   DWORD bytes_read;
+   BOOL bResult;
+
+   bResult = ReadFile(pHandleInfo->OSHandle, buffer, count, &bytes_read, NULL);
+
+   if (bResult) {
+      pHandleInfo->bEOF = false;
+      pHandleInfo->bEOT = false;
+      pHandleInfo->bEOD = false;
+      return bytes_read;
+   } else {
+      int iReturnValue = 0;
+      DWORD last_error = GetLastError();
+
+      switch (last_error) {
+
+      case ERROR_FILEMARK_DETECTED:
+         pHandleInfo->bEOF = true;
+         break;
+
+      case ERROR_END_OF_MEDIA:
+         pHandleInfo->bEOT = true;
+         break;
+
+      case ERROR_NO_MEDIA_IN_DRIVE:
+         pHandleInfo->bEOF = false;
+         pHandleInfo->bEOT = false;
+         pHandleInfo->bEOD = false;
+         errno = ENOMEDIUM;
+         iReturnValue = -1;
+         break;
+
+      case ERROR_NO_DATA_DETECTED:
+         pHandleInfo->bEOD = true;
+         break;
+
+      case ERROR_INVALID_HANDLE:
+      case ERROR_ACCESS_DENIED:
+      case ERROR_LOCK_VIOLATION:
+         errno = EBADF;
+         iReturnValue = -1;
+         break;
+
+      default:
+         pHandleInfo->bEOF = false;
+         pHandleInfo->bEOT = false;
+         pHandleInfo->bEOD = false;
+         errno = EIO;
+         iReturnValue = -1;
+      }
+
+      return iReturnValue;
+   }
+}
+
+int
+tape_write(int fd, const void *buffer, unsigned int count)
+{
+   if (buffer == NULL) {
+      errno = EINVAL;
+      return -1;
+   }
+
+   if (fd < 3 || fd >= (int)(NUMBER_HANDLE_ENTRIES + 3) || TapeHandleTable[fd - 3].OSHandle == INVALID_HANDLE_VALUE)
+   {
+      errno = EBADF;
+      return -1;
+   }
+
+   PTAPE_HANDLE_INFO    pHandleInfo = &TapeHandleTable[fd - 3];
+
+   DWORD bytes_written;
+   BOOL bResult;
+
+   bResult = WriteFile(pHandleInfo->OSHandle, buffer, count, &bytes_written, NULL);
+
+   if (bResult) {
+      pHandleInfo->bEOF = false;
+      pHandleInfo->bEOT = false;
+      return bytes_written;
+   } else {
+      DWORD last_error = GetLastError();
+
+      switch (last_error) {
+      case ERROR_END_OF_MEDIA:
+      case ERROR_DISK_FULL:
+         pHandleInfo->bEOT = true;
+         errno = ENOSPC;
+         break;
+
+      case ERROR_NO_MEDIA_IN_DRIVE:
+         pHandleInfo->bEOF = false;
+         pHandleInfo->bEOT = false;
+         pHandleInfo->bEOD = false;
+         errno = ENOMEDIUM;
+         break;
+
+      case ERROR_INVALID_HANDLE:
+      case ERROR_ACCESS_DENIED:
+         errno = EBADF;
+         break;
+
+      default:
+         pHandleInfo->bEOF = false;
+         pHandleInfo->bEOT = false;
+         pHandleInfo->bEOD = false;
+         errno = EIO;
+         break;
+      }
+      return -1;
+   }
+}
+
+int
+tape_close(int fd)
+{
+   if (fd < 3 || fd >= (int)(NUMBER_HANDLE_ENTRIES + 3) || 
+      TapeHandleTable[fd - 3].OSHandle == INVALID_HANDLE_VALUE) {
+      errno = EBADF;
+      return -1;
+   }
+
+   PTAPE_HANDLE_INFO    pHandleInfo = &TapeHandleTable[fd - 3];
+
+   if (!CloseHandle(pHandleInfo->OSHandle)) {
+      pHandleInfo->OSHandle = INVALID_HANDLE_VALUE;
+      errno = EBADF;
+      return -1;
+   }
+
+   pHandleInfo->OSHandle = INVALID_HANDLE_VALUE;
+
+   return 0;
+}
+
+int
+tape_ioctl(int fd, unsigned long int request, ...)
+{
+   va_list argp;
+   int result;
+
+   va_start(argp, request);
+
+   switch (request) {
+   case MTIOCTOP:
+      result = tape_op(fd, va_arg(argp, mtop *));
+      break;
+
+   case MTIOCGET:
+      result = tape_get(fd, va_arg(argp, mtget *));
+      break;
+
+   case MTIOCPOS:
+      result = tape_pos(fd, va_arg(argp, mtpos *));
+      break;
+
+   default:
+      errno = ENOTTY;
+      result = -1;
+      break;
+   }
+
+   va_end(argp);
+
+   return result;
+}
+
+int tape_op(int fd, struct mtop *mt_com)
+{
+   DWORD result = NO_ERROR;
+   int   index;
+
+   if (fd < 3 || fd >= (int)(NUMBER_HANDLE_ENTRIES + 3) || 
+       TapeHandleTable[fd - 3].OSHandle == INVALID_HANDLE_VALUE)
+   {
+      errno = EBADF;
+      return -1;
+   }
+
+   PTAPE_HANDLE_INFO    pHandleInfo = &TapeHandleTable[fd - 3];
+
+   switch (mt_com->mt_op)
+   {
+   case MTRESET:
+   case MTNOP:
+   case MTSETDRVBUFFER:
+      break;
+
+   default:
+   case MTRAS1:
+   case MTRAS2:
+   case MTRAS3:
+   case MTSETDENSITY:
+      errno = ENOTTY;
+      result = (DWORD)-1;
+      break;
+
+   case MTFSF:
+      for (index = 0; index < mt_com->mt_count; index++) {
+         result = SetTapePosition(pHandleInfo->OSHandle, TAPE_SPACE_FILEMARKS, 0, 1, 0, FALSE);
+         if (result == NO_ERROR) {
+            pHandleInfo->ulFile++;
+            pHandleInfo->bEOF = true;
+            pHandleInfo->bEOT = false;
+         }
+      }
+      break;
+
+   case MTBSF:
+      for (index = 0; index < mt_com->mt_count; index++) {
+         result = SetTapePosition(pHandleInfo->OSHandle, TAPE_SPACE_FILEMARKS, 0, (DWORD)-1, ~0, FALSE);
+         if (result == NO_ERROR) {
+            pHandleInfo->ulFile--;
+            pHandleInfo->bBlockValid = false;
+            pHandleInfo->bEOD = false;
+            pHandleInfo->bEOF = false;
+            pHandleInfo->bEOT = false;
+         }
+      }
+      break;
+
+   case MTFSR:
+      result = SetTapePosition(pHandleInfo->OSHandle, TAPE_SPACE_RELATIVE_BLOCKS, 0, mt_com->mt_count, 0, FALSE);
+      if (result == NO_ERROR) {
+         pHandleInfo->bEOD = false;
+         pHandleInfo->bEOF = false;
+         pHandleInfo->bEOT = false;
+      } else if (result == ERROR_FILEMARK_DETECTED) {
+         pHandleInfo->bEOF = true;
+      }
+      break;
+
+   case MTBSR:
+      result = SetTapePosition(pHandleInfo->OSHandle, TAPE_SPACE_RELATIVE_BLOCKS, 0, -mt_com->mt_count, ~0, FALSE);
+      if (result == NO_ERROR) {
+         pHandleInfo->bEOD = false;
+         pHandleInfo->bEOF = false;
+         pHandleInfo->bEOT = false;
+      } else if (result == ERROR_FILEMARK_DETECTED) {
+         pHandleInfo->ulFile--;
+         pHandleInfo->bBlockValid = false;
+         pHandleInfo->bEOD = false;
+         pHandleInfo->bEOF = false;
+         pHandleInfo->bEOT = false;
+      }
+      break;
+
+   case MTWEOF:
+      result = WriteTapemark(pHandleInfo->OSHandle, TAPE_FILEMARKS, mt_com->mt_count, FALSE);
+      if (result == NO_ERROR) {
+         pHandleInfo->bEOF = true;
+         pHandleInfo->bEOT = false;
+         pHandleInfo->ulFile += mt_com->mt_count;
+         pHandleInfo->bBlockValid = true;
+         pHandleInfo->ullFileStart = 0;
+      }
+      break;
+
+   case MTREW:
+      result = SetTapePosition(pHandleInfo->OSHandle, TAPE_REWIND, 0, 0, 0, FALSE);
+      if (result == NO_ERROR) {
+         pHandleInfo->bEOD = false;
+         pHandleInfo->bEOF = false;
+         pHandleInfo->bEOT = false;
+         pHandleInfo->ulFile = 0;
+         pHandleInfo->bBlockValid = true;
+         pHandleInfo->ullFileStart = 0;
+      }
+      break;
+
+   case MTOFFL:
+      result = PrepareTape(pHandleInfo->OSHandle, TAPE_UNLOAD, FALSE);
+      if (result == NO_ERROR) {
+         pHandleInfo->bEOD = false;
+         pHandleInfo->bEOF = false;
+         pHandleInfo->bEOT = false;
+         pHandleInfo->ulFile = 0;
+         pHandleInfo->ullFileStart = 0;
+      }
+      break;
+
+   case MTRETEN:
+      result = PrepareTape(pHandleInfo->OSHandle, TAPE_TENSION, FALSE);
+      if (result == NO_ERROR) {
+         pHandleInfo->bEOD = false;
+         pHandleInfo->bEOF = false;
+         pHandleInfo->bEOT = false;
+         pHandleInfo->ulFile = 0;
+         pHandleInfo->bBlockValid = true;
+         pHandleInfo->ullFileStart = 0;
+      }
+      break;
+
+   case MTBSFM:
+      for (index = 0; index < mt_com->mt_count; index++) {
+         result = SetTapePosition(pHandleInfo->OSHandle, TAPE_SPACE_FILEMARKS, 0, (DWORD)-1, ~0, FALSE);
+         if (result == NO_ERROR) {
+            result = SetTapePosition(pHandleInfo->OSHandle, TAPE_SPACE_FILEMARKS, 0, 1, 0, FALSE);
+            pHandleInfo->bEOD = false;
+            pHandleInfo->bEOF = false;
+            pHandleInfo->bEOT = false;
+         }
+      }
+      break;
+
+   case MTFSFM:
+      for (index = 0; index < mt_com->mt_count; index++) {
+         result = SetTapePosition(pHandleInfo->OSHandle, TAPE_SPACE_FILEMARKS, 0, mt_com->mt_count, 0, FALSE);
+         if (result == NO_ERROR) {
+            result = SetTapePosition(pHandleInfo->OSHandle, TAPE_SPACE_FILEMARKS, 0, (DWORD)-1, ~0, FALSE);
+            pHandleInfo->bEOD = false;
+            pHandleInfo->bEOF = false;
+            pHandleInfo->bEOT = false;
+         }
+      }
+      break;
+
+   case MTEOM:
+      for ( ; ; ) {
+         result = SetTapePosition(pHandleInfo->OSHandle, TAPE_SPACE_FILEMARKS, 0, 1, 0, FALSE);
+         if (result != NO_ERROR) {
+            pHandleInfo->bEOF = false;
+
+            if (result == ERROR_END_OF_MEDIA) {
+               pHandleInfo->bEOD = true;
+               pHandleInfo->bEOT = true;
+               return 0;
+            }
+            if (result == ERROR_NO_DATA_DETECTED) {
+               pHandleInfo->bEOD = true;
+               pHandleInfo->bEOT = false;
+               return 0;
+            }
+            break;
+         } else {
+            pHandleInfo->bEOF = true;
+            pHandleInfo->ulFile++;
+         }
+      }
+      break;
+
+   case MTERASE:
+      result = EraseTape(pHandleInfo->OSHandle, TAPE_ERASE_LONG, FALSE);
+      if (result == NO_ERROR) {
+         pHandleInfo->bEOD = true;
+         pHandleInfo->bEOF = false;
+         pHandleInfo->bEOT = false;
+         pHandleInfo->ulFile = 0;
+         pHandleInfo->bBlockValid = true;
+         pHandleInfo->ullFileStart = 0;
+      }
+      break;
+
+   case MTSETBLK:
+      {
+         TAPE_SET_MEDIA_PARAMETERS  SetMediaParameters;
+
+         SetMediaParameters.BlockSize = mt_com->mt_count;
+         result = SetTapeParameters(pHandleInfo->OSHandle, SET_TAPE_MEDIA_INFORMATION, &SetMediaParameters);
+      }
+      break;
+
+   case MTSEEK:
+      {
+         TAPE_POSITION_INFO   TapePositionInfo;
+
+         result = SetTapePosition(pHandleInfo->OSHandle, TAPE_ABSOLUTE_BLOCK, 0, mt_com->mt_count, 0, FALSE);
+
+         memset(&TapePositionInfo, 0, sizeof(TapePositionInfo));
+         DWORD dwPosResult = GetTapePositionInfo(pHandleInfo->OSHandle, &TapePositionInfo);
+         if (dwPosResult == NO_ERROR && TapePositionInfo.FileSetValid) {
+            pHandleInfo->ulFile = (ULONG)TapePositionInfo.FileNumber;
+         } else {
+            pHandleInfo->ulFile = ~0U;
+         }
+      }
+      break;
+
+   case MTTELL:
+      {
+         DWORD partition;
+         DWORD offset;
+         DWORD offsetHi;
+
+         result = GetTapePosition(pHandleInfo->OSHandle, TAPE_ABSOLUTE_BLOCK, &partition, &offset, &offsetHi);
+         if (result == NO_ERROR) {
+            return offset;
+         }
+      }
+      break;
+
+   case MTFSS:
+      result = SetTapePosition(pHandleInfo->OSHandle, TAPE_SPACE_SETMARKS, 0, mt_com->mt_count, 0, FALSE);
+      break;
+
+   case MTBSS:
+      result = SetTapePosition(pHandleInfo->OSHandle, TAPE_SPACE_SETMARKS, 0, -mt_com->mt_count, ~0, FALSE);
+      break;
+
+   case MTWSM:
+      result = WriteTapemark(pHandleInfo->OSHandle, TAPE_SETMARKS, mt_com->mt_count, FALSE);
+      break;
+
+   case MTLOCK:
+      result = PrepareTape(pHandleInfo->OSHandle, TAPE_LOCK, FALSE);
+      break;
+
+   case MTUNLOCK:
+      result = PrepareTape(pHandleInfo->OSHandle, TAPE_UNLOCK, FALSE);
+      break;
+
+   case MTLOAD:
+      result = PrepareTape(pHandleInfo->OSHandle, TAPE_LOAD, FALSE);
+      break;
+
+   case MTUNLOAD:
+      result = PrepareTape(pHandleInfo->OSHandle, TAPE_UNLOAD, FALSE);
+      break;
+
+   case MTCOMPRESSION:
+      {
+         TAPE_GET_DRIVE_PARAMETERS  GetDriveParameters;
+         TAPE_SET_DRIVE_PARAMETERS  SetDriveParameters;
+         DWORD                      size;
+
+         size = sizeof(GetDriveParameters);
+
+         result = GetTapeParameters(pHandleInfo->OSHandle, GET_TAPE_DRIVE_INFORMATION, &size, &GetDriveParameters);
+
+         if (result == NO_ERROR)
+         {
+            SetDriveParameters.ECC = GetDriveParameters.ECC;
+            SetDriveParameters.Compression = (BOOLEAN)mt_com->mt_count;
+            SetDriveParameters.DataPadding = GetDriveParameters.DataPadding;
+            SetDriveParameters.ReportSetmarks = GetDriveParameters.ReportSetmarks;
+            SetDriveParameters.EOTWarningZoneSize = GetDriveParameters.EOTWarningZoneSize;
+
+            result = SetTapeParameters(pHandleInfo->OSHandle, SET_TAPE_DRIVE_INFORMATION, &SetDriveParameters);
+         }
+      }
+      break;
+
+   case MTSETPART:
+      result = SetTapePosition(pHandleInfo->OSHandle, TAPE_LOGICAL_BLOCK, mt_com->mt_count, 0, 0, FALSE);
+      break;
+
+   case MTMKPART:
+      if (mt_com->mt_count == 0)
+      {
+         result = CreateTapePartition(pHandleInfo->OSHandle, TAPE_INITIATOR_PARTITIONS, 1, 0);
+      }
+      else
+      {
+         result = CreateTapePartition(pHandleInfo->OSHandle, TAPE_INITIATOR_PARTITIONS, 2, mt_com->mt_count);
+      }
+      break;
+   }
+
+   if ((result == NO_ERROR && pHandleInfo->bEOF) || 
+       (result == ERROR_FILEMARK_DETECTED && mt_com->mt_op == MTFSR)) {
+
+      TAPE_POSITION_INFO TapePositionInfo;
+
+      if (GetTapePositionInfo(pHandleInfo->OSHandle, &TapePositionInfo) == NO_ERROR) {
+         pHandleInfo->bBlockValid = true;
+         pHandleInfo->ullFileStart = TapePositionInfo.BlockNumber;
+      }
+   }
+
+   switch (result) {
+   case NO_ERROR:
+   case (DWORD)-1:   /* Error has already been translated into errno */
+      break;
+
+   default:
+   case ERROR_FILEMARK_DETECTED:
+      errno = EIO;
+      break;
+
+   case ERROR_END_OF_MEDIA:
+      pHandleInfo->bEOT = true;
+      errno = EIO;
+      break;
+
+   case ERROR_NO_DATA_DETECTED:
+      pHandleInfo->bEOD = true;
+      errno = EIO;
+      break;
+
+   case ERROR_NO_MEDIA_IN_DRIVE:
+      pHandleInfo->bEOF = false;
+      pHandleInfo->bEOT = false;
+      pHandleInfo->bEOD = false;
+      errno = ENOMEDIUM;
+      break;
+
+   case ERROR_INVALID_HANDLE:
+   case ERROR_ACCESS_DENIED:
+   case ERROR_LOCK_VIOLATION:
+      errno = EBADF;
+      break;
+   }
+
+   return result == NO_ERROR ? 0 : -1;
+}
+
+int tape_get(int fd, struct mtget *mt_get)
+{
+   TAPE_POSITION_INFO pos_info;
+   BOOL result;
+
+   if (fd < 3 || fd >= (int)(NUMBER_HANDLE_ENTRIES + 3) || 
+       TapeHandleTable[fd - 3].OSHandle == INVALID_HANDLE_VALUE) {
+      errno = EBADF;
+      return -1;
+   }
+
+   PTAPE_HANDLE_INFO    pHandleInfo = &TapeHandleTable[fd - 3];
+
+   if (GetTapePositionInfo(pHandleInfo->OSHandle, &pos_info) != NO_ERROR) {
+      return -1;
+   }
+
+   DWORD density = 0;
+   DWORD blocksize = 0;
+
+   result = GetDensityBlockSize(pHandleInfo->OSHandle, &density, &blocksize);
+
+   if (result != NO_ERROR) {
+      TAPE_GET_DRIVE_PARAMETERS drive_params;
+      DWORD size;
+
+      size = sizeof(drive_params);
+
+      result = GetTapeParameters(pHandleInfo->OSHandle, GET_TAPE_DRIVE_INFORMATION, &size, &drive_params);
+
+      if (result == NO_ERROR) {
+         blocksize = drive_params.DefaultBlockSize;
+      }
+   }
+
+   mt_get->mt_type = MT_ISSCSI2;
+
+   // Partition #
+   mt_get->mt_resid = pos_info.PartitionBlockValid ? pos_info.Partition : (ULONG)-1;
+
+   // Density / Block Size
+   mt_get->mt_dsreg = ((density << MT_ST_DENSITY_SHIFT) & MT_ST_DENSITY_MASK) |
+                      ((blocksize << MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK);
+
+   mt_get->mt_gstat = 0x00010000;  /* Immediate report mode.*/
+
+   if (pHandleInfo->bEOF) {
+      mt_get->mt_gstat |= 0x80000000;     // GMT_EOF
+   }
+
+   if (pos_info.PartitionBlockValid && pos_info.BlockNumber == 0) {
+      mt_get->mt_gstat |= 0x40000000;     // GMT_BOT
+   }
+
+   if (pHandleInfo->bEOT) {
+      mt_get->mt_gstat |= 0x20000000;     // GMT_EOT
+   }
+
+   if (pHandleInfo->bEOD) {
+      mt_get->mt_gstat |= 0x08000000;     // GMT_EOD
+   }
+
+   TAPE_GET_MEDIA_PARAMETERS  media_params;
+   DWORD size = sizeof(media_params);
+   
+   result = GetTapeParameters(pHandleInfo->OSHandle, GET_TAPE_MEDIA_INFORMATION, &size, &media_params);
+
+   if (result == NO_ERROR && media_params.WriteProtected) {
+      mt_get->mt_gstat |= 0x04000000;     // GMT_WR_PROT
+   }
+
+   result = GetTapeStatus(pHandleInfo->OSHandle);
+
+   if (result != NO_ERROR) {
+      if (result == ERROR_NO_MEDIA_IN_DRIVE) {
+         mt_get->mt_gstat |= 0x00040000;  // GMT_DR_OPEN
+      }
+   } else {
+      mt_get->mt_gstat |= 0x01000000;     // GMT_ONLINE
+   }
+
+   // Recovered Error Count
+   mt_get->mt_erreg = 0;
+
+   // File Number
+   mt_get->mt_fileno = (__daddr_t)pHandleInfo->ulFile;
+
+   // Block Number
+   mt_get->mt_blkno = (__daddr_t)(pHandleInfo->bBlockValid ? pos_info.BlockNumber - pHandleInfo->ullFileStart : (ULONGLONG)-1);
+
+   return 0;
+}
+
+#define  SERVICEACTION_SHORT_FORM_BLOCKID             0
+#define  SERVICEACTION_SHORT_FORM_VENDOR_SPECIFIC     1
+#define  SERVICEACTION_LONG_FORM                      6
+#define  SERVICEACTION_EXTENDED_FORM                  8
+
+
+typedef  struct   _SCSI_READ_POSITION_SHORT_BUFFER
+{
+   UCHAR    :1;
+   UCHAR    PERR:1;
+   UCHAR    BPU:1;
+   UCHAR    :1;
+   UCHAR    BYCU:1;
+   UCHAR    BCU:1;
+   UCHAR    EOP:1;
+   UCHAR    BOP:1;
+   UCHAR    Partition;
+   UCHAR    Reserved1[2];
+   UCHAR    FirstBlock[4];
+   UCHAR    LastBlock[4];
+   UCHAR    Reserved2;
+   UCHAR    NumberBufferBlocks[3];
+   UCHAR    NumberBufferBytes[4];
+}  SCSI_READ_POSITION_SHORT_BUFFER, *PSCSI_READ_POSITION_SHORT_BUFFER;
+
+typedef  struct   _SCSI_READ_POSITION_LONG_BUFFER
+{
+   UCHAR    :2;
+   UCHAR    BPU:1;
+   UCHAR    MPU:1;
+   UCHAR    :2;
+   UCHAR    EOP:1;
+   UCHAR    BOP:1;
+   UCHAR    Reserved3[3];
+   UCHAR    Partition[4];
+   UCHAR    BlockNumber[8];
+   UCHAR    FileNumber[8];
+   UCHAR    SetNumber[8];
+}  SCSI_READ_POSITION_LONG_BUFFER, *PSCSI_READ_POSITION_LONG_BUFFER;
+
+typedef  struct   _SCSI_READ_POSITION_EXTENDED_BUFFER
+{
+   UCHAR    :1;
+   UCHAR    PERR:1;
+   UCHAR    LOPU:1;
+   UCHAR    :1;
+   UCHAR    BYCU:1;
+   UCHAR    LOCU:1;
+   UCHAR    EOP:1;
+   UCHAR    BOP:1;
+   UCHAR    Partition;
+   UCHAR    AdditionalLength[2];
+   UCHAR    Reserved1;
+   UCHAR    NumberBufferObjects[3];
+   UCHAR    FirstLogicalObject[8];
+   UCHAR    LastLogicalObject[8];
+   UCHAR    NumberBufferObjectBytes[8];
+}  SCSI_READ_POSITION_EXTENDED_BUFFER, *PSCSI_READ_POSITION_EXTENDED_BUFFER;
+
+typedef union _READ_POSITION_RESULT {
+   SCSI_READ_POSITION_SHORT_BUFFER     ShortBuffer;
+   SCSI_READ_POSITION_LONG_BUFFER      LongBuffer;
+   SCSI_READ_POSITION_EXTENDED_BUFFER  ExtendedBuffer;
+}  READ_POSITION_RESULT, *PREAD_POSITION_RESULT;
+
+DWORD GetTapePositionInfo(HANDLE hDevice, PTAPE_POSITION_INFO TapePositionInfo)
+{
+   PSCSI_PASS_THROUGH   ScsiPassThrough;
+   BOOL                 bResult;
+   DWORD                dwBytesReturned;
+
+   const DWORD dwBufferSize = sizeof(SCSI_PASS_THROUGH) + sizeof(READ_POSITION_RESULT) + 28;
+
+   memset(TapePositionInfo, 0, sizeof(*TapePositionInfo));
+
+   ScsiPassThrough = (PSCSI_PASS_THROUGH)malloc(dwBufferSize);
+
+   for (int pass = 0; pass < 2; pass++)
+   {
+      memset(ScsiPassThrough, 0, dwBufferSize);
+
+      ScsiPassThrough->Length = sizeof(SCSI_PASS_THROUGH);
+
+      ScsiPassThrough->CdbLength = 10;
+      ScsiPassThrough->SenseInfoLength = 28;
+      ScsiPassThrough->DataIn = 1;
+      ScsiPassThrough->DataTransferLength = sizeof(SCSI_READ_POSITION_LONG_BUFFER);
+      ScsiPassThrough->TimeOutValue = 1000;
+      ScsiPassThrough->DataBufferOffset = sizeof(SCSI_PASS_THROUGH) + 28;
+      ScsiPassThrough->SenseInfoOffset = sizeof(SCSI_PASS_THROUGH);
+
+      ScsiPassThrough->Cdb[0] = 0x34;  // READ POSITION
+
+      switch (pass)
+      {
+      case 0:
+         ScsiPassThrough->Cdb[1] = SERVICEACTION_LONG_FORM;
+         break;
+
+      case 1:
+         ScsiPassThrough->Cdb[1] = SERVICEACTION_SHORT_FORM_BLOCKID;
+         break;
+      }
+
+      bResult = DeviceIoControl( hDevice, 
+                                 IOCTL_SCSI_PASS_THROUGH, 
+                                 ScsiPassThrough, sizeof(SCSI_PASS_THROUGH), 
+                                 ScsiPassThrough, dwBufferSize, 
+                                 &dwBytesReturned, 
+                                 NULL);
+
+      if (bResult && dwBytesReturned >= (offsetof(SCSI_PASS_THROUGH, ScsiStatus) + sizeof(ScsiPassThrough->ScsiStatus))) {
+         if (ScsiPassThrough->ScsiStatus == SCSISTAT_GOOD) {
+            PREAD_POSITION_RESULT   pPosResult = (PREAD_POSITION_RESULT)((PUCHAR)ScsiPassThrough + ScsiPassThrough->DataBufferOffset);
+
+            switch (pass)
+            {
+            case 0:     // SERVICEACTION_LONG_FORM
+               {
+                  TapePositionInfo->AtPartitionStart = pPosResult->LongBuffer.BOP;
+                  TapePositionInfo->AtPartitionEnd = pPosResult->LongBuffer.EOP;
+
+                  if (!TapePositionInfo->PartitionBlockValid) {
+                     TapePositionInfo->PartitionBlockValid = !pPosResult->LongBuffer.BPU;
+
+                     if (TapePositionInfo->PartitionBlockValid) {
+                        TapePositionInfo->Partition =   Read32BitUnsigned(pPosResult->LongBuffer.Partition);
+                        TapePositionInfo->BlockNumber = Read64BitUnsigned(pPosResult->LongBuffer.BlockNumber);
+                     }
+                  }
+
+                  TapePositionInfo->FileSetValid = !pPosResult->LongBuffer.MPU;
+                  if (TapePositionInfo->FileSetValid) {
+                     TapePositionInfo->FileNumber =  Read64BitUnsigned(pPosResult->LongBuffer.FileNumber);
+                     TapePositionInfo->SetNumber =   Read64BitUnsigned(pPosResult->LongBuffer.SetNumber);
+                  }
+               }
+               break;
+
+            case 1:     // SERVICEACTION_SHORT_FORM_BLOCKID
+               {
+                  // pPosResult->ShortBuffer.PERR;
+                  // pPosResult->ShortBuffer.BYCU;
+                  // pPosResult->ShortBuffer.BCU;
+                  TapePositionInfo->AtPartitionStart = pPosResult->ShortBuffer.BOP;
+                  TapePositionInfo->AtPartitionEnd = pPosResult->ShortBuffer.EOP;
+
+                  if (!TapePositionInfo->PartitionBlockValid) {
+                     TapePositionInfo->PartitionBlockValid = !pPosResult->ShortBuffer.BPU;
+
+                     if (TapePositionInfo->PartitionBlockValid) {
+                        TapePositionInfo->Partition =   pPosResult->ShortBuffer.Partition;
+                        TapePositionInfo->BlockNumber = Read32BitUnsigned(pPosResult->ShortBuffer.FirstBlock);
+                     }
+                  }
+                  // Read32BitsUnsigned(pPosResult->ShortBuffer.LastBlock);
+                  // Read24BitsUnsigned(pPosResult->ShortBuffer.NumberBufferBlocks);
+                  // Read32BitsUnsigned(pPosResult->ShortBuffer.NumberBufferBytes);
+               }
+               break;
+            }
+         }
+      }
+   }
+   free(ScsiPassThrough);
+
+   return NO_ERROR;
+}
+
+DWORD GetDensityBlockSize(HANDLE hDevice, DWORD *pdwDensity, DWORD *pdwBlockSize)
+{
+   DWORD             dwBufferSize = sizeof(GET_MEDIA_TYPES) + 5 * sizeof(DEVICE_MEDIA_INFO);
+   GET_MEDIA_TYPES * pGetMediaTypes = (GET_MEDIA_TYPES *)malloc(dwBufferSize);
+   BOOL              bResult;
+   DWORD             dwResult;
+
+   if (pGetMediaTypes == NULL) {
+      return ERROR_OUTOFMEMORY;
+   }
+
+   do {
+      DWORD          dwBytesReturned;
+      
+      bResult = DeviceIoControl( hDevice, 
+                                 IOCTL_STORAGE_GET_MEDIA_TYPES_EX, 
+                                 NULL, 0, 
+                                 (LPVOID)pGetMediaTypes, dwBufferSize, 
+                                 &dwBytesReturned, 
+                                 NULL);
+
+      if (!bResult) {
+         dwResult = GetLastError();
+
+         if (dwResult != ERROR_INSUFFICIENT_BUFFER) {
+            free(pGetMediaTypes);
+            return dwResult;
+         }
+
+         dwBufferSize += 6 * sizeof(DEVICE_MEDIA_INFO);
+
+         GET_MEDIA_TYPES * pNewBuffer = (GET_MEDIA_TYPES *)realloc(pGetMediaTypes, dwBufferSize);
+
+         if (pNewBuffer != pGetMediaTypes) {
+            free(pGetMediaTypes);
+
+            if (pNewBuffer == NULL) {
+               return ERROR_OUTOFMEMORY;
+            }
+
+            pGetMediaTypes = pNewBuffer;
+         }
+      }
+   } while (!bResult);
+
+   if (pGetMediaTypes->DeviceType != FILE_DEVICE_TAPE) {
+      free(pGetMediaTypes);
+      return ERROR_BAD_DEVICE;
+   }
+
+   for (DWORD idxMedia = 0; idxMedia < pGetMediaTypes->MediaInfoCount; idxMedia++) {
+
+      if (pGetMediaTypes->MediaInfo[idxMedia].DeviceSpecific.TapeInfo.MediaCharacteristics & MEDIA_CURRENTLY_MOUNTED) {
+
+         if (pGetMediaTypes->MediaInfo[idxMedia].DeviceSpecific.TapeInfo.BusType == BusTypeScsi) {
+            *pdwDensity = pGetMediaTypes->MediaInfo[idxMedia].DeviceSpecific.TapeInfo.BusSpecificData.ScsiInformation.DensityCode;
+         } else {
+            *pdwDensity = 0;
+         }
+
+         *pdwBlockSize = pGetMediaTypes->MediaInfo[idxMedia].DeviceSpecific.TapeInfo.CurrentBlockSize;
+
+         free(pGetMediaTypes);
+
+         return NO_ERROR;
+      }
+   }
+
+   free(pGetMediaTypes);
+
+   return ERROR_NO_MEDIA_IN_DRIVE;
+}
+
+int tape_pos(int fd, struct mtpos *mt_pos)
+{
+   DWORD partition;
+   DWORD offset;
+   DWORD offsetHi;
+   BOOL result;
+
+   if (fd < 3 || fd >= (int)(NUMBER_HANDLE_ENTRIES + 3) || 
+       TapeHandleTable[fd - 3].OSHandle == INVALID_HANDLE_VALUE) {
+      errno = EBADF;
+      return -1;
+   }
+
+   PTAPE_HANDLE_INFO    pHandleInfo = &TapeHandleTable[fd - 3];
+
+   result = GetTapePosition(pHandleInfo->OSHandle, TAPE_ABSOLUTE_BLOCK, &partition, &offset, &offsetHi);
+   if (result == NO_ERROR) {
+      mt_pos->mt_blkno = offset;
+      return 0;
+   }
+
+   return -1;
+}
diff --git a/bacula/src/win32/tools/Makefile b/bacula/src/win32/tools/Makefile
new file mode 100644 (file)
index 0000000..59d3829
--- /dev/null
@@ -0,0 +1,97 @@
+#
+# Makefile for win32 bacula executables
+# Using MinGW cross-compiler on GNU/Linux
+#
+#  Written by Robert Nelson, June 2006
+#
+
+include ../Makefile.inc
+
+INCLUDES = \
+       $(INCLUDE_PTHREADS) \
+       $(INCLUDE_BACULA) \
+       $(INCLUDE_ZLIB) \
+       $(INCLUDE_OPENSSL) \
+       $(INCLUDE_ICONS)
+
+DEFINES = \
+       -DUSING_DLL \
+       $(HAVES)
+
+VPATH = ../../tools ../../dird
+
+##########################################################################
+
+DIRCONF_OBJS = \
+       $(OBJDIR)/dird_conf.o \
+       $(OBJDIR)/run_conf.o \
+       $(OBJDIR)/inc_conf.o
+
+ALL_OBJS = \
+       $(DIRCONF_OBJS) \
+       $(OBJDIR)/bsmtp.o \
+       $(OBJDIR)/dbcheck.o \
+       $(OBJDIR)/fstype.o \
+       $(OBJDIR)/drivetype.o \
+       $(OBJDIR)/testfind.o \
+       $(OBJDIR)/testls.o \
+       $(OBJDIR)/bregex.o \
+       $(OBJDIR)/bwild.o
+
+##########################################################################
+
+# Targets
+
+.PHONY: all clean
+
+all: \
+       $(BINDIR)/dbcheck.exe $(BINDIR)/fstype.exe $(BINDIR)/drivetype.exe \
+       $(BINDIR)/testfind.exe $(BINDIR)/testls.exe $(BINDIR)/bregex.exe \
+       $(BINDIR)/bwild.exe
+
+#
+# bsmtp needs passwd file emulation
+#
+#      $(BINDIR)/bsmtp.exe
+
+clean:
+       @echo "Cleaning `pwd`"
+       $(call clean_obj,$(ALL_OBJS))
+       $(call clean_exe,$(BINDIR)/bsmtp.exe)
+       $(call clean_exe,$(BINDIR)/dbcheck.exe)
+       $(call clean_exe,$(BINDIR)/fstype.exe)
+       $(call clean_exe,$(BINDIR)/drivetype.exe)
+       $(call clean_exe,$(BINDIR)/testfind.exe)
+       $(call clean_exe,$(BINDIR)/testls.exe)
+       $(call clean_exe,$(BINDIR)/bregex.exe)
+       $(call clean_exe,$(BINDIR)/bwild.exe)
+
+#
+# Rules
+#
+
+$(BINDIR)/bsmtp.exe: $(OBJDIR)/bsmtp.o $(LIBS_BACULA)
+       $(call link_conapp,)
+
+$(BINDIR)/dbcheck.exe: $(OBJDIR)/dbcheck.o $(DIRCONF_OBJS) $(LIBS_BACULA)
+       $(call link_conapp,)
+
+$(BINDIR)/fstype.exe: $(OBJDIR)/fstype.o $(LIBS_BACULA)
+       $(call link_conapp,)
+
+$(BINDIR)/drivetype.exe: $(OBJDIR)/drivetype.o $(LIBS_BACULA)
+       $(call link_conapp,)
+
+$(BINDIR)/testfind.exe: $(OBJDIR)/testfind.o $(DIRCONF_OBJS) $(LIBS_BACULA)
+       $(call link_conapp,)
+
+$(BINDIR)/testls.exe: $(OBJDIR)/testls.o $(LIBS_BACULA)
+       $(call link_conapp,)
+
+$(BINDIR)/bregex.exe: $(OBJDIR)/bregex.o $(LIBS_BACULA)
+       $(call link_conapp,)
+
+$(BINDIR)/bwild.exe: $(OBJDIR)/bwild.o $(LIBS_BACULA)
+       $(call link_conapp,)
+
+include ../Makefile.rules