示例#1
1
void ViewerCmdLine::parseOptionsFile()
{
  StringStorage pathToIniFile = m_options[OPTIONS_FILE];
  if (pathToIniFile.findChar(_T('\\')) == -1) {
    StringStorage newPathToIniFile;
    newPathToIniFile.format(_T(".\\%s"), pathToIniFile.getString());
    pathToIniFile = newPathToIniFile;
  }
  IniFileSettingsManager sm(pathToIniFile.getString());
  sm.setApplicationName(_T("connection"));

  StringStorage host;
  if (!sm.getString(_T("host"), &host)) {
    throw CommandLineFormatException(_T("Could not read options file."));
  }
  StringStorage port;
  if (sm.getString(_T("port"), &port)) {
    StringStorage hostString;
    hostString.format(_T("%s:%s"), host.getString(), port.getString());
    m_conData->setHost(&hostString);
  } else {
    m_conData->setHost(&host);
  }

  StringStorage password;
  sm.getString(_T("password"), &password);
  if (!password.isEmpty()) {
    m_conData->setCryptedPassword(&password);
  } else {
    parsePassword();
  }
  
  sm.setApplicationName(_T("options"));
  m_conConf->loadFromStorage(&sm);
}
示例#2
0
void ViewerCmdLine::parseHostArg()
{
  StringStorage host;
  m_wpcl.getArgument(1, &host);

  if (host.findChar(_T(':')) != -1) {
    m_conData->setHost(&host);
  } else {
   if (isPresent(PORT)) {
     StringStorage hostPort;

     hostPort.format(_T("%s::%s"), host.getString(),
                                  m_options[PORT].getString());
     m_conData->setHost(&hostPort);
   }
   m_conData->setHost(&host);
  }
}