ReactOS  0.4.14-dev-583-g2a1ba2c
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  */
16 int
17 WINAPI
18 lstrcmpA(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  */
40 int
41 WINAPI
42 lstrcmpiA(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  */
64 LPSTR
65 WINAPI
66 lstrcpynA(LPSTR lpString1, LPCSTR lpString2, int iMaxLength)
67 {
68  LPSTR d = lpString1;
69  LPCSTR s = lpString2;
70  UINT count = iMaxLength;
71  LPSTR Ret = NULL;
72 
73  _SEH2_TRY
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  }
89  _SEH2_END;
90 
91  return Ret;
92 }
93 
94 
95 /*
96  * @implemented
97  */
98 LPSTR
99 WINAPI
100 lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
101 {
102  LPSTR Ret = NULL;
103 
104  _SEH2_TRY
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  */
121 LPSTR
122 WINAPI
123 lstrcatA(LPSTR lpString1, LPCSTR lpString2)
124 {
125  LPSTR Ret = NULL;
126 
127  _SEH2_TRY
128  {
129  Ret = strcat(lpString1, lpString2);
130  }
132  {
133  }
134  _SEH2_END;
135 
136  return Ret;
137 }
138 
139 
140 /*
141  * @implemented
142  */
143 int
144 WINAPI
145 lstrlenA(LPCSTR lpString)
146 {
147  INT Ret = 0;
148 
149  if (lpString == NULL)
150  return 0;
151 
152  _SEH2_TRY
153  {
154  Ret = strlen(lpString);
155  }
157  {
158  }
159  _SEH2_END;
160 
161  return Ret;
162 }
163 
164 
165 /*
166  * @implemented
167  */
168 int
169 WINAPI
170 lstrcmpW(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  */
192 int
193 WINAPI
194 lstrcmpiW(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  */
216 LPWSTR
217 WINAPI
218 lstrcpynW(LPWSTR lpString1, LPCWSTR lpString2, int iMaxLength)
219 {
220  LPWSTR d = lpString1;
221  LPCWSTR s = lpString2;
222  UINT count = iMaxLength;
223  LPWSTR Ret = NULL;
224 
225  _SEH2_TRY
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  */
250 LPWSTR
251 WINAPI
252 lstrcpyW(LPWSTR lpString1, LPCWSTR lpString2)
253 {
254  LPWSTR Ret = NULL;
255 
256  _SEH2_TRY
257  {
258  Ret = wcscpy(lpString1, lpString2);
259  }
261  {
262  }
263  _SEH2_END;
264 
265  return Ret;
266 }
267 
268 
269 /*
270  * @implemented
271  */
272 LPWSTR
273 WINAPI
274 lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
275 {
276  LPWSTR Ret = NULL;
277 
278  _SEH2_TRY
279  {
280  Ret = wcscat(lpString1, lpString2);
281  }
283  {
284  }
285  _SEH2_END;
286 
287  return Ret;
288 }
289 
290 
291 /*
292  * @implemented
293  */
294 int
295 WINAPI
296 lstrlenW(LPCWSTR lpString)
297 {
298  INT Ret = 0;
299 
300  if (lpString == NULL)
301  return 0;
302 
303  _SEH2_TRY
304  {
305  Ret = wcslen(lpString);
306  }
308  {
309  }
310  _SEH2_END;
311 
312  return Ret;
313 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
LPSTR WINAPI lstrcpynA(LPSTR lpString1, LPCSTR lpString2, int iMaxLength)
Definition: lstring.c:66
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LPWSTR WINAPI lstrcpynW(LPWSTR lpString1, LPCWSTR lpString2, int iMaxLength)
Definition: lstring.c:218
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
GLuint GLuint GLsizei count
Definition: gl.h:1545
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
#define NORM_IGNORECASE
Definition: winnls.h:173
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:56
_SEH2_TRY
Definition: create.c:4250
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
_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:426
const char * LPCSTR
Definition: xmlstorage.h:183
INT WINAPI CompareStringA(LCID lcid, DWORD flags, LPCSTR str1, INT len1, LPCSTR str2, INT len2)
Definition: lang.c:2299
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: lang.c:2275
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define d
Definition: ke_i.h:81
#define WINAPI
Definition: msvc.h:6
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
LPWSTR WINAPI lstrcpyW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:252
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
GLdouble s
Definition: gl.h:2039
_SEH2_END
Definition: create.c:4424
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
unsigned int UINT
Definition: ndis.h:50
int WINAPI lstrlenW(LPCWSTR lpString)
Definition: lstring.c:296
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LCID WINAPI GetThreadLocale(void)
Definition: lang.c:1449