2
* WinPR: Windows Portable Runtime
3
* String Manipulation (CRT)
5
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7
* Licensed under the Apache License, Version 2.0 (the "License");
8
* you may not use this file except in compliance with the License.
9
* You may obtain a copy of the License at
11
* http://www.apache.org/licenses/LICENSE-2.0
13
* Unless required by applicable law or agreed to in writing, software
14
* distributed under the License is distributed on an "AS IS" BASIS,
15
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
* See the License for the specific language governing permissions and
17
* limitations under the License.
20
#ifndef WINPR_CRT_STRING_H
21
#define WINPR_CRT_STRING_H
25
#include <winpr/winpr.h>
26
#include <winpr/wtypes.h>
34
#define CSTR_LESS_THAN 1
36
#define CSTR_GREATER_THAN 3
41
#define CP_THREAD_ACP 3
46
#define MB_PRECOMPOSED 0x00000001
47
#define MB_COMPOSITE 0x00000002
48
#define MB_USEGLYPHCHARS 0x00000004
49
#define MB_ERR_INVALID_CHARS 0x00000008
51
WINPR_API char* _strdup(const char* strSource);
52
WINPR_API WCHAR* _wcsdup(const WCHAR* strSource);
54
WINPR_API int _stricmp(const char* string1, const char* string2);
55
WINPR_API int _strnicmp(const char* string1, const char* string2, size_t count);
57
WINPR_API int _wcscmp(const WCHAR* string1, const WCHAR* string2);
59
WINPR_API size_t _wcslen(const WCHAR* str);
60
WINPR_API WCHAR* _wcschr(const WCHAR* str, WCHAR c);
62
WINPR_API char* strtok_s(char* strToken, const char* strDelimit, char** context);
63
WINPR_API WCHAR* wcstok_s(WCHAR* strToken, const WCHAR* strDelimit, WCHAR** context);
65
WINPR_API LPSTR CharUpperA(LPSTR lpsz);
66
WINPR_API LPWSTR CharUpperW(LPWSTR lpsz);
69
#define CharUpper CharUpperW
71
#define CharUpper CharUpperA
74
WINPR_API DWORD CharUpperBuffA(LPSTR lpsz, DWORD cchLength);
75
WINPR_API DWORD CharUpperBuffW(LPWSTR lpsz, DWORD cchLength);
78
#define CharUpperBuff CharUpperBuffW
80
#define CharUpperBuff CharUpperBuffA
83
WINPR_API LPSTR CharLowerA(LPSTR lpsz);
84
WINPR_API LPWSTR CharLowerW(LPWSTR lpsz);
87
#define CharLower CharLowerW
89
#define CharLower CharLowerA
92
WINPR_API DWORD CharLowerBuffA(LPSTR lpsz, DWORD cchLength);
93
WINPR_API DWORD CharLowerBuffW(LPWSTR lpsz, DWORD cchLength);
96
#define CharLowerBuff CharLowerBuffW
98
#define CharLowerBuff CharLowerBuffA
101
WINPR_API BOOL IsCharAlphaA(CHAR ch);
102
WINPR_API BOOL IsCharAlphaW(WCHAR ch);
105
#define IsCharAlpha IsCharAlphaW
107
#define IsCharAlpha IsCharAlphaA
110
WINPR_API BOOL IsCharAlphaNumericA(CHAR ch);
111
WINPR_API BOOL IsCharAlphaNumericW(WCHAR ch);
114
#define IsCharAlphaNumeric IsCharAlphaNumericW
116
#define IsCharAlphaNumeric IsCharAlphaNumericA
119
WINPR_API BOOL IsCharUpperA(CHAR ch);
120
WINPR_API BOOL IsCharUpperW(WCHAR ch);
123
#define IsCharUpper IsCharUpperW
125
#define IsCharUpper IsCharUpperA
128
WINPR_API BOOL IsCharLowerA(CHAR ch);
129
WINPR_API BOOL IsCharLowerW(WCHAR ch);
132
#define IsCharLower IsCharLowerW
134
#define IsCharLower IsCharLowerA
137
WINPR_API int lstrlenA(LPCSTR lpString);
138
WINPR_API int lstrlenW(LPCWSTR lpString);
141
#define lstrlen lstrlenW
143
#define lstrlen lstrlenA
146
WINPR_API int lstrcmpA(LPCSTR lpString1, LPCSTR lpString2);
147
WINPR_API int lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2);
150
#define lstrcmp lstrcmpW
152
#define lstrcmp lstrcmpA
155
#define sprintf_s snprintf
157
/* Unicode Conversion */
159
WINPR_API int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
160
int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
162
WINPR_API int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar,
163
LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
167
#define _wcscmp wcscmp
168
#define _wcslen wcslen
169
#define _wcschr wcschr
175
WINPR_API int ConvertToUnicode(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
176
int cbMultiByte, LPWSTR* lpWideCharStr, int cchWideChar);
178
WINPR_API int ConvertFromUnicode(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar,
179
LPSTR* lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
185
#endif /* WINPR_CRT_STRING_H */