コード例 #1
0
ファイル: hsz.c プロジェクト: conioh/os-design
/***************************************************************************\
* ParseInstSpecificAtom
*
* Description:
* Extracts the hwnd value out of the atom.
*
* History:
* 11-1-91 sanfords Created.
\***************************************************************************/
HWND ParseInstSpecificAtom(
LATOM la,
LATOM *plaNormal)
{
    CHAR sz[256];
    LPSTR pszHwnd;
    HWND hwnd;

    /*
     * LATER- NEED TO MAKE THIS UNICODE BASED WHEN WE GET A SCANF WE CAN USE
     */
    if (GetAtomNameA(la, sz, 256) == 0) {
        return (0);
    }
    pszHwnd = strrchr(sz, '(');
    if (pszHwnd == NULL) {
        return (0);
    }
    if (sscanf(pszHwnd, "(%#p)", &hwnd) != 1) {
        return (0);
    }
    if (plaNormal != NULL) {
        *pszHwnd = '\0';
        *plaNormal = AddAtomA(sz);
    }
    return (hwnd);
}
コード例 #2
0
ファイル: main.cpp プロジェクト: tweimer/miranda-ng
int ProtoAck(WPARAM, LPARAM lParam)
{
	ACKDATA *ack = (ACKDATA *)lParam;

	if (ack->type == ACKTYPE_STATUS) {
		WORD newStatus = (WORD)ack->lParam;
		WORD oldStatus = (DWORD_PTR)ack->hProcess;
		if (oldStatus == newStatus)
			return 0;

		char *szProto = (char *)ack->szModule;
		if (newStatus == ID_STATUS_OFFLINE) {
			//The protocol switched to offline. Disable the popups for this protocol
			db_set_b(NULL, MODULE, szProto, 0);
		}
		else if (oldStatus < ID_STATUS_ONLINE && newStatus >= ID_STATUS_ONLINE) {
			//The protocol changed from a disconnected status to a connected status.
			//Enable the popups for this protocol.
			ATOM idTimer = AddAtomA(szProto);
			if (idTimer)
				SetTimer(SecretWnd, idTimer, (UINT)opt.PopupConnectionTimeout * 1000, ConnectionTimerProc);
		}
	}

	return 0;
}
コード例 #3
0
ファイル: hsz.c プロジェクト: conioh/os-design
HSZ InternalDdeCreateStringHandle(
DWORD idInst,
PVOID psz,
int iCodePage)
{
    PCL_INSTANCE_INFO pcii;
    HSZ hszRet = 0;
    int cb;
    WCHAR szw[256];

    EnterDDECrit;

    pcii = ValidateInstance((HANDLE)LongToHandle( idInst ));
    if (pcii == NULL) {
        BestSetLastDDEMLError(DMLERR_INVALIDPARAMETER);
        goto Exit;
    }

    switch (iCodePage) {
    case CP_WINANSI:
        if (*(LPSTR)psz == '\0') {
            goto Exit;
        }
        hszRet = NORMAL_HSZ_FROM_LATOM(AddAtomA((LPSTR)psz));
        break;

    default:

        /*
         * Convert psz to unicode and fall through.
         */
        cb = sizeof(szw) /  sizeof(WCHAR);
#ifdef LATER
        MultiByteToWideChar((UINT)iCodePage, MB_PRECOMPOSED,
                            (LPSTR)psz, -1, szw, cb);
#endif
        psz = &szw[0];


    case CP_WINUNICODE:
        if (*(LPWSTR)psz == L'\0') {
            goto Exit;
        }
        hszRet = NORMAL_HSZ_FROM_LATOM(AddAtomW((LPWSTR)psz));
        break;
    }
    MONHSZ(pcii, hszRet, MH_CREATE);

Exit:
    LeaveDDECrit;
    return (hszRet);
}
コード例 #4
0
static HKEY GetKeyA(LPCSTR appname, BOOL * closekey, BOOL fCreate)
{
    HKEY key = 0;
    char achName[MAX_PATH];
	HRESULT hr;
#if !MMPROFILECACHE
    *closekey = TRUE;
#else
    UINT n;
    ATOM atm;

    *closekey = FALSE;
    //
    // See if we have already used this key
    //
    atm = FindAtomA(appname);

    if (atm != 0) {
	// Atom exists... search the table for it.
        for (n=0; n<keyscached; ++n) {
            if (akeyatoms[n] == atm) {
                DPF2(("Found existing key for %s\n", appname));
                return ahkey[n];
            }
        }
    }
    DPF2(("No key found for %s", appname));
#endif

    hr = StringCchCopyA(achName, MAX_PATH, KEYNAMEA);
	if (FAILED(hr))
		OutputError(hr, IDS_SAFE_COPY);

    if ((!fCreate && RegOpenKeyA(ROOTKEY, achName, &key) == ERROR_SUCCESS)
        || (fCreate && RegCreateKeyA(ROOTKEY, achName, &key) == ERROR_SUCCESS)) {
#if MMPROFILECACHE
        if ((keyscached < KEYSCACHED)
	  && (atm = AddAtomA(appname))) {
            // Add this key to the cache array
            akeyatoms[keyscached] = atm;
            ahkey[keyscached] = key;
            DPF1(("Adding key %s to cache array in position %d\n", appname, keyscached));
            ++keyscached;
        } else {
            DPF2(("Not adding key %s to cache array\n", appname));
            *closekey = TRUE;
        }
#endif
    }

    return(key);
}
コード例 #5
0
ファイル: profile.c プロジェクト: mingpen/OpenNT
static HKEY GetKeyA(LPCSTR appname, BOOL * closekey, BOOL fCreate)
{
    HKEY key = 0;
    char achName[MAX_PATH];
#if !MMPROFILECACHE
    *closekey = TRUE;
#else
    UINT n;
    ATOM atm;

    *closekey = FALSE;
    //
    // See if we have already used this key
    //
    atm = FindAtomA(appname);

    if (atm != 0) {
	// Atom exists... search the table for it.
        for (n=0; n<keyscached; ++n) {
            if (akeyatoms[n] == atm) {
                DPF2(("Found existing key for %s\n", appname));
                return ahkey[n];
            }
        }
    }
    DPF2(("No key found for %s", appname));
#endif

    lstrcpyA(achName, KEYNAMEA);
    // Use registry under "CURRENT_USER\Software\Microsoft\Windiff\"
    //lstrcatA(achName, appname);

    if ((!fCreate && RegOpenKeyA(ROOTKEY, achName, &key) == ERROR_SUCCESS)
        || (fCreate && RegCreateKeyA(ROOTKEY, achName, &key) == ERROR_SUCCESS)) {
#if MMPROFILECACHE
        if ((keyscached < KEYSCACHED)
	  && (atm = AddAtomA(appname))) {
            // Add this key to the cache array
            akeyatoms[keyscached] = atm;
            ahkey[keyscached] = key;
            DPF1(("Adding key %s to cache array in position %d\n", appname, keyscached));
            ++keyscached;
        } else {
            DPF2(("Not adding key %s to cache array\n", appname));
            *closekey = TRUE;
        }
#endif
    }

    return(key);
}
コード例 #6
0
ファイル: atom.c プロジェクト: AmesianX/RosWine
static void test_local_error_handling(void)
{
    char buffer[260];
    WCHAR bufferW[260];
    int i;

    memset( buffer, 'a', 256 );
    buffer[256] = 0;
    ok( !AddAtomA(buffer), "add succeeded\n" );
    ok( !FindAtomA(buffer), "find succeeded\n" );

    if (unicode_OS)
    {
        for (i = 0; i < 256; i++) bufferW[i] = 'b';
        bufferW[256] = 0;
        ok( !AddAtomW(bufferW), "add succeeded\n" );
        ok( !FindAtomW(bufferW), "find succeeded\n" );
    }
}
コード例 #7
0
ファイル: atom.c プロジェクト: AmesianX/RosWine
static void test_local_get_atom_name(void)
{
    char buf[10], in[257], out[257];
    WCHAR bufW[10], inW[257], outW[257];
    int i;
    UINT len;
    static const WCHAR resultW[] = {'f','o','o','b','a','r',0,'.','.','.'};

    ATOM atom = AddAtomA( "foobar" );

    /* Get the name of the atom we added above */
    memset( buf, '.', sizeof(buf) );
    len = GetAtomNameA( atom, buf, 10 );
    ok( len == strlen("foobar"), "bad length %d\n", len );
    ok( !memcmp( buf, "foobar\0...", 10 ), "bad buffer contents\n" );

    /* Repeat, unicode-style */
    if (unicode_OS)
    {
        for (i = 0; i < 10; i++) bufW[i] = '.';
        SetLastError( 0xdeadbeef );
        len = GetAtomNameW( atom, bufW, 10 );
        ok( len && GetLastError() == 0xdeadbeef, "GetAtomNameW failed\n" );
        ok( len == lstrlenW(foobarW), "bad length %d\n", len );
        ok( !memcmp( bufW, resultW, 10*sizeof(WCHAR) ), "bad buffer contents\n" );
    }

    /* Get the name of the atom we added above */
    memset( buf, '.', sizeof(buf) );
    len = GetAtomNameA( atom, buf, 6 );
    ok( len == 5, "bad length %d\n", len );
    ok( !memcmp( buf, "fooba\0....", 10 ), "bad buffer contents\n" );
 
    /* Repeat, unicode-style */
    if (unicode_OS)
    {
        WCHAR resW[] = {'f','o','o','b','a','\0','.','.','.','.'};
        for (i = 0; i < 10; i++) bufW[i] = '.';
        SetLastError( 0xdeadbeef );
        len = GetAtomNameW( atom, bufW, 6 );
        ok( len && GetLastError() == 0xdeadbeef, "GlobalGetAtomNameW failed\n" );
        ok( len == 5, "bad length %d\n", len );
        ok( !memcmp( bufW, resW, 10*sizeof(WCHAR) ), "bad buffer contents\n" );
    }
 
    /* Check error code returns */
    memset(buf, '.', 10);
    ok( !GetAtomNameA( atom, buf,  0 ), "succeeded\n" );
    ok( !memcmp( buf, "..........", 10 ), "should not touch buffer\n" );

    if (unicode_OS)
    {
        static const WCHAR sampleW[] = {'.','.','.','.','.','.','.','.','.','.'};

        for (i = 0; i < 10; i++) bufW[i] = '.';
        ok( !GetAtomNameW( atom, bufW, 0 ), "succeeded\n" );
        ok( !memcmp( bufW, sampleW, sizeof(sampleW) ), "should not touch buffer\n" );
    }

    /* Test integer atoms */
    for (i = 0; i <= 0xbfff; i++)
    {
        memset( buf, 'a', 10 );
        len = GetAtomNameA( (ATOM)i, buf, 10 );
        if (i)
        {
            char res[20];
            ok( (len > 1) && (len < 7), "bad length %d for %s\n", len, buf );
            sprintf( res, "#%d", i );
            memset( res + strlen(res) + 1, 'a', 10 );
            ok( !memcmp( res, buf, 10 ), "bad buffer contents %s\n", buf );
        }
        else
            ok( !len, "bad length %d\n", len );

        len = GetAtomNameA( (ATOM)i, buf, 1);
        ok(!len, "succeed with %u for %u\n", len, i);

        /* ERROR_MORE_DATA is on nt3.51 sp5 */
        if (i)
            ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
               GetLastError() == ERROR_MORE_DATA,
               "wrong error conditions %u for %u\n", GetLastError(), i);
        else
            ok(GetLastError() == ERROR_INVALID_PARAMETER ||
               GetLastError() == ERROR_MORE_DATA,
               "wrong error conditions %u for %u\n", GetLastError(), i);
    }
    /* test string limits & overflow */
    do_initA(in, "abcdefghij", 255);
    atom = AddAtomA(in);
    ok(atom, "couldn't add atom for %s\n", in);
    len = GetAtomNameA(atom, out, sizeof(out));
    ok(len == 255, "length mismatch (%u instead of 255)\n", len);
    for (i = 0; i < 255; i++)
    {
        ok(out[i] == "abcdefghij"[i % 10], "wrong string at %i (%c instead of %c)\n", i, out[i], "abcdefghij"[i % 10]);
    }
    ok(out[255] == '\0', "wrong end of string\n");
    memset(out, '.', sizeof(out));
    len = GetAtomNameA(atom, out, 10);
    ok(len == 9, "succeeded %d\n", len);
    for (i = 0; i < 9; i++)
    {
        ok(out[i] == "abcdefghij"[i % 10], "wrong string at %i (%c instead of %c)\n", i, out[i], "abcdefghij"[i % 10]);
    }
    ok(out[9] == '\0', "wrong end of string\n");
    ok(out[10] == '.', "buffer overwrite\n");
    do_initA(in, "abcdefghij", 256);
    atom = AddAtomA(in);
    ok(!atom, "succeeded\n");

    /* ERROR_MORE_DATA is on nt3.51 sp5 */
    ok(GetLastError() == ERROR_INVALID_PARAMETER ||
       GetLastError() == ERROR_MORE_DATA,
       "wrong error code (%u)\n", GetLastError());

    if (unicode_OS)
    {
        /* test integral atoms */
        for (i = 0; i <= 0xbfff; i++)
        {
            memset(outW, 'a', sizeof(outW));
            len = GetAtomNameW( (ATOM)i, outW, 10 );
            if (i)
            {
                WCHAR res[20];
                
                ok( (len > 1) && (len < 7), "bad length %d\n", len );
                wsprintfW( res, integfmt, i );
                memset( res + lstrlenW(res) + 1, 'a', 10 * sizeof(WCHAR));
                ok( !memcmp( res, outW, 10 * sizeof(WCHAR) ), "bad buffer contents for %d\n", i );
            }
            else
                ok( !len, "bad length %d\n", len );

            len = GetAtomNameW( (ATOM)i, outW, 1);
            ok(!len, "succeed with %u for %u\n", len, i);

            /* ERROR_MORE_DATA is on nt3.51 sp5 */
            ok(GetLastError() == ERROR_MORE_DATA ||
               GetLastError() == (i ? ERROR_INSUFFICIENT_BUFFER : ERROR_INVALID_PARAMETER),
               "wrong error conditions %u for %u\n", GetLastError(), i);
        }
        do_initW(inW, "abcdefghij", 255);
        atom = AddAtomW(inW);
        ok(atom, "couldn't add atom for %s\n", in);
        len = GetAtomNameW(atom, outW, sizeof(outW)/sizeof(outW[0]));
        ok(len == 255, "length mismatch (%u instead of 255)\n", len);
        for (i = 0; i < 255; i++)
        {
            ok(outW[i] == "abcdefghij"[i % 10], "wrong string at %i (%c instead of %c)\n", i, outW[i], "abcdefghij"[i % 10]);
        }
        ok(outW[255] == '\0', "wrong end of string\n");
        memset(outW, '.', sizeof(outW));
        len = GetAtomNameW(atom, outW, 10);
        ok(len == 9, "succeeded %d\n", len);
        for (i = 0; i < 9; i++)
        {
            ok(outW[i] == "abcdefghij"[i % 10], "wrong string at %i (%c instead of %c)\n", i, outW[i], "abcdefghij"[i % 10]);
        }
        ok(outW[9] == '\0', "wrong end of string\n");
        ok(outW[10] == DOUBLE('.'), "buffer overwrite\n");
        do_initW(inW, "abcdefghij", 256);
        atom = AddAtomW(inW);
        ok(!atom, "succeeded\n");

        /* ERROR_MORE_DATA is on nt3.51 sp5 */
        ok(GetLastError() == ERROR_INVALID_PARAMETER ||
           GetLastError() == ERROR_MORE_DATA,
           "wrong error code (%u)\n", GetLastError());
    }
}
コード例 #8
0
ファイル: atom.c プロジェクト: AmesianX/RosWine
static void test_local_add_atom(void)
{
    ATOM atom, w_atom;
    INT_PTR i;

    SetLastError( 0xdeadbeef );
    atom = AddAtomA( "foobar" );
    ok( atom >= 0xc000, "bad atom id %x\n", atom );
    ok( GetLastError() == 0xdeadbeef, "AddAtomA set last error\n" );

    /* Verify that it can be found (or not) appropriately */
    ok( FindAtomA( "foobar" ) == atom, "could not find atom foobar\n" );
    ok( FindAtomA( "FOOBAR" ) == atom, "could not find atom FOOBAR\n" );
    ok( !FindAtomA( "_foobar" ), "found _foobar\n" );

    /* Add the same atom, specifying string as unicode; should
     * find the first one, not add a new one */
    SetLastError( 0xdeadbeef );
    w_atom = AddAtomW( foobarW );
    if (w_atom && GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
        unicode_OS = TRUE;
    else
        trace("WARNING: Unicode atom APIs are not supported on this platform\n");

    if (unicode_OS)
    {
        ok( w_atom == atom, "Unicode atom does not match ASCII\n" );
        ok( GetLastError() == 0xdeadbeef, "AddAtomW set last error\n" );
    }

    /* Verify that it can be found (or not) appropriately via unicode name */
    if (unicode_OS)
    {
        ok( FindAtomW( foobarW ) == atom, "could not find atom foobar\n" );
        ok( FindAtomW( FOOBARW ) == atom, "could not find atom FOOBAR\n" );
        ok( !FindAtomW( _foobarW ), "found _foobar\n" );
    }

    /* Test integer atoms
     * (0x0001 .. 0xbfff) should be valid;
     * (0xc000 .. 0xffff) should be invalid */

    SetLastError( 0xdeadbeef );
    ok( AddAtomA(0) == 0 && GetLastError() == 0xdeadbeef, "succeeded to add atom 0\n" );
    if (unicode_OS)
    {
        SetLastError( 0xdeadbeef );
        ok( AddAtomW(0) == 0 && GetLastError() == 0xdeadbeef, "succeeded to add atom 0\n" );
    }

    SetLastError( 0xdeadbeef );
    for (i = 1; i <= 0xbfff; i++)
    {
        SetLastError( 0xdeadbeef );
        ok( AddAtomA((LPCSTR)i) == i && GetLastError() == 0xdeadbeef,
            "failed to add atom %lx\n", i );
        if (unicode_OS)
        {
            SetLastError( 0xdeadbeef );
            ok( AddAtomW((LPCWSTR)i) == i && GetLastError() == 0xdeadbeef,
                "failed to add atom %lx\n", i );
        }
    }

    for (i = 0xc000; i <= 0xffff; i++)
    {
        ok( !AddAtomA((LPCSTR)i), "succeeded adding %lx\n", i );
        if (unicode_OS)
            ok( !AddAtomW((LPCWSTR)i), "succeeded adding %lx\n", i );
    }
}
コード例 #9
0
ServiceRegistrar::ServiceRegistrar(LPCSTR p_serviceName, fnServiceCreator p_creator)
{
	m_serviceAtom = AddAtomA(p_serviceName);
	ServiceManager::KnownService(m_serviceAtom,  p_creator);

}