mirror of https://github.com/FreeRDP/FreeRDP
[winpr,string] remove duplicate string functions
prefer standard C functions over window specific ones
This commit is contained in:
parent
4f7a3762ae
commit
b46a4ce750
|
@ -166,24 +166,6 @@ extern "C"
|
|||
#define IsCharLower IsCharLowerW
|
||||
#else
|
||||
#define IsCharLower IsCharLowerA
|
||||
#endif
|
||||
|
||||
WINPR_API int lstrlenA(LPCSTR lpString);
|
||||
WINPR_API int lstrlenW(LPCWSTR lpString);
|
||||
|
||||
#ifdef UNICODE
|
||||
#define lstrlen lstrlenW
|
||||
#else
|
||||
#define lstrlen lstrlenA
|
||||
#endif
|
||||
|
||||
WINPR_API int lstrcmpA(LPCSTR lpString1, LPCSTR lpString2);
|
||||
WINPR_API int lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2);
|
||||
|
||||
#ifdef UNICODE
|
||||
#define lstrcmp lstrcmpW
|
||||
#else
|
||||
#define lstrcmp lstrcmpA
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -640,46 +640,6 @@ BOOL IsCharLowerW(WCHAR ch)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int lstrlenA(LPCSTR lpString)
|
||||
{
|
||||
return (int)strlen(lpString);
|
||||
}
|
||||
|
||||
int lstrlenW(LPCWSTR lpString)
|
||||
{
|
||||
LPCWSTR p;
|
||||
|
||||
if (!lpString)
|
||||
return 0;
|
||||
|
||||
p = (LPCWSTR)lpString;
|
||||
|
||||
while (*p)
|
||||
p++;
|
||||
|
||||
return (int)(p - lpString);
|
||||
}
|
||||
|
||||
int lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
|
||||
{
|
||||
return strcmp(lpString1, lpString2);
|
||||
}
|
||||
|
||||
int lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
|
||||
{
|
||||
WCHAR value1, value2;
|
||||
|
||||
while (*lpString1 && (*lpString1 == *lpString2))
|
||||
{
|
||||
lpString1++;
|
||||
lpString2++;
|
||||
}
|
||||
|
||||
Data_Read_UINT16(lpString1, value1);
|
||||
Data_Read_UINT16(lpString2, value2);
|
||||
return value1 - value2;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
size_t ConvertLineEndingToLF(char* str, size_t size)
|
||||
|
|
|
@ -120,8 +120,8 @@ HRESULT PATH_ALLOC_COMBINE(PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags
|
|||
if (!pszPathIn)
|
||||
return E_FAIL; /* valid but not implemented, see top comment */
|
||||
|
||||
pszPathInLength = lstrlenA(pszPathIn);
|
||||
pszMoreLength = lstrlenA(pszMore);
|
||||
pszPathInLength = strlen(pszPathIn);
|
||||
pszMoreLength = strlen(pszMore);
|
||||
|
||||
/* prevent segfaults - the complete implementation below is buggy */
|
||||
if (pszPathInLength < 3)
|
||||
|
|
|
@ -21,8 +21,8 @@ HRESULT PATH_CCH_ADD_EXTENSION(PWSTR pszPath, size_t cchPath, PCWSTR pszExt)
|
|||
if (!pszExt)
|
||||
return E_INVALIDARG;
|
||||
|
||||
pszExtLength = lstrlenW(pszExt);
|
||||
pszPathLength = lstrlenW(pszPath);
|
||||
pszExtLength = _wcslen(pszExt);
|
||||
pszPathLength = _wcslen(pszPath);
|
||||
bExtDot = (pszExt[0] == '.') ? TRUE : FALSE;
|
||||
|
||||
pDot = _wcsrchr(pszPath, '.');
|
||||
|
@ -66,8 +66,8 @@ HRESULT PATH_CCH_ADD_EXTENSION(PSTR pszPath, size_t cchPath, PCSTR pszExt)
|
|||
if (!pszExt)
|
||||
return E_INVALIDARG;
|
||||
|
||||
pszExtLength = lstrlenA(pszExt);
|
||||
pszPathLength = lstrlenA(pszPath);
|
||||
pszExtLength = strlen(pszExt);
|
||||
pszPathLength = strlen(pszPath);
|
||||
bExtDot = (pszExt[0] == '.') ? TRUE : FALSE;
|
||||
|
||||
pDot = strrchr(pszPath, '.');
|
||||
|
|
|
@ -14,7 +14,7 @@ HRESULT PATH_CCH_ADD_SEPARATOR(PWSTR pszPath, size_t cchPath)
|
|||
if (!pszPath)
|
||||
return E_INVALIDARG;
|
||||
|
||||
pszPathLength = lstrlenW(pszPath);
|
||||
pszPathLength = _wcslen(pszPath);
|
||||
|
||||
if (pszPath[pszPathLength - 1] == CUR_PATH_SEPARATOR_CHR)
|
||||
return S_FALSE;
|
||||
|
@ -39,7 +39,7 @@ HRESULT PATH_CCH_ADD_SEPARATOR(PSTR pszPath, size_t cchPath)
|
|||
if (!pszPath)
|
||||
return E_INVALIDARG;
|
||||
|
||||
pszPathLength = lstrlenA(pszPath);
|
||||
pszPathLength = strlen(pszPath);
|
||||
|
||||
if (pszPath[pszPathLength - 1] == CUR_PATH_SEPARATOR_CHR)
|
||||
return S_FALSE;
|
||||
|
|
|
@ -15,7 +15,7 @@ HRESULT PATH_CCH_ADD_SEPARATOR_EX(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
|
|||
if (!pszPath)
|
||||
return E_INVALIDARG;
|
||||
|
||||
pszPathLength = lstrlenW(pszPath);
|
||||
pszPathLength = _wcslen(pszPath);
|
||||
|
||||
if (pszPath[pszPathLength - 1] == CUR_PATH_SEPARATOR_CHR)
|
||||
return S_FALSE;
|
||||
|
@ -41,7 +41,7 @@ HRESULT PATH_CCH_ADD_SEPARATOR_EX(PSTR pszPath, size_t cchPath, PSTR* ppszEnd,
|
|||
if (!pszPath)
|
||||
return E_INVALIDARG;
|
||||
|
||||
pszPathLength = lstrlenA(pszPath);
|
||||
pszPathLength = strlen(pszPath);
|
||||
|
||||
if (pszPath[pszPathLength - 1] == CUR_PATH_SEPARATOR_CHR)
|
||||
return S_FALSE;
|
||||
|
|
|
@ -24,8 +24,8 @@ HRESULT PATH_CCH_APPEND(PWSTR pszPath, size_t cchPath, PCWSTR pszMore)
|
|||
if (cchPath == 0 || cchPath > PATHCCH_MAX_CCH)
|
||||
return E_INVALIDARG;
|
||||
|
||||
pszMoreLength = lstrlenW(pszMore);
|
||||
pszPathLength = lstrlenW(pszPath);
|
||||
pszMoreLength = _wcslen(pszMore);
|
||||
pszPathLength = _wcslen(pszPath);
|
||||
|
||||
pathBackslash = (pszPath[pszPathLength - 1] == CUR_PATH_SEPARATOR_CHR) ? TRUE : FALSE;
|
||||
moreBackslash = (pszMore[0] == CUR_PATH_SEPARATOR_CHR) ? TRUE : FALSE;
|
||||
|
@ -84,11 +84,11 @@ HRESULT PATH_CCH_APPEND(PSTR pszPath, size_t cchPath, PCSTR pszMore)
|
|||
if (cchPath == 0 || cchPath > PATHCCH_MAX_CCH)
|
||||
return E_INVALIDARG;
|
||||
|
||||
pszPathLength = lstrlenA(pszPath);
|
||||
pszPathLength = strlen(pszPath);
|
||||
if (pszPathLength > 0)
|
||||
pathBackslash = (pszPath[pszPathLength - 1] == CUR_PATH_SEPARATOR_CHR) ? TRUE : FALSE;
|
||||
|
||||
pszMoreLength = lstrlenA(pszMore);
|
||||
pszMoreLength = strlen(pszMore);
|
||||
if (pszMoreLength > 0)
|
||||
moreBackslash = (pszMore[0] == CUR_PATH_SEPARATOR_CHR) ? TRUE : FALSE;
|
||||
|
||||
|
|
|
@ -738,7 +738,7 @@ HRESULT PathCchStripPrefixW(PWSTR pszPath, size_t cchPath)
|
|||
if (cchPath < 6)
|
||||
return S_FALSE;
|
||||
|
||||
rc = (lstrlenW(&pszPath[4]) + 1);
|
||||
rc = (_wcslen(&pszPath[4]) + 1);
|
||||
if ((rc < 0) || ((INT64)cchPath < rc))
|
||||
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
|
||||
|
|
|
@ -994,7 +994,7 @@ static const SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameW(const
|
|||
|
||||
for (index = 0; index < (int)cPackages; index++)
|
||||
{
|
||||
if (lstrcmpW(Name, SecurityFunctionTableW_NAME_LIST[index].Name) == 0)
|
||||
if (_wcscmp(Name, SecurityFunctionTableW_NAME_LIST[index].Name) == 0)
|
||||
{
|
||||
return (const SecurityFunctionTableW*)SecurityFunctionTableW_NAME_LIST[index]
|
||||
.SecurityFunctionTable;
|
||||
|
@ -1164,7 +1164,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityPackageInfoW(SEC_WCHAR* pszP
|
|||
|
||||
for (index = 0; index < (int)cPackages; index++)
|
||||
{
|
||||
if (lstrcmpW(pszPackageName, SecPkgInfoW_LIST[index]->Name) == 0)
|
||||
if (_wcscmp(pszPackageName, SecPkgInfoW_LIST[index]->Name) == 0)
|
||||
{
|
||||
size = sizeof(SecPkgInfoW);
|
||||
pPackageInfo =
|
||||
|
|
Loading…
Reference in New Issue