Exemple #1
1
void ViewerCmdLine::parse()
{
  const CmdLineOption options[] = {
    HELP,
    HELP_SHORT,
    OPTIONS_FILE,
    LISTEN,
    HOST,
    PORT,
    PASSWORD,
    SHOW_CONTROLS,
    VIEW_ONLY,
    USE_CLIPBOARD,
    SCALE,
    FULL_SCREEN,
    WARN_FULL_SCREEN,
    ENCODING,
    COPY_RECT,
    MOUSE_CURSOR,
    MOUSE_LOCAL,
    MOUSE_SWAP,
    JPEG_IMAGE_QUALITY,
    COMPRESSION_LEVEL
  };

  if (!processCmdLine(&options[0], sizeof(options) / sizeof(CmdLineOption))) {
    throw CommandLineFormatException();
  }

  if (isHelpPresent()) {
    throw CommandLineFormatHelp();
  }


  if (m_wpcl.getArgumentsCount() > 2) {
    throw CommandLineFormatException();
  }

  if (m_wpcl.getArgumentsCount() > 1) {
    if (isPresent(ViewerCmdLine::HOST)) {
      throw CommandLineFormatException();
    }
  }

  if (isPresent(ViewerCmdLine::OPTIONS_FILE)) {
    parseOptionsFile();
  } else {
    if (isPresent(ViewerCmdLine::LISTEN)) {
      *m_isListening = true;
    } else {
      if (!parseHost()) {
        throw CommandLineFormatException();
      }
    }
  }
  parsePassword();
  parseEncoding();
  parseMouseShape();
  parseMouseCursor();
  parseScale();
  parseFullScreen();
  parseCompressionLevel();
  parseWarnFullScr();
  parseMouseSwap();
  parseUseClipboard();
  parseShowControl();
  parseCopyRect();
  parseViewOnly();
  parseJpegImageQuality();
}
Exemple #2
0
int eString::readEncodingFile()
{
	FILE *f = fopen(CONFIGDIR "/enigma/encoding.conf", "rt");
	if (f)
	{

		CountryCodeDefaultMapping.clear();
		TransponderDefaultMapping.clear();
		TransponderUseTwoCharMapping.clear();
		char *line = (char*) malloc(256);
		size_t bufsize=256;
		int count, i;
		int tsid, onid, encoding;
		bool parsed;
		while( getline(&line, &bufsize, f) != -1 )
		{
			if ( line[0] == '#' )
				continue;

			char sec[4][64];
			count = sscanf(line, "%s%s%s%s", sec[0], sec[1], sec[2],sec[3]);
			for (i = 0; i < count; i++)
			{
				if (sec[i][0] == '#')
				{
					count = i;
					break;
				}
			}
			parsed = false;
			if (count == 2)
			{
				if (strlen(sec[0]) == 3 && (encoding = parseEncoding(sec[1])) >= 0)
				{
					CountryCodeDefaultMapping[sec[0]] = encoding;
					parsed = true;
				}
				else
				{
					strcpy(sec[2], "VideoTexSuppl");
					count++;
				}
			}
			if (count >= 3 &&
				((sscanf(sec[0], "0x%x", &tsid) == 1 && sscanf(sec[1], "0x%x", &onid) == 1) ||
				(sscanf(sec[0], "%d", &tsid) == 1 && sscanf(sec[1], "%d", &onid) == 1)) &&
				(encoding = parseEncoding(sec[2])) >= 0)
			{
				if (encoding == VIDEOTEXSUPPL_ENCODING)
					TransponderUseTwoCharMapping.insert((tsid<<16)|onid);
				else{
					if(count==4 && strcasecmp(sec[3],"noEncodeID")==0)	//data has not first encode type id.
						encoding=encoding | 0x80;
					TransponderDefaultMapping[(tsid<<16)|onid]=encoding;
					}
				parsed = true;
			}
			if (!parsed)
				eDebug("couldn't parse %s", line);
		}
		fclose(f);
		free(line);
		return 0;

	}
	return -1;
}