Changeset 3059


Ignore:
Timestamp:
22/01/2012 16:17:36 (4 months ago)
Author:
chris
Message:

Split option processing out of Daemon::Main() to ease use of Daemon class in tests.

Location:
box/trunk/lib/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/server/Daemon.cpp

    r3030 r3059  
    330330        mAppName = argv[0]; 
    331331 
     332        int ret = ProcessOptions(argc, argv); 
     333        if (ret != 0) 
     334        { 
     335                return ret; 
     336        } 
     337 
     338        return Main(mConfigFileName); 
     339} 
     340 
     341// -------------------------------------------------------------------------- 
     342// 
     343// Function 
     344//              Name:    Daemon::ProcessOptions(int argc, const char *argv[]) 
     345//              Purpose: Parses command-line options. Useful when you have 
     346//                       a local Daemon object and don't intend to fork() 
     347//                       or call Main(). 
     348//              Created: 2008/11/04 
     349// 
     350// -------------------------------------------------------------------------- 
     351 
     352int Daemon::ProcessOptions(int argc, const char *argv[]) 
     353{ 
    332354        #ifdef BOX_RELEASE_BUILD 
    333         mLogLevel = Log::NOTICE; // need an int to do math with 
     355        mLogLevel = Log::NOTICE; 
    334356        #else 
    335         mLogLevel = Log::INFO; // need an int to do math with 
     357        mLogLevel = Log::INFO; 
    336358        #endif 
    337359 
     
    394416        } 
    395417 
    396         return Main(mConfigFileName); 
     418        return 0; 
    397419} 
    398420 
  • box/trunk/lib/server/Daemon.h

    r2806 r3059  
    4343        virtual int Main(const std::string& rDefaultConfigFile, int argc, 
    4444                const char *argv[]); 
     45        virtual int ProcessOptions(int argc, const char *argv[]); 
    4546 
    4647        /* override this Main() if you want custom option processing: */ 
Note: See TracChangeset for help on using the changeset viewer.