示例#1
0
__int64 CDSMSplitterFile::Read(__int64 len, CStringW& str)
{
	char c;
	CStringA s;
	__int64 i = 0;
	while (i++ < len && (c = (char)BitRead(8)) != 0) {
		s += c;
	}
	str = UTF8ToString(s);
	return i;
}
示例#2
0
int main()
{
  printf("EM_ASM: Simple expression without trailing semicolon\n");
  EM_ASM(console.log('1. expression without trailing semicolon'));
  EM_ASM("console.log('2. expression without trailing semicolon')");
  EM_ASM({"console.log('3. expression without trailing semicolon')"});
  EM_ASM({console.log('4. expression without trailing semicolon')});
  EM_ASM("{console.log('5. expression without trailing semicolon')}");

  printf("\nEM_ASM: Double quotes\n");
  EM_ASM(console.log("1. string in double quotes"));
  EM_ASM("console.log(\"2. string in double quotes\")");
  EM_ASM({"console.log(\"3. string in double quotes\")"});
  EM_ASM({console.log("4. string in double quotes")});
  EM_ASM("{console.log(\"5. string in double quotes\")}");

  printf("\nEM_ASM: Double quotes inside a string\n");
  EM_ASM(console.log('1. this is \"double\" \"quotes\"'));
  EM_ASM(console.log('2. this is "double" "quotes" without escaping'));
  EM_ASM("console.log('3. this is \"double\" \"quotes\"')");
  EM_ASM({"console.log('4. this is \"double\" \"quotes\"')"});
  EM_ASM({console.log('5. this is \"double\" \"quotes\"')});
  EM_ASM({console.log('6. this is "double" "quotes" without esacping')});
  EM_ASM("{console.log('7. this is \"double\" \"quotes\"')}");

  printf("\nEM_ASM: Pass a string\n");
  EM_ASM(console.log('1. hello ' + UTF8ToString($0)), "world!");
  EM_ASM("console.log('2. hello ' + UTF8ToString($0))", "world!");
  EM_ASM({"console.log('3. hello ' + UTF8ToString($0))"}, "world!");
  EM_ASM({console.log('4. hello ' + UTF8ToString($0))}, "world!");
  EM_ASM("{console.log('5. hello ' + UTF8ToString($0))}", "world!");

  printf("\nEM_ASM: Simple expression without trailing semicolon, wrap code block in extra parentheses\n");
  EM_ASM((console.log('1. expression without trailing semicolon, in parentheses')));
  EM_ASM(("console.log('2. expression without trailing semicolon, in parentheses')"));
  EM_ASM(({"console.log('3. expression without trailing semicolon, in parentheses')"}));
示例#3
0
/*fa MTR_ShowSimpleMessageBox yes */
void MTR_CALL MTR_ShowSimpleMessageBox(uint8_t type, const char *title,
 const char *message)
{
    const char *emptyString = "";
    const char *resultTitle;
    const char *resultMessage;

    if (title == NULL)
        resultTitle = emptyString;
    else
        resultTitle = title;

    if (message == NULL)
        resultMessage = emptyString;
    else
        resultMessage = message;

    #ifdef __GNUC__
    switch (type)
    {
        case MTR_DMT_INFO:
        case MTR_DMT_NOTE:
        case MTR_DMT_DEBUG:
            tinyfd_messageBox(resultTitle, resultMessage, "ok", "info", 1);
            break;
        case MTR_DMT_WARNING:
            tinyfd_messageBox(resultTitle, resultMessage, "ok", "warning", 1);
            break;
        case MTR_DMT_ERROR:
        case MTR_DMT_FATAL:
            tinyfd_messageBox(resultTitle, resultMessage, "ok", "error", 1);
            break;
        default: /* Similar MTR_DMT_INFO */
            tinyfd_messageBox(resultTitle, resultMessage, "ok", "info", 1);
            break;
    }
    #else
    int dummy;
    dummy = EM_ASM_INT({
        var msg = UTF8ToString($0);
        alert(msg);
        return 0;
    }, resultMessage);
UnicodeString UnMungeStr(const UnicodeString & Str)
{
  // Str should contain ASCII characters only
  RawByteString Source = Str;
  RawByteString Dest;
  char * Buffer = Dest.SetLength(Source.GetLength());
  putty_unmungestr(Source.c_str(), Buffer, static_cast<int>(Source.GetLength()));
  // Cut the string at null character
  PackStr(Dest);
  UnicodeString Result;
  const std::string Bom(CONST_BOM);
  if (Dest.Pos(Bom.c_str()) == 1)
  {
    Dest.Delete(1, Bom.size());
    Result = UTF8ToString(Dest);
  }
  else
  {
    Result = AnsiToString(Dest);
  }
  return Result;
}
示例#5
0
bool CSubtitleDlDlg::Parse()
{
	isdb_movie m;
	isdb_subtitle sub;

	CAtlList<CStringA> sl;
	Explode(m_pTA->raw_list, sl, '\n');
	CString str;

	POSITION pos = sl.GetHeadPosition();

	while (pos) {
		str = sl.GetNext(pos);

		CStringA param = str.Left(max(0, str.Find('=')));
		CStringA value = str.Mid(str.Find('=')+1);

		if (param == "ticket") {
			m_pTA->ticket = value;
		} else if (param == "movie") {
			m.reset();
			Explode(value, m.titles, '|');
		} else if (param == "subtitle") {
			sub.reset();
			sub.id = atoi(value);
		} else if (param == "name") {
			sub.name = value;
		} else if (param == "discs") {
			sub.discs = atoi(value);
		} else if (param == "disc_no") {
			sub.disc_no = atoi(value);
		} else if (param == "format") {
			sub.format = value;
		} else if (param == "iso639_2") {
			sub.iso639_2 = value;
		} else if (param == "language") {
			sub.language = value;
		} else if (param == "nick") {
			sub.nick = value;
		} else if (param == "email") {
			sub.email = value;
		} else if (param.IsEmpty() && value == "endsubtitle") {
			m.subs.AddTail(sub);
		} else if (param.IsEmpty() && value == "endmovie") {
			m_pTA->raw_movies.AddTail(m);
		} else if (param.IsEmpty() && value == "end") {
			break;
		}
	}

	pos = m_pTA->raw_movies.GetHeadPosition();

	while (pos) {
		isdb_movie& m = m_pTA->raw_movies.GetNext(pos);
		isdb_movie_parsed p;

		CStringA titlesA = Implode(m.titles, '|');
		titlesA.Replace("|", ", ");
		p.titles = UTF8ToString(titlesA);
		p.checked = false;

		POSITION pos2 = m.subs.GetHeadPosition();
		while (pos2) {
			const isdb_subtitle& s = m.subs.GetNext(pos2);
			p.name = UTF8ToString(s.name);
			p.language = s.language;
			p.format = s.format;
			p.disc.Format(_T("%d/%d"), s.disc_no, s.discs);
			p.ptr = reinterpret_cast<DWORD_PTR>(&s);

			m_parsed_movies.Add(p);
		}
	}

	bool ret = true;
	if (m_parsed_movies.GetCount() == 0) {
		ret = false;
	}

	return ret;
}
示例#6
0
文件: PuttyIntf.cpp 项目: elfmz/far2l
int GetUserpassInput(prompts_t * p, const uint8_t * /*in*/, int /*inlen*/)
{
  DebugAssert(p != nullptr);
  TSecureShell * SecureShell = NB_STATIC_DOWNCAST(TSecureShell, p->frontend);
  DebugAssert(SecureShell != nullptr);

  int Result;
  std::unique_ptr<TStrings> Prompts(new TStringList());
  std::unique_ptr<TStrings> Results(new TStringList());
  {
    UnicodeString Name = UTF8ToString(p->name);
    UnicodeString AName = Name;
    TPromptKind PromptKind = SecureShell->IdentifyPromptKind(AName);
    bool UTF8Prompt = (PromptKind != pkPassphrase);

    for (size_t Index = 0; Index < p->n_prompts; ++Index)
    {
      prompt_t * Prompt = p->prompts[Index];
      UnicodeString S;
      if (UTF8Prompt)
      {
        S = UTF8ToString(Prompt->prompt);
      }
      else
      {
        S = UnicodeString(AnsiString(Prompt->prompt));
      }
      Prompts->AddObject(S, reinterpret_cast<TObject *>(static_cast<size_t>(FLAGMASK(Prompt->echo, pupEcho))));
      // this fails, when new passwords do not match on change password prompt,
      // and putty retries the prompt
      DebugAssert(Prompt->resultsize == 0);
      Results->Add(L"");
    }

    UnicodeString Instructions = UTF8ToString(p->instruction);
    if (SecureShell->PromptUser(p->to_server != 0, Name, p->name_reqd != 0,
          Instructions, p->instr_reqd != 0, Prompts.get(), Results.get()))
    {
      for (size_t Index = 0; Index < p->n_prompts; ++Index)
      {
        prompt_t * Prompt = p->prompts[Index];
        RawByteString S;
        if (UTF8Prompt)
        {
          S = RawByteString(UTF8String(Results->GetString(Index)));
        }
        else
        {
          S = RawByteString(AnsiString(Results->GetString(Index)));
        }
        prompt_set_result(Prompt, S.c_str());
      }
      Result = 1;
    }
    else
    {
      Result = 0;
    }
  }
  __finally
  {
//    delete Prompts;
//    delete Results;
  };

  return Result;
}
示例#7
0
void CFileDiffDlg::DiffProps(int selIndex)
{
	CFileDiffDlg::FileDiff fd = m_arFilteredList[selIndex];

	CTSVNPath url1 = CTSVNPath(m_path1.GetSVNPathString() + _T("/") + fd.path.GetSVNPathString());
	CTSVNPath url2 = m_bDoPegDiff ? url1 : CTSVNPath(m_path2.GetSVNPathString() + _T("/") + fd.path.GetSVNPathString());

	SVNProperties propsurl1(url1, m_rev1, false);
	SVNProperties propsurl2(url2, m_rev2, false);
	
	// collect the properties of both revisions in a set
	std::set<std::string> properties;
	for (int wcindex = 0; wcindex < propsurl1.GetCount(); ++wcindex)
	{
		std::string urlname = propsurl1.GetItemName(wcindex);
		if ( properties.find(urlname) == properties.end() )
		{
			properties.insert(urlname);
		}
	}
	for (int wcindex = 0; wcindex < propsurl2.GetCount(); ++wcindex)
	{
		std::string urlname = propsurl2.GetItemName(wcindex);
		if ( properties.find(urlname) == properties.end() )
		{
			properties.insert(urlname);
		}
	}

	// iterate over all properties and diff the properties
	for (std::set<std::string>::iterator iter = properties.begin(), end = properties.end(); iter != end; ++iter)
	{
		const std::string& url1name = *iter;
		
		tstring url1value = _T(""); // CUnicodeUtils::StdGetUnicode((char *)propsurl1.GetItemValue(wcindex).c_str());
		for (int url1index = 0; url1index < propsurl1.GetCount(); ++url1index)
		{
			if (propsurl1.GetItemName(url1index).compare(url1name)==0)
			{
				url1value = CUnicodeUtils::GetUnicode(propsurl1.GetItemValue(url1index).c_str());
			}
		}		
		
		tstring url2value = _T("");
		for (int url2index = 0; url2index < propsurl2.GetCount(); ++url2index)
		{
			if (propsurl2.GetItemName(url2index).compare(url1name)==0)
			{
				url2value = CUnicodeUtils::GetUnicode(propsurl2.GetItemValue(url2index).c_str());
			}
		}

		if (url2value.compare(url1value)!=0)
		{
			// write both property values to temporary files
			CTSVNPath url1propfile = CTempFiles::Instance().GetTempFilePath(false);
			CTSVNPath url2propfile = CTempFiles::Instance().GetTempFilePath(false);
			FILE * pFile;
			_tfopen_s(&pFile, url1propfile.GetWinPath(), _T("wb"));
			if (pFile)
			{
				fputs(CUnicodeUtils::StdGetUTF8(url1value).c_str(), pFile);
				fclose(pFile);
				FILE * pFile2;
				_tfopen_s(&pFile2, url2propfile.GetWinPath(), _T("wb"));
				if (pFile)
				{
					fputs(CUnicodeUtils::StdGetUTF8(url2value).c_str(), pFile2);
					fclose(pFile2);
				}
				else
					return;
			}
			else
				return;
			SetFileAttributes(url1propfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
			SetFileAttributes(url2propfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
			CString n1, n2;
			if (m_rev1.IsWorking())
				n1.Format(IDS_DIFF_WCNAME, CUnicodeUtils::StdGetUnicode(url1name).c_str());
			if (m_rev1.IsBase())
				n1.Format(IDS_DIFF_BASENAME, CUnicodeUtils::StdGetUnicode(url1name).c_str());
			if (m_rev1.IsHead() || m_rev1.IsNumber())
			{
				if (m_bDoPegDiff)
				{
					n1.Format(_T("%s : %s Revision %ld"), CUnicodeUtils::StdGetUnicode(url1name).c_str(), (LPCTSTR)fd.path.GetSVNPathString(), (LONG)m_rev1);
				}
				else
				{
					CString sTemp (UTF8ToString (url1name).c_str());
					sTemp += _T(" : ");
					n1 = sTemp + m_path1.GetSVNPathString() + _T("/") + fd.path.GetSVNPathString();
				}
			}
			if (m_rev2.IsWorking())
				n2.Format(IDS_DIFF_WCNAME, CUnicodeUtils::StdGetUnicode(url1name).c_str());
			if (m_rev2.IsBase())
				n2.Format(IDS_DIFF_BASENAME, CUnicodeUtils::StdGetUnicode(url1name).c_str());
			if (m_rev2.IsHead() || m_rev2.IsNumber())
			{
				if (m_bDoPegDiff)
				{
					n2.Format(_T("%s : %s Revision %ld"), CUnicodeUtils::StdGetUnicode(url1name).c_str(),  (LPCTSTR)fd.path.GetSVNPathString(), (LONG)m_rev2);
				}
				else
				{
					CString sTemp (UTF8ToString (url1name).c_str());
					sTemp += _T(" : ");
					n2 = sTemp + m_path2.GetSVNPathString() + _T("/") + fd.path.GetSVNPathString();
				}
			}
			CAppUtils::StartExtDiffProps(url1propfile, url2propfile, n1, n2, TRUE);
		}
	}
}