|
Packit Service |
fa4841 |
/**
|
|
Packit Service |
fa4841 |
* WinPR: Windows Portable Runtime
|
|
Packit Service |
fa4841 |
* String Manipulation (CRT)
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
Packit Service |
fa4841 |
* Copyright 2016 David PHAM-VAN <d.phamvan@inuvika.com>
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
Packit Service |
fa4841 |
* you may not use this file except in compliance with the License.
|
|
Packit Service |
fa4841 |
* You may obtain a copy of the License at
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit Service |
fa4841 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit Service |
fa4841 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit Service |
fa4841 |
* See the License for the specific language governing permissions and
|
|
Packit Service |
fa4841 |
* limitations under the License.
|
|
Packit Service |
fa4841 |
*/
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifndef WINPR_CRT_STRING_H
|
|
Packit Service |
fa4841 |
#define WINPR_CRT_STRING_H
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#include <wchar.h>
|
|
Packit Service |
fa4841 |
#include <string.h>
|
|
Packit Service |
fa4841 |
#include <winpr/winpr.h>
|
|
Packit Service |
fa4841 |
#include <winpr/wtypes.h>
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef __cplusplus
|
|
Packit Service |
b1ea74 |
extern "C"
|
|
Packit Service |
b1ea74 |
{
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifndef _WIN32
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
#define CSTR_LESS_THAN 1
|
|
Packit Service |
b1ea74 |
#define CSTR_EQUAL 2
|
|
Packit Service |
b1ea74 |
#define CSTR_GREATER_THAN 3
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
#define CP_ACP 0
|
|
Packit Service |
b1ea74 |
#define CP_OEMCP 1
|
|
Packit Service |
b1ea74 |
#define CP_MACCP 2
|
|
Packit Service |
b1ea74 |
#define CP_THREAD_ACP 3
|
|
Packit Service |
b1ea74 |
#define CP_SYMBOL 42
|
|
Packit Service |
b1ea74 |
#define CP_UTF7 65000
|
|
Packit Service |
b1ea74 |
#define CP_UTF8 65001
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
#define MB_PRECOMPOSED 0x00000001
|
|
Packit Service |
b1ea74 |
#define MB_COMPOSITE 0x00000002
|
|
Packit Service |
b1ea74 |
#define MB_USEGLYPHCHARS 0x00000004
|
|
Packit Service |
b1ea74 |
#define MB_ERR_INVALID_CHARS 0x00000008
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API char* _strdup(const char* strSource);
|
|
Packit Service |
b1ea74 |
WINPR_API WCHAR* _wcsdup(const WCHAR* strSource);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API int _stricmp(const char* string1, const char* string2);
|
|
Packit Service |
b1ea74 |
WINPR_API int _strnicmp(const char* string1, const char* string2, size_t count);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API int _wcscmp(const WCHAR* string1, const WCHAR* string2);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API size_t _wcslen(const WCHAR* str);
|
|
Packit Service |
b1ea74 |
WINPR_API size_t _wcsnlen(const WCHAR* str, size_t maxNumberOfElements);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API WCHAR* _wcschr(const WCHAR* str, WCHAR c);
|
|
Packit Service |
b1ea74 |
WINPR_API WCHAR* _wcsrchr(const WCHAR* str, WCHAR c);
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
WINPR_API char* strtok_s(char* strToken, const char* strDelimit, char** context);
|
|
Packit Service |
b1ea74 |
WINPR_API WCHAR* wcstok_s(WCHAR* strToken, const WCHAR* strDelimit, WCHAR** context);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#else
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
#define _wcscmp wcscmp
|
|
Packit Service |
b1ea74 |
#define _wcslen wcslen
|
|
Packit Service |
b1ea74 |
#define _wcsnlen wcsnlen
|
|
Packit Service |
b1ea74 |
#define _wcschr wcschr
|
|
Packit Service |
b1ea74 |
#define _wcsrchr wcsrchr
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#if !defined(_WIN32) || defined(_UWP)
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API LPSTR CharUpperA(LPSTR lpsz);
|
|
Packit Service |
b1ea74 |
WINPR_API LPWSTR CharUpperW(LPWSTR lpsz);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef UNICODE
|
|
Packit Service |
b1ea74 |
#define CharUpper CharUpperW
|
|
Packit Service |
fa4841 |
#else
|
|
Packit Service |
b1ea74 |
#define CharUpper CharUpperA
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API DWORD CharUpperBuffA(LPSTR lpsz, DWORD cchLength);
|
|
Packit Service |
b1ea74 |
WINPR_API DWORD CharUpperBuffW(LPWSTR lpsz, DWORD cchLength);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef UNICODE
|
|
Packit Service |
b1ea74 |
#define CharUpperBuff CharUpperBuffW
|
|
Packit Service |
fa4841 |
#else
|
|
Packit Service |
b1ea74 |
#define CharUpperBuff CharUpperBuffA
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API LPSTR CharLowerA(LPSTR lpsz);
|
|
Packit Service |
b1ea74 |
WINPR_API LPWSTR CharLowerW(LPWSTR lpsz);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef UNICODE
|
|
Packit Service |
b1ea74 |
#define CharLower CharLowerW
|
|
Packit Service |
fa4841 |
#else
|
|
Packit Service |
b1ea74 |
#define CharLower CharLowerA
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API DWORD CharLowerBuffA(LPSTR lpsz, DWORD cchLength);
|
|
Packit Service |
b1ea74 |
WINPR_API DWORD CharLowerBuffW(LPWSTR lpsz, DWORD cchLength);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef UNICODE
|
|
Packit Service |
b1ea74 |
#define CharLowerBuff CharLowerBuffW
|
|
Packit Service |
fa4841 |
#else
|
|
Packit Service |
b1ea74 |
#define CharLowerBuff CharLowerBuffA
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL IsCharAlphaA(CHAR ch);
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL IsCharAlphaW(WCHAR ch);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef UNICODE
|
|
Packit Service |
b1ea74 |
#define IsCharAlpha IsCharAlphaW
|
|
Packit Service |
fa4841 |
#else
|
|
Packit Service |
b1ea74 |
#define IsCharAlpha IsCharAlphaA
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL IsCharAlphaNumericA(CHAR ch);
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL IsCharAlphaNumericW(WCHAR ch);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef UNICODE
|
|
Packit Service |
b1ea74 |
#define IsCharAlphaNumeric IsCharAlphaNumericW
|
|
Packit Service |
fa4841 |
#else
|
|
Packit Service |
b1ea74 |
#define IsCharAlphaNumeric IsCharAlphaNumericA
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL IsCharUpperA(CHAR ch);
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL IsCharUpperW(WCHAR ch);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef UNICODE
|
|
Packit Service |
b1ea74 |
#define IsCharUpper IsCharUpperW
|
|
Packit Service |
fa4841 |
#else
|
|
Packit Service |
b1ea74 |
#define IsCharUpper IsCharUpperA
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL IsCharLowerA(CHAR ch);
|
|
Packit Service |
b1ea74 |
WINPR_API BOOL IsCharLowerW(WCHAR ch);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef UNICODE
|
|
Packit Service |
b1ea74 |
#define IsCharLower IsCharLowerW
|
|
Packit Service |
fa4841 |
#else
|
|
Packit Service |
b1ea74 |
#define IsCharLower IsCharLowerA
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API int lstrlenA(LPCSTR lpString);
|
|
Packit Service |
b1ea74 |
WINPR_API int lstrlenW(LPCWSTR lpString);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef UNICODE
|
|
Packit Service |
b1ea74 |
#define lstrlen lstrlenW
|
|
Packit Service |
fa4841 |
#else
|
|
Packit Service |
b1ea74 |
#define lstrlen lstrlenA
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API int lstrcmpA(LPCSTR lpString1, LPCSTR lpString2);
|
|
Packit Service |
b1ea74 |
WINPR_API int lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef UNICODE
|
|
Packit Service |
b1ea74 |
#define lstrcmp lstrcmpW
|
|
Packit Service |
fa4841 |
#else
|
|
Packit Service |
b1ea74 |
#define lstrcmp lstrcmpA
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifndef _WIN32
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
#define sprintf_s snprintf
|
|
Packit Service |
b1ea74 |
#define _snprintf snprintf
|
|
Packit Service |
fa4841 |
#define _scprintf(...) snprintf(NULL, 0, __VA_ARGS__)
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
#define _scprintf(...) snprintf(NULL, 0, __VA_ARGS__)
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
/* Unicode Conversion */
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
|
|
Packit Service |
b1ea74 |
int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr,
|
|
Packit Service |
b1ea74 |
int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte,
|
|
Packit Service |
b1ea74 |
LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
/* Extended API */
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API int ConvertToUnicode(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
|
|
Packit Service |
b1ea74 |
int cbMultiByte, LPWSTR* lpWideCharStr, int cchWideChar);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API int ConvertFromUnicode(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr,
|
|
Packit Service |
b1ea74 |
int cchWideChar, LPSTR* lpMultiByteStr, int cbMultiByte,
|
|
Packit Service |
b1ea74 |
LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API void ByteSwapUnicode(WCHAR* wstr, int length);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API int ConvertLineEndingToLF(char* str, int size);
|
|
Packit Service |
b1ea74 |
WINPR_API char* ConvertLineEndingToCRLF(const char* str, int* size);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API char* StrSep(char** stringp, const char* delim);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WINPR_API INT64 GetLine(char** lineptr, size_t* size, FILE* stream);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef __cplusplus
|
|
Packit Service |
fa4841 |
}
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#endif /* WINPR_CRT_STRING_H */
|