Exemplo n.º 1
0
netbios_name::netbios_name(LPCTSTR n, UCHAR type, bool group, UCHAR lana) :
	m_managed (false),
	m_registered (false),
	m_duplicated (false),
	m_error (false),
	m_lana (lana),
	m_listener (NULL),
	m_dgreceiver (NULL),
	m_term (NULL)
{
	// Преобразование имени в NetBIOS-имя
	int len = NCBNAMSZ - 1;
	CT2A nA( n );
	LPCSTR src = (LPCSTR)nA;
	LPSTR dst = (LPSTR)netbiosed.name;
	for ( ; len && *src; --len, ++dst, ++src )
		*dst = *src;
	for ( ; len; --len )
		*dst++ = ' ';
	*dst = (CHAR)type;
	CharUpperBuffA( (LPSTR)netbiosed.name, NCBNAMSZ - 1 );
	CharToOemBuffA( (LPSTR)netbiosed.name, (LPSTR)netbiosed.name, NCBNAMSZ - 1 );
	netbiosed.name_num = 0;
	netbiosed.name_flags = (UCHAR)( group ? GROUP_NAME : UNIQUE_NAME );

	original = GetANSIName();
}
Exemplo n.º 2
0
ZIPINLINE void ZipPlatform::AnsiOem(CZipAutoBuffer& buffer, bool bAnsiToOem)
{
	if (bAnsiToOem)
		CharToOemBuffA(buffer, buffer, buffer.GetSize());
	else
		OemToCharBuffA(buffer, buffer, buffer.GetSize());
}
Exemplo n.º 3
0
Arquivo: text.c Projeto: RPG-7/reactos
/*
 * @implemented
 */
BOOL
WINAPI
CharToOemA(LPCSTR s, LPSTR d)
{
    if (!s || !d) return TRUE;
    return CharToOemBuffA(s, d, strlen(s) + 1);
}
const CHAR CConvOem::toOemA(const CHAR chSrc)
{
	if (m_blInvalidBuff)
	{
		SetLastError(ERROR_INVALID_ADDRESS);
		return EOF;
	}
	CharToOemBuffA(&chSrc, m_szBuff, 1);
	return *m_szBuff;
}
Exemplo n.º 5
0
ZIPINLINE void ZipPlatform::AnsiOem(CZipAutoBuffer& buffer, bool bAnsiToOem)
{
#ifdef _ZIP_SAFE_WINDOWS_API
	UINT cpIn, cpOut;
	if (bAnsiToOem)
	{
		cpIn = CP_ACP;
		cpOut = CP_OEMCP;
	}
	else
	{
		cpIn = CP_OEMCP;
		cpOut = CP_ACP;
	}

	CZipAutoBuffer interBuffer;

	int size = buffer.GetSize();
	// iLen doesn't include terminating character
	int iLen = MultiByteToWideChar(cpIn, MB_PRECOMPOSED, buffer, size, NULL, 0);
	if (iLen <= 0)
		return;
	interBuffer.Allocate(iLen * sizeof(wchar_t));
	LPWSTR lpszWide = (LPWSTR)(char*)interBuffer;
	iLen = MultiByteToWideChar(cpIn, MB_PRECOMPOSED, buffer, size, lpszWide, iLen);
	ASSERT(iLen != 0);

	// iLen does not include terminating character
	size = WideCharToMultiByte(cpOut, 0, lpszWide, iLen, NULL, 0, NULL, NULL);
	if (size <= 0)
		return;
	buffer.Allocate(size);
	size = WideCharToMultiByte(cpOut, 0, lpszWide, iLen, buffer, size, NULL, NULL);
	ASSERT(size != 0);
#else
	if (bAnsiToOem)
		CharToOemBuffA(buffer, buffer, buffer.GetSize());
	else
		OemToCharBuffA(buffer, buffer, buffer.GetSize());
#endif
}
Exemplo n.º 6
0
void LogerManager::showColorText(const char *text, int level)
{

#if defined(WIN32) && defined(LOG4Z_OEM_CONSOLE)
    char oem[LOG4Z_LOG_BUF_SIZE] = { 0 };
    CharToOemBuffA(text, oem, LOG4Z_LOG_BUF_SIZE);
#endif

    if (level <= LOG_LEVEL_DEBUG || level > LOG_LEVEL_FATAL)
    {
#if defined(WIN32) && defined(LOG4Z_OEM_CONSOLE)
        printf("%s", oem);
#else
        printf("%s", text);
#endif
        return;
    }
#ifndef WIN32
    printf("%s%s\e[0m", LOG_COLOR[level], text);
#else
    AutoLock l(_scLock);
    HANDLE hStd = ::GetStdHandle(STD_OUTPUT_HANDLE);
    if (hStd == INVALID_HANDLE_VALUE) return;
    CONSOLE_SCREEN_BUFFER_INFO oldInfo;
    if (!GetConsoleScreenBufferInfo(hStd, &oldInfo))
    {
        return;
    }
    else
    {
        SetConsoleTextAttribute(hStd, LOG_COLOR[level]);
#ifdef LOG4Z_OEM_CONSOLE
		printf("%s", oem);
#else
		printf("%s", text);
#endif
		SetConsoleTextAttribute(hStd, oldInfo.wAttributes);
    }
#endif
    return;
}
Exemplo n.º 7
0
/***********************************************************************
 *           AnsiToOemBuff   (KEYBOARD.134)
 */
void WINAPI AnsiToOemBuff16( LPCSTR s, LPSTR d, UINT16 len )
{
    if (len != 0) CharToOemBuffA( s, d, len );
}
Exemplo n.º 8
0
void COEMFile::Write(const void FAR* lpBuf, UINT nCount)
{
	CharToOemBuffA((const char*)lpBuf, (char*)lpBuf, nCount);
	CTrackFile::Write(lpBuf, nCount);
}
Exemplo n.º 9
0
/*
 * @implemented
 */
HANDLE
WINAPI
GetClipboardData(UINT uFormat)
{
    HANDLE hData = NULL;
    PVOID pData = NULL;
    DWORD cbData = 0;
    GETCLIPBDATA gcd;

    hData = NtUserGetClipboardData(uFormat, &gcd);
    if (!hData)
        return NULL;

    if (gcd.fGlobalHandle)
    {
        HANDLE hGlobal;

        NtUserCreateLocalMemHandle(hData, NULL, 0, &cbData);
        hGlobal = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, cbData);
        pData = GlobalLock(hGlobal);
        NtUserCreateLocalMemHandle(hData, pData, cbData, NULL);
        hData = hGlobal;
    }

    if (gcd.uFmtRet != uFormat)
    {
        SETCLIPBDATA scd = {FALSE, FALSE};
        HANDLE hNewData = NULL;
        PVOID pNewData = NULL;

        /* Synthesize requested format */
        switch (uFormat)
        {
            case CF_TEXT:
                if (gcd.uFmtRet == CF_UNICODETEXT)
                    pNewData = IntSynthesizeMultiByte(pData, cbData, uFormat == CF_OEMTEXT);
                else // CF_OEMTEXT
                    OemToCharBuffA(pData, pData, cbData);
                break;
            case CF_OEMTEXT:
                if (gcd.uFmtRet == CF_UNICODETEXT)
                    pNewData = IntSynthesizeMultiByte(pData, cbData, uFormat == CF_OEMTEXT);
                else
                    CharToOemBuffA(pData, pData, cbData);
                break;
            case CF_UNICODETEXT:
                pNewData = IntSynthesizeWideChar(pData, cbData, gcd.uFmtRet == CF_OEMTEXT);
                break;
            default:
                FIXME("Format: %u != %u\n", uFormat, gcd.uFmtRet);
        }

        /* Is it a global handle? */
        if (pNewData)
            hNewData = GlobalHandle(pNewData);

        if (hNewData)
        {
            /* Free old data */
            if (pData)
            {
                GlobalUnlock(hData);
                GlobalFree(hData);
            }
            hData = hNewData;
            pData = pNewData;
        }

        /* Save synthesized format in clibboard */
        if (pData)
        {
            HANDLE hMem;

            scd.fGlobalHandle = TRUE;
            hMem = NtUserConvertMemHandle(pData, GlobalSize(hData));
            NtUserSetClipboardData(uFormat, hMem, &scd);
        }
        else if (hData)
            NtUserSetClipboardData(uFormat, hData, &scd);
    }

    /* Unlock global handle */
    if (pData)
        GlobalUnlock(hData);

    return hData;
}