1998-12-04 18:28:13 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
2015-11-14 14:57:11 +00:00
|
|
|
* FILE: dll/win32/kernel32/winnls/string/lstring.c
|
1998-12-04 18:28:13 +00:00
|
|
|
* PURPOSE: Local string functions
|
|
|
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* Created 01/11/98
|
|
|
|
*/
|
1999-03-19 05:55:55 +00:00
|
|
|
|
2003-01-15 21:24:36 +00:00
|
|
|
#include <k32.h>
|
1998-10-05 04:00:59 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1998-10-05 04:00:59 +00:00
|
|
|
int
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2008-05-12 20:11:11 +00:00
|
|
|
lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
|
1998-10-05 04:00:59 +00:00
|
|
|
{
|
2008-05-12 20:11:11 +00:00
|
|
|
int Result;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2008-05-12 20:11:11 +00:00
|
|
|
if (lpString1 == lpString2)
|
|
|
|
return 0;
|
|
|
|
if (lpString1 == NULL)
|
|
|
|
return -1;
|
|
|
|
if (lpString2 == NULL)
|
|
|
|
return 1;
|
2004-12-04 19:52:55 +00:00
|
|
|
|
2008-05-12 20:11:11 +00:00
|
|
|
Result = CompareStringA(GetThreadLocale(), 0, lpString1, -1, lpString2, -1);
|
2017-03-06 19:17:53 +00:00
|
|
|
if (Result)
|
|
|
|
Result -= 2;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2008-05-12 20:11:11 +00:00
|
|
|
return Result;
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1998-10-05 04:00:59 +00:00
|
|
|
int
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2008-05-12 20:11:11 +00:00
|
|
|
lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
|
1998-10-05 04:00:59 +00:00
|
|
|
{
|
2008-05-12 20:11:11 +00:00
|
|
|
int Result;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2008-05-12 20:11:11 +00:00
|
|
|
if (lpString1 == lpString2)
|
|
|
|
return 0;
|
|
|
|
if (lpString1 == NULL)
|
|
|
|
return -1;
|
|
|
|
if (lpString2 == NULL)
|
|
|
|
return 1;
|
2004-12-04 19:52:55 +00:00
|
|
|
|
2008-05-12 20:11:11 +00:00
|
|
|
Result = CompareStringA(GetThreadLocale(), NORM_IGNORECASE, lpString1, -1, lpString2, -1);
|
|
|
|
if (Result)
|
|
|
|
Result -= 2;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2008-05-12 20:11:11 +00:00
|
|
|
return Result;
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|
1999-10-07 23:46:27 +00:00
|
|
|
|
2017-03-06 19:17:53 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1998-10-05 04:00:59 +00:00
|
|
|
LPSTR
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2008-05-12 20:11:11 +00:00
|
|
|
lstrcpynA(LPSTR lpString1, LPCSTR lpString2, int iMaxLength)
|
1998-10-05 04:00:59 +00:00
|
|
|
{
|
2006-05-03 10:55:46 +00:00
|
|
|
LPSTR d = lpString1;
|
|
|
|
LPCSTR s = lpString2;
|
|
|
|
UINT count = iMaxLength;
|
|
|
|
LPSTR Ret = NULL;
|
2004-07-04 18:11:49 +00:00
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2004-01-28 08:51:09 +00:00
|
|
|
{
|
2006-05-03 10:55:46 +00:00
|
|
|
while ((count > 1) && *s)
|
2004-01-28 08:51:09 +00:00
|
|
|
{
|
2006-05-03 10:55:46 +00:00
|
|
|
count--;
|
|
|
|
*d++ = *s++;
|
2004-01-28 08:51:09 +00:00
|
|
|
}
|
2008-05-12 20:11:11 +00:00
|
|
|
|
|
|
|
if (count)
|
|
|
|
*d = 0;
|
2006-05-03 10:55:46 +00:00
|
|
|
|
|
|
|
Ret = lpString1;
|
2004-02-02 15:50:16 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2009-06-23 23:06:10 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2004-01-28 08:51:09 +00:00
|
|
|
|
2006-05-03 10:55:46 +00:00
|
|
|
return Ret;
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1998-10-05 04:00:59 +00:00
|
|
|
LPSTR
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2008-05-12 20:11:11 +00:00
|
|
|
lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
|
1998-10-05 04:00:59 +00:00
|
|
|
{
|
2006-05-03 10:55:46 +00:00
|
|
|
LPSTR Ret = NULL;
|
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2006-05-03 10:55:46 +00:00
|
|
|
{
|
|
|
|
memmove(lpString1, lpString2, strlen(lpString2) + 1);
|
|
|
|
Ret = lpString1;
|
2008-05-12 20:11:11 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2009-06-23 23:06:10 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2004-07-04 18:11:49 +00:00
|
|
|
|
2006-05-03 10:55:46 +00:00
|
|
|
return Ret;
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1998-10-05 04:00:59 +00:00
|
|
|
LPSTR
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2008-05-12 20:11:11 +00:00
|
|
|
lstrcatA(LPSTR lpString1, LPCSTR lpString2)
|
1998-10-05 04:00:59 +00:00
|
|
|
{
|
2006-05-03 10:55:46 +00:00
|
|
|
LPSTR Ret = NULL;
|
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2006-05-03 10:55:46 +00:00
|
|
|
{
|
|
|
|
Ret = strcat(lpString1, lpString2);
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2009-06-23 23:06:10 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2006-05-03 10:55:46 +00:00
|
|
|
|
|
|
|
return Ret;
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1998-10-05 04:00:59 +00:00
|
|
|
int
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2008-05-12 20:11:11 +00:00
|
|
|
lstrlenA(LPCSTR lpString)
|
1998-10-05 04:00:59 +00:00
|
|
|
{
|
2006-05-03 10:55:46 +00:00
|
|
|
INT Ret = 0;
|
|
|
|
|
2017-03-06 19:17:53 +00:00
|
|
|
if (lpString == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2006-05-03 10:55:46 +00:00
|
|
|
{
|
|
|
|
Ret = strlen(lpString);
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2009-06-23 23:06:10 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2006-05-03 10:55:46 +00:00
|
|
|
|
|
|
|
return Ret;
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1998-10-05 04:00:59 +00:00
|
|
|
int
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2008-05-12 20:11:11 +00:00
|
|
|
lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
|
1998-10-05 04:00:59 +00:00
|
|
|
{
|
2008-05-12 20:11:11 +00:00
|
|
|
int Result;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2008-05-12 20:11:11 +00:00
|
|
|
if (lpString1 == lpString2)
|
|
|
|
return 0;
|
|
|
|
if (lpString1 == NULL)
|
|
|
|
return -1;
|
|
|
|
if (lpString2 == NULL)
|
|
|
|
return 1;
|
2004-12-04 19:52:55 +00:00
|
|
|
|
2008-05-12 20:11:11 +00:00
|
|
|
Result = CompareStringW(GetThreadLocale(), 0, lpString1, -1, lpString2, -1);
|
|
|
|
if (Result)
|
|
|
|
Result -= 2;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2008-05-12 20:11:11 +00:00
|
|
|
return Result;
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1998-10-05 04:00:59 +00:00
|
|
|
int
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2008-05-12 20:11:11 +00:00
|
|
|
lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
|
1998-10-05 04:00:59 +00:00
|
|
|
{
|
2008-05-12 20:11:11 +00:00
|
|
|
int Result;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2008-05-12 20:11:11 +00:00
|
|
|
if (lpString1 == lpString2)
|
|
|
|
return 0;
|
|
|
|
if (lpString1 == NULL)
|
|
|
|
return -1;
|
|
|
|
if (lpString2 == NULL)
|
|
|
|
return 1;
|
2004-12-04 19:52:55 +00:00
|
|
|
|
2008-05-12 20:11:11 +00:00
|
|
|
Result = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, lpString1, -1, lpString2, -1);
|
|
|
|
if (Result)
|
|
|
|
Result -= 2;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2008-05-12 20:11:11 +00:00
|
|
|
return Result;
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1998-10-05 04:00:59 +00:00
|
|
|
LPWSTR
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2008-05-12 20:11:11 +00:00
|
|
|
lstrcpynW(LPWSTR lpString1, LPCWSTR lpString2, int iMaxLength)
|
1998-10-05 04:00:59 +00:00
|
|
|
{
|
2006-05-03 10:55:46 +00:00
|
|
|
LPWSTR d = lpString1;
|
|
|
|
LPCWSTR s = lpString2;
|
|
|
|
UINT count = iMaxLength;
|
|
|
|
LPWSTR Ret = NULL;
|
2004-07-04 18:11:49 +00:00
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2004-01-28 08:51:09 +00:00
|
|
|
{
|
2006-05-03 10:55:46 +00:00
|
|
|
while ((count > 1) && *s)
|
2004-01-28 08:51:09 +00:00
|
|
|
{
|
2006-05-03 10:55:46 +00:00
|
|
|
count--;
|
|
|
|
*d++ = *s++;
|
2004-01-28 08:51:09 +00:00
|
|
|
}
|
2008-05-12 20:11:11 +00:00
|
|
|
|
|
|
|
if (count)
|
|
|
|
*d = 0;
|
2006-05-03 10:55:46 +00:00
|
|
|
|
|
|
|
Ret = lpString1;
|
2004-02-02 15:50:16 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2009-06-23 23:06:10 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2004-01-28 08:51:09 +00:00
|
|
|
|
2006-05-03 10:55:46 +00:00
|
|
|
return Ret;
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1998-10-05 04:00:59 +00:00
|
|
|
LPWSTR
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2008-05-12 20:11:11 +00:00
|
|
|
lstrcpyW(LPWSTR lpString1, LPCWSTR lpString2)
|
1998-10-05 04:00:59 +00:00
|
|
|
{
|
2006-05-03 10:55:46 +00:00
|
|
|
LPWSTR Ret = NULL;
|
2004-07-04 18:11:49 +00:00
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2006-05-03 10:55:46 +00:00
|
|
|
{
|
2006-05-05 17:16:05 +00:00
|
|
|
Ret = wcscpy(lpString1, lpString2);
|
2006-05-03 10:55:46 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2009-06-23 23:06:10 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2006-05-03 10:55:46 +00:00
|
|
|
|
|
|
|
return Ret;
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1998-10-05 04:00:59 +00:00
|
|
|
LPWSTR
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2008-05-12 20:11:11 +00:00
|
|
|
lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
|
1998-10-05 04:00:59 +00:00
|
|
|
{
|
2006-05-03 10:55:46 +00:00
|
|
|
LPWSTR Ret = NULL;
|
2004-07-04 18:11:49 +00:00
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2006-05-03 10:55:46 +00:00
|
|
|
{
|
|
|
|
Ret = wcscat(lpString1, lpString2);
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2009-06-23 23:06:10 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2006-05-03 10:55:46 +00:00
|
|
|
|
|
|
|
return Ret;
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1998-10-05 04:00:59 +00:00
|
|
|
int
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2008-05-12 20:11:11 +00:00
|
|
|
lstrlenW(LPCWSTR lpString)
|
1998-10-05 04:00:59 +00:00
|
|
|
{
|
2006-05-03 10:55:46 +00:00
|
|
|
INT Ret = 0;
|
|
|
|
|
2017-03-06 19:17:53 +00:00
|
|
|
if (lpString == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2006-05-03 10:55:46 +00:00
|
|
|
{
|
|
|
|
Ret = wcslen(lpString);
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2009-06-23 23:06:10 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2006-05-03 10:55:46 +00:00
|
|
|
|
|
|
|
return Ret;
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|