Пример #1
0
bool ServerCommandLine::parse(const TCHAR *commandLine)
{
  CommandLineFormat format[] = {
    { _T("-help"), NO_ARG },
    { _T("-h"), NO_ARG },
    { _T("-?"), NO_ARG },
    { _T("/help"), NO_ARG },
    { _T("/h"), NO_ARG },
    { _T("/?"), NO_ARG },
    { RUN_SERVER_KEY, NO_ARG },
    { RUN_SERVER_PORTABLE_KEY, NO_ARG },
    { SERVER_NAME_KEY,  NEEDS_ARG },
    { VNC_INI_DIRECTORY_PATH,  NEEDS_ARG },



  };

  if (!CommandLine::parse(format, sizeof(format) / sizeof(CommandLineFormat), commandLine)) {
    return false;
  }
  if (showHelp() && optionSpecified(RUN_SERVER_KEY) && optionSpecified(RUN_SERVER_PORTABLE_KEY)) {
    return false;
  }

  return true;
}
Пример #2
0
void ControlCommandLine::setVncPort()
{
    if ( ( hasSetVncPortFlag() && ! hasPortableFlag() && m_foundKeys.size() > 1 ) ||
        ( hasSetVncPortFlag() &&  hasPortableFlag()  && ! hasVncIniDirectoryFlag() && m_foundKeys.size() > 2 )  ||
        ( hasSetVncPortFlag() &&  hasPortableFlag() && hasVncIniDirectoryFlag() && m_foundKeys.size() > 3 ) ) {
            throw CommandLineFormatException();
    } else {
        optionSpecified(SET_VNC_PORT, &m_vncPort);
        optionSpecified(VNC_INI_DIRECTORY, &m_vncIniDirectoryPath);

    }
}
Пример #3
0
void ControlCommandLine::setVncPortAndPrimaryPassword()
{
    if ( ( hasSetVncPortFlag() && hasSetVncPasswordFlag() && ! hasPortableFlag() && m_foundKeys.size() > 2 ) ||
        ( hasSetVncPortFlag() && hasSetVncPasswordFlag() &&  hasPortableFlag()  && ! hasVncIniDirectoryFlag() && m_foundKeys.size() > 3 )  ||
        ( hasSetVncPortFlag() && hasSetVncPasswordFlag() &&  hasPortableFlag() && hasVncIniDirectoryFlag() && m_foundKeys.size() > 4 ) ) {
            throw CommandLineFormatException();
    } else {
        optionSpecified(SET_PRIMARY_VNC_PASSWORD, &m_vncPassword);
        optionSpecified(SET_CONTROL_PASSWORD, &m_controlPassword);
        optionSpecified(SET_VNC_PORT, &m_vncPort);
        optionSpecified(VNC_INI_DIRECTORY, &m_vncIniDirectoryPath);
    }
}
void QueryConnectionCommandLine::parse(const CommandLineArgs *commandLine)
{
  CommandLineFormat format[] = {
    { QUERY_CONNECTION, NO_ARG },
    { PEER_ADDR, NEEDS_ARG},
    { TIMEOUT, NEEDS_ARG },
    { ACCEPT, NO_ARG }
  };

  if (!CommandLine::parse(format, sizeof(format) / sizeof(CommandLineFormat), commandLine)) {
    throw Exception(_T("Wrong command line format"));
  }

  if (!optionSpecified(QUERY_CONNECTION)) {
    throw Exception(_T("-queryconnection flag is not specified"));
  }

  StringStorage timeoutStr;

  if (optionSpecified(TIMEOUT, &timeoutStr) &&
      !StringParser::parseInt(timeoutStr.getString(), (int *)&m_timeout)) {
    throw Exception(_T("Invalid timeout"));
  }
}
bool ServerCommandLine::parse(const CommandLineArgs *cmdArgs)
{
  CommandLineFormat format[] = {
    { _T("-help"), NO_ARG },
    { _T("-h"), NO_ARG },
    { _T("-?"), NO_ARG },
    { _T("/help"), NO_ARG },
    { _T("/h"), NO_ARG },
    { _T("/?"), NO_ARG },
    { _T("-run"), NO_ARG }
  };

  if (!CommandLine::parse(format, sizeof(format) / sizeof(CommandLineFormat), cmdArgs)) {
    return false;
  }
  if (showHelp() && optionSpecified(_T("-run"))) {
    return false;
  }

  return true;
}
bool ControlCommandLine::hasCheckServicePasswords()
{
  return optionSpecified(CHECK_SERVICE_PASSWORDS);
}
bool ControlCommandLine::hasShareWindow()
{
  return optionSpecified(SHARE_WINDOW);
}
bool ControlCommandLine::hasShareRect()
{
  return optionSpecified(SHARE_RECT);
}
bool ControlCommandLine::isSlave()
{
  return optionSpecified(SLAVE_MODE);
}
bool ControlCommandLine::hasControlServiceFlag()
{
  return optionSpecified(CONTROL_SERVICE);
}
bool ControlCommandLine::hasConfigServiceFlag()
{
  return optionSpecified(CONFIG_SERVICE);
}
Пример #12
0
bool ControlCommandLine::hasSetVncPortAndPrimaryPasswdFlag()
{
    return optionSpecified(SET_VNC_PORT) && optionSpecified(SET_PRIMARY_VNC_PASSWORD);
}
Пример #13
0
bool ControlCommandLine::hasVncIniDirectoryFlag()
{
    return optionSpecified(VNC_INI_DIRECTORY);
}
Пример #14
0
bool ControlCommandLine::hasSetVncPortFlag()
{
    return optionSpecified(SET_VNC_PORT);
}
Пример #15
0
bool ControlCommandLine::hasPortableFlag()
{
    return optionSpecified(PORTABLE);
}
bool ControlCommandLine::hasSetControlPasswordFlag()
{
  return optionSpecified(SET_CONTROL_PASSWORD);
}
bool ControlCommandLine::hasConfigAppFlag()
{
  return optionSpecified(CONFIG_APPLICATION);
}
Пример #18
0
void ControlCommandLine::parse(const TCHAR *commandLine)
{
  CommandLineFormat fmt[] = {
    { PASSWORD_FILE, NEEDS_ARG },
    { CONFIG_RELOAD, NO_ARG },
    { DISCONNECT_ALL, NO_ARG },
    { CONNECT, NEEDS_ARG },
    { SHUTDOWN, NO_ARG },
    { SET_PRIMARY_VNC_PASSWORD, NEEDS_ARG },
    { SET_CONTROL_PASSWORD, NEEDS_ARG },
    { CONTROL_SERVICE, NO_ARG },
    { CONTROL_APPLICATION, NO_ARG },
    { CONFIG_APPLICATION, NO_ARG },
    { CONFIG_SERVICE, NO_ARG },
    { SLAVE_MODE, NO_ARG },
    { DONT_ELEVATE, NO_ARG },
    { PORTABLE, NO_ARG },
    { SET_VNC_PORT, NEEDS_ARG },
    { VNC_INI_DIRECTORY, NEEDS_ARG },

  };

  if (!CommandLine::parse(fmt, sizeof(fmt) / sizeof(CommandLineFormat), commandLine)) {
    throw CommandLineFormatException();
  }

  if (hasConfigServiceFlag() && ((int)m_foundKeys.size() > (optionSpecified(DONT_ELEVATE) ? 2 : 1))) {
    throw CommandLineFormatException();
  }

  if ( ( hasConfigAppFlag()  && ! hasPortableFlag() && m_foundKeys.size() > 1  ) ||
       ( hasConfigAppFlag()  &&  hasPortableFlag()  && m_foundKeys.size() > 2 ) ) {
    throw CommandLineFormatException();
  }

  bool hasPassFile = hasPasswordFile();
  if (hasPassFile) {
    optionSpecified(PASSWORD_FILE, &m_passwordFile);
  }

  if (hasKillAllFlag() && hasReloadFlag()) {
    throw CommandLineFormatException();
  }

  if (hasConnectFlag()) {
    optionSpecified(CONNECT, &m_connectHostName);
  }

  if(hasSetVncPortAndPrimaryPasswdFlag()) {
      setVncPortAndPrimaryPassword();
  }

  if ((hasControlServiceFlag() || hasControlAppFlag()) && (isSlave()) && (m_foundKeys.size() > 2)) {
    throw CommandLineFormatException();
  }

  bool hasNotSlaveControl = (hasControlServiceFlag() || hasControlAppFlag()) && !isSlave();
  if ((hasNotSlaveControl && !hasPassFile && m_foundKeys.size() > 2) ||
      (hasNotSlaveControl && hasPassFile && m_foundKeys.size() != 3)) {
    throw CommandLineFormatException();
  }

  if(hasSetVncPortFlag() && ! hasSetVncPasswordFlag()) {
      setVncPort();
  }

  if(! hasSetVncPortFlag() && ( hasSetVncPasswordFlag() || hasSetControlPasswordFlag()) ) {
      setVncOrControlPassword();
  }

  if (m_foundKeys.size() == 0) {
    throw CommandLineFormatException();
  }
}
bool ControlCommandLine::hasDontElevateFlag()
{
  return optionSpecified(DONT_ELEVATE);
}
bool ControlCommandLine::hasPasswordFile()
{
  return optionSpecified(PASSWORD_FILE);
}
bool ControlCommandLine::hasControlAppFlag()
{
  return optionSpecified(CONTROL_APPLICATION);
}
bool ControlCommandLine::hasReloadFlag()
{
  return optionSpecified(CONFIG_RELOAD);
}
bool ControlCommandLine::hasSharePrimaryFlag()
{
  return optionSpecified(SHARE_PRIMARY);
}
bool ControlCommandLine::hasKillAllFlag()
{
  return optionSpecified(DISCONNECT_ALL);
}
bool ControlCommandLine::hasShareDisplay()
{
  return optionSpecified(SHARE_DISPLAY);
}
bool ControlCommandLine::hasConnectFlag()
{
  return optionSpecified(CONNECT);
}
bool ControlCommandLine::hasShareFull()
{
  return optionSpecified(SHARE_FULL);
}
bool ControlCommandLine::hasShutdownFlag()
{
  return optionSpecified(SHUTDOWN);
}
void ControlCommandLine::parse(const CommandLineArgs *cmdArgs)
{
  CommandLineFormat fmt[] = {
    { PASSWORD_FILE, NEEDS_ARG },
    { CONFIG_RELOAD, NO_ARG },
    { DISCONNECT_ALL, NO_ARG },
    { CONNECT, NEEDS_ARG },
    { SHUTDOWN, NO_ARG },
    { SET_PRIMARY_VNC_PASSWORD, NEEDS_ARG },
    { SET_CONTROL_PASSWORD, NEEDS_ARG },
    { CHECK_SERVICE_PASSWORDS, NO_ARG },
    { SHARE_PRIMARY, NO_ARG },
    { SHARE_RECT, NEEDS_ARG },
    { SHARE_DISPLAY, NEEDS_ARG },
    { SHARE_WINDOW, NEEDS_ARG },
    { SHARE_FULL, NO_ARG },
    { CONTROL_SERVICE, NO_ARG },
    { CONTROL_APPLICATION, NO_ARG },
    { CONFIG_APPLICATION, NO_ARG },
    { CONFIG_SERVICE, NO_ARG },
    { SLAVE_MODE, NO_ARG },
    { DONT_ELEVATE, NO_ARG }
  };

  if (!CommandLine::parse(fmt, sizeof(fmt) / sizeof(CommandLineFormat), cmdArgs)) {
    throw CommandLineFormatException();
  }

  if (hasConfigServiceFlag() && ((int)m_foundKeys.size() > (optionSpecified(DONT_ELEVATE) ? 2 : 1))) {
    throw CommandLineFormatException();
  }

  if (hasConfigAppFlag() && m_foundKeys.size() > 1) {
    throw CommandLineFormatException();
  }

  bool hasPassFile = hasPasswordFile();
  if (hasPassFile) {
    optionSpecified(PASSWORD_FILE, &m_passwordFile);
  }

  if (hasShareRect()) {
    StringStorage strRect;
    optionSpecified(SHARE_RECT, &strRect);
    parseRectCoordinates(&strRect);
  }

  if (hasShareDisplay()) {
    StringStorage strDisplayNumber;
    optionSpecified(SHARE_DISPLAY, &strDisplayNumber);
    parseDisplayNumber(&strDisplayNumber);
  }

  if (hasShareWindow()) {
    optionSpecified(SHARE_WINDOW, &m_windowHeaderName);
  }

  if (hasKillAllFlag() && hasReloadFlag()) {
    throw CommandLineFormatException();
  }

  if (hasConnectFlag()) {
    optionSpecified(CONNECT, &m_connectHostName);
  }

  if ((hasSetVncPasswordFlag() || hasSetControlPasswordFlag()) && m_foundKeys.size() > 1) {
    throw CommandLineFormatException();
  } else {
    optionSpecified(SET_CONTROL_PASSWORD, &m_controlPassword);
    optionSpecified(SET_PRIMARY_VNC_PASSWORD, &m_vncPassword);
  }

  if ((hasControlServiceFlag() || hasControlAppFlag()) && (isSlave()) && (m_foundKeys.size() > 2)) {
    throw CommandLineFormatException();
  }

  bool hasNotSlaveControl = (hasControlServiceFlag() || hasControlAppFlag()) && !isSlave();
  if ((hasNotSlaveControl && !hasPassFile && m_foundKeys.size() > 2) ||
      (hasNotSlaveControl && hasPassFile && m_foundKeys.size() != 3)) {
    throw CommandLineFormatException();
  }

  if (m_foundKeys.size() == 0) {
    throw CommandLineFormatException();
  }
}
bool ControlCommandLine::hasSetVncPasswordFlag()
{
  return optionSpecified(SET_PRIMARY_VNC_PASSWORD);
}