ReactOS 0.4.15-dev-6694-g4ba8af9
lstring.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: dll/win32/kernel32/winnls/string/lstring.c
5 * PURPOSE: Local string functions
6 * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
7 * UPDATE HISTORY:
8 * Created 01/11/98
9 */
10
11#include <k32.h>
12
13/*
14 * @implemented
15 */
16int
18lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
19{
20 int Result;
21
22 if (lpString1 == lpString2)
23 return 0;
24 if (lpString1 == NULL)
25 return -1;
26 if (lpString2 == NULL)
27 return 1;
28
29 Result = CompareStringA(GetThreadLocale(), 0, lpString1, -1, lpString2, -1);
30 if (Result)
31 Result -= 2;
32
33 return Result;
34}
35
36
37/*
38 * @implemented
39 */
40int
42lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
43{
44 int Result;
45
46 if (lpString1 == lpString2)
47 return 0;
48 if (lpString1 == NULL)
49 return -1;
50 if (lpString2 == NULL)
51 return 1;
52
53 Result = CompareStringA(GetThreadLocale(), NORM_IGNORECASE, lpString1, -1, lpString2, -1);
54 if (Result)
55 Result -= 2;
56
57 return Result;
58}
59
60
61/*
62 * @implemented
63 */
66lstrcpynA(LPSTR lpString1, LPCSTR lpString2, int iMaxLength)
67{
68 LPSTR d = lpString1;
69 LPCSTR s = lpString2;
70 UINT count = iMaxLength;
71 LPSTR Ret = NULL;
72
74 {
75 while ((count > 1) && *s)
76 {
77 count--;
78 *d++ = *s++;
79 }
80
81 if (count)
82 *d = 0;
83
84 Ret = lpString1;
85 }
87 {
88 }
90
91 return Ret;
92}
93
94
95/*
96 * @implemented
97 */
100lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
101{
102 LPSTR Ret = NULL;
103
105 {
106 memmove(lpString1, lpString2, strlen(lpString2) + 1);
107 Ret = lpString1;
108 }
110 {
111 }
112 _SEH2_END;
113
114 return Ret;
115}
116
117
118/*
119 * @implemented
120 */
121LPSTR
122WINAPI
123lstrcatA(LPSTR lpString1, LPCSTR lpString2)
124{
125 LPSTR Ret = NULL;
126
128 {
129 Ret = strcat(lpString1, lpString2);
130 }
132 {
133 }
134 _SEH2_END;
135
136 return Ret;
137}
138
139
140/*
141 * @implemented
142 */
143int
144WINAPI
146{
147 INT Ret = 0;
148
149 if (lpString == NULL)
150 return 0;
151
153 {
154 Ret = strlen(lpString);
155 }
157 {
158 }
159 _SEH2_END;
160
161 return Ret;
162}
163
164
165/*
166 * @implemented
167 */
168int
169WINAPI
170lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
171{
172 int Result;
173
174 if (lpString1 == lpString2)
175 return 0;
176 if (lpString1 == NULL)
177 return -1;
178 if (lpString2 == NULL)
179 return 1;
180
181 Result = CompareStringW(GetThreadLocale(), 0, lpString1, -1, lpString2, -1);
182 if (Result)
183 Result -= 2;
184
185 return Result;
186}
187
188
189/*
190 * @implemented
191 */
192int
193WINAPI
194lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
195{
196 int Result;
197
198 if (lpString1 == lpString2)
199 return 0;
200 if (lpString1 == NULL)
201 return -1;
202 if (lpString2 == NULL)
203 return 1;
204
205 Result = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, lpString1, -1, lpString2, -1);
206 if (Result)
207 Result -= 2;
208
209 return Result;
210}
211
212
213/*
214 * @implemented
215 */
216LPWSTR
217WINAPI
218lstrcpynW(LPWSTR lpString1, LPCWSTR lpString2, int iMaxLength)
219{
220 LPWSTR d = lpString1;
221 LPCWSTR s = lpString2;
222 UINT count = iMaxLength;
223 LPWSTR Ret = NULL;
224
226 {
227 while ((count > 1) && *s)
228 {
229 count--;
230 *d++ = *s++;
231 }
232
233 if (count)
234 *d = 0;
235
236 Ret = lpString1;
237 }
239 {
240 }
241 _SEH2_END;
242
243 return Ret;
244}
245
246
247/*
248 * @implemented
249 */
250LPWSTR
251WINAPI
252lstrcpyW(LPWSTR lpString1, LPCWSTR lpString2)
253{
254 LPWSTR Ret = NULL;
255
257 {
258 Ret = wcscpy(lpString1, lpString2);
259 }
261 {
262 }
263 _SEH2_END;
264
265 return Ret;
266}
267
268
269/*
270 * @implemented
271 */
272LPWSTR
273WINAPI
274lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
275{
276 LPWSTR Ret = NULL;
277
279 {
280 Ret = wcscat(lpString1, lpString2);
281 }
283 {
284 }
285 _SEH2_END;
286
287 return Ret;
288}
289
290
291/*
292 * @implemented
293 */
294int
295WINAPI
297{
298 INT Ret = 0;
299
300 if (lpString == NULL)
301 return 0;
302
304 {
305 Ret = wcslen(lpString);
306 }
308 {
309 }
310 _SEH2_END;
311
312 return Ret;
313}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define NULL
Definition: types.h:112
#define lstrcpynA
Definition: compat.h:751
#define lstrcpyW
Definition: compat.h:749
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
GLdouble s
Definition: gl.h:2039
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define d
Definition: ke_i.h:81
LCID WINAPI GetThreadLocale(void)
Definition: lang.c:1459
INT WINAPI CompareStringA(LCID lcid, DWORD flags, LPCSTR str1, INT len1, LPCSTR str2, INT len2)
Definition: lang.c:2695
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: lang.c:2671
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
unsigned int UINT
Definition: ndis.h:50
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
int32_t INT
Definition: typedefs.h:58
#define WINAPI
Definition: msvc.h:6
#define NORM_IGNORECASE
Definition: winnls.h:176
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185