wmic: Convert integer property values to BSTR.
[wine/wine-gecko.git] / dlls / kernel32 / string.c
blob120c868b70f0754d066a182126498fd769121d02
1 /*
2 * Kernel string functions
4 * Copyright 1993 Yngvi Sigurjonsson
5 * Copyright 1996 Alexandre Julliard
6 * Copyright 2001 Dmitry Timoshkov for CodeWeavers
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
24 #include "wine/port.h"
26 #include <ctype.h>
27 #include <stdarg.h>
28 #include <string.h>
30 #define WINE_NO_INLINE_STRING
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wine/unicode.h"
34 #include "wine/exception.h"
37 /***********************************************************************
38 * lstrcatA (KERNEL32.@)
39 * lstrcat (KERNEL32.@)
41 LPSTR WINAPI lstrcatA( LPSTR dst, LPCSTR src )
43 __TRY
45 strcat( dst, src );
47 __EXCEPT_PAGE_FAULT
49 SetLastError( ERROR_INVALID_PARAMETER );
50 return NULL;
52 __ENDTRY
53 return dst;
57 /***********************************************************************
58 * lstrcatW (KERNEL32.@)
60 LPWSTR WINAPI lstrcatW( LPWSTR dst, LPCWSTR src )
62 __TRY
64 strcatW( dst, src );
66 __EXCEPT_PAGE_FAULT
68 SetLastError( ERROR_INVALID_PARAMETER );
69 return NULL;
71 __ENDTRY
72 return dst;
76 /***********************************************************************
77 * lstrcpyA (KERNEL32.@)
78 * lstrcpy (KERNEL32.@)
80 LPSTR WINAPI lstrcpyA( LPSTR dst, LPCSTR src )
82 __TRY
84 /* this is how Windows does it */
85 memmove( dst, src, strlen(src)+1 );
87 __EXCEPT_PAGE_FAULT
89 SetLastError( ERROR_INVALID_PARAMETER );
90 return NULL;
92 __ENDTRY
93 return dst;
97 /***********************************************************************
98 * lstrcpyW (KERNEL32.@)
100 LPWSTR WINAPI lstrcpyW( LPWSTR dst, LPCWSTR src )
102 __TRY
104 strcpyW( dst, src );
106 __EXCEPT_PAGE_FAULT
108 SetLastError( ERROR_INVALID_PARAMETER );
109 return NULL;
111 __ENDTRY
112 return dst;
116 /***********************************************************************
117 * lstrcpynA (KERNEL32.@)
118 * lstrcpyn (KERNEL32.@)
120 * Note: this function differs from the UNIX strncpy, it _always_ writes
121 * a terminating \0.
123 * Note: n is an INT but Windows treats it as unsigned, and will happily
124 * copy a gazillion chars if n is negative.
126 LPSTR WINAPI lstrcpynA( LPSTR dst, LPCSTR src, INT n )
128 __TRY
130 LPSTR d = dst;
131 LPCSTR s = src;
132 UINT count = n;
134 while ((count > 1) && *s)
136 count--;
137 *d++ = *s++;
139 if (count) *d = 0;
141 __EXCEPT_PAGE_FAULT
143 SetLastError( ERROR_INVALID_PARAMETER );
144 return 0;
146 __ENDTRY
147 return dst;
151 /***********************************************************************
152 * lstrcpynW (KERNEL32.@)
154 * Note: this function differs from the UNIX strncpy, it _always_ writes
155 * a terminating \0
157 * Note: n is an INT but Windows treats it as unsigned, and will happily
158 * copy a gazillion chars if n is negative.
160 LPWSTR WINAPI lstrcpynW( LPWSTR dst, LPCWSTR src, INT n )
162 __TRY
164 LPWSTR d = dst;
165 LPCWSTR s = src;
166 UINT count = n;
168 while ((count > 1) && *s)
170 count--;
171 *d++ = *s++;
173 if (count) *d = 0;
175 __EXCEPT_PAGE_FAULT
177 SetLastError( ERROR_INVALID_PARAMETER );
178 return 0;
180 __ENDTRY
181 return dst;
185 /***********************************************************************
186 * lstrlenA (KERNEL32.@)
187 * lstrlen (KERNEL32.@)
189 INT WINAPI lstrlenA( LPCSTR str )
191 INT ret;
192 __TRY
194 ret = strlen(str);
196 __EXCEPT_PAGE_FAULT
198 SetLastError( ERROR_INVALID_PARAMETER );
199 return 0;
201 __ENDTRY
202 return ret;
206 /***********************************************************************
207 * lstrlenW (KERNEL32.@)
209 INT WINAPI lstrlenW( LPCWSTR str )
211 INT ret;
212 __TRY
214 ret = strlenW(str);
216 __EXCEPT_PAGE_FAULT
218 SetLastError( ERROR_INVALID_PARAMETER );
219 return 0;
221 __ENDTRY
222 return ret;