[Box Backup-commit] COMMIT r3059 - box/trunk/lib/server
subversion at boxbackup.org
subversion at boxbackup.org
Sun Jan 22 16:17:36 GMT 2012
Author: chris
Date: 2012-01-22 16:17:36 +0000 (Sun, 22 Jan 2012)
New Revision: 3059
Modified:
box/trunk/lib/server/Daemon.cpp
box/trunk/lib/server/Daemon.h
Log:
Split option processing out of Daemon::Main() to ease use of Daemon class in tests.
Modified: box/trunk/lib/server/Daemon.cpp
===================================================================
--- box/trunk/lib/server/Daemon.cpp 2012-01-19 20:44:45 UTC (rev 3058)
+++ box/trunk/lib/server/Daemon.cpp 2012-01-22 16:17:36 UTC (rev 3059)
@@ -329,10 +329,32 @@
mConfigFileName = rDefaultConfigFile;
mAppName = argv[0];
+ int ret = ProcessOptions(argc, argv);
+ if (ret != 0)
+ {
+ return ret;
+ }
+
+ return Main(mConfigFileName);
+}
+
+// --------------------------------------------------------------------------
+//
+// Function
+// Name: Daemon::ProcessOptions(int argc, const char *argv[])
+// Purpose: Parses command-line options. Useful when you have
+// a local Daemon object and don't intend to fork()
+// or call Main().
+// Created: 2008/11/04
+//
+// --------------------------------------------------------------------------
+
+int Daemon::ProcessOptions(int argc, const char *argv[])
+{
#ifdef BOX_RELEASE_BUILD
- mLogLevel = Log::NOTICE; // need an int to do math with
+ mLogLevel = Log::NOTICE;
#else
- mLogLevel = Log::INFO; // need an int to do math with
+ mLogLevel = Log::INFO;
#endif
if (argc == 2 && strcmp(argv[1], "/?") == 0)
@@ -393,7 +415,7 @@
new FileLogger(mLogFile, mLogFileLevel));
}
- return Main(mConfigFileName);
+ return 0;
}
// --------------------------------------------------------------------------
Modified: box/trunk/lib/server/Daemon.h
===================================================================
--- box/trunk/lib/server/Daemon.h 2012-01-19 20:44:45 UTC (rev 3058)
+++ box/trunk/lib/server/Daemon.h 2012-01-22 16:17:36 UTC (rev 3059)
@@ -42,6 +42,7 @@
virtual int Main(const std::string& rDefaultConfigFile, int argc,
const char *argv[]);
+ virtual int ProcessOptions(int argc, const char *argv[]);
/* override this Main() if you want custom option processing: */
virtual int Main(const std::string &rConfigFile);
More information about the Boxbackup-commit
mailing list