[Box Backup-dev] COMMIT r734 - box/chris/merge/bin/bbackupd
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Wed, 9 Aug 2006 12:51:33 +0000 (GMT)
Author: chris
Date: 2006-08-09 12:51:32 +0000 (Wed, 09 Aug 2006)
New Revision: 734
Modified:
box/chris/merge/bin/bbackupd/Win32ServiceFunctions.h
box/chris/merge/bin/bbackupd/bbackupd.cpp
Log:
* bbackupd.cpp
* Win32ServiceFunctions.h
- Revert to trunk
Modified: box/chris/merge/bin/bbackupd/Win32ServiceFunctions.h
===================================================================
--- box/chris/merge/bin/bbackupd/Win32ServiceFunctions.h 2006-08-09 12:43:59 UTC (rev 733)
+++ box/chris/merge/bin/bbackupd/Win32ServiceFunctions.h 2006-08-09 12:51:32 UTC (rev 734)
@@ -12,8 +12,8 @@
#ifndef WIN32SERVICEFUNCTIONS_H
#define WIN32SERVICEFUNCTIONS_H
-int RemoveService(void);
-int InstallService(const char* pConfigFilePath);
-void OurService(char* pConfigFileName);
+void RemoveService(void);
+void InstallService(void);
+void OurService(void);
#endif
Modified: box/chris/merge/bin/bbackupd/bbackupd.cpp
===================================================================
--- box/chris/merge/bin/bbackupd/bbackupd.cpp 2006-08-09 12:43:59 UTC (rev 733)
+++ box/chris/merge/bin/bbackupd/bbackupd.cpp 2006-08-09 12:51:32 UTC (rev 734)
@@ -19,7 +19,7 @@
#include "Win32ServiceFunctions.h"
#include "Win32BackupService.h"
- extern Win32BackupService* gpDaemonService;
+ extern Win32BackupService gDaemonService;
#endif
int main(int argc, const char *argv[])
@@ -28,7 +28,7 @@
#ifdef WIN32
- ::openlog("Box Backup (bbackupd)", LOG_PID, LOG_LOCAL6);
+ ::openlog("Box Backup (bbackupd)", 0, 0);
if(argc == 2 &&
(::strcmp(argv[1], "--help") == 0 ||
@@ -40,25 +40,32 @@
}
if(argc == 2 && ::strcmp(argv[1], "-r") == 0)
{
- return RemoveService();
+ RemoveService();
+ return 0;
}
- if((argc == 2 || argc == 3) && ::strcmp(argv[1], "-i") == 0)
+ if(argc == 2 && ::strcmp(argv[1], "-i") == 0)
{
- const char* config = NULL;
- if (argc == 3)
- {
- config = argv[2];
- }
- return InstallService(config);
+ InstallService();
+ return 0;
}
bool runAsWin32Service = false;
- if (argc >= 2 && ::strcmp(argv[1], "--service") == 0)
+ if (argc == 2 && ::strcmp(argv[1], "--service") == 0)
{
runAsWin32Service = true;
}
+
+ // Under win32 we must initialise the Winsock library
+ // before using sockets
+
+ WSADATA info;
- gpDaemonService = new Win32BackupService();
+ if (WSAStartup(0x0101, &info) == SOCKET_ERROR)
+ {
+ // box backup will not run without sockets
+ ::syslog(LOG_ERR, "Failed to initialise Windows Sockets");
+ THROW_EXCEPTION(BackupStoreException, Internal)
+ }
EnableBackupRights();
@@ -66,33 +73,20 @@
if (runAsWin32Service)
{
- syslog(LOG_INFO, "Box Backup service starting");
-
- char* config = NULL;
- if (argc >= 3)
- {
- config = strdup(argv[2]);
- }
-
- OurService(config);
-
- if (config)
- {
- free(config);
- }
-
- syslog(LOG_INFO, "Box Backup service shut down");
+ syslog(LOG_INFO,"Starting Box Backup Service");
+ OurService();
}
else
{
- ExitCode = gpDaemonService->Main(
+ ExitCode = gDaemonService.Main(
BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv);
}
+ // Clean up our sockets
+ WSACleanup();
+
::closelog();
- delete gpDaemonService;
-
return ExitCode;
#else // !WIN32