From 5020da6dc236f55111c99f61f2f6c6c8257cde37 Mon Sep 17 00:00:00 2001 From: Robert Nelson Date: Fri, 30 Jun 2006 04:14:19 +0000 Subject: [PATCH] Add all the new files from the Windows branch. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3095 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/win32/cats/Makefile | 73 + bacula/src/win32/cats/cats.vcproj | 519 +++++++ .../src/win32/cats/create_mysql_database.cmd | 13 + .../src/win32/cats/delete_catalog_backup.cmd | 4 + bacula/src/win32/cats/drop_mysql_database.cmd | 13 + bacula/src/win32/cats/drop_mysql_tables.cmd | 13 + bacula/src/win32/cats/drop_mysql_tables.sql | 25 + .../src/win32/cats/grant_mysql_privileges.cmd | 13 + .../src/win32/cats/grant_mysql_privileges.sql | 5 + bacula/src/win32/cats/make_catalog_backup.cmd | 38 + bacula/src/win32/cats/make_mysql_tables.cmd | 13 + bacula/src/win32/cats/make_mysql_tables.sql | 309 ++++ bacula/src/win32/cats/update_mysql_tables.cmd | 18 + bacula/src/win32/cats/update_mysql_tables.sql | 32 + bacula/src/win32/dird/Makefile | 102 ++ bacula/src/win32/dird/dird.vcproj | 1137 ++++++++++++++ bacula/src/win32/dird/winbacula.h | 70 + bacula/src/win32/dird/winmain.cpp | 339 +++++ bacula/src/win32/dird/winservice.cpp | 761 ++++++++++ bacula/src/win32/dird/winservice.h | 126 ++ bacula/src/win32/dll/Makefile | 182 +++ bacula/src/win32/dll/bacula.def | 638 ++++++++ bacula/src/win32/libbac/Makefile | 110 ++ bacula/src/win32/libbac/libbac.vcproj | 1339 +++++++++++++++++ bacula/src/win32/libfind/Makefile | 66 + bacula/src/win32/libfind/libfind.vcproj | 406 +++++ bacula/src/win32/libwin32/bacula.bmp | Bin 0 -> 3126 bytes bacula/src/win32/libwin32/bacula.ico | Bin 0 -> 766 bytes bacula/src/win32/libwin32/bacula.rc | 1 + bacula/src/win32/libwin32/error.ico | Bin 0 -> 766 bytes bacula/src/win32/libwin32/idle.ico | Bin 0 -> 766 bytes bacula/src/win32/libwin32/libwin32.vcproj | 167 ++ bacula/src/win32/libwin32/popup.c | 47 + bacula/src/win32/libwin32/running.ico | Bin 0 -> 766 bytes bacula/src/win32/libwin32/saving.ico | Bin 0 -> 766 bytes bacula/src/win32/libwin32/warn.ico | Bin 0 -> 766 bytes bacula/src/win32/libwin32/winabout.cpp | 80 + bacula/src/win32/libwin32/winabout.h | 48 + bacula/src/win32/libwin32/winbacula.h | 73 + bacula/src/win32/libwin32/winevents.cpp | 87 ++ bacula/src/win32/libwin32/winevents.h | 44 + bacula/src/win32/libwin32/winres.h | 46 + bacula/src/win32/libwin32/winres.rc | 181 +++ bacula/src/win32/libwin32/winservice.h | 125 ++ bacula/src/win32/libwin32/winstat.cpp | 97 ++ bacula/src/win32/libwin32/winstat.h | 45 + bacula/src/win32/libwin32/wintray.cpp | 353 +++++ bacula/src/win32/libwin32/wintray.h | 93 ++ bacula/src/win32/scripts/mtx-changer.cmd.in | 194 +++ bacula/src/win32/scripts/sleep.c | 23 + bacula/src/win32/scripts/sleep.vcproj | 199 +++ bacula/src/win32/stored/Makefile | 148 ++ bacula/src/win32/stored/mtops.cpp | 1147 ++++++++++++++ bacula/src/win32/tools/Makefile | 97 ++ 54 files changed, 9659 insertions(+) create mode 100644 bacula/src/win32/cats/Makefile create mode 100644 bacula/src/win32/cats/cats.vcproj create mode 100644 bacula/src/win32/cats/create_mysql_database.cmd create mode 100644 bacula/src/win32/cats/delete_catalog_backup.cmd create mode 100644 bacula/src/win32/cats/drop_mysql_database.cmd create mode 100644 bacula/src/win32/cats/drop_mysql_tables.cmd create mode 100644 bacula/src/win32/cats/drop_mysql_tables.sql create mode 100644 bacula/src/win32/cats/grant_mysql_privileges.cmd create mode 100644 bacula/src/win32/cats/grant_mysql_privileges.sql create mode 100644 bacula/src/win32/cats/make_catalog_backup.cmd create mode 100644 bacula/src/win32/cats/make_mysql_tables.cmd create mode 100644 bacula/src/win32/cats/make_mysql_tables.sql create mode 100644 bacula/src/win32/cats/update_mysql_tables.cmd create mode 100644 bacula/src/win32/cats/update_mysql_tables.sql create mode 100644 bacula/src/win32/dird/Makefile create mode 100644 bacula/src/win32/dird/dird.vcproj create mode 100644 bacula/src/win32/dird/winbacula.h create mode 100644 bacula/src/win32/dird/winmain.cpp create mode 100644 bacula/src/win32/dird/winservice.cpp create mode 100644 bacula/src/win32/dird/winservice.h create mode 100644 bacula/src/win32/dll/Makefile create mode 100644 bacula/src/win32/dll/bacula.def create mode 100644 bacula/src/win32/libbac/Makefile create mode 100644 bacula/src/win32/libbac/libbac.vcproj create mode 100644 bacula/src/win32/libfind/Makefile create mode 100644 bacula/src/win32/libfind/libfind.vcproj create mode 100644 bacula/src/win32/libwin32/bacula.bmp create mode 100644 bacula/src/win32/libwin32/bacula.ico create mode 100644 bacula/src/win32/libwin32/bacula.rc create mode 100644 bacula/src/win32/libwin32/error.ico create mode 100644 bacula/src/win32/libwin32/idle.ico create mode 100644 bacula/src/win32/libwin32/libwin32.vcproj create mode 100644 bacula/src/win32/libwin32/popup.c create mode 100644 bacula/src/win32/libwin32/running.ico create mode 100644 bacula/src/win32/libwin32/saving.ico create mode 100644 bacula/src/win32/libwin32/warn.ico create mode 100644 bacula/src/win32/libwin32/winabout.cpp create mode 100644 bacula/src/win32/libwin32/winabout.h create mode 100644 bacula/src/win32/libwin32/winbacula.h create mode 100644 bacula/src/win32/libwin32/winevents.cpp create mode 100644 bacula/src/win32/libwin32/winevents.h create mode 100644 bacula/src/win32/libwin32/winres.h create mode 100644 bacula/src/win32/libwin32/winres.rc create mode 100644 bacula/src/win32/libwin32/winservice.h create mode 100644 bacula/src/win32/libwin32/winstat.cpp create mode 100644 bacula/src/win32/libwin32/winstat.h create mode 100644 bacula/src/win32/libwin32/wintray.cpp create mode 100644 bacula/src/win32/libwin32/wintray.h create mode 100644 bacula/src/win32/scripts/mtx-changer.cmd.in create mode 100644 bacula/src/win32/scripts/sleep.c create mode 100644 bacula/src/win32/scripts/sleep.vcproj create mode 100644 bacula/src/win32/stored/Makefile create mode 100644 bacula/src/win32/stored/mtops.cpp create mode 100644 bacula/src/win32/tools/Makefile diff --git a/bacula/src/win32/cats/Makefile b/bacula/src/win32/cats/Makefile new file mode 100644 index 0000000000..46b71a0670 --- /dev/null +++ b/bacula/src/win32/cats/Makefile @@ -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 index 0000000000..87ab1f25a2 --- /dev/null +++ b/bacula/src/win32/cats/cats.vcproj @@ -0,0 +1,519 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bacula/src/win32/cats/create_mysql_database.cmd b/bacula/src/win32/cats/create_mysql_database.cmd new file mode 100644 index 0000000000..138bff38ab --- /dev/null +++ b/bacula/src/win32/cats/create_mysql_database.cmd @@ -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 index 0000000000..a3cfcf6333 --- /dev/null +++ b/bacula/src/win32/cats/delete_catalog_backup.cmd @@ -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 index 0000000000..586de2a3b2 --- /dev/null +++ b/bacula/src/win32/cats/drop_mysql_database.cmd @@ -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 index 0000000000..fb897394ce --- /dev/null +++ b/bacula/src/win32/cats/drop_mysql_tables.cmd @@ -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 index 0000000000..cf81c8dd9a --- /dev/null +++ b/bacula/src/win32/cats/drop_mysql_tables.sql @@ -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 index 0000000000..49b99a89f7 --- /dev/null +++ b/bacula/src/win32/cats/grant_mysql_privileges.cmd @@ -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 index 0000000000..043d987c03 --- /dev/null +++ b/bacula/src/win32/cats/grant_mysql_privileges.sql @@ -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 index 0000000000..50480bd2c4 --- /dev/null +++ b/bacula/src/win32/cats/make_catalog_backup.cmd @@ -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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bacula/src/win32/dird/winbacula.h b/bacula/src/win32/dird/winbacula.h new file mode 100644 index 0000000000..22c655f602 --- /dev/null +++ b/bacula/src/win32/dird/winbacula.h @@ -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 index 0000000000..dad80940fe --- /dev/null +++ b/bacula/src/win32/dird/winmain.cpp @@ -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 +#include +#include +#include +#include + +#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