From: Kern Sibbald Date: Wed, 15 Aug 2007 16:54:21 +0000 (+0000) Subject: kes Update AUTHORs file X-Git-Tag: Release-2.2.1~65 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b75828273c5c05a28b8443be909c892275dd6857;p=bacula%2Fbacula kes Update AUTHORs file kes Increase the default max concurrent jobs to 20 in FD and SD to correspond with the default .conf files. kes Rewrite the Win32 service routines. This eliminates the 3 copies some different, of the same file created by RN when porting the Win32 SD and Dir. kes Rearrange some of the Win32 directories and the placement of the files in them. kes Set DEVELOPER flag in version.h git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5358 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/AUTHORS b/bacula/AUTHORS index 9764f56489..93575d2d9e 100644 --- a/bacula/AUTHORS +++ b/bacula/AUTHORS @@ -18,6 +18,7 @@ Andreas Piesk Andrew Ford Arno Lehmann Bernd Frick +Bill Moran Carlos A. Molina G Carsten Paeth Chris Lee @@ -64,6 +65,7 @@ Morgan Nic Bellamy Nicolas Boichat Olivier Lehmann +Peter Buschmann Peter Eriksson Philippe Chauvat Phil Stracchino diff --git a/bacula/src/filed/filed_conf.c b/bacula/src/filed/filed_conf.c index 3018ac1efd..427bc4bcfb 100644 --- a/bacula/src/filed/filed_conf.c +++ b/bacula/src/filed/filed_conf.c @@ -96,7 +96,7 @@ static RES_ITEM cli_items[] = { {"piddirectory", store_dir, ITEM(res_client.pid_directory), 0, ITEM_REQUIRED, 0}, {"subsysdirectory", store_dir, ITEM(res_client.subsys_directory), 0, 0, 0}, {"scriptsdirectory", store_dir, ITEM(res_client.scripts_directory), 0, 0, 0}, - {"maximumconcurrentjobs", store_pint, ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 10}, + {"maximumconcurrentjobs", store_pint, ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 20}, {"messages", store_res, ITEM(res_client.messages), R_MSGS, 0, 0}, {"sdconnecttimeout", store_time,ITEM(res_client.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30}, {"heartbeatinterval", store_time, ITEM(res_client.heartbeat_interval), 0, ITEM_DEFAULT, 0}, diff --git a/bacula/src/stored/stored_conf.c b/bacula/src/stored/stored_conf.c index d40e212e0c..caace4c970 100644 --- a/bacula/src/stored/stored_conf.c +++ b/bacula/src/stored/stored_conf.c @@ -75,7 +75,7 @@ static RES_ITEM store_items[] = { {"piddirectory", store_dir, ITEM(res_store.pid_directory), 0, ITEM_REQUIRED, 0}, {"subsysdirectory", store_dir, ITEM(res_store.subsys_directory), 0, 0, 0}, {"scriptsdirectory", store_dir, ITEM(res_store.scripts_directory), 0, 0, 0}, - {"maximumconcurrentjobs", store_pint, ITEM(res_store.max_concurrent_jobs), 0, ITEM_DEFAULT, 10}, + {"maximumconcurrentjobs", store_pint, ITEM(res_store.max_concurrent_jobs), 0, ITEM_DEFAULT, 20}, {"heartbeatinterval", store_time, ITEM(res_store.heartbeat_interval), 0, ITEM_DEFAULT, 0}, {"tlsenable", store_bit, ITEM(res_store.tls_enable), 1, 0, 0}, {"tlsrequire", store_bit, ITEM(res_store.tls_require), 1, 0, 0}, diff --git a/bacula/src/version.h b/bacula/src/version.h index 06413385b7..c3ba21d46b 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "2.2.0" -#define BDATE "08 August 2007" -#define LSMDATE "08Aug07" +#define VERSION "2.3.0" +#define BDATE "15 August 2007" +#define LSMDATE "15Aug07" #define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n" #define BYEAR "2007" /* year for copyright messages in progs */ diff --git a/bacula/src/win32/Makefile b/bacula/src/win32/Makefile index 56e8d3198d..2797503ee3 100644 --- a/bacula/src/win32/Makefile +++ b/bacula/src/win32/Makefile @@ -43,7 +43,10 @@ Makefile.inc: Makefile.inc.in echo -e "You must run build-win32-cross-tools and build-dependencies first.\n"; \ exit 1; \ fi ; \ - sed -e "s^@TOPDIR@^$${TOPDIR}^" \ + $(ECHO_CMD)BUILDDIR=`(pwd)`; \ + sed \ + -e "s^@BUILDDIR@^$${BUILDDIR}^" \ + -e "s^@TOPDIR@^$${TOPDIR}^" \ -e "s^@BINDIR@^$${BINDIR}^" \ -e "s^@INCDIR@^$${INCDIR}^" \ -e "s^@DLLDIR@^$${DLLDIR}^" < Makefile.inc.in > $@ diff --git a/bacula/src/win32/Makefile.inc.in b/bacula/src/win32/Makefile.inc.in index 052a6ed9db..c5b651b0c0 100644 --- a/bacula/src/win32/Makefile.inc.in +++ b/bacula/src/win32/Makefile.inc.in @@ -9,6 +9,7 @@ ECHO_CMD = @ +BUILDDIR := @BUILDDIR@ TOPDIR := @TOPDIR@ DEPKGS := $(TOPDIR)/depkgs-mingw32 @@ -45,41 +46,41 @@ INCLUDE_WX := -I$(DEPKGS)/lib/wx_dll/msw -I$(DEPKGS)/include INCLUDE_MYSQL := -I$(DEPKGS)/include/mysql LIBS_PTHREADS := \ - $(DEPKGS)/lib/libpthreadGCE.a + $(DEPKGS)/lib/libpthreadGCE.a LIBS_ZLIB := \ - $(DEPKGS)/lib/libz.a + $(DEPKGS)/lib/libz.a LIBS_MYSQL := \ - $(DEPKGS)/lib/libmysql.a + $(DEPKGS)/lib/libmysql.a LIBS_POSTGRESQL := \ - $(DEPKGS)/lib/libpq.a + $(DEPKGS)/lib/libpq.a LIBS_SQLITE := \ - $(DEPKGS)/lib/libsqlite3.a + $(DEPKGS)/lib/libsqlite3.a LIBS_SSL := \ - $(DEPKGS)/lib/libssl.dll.a + $(DEPKGS)/lib/libssl.dll.a LIBS_CRYPTO := \ - $(DEPKGS)/lib/libcrypto.dll.a + $(DEPKGS)/lib/libcrypto.dll.a LIBS_WX := \ - $(DEPKGS)/lib/wx_dll/libwxmsw27_core.a \ - $(DEPKGS)/lib/wx_dll/libwxbase27.a + $(DEPKGS)/lib/wx_dll/libwxmsw27_core.a \ + $(DEPKGS)/lib/wx_dll/libwxbase27.a LIBS_CATS := \ - $(LIBDIR)/libcats.a + $(LIBDIR)/libcats.a LIBS_BACULA := \ - $(LIBDIR)/libbacula.a + $(LIBDIR)/libbacula.a HAVES := \ - -DHAVE_WIN32 \ - -DHAVE_MINGW \ - -DHAVE_ZLIB_H \ - -DHAVE_LIBZ \ - -DHAVE_CRYPTO \ - -DHAVE_OPENSSL \ - -DHAVE_TLS + -DHAVE_WIN32 \ + -DHAVE_MINGW \ + -DHAVE_ZLIB_H \ + -DHAVE_LIBZ \ + -DHAVE_CRYPTO \ + -DHAVE_OPENSSL \ + -DHAVE_TLS diff --git a/bacula/src/win32/Makefile.rules b/bacula/src/win32/Makefile.rules index 8535f46ce8..72c93c86ba 100644 --- a/bacula/src/win32/Makefile.rules +++ b/bacula/src/win32/Makefile.rules @@ -7,6 +7,7 @@ define clean_obj $(ECHO_CMD)rm -f $(1) $(patsubst %.o,%.d,$(filter-out %.res,$(1))) + $(ECHO_CMD)rm -f $(1) $(addsuffix .d.*,$(basename $(1))) endef define clean_exe diff --git a/bacula/src/win32/compat/getopt.c b/bacula/src/win32/compat/getopt.c index 695c98248d..597ee42a8c 100644 --- a/bacula/src/win32/compat/getopt.c +++ b/bacula/src/win32/compat/getopt.c @@ -40,7 +40,7 @@ #include "getopt.h" -static const char* ID = "$Id$"; +static const char* ID = "$Id: getopt.c 5170 2007-07-13 13:33:34Z kerns $"; char* optarg = NULL; diff --git a/bacula/src/win32/dird/Makefile b/bacula/src/win32/dird/Makefile index de5b657b70..387a6b2828 100644 --- a/bacula/src/win32/dird/Makefile +++ b/bacula/src/win32/dird/Makefile @@ -8,6 +8,7 @@ include ../Makefile.inc INCLUDES = \ + -I. \ $(INCLUDE_PTHREADS) \ $(INCLUDE_BACULA) \ $(INCLUDE_ZLIB) \ @@ -20,8 +21,8 @@ DEFINES = \ -DWINVER=0x500 \ $(HAVES) -vpath %.c ../../dird -vpath %.cpp ../../dird +vpath %.c ../../dird ../libwin32 +vpath %.cpp ../../dird ../libwin32 ########################################################################## @@ -67,16 +68,20 @@ DIRD_OBJS = \ $(OBJDIR)/ua_tree.o \ $(OBJDIR)/ua_update.o \ $(OBJDIR)/verify.o \ - $(OBJDIR)/winservice.o \ - $(OBJDIR)/winmain.o \ - $(OBJDIR)/winres.res + $(OBJDIR)/service.o \ + $(OBJDIR)/main.o \ + $(OBJDIR)/bacula.res ALL_OBJS = $(DIRD_OBJS) DIRD_LIBS = \ $(LIBS_PTHREADS) \ - -lwsock32 + -lole32 \ + -loleaut32 \ + -lwsock32 \ + -luuid \ + -lcomctl32 ###################################################################### diff --git a/bacula/src/win32/dird/bacula.rc b/bacula/src/win32/dird/bacula.rc new file mode 100644 index 0000000000..92b889cb41 --- /dev/null +++ b/bacula/src/win32/dird/bacula.rc @@ -0,0 +1 @@ +#include "../libwin32/bacula.rc" diff --git a/bacula/src/win32/dird/main.cpp b/bacula/src/win32/dird/main.cpp new file mode 100644 index 0000000000..a0cc118b6c --- /dev/null +++ b/bacula/src/win32/dird/main.cpp @@ -0,0 +1,36 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2007-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation, which is + listed in the file LICENSE. + + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ +/* + * Kern Sibbald, August 2007 + * + * Version $Id$ + * + */ + +#include "who.h" +#include "../libwin32/main.cpp" diff --git a/bacula/src/win32/dird/service.cpp b/bacula/src/win32/dird/service.cpp new file mode 100644 index 0000000000..0be0918bb2 --- /dev/null +++ b/bacula/src/win32/dird/service.cpp @@ -0,0 +1,36 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2007-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation, which is + listed in the file LICENSE. + + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ +/* + * Kern Sibbald, August 2007 + * + * Version $Id$ + * + */ + +#include "who.h" +#include "../libwin32/service.cpp" diff --git a/bacula/src/win32/dird/who.h b/bacula/src/win32/dird/who.h new file mode 100644 index 0000000000..cee1572492 --- /dev/null +++ b/bacula/src/win32/dird/who.h @@ -0,0 +1,44 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2007-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation, which is + listed in the file LICENSE. + + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ +/* + * Kern Sibbald, August 2007 + * + * Version $Id$ + * + * This file is pulled in by certain generic routines in libwin32 + * to define the names of the daemon that is being built. + */ + +#define APP_NAME "Bacula-dir" +#define LC_APP_NAME "bacula-dir" +#define APP_DESC "Bacula Director Service" + +#define terminate_app(x) terminate_dird(x) +extern void terminate_dird(int sig); + +#define VSSInit() diff --git a/bacula/src/win32/dird/winbacula.h b/bacula/src/win32/dird/winbacula.h deleted file mode 100644 index 6a0a4e9a57..0000000000 --- a/bacula/src/win32/dird/winbacula.h +++ /dev/null @@ -1,67 +0,0 @@ -// 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 BaculaOptDebug[] = "/debug"; - -const char BaculaRunService[] = "/service"; -const char BaculaRunAsUserApp[] = "/run"; -const char BaculaKillRunningCopy[] = "/kill"; - -const char BaculaInstallService[] = "/install"; -const char BaculaRemoveService[] = "/remove"; - -const char BaculaShowHelp[] = "/help"; - -// Usage string -const char BaculaUsageText[] = "Bacula [/debug] [/service] [/run] [/kill] [/install] [/remove] [/help]\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 deleted file mode 100644 index 281127683f..0000000000 --- a/bacula/src/win32/dird/winmain.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/* - Bacula® - The Network Backup Solution - - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. - - The main author of Bacula is Kern Sibbald, with contributions from - many others, a complete list can be found in the file AUTHORS. - This program is Free Software; you can redistribute it and/or - modify it under the terms of version two of the GNU General Public - License as published by the Free Software Foundation and included - in the file LICENSE. - - 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Bacula® is a registered trademark of John Walker. - The licensor of Bacula is the Free Software Foundation Europe - (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, - Switzerland, email:ftf@fsfeurope.org. -*/ - -#include -#include - -#include "bacula.h" -#include "winbacula.h" -#include "winservice.h" -#include -#include - -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-dir"; -DWORD mainthreadId; -bool opt_debug = false; - -/* Imported variables */ -extern DWORD g_servicethread; - -#define MAX_COMMAND_ARGS 100 -static char *command_args[MAX_COMMAND_ARGS] = {"bacula-dir", 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; - } - - /* Build Unix style argc *argv[] */ - - /* Don't NULL command_args[0] !!! */ - for (i=1;i -#include -#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 "bacula.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// 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 Director for Win32\0" - VALUE "FileVersion", VERSION "\0" - VALUE "InternalName", "Bacula\0" - VALUE "LegalCopyright", "Copyright Free Software Foundation Europe e.V., 1999-2007\0" - VALUE "LegalTrademarks", "Licensed under GNU GPL 2.0\0" - VALUE "OriginalFilename", "bacula-fd.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 -BEGIN - IDI_BACULA "Bacula" -END diff --git a/bacula/src/win32/dird/winservice.cpp b/bacula/src/win32/dird/winservice.cpp deleted file mode 100644 index 1b71b617b5..0000000000 --- a/bacula/src/win32/dird/winservice.cpp +++ /dev/null @@ -1,521 +0,0 @@ -// 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 (C) 2000-2006 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" - -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; - -extern bool opt_debug; - -// SERVICE-MODE ROUTINES - -// Service-mode defines: - -// Internal service name -#define BAC_SERVICENAME "Bacula-dir" - -// 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; - - // 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.")); - } - - 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 char *pszCmdLine) -{ - const int pathlength = 2048; - char path[pathlength]; - char servicecmd[pathlength]; - - // Get the filename of this executable - if (GetModuleFileName(NULL, path, pathlength-(strlen(BaculaRunService)+2)) == 0) { - MessageBox(NULL, _("Unable to install Bacula Director service"), szAppName, MB_ICONEXCLAMATION | MB_OK); - return 0; - } - - // Append the service-start flag to the end of the path: - if ((int)strlen(path) + 5 + (int)strlen(BaculaRunService) + (int)strlen(pszCmdLine) < pathlength) { - sprintf(servicecmd, "\"%s\" %s %s", path, BaculaRunService, pszCmdLine); - } 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; - } - - 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 Director service was not installed"), - szAppName, MB_ICONEXCLAMATION | MB_OK); - return 0; - } - - // 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 Director service could not be installed"), - szAppName, MB_ICONEXCLAMATION | MB_OK); - return 0; - } - - set_service_description(hsrvmanager,hservice, -_("Provides director services. Bacula -- the network backup solution.")); - - CloseServiceHandle(hsrvmanager); - CloseServiceHandle(hservice); - - // Everything went fine - if (opt_debug) { - MessageBox(NULL, - _("The Bacula Director 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); - } - return 0; -} - - -// SERVICE REMOVE ROUTINE -int -bacService::RemoveService() -{ - 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 Director service could not be stopped"), szAppName, MB_ICONEXCLAMATION | MB_OK); - } - } - - // Now remove the service from the SCM - if(DeleteService(hservice)) { - if (opt_debug) { - MessageBox(NULL, _("The Bacula Director service has been removed"), szAppName, MB_ICONINFORMATION | MB_OK); - } - } else { - MessageBox(NULL, _("The Bacula Director service could not be removed"), szAppName, MB_ICONEXCLAMATION | MB_OK); - } - - CloseServiceHandle(hservice); - } else { - MessageBox(NULL, _("The Bacula Director service could not be found"), szAppName, MB_ICONEXCLAMATION | MB_OK); - } - - CloseServiceHandle(hsrvmanager); - } else { - MessageBox(NULL, _("The SCM could not be contacted - the Bacula Director service was not removed"), szAppName, MB_ICONEXCLAMATION | MB_OK); - } - 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 deleted file mode 100644 index 841d85c6e6..0000000000 --- a/bacula/src/win32/dird/winservice.h +++ /dev/null @@ -1,69 +0,0 @@ -// 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: - // 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(const char *pszCmdLine); - - // Routine to remove the Apcupsd service from the local machine - static int RemoveService(); - - // SERVICE SUPPORT FUNCTIONS - - // 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(); -}; - -#endif diff --git a/bacula/src/win32/filed/Makefile b/bacula/src/win32/filed/Makefile index 72f778f549..e1327b4f70 100644 --- a/bacula/src/win32/filed/Makefile +++ b/bacula/src/win32/filed/Makefile @@ -17,6 +17,7 @@ INCLUDES = \ $(INCLUDE_ICONS) DEFINES = \ + -DHAVE_TRAY_MONITOR \ -DUSING_DLL \ -DWIN32_VSS \ -DWINVER=0x500 \ @@ -43,12 +44,12 @@ FILED_OBJS = \ $(OBJDIR)/vss_XP.o \ $(OBJDIR)/vss_W2K3.o \ $(OBJDIR)/vss_Vista.o \ - $(OBJDIR)/winabout.o \ - $(OBJDIR)/winservice.o \ - $(OBJDIR)/winstat.o \ - $(OBJDIR)/wintray.o \ - $(OBJDIR)/winmain.o \ - $(OBJDIR)/winres.res + $(OBJDIR)/aboutDialog.o \ + $(OBJDIR)/service.o \ + $(OBJDIR)/statusDialog.o \ + $(OBJDIR)/trayMonitor.o \ + $(OBJDIR)/main.o \ + $(OBJDIR)/bacula.res ALL_OBJS = $(FILED_OBJS) diff --git a/bacula/src/win32/filed/bacula.rc b/bacula/src/win32/filed/bacula.rc new file mode 100644 index 0000000000..92b889cb41 --- /dev/null +++ b/bacula/src/win32/filed/bacula.rc @@ -0,0 +1 @@ +#include "../libwin32/bacula.rc" diff --git a/bacula/src/win32/filed/main.cpp b/bacula/src/win32/filed/main.cpp new file mode 100644 index 0000000000..a0cc118b6c --- /dev/null +++ b/bacula/src/win32/filed/main.cpp @@ -0,0 +1,36 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2007-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation, which is + listed in the file LICENSE. + + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ +/* + * Kern Sibbald, August 2007 + * + * Version $Id$ + * + */ + +#include "who.h" +#include "../libwin32/main.cpp" diff --git a/bacula/src/win32/filed/service.cpp b/bacula/src/win32/filed/service.cpp new file mode 100644 index 0000000000..0be0918bb2 --- /dev/null +++ b/bacula/src/win32/filed/service.cpp @@ -0,0 +1,36 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2007-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation, which is + listed in the file LICENSE. + + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ +/* + * Kern Sibbald, August 2007 + * + * Version $Id$ + * + */ + +#include "who.h" +#include "../libwin32/service.cpp" diff --git a/bacula/src/win32/filed/trayMonitor.cpp b/bacula/src/win32/filed/trayMonitor.cpp new file mode 100644 index 0000000000..71be7ac251 --- /dev/null +++ b/bacula/src/win32/filed/trayMonitor.cpp @@ -0,0 +1,36 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2007-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation, which is + listed in the file LICENSE. + + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ +/* + * Kern Sibbald, August 2007 + * + * Version $Id$ + * + */ + +#include "who.h" +#include "../libwin32/trayMonitor.cpp" diff --git a/bacula/src/win32/filed/who.h b/bacula/src/win32/filed/who.h new file mode 100644 index 0000000000..e5430a6cdf --- /dev/null +++ b/bacula/src/win32/filed/who.h @@ -0,0 +1,43 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2007-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation, which is + listed in the file LICENSE. + + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ +/* + * Kern Sibbald, August 2007 + * + * Version $Id$ + * + * This file is pulled in by certain generic routines in libwin32 + * to define the names of the daemon that is being built. + */ + +#define APP_NAME "Bacula-fd" +#define LC_APP_NAME "bacula-fd" +#define APP_DESC "Bacula File Service" + +#define terminate_app(x) terminate_filed(x) +extern void terminate_filed(int sig); +extern void VSSInit(); diff --git a/bacula/src/win32/filed/winmain.cpp b/bacula/src/win32/filed/winmain.cpp deleted file mode 100644 index 9ce6b74fc0..0000000000 --- a/bacula/src/win32/filed/winmain.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/* - This file is patterned after the VNC Win32 code by ATT -*/ -/* - Bacula® - The Network Backup Solution - - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. - - The main author of Bacula is Kern Sibbald, with contributions from - many others, a complete list can be found in the file AUTHORS. - This program is Free Software; you can redistribute it and/or - modify it under the terms of version two of the GNU General Public - License as published by the Free Software Foundation and included - in the file LICENSE. - - 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Bacula® is a registered trademark of John Walker. - The licensor of Bacula is the Free Software Foundation Europe - (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, - Switzerland, email:ftf@fsfeurope.org. -*/ - -#include -#include - -#include "bacula.h" -#include "winbacula.h" -#include "wintray.h" -#include "winservice.h" -#include -#include - -#undef _WIN32_IE -#define _WIN32_IE 0x0401 -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#include - -extern int BaculaMain(int argc, char *argv[]); -extern void terminate_filed(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 *, ...); -extern void VSSInit(); - -/* Globals */ -HINSTANCE hAppInstance; -const char *szAppName = "Bacula-fd"; -DWORD mainthreadId; -bool opt_debug = false; - -/* Imported variables */ -extern DWORD g_servicethread; - -#define MAX_COMMAND_ARGS 100 -static char *command_args[MAX_COMMAND_ARGS] = {"bacula-fd", 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(); - - INITCOMMONCONTROLSEX initCC = { - sizeof(INITCOMMONCONTROLSEX), - ICC_STANDARD_CLASSES - }; - - InitCommonControlsEx(&initCC); - - /* - * 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; - } - - /* Build Unix style argc *argv[] */ - - /* Don't NULL command_args[0] !!! */ - for (i=1;i