Пример #1
0
UTF16 FIContent::getContentLongString()
{
	if (m_iContentGroup == 0xFFFFFFFDU)
		return UTF16(L"Unique Content: SHA2-512 = ") + UTF16(HexString::binToHex(m_sha));
	else
		return UTF16::format(L"Content Group #%u: SHA2-512 = ", m_iContentGroup) + UTF16(HexString::binToHex(m_sha));
}
Пример #2
0
void JSON::as_string(Error& error, const HOutputStream& out) const
{
	switch (m_type)
	{
	case e_null:    out->twrite(error, UTF16(L"")); break;
	case e_bool:    out->twrite(error, m_bool ? UTF16(g_sTrueUTF16) : UTF16(g_sFalseUTF16)); break;
	case e_integer: out->twrite(error, UTF16::format(L"%lld", m_integer)); break;
	case e_real:    out->twrite(error, UTF16::format(L"%e", m_real)); break;
	case e_string:  out->twrite(error, m_string); break;
	case e_array:   m_array.as_string(error, out); break;
	case e_object:  m_object.as_string(error, out); break;
	}
};
Пример #3
0
/* Sends the squarelist to the client. */
void PlayerSession::SendSquareList()
{
	if ( !IsAuthenticated() || mCharacter == NULL )
		return;

	Buffer listpkt;
	listpkt.WriteUInt32( 0 );
	listpkt.WriteUInt32( HASH_LIST_SQUARES );
	listpkt.WriteUInt32( SquareManager::GetSquareCount() );

	Square *squares = SquareManager::GetList();
	for ( uint32_t i = 0, j = 0; i < MAX_SQUARES; i++ )
	{
		if ( squares[i].IsActive() != NULL )
		{
			listpkt.WriteUInt32( HASH_OBJ_SQUARE + j );
			listpkt.WriteWideString( UTF16( squares[i].mName ) );
			listpkt.WriteUInt32( squares[i].mStatus );
			listpkt.WriteUInt32( squares[i].mType );
			listpkt.WriteUInt32( squares[i].mCapacity );

			j++;
		}
	}
	Send( listpkt, MSG_SQUARE_LIST );
}
Пример #4
0
void DeepScanner::processFile(FIFile* pFile)
{
	Error error;
	class SkipFile {};

	try
	{
		Path path = pFile->getAbsolutePath(error, m_db.m_root);
		if (error)
			throw SkipFile();

		m_fProgress = Real64(m_iCurItem) / Real64(m_db.m_pFIFiles.size());
		progressReport(path);

		FileInputStream fis(error, path);
		if (error)
			throw SkipFile();

		FIIndex* pIndex = vivFileIndex(error, fis);

		if (error)
			throw SkipFile();

		pFile->setFIIndex(pIndex);
		pIndex->addFIFile(pFile);
	}
	catch (SkipFile&)
	{
		UTF16 sErrorMessage = (error ? UTF16(error) : L"Unknown Error");

		skipWarning(pFile->getPath(), error);
	}
}
Пример #5
0
		String GetErrorMessage (DWORD code) {
		
			//	Attempt to get string from
			//	system
			LPWSTR ptr;
			auto num=FormatMessageW(
				FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
				nullptr,
				code,
				0,
				reinterpret_cast<LPWSTR>(&ptr),
				0,
				nullptr
			);
			
			//	If no characters were returned,
			//	just return the empty string
			if (num==0) return String();
			
			//	Get rid of trailing carriage return
			//	line feed, if present
			for (
				;
				(num!=0) &&
				(
					(ptr[num-1]=='\r') ||
					(ptr[num-1]=='\n')
				);
				--num
			);
			
			//	Return empty string if there
			//	are no characters left after
			//	eliminating trailing carriage
			//	returns and line feeds, otherwise
			//	decode
			String retr;
			if (num!=0) try {
			
				retr=UTF16(false).Decode(
					reinterpret_cast<Byte *>(ptr),
					reinterpret_cast<Byte *>(ptr+num)
				);
			
			} catch (...) {
			
				LocalFree(ptr);
				
				throw;
			
			}
			
			LocalFree(ptr);
			
			return retr;
		
		}
Пример #6
0
void JSONObject::as_string(Error& error, const HOutputStream& out) const
{
	out->twrite(error, L'(');
	if (error) return;

	if (size() > 0)
	{
		bool bFirst = true;

		TreeMap<UTF16, JSON>::Iterator it(m_core->m_tree);
		UTF16 sKey;
		JSON value;
		while (it(sKey, value))
		{
			if (bFirst)
				bFirst = false;
			else
			{
				out->twrite(error, UTF16(L"; "));
				if (error)
					return;
			}

			out->twrite(error, UTF16(sKey));
			if (error)
				return;

			out->twrite(error, UTF16(L" = "));

			if (error)
				return;

			value.as_string(error, out);

			if (error)
				return;
		}
	}

	out->twrite(error, L')');

	if (error)
		return;
}
Пример #7
0
void DeepScanner::progressReport(const Path& path)
{
	if (m_bSendProgress)
	{
		m_bSendProgress = false;

		m_report.setProgress(m_fProgress);
		m_report.setSubtaskDescription(UTF16(path));
		m_master.DeepScanner_progress(m_report);
	}
}
Пример #8
0
JSON JSON::as_object() const
{
	switch (m_type)
	{
	case e_null: return JSON(e_object);
	case e_array: return m_array.as_object();
	case e_object: return *this;
	default:
		{
			JSON ret = JSON(e_object);
			ret[UTF16(g_sScalarKey)] = (*this);
			return ret;
		}
	}
}
Пример #9
0
::DumpLevel JitOptions::queryDumpLevel(LLILCJitContext &Context) {
  ::DumpLevel JitDumpLevel = ::DumpLevel::NODUMP;

  char16_t *LevelWStr =
      getStringConfigValue(Context.JitInfo, UTF16("DUMPLLVMIR"));
  if (LevelWStr) {
    std::unique_ptr<std::string> Level = Convert::utf16ToUtf8(LevelWStr);
    std::transform(Level->begin(), Level->end(), Level->begin(), ::toupper);
    if (Level->compare("VERBOSE") == 0) {
      JitDumpLevel = ::DumpLevel::VERBOSE;
    } else if (Level->compare("SUMMARY") == 0) {
      JitDumpLevel = ::DumpLevel::SUMMARY;
    }
  }

  return JitDumpLevel;
}
Пример #10
0
	TextEncoding TextEncoding::WebCharset(const UnicodeChar * name)
	{
		// This method of converting encoding names to code pages
		// supported on all Windows machines with IE 5.0 or later installed,
		// and on some Windows CE devices.  However, we can't depend on it,
		// so fall back to hard-coded names if using IMultiLanguage2 fails.
		try {
			Component<IMultiLanguage2> multiLanguage(CLSID_CMultiLanguage);
			Component<IEnumCodePage> enumCodePage;

			ThrowIfXMLError(multiLanguage->EnumCodePages(0, LOCALE_INVARIANT, enumCodePage.Adopt()));

			MIMECPINFO cpInfo;
			ULONG cpCount;
			while (enumCodePage->Next(1, &cpInfo, &cpCount) == S_OK) {
				if (::_wcsicmp(cpInfo.wszWebCharset, name) == 0) {
					return TextEncoding(cpInfo.uiCodePage);
				}
			}
		}
		catch (...) {
		}

		if (_wcsicmp(name, L"UTF-8") == 0) {
			return UTF8();
		}
		else if (_wcsicmp(name, L"UTF-16") == 0) {
			return UTF16();
		}
		else if (_wcsicmp(name, L"ISO-10646-UCS-2") == 0) {
			return UCS2();
		}
		else if (_wcsicmp(name, L"ISO-8859-1") == 0) {
			return ISOLatin1();
		}
		else if (_wcsicmp(name, L"Shift_JIS") == 0) {
			return ShiftJIS();
		}
		else if (_wcsicmp(name, L"Windows-1252") == 0) {
			return WindowsLatin1();
		}
		else {
			throw XMLException(0, "Unknown encoding");
		}
	}
Пример #11
0
UTF16 JSON::as_string() const
{
	if (m_type == e_string)
		return m_string;

	Buffer buf(0);

	{
		Error error;
		HOutputStream out = NewObject(BufferedOutputStream, NewObject(MemoryOutputStream,buf), 512);
		as_string(error, out);

		Check(!error);

		out->write(error, L"", 2);

		Check(!error);
	}

	return UTF16(Blob(buf));
}
static HUTF16List listLogicalDrives()
{
	HUTF16List hOutSubpaths = NewObject(UTF16List);
	Buffer buf(0);
	int iBufLength = GetLogicalDriveStrings(0, (LPTSTR) buf.ptr());
	if (iBufLength == 0)
		return hOutSubpaths;
	buf.resize(iBufLength*2);
	int iNumChrs = GetLogicalDriveStrings(buf.length() / 2, (LPTSTR) buf.ptr());

	const Chr16* pStart = ((Chr16*) buf.ptr());
	const Chr16* pEnd = pStart + iNumChrs;

	while (pStart < pEnd)
	{
		UTF16 s = UTF16(pStart);
		hOutSubpaths->add(s);
		pStart += s.length() + 1;
	}

	return hOutSubpaths;
}
Пример #13
0
static UTF8 stringToCStringLiteral(const UTF16& sString)
{
	UTF8 sOut = "L\"";

	const Chr16* p = sString.ptr();

	for (int i = 0; i < sString.length(); i++)
	{
		Chr16 c = p[i];
		Chr16 sC[2];
		sC[0] = c;
		sC[1] = L'\0';

		switch (c)
		{
		case L'\a' : sOut = sOut + "\\a"; break;
		case L'\b' : sOut = sOut + "\\b"; break;
		case L'\f' : sOut = sOut + "\\f"; break;
		case L'\n' : sOut = sOut + "\\n"; break;
		case L'\r' : sOut = sOut + "\\r"; break;
		case L'\t' : sOut = sOut + "\\t"; break;
		case L'\v' : sOut = sOut + "\\v"; break;
		case L'\'' : sOut = sOut + "\\'"; break;
		case L'\"' : sOut = sOut + "\\\""; break;
		case L'\\' : sOut = sOut + "\\\\"; break;
		case L'\?' : sOut = sOut + "\\?"; break;
		default:
			if (0x20 <= c && c <= 0x7E)
				sOut = sOut + UTF8(UTF16(sC));
			else
				sOut = sOut + "\\x" + UTF8::format("%.4X", UInt32(c));
		}
	}

	sOut = sOut + "\"";
	return sOut;
}
Пример #14
0
bool JitOptions::queryMethodSet(LLILCJitContext &JitContext, MethodSet &TheSet,
                                const char16_t *Name) {
  if (!TheSet.isInitialized()) {
    char16_t *ConfigStr = getStringConfigValue(JitContext.JitInfo, Name);
    bool NeedFree = true;
    if (ConfigStr == nullptr) {
      ConfigStr = (char16_t *)UTF16("");
      NeedFree = false;
    }
    std::unique_ptr<std::string> ConfigUtf8 = Convert::utf16ToUtf8(ConfigStr);
    TheSet.init(std::move(ConfigUtf8));
    if (NeedFree) {
      freeStringConfigValue(JitContext.JitInfo, ConfigStr);
    }
  }

  const char *ClassName = nullptr;
  const char *MethodName = nullptr;
  MethodName =
      JitContext.JitInfo->getMethodName(JitContext.MethodInfo->ftn, &ClassName);
  bool IsInMethodSet =
      TheSet.contains(MethodName, ClassName, JitContext.MethodInfo->args.pSig);
  return IsInMethodSet;
}
Пример #15
0
bool JitOptions::queryIsExcludeMethod(LLILCJitContext &JitContext) {
  return queryMethodSet(JitContext, ExcludeMethodSet,
                        (const char16_t *)UTF16("AltJitExclude"));
}
Пример #16
0
TextEncoding TextEncoding::Palm(UInt8 encoding)
{
    switch (encoding) {
    // Latin Palm OS character encoding, and subsets.
    // PalmOS variant of CP1252, with 10 extra Greek characters
    case charEncodingPalmGSM:
        ThrowError(kTextUnsupportedEncodingErr);
    // PalmOS version of CP1252
    case charEncodingPalmLatin:
        return PalmLatin1();
    // Windows variant of 8859-1
    case charEncodingCP1252:
        return WindowsLatin1();
    // ISO 8859 Part 1
    case charEncodingISO8859_1:
        return ISOLatin1();
    // ISO 646-1991
    case charEncodingAscii:
        return ASCII();

    // Japanese Palm OS character encoding, and subsets.
    // PalmOS version of CP932
    case charEncodingPalmSJIS:
        return PalmShiftJIS();
    // Windows variant of ShiftJIS
    case charEncodingCP932:
        return WindowsShiftJIS();
    // Encoding for JIS 0208-1990 + 1-byte katakana
    case charEncodingShiftJIS:
        return ShiftJIS();

    // Unicode character encodings
    // UCS2 is UTF16 minus the surrogate pairs
    case charEncodingUCS2:
        return UCS2();
    case charEncodingUTF8:
        return UTF8();
    case charEncodingUTF7:
        return UTF7();
    case charEncodingUTF16:
        return UTF16();
    case charEncodingUTF16BE:
        return UTF16BE();
    case charEncodingUTF16LE:
        return UTF16LE();
    case charEncodingUTF32:
        return UTF32();
    case charEncodingUTF32BE:
        return UTF32BE();
    case charEncodingUTF32LE:
        return UTF32LE();
    // A variant of UTF7 used by the IMAP mail protocol to encode
    // mail folder names.  Documented in RFC 2060.  This does not
    // seem to be supported by the Macintosh text encoding converter.
    case charEncodingUTF7_IMAP:
        ThrowError(kTextUnsupportedEncodingErr);
    // I really don't know how this is different from UTF32...
    case charEncodingUCS4:
        return UTF32();

    // Latin character encodings
    case charEncodingCP850:
        return TextEncoding(kTextEncodingDOSLatin1, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP437:
        return TextEncoding(kTextEncodingDOSLatinUS, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP865:
        return TextEncoding(kTextEncodingDOSNordic, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP860:
        return TextEncoding(kTextEncodingDOSPortuguese, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP861:
        return TextEncoding(kTextEncodingDOSIcelandic, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP863:
        return TextEncoding(kTextEncodingDOSCanadianFrench, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP775:
        return TextEncoding(kTextEncodingDOSBalticRim, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingMacIslande:
        return TextEncoding(kTextEncodingMacIcelandic, kMacIcelandicStdDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingMacintosh:
        return TextEncoding(kTextEncodingMacRoman, kMacRomanDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP1257:
        return TextEncoding(kTextEncodingWindowsBalticRim, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingISO8859_3:
        return TextEncoding(kTextEncodingISOLatin3, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingISO8859_4:
        return TextEncoding(kTextEncodingISOLatin4, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);

    // Extended Latin character encodings
    case charEncodingISO8859_2:
        return TextEncoding(kTextEncodingISOLatin2, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP1250:
        return TextEncoding(kTextEncodingWindowsLatin2, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP852:
        return TextEncoding(kTextEncodingDOSLatin2, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    // This doesn't seem to be implemented on the Mac, though there's
    // a description of it at http://www.kiv.zcu.cz/~luki/cs/cs-encodings-faq.html
    case charEncodingXKamenicky:
        ThrowError(kTextUnsupportedEncodingErr);
    case charEncodingMacXCroate:
        return TextEncoding(kTextEncodingMacCroatian, kMacCroatianDefaultVariant,
                            kTextEncodingDefaultFormat);
    // I just can't figure out which encoding this refers to.
    // It seems like Mac OS X Latin-2, but I don't know what that is.
    case charEncodingMacXLat2:
        ThrowError(kTextUnsupportedEncodingErr);
    case charEncodingMacXRomania:
        return TextEncoding(kTextEncodingMacRomanian, kMacRomanianDefaultVariant,
                            kTextEncodingDefaultFormat);
    // I think this must be the character set used by GSM phones in Europe.
    // http://www.csoft.co.uk/character_sets/gsm.htm
    case charEncodingGSM:
        ThrowError(kTextUnsupportedEncodingErr);

    // Japanese character encodings
    case charEncodingEucJp:
        return TextEncoding(kTextEncodingEUC_JP, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingISO2022Jp:
        return TextEncoding(kTextEncodingISO_2022_JP, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    // This isn't so much an encoding as a heuristic...
    case charEncodingXAutoJp:
        ThrowError(kTextUnsupportedEncodingErr);

    // Greek character encodings
    case charEncodingISO8859_7:
        return TextEncoding(kTextEncodingISOLatinGreek, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP1253:
        return TextEncoding(kTextEncodingWindowsGreek, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP869:
        return TextEncoding(kTextEncodingDOSGreek2, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP737:
        return TextEncoding(kTextEncodingDOSGreek, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingMacXGr:
        return TextEncoding(kTextEncodingMacGreek, kMacGreekDefaultVariant,
                            kTextEncodingDefaultFormat);

    // Cyrillic character encodings
    case charEncodingCP1251:
        return TextEncoding(kTextEncodingWindowsCyrillic, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingISO8859_5:
        return TextEncoding(kTextEncodingISOLatinCyrillic, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingKoi8R:
        return TextEncoding(kTextEncodingKOI8_R, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    // I'm just guessing by elimination that they mean RFC 2319, Ukrainian here.
    case charEncodingKoi8:
        return TextEncoding(kTextEncodingKOI8_U, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP855:
        return TextEncoding(kTextEncodingDOSCyrillic, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP866:
        return TextEncoding(kTextEncodingDOSRussian, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingMacCyr:
        return TextEncoding(kTextEncodingMacCyrillic, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingMacUkraine:
        return TextEncoding(kTextEncodingMacUkrainian, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);

    // Turkish character encodings
    case charEncodingCP1254:
        return TextEncoding(kTextEncodingWindowsLatin5, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingISO8859_9:
        return TextEncoding(kTextEncodingISOLatin5, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP857:
        return TextEncoding(kTextEncodingDOSTurkish, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingMacTurc:
        return TextEncoding(kTextEncodingMacTurkish, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    // This seems to be DOS Latin 3, but it's not listed in the Mac tables.
    case charEncodingCP853:
        ThrowError(kTextUnsupportedEncodingErr);

    // Arabic character encodings
    // The Mac tables don't make any distinction between ISO 8859-6, Asmo 708,
    // and DOS 708.  I hope it's OK to merge them...
    case charEncodingISO8859_6:
    case charEncodingAsmo708:
    case charEncodingAsmo708Plus:
    case charEncodingAsmo708Fr:
        return TextEncoding(kTextEncodingISOLatinArabic, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP1256:
        return TextEncoding(kTextEncodingWindowsArabic, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP864:
        return TextEncoding(kTextEncodingDOSArabic, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingMacAra:
        return TextEncoding(kTextEncodingMacArabic, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);

    // Simplified Chinese character encodings
    case charEncodingGB2312:
        return TextEncoding(kTextEncodingGB_2312_80, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingHZ:
        return TextEncoding(kTextEncodingHZ_GB_2312, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingGBK:
        return TextEncoding(kTextEncodingGBK_95, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    // I'm guessing that this is a Palm variation on GB 2312...
    case charEncodingPalmGB:
        return TextEncoding(kTextEncodingGB_2312_80, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);

    // Traditional Chinese character encodings
    case charEncodingBig5:
        return TextEncoding(kTextEncodingBig5, kBig5_BasicVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingBig5_HKSCS:
        return TextEncoding(kTextEncodingBig5_HKSCS_1999, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    // I'm just guessing that by "Plus" Palm means the ETenVariant that Apple
    // says "adds kana, Cyrillic, radicals, etc with hi bytes C6-C8,F9"
    case charEncodingBig5Plus:
        return TextEncoding(kTextEncodingBig5, kBig5_ETenVariant,
                            kTextEncodingDefaultFormat);
    // No clue what Palm changed, so just use Big-5.
    case charEncodingPalmBig5:
        return TextEncoding(kTextEncodingBig5, kBig5_BasicVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingISO2022CN:
        return TextEncoding(kTextEncodingISO_2022_CN, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);

    // Vietnamese character encodings
    case charEncodingViscii:
        return TextEncoding(kTextEncodingVISCII, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    // VIQR stands for VIetnamese Quoted-Readable,
    // which is a convention to write Vietnamese letters using 7-bit ASCII.
    // http://www.nonsong.org/viqr.html
    case charEncodingViqr:
        ThrowError(kTextUnsupportedEncodingErr);
    // Also known as VPS
    // http://homepages.cwi.nl/~dik/english/codes/stand.html#vncii
    case charEncodingVncii:
        ThrowError(kTextUnsupportedEncodingErr);
    // Several web site seem to think Vietnet is the same as VIQR
    case charEncodingVietnet:
        ThrowError(kTextUnsupportedEncodingErr);
    case charEncodingCP1258:
        return TextEncoding(kTextEncodingWindowsVietnamese, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);

    // Korean character encodings
    case charEncodingEucKr:
        return TextEncoding(kTextEncodingEUC_KR, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP949:
        return TextEncoding(kTextEncodingDOSKorean, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingISO2022Kr:
        return TextEncoding(kTextEncodingISO_2022_KR, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);

    // Hebrew character encodings
    case charEncodingISO8859_8I:
        return TextEncoding(kTextEncodingISOLatinHebrew, kISOLatinHebrewImplicitOrderVariant,
                            kTextEncodingDefaultFormat);
    // Comments in the Mac TextCommon.h make it clear that the "default"
    // variant of ISO 8859-8 is visual ordering.
    case charEncodingISO8859_8:
        return TextEncoding(kTextEncodingISOLatinHebrew, kISOLatinHebrewVisualOrderVariant,
                            kTextEncodingDefaultFormat);
    case charEncodingCP1255:
        return TextEncoding(kTextEncodingWindowsHebrew, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);
    // There's no explicit visual variant for cp1255, so I'm hoping that
    // using the default variant is better than throwing an exception...
    case charEncodingCP1255V:
        return TextEncoding(kTextEncodingWindowsHebrew, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);

    // Thai character encodings
    // TIS-620, http://www.langbox.com/codeset/tis620.html
    case charEncodingTis620:
        ThrowError(kTextUnsupportedEncodingErr);
    case charEncodingCP874:
        return TextEncoding(kTextEncodingDOSThai, kTextEncodingDefaultVariant,
                            kTextEncodingDefaultFormat);

    default:
        ThrowError(kTextUnsupportedEncodingErr);
    }

    // not reached
    return TextEncoding();
}
static UTF16 getNotesOnLogicalDrive(Error& error, const UTF16& sLogicalDrive)
{
	UTF16Buffer sbVolName(MAX_PATH+1);
	UTF16Buffer sbFSType(MAX_PATH+1);

	if (!GetVolumeInformation(sLogicalDrive.ptr(), sbVolName.ptr(), 
		sbVolName.flength(), NULL, NULL, NULL, sbFSType.ptr(), sbFSType.flength()))
	{
		error.what(WindowsError::getLastError());
		error.who(L"GetVolumeInformation");
		return UTF16();
	}
	
	UTF16 sVolName = sbVolName;
	UTF16 sFSType = sbFSType;

	if (!sVolName.empty())
		sVolName = sVolName + " ";
	
	if (!sFSType.empty())
		sFSType = sFSType + " ";

	UTF16 sDriveType;

	switch (GetDriveType(sLogicalDrive.ptr()))
	{
	case DRIVE_NO_ROOT_DIR: sDriveType = L"No Root Dir "; break;
	case DRIVE_REMOVABLE: sDriveType = L"Removable "; break;
	case DRIVE_FIXED: sDriveType = L"Fixed "; break;
	case DRIVE_CDROM: sDriveType = L"CDROM "; break;
	case DRIVE_RAMDISK: sDriveType = L"RAM Disk "; break;
	default: sDriveType = L"Unknown ";
	}

	UTF16 sSizeInfo;

	UInt64 iBytesFree, iTotalBytes;
	ULARGE_INTEGER ulgFreeBytesAvailable, ulgTotalNumberOfBytes;
	if (GetDiskFreeSpaceEx(sLogicalDrive.ptr(), &ulgFreeBytesAvailable, &ulgTotalNumberOfBytes, NULL))
	{
		iBytesFree = ulgFreeBytesAvailable.QuadPart;
		iTotalBytes = ulgTotalNumberOfBytes.QuadPart;

		int iUnit = 0;
		for (UInt64 i = iTotalBytes; i > 0; i >>= 10)
			iUnit++;
		UTF16 sUnit;
		switch (iUnit)
		{
		case 0: iUnit = 1; sUnit = L"B"; break;
		case 1: sUnit = L"B"; break;
		case 2: sUnit = L"KB"; break;
		case 3: sUnit = L"MB"; break;
		case 4: sUnit = L"GB"; break;
		case 5: sUnit = L"TB"; break;
		case 6: sUnit = L"PB"; break;
		case 7: sUnit = L"EB"; break;
		case 8: sUnit = L"ZB"; break;
		case 9: sUnit = L"YB"; break;
		default: sUnit = L"??"; break;
		}

		Real64 fBytesFree = Real64(iBytesFree) / Real64(1ULL << (10*(iUnit-1)));
		Real64 fTotalBytes = Real64(iTotalBytes) / Real64(1ULL << (10*(iUnit-1)));
		Real64 fBytesUsed = fTotalBytes - fBytesFree;

		sSizeInfo = UTF16::format(L"%d/%d%s ", UInt32(fBytesUsed), UInt32(fTotalBytes), sUnit.ptr());
	}
Пример #18
0
// Determine if SIMD intrinsics should be used.
bool JitOptions::queryDoSIMDIntrinsic(LLILCJitContext &Context) {
  return queryNonNullNonEmpty(Context,
                              (const char16_t *)UTF16("SIMDINTRINSIC"));
}
Пример #19
0
// Determine if GCInfo encoding logs should be emitted
bool JitOptions::queryLogGcInfo(LLILCJitContext &Context) {
  return queryNonNullNonEmpty(Context,
                              (const char16_t *)UTF16("JitGCInfoLogging"));
}
Пример #20
0
// Determine if GC statepoints should be inserted.
bool JitOptions::queryDoInsertStatepoints(LLILCJitContext &Context) {
  return queryNonNullNonEmpty(Context,
                              (const char16_t *)UTF16("INSERTSTATEPOINTS"));
}
Пример #21
0
// Get the GC-Scheme used by the runtime -- conservative/precise
bool JitOptions::queryUseConservativeGC(LLILCJitContext &Context) {
  return queryNonNullNonEmpty(Context,
                              (const char16_t *)UTF16("GCCONSERVATIVE"));
}
Пример #22
0
bool JitOptions::queryIsCodeRangeMethod(LLILCJitContext &JitContext) {
  return queryMethodSet(JitContext, CodeRangeMethodSet,
                        (const char16_t *)UTF16("AltJitCodeRangeDump"));
}
Пример #23
0
bool JitOptions::queryIsLLVMDumpMethod(LLILCJitContext &JitContext) {
  return queryMethodSet(JitContext, LLVMMethodSet,
                        (const char16_t *)UTF16("AltJitLLVMDump"));
}
Пример #24
0
int wmain(int argc, Chr16** argv)
{
	Lock::setupGlobalLock();

	Error error;
	LogStdout log;
		
	class Fatal {};

	try
	{
		loginfo("Tomazos Resource Compiler 1.0 (c) Andrew Tomazos 2009");

		if (argc != 3)
		{
			error.what(L"Usage: ResourceCompiler <ResourceDir> <Out.cpp>");
			throw Fatal();
		}

		UTF16 sSourceDirPath = argv[1];
		UTF16 sOutPath = argv[2];

		Path sourceDir(error, sSourceDirPath);
		
		if (error)
			throw Fatal();

		UTF16 sFullSourceDirPath = UTF16(sourceDir);
		if (!sFullSourceDirPath.endsWith(L"\\"))
			sFullSourceDirPath = sFullSourceDirPath + L"\\";

		UTF16List fps;
		sourceDir.walk(ResourceCompilerWalker(fps));

		loginfo("Found %d files", fps.size());

		TreeMap<UTF16, Blob> data;

		{
			UTF16List::Iterator it(fps);
			UTF16 sFullFilePath;

			while (it(sFullFilePath))
			{
				if (!sFullFilePath.startsWith(sFullSourceDirPath))
				{
					Check();
					throw Fatal();
				}

				UTF16 sRelFilePath = sFullFilePath.suffix(sFullFilePath.length() - sFullSourceDirPath.length());

				Path file(error, sFullFilePath);
				
				if (error)
					throw Fatal();

				HInputStream fis;
				
				file.readFile(error, fis);

				if (error)
					throw Fatal();

				
				Blob sFileContent = fis->slurp(error);

				if (error)
					throw Fatal();

				loginfo("Found %s (%d bytes)", sRelFilePath.ptr(), sFileContent.length());

				data.add(sRelFilePath, sFileContent);
			}
		}

		Path outPath(error, sOutPath);

		if (error)
			throw Fatal();

		HOutputStream hOut;
		outPath.overwriteFile(error, hOut);

		if (error)
			throw Fatal();

		#define ResLine(x) { hOut->twrite(error, UTF8(x)); if (error) throw Fatal(); hOut->twrite(error, UTF8("\r\n")); if (error) throw Fatal(); }
		#define ResLineF(...) { ResLine(UTF8::format(__VA_ARGS__)); }

		ResLine("#include \"Runtime.h\"");
		ResLine("");
		ResLine("void ResourceManager::setup()");
		ResLine("{");

		{
			TreeMap<UTF16, Blob>::Iterator it(data);
			UTF16 sPath;
			Blob bData;
			int iCount = 0;

			int iNumResources = data.size();

			while (it(sPath, bData))
			{
				iCount++;
				UTF8 sId = UTF8::format("s_res_data_%d", iCount);
				
				ResLineF("    static UInt8 %s[] = { ", sId.ptr());
				for (int i = 0; i < bData.length(); i++)
				{
					if (i % 16 == 0)
					{
						hOut->twrite(error, UTF8("        "));
						if (error)
							throw Fatal();
					}

					hOut->twrite(error, UTF8::format("0x%.2X", UInt32(bData.idx<UInt8>(i))));

					if (error) throw Fatal();

					if (i != bData.length() - 1)
					{
						hOut->twrite(error, UTF8(", "));

						if (error)
							throw Fatal();
					}

					if (i % 16 == 15 || i == bData.length() - 1)
						ResLine("");
				}
				ResLineF("    };");
				ResLine("");
				ResLineF("    ResourceManager::instance()->set(%s, %s, %d);", stringToCStringLiteral(sPath).ptr(), sId.ptr(), bData.length());
				if (iCount != iNumResources)
					ResLine("");
			}
		}

		ResLine("}");

		#undef ResLine

		return 0;
	}
	catch (Fatal&)
	{
		if (error)
			logerr("%s", UTF16(error).ptr());
		
		return 1;
	}
}
Пример #25
0
bool JitOptions::queryIsAltJit(LLILCJitContext &Context) {
  // Initial state is that we are not an alternative jit until proven otherwise;
  bool IsAlternateJit = false;

// NDEBUG is !Debug

#if !defined(NDEBUG)

  // DEBUG case

  // Get/reuse method set that contains the altjit method value.
  MethodSet *AltJit = nullptr;

  if (Context.Flags & CORJIT_FLG_PREJIT) {
    if (!AltJitNgenMethodSet.isInitialized()) {
      char16_t *NgenStr =
          getStringConfigValue(Context.JitInfo, UTF16("AltJitNgen"));
      std::unique_ptr<std::string> NgenUtf8 = Convert::utf16ToUtf8(NgenStr);
      AltJitNgenMethodSet.init(std::move(NgenUtf8));
      freeStringConfigValue(Context.JitInfo, NgenStr);
    }
    // Set up AltJitNgen set to be used for AltJit test.
    AltJit = &AltJitNgenMethodSet;
  } else {
    if (!AltJitMethodSet.isInitialized()) {
      char16_t *JitStr = getStringConfigValue(Context.JitInfo, UTF16("AltJit"));
      // Move this to the UTIL code and ifdef it for platform
      std::unique_ptr<std::string> JitUtf8 = Convert::utf16ToUtf8(JitStr);
      AltJitMethodSet.init(std::move(JitUtf8));
      freeStringConfigValue(Context.JitInfo, JitStr);
    }
    // Set up AltJit set to be use for AltJit test.
    AltJit = &AltJitMethodSet;
  }

#ifdef ALT_JIT
  const char *ClassName = nullptr;
  const char *MethodName = nullptr;
  MethodName =
      Context.JitInfo->getMethodName(Context.MethodInfo->ftn, &ClassName);
  IsAlternateJit =
      AltJit->contains(MethodName, ClassName, Context.MethodInfo->args.pSig);
#endif // ALT_JIT

#else
  if (Context.Flags & CORJIT_FLG_PREJIT) {
    char16_t *NgenStr =
        getStringConfigValue(Context.JitInfo, UTF16("AltJitNgen"));
    std::unique_ptr<std::string> NgenUtf8 = Convert::utf16ToUtf8(NgenStr);
    if (NgenUtf8->compare("*") == 0) {
      IsAlternateJit = true;
    }
  } else {
    char16_t *JitStr = getStringConfigValue(Context.JitInfo, UTF16("AltJit"));
    std::unique_ptr<std::string> JitUtf8 = Convert::utf16ToUtf8(JitStr);
    if (JitUtf8->compare("*") == 0) {
      IsAlternateJit = true;
    }
  }
#endif

  return IsAlternateJit;
}
Пример #26
0
bool JitOptions::queryIsBreakMethod(LLILCJitContext &JitContext) {
  return queryMethodSet(JitContext, BreakMethodSet,
                        (const char16_t *)UTF16("AltJitBreakAtJitStart"));
}
Пример #27
0
/* Sends the characterlist to the client. */
void PlayerSession::SendCharacterList()
{
	if ( !IsAuthenticated() )
		return;

	/* Send the character limit and the available character licenses. */
	Buffer licensepkt;
	licensepkt.WriteUInt32( mAccount->mMaxChars );
	licensepkt.WriteUInt32( HASH_LIST_CHARLICENCES );
	licensepkt.WriteUInt32( mAccount->mLicenseCount );
	if ( mAccount->mLicenseCount > 0 )
		for ( uint32_t i = 0; i < mAccount->mLicenseCount; i++ )
			licensepkt.WriteUInt32( mAccount->mLicenses[i] );

	Send( licensepkt, MSG_CHARACTER_LICENSE );

	/* Send the character list. */
	Buffer listpkt;
	listpkt.WriteUInt32( HASH_LIST_CHARACTERS );
	listpkt.WriteUInt32( mAccount->mCharacters.size() );
	if ( mAccount->mCharacters.size() > 0 )
	{
		uint32_t index = 0;
		for ( CharacterList::iterator i = mAccount->mCharacters.begin(); i != mAccount->mCharacters.end(); ++i, index++ )
		{
			CharacterData *chara = *i;

			listpkt.WriteUInt32( HASH_OBJ_CHARACTER +  index );
			listpkt.WriteWideString( UTF16( chara->mName ) );

			listpkt.WriteUInt32( 0 );
			listpkt.WriteUInt32( chara->mClassId );
			listpkt.WriteUInt16( chara->mLevel );
			listpkt.WriteUInt32( chara->mExperience );
			listpkt.WriteUInt16( chara->mPvpLevel );
			listpkt.WriteUInt32( chara->mPvpExperience );
			listpkt.WriteUInt16( chara->mWarLevel );
			listpkt.WriteUInt32( chara->mWarExperience );
			listpkt.WriteUInt16( chara->mRebirthLevel );
			listpkt.WriteUInt16( chara->mRebirthCount );

			struct tm *timeinfo = localtime( &chara->mLastPlayed );
			listpkt.WriteUInt32( HASH_DATETIME_LASTPLAYED );
			listpkt.WriteUInt16( timeinfo->tm_year + 1900 );
			listpkt.WriteUInt16( timeinfo->tm_mon + 1 );
			listpkt.WriteUInt16( timeinfo->tm_wday );
			listpkt.WriteUInt16( timeinfo->tm_hour );
			listpkt.WriteUInt16( timeinfo->tm_min );
			listpkt.WriteUInt16( timeinfo->tm_sec );
			listpkt.WriteUInt16( 0 );

			listpkt.WriteUInt32( HASH_LIST_EQUIPMENT );
			listpkt.WriteUInt32( chara->mEquipmentCount );
			for ( uint8_t j = 0; j < chara->mEquipmentCount; j++ )
			{
				listpkt.WriteUInt32( HASH_OBJ_EQUIPMENT + j );
				listpkt.WriteUInt32( chara->mEquipment[j].mId );

				listpkt.WriteUInt32( 0x613E5DCA );
				listpkt.Write( (byte *)"\0\0\0\0\0\0\0\0\0\0\0", 11 );
			}

			listpkt.WriteUInt32( HASH_LIST_STAGELICENCES );
			listpkt.WriteUInt32( 0 );
		}
	}
	Send( listpkt, MSG_CHARACTER_LIST );
}