Changeset 70f2d7b in nscp for NSClient++.cpp


Ignore:
Timestamp:
03/29/06 22:19:32 (7 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
76aafc4
Parents:
aabbd97
Message:

Updated with reg settings (take 1)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NSClient++.cpp

    rf42280d r70f2d7b  
    2020#include <Socket.h> 
    2121#include <b64/b64.h> 
     22#include <config.h> 
    2223 
    2324 
     
    6566      g_bConsoleLog = true; 
    6667      std::string password; 
    67       Settings::getInstance()->setFile(mainClient.getBasePath() + "NSC.ini"); 
     68      try { 
     69        Settings::getInstance()->setFile(mainClient.getBasePath() + "NSC.ini"); 
     70      } catch (SettingsException e) { 
     71        std::cout << "Could not find settings: " << e.getMessage() << std::endl;; 
     72        return 1; 
     73      } 
    6874      std::cout << "Enter password to encrypt (has to be a single word): "; 
    6975      std::cin >> password; 
     
    97103#endif 
    98104      g_bConsoleLog = true; 
    99       mainClient.InitiateService(); 
     105      if (!mainClient.InitiateService()) { 
     106        LOG_ERROR_STD("Service *NOT* started!"); 
     107        return -1; 
     108      } 
     109      LOG_MESSAGE_STD("Using settings from: " + Settings::getInstance()->getActiveType()); 
    100110      LOG_MESSAGE("Enter command to inject or exit to terminate..."); 
    101111      std::string s = ""; 
     
    146156 * When the program is started as a service this will be the entry point. 
    147157 */ 
    148 void NSClientT::InitiateService(void) { 
    149   Settings::getInstance()->setFile(getBasePath() + "NSC.ini"); 
    150  
     158bool NSClientT::InitiateService(void) { 
     159  try { 
     160    Settings::getInstance()->setFile(getBasePath() + "NSC.ini"); 
     161  } catch (SettingsException e) { 
     162    LOG_ERROR_STD("Could not find settings: " + e.getMessage()); 
     163    return false; 
     164  } 
    151165  try { 
    152166    simpleSocket::WSAStartup(); 
    153167  } catch (simpleSocket::SocketException e) { 
    154168    LOG_ERROR_STD("Uncaught exception: " + e.getMessage()); 
     169    return false; 
    155170  } 
    156171 
     
    161176    } catch(const NSPluginException& e) { 
    162177      LOG_ERROR_STD("Exception raised: " + e.error_ + " in module: " + e.file_); 
     178      return false; 
    163179    } 
    164180  } 
    165181  loadPlugins(); 
     182  return true; 
    166183} 
    167184/** 
Note: See TracChangeset for help on using the changeset viewer.