~ubuntu-branches/ubuntu/vivid/freerdp/vivid

« back to all changes in this revision

Viewing changes to winpr/include/winpr/string.h

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-11-11 12:20:50 UTC
  • mfrom: (1.2.5)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20141111122050-7z628f4ab38qxad5
Tags: upstream-1.1.0~git20140921.1.440916e+dfsg1
ImportĀ upstreamĀ versionĀ 1.1.0~git20140921.1.440916e+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * WinPR: Windows Portable Runtime
 
3
 * String Manipulation (CRT)
 
4
 *
 
5
 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 
6
 *
 
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
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
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.
 
18
 */
 
19
 
 
20
#ifndef WINPR_CRT_STRING_H
 
21
#define WINPR_CRT_STRING_H
 
22
 
 
23
#include <wchar.h>
 
24
#include <string.h>
 
25
#include <winpr/winpr.h>
 
26
#include <winpr/wtypes.h>
 
27
 
 
28
#ifdef __cplusplus
 
29
extern "C" {
 
30
#endif
 
31
 
 
32
#ifndef _WIN32
 
33
 
 
34
#define CSTR_LESS_THAN                  1
 
35
#define CSTR_EQUAL                      2
 
36
#define CSTR_GREATER_THAN               3
 
37
 
 
38
#define CP_ACP                          0
 
39
#define CP_OEMCP                        1
 
40
#define CP_MACCP                        2
 
41
#define CP_THREAD_ACP                   3
 
42
#define CP_SYMBOL                       42
 
43
#define CP_UTF7                         65000
 
44
#define CP_UTF8                         65001
 
45
 
 
46
#define MB_PRECOMPOSED                  0x00000001
 
47
#define MB_COMPOSITE                    0x00000002
 
48
#define MB_USEGLYPHCHARS                0x00000004
 
49
#define MB_ERR_INVALID_CHARS            0x00000008
 
50
 
 
51
WINPR_API char* _strdup(const char* strSource);
 
52
WINPR_API WCHAR* _wcsdup(const WCHAR* strSource);
 
53
 
 
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);
 
56
 
 
57
WINPR_API int _wcscmp(const WCHAR* string1, const WCHAR* string2);
 
58
 
 
59
WINPR_API size_t _wcslen(const WCHAR* str);
 
60
WINPR_API WCHAR* _wcschr(const WCHAR* str, WCHAR c);
 
61
 
 
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);
 
64
 
 
65
WINPR_API LPSTR CharUpperA(LPSTR lpsz);
 
66
WINPR_API LPWSTR CharUpperW(LPWSTR lpsz);
 
67
 
 
68
#ifdef UNICODE
 
69
#define CharUpper       CharUpperW
 
70
#else
 
71
#define CharUpper       CharUpperA
 
72
#endif
 
73
 
 
74
WINPR_API DWORD CharUpperBuffA(LPSTR lpsz, DWORD cchLength);
 
75
WINPR_API DWORD CharUpperBuffW(LPWSTR lpsz, DWORD cchLength);
 
76
 
 
77
#ifdef UNICODE
 
78
#define CharUpperBuff   CharUpperBuffW
 
79
#else
 
80
#define CharUpperBuff   CharUpperBuffA
 
81
#endif
 
82
 
 
83
WINPR_API LPSTR CharLowerA(LPSTR lpsz);
 
84
WINPR_API LPWSTR CharLowerW(LPWSTR lpsz);
 
85
 
 
86
#ifdef UNICODE
 
87
#define CharLower       CharLowerW
 
88
#else
 
89
#define CharLower       CharLowerA
 
90
#endif
 
91
 
 
92
WINPR_API DWORD CharLowerBuffA(LPSTR lpsz, DWORD cchLength);
 
93
WINPR_API DWORD CharLowerBuffW(LPWSTR lpsz, DWORD cchLength);
 
94
 
 
95
#ifdef UNICODE
 
96
#define CharLowerBuff   CharLowerBuffW
 
97
#else
 
98
#define CharLowerBuff   CharLowerBuffA
 
99
#endif
 
100
 
 
101
WINPR_API BOOL IsCharAlphaA(CHAR ch);
 
102
WINPR_API BOOL IsCharAlphaW(WCHAR ch);
 
103
 
 
104
#ifdef UNICODE
 
105
#define IsCharAlpha     IsCharAlphaW
 
106
#else
 
107
#define IsCharAlpha     IsCharAlphaA
 
108
#endif
 
109
 
 
110
WINPR_API BOOL IsCharAlphaNumericA(CHAR ch);
 
111
WINPR_API BOOL IsCharAlphaNumericW(WCHAR ch);
 
112
 
 
113
#ifdef UNICODE
 
114
#define IsCharAlphaNumeric      IsCharAlphaNumericW
 
115
#else
 
116
#define IsCharAlphaNumeric      IsCharAlphaNumericA
 
117
#endif
 
118
 
 
119
WINPR_API BOOL IsCharUpperA(CHAR ch);
 
120
WINPR_API BOOL IsCharUpperW(WCHAR ch);
 
121
 
 
122
#ifdef UNICODE
 
123
#define IsCharUpper     IsCharUpperW
 
124
#else
 
125
#define IsCharUpper     IsCharUpperA
 
126
#endif
 
127
 
 
128
WINPR_API BOOL IsCharLowerA(CHAR ch);
 
129
WINPR_API BOOL IsCharLowerW(WCHAR ch);
 
130
 
 
131
#ifdef UNICODE
 
132
#define IsCharLower     IsCharLowerW
 
133
#else
 
134
#define IsCharLower     IsCharLowerA
 
135
#endif
 
136
 
 
137
WINPR_API int lstrlenA(LPCSTR lpString);
 
138
WINPR_API int lstrlenW(LPCWSTR lpString);
 
139
 
 
140
#ifdef UNICODE
 
141
#define lstrlen         lstrlenW
 
142
#else
 
143
#define lstrlen         lstrlenA
 
144
#endif
 
145
 
 
146
WINPR_API int lstrcmpA(LPCSTR lpString1, LPCSTR lpString2);
 
147
WINPR_API int lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2);
 
148
 
 
149
#ifdef UNICODE
 
150
#define lstrcmp         lstrcmpW
 
151
#else
 
152
#define lstrcmp         lstrcmpA
 
153
#endif
 
154
 
 
155
#define  sprintf_s      snprintf
 
156
 
 
157
/* Unicode Conversion */
 
158
 
 
159
WINPR_API int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
 
160
                int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
 
161
 
 
162
WINPR_API int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar,
 
163
                LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
 
164
 
 
165
#else
 
166
 
 
167
#define _wcscmp         wcscmp
 
168
#define _wcslen         wcslen
 
169
#define _wcschr         wcschr
 
170
 
 
171
#endif
 
172
 
 
173
/* Extended API */
 
174
 
 
175
WINPR_API int ConvertToUnicode(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
 
176
                int cbMultiByte, LPWSTR* lpWideCharStr, int cchWideChar);
 
177
 
 
178
WINPR_API int ConvertFromUnicode(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar,
 
179
                LPSTR* lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
 
180
 
 
181
#ifdef __cplusplus
 
182
}
 
183
#endif
 
184
 
 
185
#endif /* WINPR_CRT_STRING_H */