示例#1
0
文件: lcompat.c 项目: mingpen/OpenNT
int
APIENTRY
lstrcmpA(
    LPCSTR lpString1,
    LPCSTR lpString2
    )
{
    int retval;

    retval = CompareStringA( GetThreadLocale(),
                             LOCALE_USE_CP_ACP,
                             lpString1,
                             -1,
                             lpString2,
                             -1 );
    if (retval == 0)
    {
        //
        // The caller is not expecting failure.  Try the system
        // default locale id.
        //
        retval = CompareStringA( GetSystemDefaultLCID(),
                                 LOCALE_USE_CP_ACP,
                                 lpString1,
                                 -1,
                                 lpString2,
                                 -1 );
    }

    if (retval == 0)
    {
        if (lpString1 && lpString2)
        {
            //
            // The caller is not expecting failure.  We've never had a
            // failure indicator before.  We'll do a best guess by calling
            // the C runtimes to do a non-locale sensitive compare.
            //
            return strcmp(lpString1, lpString2);
        }
        else if (lpString1)
        {
            return (1);
        }
        else if (lpString2)
        {
            return (-1);
        }
        else
        {
            return (0);
        }
    }

    return (retval - 2);
}
示例#2
0
static HMODULE HelperGetToucanDLL()
{
	if (g_toucan_dll)
		return g_toucan_dll;

	/*
	** We need to enumerate the DLLs loaded to find toucan dll.
	** This is done because the toucan dll changes with each update.
	** The toucan dll has the following format. "xfire_toucan_{BUILD_NUMBER}.dll"
	** We simply try to find a dll w/ the prefix "xfire_toucan"
	*/
	HANDLE snapshot_handle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
	if (snapshot_handle != INVALID_HANDLE_VALUE)
	{
		MODULEENTRY32 module_entry;
		module_entry.dwSize = sizeof(MODULEENTRY32); 

		BOOL result = Module32First(snapshot_handle, &module_entry);
		char module_name[] = "xfire_toucan";
		DWORD module_name_len = sizeof(module_name)-1;
		while (result)
		{
			if (CompareStringA(LOCALE_USER_DEFAULT, NORM_IGNORECASE, module_entry.szModule, module_name_len, module_name, module_name_len) == CSTR_EQUAL)
			{
				g_toucan_dll = module_entry.hModule;
				break;
			}
			result = Module32Next(snapshot_handle, &module_entry);
		}

		CloseHandle(snapshot_handle);
	}

	return g_toucan_dll;
}
示例#3
0
文件: batch.c 项目: r6144/wine
static const char *compare_line(const char *out_line, const char *out_end, const char *exp_line,
        const char *exp_end)
{
    const char *out_ptr = out_line, *exp_ptr = exp_line;
    const char *err = NULL;

    static const char pwd_cmd[] = {'@','p','w','d','@'};
    static const char todo_space_cmd[] = {'@','t','o','d','o','_','s','p','a','c','e','@'};
    static const char or_broken_cmd[] = {'@','o','r','_','b','r','o','k','e','n','@'};

    while(exp_ptr < exp_end) {
        if(*exp_ptr == '@') {
            if(exp_ptr+sizeof(pwd_cmd) <= exp_end
                    && !memcmp(exp_ptr, pwd_cmd, sizeof(pwd_cmd))) {
                exp_ptr += sizeof(pwd_cmd);
                if(out_end-out_ptr < workdir_len
                   || (CompareStringA(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, out_ptr, workdir_len,
                       workdir, workdir_len) != CSTR_EQUAL)) {
                    err = out_ptr;
                }else {
                    out_ptr += workdir_len;
                    continue;
                }
            }else if(exp_ptr+sizeof(todo_space_cmd) <= exp_end
                    && !memcmp(exp_ptr, todo_space_cmd, sizeof(todo_space_cmd))) {
                exp_ptr += sizeof(todo_space_cmd);
                todo_wine ok(*out_ptr == ' ', "expected space\n");
                if(out_ptr < out_end && *out_ptr == ' ')
                    out_ptr++;
                continue;
            }else if(exp_ptr+sizeof(or_broken_cmd) <= exp_end
                     && !memcmp(exp_ptr, or_broken_cmd, sizeof(or_broken_cmd))) {
                exp_ptr = exp_end;
                continue;
            }
        }else if(out_ptr == out_end || *out_ptr != *exp_ptr) {
            err = out_ptr;
        }

        if(err) {
            if(!broken(1))
                return err;

            while(exp_ptr+sizeof(or_broken_cmd) <= exp_end && memcmp(exp_ptr, or_broken_cmd, sizeof(or_broken_cmd)))
                exp_ptr++;
            if(!exp_ptr)
                return err;

            exp_ptr += sizeof(or_broken_cmd);
            out_ptr = out_line;
            err = NULL;
            continue;
        }

        exp_ptr++;
        out_ptr++;
    }

    return exp_ptr == exp_end ? NULL : out_ptr;
}
示例#4
0
/* Helper function for retrieving environment variables */
static BOOL get_env(const WCHAR * env, const char * var, char ** result)
{
    const WCHAR * p = env;
    int envlen, varlen, buflen;
    char buf[256];

    if (!env || !var || !result) return FALSE;

    varlen = strlen(var);
    do
    {
        envlen = lstrlenW(p);
        sprintf(buf, "%s", userenv_dbgstr_w(p));
        if (CompareStringA(GetThreadLocale(), NORM_IGNORECASE|LOCALE_USE_CP_ACP, buf, min(envlen, varlen), var, varlen) == CSTR_EQUAL)
        {
            if (buf[varlen] == '=')
            {
                buflen = strlen(buf);
                *result = HeapAlloc(GetProcessHeap(), 0, buflen + 1);
                if (!*result) return FALSE;
                memcpy(*result, buf, buflen + 1);
                return TRUE;
            }
        }
        p = p + envlen + 1;
    } while (*p);
    return FALSE;
}
示例#5
0
int _cdecl LCSort(const void *el1,const void *el2)
{
	char Str1[]={*reinterpret_cast<const char*>(el1),L'\0'},
		Str2[]={*reinterpret_cast<const char*>(el2),L'\0'};
	OemToCharBuffA(Str1,Str1,1);
	OemToCharBuffA(Str2,Str2,1);
	return(CompareStringA(Opt.LCIDSort,NORM_IGNORENONSPACE|SORT_STRINGSORT|NORM_IGNORECASE,Str1,1,Str2,1)-2);
}
示例#6
0
/*********************************************************************
 *		__crtCompareStringA (MSVCRT.@)
 */
int CDECL __crtCompareStringA( LCID lcid, DWORD flags, const char *src1, int len1,
                               const char *src2, int len2 )
{
    FIXME("(lcid %x, flags %x, %s(%d), %s(%d), partial stub\n",
          lcid, flags, debugstr_a(src1), len1, debugstr_a(src2), len2 );
    /* FIXME: probably not entirely right */
    return CompareStringA( lcid, flags, src1, len1, src2, len2 );
}
示例#7
0
  /* Collate */
  int _Locale_strcmp(struct _Locale_collate* lcol,
		                 const char* s1, size_t n1,
		                 const char* s2, size_t n2) {
    int result;
    if(__GetDefaultCP(lcol->lcid) == atoi(lcol->cp)) {
	    result=CompareStringA(lcol->lcid, 0, s1, n1, s2, n2);
    }
    else {
	    char *buf1, *buf2;
	    size_t size1, size2;
	    buf1 = __ConvertToCP(atoi(lcol->cp), __GetDefaultCP(lcol->lcid), s1, n1, &size1);
	    buf2 = __ConvertToCP(atoi(lcol->cp), __GetDefaultCP(lcol->lcid), s2, n2, &size2);

	    result=CompareStringA(lcol->lcid, 0, buf1, size1, buf2, size2);
	    free(buf1); free(buf2);
    }
    return (result == CSTR_EQUAL) ? 0 : (result == CSTR_LESS_THAN) ? -1 : 1;
  }
示例#8
0
int strcoll (const char* s1,const char* s2)
{
    int ret;
    ret = CompareStringA(LOCALE_USER_DEFAULT,0,s1,strlen(s1),s2,strlen(s2));
    if (ret == 0)
        return 0;
    else
        return ret - 2;
    return 0;
}
示例#9
0
/*************************************************************************
 * IntlStrEqWorkerA	[COMCTL32.376]
 *
 * Compare two strings.
 *
 * PARAMS
 *  bCase    [I] Whether to compare case sensitively
 *  lpszStr  [I] First string to compare
 *  lpszComp [I] Second string to compare
 *  iLen     [I] Length to compare
 *
 * RETURNS
 *  TRUE  If the strings are equal.
 *  FALSE Otherwise.
 */
BOOL WINAPI IntlStrEqWorkerA(BOOL bCase, LPCSTR lpszStr, LPCSTR lpszComp,
                             int iLen)
{
  DWORD dwFlags;
  int iRet;

  TRACE("(%d,%s,%s,%d)\n", bCase,
        debugstr_a(lpszStr), debugstr_a(lpszComp), iLen);

  /* FIXME: This flag is undocumented and unknown by our CompareString.
   */
  dwFlags = LOCALE_RETURN_GENITIVE_NAMES;
  if (!bCase) dwFlags |= NORM_IGNORECASE;

  iRet = CompareStringA(GetThreadLocale(),
                        dwFlags, lpszStr, iLen, lpszComp, iLen);

  if (!iRet)
    iRet = CompareStringA(2048, dwFlags, lpszStr, iLen, lpszComp, iLen);

  return iRet == CSTR_EQUAL;
}
示例#10
0
文件: misc.c 项目: slapin/wine
static BOOL check_format(LPSTR path, LPSTR inf)
{
    CHAR check[MAX_PATH];
    BOOL res;

    static const CHAR format[] = "\\INF\\oem";

    GetWindowsDirectoryA(check, MAX_PATH);
    strcat(check, format);
    res = CompareStringA(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, check, -1, path, strlen(check)) == CSTR_EQUAL &&
          path[strlen(check)] != '\\';

    return (!inf) ? res : res && (inf == path + strlen(check) - 3);
}
示例#11
0
int stricomp(const char *s1,const char *s2)
{
#ifdef _WIN_ALL
  return CompareStringA(LOCALE_USER_DEFAULT,NORM_IGNORECASE|SORT_STRINGSORT,s1,-1,s2,-1)-2;
#else
  while (toupper(*s1)==toupper(*s2))
  {
    if (*s1==0)
      return 0;
    s1++;
    s2++;
  }
  return s1 < s2 ? -1 : 1;
#endif
}
示例#12
0
bool
AbstractAirspace::MatchNamePrefix(const TCHAR *prefix) const
{
  size_t prefix_length = _tcslen(prefix);
#if defined(__WINE__) && !defined(_UNICODE)
  if (name.length() < prefix_length)
    return false;

  /* on WINE, we don't have _tcsnicmp() */
  return CompareStringA(LOCALE_USER_DEFAULT,
                        NORM_IGNORECASE|NORM_IGNOREKANATYPE|
                        NORM_IGNORENONSPACE|NORM_IGNORESYMBOLS|
                        NORM_IGNOREWIDTH,
                        name.c_str(), prefix_length,
                        prefix, prefix_length) == CSTR_EQUAL;
#else
  return _tcsnicmp(name.c_str(), prefix, prefix_length) == 0;
#endif
}
示例#13
0
static const u_char *
find_string(const u_char *bp, int *tgt, const char * const *n1,
		const char * const *n2, int c)
{
	int i;
	unsigned int len;

	/* check full name - then abbreviated ones */
	for (; n1 != NULL; n1 = n2, n2 = NULL) {
		for (i = 0; i < c; i++, n1++) {
			len = strlen(*n1);
//			if (strncasecmp(*n1, (const char *)bp, len) == 0) {
			if (CompareStringA(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, *n1, -1, (const char *)bp, len) == CSTR_EQUAL) {
				*tgt = i;
				return bp + len;
			}
		}
	}

	/* Nothing matched */
	return NULL;
}
示例#14
0
/*************************************************************************
 * COMCTL32_ChrCmpHelperA
 *
 * Internal helper for ChrCmpA/COMCTL32_ChrCmpIA.
 *
 * NOTES
 *  Both this function and its Unicode counterpart are very inefficient. To
 *  fix this, CompareString must be completely implemented and optimised
 *  first. Then the core character test can be taken out of that function and
 *  placed here, so that it need never be called at all. Until then, do not
 *  attempt to optimise this code unless you are willing to test that it
 *  still performs correctly.
 */
static BOOL COMCTL32_ChrCmpHelperA(WORD ch1, WORD ch2, DWORD dwFlags)
{
  char str1[3], str2[3];

  str1[0] = LOBYTE(ch1);
  if (IsDBCSLeadByte(str1[0]))
  {
    str1[1] = HIBYTE(ch1);
    str1[2] = '\0';
  }
  else
    str1[1] = '\0';

  str2[0] = LOBYTE(ch2);
  if (IsDBCSLeadByte(str2[0]))
  {
    str2[1] = HIBYTE(ch2);
    str2[2] = '\0';
  }
  else
    str2[1] = '\0';

  return CompareStringA(GetThreadLocale(), dwFlags, str1, -1, str2, -1) - CSTR_EQUAL;
}
示例#15
0
int strnicomp(const char *s1,const char *s2,size_t n)
{
#ifdef _WIN_ALL
  // If we specify 'n' exceeding the actual string length, CompareString goes
  // beyond the trailing zero and compares garbage. So we need to limit 'n'
  // to real string length.
  // It is important to use strnlen (or memchr(...,0)) instead of strlen,
  // because data can be not zero terminated.
  size_t l1=Min(strnlen(s1,n),n);
  size_t l2=Min(strnlen(s2,n),n);
  return CompareStringA(LOCALE_USER_DEFAULT,NORM_IGNORECASE|SORT_STRINGSORT,s1,(int)l1,s2,(int)l2)-2;
#else
  if (n==0)
    return 0;
  while (toupper(*s1)==toupper(*s2))
  {
    if (*s1==0 || --n==0)
      return 0;
    s1++;
    s2++;
  }
  return s1 < s2 ? -1 : 1;
#endif
}
示例#16
0
/**************************************************************************
 * StrCmpNA [COMCTL32.352]
 *
 * Compare two strings, up to a maximum length.
 *
 * PARAMS
 *  lpszStr  [I] First string to compare
 *  lpszComp [I] Second string to compare
 *  iLen     [I] Maximum number of chars to compare.
 *
 * RETURNS
 *  An integer less than, equal to or greater than 0, indicating that
 *  lpszStr is less than, the same, or greater than lpszComp.
 */
INT WINAPI StrCmpNA(LPCSTR lpszStr, LPCSTR lpszComp, INT iLen)
{
  TRACE("(%s,%s,%i)\n", debugstr_a(lpszStr), debugstr_a(lpszComp), iLen);
  return CompareStringA(GetThreadLocale(), 0, lpszStr, iLen, lpszComp, iLen) - CSTR_EQUAL;
}
示例#17
0
文件: test1.cpp 项目: 0-wiz-0/coreclr
int __cdecl main(int argc, char *argv[])
{    
    char str1[] = {'f','o','o',0};
    char str2[] = {'f','o','o','x',0};
    char str3[] = {'f','O','o',0};
    int flags = NORM_IGNORECASE | NORM_IGNOREWIDTH;
    int ret;

    if (0 != PAL_Initialize(argc, argv))
    {
        return FAIL;
    }

    ret = CompareStringA(0x0409, flags, str1, -1, str2, -1);
    if (ret != CSTR_LESS_THAN)
    {
        Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return "
            "CSTR_LESS_THAN!\n", str1, -1, str2, -1);
    }

    ret = CompareStringA(0x0409, flags, str1, -1, str2, 3);
    if (ret != CSTR_EQUAL)
    {
        Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return "
            "CSTR_EQUAL!\n", str1, -1, str2, 3);
    }

    ret = CompareStringA(0x0409, flags, str2, -1, str1, -1);
    if (ret != CSTR_GREATER_THAN)
    {
        Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return "
            "CSTR_GREATER_THAN!\n", str2, -1, str1, -1);
    }

    ret = CompareStringA(0x0409, flags, str1, -1, str3, -1);
    if (ret != CSTR_EQUAL)
    {
        Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return "
            "CSTR_EQUAL!\n", str1, -1, str3, -1);
    }

    ret = CompareStringA(0x0409, flags, str3, -1, str1, -1);
    if (ret != CSTR_EQUAL)
    {
        Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return "
            "CSTR_EQUAL!\n", str3, -1, str1, -1);
    }

    ret = CompareStringA(0x0409, flags, str3, -1, str1, -1);
    if (ret != CSTR_EQUAL)
    {
        Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return "
            "CSTR_EQUAL!\n", str3, -1, str1, -1);
    }

    ret = CompareStringA(0x0409, flags, str1, 0, str3, -1);
    if (ret != CSTR_LESS_THAN)
    {
        Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return "
            "CSTR_GREATER_THAN!\n", str1, 0, str3, -1);
    }

    
    ret = CompareStringA(0x0409, flags, NULL, -1, str3, -1);
    if (ret != 0)
    {
        Fail("CompareStringA should have returned 0, got %d!\n", ret);
    }
    if (GetLastError() != ERROR_INVALID_PARAMETER)
    {
        Fail("CompareStringA should have set the last error to "
            "ERROR_INVALID_PARAMETER!\n");
    }

    PAL_Terminate();

    return PASS;
}
示例#18
0
文件: ole2nls.c 项目: AlexSteel/wine
/***********************************************************************
 *           CompareStringA       (OLE2NLS.8)
 */
INT16 WINAPI CompareString16(LCID lcid, DWORD flags, LPCSTR str1, INT16 len1, LPCSTR str2, INT16 len2)
{
    return CompareStringA(lcid, flags, str1, len1, str2, len2);
}
示例#19
0
bool   str_wrap_text_iequalsa(const char *s1, const char *s2, aint len)
{
	return CSTR_EQUAL == CompareStringA(LOCALE_USER_DEFAULT,NORM_IGNORECASE,s1,len,s2,len);
}
示例#20
0
int strncasecmp(char *a,char *b,int len){
	return CompareStringA(LOCALE_INVARIANT, NORM_IGNORECASE, a, -1, b, len) -2;
}
示例#21
0
文件: batch.c 项目: Kelimion/wine
static const char *compare_line(const char *out_line, const char *out_end, const char *exp_line,
        const char *exp_end)
{
    const char *out_ptr = out_line, *exp_ptr = exp_line;
    const char *err = NULL;

    static const char pwd_cmd[] = {'@','p','w','d','@'};
    static const char drive_cmd[] = {'@','d','r','i','v','e','@'};
    static const char path_cmd[]  = {'@','p','a','t','h','@'};
    static const char shortpath_cmd[]  = {'@','s','h','o','r','t','p','a','t','h','@'};
    static const char space_cmd[] = {'@','s','p','a','c','e','@'};
    static const char tab_cmd[]   = {'@','t','a','b','@'};
    static const char or_broken_cmd[] = {'@','o','r','_','b','r','o','k','e','n','@'};

    while(exp_ptr < exp_end) {
        if(*exp_ptr == '@') {
            if(exp_ptr+sizeof(pwd_cmd) <= exp_end
                    && !memcmp(exp_ptr, pwd_cmd, sizeof(pwd_cmd))) {
                exp_ptr += sizeof(pwd_cmd);
                if(out_end-out_ptr < workdir_len
                   || (CompareStringA(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, out_ptr, workdir_len,
                       workdir, workdir_len) != CSTR_EQUAL)) {
                    err = out_ptr;
                }else {
                    out_ptr += workdir_len;
                    continue;
                }
            } else if(exp_ptr+sizeof(drive_cmd) <= exp_end
                    && !memcmp(exp_ptr, drive_cmd, sizeof(drive_cmd))) {
                exp_ptr += sizeof(drive_cmd);
                if(out_end-out_ptr < drive_len
                   || (CompareStringA(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
                                      out_ptr, drive_len, drive, drive_len) != CSTR_EQUAL)) {
                    err = out_ptr;
                }else {
                    out_ptr += drive_len;
                    continue;
                }
            } else if(exp_ptr+sizeof(path_cmd) <= exp_end
                    && !memcmp(exp_ptr, path_cmd, sizeof(path_cmd))) {
                exp_ptr += sizeof(path_cmd);
                if(out_end-out_ptr < path_len
                   || (CompareStringA(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
                                      out_ptr, path_len, path, path_len) != CSTR_EQUAL)) {
                    err = out_ptr;
                }else {
                    out_ptr += path_len;
                    continue;
                }
            } else if(exp_ptr+sizeof(shortpath_cmd) <= exp_end
                    && !memcmp(exp_ptr, shortpath_cmd, sizeof(shortpath_cmd))) {
                exp_ptr += sizeof(shortpath_cmd);
                if(out_end-out_ptr < shortpath_len
                   || (CompareStringA(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
                                      out_ptr, shortpath_len, shortpath, shortpath_len) != CSTR_EQUAL)) {
                    err = out_ptr;
                }else {
                    out_ptr += shortpath_len;
                    continue;
                }
            }else if(exp_ptr+sizeof(space_cmd) <= exp_end
                    && !memcmp(exp_ptr, space_cmd, sizeof(space_cmd))) {
                exp_ptr += sizeof(space_cmd);
                if(out_ptr < out_end && *out_ptr == ' ') {
                    out_ptr++;
                    continue;
                } else {
                    err = out_end;
                }
            }else if(exp_ptr+sizeof(tab_cmd) <= exp_end
                    && !memcmp(exp_ptr, tab_cmd, sizeof(tab_cmd))) {
                exp_ptr += sizeof(tab_cmd);
                if(out_ptr < out_end && *out_ptr == '\t') {
                    out_ptr++;
                    continue;
                } else {
                    err = out_end;
                }
            }else if(exp_ptr+sizeof(or_broken_cmd) <= exp_end
                     && !memcmp(exp_ptr, or_broken_cmd, sizeof(or_broken_cmd))) {
                if(out_ptr == out_end)
                    return NULL;
                else
                    err = out_ptr;
            }else if(out_ptr == out_end || *out_ptr != *exp_ptr)
                err = out_ptr;
        }else if(out_ptr == out_end || *out_ptr != *exp_ptr) {
            err = out_ptr;
        }

        if(err) {
            if(!broken(1))
                return err;

            while(exp_ptr+sizeof(or_broken_cmd) <= exp_end && memcmp(exp_ptr, or_broken_cmd, sizeof(or_broken_cmd)))
                exp_ptr++;
            if(!exp_ptr)
                return err;

            exp_ptr += sizeof(or_broken_cmd);
            out_ptr = out_line;
            err = NULL;
            continue;
        }

        exp_ptr++;
        out_ptr++;
    }

    if(exp_ptr != exp_end)
        return out_ptr;
    else if(out_ptr != out_end)
        return exp_end;

    return NULL;
}
示例#22
0
/*	The callback routine for the main window.
	PA: The WM_CREATE  message registers the main window as a clipboard viewer.
		The WM_DESTROY message unregisters the main window.
*/
static LRESULT CALLBACK MainWindowProcedure (HWND hWin, UINT uMess, WPARAM wPara, LPARAM lPara)
{
	switch (uMess)
	{
		case WM_NCPAINT:
			break;
		/*	WM_ENTERIDLE message is used to let Clean evaluate the initialisation action
			of a modal dialog by sending the CcWmIDLEDIALOG message.
		*/
		case WM_ENTERIDLE:
			{
				HWND hwndModalDialog;

				hwndModalDialog = (HWND)lPara;

				if (wPara == MSGF_DIALOGBOX && hwndModalDialog != ghwndLastModalDialog)
				{
					SendMessage1ToClean (CcWmIDLEDIALOG,(int)hwndModalDialog);
					ghwndLastModalDialog = hwndModalDialog;
				}
				else
				{
					SendMessage0ToClean (CcWmIDLETIMER);
				}
				return 0;
			}
			break;
		case WM_TIMER:
			{
				SendMessage2ToClean (CcWmTIMER, wPara, GetMessageTime ());
			}
			break;
		case WM_ENABLE:
			{
				HWND hwin;
				char title[64];

				hwin = GetWindow (ghMainWindow, GW_HWNDFIRST);
				while (hwin != NULL)
				{
					GetWindowText (hwin, title, 63);

					if (GetWindow (hwin, GW_OWNER) == ghMainWindow)
					{
						RECT r;
						GetWindowRect (hwin, &r);
						if (r.top != -1 || r.left != -1 || r.right != 0 || r.bottom != 0)
						{
							EnableWindow (hwin, (BOOL) wPara);
						}
					}
					hwin = GetWindow (hwin, GW_HWNDNEXT);
				}
			}
			break;
		/*	PM_SOCKET_EVENT and PM_DNS_EVENT are intercepted by MainWindowProcedure.
			If ghTCPWindow != NULL, then these messages are passed on to ghTCPWindow.
		*/
		case PM_SOCKET_EVENT:
		case PM_DNS_EVENT:
			{
				if (ghTCPWindow != NULL)
					SendMessage (ghTCPWindow, uMess, wPara, lPara);

				return 0;
			}
			break;
		case WM_DDE_INITIATE:
			{
				static char apptext[256], topictext[256];
				ATOM aApp, aTopic;
/* RWS ... */
				BOOL handleTopic;
/* ... RWS */
				GlobalGetAtomName (HIWORD (lPara), topictext, 256);

				if (lstrcmp (topictext, "CLEANOPEN") == 0)
/* RWS: compare application name */
				{
					GlobalGetAtomName (LOWORD (lPara), apptext, 256);
					handleTopic	= CompareStringA (LOCALE_USER_DEFAULT, NORM_IGNORECASE,
									apptext, lstrlen (apptext), gAppName, lstrlen (gAppName)) == 2;	/* 2 means they are equal */
				}
				else
					handleTopic	= FALSE;

				if (handleTopic)
				{
/* ... RWS */
					aApp = GlobalAddAtom (apptext);
					aTopic = GlobalAddAtom (topictext);
					SendMessage ((HWND) wPara, WM_DDE_ACK, (WPARAM) hWin, MAKELONG (aApp, aTopic));
					GlobalDeleteAtom (aApp);
					GlobalDeleteAtom (aTopic);
				}
				else
				{
					return DefWindowProc (hWin, uMess, wPara, lPara);
				}
			}
			break;
		case WM_DDE_EXECUTE:
			{
				char *commandstring;
				char *pcommand;
				int len;
				union
				{
					DDEACK ddeack;
					WORD w;
				}	da;

				pcommand = GlobalLock ((HANDLE) lPara);
				len = lstrlen (pcommand) + 1;
				commandstring = rmalloc (len);	/* this pointer is passed to and freed in the Clean code. */
				lstrcpyn (commandstring, pcommand, len);
				GlobalUnlock ((HANDLE) lPara);

				SendMessage1ToClean (CcWmDDEEXECUTE, commandstring);

				da.ddeack.bAppReturnCode = 0;
				da.ddeack.fBusy = 0;
				da.ddeack.fAck = 1;
				PostMessage ((HWND) wPara, WM_DDE_ACK, (WPARAM) hWin, PackDDElParam (WM_DDE_ACK, (UINT) da.w, lPara));
				return 0;
			}
			break;
		case WM_DDE_TERMINATE:
			{
				PostMessage ((HWND) wPara, WM_DDE_TERMINATE, (WPARAM) hWin, 0);
			} return 0;
		default:
			return DefWindowProc (hWin, uMess, wPara, lPara);
			break;
	}
	return 0;
}	/*	MainWindowProcedure */
示例#23
0
/***********************************************************************
 *           CompareStringA       (OLE2NLS.8)
 */
UINT16 WINAPI CompareString16(DWORD lcid,DWORD fdwStyle,
                              LPCSTR s1,DWORD l1,LPCSTR s2,DWORD l2)
{
	return (UINT16)CompareStringA(lcid,fdwStyle,s1,l1,s2,l2);
}
示例#24
0
int MyStringCollateNoCase(const char *s1, const char *s2)
{ 
  return ConvertCompareResult(CompareStringA(
    LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, s1, -1, s2, -1)); 
}
示例#25
0
DWORD CIME::GetImeId(UINT uIndex)
{
	static HKL hklPrev = 0;
	static DWORD dwID[2] = { 0, 0 };  // Cache the result

	DWORD   dwVerSize;
	DWORD   dwVerHandle;
	LPVOID  lpVerBuffer;
	LPVOID  lpVerData;
	UINT    cbVerData;
	char    szTmp[1024];

	if(uIndex >= sizeof(dwID) / sizeof(dwID[0]))
		return 0;

	if(hklPrev == s_hklCurrent)
		return dwID[uIndex];

	hklPrev = s_hklCurrent;  // Save for the next invocation

	// Check if we are using an older Chinese IME
	if(!((s_hklCurrent == _CHT_HKL) || (s_hklCurrent == _CHT_HKL2) || (s_hklCurrent == _CHS_HKL)))
	{
		dwID[0] = dwID[1] = 0;
		return dwID[uIndex];
	}

	// Obtain the IME file name
	if (!_ImmGetIMEFileNameA(s_hklCurrent, szTmp, (sizeof(szTmp) / sizeof(szTmp[0])) - 1))
	{
		dwID[0] = dwID[1] = 0;
		return dwID[uIndex];
	}

	// Check for IME that doesn't implement reading string API
	if (!_GetReadingString)
	{
		if((CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTmp, -1, CHT_IMEFILENAME1, -1) != CSTR_EQUAL) &&
			(CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTmp, -1, CHT_IMEFILENAME2, -1) != CSTR_EQUAL) &&
			(CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTmp, -1, CHT_IMEFILENAME3, -1) != CSTR_EQUAL) &&
			(CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTmp, -1, CHS_IMEFILENAME1, -1) != CSTR_EQUAL) &&
			(CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTmp, -1, CHS_IMEFILENAME2, -1) != CSTR_EQUAL))
		{
			dwID[0] = dwID[1] = 0;
			return dwID[uIndex];
		}
	}

	dwVerSize = _GetFileVersionInfoSizeA(szTmp, &dwVerHandle);
	if(dwVerSize)
	{
		lpVerBuffer = HeapAlloc(GetProcessHeap(), 0, dwVerSize);
		if(lpVerBuffer)
		{
			if(_GetFileVersionInfoA(szTmp, dwVerHandle, dwVerSize, lpVerBuffer))
			{
				if(_VerQueryValueA(lpVerBuffer, "\\", &lpVerData, &cbVerData))
				{
					DWORD dwVer = ((VS_FIXEDFILEINFO*)lpVerData)->dwFileVersionMS;
					dwVer = (dwVer & 0x00ff0000) << 8 | (dwVer & 0x000000ff) << 16;
					if(_GetReadingString
						||
						(GetLanguage() == LANG_CHT &&
						(dwVer == MAKEIMEVERSION(4, 2) || 
						dwVer == MAKEIMEVERSION(4, 3) || 
						dwVer == MAKEIMEVERSION(4, 4) || 
						dwVer == MAKEIMEVERSION(5, 0) ||
						dwVer == MAKEIMEVERSION(5, 1) ||
						dwVer == MAKEIMEVERSION(5, 2) ||
						dwVer == MAKEIMEVERSION(6, 0)))
						||
						(GetLanguage() == LANG_CHS &&
						(dwVer == MAKEIMEVERSION(4, 1) ||
						dwVer == MAKEIMEVERSION(4, 2) ||
						dwVer == MAKEIMEVERSION(5, 3)))
						)
					{
						dwID[0] = dwVer | GetLanguage();
						dwID[1] = ((VS_FIXEDFILEINFO*)lpVerData)->dwFileVersionLS;
					}
				}
			}
			HeapFree(GetProcessHeap(), 0, lpVerBuffer);
		}
	}

	return dwID[uIndex];
}
示例#26
0
// This function handles the ACK received from that hooked.
int handleAckSMS(WPARAM wParam, LPARAM lParam)
{
	if (!lParam)
		return 0;
	if (((ACKDATA*)lParam)->type != ICQACKTYPE_SMS)
		return 0;

	char szPhone[MAX_PHONE_LEN] = { 0 };
	TCHAR tszPhone[MAX_PHONE_LEN] = { 0 };
	LPSTR lpszXML = (LPSTR)((ACKDATA*)lParam)->lParam, lpszData, lpszPhone;
	size_t dwXMLSize = 0, dwDataSize, dwPhoneSize;
	ACKDATA *ack = ((ACKDATA*)lParam);

	if (lpszXML)
		dwXMLSize = mir_strlen(lpszXML);

	if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_message", "text", NULL)) {
		if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszPhone, &dwPhoneSize, "sms_message", "sender", NULL)) {
			LPSTR lpszMessageUTF;
			size_t dwBuffLen, dwMessageXMLEncodedSize, dwMessageXMLDecodedSize;
			DBEVENTINFO dbei = { sizeof(dbei) };

			dwBuffLen = (dwDataSize + MAX_PATH);
			dbei.pBlob = (LPBYTE)MEMALLOC((dwBuffLen + dwPhoneSize));
			LPWSTR lpwszMessageXMLEncoded = (LPWSTR)MEMALLOC((dwBuffLen*sizeof(WCHAR)));
			LPWSTR lpwszMessageXMLDecoded = (LPWSTR)MEMALLOC((dwBuffLen*sizeof(WCHAR)));
			if (dbei.pBlob && lpwszMessageXMLEncoded && lpwszMessageXMLDecoded) {
				dwMessageXMLEncodedSize = MultiByteToWideChar(CP_UTF8, 0, lpszData, (int)dwDataSize, lpwszMessageXMLEncoded, (int)dwBuffLen);
				DecodeXML(lpwszMessageXMLEncoded, dwMessageXMLEncodedSize, lpwszMessageXMLDecoded, dwBuffLen, &dwMessageXMLDecodedSize);
				lpszMessageUTF = (LPSTR)lpwszMessageXMLEncoded;
				WideCharToMultiByte(CP_UTF8, 0, lpwszMessageXMLDecoded, (int)dwMessageXMLDecodedSize, lpszMessageUTF, (int)dwBuffLen, NULL, NULL);

				dwPhoneSize = CopyNumberA(szPhone, lpszPhone, dwPhoneSize);
				dwPhoneSize = MultiByteToWideChar(CP_UTF8, 0, szPhone, (int)dwPhoneSize, tszPhone, MAX_PHONE_LEN);
				MCONTACT hContact = HContactFromPhone(tszPhone, dwPhoneSize);

				dbei.szModule = GetModuleName(hContact);
				dbei.timestamp = time(NULL);
				dbei.flags = DBEF_UTF;
				dbei.eventType = ICQEVENTTYPE_SMS;
				dbei.cbBlob = (mir_snprintf((LPSTR)dbei.pBlob, ((dwBuffLen + dwPhoneSize)), "SMS From: +%s\r\n%s", szPhone, lpszMessageUTF) + sizeof(DWORD));
				//dbei.pBlob=(LPBYTE)lpszBuff;
				(*((DWORD*)(dbei.pBlob + (dbei.cbBlob - sizeof(DWORD))))) = 0;
				MEVENT hResult = db_event_add(hContact, &dbei);
				if (hContact == NULL) {
					if (RecvSMSWindowAdd(NULL, ICQEVENTTYPE_SMS, tszPhone, dwPhoneSize, (LPSTR)dbei.pBlob, dbei.cbBlob)) {
						db_event_markRead(hContact, hResult);
						SkinPlaySound("RecvSMSMsg");
					}
				}
			}
			MEMFREE(lpwszMessageXMLDecoded);
			MEMFREE(lpwszMessageXMLEncoded);
			MEMFREE(dbei.pBlob);
		}
	}
	else
		if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_delivery_receipt", "delivered", NULL)) {
			if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszPhone, &dwPhoneSize, "sms_delivery_receipt", "destination", NULL)) {
				dwPhoneSize = CopyNumberA(szPhone, lpszPhone, dwPhoneSize);
				dwPhoneSize = MultiByteToWideChar(CP_UTF8, 0, szPhone, (int)dwPhoneSize, tszPhone, MAX_PHONE_LEN);
				MCONTACT hContact = HContactFromPhone(tszPhone, dwPhoneSize);

				DBEVENTINFO dbei = { 0 };
				dbei.cbSize = sizeof(dbei);
				dbei.szModule = GetModuleName(hContact);
				dbei.timestamp = time(NULL);
				dbei.flags = DBEF_UTF;
				dbei.eventType = ICQEVENTTYPE_SMSCONFIRMATION;
				if (CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "yes", 3) == CSTR_EQUAL) {
					dbei.cbBlob = (MAX_PHONE_LEN + MAX_PATH);
					dbei.pBlob = (PBYTE)MEMALLOC(dbei.cbBlob);
					if (dbei.pBlob) dbei.cbBlob = (mir_snprintf((LPSTR)dbei.pBlob, dbei.cbBlob, "SMS Confirmation From: +%s\r\nSMS was sent succesfully", szPhone) + 4);
				}
				else {
					if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_delivery_receipt", "error", "params", "param", NULL) == FALSE) {
						lpszData = "";
						dwDataSize = 0;
					}
					dbei.cbBlob = (int)(MAX_PHONE_LEN + MAX_PATH + dwDataSize);
					dbei.pBlob = (PBYTE)MEMALLOC(dbei.cbBlob);
					if (dbei.pBlob) {
						dbei.cbBlob = mir_snprintf((LPSTR)dbei.pBlob, dbei.cbBlob, "SMS Confirmation From: +%s\r\nSMS was not sent succesfully: ", szPhone);
						memcpy((dbei.pBlob + dbei.cbBlob), lpszData, dwDataSize);
						dbei.cbBlob += (int)(dwDataSize + sizeof(DWORD));
						(*((DWORD*)(dbei.pBlob + (dbei.cbBlob - sizeof(DWORD))))) = 0;
					}
				}

				if (dbei.pBlob) {
					if (hContact)
						db_event_add(hContact, &dbei);
					else
						RecvSMSWindowAdd(NULL, ICQEVENTTYPE_SMSCONFIRMATION, tszPhone, dwPhoneSize, (LPSTR)dbei.pBlob, dbei.cbBlob);

					MEMFREE(dbei.pBlob);
				}
			}
		}
		else
			if ((ack->result == ACKRESULT_FAILED) || GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_response", "deliverable", NULL)) {
				HWND hWndDlg = SendSMSWindowHwndByHProcessGet(ack->hProcess);
				if (hWndDlg) {
					char szNetwork[MAX_PATH];

					KillTimer(hWndDlg, wParam);
					GetXMLFieldExBuff(lpszXML, dwXMLSize, szNetwork, sizeof(szNetwork), NULL, "sms_response", "network", NULL);

					if (ack->result == ACKRESULT_FAILED || CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "no", 2) == CSTR_EQUAL) {
						char szBuff[1024];
						TCHAR tszErrorMessage[1028];
						LPSTR lpszErrorDescription;

						if (SendSMSWindowMultipleGet(hWndDlg)) {
							TVITEM tvi;
							tvi.mask = TVIF_TEXT;
							tvi.hItem = SendSMSWindowHItemSendGet(hWndDlg);
							tvi.pszText = tszPhone;
							tvi.cchTextMax = _countof(tszPhone);
							TreeView_GetItem(GetDlgItem(hWndDlg, IDC_NUMBERSLIST), &tvi);
						}
						else GetDlgItemText(hWndDlg, IDC_ADDRESS, tszPhone, _countof(szPhone));

						if (ack->result == ACKRESULT_FAILED)
							lpszErrorDescription = lpszXML;
						else {
							lpszErrorDescription = szBuff;
							GetXMLFieldExBuff(lpszXML, dwXMLSize, szBuff, sizeof(szBuff), NULL, "sms_response", "error", "params", "param", NULL);
						}

						mir_sntprintf(tszErrorMessage, TranslateT("SMS message didn't send by %S to %s because: %S"), szNetwork, tszPhone, lpszErrorDescription);
						ShowWindow(hWndDlg, SW_SHOWNORMAL);
						EnableWindow(hWndDlg, FALSE);
						HWND hwndTimeOut = CreateDialog(ssSMSSettings.hInstance, MAKEINTRESOURCE(IDD_SENDSMSTIMEDOUT), hWndDlg, SMSTimedOutDlgProc);
						SetDlgItemText(hwndTimeOut, IDC_STATUS, tszErrorMessage);
					}
					else {
						SendSMSWindowDBAdd(hWndDlg);
						if (SendSMSWindowMultipleGet(hWndDlg)) {
							if (SendSMSWindowNextHItemGet(hWndDlg, SendSMSWindowHItemSendGet(hWndDlg))) {
								SendSMSWindowAsSentSet(hWndDlg);
								SendSMSWindowHItemSendSet(hWndDlg, SendSMSWindowNextHItemGet(hWndDlg, SendSMSWindowHItemSendGet(hWndDlg)));
								SendSMSWindowNext(hWndDlg);
							}
							else SendSMSWindowRemove(hWndDlg);
						}
						else {
							if (CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "yes", 3) == CSTR_EQUAL ||
								CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "smtp", 4) == CSTR_EQUAL) {
								char szSource[MAX_PATH], szMessageID[MAX_PATH];

								if (DB_SMS_GetByte(NULL, "ShowACK", SMS_DEFAULT_SHOWACK)) {
									HWND hwndAccepted = CreateDialog(ssSMSSettings.hInstance, MAKEINTRESOURCE(IDD_SENDSMSACCEPT), hWndDlg, SMSAcceptedDlgProc);
									if (CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "yes", 3) == CSTR_EQUAL) {
										GetXMLFieldExBuff(lpszXML, dwXMLSize, szSource, sizeof(szSource), NULL, "sms_response", "source", NULL);
										GetXMLFieldExBuff(lpszXML, dwXMLSize, szMessageID, sizeof(szMessageID), NULL, "sms_response", "message_id", NULL);
									}
									else {
										SetDlgItemText(hwndAccepted, IDC_ST_SOURCE, TranslateT("From:"));
										SetDlgItemText(hwndAccepted, IDC_ST_MESSAGEID, TranslateT("To:"));
										GetXMLFieldExBuff(lpszXML, dwXMLSize, szSource, sizeof(szSource), NULL, "sms_response", "from", NULL);
										GetXMLFieldExBuff(lpszXML, dwXMLSize, szMessageID, sizeof(szMessageID), NULL, "sms_response", "to", NULL);
									}
									SetDlgItemTextA(hwndAccepted, IDC_NETWORK, szNetwork);
									SetDlgItemTextA(hwndAccepted, IDC_SOURCE, szSource);
									SetDlgItemTextA(hwndAccepted, IDC_MESSAGEID, szMessageID);
								}
								else SendSMSWindowRemove(hWndDlg);
							}
							else SendSMSWindowRemove(hWndDlg);
						}
					}
				}
			}
	return 0;
}
int __cdecl __crtCompareStringW(
        LCID     Locale,
        DWORD    dwCmpFlags,
        LPCWSTR  lpString1,
        int      cchCount1,
        LPCWSTR  lpString2,
        int      cchCount2,
        int      code_page
        )
{
        static int f_use = 0;

        /*
         * Look for unstubbed 'preferred' flavor. Otherwise use available flavor.
         * Must actually call the function to ensure it's not a stub.
         */

        if (0 == f_use)
        {
            if (0 != CompareStringW(0, 0, L"\0", 1, L"\0", 1))
                f_use = USE_W;

            else if (0 != CompareStringA(0, 0, "\0", 1, "\0", 1))
                f_use = USE_A;

            else
                return 0;
        }

        /*
         * CompareString will compare past NULL. Must find NULL if in string
         * before cchCountn wide characters.
         */

        if (cchCount1 > 0)
            cchCount1= wcsncnt(lpString1, cchCount1);
        if (cchCount2 > 0)
            cchCount2= wcsncnt(lpString2, cchCount2);

        if (!cchCount1 || !cchCount2)
            return (cchCount1 - cchCount2 == 0) ? 2 :
                   (cchCount1 - cchCount2 < 0) ? 1 : 3;

        /* Use "W" version */

        if (USE_W == f_use)
        {
            return CompareStringW( Locale,
                                   dwCmpFlags,
                                   lpString1,
                                   cchCount1,
                                   lpString2,
                                   cchCount2 );
        }

        /* Use "A" version */

        if (USE_A == f_use)
        {
            int buff_size1;
            int buff_size2;
            unsigned char *buffer1;
            unsigned char *buffer2;

            /*
             * Use __lc_codepage for conversion if code_page not specified
             */

            if (0 == code_page)
                code_page = __lc_codepage;

            /*
             * Convert strings and return the requested information.
             */

            /* find out how big a buffer we need (includes NULL if any) */
            if ( 0 == (buff_size1 = WideCharToMultiByte( code_page,
                                                         WC_COMPOSITECHECK |
                                                            WC_SEPCHARS,
                                                         lpString1,
                                                         cchCount1,
                                                         NULL,
                                                         0,
                                                         NULL,
                                                         NULL )) )
                return 0;

            /* allocate enough space for chars */
            __try {
                buffer1 = (unsigned char *)_alloca( buff_size1 * sizeof(char) );
            }
            __except( EXCEPTION_EXECUTE_HANDLER ) {
                buffer1 = NULL;
            }

            if ( buffer1 == NULL )
                return 0;

            /* do the conversion */
            if ( 0 == WideCharToMultiByte( code_page,
                                           WC_COMPOSITECHECK | WC_SEPCHARS,
                                           lpString1,
                                           cchCount1,
                                           buffer1,
                                           buff_size1,
                                           NULL,
                                           NULL ) )
                return 0;

            /* find out how big a buffer we need (includes NULL if any) */
            if ( 0 == (buff_size2 = WideCharToMultiByte( code_page,
                                                         WC_COMPOSITECHECK |
                                                            WC_SEPCHARS,
                                                         lpString2,
                                                         cchCount2,
                                                         NULL,
                                                         0,
                                                         NULL,
                                                         NULL )) )
                return 0;

            /* allocate enough space for chars */
            __try {
                buffer2 = (unsigned char *)_alloca( buff_size2 * sizeof(char) );
            }
            __except( EXCEPTION_EXECUTE_HANDLER ) {
                buffer2 = NULL;
            }

            if ( buffer2 == NULL )
                return 0;

            /* do the conversion */
            if ( 0 == WideCharToMultiByte( code_page,
                                           WC_COMPOSITECHECK | WC_SEPCHARS,
                                           lpString2,
                                           cchCount2,
                                           buffer2,
                                           buff_size2,
                                           NULL,
                                           NULL ) )
                return 0;

            return CompareStringA( Locale,
                                   dwCmpFlags,
                                   buffer1,
                                   buff_size1,
                                   buffer2,
                                   buff_size2 );
        }